react-jsonschema-form
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -11,2 +11,10 @@ "use strict"; | ||
var _assign = require("babel-runtime/core-js/object/assign"); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _toConsumableArray2 = require("babel-runtime/helpers/toConsumableArray"); | ||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | ||
var _defineProperty2 = require("babel-runtime/helpers/defineProperty"); | ||
@@ -136,3 +144,3 @@ | ||
var newKey = preferredKey; | ||
while (_this.props.formData.hasOwnProperty(newKey)) { | ||
while (formData.hasOwnProperty(newKey)) { | ||
newKey = preferredKey + "-" + ++index; | ||
@@ -143,8 +151,14 @@ } | ||
return function (value, errorSchema) { | ||
if (oldValue === value) { | ||
return; | ||
} | ||
value = _this.getAvailableKey(value, _this.props.formData); | ||
var newFormData = (0, _extends6.default)({}, _this.props.formData); | ||
var property = newFormData[oldValue]; | ||
delete newFormData[oldValue]; | ||
newFormData[value] = property; | ||
_this.props.onChange(newFormData, errorSchema && _this.props.errorSchema && (0, _extends6.default)({}, _this.props.errorSchema, (0, _defineProperty3.default)({}, value, errorSchema))); | ||
var newKeys = (0, _defineProperty3.default)({}, oldValue, value); | ||
var keyValues = (0, _keys2.default)(newFormData).map(function (key) { | ||
var newKey = newKeys[key] || key; | ||
return (0, _defineProperty3.default)({}, newKey, newFormData[key]); | ||
}); | ||
var renamedObj = _assign2.default.apply(Object, [{}].concat((0, _toConsumableArray3.default)(keyValues))); | ||
_this.props.onChange(renamedObj, errorSchema && _this.props.errorSchema && (0, _extends6.default)({}, _this.props.errorSchema, (0, _defineProperty3.default)({}, value, errorSchema))); | ||
}; | ||
@@ -151,0 +165,0 @@ }, _this.handleAddClick = function (schema) { |
@@ -88,3 +88,3 @@ "use strict"; | ||
onFocus: _propTypes2.default.func, | ||
formData: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), | ||
formData: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number, _propTypes2.default.bool]), | ||
registry: _propTypes2.default.shape({ | ||
@@ -91,0 +91,0 @@ widgets: _propTypes2.default.objectOf(_propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.object])).isRequired, |
@@ -140,6 +140,6 @@ "use strict"; | ||
var nextState = this.getStateFromProps(nextProps); | ||
this.setState(nextState); | ||
if (!(0, _utils.deepEquals)(nextState.formData, nextProps.formData) && this.props.onChange) { | ||
if (!(0, _utils.deepEquals)(nextState.formData, nextProps.formData) && !(0, _utils.deepEquals)(nextState.formData, this.state.formData) && this.props.onChange) { | ||
this.props.onChange(nextState); | ||
} | ||
this.setState(nextState); | ||
} | ||
@@ -146,0 +146,0 @@ }, { |
@@ -172,3 +172,4 @@ "use strict"; | ||
registry = _props.registry, | ||
onBlur = _props.onBlur; | ||
onBlur = _props.onBlur, | ||
options = _props.options; | ||
@@ -194,3 +195,3 @@ return _react2.default.createElement( | ||
}), | ||
_react2.default.createElement( | ||
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && _react2.default.createElement( | ||
"li", | ||
@@ -204,3 +205,3 @@ null, | ||
), | ||
_react2.default.createElement( | ||
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && _react2.default.createElement( | ||
"li", | ||
@@ -207,0 +208,0 @@ null, |
@@ -42,2 +42,3 @@ "use strict"; | ||
var enumOptions = options.enumOptions, | ||
enumDisabled = options.enumDisabled, | ||
inline = options.inline; | ||
@@ -50,3 +51,4 @@ | ||
var checked = value.indexOf(option.value) !== -1; | ||
var disabledCls = disabled || readonly ? "disabled" : ""; | ||
var itemDisabled = enumDisabled && enumDisabled.indexOf(option.value) != -1; | ||
var disabledCls = disabled || itemDisabled || readonly ? "disabled" : ""; | ||
var checkbox = _react2.default.createElement( | ||
@@ -59,3 +61,3 @@ "span", | ||
checked: checked, | ||
disabled: disabled || readonly, | ||
disabled: disabled || itemDisabled || readonly, | ||
autoFocus: autofocus && index === 0, | ||
@@ -62,0 +64,0 @@ onChange: function onChange(event) { |
@@ -29,5 +29,6 @@ "use strict"; | ||
*/ | ||
function processValue(_ref, value) { | ||
var type = _ref.type, | ||
items = _ref.items; | ||
function processValue(schema, value) { | ||
// "enum" is a reserved word, so only "type" and "items" can be destructured | ||
var type = schema.type, | ||
items = schema.items; | ||
@@ -43,2 +44,17 @@ if (value === "") { | ||
} | ||
// If type is undefined, but an enum is present, try and infer the type from | ||
// the enum values | ||
if (schema.enum) { | ||
if (schema.enum.every(function (x) { | ||
return (0, _utils.guessType)(x) === "number"; | ||
})) { | ||
return (0, _utils.asNumber)(value); | ||
} else if (schema.enum.every(function (x) { | ||
return (0, _utils.guessType)(x) === "boolean"; | ||
})) { | ||
return value === "true"; | ||
} | ||
} | ||
return value; | ||
@@ -104,5 +120,5 @@ } | ||
), | ||
enumOptions.map(function (_ref2, i) { | ||
var value = _ref2.value, | ||
label = _ref2.label; | ||
enumOptions.map(function (_ref, i) { | ||
var value = _ref.value, | ||
label = _ref.label; | ||
@@ -109,0 +125,0 @@ var disabled = enumDisabled && enumDisabled.indexOf(value) != -1; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.ADDITIONAL_PROPERTY_FLAG = undefined; | ||
exports.guessType = exports.ADDITIONAL_PROPERTY_FLAG = undefined; | ||
@@ -321,5 +321,5 @@ var _setImmediate2 = require("babel-runtime/core-js/set-immediate"); | ||
return (0, _keys2.default)(obj2).reduce(function (acc, key) { | ||
var left = obj1[key], | ||
var left = obj1 ? obj1[key] : {}, | ||
right = obj2[key]; | ||
if (obj1.hasOwnProperty(key) && isObject(right)) { | ||
if (obj1 && obj1.hasOwnProperty(key) && isObject(right)) { | ||
acc[key] = mergeObjects(left, right, concatArrays); | ||
@@ -533,3 +533,3 @@ } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) { | ||
// based on the data we are defining | ||
var guessType = function guessType(value) { | ||
var guessType = exports.guessType = function guessType(value) { | ||
if (Array.isArray(value)) { | ||
@@ -536,0 +536,0 @@ return "array"; |
{ | ||
"name": "react-jsonschema-form", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"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
Sorry, the diff of this file is too big to display
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
1272471
42
5197
1892