react-jsonschema-form
Advanced tools
Comparing version 0.43.0 to 0.44.0
@@ -14,4 +14,4 @@ "use strict"; | ||
function ErrorList(_ref) { | ||
var errors = _ref.errors; | ||
function ErrorList(props) { | ||
var errors = props.errors; | ||
@@ -18,0 +18,0 @@ return _react2.default.createElement( |
@@ -65,3 +65,6 @@ "use strict"; | ||
"button", | ||
_extends({ type: "button", className: "btn btn-" + type + " " + className }, otherProps), | ||
_extends({ | ||
type: "button", | ||
className: "btn btn-" + type + " " + className | ||
}, otherProps), | ||
_react2.default.createElement("i", { className: "glyphicon glyphicon-" + icon }) | ||
@@ -73,3 +76,8 @@ ); | ||
function DefaultArrayItem(props) { | ||
var btnStyle = { flex: 1, paddingLeft: 6, paddingRight: 6, fontWeight: "bold" }; | ||
var btnStyle = { | ||
flex: 1, | ||
paddingLeft: 6, | ||
paddingRight: 6, | ||
fontWeight: "bold" | ||
}; | ||
return _react2.default.createElement( | ||
@@ -83,3 +91,3 @@ "div", | ||
), | ||
props.hasToolbar ? _react2.default.createElement( | ||
props.hasToolbar && _react2.default.createElement( | ||
"div", | ||
@@ -89,20 +97,32 @@ { className: "col-xs-3 array-item-toolbox" }, | ||
"div", | ||
{ className: "btn-group", style: { display: "flex", justifyContent: "space-around" } }, | ||
props.hasMoveUp || props.hasMoveDown ? _react2.default.createElement(IconBtn, { icon: "arrow-up", className: "array-item-move-up", | ||
{ | ||
className: "btn-group", | ||
style: { display: "flex", justifyContent: "space-around" } }, | ||
(props.hasMoveUp || props.hasMoveDown) && _react2.default.createElement(IconBtn, { | ||
icon: "arrow-up", | ||
className: "array-item-move-up", | ||
tabIndex: "-1", | ||
style: btnStyle, | ||
disabled: props.disabled || props.readonly || !props.hasMoveUp, | ||
onClick: props.onReorderClick(props.index, props.index - 1) }) : null, | ||
props.hasMoveUp || props.hasMoveDown ? _react2.default.createElement(IconBtn, { icon: "arrow-down", className: "array-item-move-down", | ||
onClick: props.onReorderClick(props.index, props.index - 1) | ||
}), | ||
(props.hasMoveUp || props.hasMoveDown) && _react2.default.createElement(IconBtn, { | ||
icon: "arrow-down", | ||
className: "array-item-move-down", | ||
tabIndex: "-1", | ||
style: btnStyle, | ||
disabled: props.disabled || props.readonly || !props.hasMoveDown, | ||
onClick: props.onReorderClick(props.index, props.index + 1) }) : null, | ||
props.hasRemove ? _react2.default.createElement(IconBtn, { type: "danger", icon: "remove", className: "array-item-remove", | ||
onClick: props.onReorderClick(props.index, props.index + 1) | ||
}), | ||
props.hasRemove && _react2.default.createElement(IconBtn, { | ||
type: "danger", | ||
icon: "remove", | ||
className: "array-item-remove", | ||
tabIndex: "-1", | ||
style: btnStyle, | ||
disabled: props.disabled || props.readonly, | ||
onClick: props.onDropIndexClick(props.index) }) : null | ||
onClick: props.onDropIndexClick(props.index) | ||
}) | ||
) | ||
) : null | ||
) | ||
); | ||
@@ -120,17 +140,22 @@ } | ||
title: props.title, | ||
required: props.required }), | ||
props.schema.description ? _react2.default.createElement( | ||
required: props.required | ||
}), | ||
props.schema.description && _react2.default.createElement( | ||
"div", | ||
{ className: "field-description", key: "field-description-" + props.idSchema.$id }, | ||
{ | ||
className: "field-description", | ||
key: "field-description-" + props.idSchema.$id }, | ||
props.schema.description | ||
) : null, | ||
), | ||
_react2.default.createElement( | ||
"div", | ||
{ className: "row array-item-list", | ||
{ | ||
className: "row array-item-list", | ||
key: "array-item-list-" + props.idSchema.$id }, | ||
props.items && props.items.map(DefaultArrayItem) | ||
), | ||
props.canAdd ? _react2.default.createElement(AddButton, { | ||
props.canAdd && _react2.default.createElement(AddButton, { | ||
onClick: props.onAddClick, | ||
disabled: props.disabled || props.readonly }) : null | ||
disabled: props.disabled || props.readonly | ||
}) | ||
); | ||
@@ -148,11 +173,14 @@ } | ||
title: props.title, | ||
required: props.required }), | ||
props.schema.description ? _react2.default.createElement(ArrayFieldDescription, { | ||
required: props.required | ||
}), | ||
props.schema.description && _react2.default.createElement(ArrayFieldDescription, { | ||
key: "array-field-description-" + props.idSchema.$id, | ||
DescriptionField: props.DescriptionField, | ||
idSchema: props.idSchema, | ||
description: props.schema.description }) : null, | ||
description: props.schema.description | ||
}), | ||
_react2.default.createElement( | ||
"div", | ||
{ className: "row array-item-list", | ||
{ | ||
className: "row array-item-list", | ||
key: "array-item-list-" + props.idSchema.$id }, | ||
@@ -163,5 +191,6 @@ props.items && props.items.map(function (p) { | ||
), | ||
props.canAdd ? _react2.default.createElement(AddButton, { | ||
props.canAdd && _react2.default.createElement(AddButton, { | ||
onClick: props.onAddClick, | ||
disabled: props.disabled || props.readonly }) : null | ||
disabled: props.disabled || props.readonly | ||
}) | ||
); | ||
@@ -237,3 +266,3 @@ } | ||
onChange(formData.map(function (item, i) { | ||
var newFormData = formData.map(function (item, i) { | ||
// We need to treat undefined items as nulls to have validation. | ||
@@ -243,3 +272,4 @@ // See https://github.com/tdegrunt/jsonschema/issues/206 | ||
return index === i ? jsonValue : item; | ||
}), { validate: false }); | ||
}); | ||
onChange(newFormData, { validate: false }); | ||
}; | ||
@@ -252,7 +282,2 @@ }, _this.onSelectChange = function (value) { | ||
_createClass(ArrayField, [{ | ||
key: "shouldComponentUpdate", | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
return (0, _utils.shouldRender)(this, nextProps, nextState); | ||
} | ||
}, { | ||
key: "isItemRequired", | ||
@@ -352,4 +377,4 @@ value: function isItemRequired(itemSchema) { | ||
// Check if a custom render function was passed in | ||
var renderFunction = ArrayFieldTemplate || DefaultNormalArrayFieldTemplate; | ||
return renderFunction(arrayProps); | ||
var Component = ArrayFieldTemplate || DefaultNormalArrayFieldTemplate; | ||
return _react2.default.createElement(Component, arrayProps); | ||
} | ||
@@ -377,3 +402,5 @@ }, { | ||
var _getUiOptions$enumOpt = _extends({}, (0, _utils.getUiOptions)(uiSchema), { enumOptions: enumOptions }), | ||
var _getUiOptions$enumOpt = _extends({}, (0, _utils.getUiOptions)(uiSchema), { | ||
enumOptions: enumOptions | ||
}), | ||
_getUiOptions$enumOpt2 = _getUiOptions$enumOpt.widget, | ||
@@ -395,3 +422,4 @@ widget = _getUiOptions$enumOpt2 === undefined ? "select" : _getUiOptions$enumOpt2, | ||
formContext: formContext, | ||
autofocus: autofocus }); | ||
autofocus: autofocus | ||
}); | ||
} | ||
@@ -435,3 +463,4 @@ }, { | ||
formContext: formContext, | ||
autofocus: autofocus }); | ||
autofocus: autofocus | ||
}); | ||
} | ||
@@ -522,17 +551,17 @@ }, { | ||
key: "renderArrayFieldItem", | ||
value: function renderArrayFieldItem(_ref4) { | ||
var index = _ref4.index, | ||
_ref4$canRemove = _ref4.canRemove, | ||
canRemove = _ref4$canRemove === undefined ? true : _ref4$canRemove, | ||
_ref4$canMoveUp = _ref4.canMoveUp, | ||
canMoveUp = _ref4$canMoveUp === undefined ? true : _ref4$canMoveUp, | ||
_ref4$canMoveDown = _ref4.canMoveDown, | ||
canMoveDown = _ref4$canMoveDown === undefined ? true : _ref4$canMoveDown, | ||
itemSchema = _ref4.itemSchema, | ||
itemData = _ref4.itemData, | ||
itemUiSchema = _ref4.itemUiSchema, | ||
itemIdSchema = _ref4.itemIdSchema, | ||
itemErrorSchema = _ref4.itemErrorSchema, | ||
autofocus = _ref4.autofocus, | ||
onBlur = _ref4.onBlur; | ||
value: function renderArrayFieldItem(props) { | ||
var index = props.index, | ||
_props$canRemove = props.canRemove, | ||
canRemove = _props$canRemove === undefined ? true : _props$canRemove, | ||
_props$canMoveUp = props.canMoveUp, | ||
canMoveUp = _props$canMoveUp === undefined ? true : _props$canMoveUp, | ||
_props$canMoveDown = props.canMoveDown, | ||
canMoveDown = _props$canMoveDown === undefined ? true : _props$canMoveDown, | ||
itemSchema = props.itemSchema, | ||
itemData = props.itemData, | ||
itemUiSchema = props.itemUiSchema, | ||
itemIdSchema = props.itemIdSchema, | ||
itemErrorSchema = props.itemErrorSchema, | ||
autofocus = props.autofocus, | ||
onBlur = props.onBlur; | ||
var SchemaField = this.props.registry.fields.SchemaField; | ||
@@ -573,3 +602,4 @@ var _props6 = this.props, | ||
readonly: this.props.readonly, | ||
autofocus: autofocus }), | ||
autofocus: autofocus | ||
}), | ||
className: "array-item", | ||
@@ -611,5 +641,5 @@ disabled: disabled, | ||
function AddButton(_ref5) { | ||
var onClick = _ref5.onClick, | ||
disabled = _ref5.disabled; | ||
function AddButton(_ref4) { | ||
var onClick = _ref4.onClick, | ||
disabled = _ref4.disabled; | ||
@@ -622,5 +652,10 @@ return _react2.default.createElement( | ||
{ className: "col-xs-3 col-xs-offset-9 array-item-add text-right" }, | ||
_react2.default.createElement(IconBtn, { type: "info", icon: "plus", className: "btn-add col-xs-12", | ||
tabIndex: "0", onClick: onClick, | ||
disabled: disabled }) | ||
_react2.default.createElement(IconBtn, { | ||
type: "info", | ||
icon: "plus", | ||
className: "btn-add col-xs-12", | ||
tabIndex: "0", | ||
onClick: onClick, | ||
disabled: disabled | ||
}) | ||
) | ||
@@ -627,0 +662,0 @@ ); |
@@ -57,3 +57,4 @@ "use strict"; | ||
formContext: formContext, | ||
autofocus: autofocus }); | ||
autofocus: autofocus | ||
}); | ||
} | ||
@@ -60,0 +61,0 @@ |
@@ -23,3 +23,4 @@ "use strict"; | ||
return props.onChange((0, _utils.asNumber)(value)); | ||
} })); | ||
} | ||
})); | ||
} | ||
@@ -26,0 +27,0 @@ |
@@ -50,7 +50,2 @@ "use strict"; | ||
_createClass(ObjectField, [{ | ||
key: "shouldComponentUpdate", | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
return (0, _utils.shouldRender)(this, nextProps, nextState); | ||
} | ||
}, { | ||
key: "isRequired", | ||
@@ -117,13 +112,16 @@ value: function isRequired(name) { | ||
null, | ||
title ? _react2.default.createElement(TitleField, { | ||
title && _react2.default.createElement(TitleField, { | ||
id: idSchema.$id + "__title", | ||
title: title, | ||
required: required, | ||
formContext: formContext }) : null, | ||
schema.description ? _react2.default.createElement(DescriptionField, { | ||
formContext: formContext | ||
}), | ||
schema.description && _react2.default.createElement(DescriptionField, { | ||
id: idSchema.$id + "__description", | ||
description: schema.description, | ||
formContext: formContext }) : null, | ||
formContext: formContext | ||
}), | ||
orderedProperties.map(function (name, index) { | ||
return _react2.default.createElement(SchemaField, { key: index, | ||
return _react2.default.createElement(SchemaField, { | ||
key: index, | ||
name: name, | ||
@@ -140,3 +138,4 @@ required: _this2.isRequired(name), | ||
disabled: disabled, | ||
readonly: readonly }); | ||
readonly: readonly | ||
}); | ||
}) | ||
@@ -143,0 +142,0 @@ ); |
@@ -7,2 +7,4 @@ "use strict"; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
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; }; | ||
@@ -22,2 +24,8 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
@@ -128,3 +136,3 @@ | ||
{ className: classNames }, | ||
displayLabel ? _react2.default.createElement(Label, { label: label, required: required, id: id }) : null, | ||
displayLabel && _react2.default.createElement(Label, { label: label, required: required, id: id }), | ||
displayLabel && description ? description : null, | ||
@@ -165,3 +173,3 @@ children, | ||
function SchemaField(props) { | ||
function SchemaFieldRender(props) { | ||
var uiSchema = props.uiSchema, | ||
@@ -209,6 +217,8 @@ errorSchema = props.errorSchema, | ||
// See #439: uiSchema: Don't pass consumed class names to child components | ||
var field = _react2.default.createElement(FieldComponent, _extends({}, props, { | ||
schema: schema | ||
// See #439: Don't pass consumed class names to child components | ||
, uiSchema: _extends({}, uiSchema, { classNames: undefined }), | ||
schema: schema, | ||
uiSchema: _extends({}, uiSchema, { classNames: undefined }), | ||
disabled: disabled, | ||
@@ -218,3 +228,4 @@ readonly: readonly, | ||
errorSchema: fieldErrorSchema, | ||
formContext: formContext })); | ||
formContext: formContext | ||
})); | ||
@@ -229,8 +240,10 @@ var type = schema.type; | ||
var hidden = uiSchema["ui:widget"] === "hidden"; | ||
var classNames = ["form-group", "field", "field-" + type, errors && errors.length > 0 ? "field-error has-error" : "", uiSchema.classNames].join(" ").trim(); | ||
var classNames = ["form-group", "field", "field-" + type, errors && errors.length > 0 ? "field-error has-error has-danger" : "", uiSchema.classNames].join(" ").trim(); | ||
var fieldProps = { | ||
description: _react2.default.createElement(DescriptionField, { id: id + "__description", | ||
description: _react2.default.createElement(DescriptionField, { | ||
id: id + "__description", | ||
description: description, | ||
formContext: formContext }), | ||
formContext: formContext | ||
}), | ||
rawDescription: description, | ||
@@ -261,2 +274,28 @@ help: _react2.default.createElement(Help, { help: help }), | ||
var SchemaField = function (_React$Component) { | ||
_inherits(SchemaField, _React$Component); | ||
function SchemaField() { | ||
_classCallCheck(this, SchemaField); | ||
return _possibleConstructorReturn(this, (SchemaField.__proto__ || Object.getPrototypeOf(SchemaField)).apply(this, arguments)); | ||
} | ||
_createClass(SchemaField, [{ | ||
key: "shouldComponentUpdate", | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
// if schemas are equal idSchemas will be equal as well, | ||
// so it is not necessary to compare | ||
return !(0, _utils.deepEquals)(_extends({}, this.props, { idSchema: undefined }), _extends({}, nextProps, { idSchema: undefined })); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
return SchemaFieldRender(this.props); | ||
} | ||
}]); | ||
return SchemaField; | ||
}(_react2.default.Component); | ||
SchemaField.defaultProps = { | ||
@@ -263,0 +302,0 @@ uiSchema: {}, |
@@ -63,3 +63,4 @@ "use strict"; | ||
registry: registry, | ||
placeholder: placeholder }); | ||
placeholder: placeholder | ||
}); | ||
} | ||
@@ -66,0 +67,0 @@ |
@@ -7,4 +7,2 @@ "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 && obj !== Symbol.prototype ? "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; }; | ||
@@ -76,22 +74,16 @@ | ||
if (!_this.props.noValidate) { | ||
var _ret = function () { | ||
var _this$validate2 = _this.validate(_this.state.formData), | ||
errors = _this$validate2.errors, | ||
errorSchema = _this$validate2.errorSchema; | ||
var _this$validate2 = _this.validate(_this.state.formData), | ||
errors = _this$validate2.errors, | ||
errorSchema = _this$validate2.errorSchema; | ||
if (Object.keys(errors).length > 0) { | ||
(0, _utils.setState)(_this, { errors: errors, errorSchema: errorSchema }, function () { | ||
if (_this.props.onError) { | ||
_this.props.onError(errors); | ||
} else { | ||
console.error("Form validation failed", errors); | ||
} | ||
}); | ||
return { | ||
v: void 0 | ||
}; | ||
} | ||
}(); | ||
if ((typeof _ret === "undefined" ? "undefined" : _typeof(_ret)) === "object") return _ret.v; | ||
if (Object.keys(errors).length > 0) { | ||
(0, _utils.setState)(_this, { errors: errors, errorSchema: errorSchema }, function () { | ||
if (_this.props.onError) { | ||
_this.props.onError(errors); | ||
} else { | ||
console.error("Form validation failed", errors); | ||
} | ||
}); | ||
return; | ||
} | ||
} | ||
@@ -166,7 +158,8 @@ | ||
errors = _state.errors; | ||
var showErrorList = this.props.showErrorList; | ||
var _props2 = this.props, | ||
ErrorList = _props2.ErrorList, | ||
showErrorList = _props2.showErrorList; | ||
if (status !== "editing" && errors.length && showErrorList != false) { | ||
return _react2.default.createElement(_ErrorList2.default, { errors: errors }); | ||
return _react2.default.createElement(ErrorList, { errors: errors }); | ||
} | ||
@@ -196,15 +189,15 @@ return null; | ||
value: function render() { | ||
var _props2 = this.props, | ||
children = _props2.children, | ||
safeRenderCompletion = _props2.safeRenderCompletion, | ||
id = _props2.id, | ||
className = _props2.className, | ||
name = _props2.name, | ||
method = _props2.method, | ||
target = _props2.target, | ||
action = _props2.action, | ||
autocomplete = _props2.autocomplete, | ||
enctype = _props2.enctype, | ||
acceptcharset = _props2.acceptcharset, | ||
noHtml5Validate = _props2.noHtml5Validate; | ||
var _props3 = this.props, | ||
children = _props3.children, | ||
safeRenderCompletion = _props3.safeRenderCompletion, | ||
id = _props3.id, | ||
className = _props3.className, | ||
name = _props3.name, | ||
method = _props3.method, | ||
target = _props3.target, | ||
action = _props3.action, | ||
autocomplete = _props3.autocomplete, | ||
enctype = _props3.enctype, | ||
acceptcharset = _props3.acceptcharset, | ||
noHtml5Validate = _props3.noHtml5Validate; | ||
var _state2 = this.state, | ||
@@ -222,3 +215,4 @@ schema = _state2.schema, | ||
"form", | ||
{ className: className ? className : "rjsf", | ||
{ | ||
className: className ? className : "rjsf", | ||
id: id, | ||
@@ -244,3 +238,4 @@ name: name, | ||
registry: registry, | ||
safeRenderCompletion: safeRenderCompletion }), | ||
safeRenderCompletion: safeRenderCompletion | ||
}), | ||
children ? children : _react2.default.createElement( | ||
@@ -267,3 +262,4 @@ "p", | ||
safeRenderCompletion: false, | ||
noHtml5Validate: false | ||
noHtml5Validate: false, | ||
ErrorList: _ErrorList2.default | ||
}; | ||
@@ -282,2 +278,3 @@ exports.default = Form; | ||
FieldTemplate: _react.PropTypes.func, | ||
ErrorList: _react.PropTypes.func, | ||
onChange: _react.PropTypes.func, | ||
@@ -284,0 +281,0 @@ onError: _react.PropTypes.func, |
@@ -69,3 +69,4 @@ "use strict"; | ||
}, | ||
onBlur: onBlur }); | ||
onBlur: onBlur | ||
}); | ||
} | ||
@@ -165,3 +166,4 @@ | ||
onBlur: onBlur, | ||
autofocus: autofocus && i === 0 })) | ||
autofocus: autofocus && i === 0 | ||
})) | ||
); | ||
@@ -174,4 +176,3 @@ }), | ||
"a", | ||
{ href: "#", className: "btn btn-info btn-now", | ||
onClick: this.setNow }, | ||
{ href: "#", className: "btn btn-info btn-now", onClick: this.setNow }, | ||
"Now" | ||
@@ -185,3 +186,5 @@ ) | ||
"a", | ||
{ href: "#", className: "btn btn-warning btn-clear", | ||
{ | ||
href: "#", | ||
className: "btn btn-warning btn-clear", | ||
onClick: this.clear }, | ||
@@ -188,0 +191,0 @@ "Clear" |
@@ -43,3 +43,4 @@ "use strict"; | ||
return onBlur(inputProps.id, event.target.value); | ||
} })); | ||
} | ||
})); | ||
} | ||
@@ -46,0 +47,0 @@ |
@@ -48,3 +48,4 @@ "use strict"; | ||
null, | ||
_react2.default.createElement("input", { type: "checkbox", | ||
_react2.default.createElement("input", { | ||
type: "checkbox", | ||
id: id + "_" + index, | ||
@@ -64,3 +65,4 @@ checked: checked, | ||
} | ||
} }), | ||
} | ||
}), | ||
_react2.default.createElement( | ||
@@ -67,0 +69,0 @@ "span", |
@@ -11,13 +11,17 @@ "use strict"; | ||
var _DescriptionField = require("../fields/DescriptionField.js"); | ||
var _DescriptionField2 = _interopRequireDefault(_DescriptionField); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function CheckboxWidget(_ref) { | ||
var schema = _ref.schema, | ||
id = _ref.id, | ||
value = _ref.value, | ||
required = _ref.required, | ||
disabled = _ref.disabled, | ||
label = _ref.label, | ||
autofocus = _ref.autofocus, | ||
_onChange = _ref.onChange; | ||
function CheckboxWidget(props) { | ||
var schema = props.schema, | ||
id = props.id, | ||
value = props.value, | ||
required = props.required, | ||
disabled = props.disabled, | ||
label = props.label, | ||
autofocus = props.autofocus, | ||
_onChange = props.onChange; | ||
@@ -27,6 +31,8 @@ return _react2.default.createElement( | ||
{ className: "checkbox " + (disabled ? "disabled" : "") }, | ||
schema.description && _react2.default.createElement(_DescriptionField2.default, { description: schema.description }), | ||
_react2.default.createElement( | ||
"label", | ||
null, | ||
_react2.default.createElement("input", { type: "checkbox", | ||
_react2.default.createElement("input", { | ||
type: "checkbox", | ||
id: id, | ||
@@ -39,3 +45,4 @@ checked: typeof value === "undefined" ? false : value, | ||
return _onChange(event.target.checked); | ||
} }), | ||
} | ||
}), | ||
_react2.default.createElement( | ||
@@ -42,0 +49,0 @@ "span", |
@@ -39,3 +39,4 @@ "use strict"; | ||
return _onChange(toJSONDate(value)); | ||
} })); | ||
} | ||
})); | ||
} | ||
@@ -42,0 +43,0 @@ |
@@ -27,3 +27,4 @@ "use strict"; | ||
return _onChange(value || undefined); | ||
} })); | ||
} | ||
})); | ||
} | ||
@@ -30,0 +31,0 @@ |
@@ -173,3 +173,4 @@ "use strict"; | ||
autoFocus: autofocus, | ||
multiple: multiple }) | ||
multiple: multiple | ||
}) | ||
), | ||
@@ -176,0 +177,0 @@ _react2.default.createElement(FilesInfo, { filesInfo: filesInfo }) |
@@ -17,3 +17,7 @@ "use strict"; | ||
return _react2.default.createElement("input", { type: "hidden", id: id, value: typeof value === "undefined" ? "" : value }); | ||
return _react2.default.createElement("input", { | ||
type: "hidden", | ||
id: id, | ||
value: typeof value === "undefined" ? "" : value | ||
}); | ||
} | ||
@@ -20,0 +24,0 @@ |
@@ -13,12 +13,11 @@ "use strict"; | ||
function RadioWidget(_ref) { | ||
var schema = _ref.schema, | ||
options = _ref.options, | ||
value = _ref.value, | ||
required = _ref.required, | ||
disabled = _ref.disabled, | ||
autofocus = _ref.autofocus, | ||
_onChange = _ref.onChange; | ||
function RadioWidget(props) { | ||
var options = props.options, | ||
value = props.value, | ||
required = props.required, | ||
disabled = props.disabled, | ||
autofocus = props.autofocus, | ||
_onChange = props.onChange; | ||
// Generating a unique field name to identify this set of radio buttons | ||
// Generating a unique field name to identify this set of radio buttons | ||
var name = Math.random().toString(); | ||
@@ -39,3 +38,4 @@ var enumOptions = options.enumOptions, | ||
null, | ||
_react2.default.createElement("input", { type: "radio", | ||
_react2.default.createElement("input", { | ||
type: "radio", | ||
checked: checked, | ||
@@ -49,3 +49,4 @@ name: name, | ||
return _onChange(option.value); | ||
} }), | ||
} | ||
}), | ||
_react2.default.createElement( | ||
@@ -52,0 +53,0 @@ "span", |
@@ -28,5 +28,3 @@ "use strict"; | ||
{ className: "field-range-wrapper" }, | ||
_react2.default.createElement(_BaseInput2.default, _extends({ | ||
type: "range" | ||
}, props, (0, _utils.rangeSpec)(schema))), | ||
_react2.default.createElement(_BaseInput2.default, _extends({ type: "range" }, props, (0, _utils.rangeSpec)(schema))), | ||
_react2.default.createElement( | ||
@@ -33,0 +31,0 @@ "span", |
@@ -47,15 +47,15 @@ "use strict"; | ||
function SelectWidget(_ref2) { | ||
var schema = _ref2.schema, | ||
id = _ref2.id, | ||
options = _ref2.options, | ||
value = _ref2.value, | ||
required = _ref2.required, | ||
disabled = _ref2.disabled, | ||
readonly = _ref2.readonly, | ||
multiple = _ref2.multiple, | ||
autofocus = _ref2.autofocus, | ||
_onChange = _ref2.onChange, | ||
onBlur = _ref2.onBlur, | ||
placeholder = _ref2.placeholder; | ||
function SelectWidget(props) { | ||
var schema = props.schema, | ||
id = props.id, | ||
options = props.options, | ||
value = props.value, | ||
required = props.required, | ||
disabled = props.disabled, | ||
readonly = props.readonly, | ||
multiple = props.multiple, | ||
autofocus = props.autofocus, | ||
_onChange = props.onChange, | ||
onBlur = props.onBlur, | ||
placeholder = props.placeholder; | ||
var enumOptions = options.enumOptions; | ||
@@ -88,5 +88,5 @@ | ||
), | ||
enumOptions.map(function (_ref3, i) { | ||
var value = _ref3.value, | ||
label = _ref3.label; | ||
enumOptions.map(function (_ref2, i) { | ||
var value = _ref2.value, | ||
label = _ref2.label; | ||
@@ -93,0 +93,0 @@ return _react2.default.createElement( |
@@ -13,16 +13,16 @@ "use strict"; | ||
function TextareaWidget(_ref) { | ||
var schema = _ref.schema, | ||
id = _ref.id, | ||
placeholder = _ref.placeholder, | ||
value = _ref.value, | ||
required = _ref.required, | ||
disabled = _ref.disabled, | ||
readonly = _ref.readonly, | ||
autofocus = _ref.autofocus, | ||
onChange = _ref.onChange, | ||
onBlur = _ref.onBlur; | ||
function TextareaWidget(props) { | ||
var id = props.id, | ||
options = props.options, | ||
placeholder = props.placeholder, | ||
value = props.value, | ||
required = props.required, | ||
disabled = props.disabled, | ||
readonly = props.readonly, | ||
autofocus = props.autofocus, | ||
onChange = props.onChange, | ||
onBlur = props.onBlur; | ||
var _onChange = function _onChange(_ref2) { | ||
var value = _ref2.target.value; | ||
var _onChange = function _onChange(_ref) { | ||
var value = _ref.target.value; | ||
@@ -40,10 +40,13 @@ return onChange(value === "" ? undefined : value); | ||
autoFocus: autofocus, | ||
rows: options.rows, | ||
onBlur: onBlur && function (event) { | ||
return onBlur(id, event.target.value); | ||
}, | ||
onChange: _onChange }); | ||
onChange: _onChange | ||
}); | ||
} | ||
TextareaWidget.defaultProps = { | ||
autofocus: false | ||
autofocus: false, | ||
options: {} | ||
}; | ||
@@ -56,2 +59,5 @@ | ||
placeholder: _react.PropTypes.string, | ||
options: _react.PropTypes.shape({ | ||
rows: _react.PropTypes.number | ||
}), | ||
value: _react.PropTypes.string, | ||
@@ -58,0 +64,0 @@ required: _react.PropTypes.bool, |
@@ -119,12 +119,10 @@ "use strict"; | ||
if (!Widget.MergedWidget) { | ||
(function () { | ||
var defaultOptions = Widget.defaultProps && Widget.defaultProps.options || {}; | ||
Widget.MergedWidget = function (_ref) { | ||
var _ref$options = _ref.options, | ||
options = _ref$options === undefined ? {} : _ref$options, | ||
props = _objectWithoutProperties(_ref, ["options"]); | ||
var defaultOptions = Widget.defaultProps && Widget.defaultProps.options || {}; | ||
Widget.MergedWidget = function (_ref) { | ||
var _ref$options = _ref.options, | ||
options = _ref$options === undefined ? {} : _ref$options, | ||
props = _objectWithoutProperties(_ref, ["options"]); | ||
return _react2.default.createElement(Widget, _extends({ options: _extends({}, defaultOptions, options) }, props)); | ||
}; | ||
})(); | ||
return _react2.default.createElement(Widget, _extends({ options: _extends({}, defaultOptions, options) }, props)); | ||
}; | ||
} | ||
@@ -184,10 +182,17 @@ return Widget.MergedWidget; | ||
} | ||
// We need to recur for object schema inner default values. | ||
if (schema.type === "object") { | ||
return Object.keys(schema.properties).reduce(function (acc, key) { | ||
// Compute the defaults for this node, with the parent defaults we might | ||
// have from a previous run: defaults[key]. | ||
acc[key] = computeDefaults(schema.properties[key], (defaults || {})[key], definitions); | ||
return acc; | ||
}, {}); | ||
switch (schema.type) { | ||
// We need to recur for object schema inner default values. | ||
case "object": | ||
return Object.keys(schema.properties).reduce(function (acc, key) { | ||
// Compute the defaults for this node, with the parent defaults we might | ||
// have from a previous run: defaults[key]. | ||
acc[key] = computeDefaults(schema.properties[key], (defaults || {})[key], definitions); | ||
return acc; | ||
}, {}); | ||
case "array": | ||
if (schema.minItems) { | ||
return new Array(schema.minItems).fill(computeDefaults(schema.items, defaults, definitions)); | ||
} | ||
} | ||
@@ -376,3 +381,3 @@ return defaults; | ||
var $ref = schema.$ref, | ||
localSchema = _objectWithoutProperties(schema, ["$ref"]); // eslint-disable-line no-unused-vars | ||
localSchema = _objectWithoutProperties(schema, ["$ref"]); | ||
// Update referenced schema definition with local schema properties. | ||
@@ -379,0 +384,0 @@ |
{ | ||
"name": "react-jsonschema-form", | ||
"version": "0.43.0", | ||
"version": "0.44.0", | ||
"description": "A simple React component capable of building HTML forms out of a JSON schema.", | ||
@@ -10,4 +10,7 @@ "scripts": { | ||
"build:playground": "rimraf build && cross-env NODE_ENV=production webpack --config webpack.config.prod.js --optimize-minimize && cp playground/index.prod.html build/index.html", | ||
"cs-check": "prettier-check $npm_package_prettierOptions '{playground,src,test}/**/*.js'", | ||
"cs-format": "prettier $npm_package_prettierOptions '{playground,src,test}/**/*.js' --write", | ||
"dist": "npm run build:lib && npm run build:dist", | ||
"lint": "eslint src test", | ||
"lint": "eslint src test playground", | ||
"precommit": "lint-staged", | ||
"publish-to-gh-pages": "npm run build:playground && gh-pages --dist build/", | ||
@@ -19,2 +22,10 @@ "publish-to-npm": "npm run build:readme && npm run dist && npm publish", | ||
}, | ||
"prettierOptions": "--jsx-bracket-same-line --trailing-comma es5", | ||
"lint-staged": { | ||
"{playground,src,test}/**/*.js": [ | ||
"npm run lint", | ||
"npm run cs-format", | ||
"git add" | ||
] | ||
}, | ||
"main": "lib/index.js", | ||
@@ -50,7 +61,7 @@ "files": [ | ||
"babel-register": "^6.18.0", | ||
"chai": "^3.3.0", | ||
"codemirror": "^5.20.2", | ||
"eslint": "^2.13.1", | ||
"chai": "^3.3.0", | ||
"cross-env": "^2.0.1", | ||
"css-loader": "^0.23.1", | ||
"eslint": "^3.15.0", | ||
"eslint-plugin-react": "^4.2.3", | ||
@@ -63,4 +74,8 @@ "estraverse": "^4.2.0", | ||
"html": "0.0.10", | ||
"husky": "^0.13.2", | ||
"jsdom": "^8.3.0", | ||
"lint-staged": "^3.3.1", | ||
"mocha": "^2.5.3", | ||
"prettier": "^0.22.0", | ||
"prettier-check": "^1.0.0", | ||
"react": "^15.0.0", | ||
@@ -67,0 +82,0 @@ "react-addons-test-utils": "^15.3.2", |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality 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
3806
897677
43
38
1
0