Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-final-form

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-final-form - npm Package Compare versions

Comparing version 3.6.6 to 3.6.7

scripts/postinstall.js

606

dist/react-final-form.cjs.js

@@ -11,84 +11,82 @@ 'use strict';

//
function diffSubscription (a, b, keys) {
if (a) {
if (b) {
// $FlowFixMe
return keys.some(function (key) {
return a[key] !== b[key];
});
} else {
return true;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
return !!b;
obj[key] = value;
}
return obj;
}
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;
};
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
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];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
}
return target;
};
return target;
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
return _extends.apply(this, arguments);
}
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 _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
var objectWithoutProperties = function (obj, keys) {
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
};
}
var possibleConstructorReturn = function (self, call) {
if (!self) {
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
return self;
}
//
function diffSubscription (a, b, keys) {
if (a) {
if (b) {
// $FlowFixMe
return keys.some(function (key) {
return a[key] !== b[key];
});
} else {
return true;
}
} else {
return !!b;
}
}
// shared logic between components that use either render prop,
// children render function, or component prop
function renderComponent(props, name) {

@@ -98,17 +96,26 @@ var render = props.render,

component = props.component,
rest = objectWithoutProperties(props, ['render', 'children', 'component']);
rest = _objectWithoutPropertiesLoose(props, ["render", "children", "component"]);
if (component) {
return React.createElement(component, _extends({}, rest, { children: children, render: render }));
return React.createElement(component, _extends({}, rest, {
children: children,
render: render
}));
}
if (render) {
return render(_extends({}, rest, { children: children })); // inject children back in
return render(_extends({}, rest, {
children: children
})); // inject children back in
}
if (typeof children !== 'function') {
// istanbul ignore next
if (process.env.NODE_ENV !== 'production') {
console.error('Warning: Must specify either a render prop, a render function as children, or a component prop to ' + name);
console.error("Warning: Must specify either a render prop, a render function as children, or a component prop to " + name);
}
return null; // warning will alert developer to their mistake
}
return children(rest);

@@ -123,5 +130,7 @@ }

var result = [];
if (options) {
for (var index = 0; index < options.length; index++) {
var option = options[index];
if (option.selected) {

@@ -132,2 +141,3 @@ result.push(option.value);

}
return result;

@@ -140,5 +150,7 @@ };

}
if (isReactNative && event.nativeEvent) {
return event.nativeEvent.text;
}
var detypedEvent = event;

@@ -162,3 +174,5 @@ var _detypedEvent$target = detypedEvent.target,

}
var index = currentValue.indexOf(valueProp);
if (index < 0) {

@@ -174,4 +188,6 @@ return currentValue;

}
case 'select-multiple':
return getSelectedValues(event.target.options);
default:

@@ -182,4 +198,2 @@ return value;

