auto-views-with-ui-schema
Advanced tools
Comparing version 0.2.1 to 0.3.1
@@ -5,4 +5,3 @@ /// <reference types="react" /> | ||
import * as React from 'react'; | ||
import { CoreSchemaMetaSchema } from '../models/json-schema'; | ||
import { UISchema } from '../models/ui-schema'; | ||
import { CoreSchemaMetaSchema, UISchema } from '../models'; | ||
import { ComponentsRepo } from '../repository/components-repo'; | ||
@@ -23,2 +22,4 @@ import { ValidationError } from '../utils'; | ||
schemaPointer?: string; | ||
pick?: string[]; | ||
omit?: string[]; | ||
onChange?: AutoEventHandler; | ||
@@ -25,0 +26,0 @@ onClick?: AutoEventHandler; |
@@ -13,3 +13,3 @@ "use strict"; | ||
const React = require("react"); | ||
const ui_schema_1 = require("../models/ui-schema"); | ||
const models_1 = require("../models"); | ||
const utils_1 = require("../utils"); | ||
@@ -38,3 +38,3 @@ class AutoView extends React.Component { | ||
if (matches.length > 0) { | ||
const override = uiSchema && ui_schema_1.getComponent(uiSchema, components.name, schemaPointer); | ||
const override = uiSchema && models_1.getComponent(uiSchema, components.name, schemaPointer); | ||
const componentRecord = override && | ||
@@ -41,0 +41,0 @@ matches.find(record => record.name === override.name) || |
@@ -7,6 +7,6 @@ /// <reference types="react" /> | ||
} & AutoViewProps; | ||
export declare const AutoFields: ({data, schema: {properties}, uiSchema, pointer, schemaPointer, onChange, render}: AutoFieldsProps) => JSX.Element; | ||
export declare const AutoFields: ({ data, schema, uiSchema, pointer, schemaPointer, pick, omit, onChange, render }: AutoFieldsProps) => JSX.Element | null; | ||
export declare type AutoItemsProps = { | ||
render?(item: React.ReactNode, props: AutoViewProps, index: number): React.ReactNode; | ||
} & AutoViewProps; | ||
export declare const AutoItems: ({data, schema: {items}, uiSchema, pointer, schemaPointer, onChange, render}: AutoItemsProps) => JSX.Element; | ||
export declare const AutoItems: ({ data, schema: { items }, uiSchema, pointer, schemaPointer, onChange, render }: AutoItemsProps) => JSX.Element; |
@@ -7,5 +7,10 @@ "use strict"; | ||
const utils_2 = require("./utils"); | ||
exports.AutoFields = ({ data, schema: { properties = {} }, uiSchema, pointer, schemaPointer, onChange, render = a => a }) => { | ||
const { order } = utils_2.getUIHints(uiSchema, pointer); | ||
const fields = utils_2.orderFields(Object.keys(properties), order); | ||
exports.AutoFields = ({ data, schema, uiSchema, pointer, schemaPointer, pick, omit, onChange, render = a => a }) => { | ||
const { properties } = schema; | ||
if (!properties) { | ||
return null; | ||
} | ||
const { order } = utils_2.getHints(uiSchema, pointer); | ||
const filtered = utils_2.filter(properties, pick, omit); | ||
const fields = utils_2.orderFields(Object.keys(filtered), order); | ||
return (React.createElement(React.Fragment, null, fields.map(key => { | ||
@@ -12,0 +17,0 @@ const itemProps = { |
export * from './auto-view'; | ||
export * from './default-items'; | ||
export { orderFields } from './utils'; | ||
export * from './utils'; |
@@ -8,4 +8,3 @@ "use strict"; | ||
__export(require("./default-items")); | ||
var utils_1 = require("./utils"); | ||
exports.orderFields = utils_1.orderFields; | ||
__export(require("./utils")); | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,6 @@ | ||
import { ComponentOptions, UIHints, UISchema } from '../models/ui-schema'; | ||
import { ComponentOptions, CoreSchemaMetaSchema, UIHints, UISchema } from '../models'; | ||
import { RepoName } from '../repository'; | ||
export declare function getUIHints(uiSchema?: UISchema, pointer?: string): UIHints; | ||
export declare function getHints(uiSchema?: UISchema, pointer?: string): UIHints; | ||
export declare function getComponentOptions(uiSchema: UISchema, repo?: RepoName, pointer?: string): ComponentOptions['options'] | undefined; | ||
export declare function orderFields(source: string[], rules?: string[]): string[]; | ||
export declare function filter(properties: CoreSchemaMetaSchema['properties'], toPick?: string[], toOmit?: string[]): CoreSchemaMetaSchema['properties']; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ui_schema_1 = require("../models/ui-schema"); | ||
function getUIHints(uiSchema, pointer = '') { | ||
const omit = require("lodash.omit"); | ||
const pick = require("lodash.pick"); | ||
const models_1 = require("../models"); | ||
const utils_1 = require("../utils"); | ||
function getHints(uiSchema, pointer = '') { | ||
if (!uiSchema) { | ||
return ui_schema_1.getDefaultHints(); | ||
return models_1.getDefaultHints(); | ||
} | ||
const uiHints = ui_schema_1.getUIHints(uiSchema, pointer); | ||
const uiHints = models_1.getUIHints(uiSchema, pointer); | ||
if (!uiHints) { | ||
return ui_schema_1.getDefaultHints(); | ||
return models_1.getDefaultHints(); | ||
} | ||
return Object.assign({}, ui_schema_1.getDefaultHints(), uiHints); | ||
return Object.assign({}, models_1.getDefaultHints(), uiHints); | ||
} | ||
exports.getUIHints = getUIHints; | ||
exports.getHints = getHints; | ||
function getComponentOptions(uiSchema, repo = '', pointer = '') { | ||
const compOptions = ui_schema_1.getComponent(uiSchema, repo, pointer); | ||
const compOptions = models_1.getComponent(uiSchema, repo, pointer); | ||
return compOptions && compOptions.options; | ||
@@ -27,2 +30,12 @@ } | ||
exports.orderFields = orderFields; | ||
function filter(properties, toPick, toOmit) { | ||
if (properties && utils_1.isStringsArray(toPick)) { | ||
return pick(properties, toPick); | ||
} | ||
if (properties && utils_1.isStringsArray(toOmit)) { | ||
return omit(properties, toOmit); | ||
} | ||
return properties; | ||
} | ||
exports.filter = filter; | ||
//# sourceMappingURL=utils.js.map |
export * from './auto-view'; | ||
export * from './events'; | ||
export * from './repository'; | ||
export * from './models/ui-schema'; | ||
export { CoreSchemaMetaSchema, SimpleTypes } from './models/json-schema'; | ||
export * from './models/'; |
@@ -9,3 +9,3 @@ "use strict"; | ||
__export(require("./repository")); | ||
__export(require("./models/ui-schema")); | ||
__export(require("./models/")); | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,4 @@ | ||
import { CoreSchemaMetaSchema } from './models/json-schema'; | ||
import { CoreSchemaMetaSchema } from './models'; | ||
export declare type SchemaResolver = (id: string) => Promise<CoreSchemaMetaSchema>; | ||
export declare function jsonSchemaResolver(jsonSchema: CoreSchemaMetaSchema, resolver?: SchemaResolver, parentIds?: string[]): Promise<CoreSchemaMetaSchema>; | ||
export declare function fetchByUri(uri: string): Promise<CoreSchemaMetaSchema>; |
/// <reference types="react" /> | ||
import * as React from 'react'; | ||
import { AutoViewProps } from '../auto-view'; | ||
import { CoreSchemaMetaSchema, SimpleTypes } from '../models/json-schema'; | ||
import { CoreSchemaMetaSchema, SimpleTypes } from '../models'; | ||
export declare type JSONPointer = string; | ||
@@ -6,0 +6,0 @@ export declare type RepoName = string; |
@@ -1,2 +0,2 @@ | ||
import { CoreSchemaMetaSchema } from './models/json-schema'; | ||
import { CoreSchemaMetaSchema } from './models'; | ||
import { JSONPointer } from './repository/components-repo'; | ||
@@ -14,1 +14,2 @@ export declare function buildJsonPointer(pointer?: JSONPointer, ...keys: string[]): string; | ||
export declare function formatValidationError(error: any): ValidationError; | ||
export declare function isStringsArray(arr?: string[]): arr is string[]; |
@@ -49,2 +49,6 @@ "use strict"; | ||
exports.formatValidationError = formatValidationError; | ||
function isStringsArray(arr) { | ||
return Boolean(arr && arr.length > 0); | ||
} | ||
exports.isStringsArray = isStringsArray; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "auto-views-with-ui-schema", | ||
"version": "0.2.1", | ||
"version": "0.3.1", | ||
"description": "", | ||
@@ -9,3 +9,3 @@ "main": "./dist/index.js", | ||
"clean": "rimraf ./dist ./lib", | ||
"build": "tsc -p tsconfig.prod.json && stc --srcDir=src --outDir=dist/src --diagnostics", | ||
"build": "run-s clean && tsc -p tsconfig.prod.json && stc --srcDir=src --outDir=dist/src --diagnostics", | ||
"prepublish": "run-p lint build", | ||
@@ -25,2 +25,5 @@ "lint": "tslint \"@(src|test|stories)/**/*.ts?(x)\" -c tslint.json -p tsconfig.json", | ||
"dependencies": { | ||
"@types/lodash.difference": "^4.5.3", | ||
"@types/lodash.find": "^4.6.3", | ||
"@types/lodash.flatten": "^4.4.3", | ||
"@types/storybook__addon-actions": "^3.0.1", | ||
@@ -32,2 +35,7 @@ "@types/storybook__react": "^3.0.5", | ||
"json-pointer": "^0.6.0", | ||
"lodash.difference": "^4.5.0", | ||
"lodash.find": "^4.6.0", | ||
"lodash.flatten": "^4.4.0", | ||
"lodash.omit": "^4.5.0", | ||
"lodash.pick": "^4.4.0", | ||
"prop-types": "^15.6.0" | ||
@@ -42,2 +50,4 @@ }, | ||
"@types/json-pointer": "^1.0.30", | ||
"@types/lodash.omit": "^4.5.3", | ||
"@types/lodash.pick": "^4.4.3", | ||
"@types/material-ui": "^0.18.5", | ||
@@ -71,2 +81,3 @@ "@types/mocha": "^2.2.44", | ||
"react-markdown": "^3.1.0", | ||
"rimraf": "^2.6.2", | ||
"stylable": "^4.0.26", | ||
@@ -79,3 +90,3 @@ "stylable-integration": "^6.0.0", | ||
"tslint-wix-react": "^6.0.3", | ||
"typescript": "~2.5.3", | ||
"typescript": "^2.7.2", | ||
"webpack": "^3.8.1", | ||
@@ -82,0 +93,0 @@ "webpack-dev-server": "^2.9.4" |
@@ -15,3 +15,3 @@ # AutoViews | ||
To address specific `JSONSchema` node `UISchema` uses [JSONPointer](https://tools.ietf.org/html/rfc6901) as key and [ComponentOptions](src/models/ui-schema.ts#L1) as value to tell which component and it's setting to use, or what `UIHints` have to be applied. | ||
To address specific `JSONSchema` node `UISchema` uses [JSONPointer](https://tools.ietf.org/html/rfc6901) as key and [ComponentOptions](src/models/UISchema/UISchema.ts#L19) as value to tell which component and it's setting to use, or what `UIHints` have to be applied. | ||
@@ -18,0 +18,0 @@ ## Autoview Component |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89021
56
793
17
47
2
+ Added@types/lodash.find@^4.6.3
+ Added@types/lodash.flatten@^4.4.3
+ Addedlodash.difference@^4.5.0
+ Addedlodash.find@^4.6.0
+ Addedlodash.flatten@^4.4.0
+ Addedlodash.omit@^4.5.0
+ Addedlodash.pick@^4.4.0
+ Added@types/lodash@4.17.13(transitive)
+ Added@types/lodash.difference@4.5.9(transitive)
+ Added@types/lodash.find@4.6.9(transitive)
+ Added@types/lodash.flatten@4.4.9(transitive)
+ Addedlodash.difference@4.5.0(transitive)
+ Addedlodash.find@4.6.0(transitive)
+ Addedlodash.flatten@4.4.0(transitive)
+ Addedlodash.omit@4.5.0(transitive)
+ Addedlodash.pick@4.4.0(transitive)