react-jsonschema-form
Advanced tools
Comparing version 0.34.1 to 0.35.0
@@ -250,3 +250,3 @@ "use strict"; | ||
onChange: this.onSelectChange, | ||
options: (0, _utils.optionsList)(itemsSchema), | ||
options: { enumOptions: (0, _utils.optionsList)(itemsSchema) }, | ||
schema: schema, | ||
@@ -459,3 +459,3 @@ placeholder: title, | ||
registry: _react.PropTypes.shape({ | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.func).isRequired, | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.object])).isRequired, | ||
fields: _react.PropTypes.objectOf(_react.PropTypes.func).isRequired, | ||
@@ -462,0 +462,0 @@ definitions: _react.PropTypes.object.isRequired |
@@ -22,6 +22,8 @@ "use strict"; | ||
function buildOptions(schema) { | ||
return (0, _utils.optionsList)(Object.assign({ | ||
enumNames: ["true", "false"], | ||
enum: [true, false] | ||
}, { enumNames: schema.enumNames })); | ||
return { | ||
enumOptions: (0, _utils.optionsList)(Object.assign({ | ||
enumNames: ["true", "false"], | ||
enum: [true, false] | ||
}, { enumNames: schema.enumNames })) | ||
}; | ||
} | ||
@@ -74,3 +76,3 @@ | ||
registry: _react.PropTypes.shape({ | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.func).isRequired, | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.object])).isRequired, | ||
fields: _react.PropTypes.objectOf(_react.PropTypes.func).isRequired, | ||
@@ -77,0 +79,0 @@ definitions: _react.PropTypes.object.isRequired |
@@ -212,3 +212,3 @@ "use strict"; | ||
registry: _react.PropTypes.shape({ | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.func).isRequired, | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.object])).isRequired, | ||
fields: _react.PropTypes.objectOf(_react.PropTypes.func).isRequired, | ||
@@ -215,0 +215,0 @@ definitions: _react.PropTypes.object.isRequired |
@@ -231,3 +231,3 @@ "use strict"; | ||
registry: _react.PropTypes.shape({ | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.func).isRequired, | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.object])).isRequired, | ||
fields: _react.PropTypes.objectOf(_react.PropTypes.func).isRequired, | ||
@@ -234,0 +234,0 @@ definitions: _react.PropTypes.object.isRequired |
@@ -53,7 +53,8 @@ "use strict"; | ||
if (Array.isArray(schema.enum)) { | ||
var enumOptions = (0, _utils.optionsList)(schema); | ||
if (widget) { | ||
var Widget = (0, _utils.getAlternativeWidget)(schema, widget, widgets); | ||
return _react2.default.createElement(Widget, _extends({ options: (0, _utils.optionsList)(schema) }, commonProps)); | ||
var Widget = (0, _utils.getAlternativeWidget)(schema, widget, widgets, { enumOptions: enumOptions }); | ||
return _react2.default.createElement(Widget, commonProps); | ||
} | ||
return _react2.default.createElement(_SelectWidget2.default, _extends({ options: (0, _utils.optionsList)(schema) }, commonProps)); | ||
return _react2.default.createElement(_SelectWidget2.default, _extends({ options: { enumOptions: enumOptions } }, commonProps)); | ||
} | ||
@@ -74,3 +75,3 @@ if (widget) { | ||
registry: _react.PropTypes.shape({ | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.func).isRequired, | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.object])).isRequired, | ||
fields: _react.PropTypes.objectOf(_react.PropTypes.func).isRequired, | ||
@@ -77,0 +78,0 @@ definitions: _react.PropTypes.object.isRequired |
@@ -272,3 +272,3 @@ "use strict"; | ||
formData: _react.PropTypes.any, | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.func), | ||
widgets: _react.PropTypes.objectOf(_react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.object])), | ||
fields: _react.PropTypes.objectOf(_react.PropTypes.func), | ||
@@ -275,0 +275,0 @@ onChange: _react.PropTypes.func, |
@@ -59,3 +59,3 @@ "use strict"; | ||
className: "form-control", | ||
options: rangeOptions(type, range[0], range[1]), | ||
options: { enumOptions: rangeOptions(type, range[0], range[1]) }, | ||
value: value, | ||
@@ -62,0 +62,0 @@ disabled: disabled, |
@@ -35,2 +35,3 @@ "use strict"; | ||
var _onChange = props.onChange; | ||
var enumOptions = options.enumOptions; | ||
@@ -40,3 +41,3 @@ return _react2.default.createElement( | ||
{ className: "checkboxes", id: id }, | ||
options.map(function (option, index) { | ||
enumOptions.map(function (option, index) { | ||
var checked = value.indexOf(option.value) !== -1; | ||
@@ -54,3 +55,3 @@ return _react2.default.createElement( | ||
onChange: function onChange(event) { | ||
var all = options.map(function (_ref) { | ||
var all = enumOptions.map(function (_ref) { | ||
var value = _ref.value; | ||
@@ -80,3 +81,5 @@ return value; | ||
id: _react.PropTypes.string.isRequired, | ||
options: _react.PropTypes.array.isRequired, | ||
options: _react.PropTypes.shape({ | ||
enumOptions: _react.PropTypes.array | ||
}).isRequired, | ||
placeholder: _react.PropTypes.string, | ||
@@ -83,0 +86,0 @@ value: _react.PropTypes.any, |
@@ -24,6 +24,8 @@ "use strict"; | ||
var name = Math.random().toString(); | ||
var enumOptions = options.enumOptions; | ||
return _react2.default.createElement( | ||
"div", | ||
{ className: "field-radio-group" }, | ||
options.map(function (option, i) { | ||
enumOptions.map(function (option, i) { | ||
var checked = option.value === value; | ||
@@ -56,3 +58,5 @@ return _react2.default.createElement( | ||
id: _react.PropTypes.string.isRequired, | ||
options: _react.PropTypes.array.isRequired, | ||
options: _react.PropTypes.shape({ | ||
enumOptions: _react.PropTypes.array | ||
}).isRequired, | ||
placeholder: _react.PropTypes.string, | ||
@@ -59,0 +63,0 @@ value: _react.PropTypes.any, |
@@ -39,2 +39,3 @@ "use strict"; | ||
var _onChange = _ref.onChange; | ||
var enumOptions = options.enumOptions; | ||
@@ -66,3 +67,3 @@ return _react2.default.createElement( | ||
} }, | ||
options.map(function (_ref2, i) { | ||
enumOptions.map(function (_ref2, i) { | ||
var value = _ref2.value; | ||
@@ -84,3 +85,5 @@ var label = _ref2.label; | ||
id: _react.PropTypes.string.isRequired, | ||
options: _react.PropTypes.array.isRequired, | ||
options: _react.PropTypes.shape({ | ||
enumOptions: _react.PropTypes.array | ||
}).isRequired, | ||
placeholder: _react.PropTypes.string, | ||
@@ -87,0 +90,0 @@ value: _react.PropTypes.any, |
@@ -7,6 +7,6 @@ "use strict"; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
exports.getDefaultRegistry = getDefaultRegistry; | ||
@@ -189,23 +189,47 @@ exports.defaultFieldValue = defaultFieldValue; | ||
var registeredWidgets = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var widgetOptions = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; | ||
var type = schema.type; | ||
var format = schema.format; | ||
if (typeof widget === "function") { | ||
function setDefaultOptions(widget) { | ||
widget.defaultProps = _extends({}, widget.defaultProps, { options: widgetOptions }); | ||
return widget; | ||
} | ||
if (typeof widget === "function") { | ||
return setDefaultOptions(widget); | ||
} | ||
if (isObject(widget)) { | ||
var component = widget.component; | ||
var options = widget.options; | ||
var mergedOptions = _extends({}, options, widgetOptions); | ||
return getAlternativeWidget(schema, component, registeredWidgets, mergedOptions); | ||
} | ||
if (typeof widget !== "string") { | ||
throw new Error("Unsupported widget definition: " + (typeof widget === "undefined" ? "undefined" : _typeof(widget))); | ||
} | ||
if (widget in registeredWidgets) { | ||
return registeredWidgets[widget]; | ||
if (registeredWidgets.hasOwnProperty(widget)) { | ||
var registeredWidget = registeredWidgets[widget]; | ||
return getAlternativeWidget(schema, registeredWidget, registeredWidgets, widgetOptions); | ||
} | ||
if (!altWidgetMap.hasOwnProperty(type)) { | ||
throw new Error("No alternative widget for type " + type); | ||
} | ||
if (altWidgetMap[type].hasOwnProperty(widget)) { | ||
return altWidgetMap[type][widget]; | ||
var altWidget = altWidgetMap[type][widget]; | ||
return getAlternativeWidget(schema, altWidget, registeredWidgets, widgetOptions); | ||
} | ||
if (type === "string" && stringFormatWidgets.hasOwnProperty(format)) { | ||
return stringFormatWidgets[format]; | ||
var stringFormatWidget = stringFormatWidgets[format]; | ||
return getAlternativeWidget(schema, stringFormatWidget, registeredWidgets, widgetOptions); | ||
} | ||
var info = type === "string" && format ? "/" + format : ""; | ||
@@ -212,0 +236,0 @@ throw new Error("No alternative widget \"" + widget + "\" for type " + type + info); |
{ | ||
"name": "react-jsonschema-form", | ||
"version": "0.34.1", | ||
"version": "0.35.0", | ||
"description": "A simple React component capable of building HTML forms out of a JSON schema.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
753638
3184