//
var all = finalForm.fieldSubscriptionItems.reduce(function (result, key) {

@@ -190,15 +204,77 @@ result[key] = true;

var Field = function (_React$Component) {
inherits(Field, _React$Component);
var Field =
/*#__PURE__*/
function (_React$Component) {
_inheritsLoose(Field, _React$Component);
function Field(props, context) {
classCallCheck(this, Field);
function Field(_props, context) {
var _this;
var _this = possibleConstructorReturn(this, _React$Component.call(this, props, context));
_this = _React$Component.call(this, _props, context) || this;
_initialiseProps.call(_this);
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) {
var isEqual = _ref.isEqual,
name = _ref.name,
subscription = _ref.subscription,
validateFields = _ref.validateFields;
_this.unsubscribe = _this.context.reactFinalForm.registerField(name, listener, subscription || all, {
isEqual: isEqual,
getValidator: function getValidator() {
return _this.props.validate;
},
validateFields: validateFields
});
});
var initialState = void 0;
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) {
return _this.setState({
state: state
});
});
// istanbul ignore next
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handlers", {
onBlur: function onBlur(event) {
var state = _this.state.state; // this is to appease the Flow gods
// istanbul ignore next
if (state) {
var _this$props = _this.props,
format = _this$props.format,
formatOnBlur = _this$props.formatOnBlur;
state.blur();
if (format && formatOnBlur) {
state.change(format(state.value, state.name));
}
}
},
onChange: function onChange(event) {
var _this$props2 = _this.props,
parse = _this$props2.parse,
_value = _this$props2.value; // istanbul ignore next
if (process.env.NODE_ENV !== 'production' && event && event.target) {
var targetType = event.target.type;
var props = _this.props;
var unknown = ~['checkbox', 'radio', 'select-multiple'].indexOf(targetType) && !props.type;
var type = targetType === 'select-multiple' ? 'select' : targetType;
var _ref2 = targetType === 'select-multiple' ? _this.state.state || {} : props,
_value2 = _ref2.value;
if (unknown) {
console.error("Warning: You must pass `type=\"" + type + "\"` prop to your Field(" + props.name + ") component.\n" + ("Without it we don't know how to unpack your `value` prop - " + (Array.isArray(_value2) ? "[" + _value2 + "]" : "\"" + _value2 + "\"") + "."));
}
}
var value = event && event.target ? getValue(event, _this.state.state && _this.state.state.value, _value, isReactNative) : event;
_this.state.state && _this.state.state.change(parse ? parse(value, _this.props.name) : value);
},
onFocus: function onFocus(event) {
_this.state.state && _this.state.state.focus();
}
});
var initialState; // istanbul ignore next
if (process.env.NODE_ENV !== 'production' && !context.reactFinalForm) {

@@ -210,3 +286,3 @@ console.error('Warning: Field must be used inside of a ReactFinalForm component');

// avoid error, warning will alert developer to their mistake
_this.subscribe(props, function (state) {
_this.subscribe(_props, function (state) {
if (initialState) {

@@ -219,11 +295,16 @@ _this.notify(state);

}
_this.state = { state: initialState };
_this.state = {
state: initialState
};
return _this;
}
Field.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
var _props = this.props,
name = _props.name,
subscription = _props.subscription;
var _proto = Field.prototype;
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var _this$props3 = this.props,
name = _this$props3.name,
subscription = _this$props3.subscription;
if (prevProps.name !== name || diffSubscription(prevProps.subscription, subscription, finalForm.fieldSubscriptionItems)) {

@@ -238,29 +319,29 @@ if (this.context.reactFinalForm) {

Field.prototype.componentWillUnmount = function componentWillUnmount() {
_proto.componentWillUnmount = function componentWillUnmount() {
this.unsubscribe();
};
Field.prototype.render = function render() {
var _props2 = this.props,
allowNull = _props2.allowNull,
component = _props2.component,
children = _props2.children,
format = _props2.format,
formatOnBlur = _props2.formatOnBlur,
parse = _props2.parse,
isEqual = _props2.isEqual,
name = _props2.name,
subscription = _props2.subscription,
validate = _props2.validate,
validateFields = _props2.validateFields,
_value = _props2.value,
rest = objectWithoutProperties(_props2, ['allowNull', 'component', 'children', 'format', 'formatOnBlur', 'parse', 'isEqual', 'name', 'subscription', 'validate', 'validateFields', 'value']);
_proto.render = function render() {
var _this$props4 = this.props,
allowNull = _this$props4.allowNull,
component = _this$props4.component,
children = _this$props4.children,
format = _this$props4.format,
formatOnBlur = _this$props4.formatOnBlur,
parse = _this$props4.parse,
isEqual = _this$props4.isEqual,
name = _this$props4.name,
subscription = _this$props4.subscription,
validate = _this$props4.validate,
validateFields = _this$props4.validateFields,
_value = _this$props4.value,
rest = _objectWithoutPropertiesLoose(_this$props4, ["allowNull", "component", "children", "format", "formatOnBlur", "parse", "isEqual", "name", "subscription", "validate", "validateFields", "value"]);
var _ref = this.state.state || {},
blur = _ref.blur,
change = _ref.change,
focus = _ref.focus,
value = _ref.value,
ignoreName = _ref.name,
otherState = objectWithoutProperties(_ref, ['blur', 'change', 'focus', 'value', 'name']);
var _ref3 = this.state.state || {},
blur = _ref3.blur,
change = _ref3.change,
focus = _ref3.focus,
value = _ref3.value,
ignoreName = _ref3.name,
otherState = _objectWithoutPropertiesLoose(_ref3, ["blur", "change", "focus", "value", "name"]);

@@ -284,2 +365,3 @@ var meta = {

};
if (formatOnBlur) {

@@ -290,15 +372,21 @@ value = Field.defaultProps.format(value, name);

}
if (value === null && !allowNull) {
value = '';
}
var input = _extends({ name: name, value: value }, this.handlers);
var input = _extends({
name: name,
value: value
}, this.handlers);
if (rest.type === 'checkbox') {
if (_value === undefined) {
input.checked = !!value;
input.checked = !!value;
} else {
input.checked = !!(Array.isArray(value) && ~value.indexOf(_value));
input.checked = !!(Array.isArray(value) && ~value.indexOf(_value));
input.value = _value;
}
} else if (rest.type === 'radio') {
input.checked = value === _value;
input.checked = value === _value;
input.value = _value;

@@ -310,3 +398,6 @@ } else if (component === 'select' && rest.multiple) {

if (typeof children === 'function') {
return children(_extends({ input: input, meta: meta }, rest));
return children(_extends({
input: input,
meta: meta
}, rest));
}

@@ -316,6 +407,16 @@

// ignore meta, combine input with any other props
return React.createElement(component, _extends({}, input, { children: children }, rest));
return React.createElement(component, _extends({}, input, {
children: children
}, rest));
}
var renderProps = { input: input, meta: meta // assign to force Flow check
};return renderComponent(_extends({}, renderProps, { children: children, component: component }, rest), 'Field(' + name + ')');
var renderProps = {
input: input,
meta: meta // assign to force Flow check
};
return renderComponent(_extends({}, renderProps, {
children: children,
component: component
}, rest), "Field(" + name + ")");
};

@@ -326,6 +427,7 @@

Field.contextTypes = {
_defineProperty(Field, "contextTypes", {
reactFinalForm: PropTypes.object
};
Field.defaultProps = {
});
_defineProperty(Field, "defaultProps", {
format: function format(value, name) {

@@ -337,74 +439,4 @@ return value === undefined ? '' : value;

}
};
});
var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.subscribe = function (_ref2, listener) {
var isEqual = _ref2.isEqual,
name = _ref2.name,
subscription = _ref2.subscription,
validateFields = _ref2.validateFields;
_this2.unsubscribe = _this2.context.reactFinalForm.registerField(name, listener, subscription || all, {
isEqual: isEqual,
getValidator: function getValidator() {
return _this2.props.validate;
},
validateFields: validateFields
});
};
this.notify = function (state) {
return _this2.setState({ state: state });
};
this.handlers = {
onBlur: function onBlur(event) {
var state = _this2.state.state;
// this is to appease the Flow gods
// istanbul ignore next
if (state) {
var _props3 = _this2.props,
format = _props3.format,
formatOnBlur = _props3.formatOnBlur;
state.blur();
if (format && formatOnBlur) {
state.change(format(state.value, state.name));
}
}
},
onChange: function onChange(event) {
var _props4 = _this2.props,
parse = _props4.parse,
_value = _props4.value;
// istanbul ignore next
if (process.env.NODE_ENV !== 'production' && event && event.target) {
var targetType = event.target.type;
var props = _this2.props;
var unknown = ~['checkbox', 'radio', 'select-multiple'].indexOf(targetType) && !props.type;
var type = targetType === 'select-multiple' ? 'select' : targetType;
var _ref3 = targetType === 'select-multiple' ? _this2.state.state || {} : props,
_value2 = _ref3.value;
if (unknown) {
console.error('Warning: You must pass `type="' + type + '"` prop to your Field(' + props.name + ') component.\n' + ('Without it we don\'t know how to unpack your `value` prop - ' + (Array.isArray(_value2) ? '[' + _value2 + ']' : '"' + _value2 + '"') + '.'));
}
}
var value = event && event.target ? getValue(event, _this2.state.state && _this2.state.state.value, _value, isReactNative) : event;
_this2.state.state && _this2.state.state.change(parse ? parse(value, _this2.props.name) : value);
},
onFocus: function onFocus(event) {
_this2.state.state && _this2.state.state.focus();
}
};
};
//

@@ -415,13 +447,19 @@ var shallowEqual = function shallowEqual(a, b) {

}
if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) !== 'object' || !a || (typeof b === 'undefined' ? 'undefined' : _typeof(b)) !== 'object' || !b) {
if (typeof a !== 'object' || !a || typeof b !== 'object' || !b) {
return false;
}
var keysA = Object.keys(a);
var keysB = Object.keys(b);
if (keysA.length !== keysB.length) {
return false;
}
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(b);
for (var idx = 0; idx < keysA.length; idx++) {
var key = keysA[idx];
if (!bHasOwnProperty(key) || a[key] !== b[key]) {

@@ -431,2 +469,3 @@ return false;

}
return true;

@@ -440,6 +479,3 @@ };

//
var version = '3.6.0';
var versions = {

@@ -449,3 +485,2 @@ 'final-form': finalForm.version,

};
var all$1 = finalForm.formSubscriptionItems.reduce(function (result, key) {

@@ -456,18 +491,23 @@ result[key] = true;

var ReactFinalForm = function (_React$Component) {
inherits(ReactFinalForm, _React$Component);
var ReactFinalForm =
/*#__PURE__*/
function (_React$Component) {
_inheritsLoose(ReactFinalForm, _React$Component);
function ReactFinalForm(props) {
classCallCheck(this, ReactFinalForm);
var _this;
var _this = possibleConstructorReturn(this, _React$Component.call(this, props));
_this = _React$Component.call(this, props) || this;
_this.notify = function (state) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) {
if (_this.mounted) {
_this.setState({ state: state });
_this.setState({
state: state
});
}
_this.mounted = true;
};
});
_this.handleSubmit = function (event) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleSubmit", function (event) {
if (event) {

@@ -478,2 +518,3 @@ // sometimes not true, e.g. React Native

}
if (typeof event.stopPropagation === 'function') {

@@ -484,4 +525,5 @@ // prevent any outer forms from receiving the event too

}
return _this.form.submit();
};
});

@@ -493,6 +535,7 @@ var children = props.children,

decorators = props.decorators,
rest = objectWithoutProperties(props, ['children', 'component', 'render', 'subscription', 'decorators']);
rest = _objectWithoutPropertiesLoose(props, ["children", "component", "render", "subscription", "decorators"]);
var config = rest;
_this.mounted = false;
try {

@@ -503,14 +546,21 @@ _this.form = finalForm.createForm(config);

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: ' + e.message);
console.error("Warning: " + e.message);
}
}
_this.unsubscriptions = [];
if (_this.form) {
// set initial state
var initialState = {};
_this.form.subscribe(function (state) {
initialState = state;
}, subscription || all$1)();
_this.state = { state: initialState };
_this.state = {
state: initialState
};
}
if (decorators) {

@@ -521,6 +571,9 @@ decorators.forEach(function (decorator) {

}
return _this;
}
ReactFinalForm.prototype.getChildContext = function getChildContext() {
var _proto = ReactFinalForm.prototype;
_proto.getChildContext = function getChildContext() {
return {

@@ -531,3 +584,3 @@ reactFinalForm: this.form

ReactFinalForm.prototype.componentWillMount = function componentWillMount() {
_proto.componentWillMount = function componentWillMount() {
if (this.form) {

@@ -538,3 +591,3 @@ this.form.pauseValidation();

ReactFinalForm.prototype.componentDidMount = function componentDidMount() {
_proto.componentDidMount = function componentDidMount() {
if (this.form) {

@@ -546,3 +599,3 @@ this.unsubscriptions.push(this.form.subscribe(this.notify, this.props.subscription || all$1));

ReactFinalForm.prototype.componentWillUpdate = function componentWillUpdate() {
_proto.componentWillUpdate = function componentWillUpdate() {
// istanbul ignore next

@@ -555,3 +608,3 @@ if (this.form) {

ReactFinalForm.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var _this2 = this;

@@ -563,5 +616,7 @@

}
if (this.props.initialValues && !(this.props.initialValuesEqual || shallowEqual)(prevProps.initialValues, this.props.initialValues)) {
this.form.initialize(this.props.initialValues);
}
finalForm.configOptions.forEach(function (key) {

@@ -571,5 +626,6 @@ if (key === 'initialValues' || prevProps[key] === _this2.props[key]) {

}
_this2.form.setConfig(key, _this2.props[key]);
});
// istanbul ignore next
}); // istanbul ignore next
if (process.env.NODE_ENV !== 'production') {

@@ -579,2 +635,3 @@ if (!shallowEqual(prevProps.decorators, this.props.decorators)) {

}
if (!shallowEqual(prevProps.subscription, this.props.subscription)) {

@@ -586,3 +643,3 @@ console.error('Warning: Form subscription should not change from one render to the next as new values will be ignored');

ReactFinalForm.prototype.componentWillUnmount = function componentWillUnmount() {
_proto.componentWillUnmount = function componentWillUnmount() {
this.unsubscriptions.forEach(function (unsubscribe) {

@@ -593,15 +650,15 @@ return unsubscribe();

ReactFinalForm.prototype.render = function render() {
_proto.render = function render() {
var _this3 = this;
// remove config props
var _props = this.props,
debug = _props.debug,
initialValues = _props.initialValues,
mutators = _props.mutators,
onSubmit = _props.onSubmit,
subscription = _props.subscription,
validate = _props.validate,
validateOnBlur = _props.validateOnBlur,
props = objectWithoutProperties(_props, ['debug', 'initialValues', 'mutators', 'onSubmit', 'subscription', 'validate', 'validateOnBlur']);
var _this$props = this.props,
debug = _this$props.debug,
initialValues = _this$props.initialValues,
mutators = _this$props.mutators,
onSubmit = _this$props.onSubmit,
subscription = _this$props.subscription,
validate = _this$props.validate,
validateOnBlur = _this$props.validateOnBlur,
props = _objectWithoutPropertiesLoose(_this$props, ["debug", "initialValues", "mutators", "onSubmit", "subscription", "validate", "validateOnBlur"]);

@@ -612,4 +669,5 @@ var renderProps = _extends({}, this.state ? this.state.state : {}, {

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.batch(fn);

@@ -620,4 +678,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.blur(name);

@@ -628,4 +687,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.change(name, value);

@@ -636,4 +696,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.focus(name);

@@ -655,4 +716,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.initialize(values);

@@ -662,10 +724,12 @@ },

result[key] = function () {
var _form$mutators;
var _this3$form$mutators;
(_form$mutators = _this3.form.mutators)[key].apply(_form$mutators, arguments);
// istanbul ignore next
(_this3$form$mutators = _this3.form.mutators)[key].apply(_this3$form$mutators, arguments); // istanbul ignore next
if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your ReactFinalForm render prop.");
}
};
return result;

@@ -676,7 +740,9 @@ }, {}),

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.reset(values);
}
});
return renderComponent(_extends({}, props, renderProps, {

@@ -690,32 +756,33 @@ __versions: versions

ReactFinalForm.childContextTypes = {
_defineProperty(ReactFinalForm, "childContextTypes", {
reactFinalForm: PropTypes.object
};
});
//
var FormSpy =
/*#__PURE__*/
function (_React$Component) {
_inheritsLoose(FormSpy, _React$Component);
var FormSpy = function (_React$Component) {
inherits(FormSpy, _React$Component);
function FormSpy(props, context) {
classCallCheck(this, FormSpy);
var _this;
var _this = possibleConstructorReturn(this, _React$Component.call(this, props, context));
_this = _React$Component.call(this, props, context) || this;
_this.subscribe = function (_ref, listener) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) {
var subscription = _ref.subscription;
_this.unsubscribe = _this.context.reactFinalForm.subscribe(listener, subscription || all$1);
};
});
_this.notify = function (state) {
_this.setState({ state: state });
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) {
_this.setState({
state: state
});
if (_this.props.onChange) {
_this.props.onChange(state);
}
};
});
var initialState = void 0;
var initialState; // istanbul ignore next
// istanbul ignore next
if (process.env.NODE_ENV !== 'production' && !context.reactFinalForm) {

@@ -732,2 +799,3 @@ console.error('Warning: FormSpy must be used inside of a ReactFinalForm component');

initialState = state;
if (props.onChange) {

@@ -739,9 +807,15 @@ props.onChange(state);

}
if (initialState) {
_this.state = { state: initialState };
_this.state = {
state: initialState
};
}
return _this;
}
FormSpy.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
var _proto = FormSpy.prototype;
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var subscription = this.props.subscription;

@@ -758,13 +832,13 @@

FormSpy.prototype.componentWillUnmount = function componentWillUnmount() {
_proto.componentWillUnmount = function componentWillUnmount() {
this.unsubscribe();
};
FormSpy.prototype.render = function render() {
var _props = this.props,
onChange = _props.onChange,
subscription = _props.subscription,
rest = objectWithoutProperties(_props, ['onChange', 'subscription']);
_proto.render = function render() {
var _this$props = this.props,
onChange = _this$props.onChange,
subscription = _this$props.subscription,
rest = _objectWithoutPropertiesLoose(_this$props, ["onChange", "subscription"]);
var reactFinalForm = this.context.reactFinalForm;
var renderProps = {

@@ -774,4 +848,5 @@ batch: reactFinalForm && function (fn) {

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your FormSpy render prop.");
}
return reactFinalForm.batch(fn);

@@ -782,4 +857,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your FormSpy render prop.");
}
return reactFinalForm.blur(name);

@@ -790,4 +866,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your FormSpy render prop.");
}
return reactFinalForm.change(name, value);

@@ -798,4 +875,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your FormSpy render prop.");
}
return reactFinalForm.focus(name);

@@ -816,4 +894,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your FormSpy render prop.");
}
return reactFinalForm.initialize(values);

@@ -825,8 +904,10 @@ },

(_reactFinalForm$mutat = reactFinalForm.mutators)[key].apply(_reactFinalForm$mutat, arguments);
// istanbul ignore next
(_reactFinalForm$mutat = reactFinalForm.mutators)[key].apply(_reactFinalForm$mutat, arguments); // istanbul ignore next
if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your FormSpy render prop.");
}
};
return result;

@@ -837,4 +918,5 @@ }, {}),

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your FormSpy render prop.");
}
return reactFinalForm.reset(values);

@@ -841,0 +923,0 @@ }

@@ -5,84 +5,82 @@ import { createElement, Component } from 'react';

//
function diffSubscription (a, b, keys) {
if (a) {
if (b) {
// $FlowFixMe
return keys.some(function (key) {
return a[key] !== b[key];
});
} else {
return true;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
return !!b;
obj[key] = value;
}
return obj;
}
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;
};
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
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];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
}
return target;
};
return target;
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
return _extends.apply(this, arguments);
}
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 _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
var objectWithoutProperties = function (obj, keys) {
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
};
}
var possibleConstructorReturn = function (self, call) {
if (!self) {
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
return self;
}
//
function diffSubscription (a, b, keys) {
if (a) {
if (b) {
// $FlowFixMe
return keys.some(function (key) {
return a[key] !== b[key];
});
} else {
return true;
}
} else {
return !!b;
}
}
// shared logic between components that use either render prop,
// children render function, or component prop
function renderComponent(props, name) {

@@ -92,17 +90,26 @@ var render = props.render,

component = props.component,
rest = objectWithoutProperties(props, ['render', 'children', 'component']);
rest = _objectWithoutPropertiesLoose(props, ["render", "children", "component"]);
if (component) {
return createElement(component, _extends({}, rest, { children: children, render: render }));
return createElement(component, _extends({}, rest, {
children: children,
render: render
}));
}
if (render) {
return render(_extends({}, rest, { children: children })); // inject children back in
return render(_extends({}, rest, {
children: children
})); // inject children back in
}
if (typeof children !== 'function') {
// istanbul ignore next
if (process.env.NODE_ENV !== 'production') {
console.error('Warning: Must specify either a render prop, a render function as children, or a component prop to ' + name);
console.error("Warning: Must specify either a render prop, a render function as children, or a component prop to " + name);
}
return null; // warning will alert developer to their mistake
}
return children(rest);

@@ -117,5 +124,7 @@ }

var result = [];
if (options) {
for (var index = 0; index < options.length; index++) {
var option = options[index];
if (option.selected) {

@@ -126,2 +135,3 @@ result.push(option.value);

}
return result;

@@ -134,5 +144,7 @@ };

}
if (isReactNative && event.nativeEvent) {
return event.nativeEvent.text;
}
var detypedEvent = event;

@@ -156,3 +168,5 @@ var _detypedEvent$target = detypedEvent.target,

}
var index = currentValue.indexOf(valueProp);
if (index < 0) {

@@ -168,4 +182,6 @@ return currentValue;

}
case 'select-multiple':
return getSelectedValues(event.target.options);
default:

@@ -176,4 +192,2 @@ return value;

//
var all = fieldSubscriptionItems.reduce(function (result, key) {

@@ -184,15 +198,77 @@ result[key] = true;

var Field = function (_React$Component) {
inherits(Field, _React$Component);
var Field =
/*#__PURE__*/
function (_React$Component) {
_inheritsLoose(Field, _React$Component);
function Field(props, context) {
classCallCheck(this, Field);
function Field(_props, context) {
var _this;
var _this = possibleConstructorReturn(this, _React$Component.call(this, props, context));
_this = _React$Component.call(this, _props, context) || this;
_initialiseProps.call(_this);
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) {
var isEqual = _ref.isEqual,
name = _ref.name,
subscription = _ref.subscription,
validateFields = _ref.validateFields;
_this.unsubscribe = _this.context.reactFinalForm.registerField(name, listener, subscription || all, {
isEqual: isEqual,
getValidator: function getValidator() {
return _this.props.validate;
},
validateFields: validateFields
});
});
var initialState = void 0;
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) {
return _this.setState({
state: state
});
});
// istanbul ignore next
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handlers", {
onBlur: function onBlur(event) {
var state = _this.state.state; // this is to appease the Flow gods
// istanbul ignore next
if (state) {
var _this$props = _this.props,
format = _this$props.format,
formatOnBlur = _this$props.formatOnBlur;
state.blur();
if (format && formatOnBlur) {
state.change(format(state.value, state.name));
}
}
},
onChange: function onChange(event) {
var _this$props2 = _this.props,
parse = _this$props2.parse,
_value = _this$props2.value; // istanbul ignore next
if (process.env.NODE_ENV !== 'production' && event && event.target) {
var targetType = event.target.type;
var props = _this.props;
var unknown = ~['checkbox', 'radio', 'select-multiple'].indexOf(targetType) && !props.type;
var type = targetType === 'select-multiple' ? 'select' : targetType;
var _ref2 = targetType === 'select-multiple' ? _this.state.state || {} : props,
_value2 = _ref2.value;
if (unknown) {
console.error("Warning: You must pass `type=\"" + type + "\"` prop to your Field(" + props.name + ") component.\n" + ("Without it we don't know how to unpack your `value` prop - " + (Array.isArray(_value2) ? "[" + _value2 + "]" : "\"" + _value2 + "\"") + "."));
}
}
var value = event && event.target ? getValue(event, _this.state.state && _this.state.state.value, _value, isReactNative) : event;
_this.state.state && _this.state.state.change(parse ? parse(value, _this.props.name) : value);
},
onFocus: function onFocus(event) {
_this.state.state && _this.state.state.focus();
}
});
var initialState; // istanbul ignore next
if (process.env.NODE_ENV !== 'production' && !context.reactFinalForm) {

@@ -204,3 +280,3 @@ console.error('Warning: Field must be used inside of a ReactFinalForm component');

// avoid error, warning will alert developer to their mistake
_this.subscribe(props, function (state) {
_this.subscribe(_props, function (state) {
if (initialState) {

@@ -213,11 +289,16 @@ _this.notify(state);

}
_this.state = { state: initialState };
_this.state = {
state: initialState
};
return _this;
}
Field.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
var _props = this.props,
name = _props.name,
subscription = _props.subscription;
var _proto = Field.prototype;
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var _this$props3 = this.props,
name = _this$props3.name,
subscription = _this$props3.subscription;
if (prevProps.name !== name || diffSubscription(prevProps.subscription, subscription, fieldSubscriptionItems)) {

@@ -232,29 +313,29 @@ if (this.context.reactFinalForm) {

Field.prototype.componentWillUnmount = function componentWillUnmount() {
_proto.componentWillUnmount = function componentWillUnmount() {
this.unsubscribe();
};
Field.prototype.render = function render() {
var _props2 = this.props,
allowNull = _props2.allowNull,
component = _props2.component,
children = _props2.children,
format = _props2.format,
formatOnBlur = _props2.formatOnBlur,
parse = _props2.parse,
isEqual = _props2.isEqual,
name = _props2.name,
subscription = _props2.subscription,
validate = _props2.validate,
validateFields = _props2.validateFields,
_value = _props2.value,
rest = objectWithoutProperties(_props2, ['allowNull', 'component', 'children', 'format', 'formatOnBlur', 'parse', 'isEqual', 'name', 'subscription', 'validate', 'validateFields', 'value']);
_proto.render = function render() {
var _this$props4 = this.props,
allowNull = _this$props4.allowNull,
component = _this$props4.component,
children = _this$props4.children,
format = _this$props4.format,
formatOnBlur = _this$props4.formatOnBlur,
parse = _this$props4.parse,
isEqual = _this$props4.isEqual,
name = _this$props4.name,
subscription = _this$props4.subscription,
validate = _this$props4.validate,
validateFields = _this$props4.validateFields,
_value = _this$props4.value,
rest = _objectWithoutPropertiesLoose(_this$props4, ["allowNull", "component", "children", "format", "formatOnBlur", "parse", "isEqual", "name", "subscription", "validate", "validateFields", "value"]);
var _ref = this.state.state || {},
blur = _ref.blur,
change = _ref.change,
focus = _ref.focus,
value = _ref.value,
ignoreName = _ref.name,
otherState = objectWithoutProperties(_ref, ['blur', 'change', 'focus', 'value', 'name']);
var _ref3 = this.state.state || {},
blur = _ref3.blur,
change = _ref3.change,
focus = _ref3.focus,
value = _ref3.value,
ignoreName = _ref3.name,
otherState = _objectWithoutPropertiesLoose(_ref3, ["blur", "change", "focus", "value", "name"]);

@@ -278,2 +359,3 @@ var meta = {

};
if (formatOnBlur) {

@@ -284,15 +366,21 @@ value = Field.defaultProps.format(value, name);

}
if (value === null && !allowNull) {
value = '';
}
var input = _extends({ name: name, value: value }, this.handlers);
var input = _extends({
name: name,
value: value
}, this.handlers);
if (rest.type === 'checkbox') {
if (_value === undefined) {
input.checked = !!value;
input.checked = !!value;
} else {
input.checked = !!(Array.isArray(value) && ~value.indexOf(_value));
input.checked = !!(Array.isArray(value) && ~value.indexOf(_value));
input.value = _value;
}
} else if (rest.type === 'radio') {
input.checked = value === _value;
input.checked = value === _value;
input.value = _value;

@@ -304,3 +392,6 @@ } else if (component === 'select' && rest.multiple) {

if (typeof children === 'function') {
return children(_extends({ input: input, meta: meta }, rest));
return children(_extends({
input: input,
meta: meta
}, rest));
}

@@ -310,6 +401,16 @@

// ignore meta, combine input with any other props
return createElement(component, _extends({}, input, { children: children }, rest));
return createElement(component, _extends({}, input, {
children: children
}, rest));
}
var renderProps = { input: input, meta: meta // assign to force Flow check
};return renderComponent(_extends({}, renderProps, { children: children, component: component }, rest), 'Field(' + name + ')');
var renderProps = {
input: input,
meta: meta // assign to force Flow check
};
return renderComponent(_extends({}, renderProps, {
children: children,
component: component
}, rest), "Field(" + name + ")");
};

@@ -320,6 +421,7 @@

Field.contextTypes = {
_defineProperty(Field, "contextTypes", {
reactFinalForm: PropTypes.object
};
Field.defaultProps = {
});
_defineProperty(Field, "defaultProps", {
format: function format(value, name) {

@@ -331,74 +433,4 @@ return value === undefined ? '' : value;

}
};
});
var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.subscribe = function (_ref2, listener) {
var isEqual = _ref2.isEqual,
name = _ref2.name,
subscription = _ref2.subscription,
validateFields = _ref2.validateFields;
_this2.unsubscribe = _this2.context.reactFinalForm.registerField(name, listener, subscription || all, {
isEqual: isEqual,
getValidator: function getValidator() {
return _this2.props.validate;
},
validateFields: validateFields
});
};
this.notify = function (state) {
return _this2.setState({ state: state });
};
this.handlers = {
onBlur: function onBlur(event) {
var state = _this2.state.state;
// this is to appease the Flow gods
// istanbul ignore next
if (state) {
var _props3 = _this2.props,
format = _props3.format,
formatOnBlur = _props3.formatOnBlur;
state.blur();
if (format && formatOnBlur) {
state.change(format(state.value, state.name));
}
}
},
onChange: function onChange(event) {
var _props4 = _this2.props,
parse = _props4.parse,
_value = _props4.value;
// istanbul ignore next
if (process.env.NODE_ENV !== 'production' && event && event.target) {
var targetType = event.target.type;
var props = _this2.props;
var unknown = ~['checkbox', 'radio', 'select-multiple'].indexOf(targetType) && !props.type;
var type = targetType === 'select-multiple' ? 'select' : targetType;
var _ref3 = targetType === 'select-multiple' ? _this2.state.state || {} : props,
_value2 = _ref3.value;
if (unknown) {
console.error('Warning: You must pass `type="' + type + '"` prop to your Field(' + props.name + ') component.\n' + ('Without it we don\'t know how to unpack your `value` prop - ' + (Array.isArray(_value2) ? '[' + _value2 + ']' : '"' + _value2 + '"') + '.'));
}
}
var value = event && event.target ? getValue(event, _this2.state.state && _this2.state.state.value, _value, isReactNative) : event;
_this2.state.state && _this2.state.state.change(parse ? parse(value, _this2.props.name) : value);
},
onFocus: function onFocus(event) {
_this2.state.state && _this2.state.state.focus();
}
};
};
//

@@ -409,13 +441,19 @@ var shallowEqual = function shallowEqual(a, b) {

}
if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) !== 'object' || !a || (typeof b === 'undefined' ? 'undefined' : _typeof(b)) !== 'object' || !b) {
if (typeof a !== 'object' || !a || typeof b !== 'object' || !b) {
return false;
}
var keysA = Object.keys(a);
var keysB = Object.keys(b);
if (keysA.length !== keysB.length) {
return false;
}
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(b);
for (var idx = 0; idx < keysA.length; idx++) {
var key = keysA[idx];
if (!bHasOwnProperty(key) || a[key] !== b[key]) {

@@ -425,2 +463,3 @@ return false;

}
return true;

@@ -434,6 +473,3 @@ };

//
var version$1 = '3.6.0';
var versions = {

@@ -443,3 +479,2 @@ 'final-form': version,

};
var all$1 = formSubscriptionItems.reduce(function (result, key) {

@@ -450,18 +485,23 @@ result[key] = true;

var ReactFinalForm = function (_React$Component) {
inherits(ReactFinalForm, _React$Component);
var ReactFinalForm =
/*#__PURE__*/
function (_React$Component) {
_inheritsLoose(ReactFinalForm, _React$Component);
function ReactFinalForm(props) {
classCallCheck(this, ReactFinalForm);
var _this;
var _this = possibleConstructorReturn(this, _React$Component.call(this, props));
_this = _React$Component.call(this, props) || this;
_this.notify = function (state) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) {
if (_this.mounted) {
_this.setState({ state: state });
_this.setState({
state: state
});
}
_this.mounted = true;
};
});
_this.handleSubmit = function (event) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleSubmit", function (event) {
if (event) {

@@ -472,2 +512,3 @@ // sometimes not true, e.g. React Native

}
if (typeof event.stopPropagation === 'function') {

@@ -478,4 +519,5 @@ // prevent any outer forms from receiving the event too

}
return _this.form.submit();
};
});

@@ -487,6 +529,7 @@ var children = props.children,

decorators = props.decorators,
rest = objectWithoutProperties(props, ['children', 'component', 'render', 'subscription', 'decorators']);
rest = _objectWithoutPropertiesLoose(props, ["children", "component", "render", "subscription", "decorators"]);
var config = rest;
_this.mounted = false;
try {

@@ -497,14 +540,21 @@ _this.form = createForm(config);

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: ' + e.message);
console.error("Warning: " + e.message);
}
}
_this.unsubscriptions = [];
if (_this.form) {
// set initial state
var initialState = {};
_this.form.subscribe(function (state) {
initialState = state;
}, subscription || all$1)();
_this.state = { state: initialState };
_this.state = {
state: initialState
};
}
if (decorators) {

@@ -515,6 +565,9 @@ decorators.forEach(function (decorator) {

}
return _this;
}
ReactFinalForm.prototype.getChildContext = function getChildContext() {
var _proto = ReactFinalForm.prototype;
_proto.getChildContext = function getChildContext() {
return {

@@ -525,3 +578,3 @@ reactFinalForm: this.form

ReactFinalForm.prototype.componentWillMount = function componentWillMount() {
_proto.componentWillMount = function componentWillMount() {
if (this.form) {

@@ -532,3 +585,3 @@ this.form.pauseValidation();

ReactFinalForm.prototype.componentDidMount = function componentDidMount() {
_proto.componentDidMount = function componentDidMount() {
if (this.form) {

@@ -540,3 +593,3 @@ this.unsubscriptions.push(this.form.subscribe(this.notify, this.props.subscription || all$1));

ReactFinalForm.prototype.componentWillUpdate = function componentWillUpdate() {
_proto.componentWillUpdate = function componentWillUpdate() {
// istanbul ignore next

@@ -549,3 +602,3 @@ if (this.form) {

ReactFinalForm.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var _this2 = this;

@@ -557,5 +610,7 @@

}
if (this.props.initialValues && !(this.props.initialValuesEqual || shallowEqual)(prevProps.initialValues, this.props.initialValues)) {
this.form.initialize(this.props.initialValues);
}
configOptions.forEach(function (key) {

@@ -565,5 +620,6 @@ if (key === 'initialValues' || prevProps[key] === _this2.props[key]) {

}
_this2.form.setConfig(key, _this2.props[key]);
});
// istanbul ignore next
}); // istanbul ignore next
if (process.env.NODE_ENV !== 'production') {

@@ -573,2 +629,3 @@ if (!shallowEqual(prevProps.decorators, this.props.decorators)) {

}
if (!shallowEqual(prevProps.subscription, this.props.subscription)) {

@@ -580,3 +637,3 @@ console.error('Warning: Form subscription should not change from one render to the next as new values will be ignored');

ReactFinalForm.prototype.componentWillUnmount = function componentWillUnmount() {
_proto.componentWillUnmount = function componentWillUnmount() {
this.unsubscriptions.forEach(function (unsubscribe) {

@@ -587,15 +644,15 @@ return unsubscribe();

ReactFinalForm.prototype.render = function render() {
_proto.render = function render() {
var _this3 = this;
// remove config props
var _props = this.props,
debug = _props.debug,
initialValues = _props.initialValues,
mutators = _props.mutators,
onSubmit = _props.onSubmit,
subscription = _props.subscription,
validate = _props.validate,
validateOnBlur = _props.validateOnBlur,
props = objectWithoutProperties(_props, ['debug', 'initialValues', 'mutators', 'onSubmit', 'subscription', 'validate', 'validateOnBlur']);
var _this$props = this.props,
debug = _this$props.debug,
initialValues = _this$props.initialValues,
mutators = _this$props.mutators,
onSubmit = _this$props.onSubmit,
subscription = _this$props.subscription,
validate = _this$props.validate,
validateOnBlur = _this$props.validateOnBlur,
props = _objectWithoutPropertiesLoose(_this$props, ["debug", "initialValues", "mutators", "onSubmit", "subscription", "validate", "validateOnBlur"]);

@@ -606,4 +663,5 @@ var renderProps = _extends({}, this.state ? this.state.state : {}, {

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.batch(fn);

@@ -614,4 +672,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.blur(name);

@@ -622,4 +681,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.change(name, value);

@@ -630,4 +690,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.focus(name);

@@ -649,4 +710,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.initialize(values);

@@ -656,10 +718,12 @@ },

result[key] = function () {
var _form$mutators;
var _this3$form$mutators;
(_form$mutators = _this3.form.mutators)[key].apply(_form$mutators, arguments);
// istanbul ignore next
(_this3$form$mutators = _this3.form.mutators)[key].apply(_this3$form$mutators, arguments); // istanbul ignore next
if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your ReactFinalForm render prop.");
}
};
return result;

@@ -670,7 +734,9 @@ }, {}),

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.reset(values);
}
});
return renderComponent(_extends({}, props, renderProps, {

@@ -684,32 +750,33 @@ __versions: versions

ReactFinalForm.childContextTypes = {
_defineProperty(ReactFinalForm, "childContextTypes", {
reactFinalForm: PropTypes.object
};
});
//
var FormSpy =
/*#__PURE__*/
function (_React$Component) {
_inheritsLoose(FormSpy, _React$Component);
var FormSpy = function (_React$Component) {
inherits(FormSpy, _React$Component);
function FormSpy(props, context) {
classCallCheck(this, FormSpy);
var _this;
var _this = possibleConstructorReturn(this, _React$Component.call(this, props, context));
_this = _React$Component.call(this, props, context) || this;
_this.subscribe = function (_ref, listener) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) {
var subscription = _ref.subscription;
_this.unsubscribe = _this.context.reactFinalForm.subscribe(listener, subscription || all$1);
};
});
_this.notify = function (state) {
_this.setState({ state: state });
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) {
_this.setState({
state: state
});
if (_this.props.onChange) {
_this.props.onChange(state);
}
};
});
var initialState = void 0;
var initialState; // istanbul ignore next
// istanbul ignore next
if (process.env.NODE_ENV !== 'production' && !context.reactFinalForm) {

@@ -726,2 +793,3 @@ console.error('Warning: FormSpy must be used inside of a ReactFinalForm component');

initialState = state;
if (props.onChange) {

@@ -733,9 +801,15 @@ props.onChange(state);

}
if (initialState) {
_this.state = { state: initialState };
_this.state = {
state: initialState
};
}
return _this;
}
FormSpy.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
var _proto = FormSpy.prototype;
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var subscription = this.props.subscription;

@@ -752,13 +826,13 @@

FormSpy.prototype.componentWillUnmount = function componentWillUnmount() {
_proto.componentWillUnmount = function componentWillUnmount() {
this.unsubscribe();
};
FormSpy.prototype.render = function render() {
var _props = this.props,
onChange = _props.onChange,
subscription = _props.subscription,
rest = objectWithoutProperties(_props, ['onChange', 'subscription']);
_proto.render = function render() {
var _this$props = this.props,
onChange = _this$props.onChange,
subscription = _this$props.subscription,
rest = _objectWithoutPropertiesLoose(_this$props, ["onChange", "subscription"]);
var reactFinalForm = this.context.reactFinalForm;
var renderProps = {

@@ -768,4 +842,5 @@ batch: reactFinalForm && function (fn) {

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your FormSpy render prop.");
}
return reactFinalForm.batch(fn);

@@ -776,4 +851,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your FormSpy render prop.");
}
return reactFinalForm.blur(name);

@@ -784,4 +860,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your FormSpy render prop.");
}
return reactFinalForm.change(name, value);

@@ -792,4 +869,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your FormSpy render prop.");
}
return reactFinalForm.focus(name);

@@ -810,4 +888,5 @@ },

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your FormSpy render prop.");
}
return reactFinalForm.initialize(values);

@@ -819,8 +898,10 @@ },

(_reactFinalForm$mutat = reactFinalForm.mutators)[key].apply(_reactFinalForm$mutat, arguments);
// istanbul ignore next
(_reactFinalForm$mutat = reactFinalForm.mutators)[key].apply(_reactFinalForm$mutat, arguments); // istanbul ignore next
if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your FormSpy render prop.");
}
};
return result;

@@ -831,4 +912,5 @@ }, {}),

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your FormSpy render prop.");
}
return reactFinalForm.reset(values);

@@ -835,0 +917,0 @@ }

@@ -9,84 +9,82 @@ (function (global, factory) {

//
function diffSubscription (a, b, keys) {
if (a) {
if (b) {
// $FlowFixMe
return keys.some(function (key) {
return a[key] !== b[key];
});
} else {
return true;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
return !!b;
obj[key] = value;
}
return obj;
}
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;
};
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
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];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
}
return target;
};
return target;
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
return _extends.apply(this, arguments);
}
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 _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
var objectWithoutProperties = function (obj, keys) {
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
};
}
var possibleConstructorReturn = function (self, call) {
if (!self) {
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
return self;
}
//
function diffSubscription (a, b, keys) {
if (a) {
if (b) {
// $FlowFixMe
return keys.some(function (key) {
return a[key] !== b[key];
});
} else {
return true;
}
} else {
return !!b;
}
}
// shared logic between components that use either render prop,
// children render function, or component prop
function renderComponent(props, name) {

@@ -96,17 +94,26 @@ var render = props.render,

component = props.component,
rest = objectWithoutProperties(props, ['render', 'children', 'component']);
rest = _objectWithoutPropertiesLoose(props, ["render", "children", "component"]);
if (component) {
return React.createElement(component, _extends({}, rest, { children: children, render: render }));
return React.createElement(component, _extends({}, rest, {
children: children,
render: render
}));
}
if (render) {
return render(_extends({}, rest, { children: children })); // inject children back in
return render(_extends({}, rest, {
children: children
})); // inject children back in
}
if (typeof children !== 'function') {
// istanbul ignore next
{
console.error('Warning: Must specify either a render prop, a render function as children, or a component prop to ' + name);
console.error("Warning: Must specify either a render prop, a render function as children, or a component prop to " + name);
}
return null; // warning will alert developer to their mistake
}
return children(rest);

@@ -121,5 +128,7 @@ }

var result = [];
if (options) {
for (var index = 0; index < options.length; index++) {
var option = options[index];
if (option.selected) {

@@ -130,2 +139,3 @@ result.push(option.value);

}
return result;

@@ -138,5 +148,7 @@ };

}
if (isReactNative && event.nativeEvent) {
return event.nativeEvent.text;
}
var detypedEvent = event;

@@ -160,3 +172,5 @@ var _detypedEvent$target = detypedEvent.target,

}
var index = currentValue.indexOf(valueProp);
if (index < 0) {

@@ -172,4 +186,6 @@ return currentValue;

}
case 'select-multiple':
return getSelectedValues(event.target.options);
default:

@@ -180,4 +196,2 @@ return value;

//
var all = finalForm.fieldSubscriptionItems.reduce(function (result, key) {

@@ -188,15 +202,77 @@ result[key] = true;

var Field = function (_React$Component) {
inherits(Field, _React$Component);
var Field =
/*#__PURE__*/
function (_React$Component) {
_inheritsLoose(Field, _React$Component);
function Field(props, context) {
classCallCheck(this, Field);
function Field(_props, context) {
var _this;
var _this = possibleConstructorReturn(this, _React$Component.call(this, props, context));
_this = _React$Component.call(this, _props, context) || this;
_initialiseProps.call(_this);
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) {
var isEqual = _ref.isEqual,
name = _ref.name,
subscription = _ref.subscription,
validateFields = _ref.validateFields;
_this.unsubscribe = _this.context.reactFinalForm.registerField(name, listener, subscription || all, {
isEqual: isEqual,
getValidator: function getValidator() {
return _this.props.validate;
},
validateFields: validateFields
});
});
var initialState = void 0;
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) {
return _this.setState({
state: state
});
});
// istanbul ignore next
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handlers", {
onBlur: function onBlur(event) {
var state = _this.state.state; // this is to appease the Flow gods
// istanbul ignore next
if (state) {
var _this$props = _this.props,
format = _this$props.format,
formatOnBlur = _this$props.formatOnBlur;
state.blur();
if (format && formatOnBlur) {
state.change(format(state.value, state.name));
}
}
},
onChange: function onChange(event) {
var _this$props2 = _this.props,
parse = _this$props2.parse,
_value = _this$props2.value; // istanbul ignore next
if (event && event.target) {
var targetType = event.target.type;
var props = _this.props;
var unknown = ~['checkbox', 'radio', 'select-multiple'].indexOf(targetType) && !props.type;
var type = targetType === 'select-multiple' ? 'select' : targetType;
var _ref2 = targetType === 'select-multiple' ? _this.state.state || {} : props,
_value2 = _ref2.value;
if (unknown) {
console.error("Warning: You must pass `type=\"" + type + "\"` prop to your Field(" + props.name + ") component.\n" + ("Without it we don't know how to unpack your `value` prop - " + (Array.isArray(_value2) ? "[" + _value2 + "]" : "\"" + _value2 + "\"") + "."));
}
}
var value = event && event.target ? getValue(event, _this.state.state && _this.state.state.value, _value, isReactNative) : event;
_this.state.state && _this.state.state.change(parse ? parse(value, _this.props.name) : value);
},
onFocus: function onFocus(event) {
_this.state.state && _this.state.state.focus();
}
});
var initialState; // istanbul ignore next
if (!context.reactFinalForm) {

@@ -208,3 +284,3 @@ console.error('Warning: Field must be used inside of a ReactFinalForm component');

// avoid error, warning will alert developer to their mistake
_this.subscribe(props, function (state) {
_this.subscribe(_props, function (state) {
if (initialState) {

@@ -217,11 +293,16 @@ _this.notify(state);

}
_this.state = { state: initialState };
_this.state = {
state: initialState
};
return _this;
}
Field.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
var _props = this.props,
name = _props.name,
subscription = _props.subscription;
var _proto = Field.prototype;
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var _this$props3 = this.props,
name = _this$props3.name,
subscription = _this$props3.subscription;
if (prevProps.name !== name || diffSubscription(prevProps.subscription, subscription, finalForm.fieldSubscriptionItems)) {

@@ -236,29 +317,29 @@ if (this.context.reactFinalForm) {

Field.prototype.componentWillUnmount = function componentWillUnmount() {
_proto.componentWillUnmount = function componentWillUnmount() {
this.unsubscribe();
};
Field.prototype.render = function render() {
var _props2 = this.props,
allowNull = _props2.allowNull,
component = _props2.component,
children = _props2.children,
format = _props2.format,
formatOnBlur = _props2.formatOnBlur,
parse = _props2.parse,
isEqual = _props2.isEqual,
name = _props2.name,
subscription = _props2.subscription,
validate = _props2.validate,
validateFields = _props2.validateFields,
_value = _props2.value,
rest = objectWithoutProperties(_props2, ['allowNull', 'component', 'children', 'format', 'formatOnBlur', 'parse', 'isEqual', 'name', 'subscription', 'validate', 'validateFields', 'value']);
_proto.render = function render() {
var _this$props4 = this.props,
allowNull = _this$props4.allowNull,
component = _this$props4.component,
children = _this$props4.children,
format = _this$props4.format,
formatOnBlur = _this$props4.formatOnBlur,
parse = _this$props4.parse,
isEqual = _this$props4.isEqual,
name = _this$props4.name,
subscription = _this$props4.subscription,
validate = _this$props4.validate,
validateFields = _this$props4.validateFields,
_value = _this$props4.value,
rest = _objectWithoutPropertiesLoose(_this$props4, ["allowNull", "component", "children", "format", "formatOnBlur", "parse", "isEqual", "name", "subscription", "validate", "validateFields", "value"]);
var _ref = this.state.state || {},
blur = _ref.blur,
change = _ref.change,
focus = _ref.focus,
value = _ref.value,
ignoreName = _ref.name,
otherState = objectWithoutProperties(_ref, ['blur', 'change', 'focus', 'value', 'name']);
var _ref3 = this.state.state || {},
blur = _ref3.blur,
change = _ref3.change,
focus = _ref3.focus,
value = _ref3.value,
ignoreName = _ref3.name,
otherState = _objectWithoutPropertiesLoose(_ref3, ["blur", "change", "focus", "value", "name"]);

@@ -282,2 +363,3 @@ var meta = {

};
if (formatOnBlur) {

@@ -288,15 +370,21 @@ value = Field.defaultProps.format(value, name);

}
if (value === null && !allowNull) {
value = '';
}
var input = _extends({ name: name, value: value }, this.handlers);
var input = _extends({
name: name,
value: value
}, this.handlers);
if (rest.type === 'checkbox') {
if (_value === undefined) {
input.checked = !!value;
input.checked = !!value;
} else {
input.checked = !!(Array.isArray(value) && ~value.indexOf(_value));
input.checked = !!(Array.isArray(value) && ~value.indexOf(_value));
input.value = _value;
}
} else if (rest.type === 'radio') {
input.checked = value === _value;
input.checked = value === _value;
input.value = _value;

@@ -308,3 +396,6 @@ } else if (component === 'select' && rest.multiple) {

if (typeof children === 'function') {
return children(_extends({ input: input, meta: meta }, rest));
return children(_extends({
input: input,
meta: meta
}, rest));
}

@@ -314,6 +405,16 @@

// ignore meta, combine input with any other props
return React.createElement(component, _extends({}, input, { children: children }, rest));
return React.createElement(component, _extends({}, input, {
children: children
}, rest));
}
var renderProps = { input: input, meta: meta // assign to force Flow check
};return renderComponent(_extends({}, renderProps, { children: children, component: component }, rest), 'Field(' + name + ')');
var renderProps = {
input: input,
meta: meta // assign to force Flow check
};
return renderComponent(_extends({}, renderProps, {
children: children,
component: component
}, rest), "Field(" + name + ")");
};

@@ -324,6 +425,7 @@

Field.contextTypes = {
_defineProperty(Field, "contextTypes", {
reactFinalForm: PropTypes.object
};
Field.defaultProps = {
});
_defineProperty(Field, "defaultProps", {
format: function format(value, name) {

@@ -335,74 +437,4 @@ return value === undefined ? '' : value;

}
};
});
var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.subscribe = function (_ref2, listener) {
var isEqual = _ref2.isEqual,
name = _ref2.name,
subscription = _ref2.subscription,
validateFields = _ref2.validateFields;
_this2.unsubscribe = _this2.context.reactFinalForm.registerField(name, listener, subscription || all, {
isEqual: isEqual,
getValidator: function getValidator() {
return _this2.props.validate;
},
validateFields: validateFields
});
};
this.notify = function (state) {
return _this2.setState({ state: state });
};
this.handlers = {
onBlur: function onBlur(event) {
var state = _this2.state.state;
// this is to appease the Flow gods
// istanbul ignore next
if (state) {
var _props3 = _this2.props,
format = _props3.format,
formatOnBlur = _props3.formatOnBlur;
state.blur();
if (format && formatOnBlur) {
state.change(format(state.value, state.name));
}
}
},
onChange: function onChange(event) {
var _props4 = _this2.props,
parse = _props4.parse,
_value = _props4.value;
// istanbul ignore next
if (event && event.target) {
var targetType = event.target.type;
var props = _this2.props;
var unknown = ~['checkbox', 'radio', 'select-multiple'].indexOf(targetType) && !props.type;
var type = targetType === 'select-multiple' ? 'select' : targetType;
var _ref3 = targetType === 'select-multiple' ? _this2.state.state || {} : props,
_value2 = _ref3.value;
if (unknown) {
console.error('Warning: You must pass `type="' + type + '"` prop to your Field(' + props.name + ') component.\n' + ('Without it we don\'t know how to unpack your `value` prop - ' + (Array.isArray(_value2) ? '[' + _value2 + ']' : '"' + _value2 + '"') + '.'));
}
}
var value = event && event.target ? getValue(event, _this2.state.state && _this2.state.state.value, _value, isReactNative) : event;
_this2.state.state && _this2.state.state.change(parse ? parse(value, _this2.props.name) : value);
},
onFocus: function onFocus(event) {
_this2.state.state && _this2.state.state.focus();
}
};
};
//

@@ -413,13 +445,19 @@ var shallowEqual = function shallowEqual(a, b) {

}
if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) !== 'object' || !a || (typeof b === 'undefined' ? 'undefined' : _typeof(b)) !== 'object' || !b) {
if (typeof a !== 'object' || !a || typeof b !== 'object' || !b) {
return false;
}
var keysA = Object.keys(a);
var keysB = Object.keys(b);
if (keysA.length !== keysB.length) {
return false;
}
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(b);
for (var idx = 0; idx < keysA.length; idx++) {
var key = keysA[idx];
if (!bHasOwnProperty(key) || a[key] !== b[key]) {

@@ -429,2 +467,3 @@ return false;

}
return true;

@@ -438,6 +477,3 @@ };

//
var version = '3.6.0';
var versions = {

@@ -447,3 +483,2 @@ 'final-form': finalForm.version,

};
var all$1 = finalForm.formSubscriptionItems.reduce(function (result, key) {

@@ -454,18 +489,23 @@ result[key] = true;

var ReactFinalForm = function (_React$Component) {
inherits(ReactFinalForm, _React$Component);
var ReactFinalForm =
/*#__PURE__*/
function (_React$Component) {
_inheritsLoose(ReactFinalForm, _React$Component);
function ReactFinalForm(props) {
classCallCheck(this, ReactFinalForm);
var _this;
var _this = possibleConstructorReturn(this, _React$Component.call(this, props));
_this = _React$Component.call(this, props) || this;
_this.notify = function (state) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) {
if (_this.mounted) {
_this.setState({ state: state });
_this.setState({
state: state
});
}
_this.mounted = true;
};
});
_this.handleSubmit = function (event) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleSubmit", function (event) {
if (event) {

@@ -476,2 +516,3 @@ // sometimes not true, e.g. React Native

}
if (typeof event.stopPropagation === 'function') {

@@ -482,4 +523,5 @@ // prevent any outer forms from receiving the event too

}
return _this.form.submit();
};
});

@@ -491,6 +533,7 @@ var children = props.children,

decorators = props.decorators,
rest = objectWithoutProperties(props, ['children', 'component', 'render', 'subscription', 'decorators']);
rest = _objectWithoutPropertiesLoose(props, ["children", "component", "render", "subscription", "decorators"]);
var config = rest;
_this.mounted = false;
try {

@@ -501,14 +544,21 @@ _this.form = finalForm.createForm(config);

{
console.error('Warning: ' + e.message);
console.error("Warning: " + e.message);
}
}
_this.unsubscriptions = [];
if (_this.form) {
// set initial state
var initialState = {};
_this.form.subscribe(function (state) {
initialState = state;
}, subscription || all$1)();
_this.state = { state: initialState };
_this.state = {
state: initialState
};
}
if (decorators) {

@@ -519,6 +569,9 @@ decorators.forEach(function (decorator) {

}
return _this;
}
ReactFinalForm.prototype.getChildContext = function getChildContext() {
var _proto = ReactFinalForm.prototype;
_proto.getChildContext = function getChildContext() {
return {

@@ -529,3 +582,3 @@ reactFinalForm: this.form

ReactFinalForm.prototype.componentWillMount = function componentWillMount() {
_proto.componentWillMount = function componentWillMount() {
if (this.form) {

@@ -536,3 +589,3 @@ this.form.pauseValidation();

ReactFinalForm.prototype.componentDidMount = function componentDidMount() {
_proto.componentDidMount = function componentDidMount() {
if (this.form) {

@@ -544,3 +597,3 @@ this.unsubscriptions.push(this.form.subscribe(this.notify, this.props.subscription || all$1));

ReactFinalForm.prototype.componentWillUpdate = function componentWillUpdate() {
_proto.componentWillUpdate = function componentWillUpdate() {
// istanbul ignore next

@@ -553,3 +606,3 @@ if (this.form) {

ReactFinalForm.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var _this2 = this;

@@ -561,5 +614,7 @@

}
if (this.props.initialValues && !(this.props.initialValuesEqual || shallowEqual)(prevProps.initialValues, this.props.initialValues)) {
this.form.initialize(this.props.initialValues);
}
finalForm.configOptions.forEach(function (key) {

@@ -569,5 +624,6 @@ if (key === 'initialValues' || prevProps[key] === _this2.props[key]) {

}
_this2.form.setConfig(key, _this2.props[key]);
});
// istanbul ignore next
}); // istanbul ignore next
{

@@ -577,2 +633,3 @@ if (!shallowEqual(prevProps.decorators, this.props.decorators)) {

}
if (!shallowEqual(prevProps.subscription, this.props.subscription)) {

@@ -584,3 +641,3 @@ console.error('Warning: Form subscription should not change from one render to the next as new values will be ignored');

ReactFinalForm.prototype.componentWillUnmount = function componentWillUnmount() {
_proto.componentWillUnmount = function componentWillUnmount() {
this.unsubscriptions.forEach(function (unsubscribe) {

@@ -591,15 +648,15 @@ return unsubscribe();

ReactFinalForm.prototype.render = function render() {
_proto.render = function render() {
var _this3 = this;
// remove config props
var _props = this.props,
debug = _props.debug,
initialValues = _props.initialValues,
mutators = _props.mutators,
onSubmit = _props.onSubmit,
subscription = _props.subscription,
validate = _props.validate,
validateOnBlur = _props.validateOnBlur,
props = objectWithoutProperties(_props, ['debug', 'initialValues', 'mutators', 'onSubmit', 'subscription', 'validate', 'validateOnBlur']);
var _this$props = this.props,
debug = _this$props.debug,
initialValues = _this$props.initialValues,
mutators = _this$props.mutators,
onSubmit = _this$props.onSubmit,
subscription = _this$props.subscription,
validate = _this$props.validate,
validateOnBlur = _this$props.validateOnBlur,
props = _objectWithoutPropertiesLoose(_this$props, ["debug", "initialValues", "mutators", "onSubmit", "subscription", "validate", "validateOnBlur"]);

@@ -610,4 +667,5 @@ var renderProps = _extends({}, this.state ? this.state.state : {}, {

{
console.error('Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.batch(fn);

@@ -618,4 +676,5 @@ },

{
console.error('Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.blur(name);

@@ -626,4 +685,5 @@ },

{
console.error('Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.change(name, value);

@@ -634,4 +694,5 @@ },

{
console.error('Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.focus(name);

@@ -653,4 +714,5 @@ },

{
console.error('Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.initialize(values);

@@ -660,10 +722,12 @@ },

result[key] = function () {
var _form$mutators;
var _this3$form$mutators;
(_form$mutators = _this3.form.mutators)[key].apply(_form$mutators, arguments);
// istanbul ignore next
(_this3$form$mutators = _this3.form.mutators)[key].apply(_this3$form$mutators, arguments); // istanbul ignore next
{
console.error('Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your ReactFinalForm render prop.");
}
};
return result;

@@ -674,7 +738,9 @@ }, {}),

{
console.error('Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your ReactFinalForm render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your ReactFinalForm render prop.");
}
return _this3.form.reset(values);
}
});
return renderComponent(_extends({}, props, renderProps, {

@@ -688,32 +754,33 @@ __versions: versions

ReactFinalForm.childContextTypes = {
_defineProperty(ReactFinalForm, "childContextTypes", {
reactFinalForm: PropTypes.object
};
});
//
var FormSpy =
/*#__PURE__*/
function (_React$Component) {
_inheritsLoose(FormSpy, _React$Component);
var FormSpy = function (_React$Component) {
inherits(FormSpy, _React$Component);
function FormSpy(props, context) {
classCallCheck(this, FormSpy);
var _this;
var _this = possibleConstructorReturn(this, _React$Component.call(this, props, context));
_this = _React$Component.call(this, props, context) || this;
_this.subscribe = function (_ref, listener) {
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) {
var subscription = _ref.subscription;
_this.unsubscribe = _this.context.reactFinalForm.subscribe(listener, subscription || all$1);
};
});
_this.notify = function (state) {
_this.setState({ state: state });
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) {
_this.setState({
state: state
});
if (_this.props.onChange) {
_this.props.onChange(state);
}
};
});
var initialState = void 0;
var initialState; // istanbul ignore next
// istanbul ignore next
if (!context.reactFinalForm) {

@@ -730,2 +797,3 @@ console.error('Warning: FormSpy must be used inside of a ReactFinalForm component');

initialState = state;
if (props.onChange) {

@@ -737,9 +805,15 @@ props.onChange(state);

}
if (initialState) {
_this.state = { state: initialState };
_this.state = {
state: initialState
};
}
return _this;
}
FormSpy.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
var _proto = FormSpy.prototype;
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var subscription = this.props.subscription;

@@ -756,13 +830,13 @@

FormSpy.prototype.componentWillUnmount = function componentWillUnmount() {
_proto.componentWillUnmount = function componentWillUnmount() {
this.unsubscribe();
};
FormSpy.prototype.render = function render() {
var _props = this.props,
onChange = _props.onChange,
subscription = _props.subscription,
rest = objectWithoutProperties(_props, ['onChange', 'subscription']);
_proto.render = function render() {
var _this$props = this.props,
onChange = _this$props.onChange,
subscription = _this$props.subscription,
rest = _objectWithoutPropertiesLoose(_this$props, ["onChange", "subscription"]);
var reactFinalForm = this.context.reactFinalForm;
var renderProps = {

@@ -772,4 +846,5 @@ batch: reactFinalForm && function (fn) {

{
console.error('Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.batch() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.batch() instead. Check your FormSpy render prop.");
}
return reactFinalForm.batch(fn);

@@ -780,4 +855,5 @@ },

{
console.error('Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.blur() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.blur() instead. Check your FormSpy render prop.");
}
return reactFinalForm.blur(name);

@@ -788,4 +864,5 @@ },

{
console.error('Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.change() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.change() instead. Check your FormSpy render prop.");
}
return reactFinalForm.change(name, value);

@@ -796,4 +873,5 @@ },

{
console.error('Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.focus() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.focus() instead. Check your FormSpy render prop.");
}
return reactFinalForm.focus(name);

@@ -814,4 +892,5 @@ },

{
console.error('Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.initialize() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.initialize() instead. Check your FormSpy render prop.");
}
return reactFinalForm.initialize(values);

@@ -823,8 +902,10 @@ },

(_reactFinalForm$mutat = reactFinalForm.mutators)[key].apply(_reactFinalForm$mutat, arguments);
// istanbul ignore next
(_reactFinalForm$mutat = reactFinalForm.mutators)[key].apply(_reactFinalForm$mutat, arguments); // istanbul ignore next
{
console.error('Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.mutators is deprecated and will be removed in the next major version of React Final Form. Use: props.form.mutators instead. Check your FormSpy render prop.");
}
};
return result;

@@ -835,4 +916,5 @@ }, {}),

{
console.error('Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your FormSpy render prop.');
console.error("Warning: As of React Final Form v3.3.0, props.reset() is deprecated and will be removed in the next major version of React Final Form. Use: props.form.reset() instead. Check your FormSpy render prop.");
}
return reactFinalForm.reset(values);

@@ -839,0 +921,0 @@ }

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types"),require("final-form")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","final-form"],e):e(t["react-final-form"]={},t.React,t.PropTypes,t.FinalForm)}(this,function(t,d,e,u){"use strict";function a(e,n,t){return e?!n||t.some(function(t){return e[t]!==n[t]}):!!n}e=e&&e.hasOwnProperty("default")?e.default:e;var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},b=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},n=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},v=function(t,e){var n={};for(var r in t)0<=e.indexOf(r)||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},l=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e};function y(t,e){var n=t.render,r=t.children,i=t.component,o=v(t,["render","children","component"]);return i?d.createElement(i,b({},o,{children:r,render:n})):n?n(b({},o,{children:r})):"function"!=typeof r?null:r(o)}var o="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product,s=u.fieldSubscriptionItems.reduce(function(t,e){return t[e]=!0,t},{}),r=function(i){function h(t,e){f(this,h);var n=l(this,i.call(this,t,e));p.call(n);var r=void 0;return n.context.reactFinalForm&&n.subscribe(t,function(t){r?n.notify(t):r=t}),n.state={state:r},n}return n(h,i),h.prototype.componentDidUpdate=function(t){var e=this.props,n=e.name,r=e.subscription;(t.name!==n||a(t.subscription,r,u.fieldSubscriptionItems))&&this.context.reactFinalForm&&(this.unsubscribe(),this.subscribe(this.props,this.notify))},h.prototype.componentWillUnmount=function(){this.unsubscribe()},h.prototype.render=function(){var t=this.props,e=t.allowNull,n=t.component,r=t.children,i=t.format,o=t.formatOnBlur,a=(t.parse,t.isEqual,t.name),s=(t.subscription,t.validate,t.validateFields,t.value),u=v(t,["allowNull","component","children","format","formatOnBlur","parse","isEqual","name","subscription","validate","validateFields","value"]),c=this.state.state||{},f=(c.blur,c.change,c.focus,c.value),l=(c.name,v(c,["blur","change","focus","value","name"])),p={active:l.active,data:l.data,dirty:l.dirty,dirtySinceLastSubmit:l.dirtySinceLastSubmit,error:l.error,initial:l.initial,invalid:l.invalid,pristine:l.pristine,submitError:l.submitError,submitFailed:l.submitFailed,submitSucceeded:l.submitSucceeded,touched:l.touched,valid:l.valid,visited:l.visited};o?f=h.defaultProps.format(f,a):i&&(f=i(f,a)),null!==f||e||(f="");var m=b({name:a,value:f},this.handlers);return"checkbox"===u.type?void 0===s?m.checked=!!f:(m.checked=!(!Array.isArray(f)||!~f.indexOf(s)),m.value=s):"radio"===u.type?(m.checked=f===s,m.value=s):"select"===n&&u.multiple&&(m.value=m.value||[]),"function"==typeof r?r(b({input:m,meta:p},u)):"string"==typeof n?d.createElement(n,b({},m,{children:r},u)):y(b({},{input:m,meta:p},{children:r,component:n},u))},h}(d.Component);r.contextTypes={reactFinalForm:e.object},r.defaultProps={format:function(t,e){return void 0===t?"":t},parse:function(t,e){return""===t?void 0:t}};var p=function(){var a=this;this.subscribe=function(t,e){var n=t.isEqual,r=t.name,i=t.subscription,o=t.validateFields;a.unsubscribe=a.context.reactFinalForm.registerField(r,e,i||s,{isEqual:n,getValidator:function(){return a.props.validate},validateFields:o})},this.notify=function(t){return a.setState({state:t})},this.handlers={onBlur:function(t){var e=a.state.state;if(e){var n=a.props,r=n.format,i=n.formatOnBlur;e.blur(),r&&i&&e.change(r(e.value,e.name))}},onChange:function(t){var e=a.props,n=e.parse,r=e.value,i=t&&t.target?function(t,e,n,r){if(!r&&t.nativeEvent&&void 0!==t.nativeEvent.text)return t.nativeEvent.text;if(r&&t.nativeEvent)return t.nativeEvent.text;var i=t.target,o=i.type,a=i.value,s=i.checked;switch(o){case"checkbox":if(void 0===n)return!!s;if(s)return Array.isArray(e)?e.concat(n):[n];if(!Array.isArray(e))return e;var u=e.indexOf(n);return u<0?e:e.slice(0,u).concat(e.slice(u+1));case"select-multiple":return function(t){var e=[];if(t)for(var n=0;n<t.length;n++){var r=t[n];r.selected&&e.push(r.value)}return e}(t.target.options);default:return a}}(t,a.state.state&&a.state.state.value,r,o):t;a.state.state&&a.state.state.change(n?n(i,a.props.name):i)},onFocus:function(t){a.state.state&&a.state.state.focus()}}},m=function(t){return!(!t||"function"!=typeof t.stopPropagation)},i="3.6.0",h={"final-form":u.version,"react-final-form":i},g=u.formSubscriptionItems.reduce(function(t,e){return t[e]=!0,t},{}),F=function(a){function s(t){f(this,s);var e=l(this,a.call(this,t));e.notify=function(t){e.mounted&&e.setState({state:t}),e.mounted=!0},e.handleSubmit=function(t){return t&&("function"==typeof t.preventDefault&&t.preventDefault(),"function"==typeof t.stopPropagation&&t.stopPropagation()),e.form.submit()};t.children,t.component,t.render;var n=t.subscription,r=t.decorators,i=v(t,["children","component","render","subscription","decorators"]);e.mounted=!1;try{e.form=u.createForm(i)}catch(t){}if(e.unsubscriptions=[],e.form){var o={};e.form.subscribe(function(t){o=t},n||g)(),e.state={state:o}}return r&&r.forEach(function(t){e.unsubscriptions.push(t(e.form))}),e}return n(s,a),s.prototype.getChildContext=function(){return{reactFinalForm:this.form}},s.prototype.componentWillMount=function(){this.form&&this.form.pauseValidation()},s.prototype.componentDidMount=function(){this.form&&(this.unsubscriptions.push(this.form.subscribe(this.notify,this.props.subscription||g)),this.form.resumeValidation())},s.prototype.componentWillUpdate=function(){this.form&&(this.resumeValidation=this.resumeValidation||!this.form.isValidationPaused(),this.form.pauseValidation())},s.prototype.componentDidUpdate=function(e){var n=this;this.form&&this.resumeValidation&&this.form.resumeValidation(),this.props.initialValues&&!(this.props.initialValuesEqual||function(t,e){if(t===e)return!0;if("object"!==(void 0===t?"undefined":c(t))||!t||"object"!==(void 0===e?"undefined":c(e))||!e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var i=Object.prototype.hasOwnProperty.bind(e),o=0;o<n.length;o++){var a=n[o];if(!i(a)||t[a]!==e[a])return!1}return!0})(e.initialValues,this.props.initialValues)&&this.form.initialize(this.props.initialValues),u.configOptions.forEach(function(t){"initialValues"!==t&&e[t]!==n.props[t]&&n.form.setConfig(t,n.props[t])})},s.prototype.componentWillUnmount=function(){this.unsubscriptions.forEach(function(t){return t()})},s.prototype.render=function(){var n=this,t=this.props,e=(t.debug,t.initialValues,t.mutators,t.onSubmit,t.subscription,t.validate,t.validateOnBlur,v(t,["debug","initialValues","mutators","onSubmit","subscription","validate","validateOnBlur"])),r=b({},this.state?this.state.state:{},{batch:this.form&&function(t){return n.form.batch(t)},blur:this.form&&function(t){return n.form.blur(t)},change:this.form&&function(t,e){return n.form.change(t,e)},focus:this.form&&function(t){return n.form.focus(t)},form:b({},this.form,{reset:function(t){m(t)?n.form.reset():n.form.reset(t)}}),handleSubmit:this.handleSubmit,initialize:this.form&&function(t){return n.form.initialize(t)},mutators:this.form&&Object.keys(this.form.mutators).reduce(function(t,e){return t[e]=function(){var t;(t=n.form.mutators)[e].apply(t,arguments)},t},{}),reset:this.form&&function(t){return n.form.reset(t)}});return y(b({},e,r,{__versions:h}))},s}(d.Component);F.childContextTypes={reactFinalForm:e.object};var O=function(i){function o(e,t){f(this,o);var r=l(this,i.call(this,e,t));r.subscribe=function(t,e){var n=t.subscription;r.unsubscribe=r.context.reactFinalForm.subscribe(e,n||g)},r.notify=function(t){r.setState({state:t}),r.props.onChange&&r.props.onChange(t)};var n=void 0;return r.context.reactFinalForm&&r.subscribe(e,function(t){n?r.notify(t):(n=t,e.onChange&&e.onChange(t))}),n&&(r.state={state:n}),r}return n(o,i),o.prototype.componentDidUpdate=function(t){var e=this.props.subscription;a(t.subscription,e,u.formSubscriptionItems)&&this.context.reactFinalForm&&(this.unsubscribe(),this.subscribe(this.props,this.notify))},o.prototype.componentWillUnmount=function(){this.unsubscribe()},o.prototype.render=function(){var t=this.props,e=t.onChange,n=(t.subscription,v(t,["onChange","subscription"])),r=this.context.reactFinalForm,i={batch:r&&function(t){return r.batch(t)},blur:r&&function(t){return r.blur(t)},change:r&&function(t,e){return r.change(t,e)},focus:r&&function(t){return r.focus(t)},form:b({},r,{reset:function(t){m(t)?r.reset():r.reset(t)}}),initialize:r&&function(t){return r.initialize(t)},mutators:r&&Object.keys(r.mutators).reduce(function(t,e){return t[e]=function(){var t;(t=r.mutators)[e].apply(t,arguments)},t},{}),reset:r&&function(t){return r.reset(t)}};return e?null:y(b({},n,this.state?this.state.state:{},i))},o}(d.Component);O.contextTypes={reactFinalForm:e.object},t.Field=r,t.Form=F,t.version=i,t.FormSpy=O,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types"),require("final-form")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","final-form"],e):e(t["react-final-form"]={},t.React,t.PropTypes,t.FinalForm)}(this,function(t,h,e,s){"use strict";function u(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function b(){return(b=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function n(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function v(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],0<=e.indexOf(n)||(i[n]=t[n]);return i}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function o(e,n,t){return e?!n||t.some(function(t){return e[t]!==n[t]}):!!n}function y(t,e){var n=t.render,r=t.children,i=t.component,o=v(t,["render","children","component"]);return i?h.createElement(i,b({},o,{children:r,render:n})):n?n(b({},o,{children:r})):"function"!=typeof r?null:r(o)}e=e&&e.hasOwnProperty("default")?e.default:e;var f="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product,l=s.fieldSubscriptionItems.reduce(function(t,e){return t[e]=!0,t},{}),r=function(r){function d(t,e){var a,n;return u(c(c(a=r.call(this,t,e)||this)),"subscribe",function(t,e){var n=t.isEqual,r=t.name,i=t.subscription,o=t.validateFields;a.unsubscribe=a.context.reactFinalForm.registerField(r,e,i||l,{isEqual:n,getValidator:function(){return a.props.validate},validateFields:o})}),u(c(c(a)),"notify",function(t){return a.setState({state:t})}),u(c(c(a)),"handlers",{onBlur:function(t){var e=a.state.state;if(e){var n=a.props,r=n.format,i=n.formatOnBlur;e.blur(),r&&i&&e.change(r(e.value,e.name))}},onChange:function(t){var e=a.props,n=e.parse,r=e.value,i=t&&t.target?function(t,e,n,r){if(!r&&t.nativeEvent&&void 0!==t.nativeEvent.text)return t.nativeEvent.text;if(r&&t.nativeEvent)return t.nativeEvent.text;var i=t.target,o=i.type,a=i.value,s=i.checked;switch(o){case"checkbox":if(void 0===n)return!!s;if(s)return Array.isArray(e)?e.concat(n):[n];if(!Array.isArray(e))return e;var u=e.indexOf(n);return u<0?e:e.slice(0,u).concat(e.slice(u+1));case"select-multiple":return function(t){var e=[];if(t)for(var n=0;n<t.length;n++){var r=t[n];r.selected&&e.push(r.value)}return e}(t.target.options);default:return a}}(t,a.state.state&&a.state.state.value,r,f):t;a.state.state&&a.state.state.change(n?n(i,a.props.name):i)},onFocus:function(t){a.state.state&&a.state.state.focus()}}),a.context.reactFinalForm&&a.subscribe(t,function(t){n?a.notify(t):n=t}),a.state={state:n},a}n(d,r);var t=d.prototype;return t.componentDidUpdate=function(t){var e=this.props,n=e.name,r=e.subscription;(t.name!==n||o(t.subscription,r,s.fieldSubscriptionItems))&&this.context.reactFinalForm&&(this.unsubscribe(),this.subscribe(this.props,this.notify))},t.componentWillUnmount=function(){this.unsubscribe()},t.render=function(){var t=this.props,e=t.allowNull,n=t.component,r=t.children,i=t.format,o=t.formatOnBlur,a=(t.parse,t.isEqual,t.name),s=(t.subscription,t.validate,t.validateFields,t.value),u=v(t,["allowNull","component","children","format","formatOnBlur","parse","isEqual","name","subscription","validate","validateFields","value"]),c=this.state.state||{},f=(c.blur,c.change,c.focus,c.value),l=(c.name,v(c,["blur","change","focus","value","name"])),p={active:l.active,data:l.data,dirty:l.dirty,dirtySinceLastSubmit:l.dirtySinceLastSubmit,error:l.error,initial:l.initial,invalid:l.invalid,pristine:l.pristine,submitError:l.submitError,submitFailed:l.submitFailed,submitSucceeded:l.submitSucceeded,touched:l.touched,valid:l.valid,visited:l.visited};o?f=d.defaultProps.format(f,a):i&&(f=i(f,a)),null!==f||e||(f="");var m=b({name:a,value:f},this.handlers);return"checkbox"===u.type?void 0===s?m.checked=!!f:(m.checked=!(!Array.isArray(f)||!~f.indexOf(s)),m.value=s):"radio"===u.type?(m.checked=f===s,m.value=s):"select"===n&&u.multiple&&(m.value=m.value||[]),"function"==typeof r?r(b({input:m,meta:p},u)):"string"==typeof n?h.createElement(n,b({},m,{children:r},u)):y(b({},{input:m,meta:p},{children:r,component:n},u))},d}(h.Component);u(r,"contextTypes",{reactFinalForm:e.object}),u(r,"defaultProps",{format:function(t,e){return void 0===t?"":t},parse:function(t,e){return""===t?void 0:t}});var p=function(t){return!(!t||"function"!=typeof t.stopPropagation)},i="3.6.0",m={"final-form":s.version,"react-final-form":i},d=s.formSubscriptionItems.reduce(function(t,e){return t[e]=!0,t},{}),a=function(a){function t(t){var e;u(c(c(e=a.call(this,t)||this)),"notify",function(t){e.mounted&&e.setState({state:t}),e.mounted=!0}),u(c(c(e)),"handleSubmit",function(t){return t&&("function"==typeof t.preventDefault&&t.preventDefault(),"function"==typeof t.stopPropagation&&t.stopPropagation()),e.form.submit()});t.children,t.component,t.render;var n=t.subscription,r=t.decorators,i=v(t,["children","component","render","subscription","decorators"]);e.mounted=!1;try{e.form=s.createForm(i)}catch(t){}if(e.unsubscriptions=[],e.form){var o={};e.form.subscribe(function(t){o=t},n||d)(),e.state={state:o}}return r&&r.forEach(function(t){e.unsubscriptions.push(t(e.form))}),e}n(t,a);var e=t.prototype;return e.getChildContext=function(){return{reactFinalForm:this.form}},e.componentWillMount=function(){this.form&&this.form.pauseValidation()},e.componentDidMount=function(){this.form&&(this.unsubscriptions.push(this.form.subscribe(this.notify,this.props.subscription||d)),this.form.resumeValidation())},e.componentWillUpdate=function(){this.form&&(this.resumeValidation=this.resumeValidation||!this.form.isValidationPaused(),this.form.pauseValidation())},e.componentDidUpdate=function(e){var n=this;this.form&&this.resumeValidation&&this.form.resumeValidation(),this.props.initialValues&&!(this.props.initialValuesEqual||function(t,e){if(t===e)return!0;if("object"!=typeof t||!t||"object"!=typeof e||!e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var i=Object.prototype.hasOwnProperty.bind(e),o=0;o<n.length;o++){var a=n[o];if(!i(a)||t[a]!==e[a])return!1}return!0})(e.initialValues,this.props.initialValues)&&this.form.initialize(this.props.initialValues),s.configOptions.forEach(function(t){"initialValues"!==t&&e[t]!==n.props[t]&&n.form.setConfig(t,n.props[t])})},e.componentWillUnmount=function(){this.unsubscriptions.forEach(function(t){return t()})},e.render=function(){var n=this,t=this.props;t.debug,t.initialValues,t.mutators,t.onSubmit,t.subscription,t.validate,t.validateOnBlur;return y(b({},v(t,["debug","initialValues","mutators","onSubmit","subscription","validate","validateOnBlur"]),b({},this.state?this.state.state:{},{batch:this.form&&function(t){return n.form.batch(t)},blur:this.form&&function(t){return n.form.blur(t)},change:this.form&&function(t,e){return n.form.change(t,e)},focus:this.form&&function(t){return n.form.focus(t)},form:b({},this.form,{reset:function(t){p(t)?n.form.reset():n.form.reset(t)}}),handleSubmit:this.handleSubmit,initialize:this.form&&function(t){return n.form.initialize(t)},mutators:this.form&&Object.keys(this.form.mutators).reduce(function(t,e){return t[e]=function(){var t;(t=n.form.mutators)[e].apply(t,arguments)},t},{}),reset:this.form&&function(t){return n.form.reset(t)}}),{__versions:m}))},t}(h.Component);u(a,"childContextTypes",{reactFinalForm:e.object});var g=function(i){function t(e,t){var r,n;return u(c(c(r=i.call(this,e,t)||this)),"subscribe",function(t,e){var n=t.subscription;r.unsubscribe=r.context.reactFinalForm.subscribe(e,n||d)}),u(c(c(r)),"notify",function(t){r.setState({state:t}),r.props.onChange&&r.props.onChange(t)}),r.context.reactFinalForm&&r.subscribe(e,function(t){n?r.notify(t):(n=t,e.onChange&&e.onChange(t))}),n&&(r.state={state:n}),r}n(t,i);var e=t.prototype;return e.componentDidUpdate=function(t){var e=this.props.subscription;o(t.subscription,e,s.formSubscriptionItems)&&this.context.reactFinalForm&&(this.unsubscribe(),this.subscribe(this.props,this.notify))},e.componentWillUnmount=function(){this.unsubscribe()},e.render=function(){var t=this.props,e=t.onChange,n=(t.subscription,v(t,["onChange","subscription"])),r=this.context.reactFinalForm,i={batch:r&&function(t){return r.batch(t)},blur:r&&function(t){return r.blur(t)},change:r&&function(t,e){return r.change(t,e)},focus:r&&function(t){return r.focus(t)},form:b({},r,{reset:function(t){p(t)?r.reset():r.reset(t)}}),initialize:r&&function(t){return r.initialize(t)},mutators:r&&Object.keys(r.mutators).reduce(function(t,e){return t[e]=function(){var t;(t=r.mutators)[e].apply(t,arguments)},t},{}),reset:r&&function(t){return r.reset(t)}};return e?null:y(b({},n,this.state?this.state.state:{},i))},t}(h.Component);g.contextTypes={reactFinalForm:e.object},t.Field=r,t.Form=a,t.version=i,t.FormSpy=g,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=react-final-form.umd.min.js.map
{
"name": "react-final-form",
"version": "3.6.6",
"version": "3.6.7",
"description": "🏁 High performance subscription-based form state management for React",

@@ -10,3 +10,4 @@ "main": "dist/react-final-form.cjs.js",

"files": [
"dist"
"dist",
"scripts"
],

@@ -32,43 +33,54 @@ "scripts": {

"devDependencies": {
"@types/react": "^16.4.2",
"babel-eslint": "^8.2.5",
"babel-jest": "^23.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"@babel/core": "^7.1.2",
"@babel/plugin-external-helpers": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@types/react": "^16.4.16",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"bundlesize": "^0.17.0",
"doctoc": "^1.3.0",
"eslint": "^5.0.1",
"eslint-config-react-app": "^2.1.0",
"eslint-plugin-babel": "^5.1.0",
"eslint-plugin-flowtype": "^2.46.3",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.10.0",
"eslint": "^5.6.1",
"eslint-config-react-app": "^3.0.3",
"eslint-plugin-babel": "^5.2.1",
"eslint-plugin-flowtype": "^2.50.3",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"fast-deep-equal": "^2.0.1",
"final-form": "^4.8.3",
"flow-bin": "^0.75.0",
"final-form": "^4.10.0",
"flow-bin": "^0.82.0",
"glow": "^1.2.2",
"husky": "^0.14.3",
"jest": "^23.2.0",
"lint-staged": "^7.0.4",
"nps": "^5.9.2",
"nps-utils": "^1.6.0",
"husky": "^1.1.1",
"jest": "^23.6.0",
"lint-staged": "^7.3.0",
"nps": "^5.9.3",
"nps-utils": "^1.7.0",
"opencollective": "^1.0.3",
"prettier": "^1.13.6",
"prettier": "^1.14.3",
"prettier-eslint-cli": "^4.7.1",
"prop-types": "^15.6.2",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"rollup": "^0.61.2",
"rollup-plugin-babel": "^3.0.5",
"rollup-plugin-commonjs": "^9.1.0",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"rollup": "^0.66.6",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-flow": "^1.1.1",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^4.0.0",
"tslint": "^5.9.1",
"typescript": "^2.8.1"
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-uglify": "^6.0.0",
"tslint": "^5.11.0",
"typescript": "^3.1.2"
},

@@ -75,0 +87,0 @@ "peerDependencies": {

@@ -18,3 +18,3 @@ # 🏁 React Final Form

✅ 💥 [**3.1k gzipped**](https://bundlephobia.com/result?p=react-final-form) 💥
✅ 💥 [**3.0k gzipped**](https://bundlephobia.com/result?p=react-final-form) 💥

@@ -649,3 +649,3 @@ ---

[See the 🏁 Final Form docs on `keepDirtyOnReinitialize`](https://github.com/final-form/final-form##keepdirtyonreinitialize-boolean).
[See the 🏁 Final Form docs on `keepDirtyOnReinitialize`](https://github.com/final-form/final-form#keepdirtyonreinitialize-boolean).

@@ -652,0 +652,0 @@ #### `mutators?: { [string]: Mutator }`

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc