react-jsonschema-form
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -106,3 +106,6 @@ "use strict"; | ||
className: "btn-group", | ||
style: { display: "flex", justifyContent: "space-around" } }, | ||
style: { | ||
display: "flex", | ||
justifyContent: "space-around" | ||
} }, | ||
(props.hasMoveUp || props.hasMoveDown) && _react2.default.createElement(IconBtn, { | ||
@@ -394,3 +397,4 @@ icon: "arrow-up", | ||
onFocus = _props3.onFocus, | ||
idPrefix = _props3.idPrefix; | ||
idPrefix = _props3.idPrefix, | ||
rawErrors = _props3.rawErrors; | ||
@@ -439,3 +443,4 @@ var title = schema.title === undefined ? name : schema.title; | ||
formContext: formContext, | ||
formData: formData | ||
formData: formData, | ||
rawErrors: rawErrors | ||
}; | ||
@@ -461,3 +466,4 @@ | ||
_props4$registry = _props4.registry, | ||
registry = _props4$registry === undefined ? (0, _utils.getDefaultRegistry)() : _props4$registry; | ||
registry = _props4$registry === undefined ? (0, _utils.getDefaultRegistry)() : _props4$registry, | ||
rawErrors = _props4.rawErrors; | ||
@@ -492,3 +498,4 @@ var items = this.props.formData; | ||
formContext: formContext, | ||
autofocus: autofocus | ||
autofocus: autofocus, | ||
rawErrors: rawErrors | ||
}); | ||
@@ -510,3 +517,4 @@ } | ||
_props5$registry = _props5.registry, | ||
registry = _props5$registry === undefined ? (0, _utils.getDefaultRegistry)() : _props5$registry; | ||
registry = _props5$registry === undefined ? (0, _utils.getDefaultRegistry)() : _props5$registry, | ||
rawErrors = _props5.rawErrors; | ||
@@ -537,3 +545,4 @@ var title = schema.title || name; | ||
formContext: formContext, | ||
autofocus: autofocus | ||
autofocus: autofocus, | ||
rawErrors: rawErrors | ||
}); | ||
@@ -561,3 +570,4 @@ } | ||
onBlur = _props6.onBlur, | ||
onFocus = _props6.onFocus; | ||
onFocus = _props6.onFocus, | ||
rawErrors = _props6.rawErrors; | ||
@@ -620,3 +630,4 @@ var title = schema.title || name; | ||
TitleField: TitleField, | ||
formContext: formContext | ||
formContext: formContext, | ||
rawErrors: rawErrors | ||
}; | ||
@@ -645,3 +656,4 @@ | ||
onBlur = props.onBlur, | ||
onFocus = props.onFocus; | ||
onFocus = props.onFocus, | ||
rawErrors = props.rawErrors; | ||
var _props7 = this.props, | ||
@@ -685,3 +697,4 @@ disabled = _props7.disabled, | ||
readonly: this.props.readonly, | ||
autofocus: autofocus | ||
autofocus: autofocus, | ||
rawErrors: rawErrors | ||
}), | ||
@@ -688,0 +701,0 @@ className: "array-item", |
@@ -97,2 +97,3 @@ "use strict"; | ||
readonly = _props.readonly, | ||
idPrefix = _props.idPrefix, | ||
onBlur = _props.onBlur, | ||
@@ -159,2 +160,3 @@ onFocus = _props.onFocus, | ||
idSchema: idSchema[name], | ||
idPrefix: idPrefix, | ||
formData: formData[name], | ||
@@ -161,0 +163,0 @@ onChange: _this2.onPropertyChange(name), |
@@ -190,3 +190,3 @@ "use strict"; | ||
errorSchema = props.errorSchema, | ||
idSchema = props.idSchema, | ||
idPrefix = props.idPrefix, | ||
name = props.name, | ||
@@ -202,3 +202,5 @@ required = props.required, | ||
var idSchema = props.idSchema; | ||
var schema = (0, _utils.retrieveSchema)(props.schema, definitions, formData); | ||
idSchema = (0, _utils.mergeObjects)((0, _utils.toIdSchema)(schema, null, definitions, formData, idPrefix), idSchema); | ||
var FieldComponent = getFieldComponent(schema, uiSchema, idSchema, fields); | ||
@@ -240,2 +242,3 @@ var DescriptionField = fields.DescriptionField; | ||
var field = _react2.default.createElement(FieldComponent, _extends({}, props, { | ||
idSchema: idSchema, | ||
schema: schema, | ||
@@ -242,0 +245,0 @@ uiSchema: _extends({}, uiSchema, { classNames: undefined }), |
@@ -165,3 +165,4 @@ "use strict"; | ||
key: "validate", | ||
value: function validate(formData, schema) { | ||
value: function validate(formData) { | ||
var schema = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.schema; | ||
var _props = this.props, | ||
@@ -171,3 +172,7 @@ validate = _props.validate, | ||
return (0, _validate2.default)(formData, schema || this.props.schema, validate, transformErrors); | ||
var _getRegistry = this.getRegistry(), | ||
definitions = _getRegistry.definitions; | ||
var resolvedSchema = (0, _utils.retrieveSchema)(schema, definitions, formData); | ||
return (0, _validate2.default)(formData, resolvedSchema, validate, transformErrors); | ||
} | ||
@@ -225,2 +230,3 @@ }, { | ||
id = _props3.id, | ||
idPrefix = _props3.idPrefix, | ||
className = _props3.className, | ||
@@ -265,2 +271,3 @@ name = _props3.name, | ||
idSchema: idSchema, | ||
idPrefix: idPrefix, | ||
formData: formData, | ||
@@ -267,0 +274,0 @@ onChange: this.onChange, |
@@ -24,2 +24,7 @@ "use strict"; | ||
// exclude the "options" and "schema" ones here. | ||
if (!props.id) { | ||
console.log("No id for", props); | ||
throw new Error("no id for props " + JSON.stringify(props)); | ||
} | ||
var value = props.value, | ||
@@ -26,0 +31,0 @@ readonly = props.readonly, |
@@ -110,6 +110,2 @@ "use strict"; | ||
_this.defaultProps = { | ||
multiple: false | ||
}; | ||
_this.onChange = function (event) { | ||
@@ -116,0 +112,0 @@ var _this$props = _this.props, |
{ | ||
"name": "react-jsonschema-form", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A simple React component capable of building HTML forms out of a JSON schema.", | ||
@@ -11,3 +11,3 @@ "scripts": { | ||
"cs-check": "prettier -l $npm_package_prettierOptions '{playground,src,test}/**/*.js'", | ||
"cs-format": "prettier $npm_package_prettierOptions '{playground,src,test}/**/*.js' --write", | ||
"cs-format": "prettier --jsx-bracket-same-line --trailing-comma es5 --use-tabs false --semi --tab-width 2 '{playground,src,test}/**/*.js' --write", | ||
"dist": "npm run build:lib && npm run build:dist", | ||
@@ -18,2 +18,3 @@ "lint": "eslint src test playground", | ||
"publish-to-npm": "npm run build:readme && npm run dist && npm publish", | ||
"preversion": "npm run build:playground && npm run dist && npm run build:readme && npm run cs-check && npm run lint", | ||
"start": "node devServer.js", | ||
@@ -23,3 +24,3 @@ "tdd": "cross-env NODE_ENV=test mocha --compilers js:babel-register --watch --require ./test/setup-jsdom.js test/**/*_test.js", | ||
}, | ||
"prettierOptions": "--jsx-bracket-same-line --trailing-comma es5 --semi", | ||
"prettierOptions": "--jsx-bracket-same-line --trailing-comma es5 --semi --tab-width 2", | ||
"lint-staged": { | ||
@@ -84,3 +85,3 @@ "{playground,src,test}/**/*.js": [ | ||
"mocha": "^2.5.3", | ||
"prettier": "^1.8.2", | ||
"prettier": "^1.12.0", | ||
"react": "^15.5.0", | ||
@@ -87,0 +88,0 @@ "react-addons-test-utils": "^15.3.2", |
@@ -6,3 +6,3 @@ react-jsonschema-form | ||
A simple [React](http://facebook.github.io/react/) component capable of building HTML forms out of a [JSON schema](http://jsonschema.net/) and using [Bootstrap](http://getbootstrap.com/) semantics by default. | ||
A simple [React](http://facebook.github.io/react/) component capable of building HTML forms out of a [JSON schema](http://json-schema.org/) and using [Bootstrap](http://getbootstrap.com/) semantics by default. | ||
@@ -26,2 +26,3 @@ A [live playground](https://mozilla-services.github.io/react-jsonschema-form/) is hosted on gh-pages. | ||
- [Form field blur events](#form-field-blur-events) | ||
- [Form field focus events](#form-field-focus-events) | ||
- [Form customization](#form-customization) | ||
@@ -47,3 +48,4 @@ - [The uiSchema object](#the-uischema-object) | ||
- [Custom labels for enum fields](#custom-labels-for-enum-fields) | ||
- [Disabled enum fields](#disabled-attribute-for-enum-fields) | ||
- [Alternative JSON-Schema compliant approach](#alternative-json-schema-compliant-approach) | ||
- [Disabled attribute for enum fields](#disabled-attribute-for-enum-fields) | ||
- [Multiple choices list](#multiple-choices-list) | ||
@@ -66,2 +68,3 @@ - [Autogenerated widget ids](#autogenerated-widget-ids) | ||
- [Error List template](#error-list-template) | ||
- [Id prefix](#id-prefix) | ||
- [Custom widgets and fields](#custom-widgets-and-fields) | ||
@@ -71,3 +74,3 @@ - [Custom widget components](#custom-widget-components) | ||
- [Custom widget options](#custom-widget-options) | ||
- [Customizing widgets' text input](#customizing-widgets-text-input) | ||
- [Customizing widgets text input](#customizing-widgets-text-input) | ||
- [Custom field components](#custom-field-components) | ||
@@ -92,7 +95,7 @@ - [Field props](#field-props) | ||
- [Property dependencies](#property-dependencies) | ||
- [Unidirectional](#unidirectional) | ||
- [Bidirectional](#bidirectional) | ||
- [Unidirectional](#unidirectional) | ||
- [Bidirectional](#bidirectional) | ||
- [Schema dependencies](#schema-dependencies) | ||
- [Conditional](#conditional) | ||
- [Dynamic](#dynamic) | ||
- [Conditional](#conditional) | ||
- [Dynamic](#dynamic) | ||
- [JSON Schema supporting status](#json-schema-supporting-status) | ||
@@ -105,3 +108,6 @@ - [Tips and tricks](#tips-and-tricks) | ||
- [TDD](#tdd) | ||
- [Releasing](#releasing) | ||
- [FAQ](#faq) | ||
- [Q: Does rjsf support oneOf, anyOf, multiple types in an array, etc.?](#q-does-rjsf-support-oneof-anyof-multiple-types-in-an-array-etc) | ||
- [Q: Will react-jsonschema-form support Material, Ant-Design, Foundation, or [some other specific widget library or frontend style]?](#q-will-react-jsonschema-form-support-material-ant-design-foundation-or-some-other-specific-widget-library-or-frontend-style) | ||
- [License](#license) | ||
@@ -569,2 +575,47 @@ | ||
#### Alternative JSON-Schema compliant approach | ||
The JSON Schema team concluded an alternative approach instead of enumNames and react-jsonschema-form supports it as well. | ||
```js | ||
const schema = { | ||
"type": "number", | ||
"anyOf": [ | ||
{ | ||
"type": "number", | ||
"title": "one", | ||
"enum": [ | ||
1 | ||
] | ||
}, | ||
{ | ||
"type": "number", | ||
"title": "two", | ||
"enum": [ | ||
2 | ||
] | ||
}, | ||
{ | ||
"type": "number", | ||
"title": "three", | ||
"enum": [ | ||
3 | ||
] | ||
} | ||
] | ||
}; | ||
``` | ||
As above this will be rendered using a select box as so: | ||
```html | ||
<select> | ||
<option value="1">one</option> | ||
<option value="2">two</option> | ||
<option value="3">three</option> | ||
</select> | ||
``` | ||
A live example of both approaches side-by-side can be found in the **Alternatives** playground preset. | ||
### Disabled attribute for `enum` fields | ||
@@ -1150,3 +1201,3 @@ | ||
#### Customizing widgets' text input | ||
#### Customizing widgets text input | ||
@@ -1153,0 +1204,0 @@ All the widgets that render a text input use the `BaseInput` component internally. If you need to customize all text inputs without customizing all widgets individially, you can provide a `BaseInput` component in the `widgets` property of `Form` (see [Custom component registration](#custom-component-registration). |
Sorry, the diff of this file is too big to display
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
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
1644648
4735
1819