Comparing version 1.31.1 to 2.0.0-alpha.0
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports["default"] = void 0; | ||
@@ -43,3 +43,3 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
function (_parent) { | ||
(0, _inherits2.default)(_class, _parent); | ||
(0, _inherits2["default"])(_class, _parent); | ||
@@ -49,5 +49,5 @@ function _class() { | ||
(0, _classCallCheck2.default)(this, _class); | ||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(_class).apply(this, arguments)); | ||
_this.state = (0, _objectSpread2.default)({}, _this.state, { | ||
(0, _classCallCheck2["default"])(this, _class); | ||
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(_class).apply(this, arguments)); | ||
_this.state = (0, _objectSpread2["default"])({}, _this.state, { | ||
model: _this.props.model, | ||
@@ -59,9 +59,9 @@ modelSync: _this.props.model | ||
(0, _createClass2.default)(_class, [{ | ||
(0, _createClass2["default"])(_class, [{ | ||
key: "componentWillReceiveProps", | ||
value: function componentWillReceiveProps(_ref) { | ||
var model = _ref.model; | ||
(0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "componentWillReceiveProps", this).apply(this, arguments); | ||
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "componentWillReceiveProps", this).apply(this, arguments); | ||
if (!(0, _isEqual.default)(this.props.model, model)) { | ||
if (!(0, _isEqual["default"])(this.props.model, model)) { | ||
this.setState(function () { | ||
@@ -78,3 +78,3 @@ return { | ||
value: function getNativeFormProps() { | ||
return (0, _omit.default)((0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "getNativeFormProps", this).call(this), ['onChangeModel']); | ||
return (0, _omit["default"])((0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getNativeFormProps", this).call(this), ['onChangeModel']); | ||
} | ||
@@ -94,3 +94,3 @@ }, { | ||
return { | ||
modelSync: (0, _set.default)((0, _cloneDeep.default)(state.modelSync), key, value) | ||
modelSync: (0, _set["default"])((0, _cloneDeep["default"])(state.modelSync), key, value) | ||
}; | ||
@@ -112,7 +112,7 @@ }; | ||
this.setState(updateState); | ||
(0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "onChange", this).apply(this, arguments); | ||
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "onChange", this).apply(this, arguments); | ||
this.setState(updateModel); | ||
} else { | ||
this.setState(updateState, function () { | ||
(0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "onChange", _this2).apply(_this2, _arguments); | ||
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "onChange", _this2).apply(_this2, _arguments); | ||
@@ -126,3 +126,3 @@ _this2.setState(updateModel); | ||
value: function __reset(state) { | ||
return (0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "__reset", this).call(this, state), { | ||
return (0, _objectSpread2["default"])({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "__reset", this).call(this, state), { | ||
model: this.props.model, | ||
@@ -139,9 +139,9 @@ modelSync: this.props.model | ||
return _class; | ||
}(parent), _class.Auto = Auto, _class.displayName = "Auto".concat(parent.displayName), _class.propTypes = (0, _objectSpread2.default)({}, parent.propTypes, { | ||
onChangeModel: _propTypes.default.func | ||
}(parent), _class.Auto = Auto, _class.displayName = "Auto".concat(parent.displayName), _class.propTypes = (0, _objectSpread2["default"])({}, parent.propTypes, { | ||
onChangeModel: _propTypes["default"].func | ||
}), _temp; | ||
}; | ||
var _default = Auto(_ValidatedQuickForm.default); | ||
var _default = Auto(_ValidatedQuickForm["default"]); | ||
exports.default = _default; | ||
exports["default"] = _default; |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports["default"] = void 0; | ||
@@ -25,6 +25,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
@@ -58,3 +58,3 @@ | ||
function (_Component) { | ||
(0, _inherits2.default)(BaseField, _Component); | ||
(0, _inherits2["default"])(BaseField, _Component); | ||
@@ -64,5 +64,5 @@ function BaseField() { | ||
(0, _classCallCheck2.default)(this, BaseField); | ||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(BaseField).apply(this, arguments)); | ||
(0, _invariant.default)(_this.context.uniforms, '<%s /> must be rendered within a form.', _this.constructor.displayName); | ||
(0, _classCallCheck2["default"])(this, BaseField); | ||
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(BaseField).apply(this, arguments)); | ||
(0, _invariant["default"])(_this.context.uniforms, '<%s /> must be rendered within a form.', _this.constructor.displayName); | ||
_this.options = { | ||
@@ -75,5 +75,5 @@ ensureValue: true, | ||
_this.randomId = _this.context.uniforms.randomId(); | ||
_this.findValue = _this.findValue.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); | ||
_this.findField = _this.findField.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); | ||
_this.findError = _this.findError.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); | ||
_this.findValue = _this.findValue.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this.findField = _this.findField.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this.findError = _this.findError.bind((0, _assertThisInitialized2["default"])(_this)); | ||
return _this; | ||
@@ -83,3 +83,3 @@ } // eslint-disable-next-line complexity | ||
(0, _createClass2.default)(BaseField, [{ | ||
(0, _createClass2["default"])(BaseField, [{ | ||
key: "shouldComponentUpdate", | ||
@@ -91,3 +91,3 @@ value: function shouldComponentUpdate(nextProps, _, _ref) { | ||
if (!(0, _isEqual.default)(prevProps, nextProps)) { | ||
if (!(0, _isEqual["default"])(prevProps, nextProps)) { | ||
return true; | ||
@@ -98,13 +98,13 @@ } | ||
nextMap = _nextContext$state.changedMap, | ||
nextState = (0, _objectWithoutProperties2.default)(_nextContext$state, ["changedMap"]); | ||
nextState = (0, _objectWithoutProperties2["default"])(_nextContext$state, ["changedMap"]); | ||
var _prevContext$state = prevContext.state, | ||
prevMap = _prevContext$state.changedMap, | ||
prevState = (0, _objectWithoutProperties2.default)(_prevContext$state, ["changedMap"]); | ||
prevState = (0, _objectWithoutProperties2["default"])(_prevContext$state, ["changedMap"]); | ||
if (!(0, _isEqual.default)(prevState, nextState)) { | ||
if (!(0, _isEqual["default"])(prevState, nextState)) { | ||
return true; | ||
} | ||
var prevName = (0, _joinName.default)(prevContext.name, prevProps.name); | ||
var nextName = (0, _joinName.default)(nextContext.name, nextProps.name); | ||
var prevName = (0, _joinName["default"])(prevContext.name, prevProps.name); | ||
var nextName = (0, _joinName["default"])(nextContext.name, nextProps.name); | ||
@@ -115,3 +115,3 @@ if (prevName !== nextName) { | ||
if (!(0, _isEqual.default)((0, _get.default)(prevMap, prevName), (0, _get.default)(nextMap, nextName))) { | ||
if (!(0, _isEqual["default"])((0, _get["default"])(prevMap, prevName), (0, _get["default"])(nextMap, nextName))) { | ||
return true; | ||
@@ -122,6 +122,6 @@ } // Fields which are using parent props, need to be updated when parent value change | ||
if (this.options.includeParent && nextName.indexOf('.') !== -1) { | ||
var prevParentValue = (0, _get.default)(prevContext.model, prevName.replace(/(.+)\..+$/, '$1')); | ||
var nextParentValue = (0, _get.default)(nextContext.model, nextName.replace(/(.+)\..+$/, '$1')); | ||
var prevParentValue = (0, _get["default"])(prevContext.model, prevName.replace(/(.+)\..+$/, '$1')); | ||
var nextParentValue = (0, _get["default"])(nextContext.model, nextName.replace(/(.+)\..+$/, '$1')); | ||
if (!(0, _isEqual.default)(prevParentValue, nextParentValue)) { | ||
if (!(0, _isEqual["default"])(prevParentValue, nextParentValue)) { | ||
return true; | ||
@@ -131,6 +131,6 @@ } | ||
var prevValue = (0, _get.default)(prevContext.model, prevName); | ||
var nextValue = (0, _get.default)(nextContext.model, nextName); | ||
var prevValue = (0, _get["default"])(prevContext.model, prevName); | ||
var nextValue = (0, _get["default"])(nextContext.model, nextName); | ||
if (!(0, _isEqual.default)(prevValue, nextValue)) { | ||
if (!(0, _isEqual["default"])(prevValue, nextValue)) { | ||
return true; | ||
@@ -143,3 +143,3 @@ } | ||
if (!(0, _isEqual.default)(prevError, nextError)) { | ||
if (!(0, _isEqual["default"])(prevError, nextError)) { | ||
return true; | ||
@@ -171,2 +171,3 @@ } // Fields like List or Nest should update, whenever their children error has changed | ||
onChange: this.getChildContextOnChange(), | ||
onSubmit: this.getChildContextOnSubmit(), | ||
randomId: this.context.uniforms.randomId | ||
@@ -179,3 +180,3 @@ } | ||
value: function getChildContextName() { | ||
return (0, _joinName.default)(null, this.context.uniforms.name, this.props.name); | ||
return (0, _joinName["default"])(null, this.context.uniforms.name, this.props.name); | ||
} | ||
@@ -202,3 +203,3 @@ }, { | ||
return (0, _objectSpread2.default)({}, state, { | ||
return (0, _objectSpread2["default"])({}, state, { | ||
label: propagate('label'), | ||
@@ -219,2 +220,7 @@ disabled: propagate('disabled'), | ||
return this.context.uniforms.onChange; | ||
} | ||
}, { | ||
key: "getChildContextOnSubmit", | ||
value: function getChildContextOnSubmit() { | ||
return this.context.uniforms.onSubmit; | ||
} // eslint-disable-next-line complexity | ||
@@ -231,6 +237,6 @@ | ||
if (name === undefined) { | ||
name = (0, _joinName.default)(context.name, props.name); | ||
name = (0, _joinName["default"])(context.name, props.name); | ||
} | ||
var changed = !!(0, _get.default)(context.state.changedMap, name); | ||
var changed = !!(0, _get["default"])(context.state.changedMap, name); | ||
var error = context.schema.getError(name, context.error); | ||
@@ -241,3 +247,3 @@ var errorMessage = context.schema.getErrorMessage(name, context.error); | ||
var fields = context.schema.getSubfields(name); | ||
var schemaProps = context.schema.getProps(name, (0, _objectSpread2.default)({}, state, props)); | ||
var schemaProps = context.schema.getProps(name, (0, _objectSpread2["default"])({}, state, props)); | ||
var initialValue = options.explicitInitialValue ? context.schema.getInitialValue(name, props) : undefined; | ||
@@ -249,3 +255,3 @@ var parent = options.includeParent && name.indexOf('.') !== -1 ? this.getFieldProps(name.replace(/(.+)\..+$/, '$1'), { | ||
var _flowingProp = flowingProp(props.label, schemaProps.label, state.label, ''), | ||
_flowingProp2 = (0, _slicedToArray2.default)(_flowingProp, 2), | ||
_flowingProp2 = (0, _slicedToArray2["default"])(_flowingProp, 2), | ||
label = _flowingProp2[0], | ||
@@ -255,3 +261,3 @@ none = _flowingProp2[1]; | ||
var _flowingProp3 = flowingProp(props.placeholder, schemaProps.placeholder, state.placeholder, label || none), | ||
_flowingProp4 = (0, _slicedToArray2.default)(_flowingProp3, 1), | ||
_flowingProp4 = (0, _slicedToArray2["default"])(_flowingProp3, 1), | ||
placeholder = _flowingProp4[0]; | ||
@@ -262,3 +268,3 @@ | ||
if (props.value === undefined || options.overrideValue) { | ||
value = (0, _get.default)(context.model, name); | ||
value = (0, _get["default"])(context.model, name); | ||
@@ -276,3 +282,3 @@ if (value === undefined && !changed && !options.explicitInitialValue) { | ||
return (0, _objectSpread2.default)({ | ||
return (0, _objectSpread2["default"])({ | ||
// 0. Constant props. | ||
@@ -321,3 +327,3 @@ findError: this.findError, | ||
value: function findValue(name) { | ||
return (0, _get.default)(this.context.uniforms.model, name); | ||
return (0, _get["default"])(this.context.uniforms.model, name); | ||
} | ||
@@ -328,12 +334,12 @@ }]); | ||
exports.default = BaseField; | ||
exports["default"] = BaseField; | ||
BaseField.displayName = 'Field'; | ||
BaseField.contextTypes = _BaseForm.default.childContextTypes; | ||
BaseField.childContextTypes = _BaseForm.default.childContextTypes; | ||
BaseField.contextTypes = _BaseForm["default"].childContextTypes; | ||
BaseField.childContextTypes = _BaseForm["default"].childContextTypes; | ||
BaseField.propTypes = process.env.NODE_ENV !== "production" ? { | ||
id: _propTypes.default.string, | ||
name: _propTypes.default.string.isRequired, | ||
disabled: _propTypes.default.bool, | ||
label: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string, _propTypes.default.node]), | ||
placeholder: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]) | ||
id: _propTypes["default"].string, | ||
name: _propTypes["default"].string.isRequired, | ||
disabled: _propTypes["default"].bool, | ||
label: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].string, _propTypes["default"].node]), | ||
placeholder: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].string]) | ||
} : {}; |
125
BaseForm.js
@@ -10,3 +10,3 @@ "use strict"; | ||
}); | ||
exports.default = exports.__childContextTypesBuild = exports.__childContextTypes = void 0; | ||
exports["default"] = exports.__childContextTypesBuild = exports.__childContextTypes = void 0; | ||
@@ -23,6 +23,6 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
@@ -53,27 +53,28 @@ | ||
var __childContextTypes = { | ||
name: _propTypes.default.arrayOf(_propTypes.default.string).isRequired, | ||
error: _propTypes.default.object, | ||
model: _propTypes.default.object.isRequired, | ||
name: _propTypes["default"].arrayOf(_propTypes["default"].string).isRequired, | ||
error: _propTypes["default"].object, | ||
model: _propTypes["default"].object.isRequired, | ||
schema: { | ||
getError: _propTypes.default.func.isRequired, | ||
getErrorMessage: _propTypes.default.func.isRequired, | ||
getErrorMessages: _propTypes.default.func.isRequired, | ||
getField: _propTypes.default.func.isRequired, | ||
getInitialValue: _propTypes.default.func.isRequired, | ||
getProps: _propTypes.default.func.isRequired, | ||
getSubfields: _propTypes.default.func.isRequired, | ||
getType: _propTypes.default.func.isRequired, | ||
getValidator: _propTypes.default.func.isRequired | ||
getError: _propTypes["default"].func.isRequired, | ||
getErrorMessage: _propTypes["default"].func.isRequired, | ||
getErrorMessages: _propTypes["default"].func.isRequired, | ||
getField: _propTypes["default"].func.isRequired, | ||
getInitialValue: _propTypes["default"].func.isRequired, | ||
getProps: _propTypes["default"].func.isRequired, | ||
getSubfields: _propTypes["default"].func.isRequired, | ||
getType: _propTypes["default"].func.isRequired, | ||
getValidator: _propTypes["default"].func.isRequired | ||
}, | ||
state: { | ||
changed: _propTypes.default.bool.isRequired, | ||
changedMap: _propTypes.default.object.isRequired, | ||
submitting: _propTypes.default.bool.isRequired, | ||
label: _propTypes.default.bool.isRequired, | ||
disabled: _propTypes.default.bool.isRequired, | ||
placeholder: _propTypes.default.bool.isRequired, | ||
showInlineError: _propTypes.default.bool.isRequired | ||
changed: _propTypes["default"].bool.isRequired, | ||
changedMap: _propTypes["default"].object.isRequired, | ||
submitting: _propTypes["default"].bool.isRequired, | ||
label: _propTypes["default"].bool.isRequired, | ||
disabled: _propTypes["default"].bool.isRequired, | ||
placeholder: _propTypes["default"].bool.isRequired, | ||
showInlineError: _propTypes["default"].bool.isRequired | ||
}, | ||
onChange: _propTypes.default.func.isRequired, | ||
randomId: _propTypes.default.func.isRequired | ||
onChange: _propTypes["default"].func.isRequired, | ||
onSubmit: _propTypes["default"].func.isRequired, | ||
randomId: _propTypes["default"].func.isRequired | ||
}; | ||
@@ -83,3 +84,3 @@ exports.__childContextTypes = __childContextTypes; | ||
var __childContextTypesBuild = function __childContextTypesBuild(type) { | ||
return (0, _isPlainObject.default)(type) ? _propTypes.default.shape((0, _mapValues.default)(type, __childContextTypesBuild)).isRequired : type; | ||
return (0, _isPlainObject["default"])(type) ? _propTypes["default"].shape((0, _mapValues["default"])(type, __childContextTypesBuild)).isRequired : type; | ||
}; | ||
@@ -92,3 +93,3 @@ | ||
function (_Component) { | ||
(0, _inherits2.default)(BaseForm, _Component); | ||
(0, _inherits2["default"])(BaseForm, _Component); | ||
@@ -98,6 +99,6 @@ function BaseForm() { | ||
(0, _classCallCheck2.default)(this, BaseForm); | ||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(BaseForm).apply(this, arguments)); | ||
(0, _classCallCheck2["default"])(this, BaseForm); | ||
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(BaseForm).apply(this, arguments)); | ||
_this.state = { | ||
bridge: (0, _createSchemaBridge.default)(_this.props.schema), | ||
bridge: (0, _createSchemaBridge["default"])(_this.props.schema), | ||
changed: null, | ||
@@ -110,8 +111,8 @@ changedMap: {}, | ||
_this.mounted = false; | ||
_this.randomId = (0, _randomIds.default)(_this.props.id); | ||
_this.onReset = _this.reset = _this.onReset.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); | ||
_this.onChange = _this.change = _this.onChange.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); | ||
_this.onSubmit = _this.submit = _this.onSubmit.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); // TODO: It shouldn't be here | ||
_this.randomId = (0, _randomIds["default"])(_this.props.id); | ||
_this.onReset = _this.reset = _this.onReset.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this.onChange = _this.change = _this.onChange.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this.onSubmit = _this.submit = _this.onSubmit.bind((0, _assertThisInitialized2["default"])(_this)); // TODO: It shouldn't be here | ||
var getModel = _this.getModel.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); | ||
var getModel = _this.getModel.bind((0, _assertThisInitialized2["default"])(_this)); | ||
@@ -127,3 +128,3 @@ _this.getModel = function () { | ||
(0, _createClass2.default)(BaseForm, [{ | ||
(0, _createClass2["default"])(BaseForm, [{ | ||
key: "getChildContext", | ||
@@ -139,2 +140,3 @@ value: function getChildContext() { | ||
onChange: this.getChildContextOnChange(), | ||
onSubmit: this.getChildContextOnSubmit(), | ||
randomId: this.randomId | ||
@@ -183,2 +185,7 @@ } | ||
}, { | ||
key: "getChildContextOnSubmit", | ||
value: function getChildContextOnSubmit() { | ||
return this.onSubmit; | ||
} | ||
}, { | ||
key: "getModel", | ||
@@ -220,3 +227,3 @@ value: function getModel() | ||
return { | ||
bridge: (0, _createSchemaBridge.default)(schema) | ||
bridge: (0, _createSchemaBridge["default"])(schema) | ||
}; | ||
@@ -229,3 +236,3 @@ }); | ||
value: function render() { | ||
return _react.default.createElement("form", this.getNativeFormProps()); | ||
return _react["default"].createElement("form", this.getNativeFormProps()); | ||
} | ||
@@ -235,3 +242,3 @@ }, { | ||
value: function getChangedKeys(root, valueA, valueB) { | ||
return (0, _changedKeys.default)(root, valueA, valueB); | ||
return (0, _changedKeys["default"])(root, valueA, valueB); | ||
} | ||
@@ -241,4 +248,4 @@ }, { | ||
value: function getNativeFormProps() { | ||
var props = (0, _omit.default)(this.props, ['autosave', 'autosaveDelay', 'disabled', 'error', 'label', 'model', 'modelTransform', 'onChange', 'onSubmit', 'onSubmitFailure', 'onSubmitSuccess', 'placeholder', 'schema', 'showInlineError']); | ||
return (0, _objectSpread2.default)({}, props, { | ||
var props = (0, _omit["default"])(this.props, ['autosave', 'autosaveDelay', 'disabled', 'error', 'label', 'model', 'modelTransform', 'onChange', 'onSubmit', 'onSubmitFailure', 'onSubmitSuccess', 'placeholder', 'schema', 'showInlineError']); | ||
return (0, _objectSpread2["default"])({}, props, { | ||
onSubmit: this.onSubmit, | ||
@@ -256,6 +263,6 @@ key: "reset-".concat(this.state.resetCount) | ||
this.state.changed = true; | ||
this.getChangedKeys(key, value, (0, _get.default)(this.getModel(), key)).forEach(function (key) { | ||
this.getChangedKeys(key, value, (0, _get["default"])(this.getModel(), key)).forEach(function (key) { | ||
return _this3.setState(function (state) { | ||
return { | ||
changedMap: (0, _set.default)((0, _cloneDeep.default)(state.changedMap), key, {}) | ||
changedMap: (0, _set["default"])((0, _cloneDeep["default"])(state.changedMap), key, {}) | ||
}; | ||
@@ -312,7 +319,7 @@ }); | ||
if (result && (0, _isFunction.default)(result.then)) { | ||
if (result && (0, _isFunction["default"])(result.then)) { | ||
this.setState({ | ||
submitting: true | ||
}); | ||
submitting = result.finally(function () { | ||
submitting = result["finally"](function () { | ||
return _this4.setState({ | ||
@@ -332,3 +339,3 @@ submitting: false | ||
exports.default = BaseForm; | ||
exports["default"] = BaseForm; | ||
BaseForm.displayName = 'Form'; | ||
@@ -346,16 +353,16 @@ BaseForm.defaultProps = { | ||
BaseForm.propTypes = process.env.NODE_ENV !== "production" ? { | ||
error: _propTypes.default.object, | ||
model: _propTypes.default.object, | ||
schema: _propTypes.default.any.isRequired, | ||
modelTransform: _propTypes.default.func, | ||
onChange: _propTypes.default.func, | ||
onSubmit: _propTypes.default.func, | ||
onSubmitFailure: _propTypes.default.func, | ||
onSubmitSuccess: _propTypes.default.func, | ||
label: _propTypes.default.bool, | ||
disabled: _propTypes.default.bool, | ||
placeholder: _propTypes.default.bool, | ||
showInlineError: _propTypes.default.bool, | ||
autosave: _propTypes.default.bool, | ||
autosaveDelay: _propTypes.default.number | ||
error: _propTypes["default"].object, | ||
model: _propTypes["default"].object, | ||
schema: _propTypes["default"].any.isRequired, | ||
modelTransform: _propTypes["default"].func, | ||
onChange: _propTypes["default"].func, | ||
onSubmit: _propTypes["default"].func, | ||
onSubmitFailure: _propTypes["default"].func, | ||
onSubmitSuccess: _propTypes["default"].func, | ||
label: _propTypes["default"].bool, | ||
disabled: _propTypes["default"].bool, | ||
placeholder: _propTypes["default"].bool, | ||
showInlineError: _propTypes["default"].bool, | ||
autosave: _propTypes["default"].bool, | ||
autosaveDelay: _propTypes["default"].number | ||
} : {}; |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports["default"] = void 0; | ||
@@ -21,7 +21,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
function Bridge() { | ||
(0, _classCallCheck2.default)(this, Bridge); | ||
(0, _invariant.default)(this.constructor !== Bridge, 'Bridge cannot be instantiated.'); | ||
(0, _classCallCheck2["default"])(this, Bridge); | ||
(0, _invariant["default"])(this.constructor !== Bridge, 'Bridge cannot be instantiated.'); | ||
} | ||
(0, _createClass2.default)(Bridge, [{ | ||
(0, _createClass2["default"])(Bridge, [{ | ||
key: "getError", | ||
@@ -31,3 +31,3 @@ value: function getError() | ||
{ | ||
(0, _invariant.default)(false, '%s have not implemented `getError` method.', this.constructor.name); | ||
(0, _invariant["default"])(false, '%s have not implemented `getError` method.', this.constructor.name); | ||
} | ||
@@ -39,3 +39,3 @@ }, { | ||
{ | ||
(0, _invariant.default)(false, '%s have not implemented `getError` method.', this.constructor.name); | ||
(0, _invariant["default"])(false, '%s have not implemented `getErrorMessage` method.', this.constructor.name); | ||
} | ||
@@ -47,3 +47,3 @@ }, { | ||
{ | ||
(0, _invariant.default)(false, '%s have not implemented `getErrorMessages` method.', this.constructor.name); | ||
(0, _invariant["default"])(false, '%s have not implemented `getErrorMessages` method.', this.constructor.name); | ||
} | ||
@@ -55,3 +55,3 @@ }, { | ||
{ | ||
(0, _invariant.default)(false, '%s have not implemented `getField` method.', this.constructor.name); | ||
(0, _invariant["default"])(false, '%s have not implemented `getField` method.', this.constructor.name); | ||
} | ||
@@ -63,3 +63,3 @@ }, { | ||
{ | ||
(0, _invariant.default)(false, '%s have not implemented `getInitialValue` method.', this.constructor.name); | ||
(0, _invariant["default"])(false, '%s have not implemented `getInitialValue` method.', this.constructor.name); | ||
} | ||
@@ -71,3 +71,3 @@ }, { | ||
{ | ||
(0, _invariant.default)(false, '%s have not implemented `getProps` method.', this.constructor.name); | ||
(0, _invariant["default"])(false, '%s have not implemented `getProps` method.', this.constructor.name); | ||
} | ||
@@ -79,3 +79,3 @@ }, { | ||
{ | ||
(0, _invariant.default)(false, '%s have not implemented `getSubfields` method.', this.constructor.name); | ||
(0, _invariant["default"])(false, '%s have not implemented `getSubfields` method.', this.constructor.name); | ||
} | ||
@@ -87,3 +87,3 @@ }, { | ||
{ | ||
(0, _invariant.default)(false, '%s have not implemented `getType` method.', this.constructor.name); | ||
(0, _invariant["default"])(false, '%s have not implemented `getType` method.', this.constructor.name); | ||
} | ||
@@ -95,3 +95,3 @@ }, { | ||
{ | ||
(0, _invariant.default)(false, '%s have not implemented `getValidator` method.', this.constructor.name); | ||
(0, _invariant["default"])(false, '%s have not implemented `getValidator` method.', this.constructor.name); | ||
} | ||
@@ -103,3 +103,3 @@ }], [{ | ||
{ | ||
(0, _invariant.default)(false, '%s have not implemented `check` method.', this.name); | ||
(0, _invariant["default"])(false, '%s have not implemented `check` method.', this.name); | ||
} | ||
@@ -110,2 +110,2 @@ }]); | ||
exports.default = Bridge; | ||
exports["default"] = Bridge; |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = changedKeys; | ||
exports["default"] = changedKeys; | ||
@@ -39,4 +39,4 @@ var _isEqual = _interopRequireDefault(require("lodash/isEqual")); | ||
var changed = (0, _xorWith.default)(pairsA, pairsB, _isEqual.default).map(function (pair) { | ||
return (0, _joinName.default)(root, pair[1]); | ||
var changed = (0, _xorWith["default"])(pairsA, pairsB, _isEqual["default"]).map(function (pair) { | ||
return (0, _joinName["default"])(root, pair[1]); | ||
}); | ||
@@ -52,7 +52,7 @@ | ||
return [root].concat(Object.keys(valueA).map(function (key) { | ||
return (0, _joinName.default)(root, key); | ||
return (0, _joinName["default"])(root, key); | ||
})); | ||
} | ||
return (0, _isEqual.default)(valueA, valueB) ? [] : [root]; | ||
return (0, _isEqual["default"])(valueA, valueB) ? [] : [root]; | ||
} |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = connectField; | ||
exports["default"] = connectField; | ||
@@ -36,3 +36,3 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
_ref$baseField = _ref.baseField, | ||
baseField = _ref$baseField === void 0 ? _BaseField.default : _ref$baseField, | ||
baseField = _ref$baseField === void 0 ? _BaseField["default"] : _ref$baseField, | ||
_ref$mapProps = _ref.mapProps, | ||
@@ -48,3 +48,3 @@ mapProps = _ref$mapProps === void 0 ? identity : _ref$mapProps, | ||
function (_baseField) { | ||
(0, _inherits2.default)(_class, _baseField); | ||
(0, _inherits2["default"])(_class, _baseField); | ||
@@ -54,4 +54,4 @@ function _class() { | ||
(0, _classCallCheck2.default)(this, _class); | ||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(_class).apply(this, arguments)); | ||
(0, _classCallCheck2["default"])(this, _class); | ||
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(_class).apply(this, arguments)); | ||
_this.options.includeInChain = includeInChain === undefined ? true : includeInChain; | ||
@@ -64,6 +64,6 @@ _this.options.initialValue = initialValue === undefined ? true : initialValue; | ||
(0, _createClass2.default)(_class, [{ | ||
(0, _createClass2["default"])(_class, [{ | ||
key: "getChildContextName", | ||
value: function getChildContextName() { | ||
return this.options.includeInChain ? (0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "getChildContextName", this).call(this) : this.context.uniforms.name; | ||
return this.options.includeInChain ? (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getChildContextName", this).call(this) : this.context.uniforms.name; | ||
} | ||
@@ -70,0 +70,0 @@ }, { |
@@ -8,16 +8,8 @@ "use strict"; | ||
}); | ||
exports.default = createSchemaBridge; | ||
exports["default"] = createSchemaBridge; | ||
var _invariant = _interopRequireDefault(require("invariant")); | ||
var _GraphQLBridge = _interopRequireDefault(require("./GraphQLBridge")); | ||
var bridges = []; | ||
var _JSONSchemaBridge = _interopRequireDefault(require("./JSONSchemaBridge")); | ||
var _SimpleSchema2Bridge = _interopRequireDefault(require("./SimpleSchema2Bridge")); | ||
var _SimpleSchemaBridge = _interopRequireDefault(require("./SimpleSchemaBridge")); | ||
var bridges = [_GraphQLBridge.default, _JSONSchemaBridge.default, _SimpleSchemaBridge.default, _SimpleSchema2Bridge.default]; | ||
var isBridge = function isBridge(schema) { | ||
@@ -36,4 +28,8 @@ return schema && schema.getError && schema.getErrorMessage && schema.getErrorMessages && schema.getField && schema.getInitialValue && schema.getProps && schema.getSubfields && schema.getType && schema.getValidator; | ||
}); | ||
(0, _invariant.default)(Bridge, 'Unrecognised schema: %s', schema); | ||
(0, _invariant["default"])(Bridge, 'Unrecognised schema: %s', schema); | ||
return new Bridge(schema); | ||
} | ||
} | ||
createSchemaBridge.register = function (bridge) { | ||
bridges.unshift(bridge); | ||
}; |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = filterDOMProps; | ||
exports["default"] = filterDOMProps; | ||
@@ -18,3 +18,3 @@ var _omit = _interopRequireDefault(require("lodash/omit")); | ||
function filterDOMProps(props) { | ||
return (0, _omit.default)(props, unwantedProps); | ||
return (0, _omit["default"])(props, unwantedProps); | ||
} // Bridges have to register additional props | ||
@@ -21,0 +21,0 @@ |
54
index.js
@@ -11,3 +11,3 @@ "use strict"; | ||
get: function get() { | ||
return _AutoForm.default; | ||
return _AutoForm["default"]; | ||
} | ||
@@ -18,3 +18,3 @@ }); | ||
get: function get() { | ||
return _BaseField.default; | ||
return _BaseField["default"]; | ||
} | ||
@@ -25,3 +25,3 @@ }); | ||
get: function get() { | ||
return _BaseForm.default; | ||
return _BaseForm["default"]; | ||
} | ||
@@ -32,33 +32,15 @@ }); | ||
get: function get() { | ||
return _Bridge.default; | ||
return _Bridge["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "GraphQLBridge", { | ||
enumerable: true, | ||
get: function get() { | ||
return _GraphQLBridge.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "QuickForm", { | ||
enumerable: true, | ||
get: function get() { | ||
return _QuickForm.default; | ||
return _QuickForm["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "SimpleSchema2Bridge", { | ||
enumerable: true, | ||
get: function get() { | ||
return _SimpleSchema2Bridge.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "SimpleSchemaBridge", { | ||
enumerable: true, | ||
get: function get() { | ||
return _SimpleSchemaBridge.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "ValidatedForm", { | ||
enumerable: true, | ||
get: function get() { | ||
return _ValidatedForm.default; | ||
return _ValidatedForm["default"]; | ||
} | ||
@@ -69,3 +51,3 @@ }); | ||
get: function get() { | ||
return _ValidatedQuickForm.default; | ||
return _ValidatedQuickForm["default"]; | ||
} | ||
@@ -76,3 +58,3 @@ }); | ||
get: function get() { | ||
return _changedKeys.default; | ||
return _changedKeys["default"]; | ||
} | ||
@@ -83,3 +65,3 @@ }); | ||
get: function get() { | ||
return _connectField.default; | ||
return _connectField["default"]; | ||
} | ||
@@ -90,3 +72,3 @@ }); | ||
get: function get() { | ||
return _createSchemaBridge.default; | ||
return _createSchemaBridge["default"]; | ||
} | ||
@@ -97,3 +79,3 @@ }); | ||
get: function get() { | ||
return _filterDOMProps.default; | ||
return _filterDOMProps["default"]; | ||
} | ||
@@ -104,3 +86,3 @@ }); | ||
get: function get() { | ||
return _injectName.default; | ||
return _injectName["default"]; | ||
} | ||
@@ -111,3 +93,3 @@ }); | ||
get: function get() { | ||
return _joinName.default; | ||
return _joinName["default"]; | ||
} | ||
@@ -118,3 +100,3 @@ }); | ||
get: function get() { | ||
return _nothing.default; | ||
return _nothing["default"]; | ||
} | ||
@@ -125,3 +107,3 @@ }); | ||
get: function get() { | ||
return _randomIds.default; | ||
return _randomIds["default"]; | ||
} | ||
@@ -138,10 +120,4 @@ }); | ||
var _GraphQLBridge = _interopRequireDefault(require("./GraphQLBridge")); | ||
var _QuickForm = _interopRequireDefault(require("./QuickForm")); | ||
var _SimpleSchema2Bridge = _interopRequireDefault(require("./SimpleSchema2Bridge")); | ||
var _SimpleSchemaBridge = _interopRequireDefault(require("./SimpleSchemaBridge")); | ||
var _ValidatedForm = _interopRequireDefault(require("./ValidatedForm")); | ||
@@ -148,0 +124,0 @@ |
@@ -10,3 +10,3 @@ "use strict"; | ||
}); | ||
exports.default = injectName; | ||
exports["default"] = injectName; | ||
@@ -19,6 +19,6 @@ var _react = _interopRequireWildcard(require("react")); | ||
return _react.Children.map(children, function (child) { | ||
return child && typeof child !== 'string' && (!parent || !parent.props || !parent.props.name) ? !child.props ? _react.default.cloneElement(child, { | ||
return child && typeof child !== 'string' && (!parent || !parent.props || !parent.props.name) ? !child.props ? _react["default"].cloneElement(child, { | ||
name: name | ||
}) : _react.default.cloneElement(child, { | ||
name: (0, _joinName.default)(name, child.props.name), | ||
}) : _react["default"].cloneElement(child, { | ||
name: (0, _joinName["default"])(name, child.props.name), | ||
children: injectName(name, child.props.children, child) | ||
@@ -25,0 +25,0 @@ }) : child; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = joinName; | ||
exports["default"] = joinName; | ||
@@ -9,0 +9,0 @@ // FIXME: ESLint seems to have problems with this code. |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports["default"] = void 0; | ||
@@ -16,4 +16,4 @@ var _react = _interopRequireDefault(require("react")); | ||
// https://github.com/facebook/react/issues/5355 | ||
var _default = parseInt(_react.default.version, 10) < 15 ? _react.default.createElement("noscript", null) : null; | ||
var _default = parseInt(_react["default"].version, 10) < 15 ? _react["default"].createElement("noscript", null) : null; | ||
exports.default = _default; | ||
exports["default"] = _default; |
{ | ||
"name": "uniforms", | ||
"version": "1.31.1", | ||
"version": "2.0.0-alpha.0", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"module": "src/index.js", | ||
"jsnext:main": "src/index.js", | ||
"description": "Core package of uniforms.", | ||
@@ -25,6 +23,4 @@ "repository": "https://github.com/vazco/uniforms/tree/master/packages/uniforms", | ||
"peerDependencies": { | ||
"graphql": "^14.0.0 || 0.8.0 - 14.0.0", | ||
"react": "^16.0.0 || ^15.0.0 || ^0.14.0", | ||
"react-dom": "^16.0.0 || ^15.0.0 || ^0.14.0", | ||
"simpl-schema": "^1.0.0 || ^0.0.4" | ||
"react-dom": "^16.0.0 || ^15.0.0 || ^0.14.0" | ||
}, | ||
@@ -37,3 +33,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "e442e5df008f0d9822bb4e0b9a8c2005355b28ec" | ||
"gitHead": "d8c3b662036412ae6c75cdd6650e449267b4c341" | ||
} |
@@ -8,6 +8,8 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports["default"] = void 0; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
@@ -29,4 +31,2 @@ | ||
var _omit = _interopRequireDefault(require("lodash/omit")); | ||
var _BaseForm = _interopRequireDefault(require("./BaseForm")); | ||
@@ -42,32 +42,35 @@ | ||
function (_parent) { | ||
(0, _inherits2.default)(_class, _parent); | ||
(0, _inherits2["default"])(_class, _parent); | ||
function _class() { | ||
(0, _classCallCheck2.default)(this, _class); | ||
return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(_class).apply(this, arguments)); | ||
(0, _classCallCheck2["default"])(this, _class); | ||
return (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(_class).apply(this, arguments)); | ||
} | ||
(0, _createClass2.default)(_class, [{ | ||
(0, _createClass2["default"])(_class, [{ | ||
key: "getNativeFormProps", | ||
value: function getNativeFormProps() { | ||
return (0, _omit.default)((0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "getNativeFormProps", this).call(this), ['autoField', 'errorsField', 'submitField']); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var nativeFormProps = this.getNativeFormProps(); | ||
var _get$call = (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getNativeFormProps", this).call(this), | ||
_get$call$autoField = _get$call.autoField, | ||
AutoField = _get$call$autoField === void 0 ? this.getAutoField() : _get$call$autoField, | ||
_get$call$errorsField = _get$call.errorsField, | ||
ErrorsField = _get$call$errorsField === void 0 ? this.getErrorsField() : _get$call$errorsField, | ||
_get$call$submitField = _get$call.submitField, | ||
SubmitField = _get$call$submitField === void 0 ? this.getSubmitField() : _get$call$submitField, | ||
props = (0, _objectWithoutProperties2["default"])(_get$call, ["autoField", "errorsField", "submitField"]); | ||
if (nativeFormProps.children) { | ||
return (0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "render", this).call(this); | ||
if (!props.children) { | ||
props.children = this.getChildContextSchema().getSubfields().map(function (key) { | ||
return _react["default"].createElement(AutoField, { | ||
key: key, | ||
name: key | ||
}); | ||
}).concat([_react["default"].createElement(ErrorsField, { | ||
key: "$ErrorsField" | ||
}), _react["default"].createElement(SubmitField, { | ||
key: "$SubmitField" | ||
})]); | ||
} | ||
var AutoField = this.props.autoField || this.getAutoField(); | ||
var ErrorsField = this.props.errorsField || this.getErrorsField(); | ||
var SubmitField = this.props.submitField || this.getSubmitField(); | ||
return _react.default.createElement("form", nativeFormProps, this.getChildContextSchema().getSubfields().map(function (key) { | ||
return _react.default.createElement(AutoField, { | ||
key: key, | ||
name: key | ||
}); | ||
}), _react.default.createElement(ErrorsField, null), _react.default.createElement(SubmitField, null)); | ||
return props; | ||
} | ||
@@ -78,3 +81,3 @@ }, { | ||
return function () { | ||
return _nothing.default; | ||
return _nothing["default"]; | ||
}; | ||
@@ -86,3 +89,3 @@ } | ||
return function () { | ||
return _nothing.default; | ||
return _nothing["default"]; | ||
}; | ||
@@ -94,3 +97,3 @@ } | ||
return function () { | ||
return _nothing.default; | ||
return _nothing["default"]; | ||
}; | ||
@@ -100,11 +103,11 @@ } | ||
return _class; | ||
}(parent), _class.Quick = Quick, _class.displayName = "Quick".concat(parent.displayName), _class.propTypes = (0, _objectSpread2.default)({}, parent.propTypes, { | ||
autoField: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]), | ||
errorsField: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]), | ||
submitField: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]) | ||
}(parent), _class.Quick = Quick, _class.displayName = "Quick".concat(parent.displayName), _class.propTypes = (0, _objectSpread2["default"])({}, parent.propTypes, { | ||
autoField: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].string]), | ||
errorsField: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].string]), | ||
submitField: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].string]) | ||
}), _temp; | ||
}; | ||
var _default = Quick(_BaseForm.default); | ||
var _default = Quick(_BaseForm["default"]); | ||
exports.default = _default; | ||
exports["default"] = _default; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = randomIds; | ||
exports["default"] = randomIds; | ||
@@ -9,0 +9,0 @@ // Workaround for SSR |
@@ -140,2 +140,3 @@ import PropTypes from 'prop-types'; | ||
onChange: this.getChildContextOnChange(), | ||
onSubmit: this.getChildContextOnSubmit(), | ||
randomId: this.context.uniforms.randomId | ||
@@ -182,2 +183,6 @@ } | ||
getChildContextOnSubmit() { | ||
return this.context.uniforms.onSubmit; | ||
} | ||
// eslint-disable-next-line complexity | ||
@@ -184,0 +189,0 @@ getFieldProps(name, options) { |
@@ -46,2 +46,3 @@ import PropTypes from 'prop-types'; | ||
onChange: PropTypes.func.isRequired, | ||
onSubmit: PropTypes.func.isRequired, | ||
randomId: PropTypes.func.isRequired | ||
@@ -125,2 +126,3 @@ }; | ||
onChange: this.getChildContextOnChange(), | ||
onSubmit: this.getChildContextOnSubmit(), | ||
randomId: this.randomId | ||
@@ -164,2 +166,6 @@ } | ||
getChildContextOnSubmit() { | ||
return this.onSubmit; | ||
} | ||
getModel(/* mode */) { | ||
@@ -166,0 +172,0 @@ return this.props.model; |
@@ -17,3 +17,3 @@ import invariant from 'invariant'; | ||
getErrorMessage(/* name, error */) { | ||
invariant(false, '%s have not implemented `getError` method.', this.constructor.name); | ||
invariant(false, '%s have not implemented `getErrorMessage` method.', this.constructor.name); | ||
} | ||
@@ -20,0 +20,0 @@ |
import invariant from 'invariant'; | ||
import GraphQLBridge from './GraphQLBridge'; | ||
import JSONSchemaBridge from './JSONSchemaBridge'; | ||
import SimpleSchema2Bridge from './SimpleSchema2Bridge'; | ||
import SimpleSchemaBridge from './SimpleSchemaBridge'; | ||
const bridges = []; | ||
const bridges = [GraphQLBridge, JSONSchemaBridge, SimpleSchemaBridge, SimpleSchema2Bridge]; | ||
const isBridge = schema => | ||
@@ -21,2 +16,3 @@ schema && | ||
schema.getValidator; | ||
export default function createSchemaBridge(schema) { | ||
@@ -34,1 +30,5 @@ // There's no need for an extra wrapper. | ||
} | ||
createSchemaBridge.register = bridge => { | ||
bridges.unshift(bridge); | ||
}; |
@@ -7,6 +7,3 @@ // @flow | ||
export {default as Bridge} from './Bridge'; | ||
export {default as GraphQLBridge} from './GraphQLBridge'; | ||
export {default as QuickForm} from './QuickForm'; | ||
export {default as SimpleSchema2Bridge} from './SimpleSchema2Bridge'; | ||
export {default as SimpleSchemaBridge} from './SimpleSchemaBridge'; | ||
export {default as ValidatedForm} from './ValidatedForm'; | ||
@@ -13,0 +10,0 @@ export {default as ValidatedQuickForm} from './ValidatedQuickForm'; |
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import omit from 'lodash/omit'; | ||
@@ -23,27 +22,17 @@ import BaseForm from './BaseForm'; | ||
getNativeFormProps() { | ||
return omit(super.getNativeFormProps(), ['autoField', 'errorsField', 'submitField']); | ||
} | ||
const { | ||
autoField: AutoField = this.getAutoField(), | ||
errorsField: ErrorsField = this.getErrorsField(), | ||
submitField: SubmitField = this.getSubmitField(), | ||
...props | ||
} = super.getNativeFormProps(); | ||
render() { | ||
const nativeFormProps = this.getNativeFormProps(); | ||
if (nativeFormProps.children) { | ||
return super.render(); | ||
if (!props.children) { | ||
props.children = this.getChildContextSchema() | ||
.getSubfields() | ||
.map(key => <AutoField key={key} name={key} />) | ||
.concat([<ErrorsField key="$ErrorsField" />, <SubmitField key="$SubmitField" />]); | ||
} | ||
const AutoField = this.props.autoField || this.getAutoField(); | ||
const ErrorsField = this.props.errorsField || this.getErrorsField(); | ||
const SubmitField = this.props.submitField || this.getSubmitField(); | ||
return ( | ||
<form {...nativeFormProps}> | ||
{this.getChildContextSchema() | ||
.getSubfields() | ||
.map(key => ( | ||
<AutoField key={key} name={key} /> | ||
))} | ||
<ErrorsField /> | ||
<SubmitField /> | ||
</form> | ||
); | ||
return props; | ||
} | ||
@@ -50,0 +39,0 @@ |
@@ -10,3 +10,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports["default"] = void 0; | ||
@@ -21,2 +21,4 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
@@ -28,4 +30,2 @@ | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
@@ -45,5 +45,5 @@ | ||
var childContextTypes = (0, _BaseForm.__childContextTypesBuild)((0, _merge.default)({ | ||
var childContextTypes = (0, _BaseForm.__childContextTypesBuild)((0, _merge["default"])({ | ||
state: { | ||
validating: _propTypes.default.bool.isRequired | ||
validating: _propTypes["default"].bool.isRequired | ||
} | ||
@@ -58,3 +58,3 @@ }, _BaseForm.__childContextTypes)); | ||
function (_parent) { | ||
(0, _inherits2.default)(_class, _parent); | ||
(0, _inherits2["default"])(_class, _parent); | ||
@@ -64,5 +64,5 @@ function _class() { | ||
(0, _classCallCheck2.default)(this, _class); | ||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(_class).apply(this, arguments)); | ||
_this.state = (0, _objectSpread2.default)({}, _this.state, { | ||
(0, _classCallCheck2["default"])(this, _class); | ||
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(_class).apply(this, arguments)); | ||
_this.state = (0, _objectSpread2["default"])({}, _this.state, { | ||
error: null, | ||
@@ -73,11 +73,11 @@ validate: false, | ||
}); | ||
_this.onValidate = _this.validate = _this.onValidate.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); | ||
_this.onValidateModel = _this.validateModel = _this.onValidateModel.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); | ||
_this.onValidate = _this.validate = _this.onValidate.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this.onValidateModel = _this.validateModel = _this.onValidateModel.bind((0, _assertThisInitialized2["default"])(_this)); | ||
return _this; | ||
} | ||
(0, _createClass2.default)(_class, [{ | ||
(0, _createClass2["default"])(_class, [{ | ||
key: "getChildContextError", | ||
value: function getChildContextError() { | ||
return (0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "getChildContextError", this).call(this) || this.state.error; | ||
return (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getChildContextError", this).call(this) || this.state.error; | ||
} | ||
@@ -87,3 +87,3 @@ }, { | ||
value: function getChildContextState() { | ||
return (0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "getChildContextState", this).call(this), { | ||
return (0, _objectSpread2["default"])({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getChildContextState", this).call(this), { | ||
validating: this.state.validating | ||
@@ -95,3 +95,3 @@ }); | ||
value: function getNativeFormProps() { | ||
return (0, _omit.default)((0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "getNativeFormProps", this).call(this), ['onValidate', 'validate', 'validator']); | ||
return (0, _omit["default"])((0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getNativeFormProps", this).call(this), ['onValidate', 'validate', 'validator']); | ||
} | ||
@@ -107,3 +107,3 @@ }, { | ||
validator = _ref.validator; | ||
(0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "componentWillReceiveProps", this).apply(this, arguments); | ||
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "componentWillReceiveProps", this).apply(this, arguments); | ||
@@ -118,8 +118,8 @@ if (this.props.schema !== schema || this.props.validator !== validator) { | ||
if (validate === 'onChange' || validate === 'onChangeAfterSubmit' && _this2.state.validate) { | ||
_this2.onValidate().catch(function () {}); | ||
_this2.onValidate()["catch"](function () {}); | ||
} | ||
}); | ||
} else if (!(0, _isEqual.default)(this.props.model, model)) { | ||
} else if (!(0, _isEqual["default"])(this.props.model, model)) { | ||
if (validate === 'onChange' || validate === 'onChangeAfterSubmit' && this.state.validate) { | ||
this.onValidateModel(model).catch(function () {}); | ||
this.onValidateModel(model)["catch"](function () {}); | ||
} | ||
@@ -133,3 +133,3 @@ } | ||
if (this.props.validate === 'onChange' || this.props.validate === 'onChangeAfterSubmit' && this.state.validate) { | ||
this.onValidate(key, value).catch(function () {}); | ||
this.onValidate(key, value)["catch"](function () {}); | ||
} // FIXME: https://github.com/vazco/uniforms/issues/293 | ||
@@ -141,3 +141,3 @@ // if (this.props.validate === 'onSubmit' && this.state.validate) { | ||
(0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "onChange", this).apply(this, arguments); | ||
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "onChange", this).apply(this, arguments); | ||
} | ||
@@ -147,3 +147,3 @@ }, { | ||
value: function __reset(state) { | ||
return (0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "__reset", this).call(this, state), { | ||
return (0, _objectSpread2["default"])({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "__reset", this).call(this, state), { | ||
error: null, | ||
@@ -172,3 +172,3 @@ validate: false, | ||
_this3.onValidate().then(function () { | ||
(0, _get2.default)((0, _getPrototypeOf2.default)(_class.prototype), "onSubmit", _this3).call(_this3).then(resolve, function (error) { | ||
(0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "onSubmit", _this3).call(_this3).then(resolve, function (error) { | ||
_this3.setState({ | ||
@@ -183,3 +183,3 @@ error: error | ||
}); | ||
promise.catch(function () {// `onSubmit` should never reject, so we ignore this rejection. | ||
promise["catch"](function () {// `onSubmit` should never reject, so we ignore this rejection. | ||
}).then(function () { | ||
@@ -202,3 +202,3 @@ // It can be already unmounted. | ||
if (model && key) { | ||
model = (0, _set.default)((0, _cloneDeep.default)(model), key, (0, _cloneDeep.default)(value)); | ||
model = (0, _set["default"])((0, _cloneDeep["default"])(model), key, (0, _cloneDeep["default"])(value)); | ||
} | ||
@@ -247,3 +247,3 @@ | ||
return _class; | ||
}(parent), _class.Validated = Validated, _class.displayName = "Validated".concat(parent.displayName), _class.defaultProps = (0, _objectSpread2.default)({}, parent.defaultProps, { | ||
}(parent), _class.Validated = Validated, _class.displayName = "Validated".concat(parent.displayName), _class.defaultProps = (0, _objectSpread2["default"])({}, parent.defaultProps, { | ||
onValidate: function onValidate(model, error, callback) { | ||
@@ -253,7 +253,7 @@ callback(); | ||
validate: 'onChangeAfterSubmit' | ||
}), _class.propTypes = (0, _objectSpread2.default)({}, parent.propTypes, { | ||
onValidate: _propTypes.default.func.isRequired, | ||
validator: _propTypes.default.any, | ||
validate: _propTypes.default.oneOf(['onChange', 'onChangeAfterSubmit', 'onSubmit']).isRequired | ||
}), _class.childContextTypes = (0, _objectSpread2.default)({}, parent.childContextTypes || {}, { | ||
}), _class.propTypes = (0, _objectSpread2["default"])({}, parent.propTypes, { | ||
onValidate: _propTypes["default"].func.isRequired, | ||
validator: _propTypes["default"].any, | ||
validate: _propTypes["default"].oneOf(['onChange', 'onChangeAfterSubmit', 'onSubmit']).isRequired | ||
}), _class.childContextTypes = (0, _objectSpread2["default"])({}, parent.childContextTypes || {}, { | ||
uniforms: childContextTypes | ||
@@ -263,4 +263,4 @@ }), _temp; | ||
var _default = Validated(_BaseForm.default); | ||
var _default = Validated(_BaseForm["default"]); | ||
exports.default = _default; | ||
exports["default"] = _default; |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports["default"] = void 0; | ||
@@ -17,4 +17,4 @@ var _BaseForm = _interopRequireDefault(require("./BaseForm")); | ||
var _default = _ValidatedForm.default.Validated(_QuickForm.default.Quick(_BaseForm.default)); | ||
var _default = _ValidatedForm["default"].Validated(_QuickForm["default"].Quick(_BaseForm["default"])); | ||
exports.default = _default; | ||
exports["default"] = _default; |
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 v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
6
3
92476
35
2351
2