react-final-form
Advanced tools
Comparing version 3.6.7 to 3.7.0
@@ -37,2 +37,3 @@ import * as React from 'react' | ||
submitSucceeded: boolean | ||
submitting: boolean | ||
touched: boolean | ||
@@ -39,0 +40,0 @@ valid: boolean |
@@ -11,17 +11,2 @@ 'use strict'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _extends() { | ||
@@ -66,10 +51,2 @@ _extends = Object.assign || function (target) { | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
// | ||
@@ -208,3 +185,3 @@ function diffSubscription (a, b, keys) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) { | ||
_this.subscribe = function (_ref, listener) { | ||
var isEqual = _ref.isEqual, | ||
@@ -221,11 +198,11 @@ name = _ref.name, | ||
}); | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) { | ||
_this.notify = function (state) { | ||
return _this.setState({ | ||
state: state | ||
}); | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handlers", { | ||
_this.handlers = { | ||
onBlur: function onBlur(event) { | ||
@@ -271,4 +248,3 @@ var state = _this.state.state; // this is to appease the Flow gods | ||
} | ||
}); | ||
}; | ||
var initialState; // istanbul ignore next | ||
@@ -354,2 +330,3 @@ | ||
submitSucceeded: otherState.submitSucceeded, | ||
submitting: otherState.submitting, | ||
touched: otherState.touched, | ||
@@ -417,7 +394,6 @@ valid: otherState.valid, | ||
_defineProperty(Field, "contextTypes", { | ||
Field.contextTypes = { | ||
reactFinalForm: PropTypes.object | ||
}); | ||
_defineProperty(Field, "defaultProps", { | ||
}; | ||
Field.defaultProps = { | ||
format: function format(value, name) { | ||
@@ -429,3 +405,3 @@ return value === undefined ? '' : value; | ||
} | ||
}); | ||
}; | ||
@@ -487,3 +463,3 @@ // | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) { | ||
_this.notify = function (state) { | ||
if (_this.mounted) { | ||
@@ -496,5 +472,5 @@ _this.setState({ | ||
_this.mounted = true; | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleSubmit", function (event) { | ||
_this.handleSubmit = function (event) { | ||
if (event) { | ||
@@ -513,3 +489,3 @@ // sometimes not true, e.g. React Native | ||
return _this.form.submit(); | ||
}); | ||
}; | ||
@@ -723,5 +699,5 @@ var children = props.children, | ||
_defineProperty(ReactFinalForm, "childContextTypes", { | ||
ReactFinalForm.childContextTypes = { | ||
reactFinalForm: PropTypes.object | ||
}); | ||
}; | ||
@@ -738,8 +714,8 @@ var FormSpy = | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) { | ||
_this.subscribe = function (_ref, listener) { | ||
var subscription = _ref.subscription; | ||
_this.unsubscribe = _this.context.reactFinalForm.subscribe(listener, subscription || all$1); | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) { | ||
_this.notify = function (state) { | ||
_this.setState({ | ||
@@ -752,3 +728,3 @@ state: state | ||
} | ||
}); | ||
}; | ||
@@ -755,0 +731,0 @@ var initialState; // istanbul ignore next |
@@ -5,17 +5,2 @@ import { createElement, Component } from 'react'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _extends() { | ||
@@ -60,10 +45,2 @@ _extends = Object.assign || function (target) { | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
// | ||
@@ -202,3 +179,3 @@ function diffSubscription (a, b, keys) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) { | ||
_this.subscribe = function (_ref, listener) { | ||
var isEqual = _ref.isEqual, | ||
@@ -215,11 +192,11 @@ name = _ref.name, | ||
}); | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) { | ||
_this.notify = function (state) { | ||
return _this.setState({ | ||
state: state | ||
}); | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handlers", { | ||
_this.handlers = { | ||
onBlur: function onBlur(event) { | ||
@@ -265,4 +242,3 @@ var state = _this.state.state; // this is to appease the Flow gods | ||
} | ||
}); | ||
}; | ||
var initialState; // istanbul ignore next | ||
@@ -348,2 +324,3 @@ | ||
submitSucceeded: otherState.submitSucceeded, | ||
submitting: otherState.submitting, | ||
touched: otherState.touched, | ||
@@ -411,7 +388,6 @@ valid: otherState.valid, | ||
_defineProperty(Field, "contextTypes", { | ||
Field.contextTypes = { | ||
reactFinalForm: PropTypes.object | ||
}); | ||
_defineProperty(Field, "defaultProps", { | ||
}; | ||
Field.defaultProps = { | ||
format: function format(value, name) { | ||
@@ -423,3 +399,3 @@ return value === undefined ? '' : value; | ||
} | ||
}); | ||
}; | ||
@@ -481,3 +457,3 @@ // | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) { | ||
_this.notify = function (state) { | ||
if (_this.mounted) { | ||
@@ -490,5 +466,5 @@ _this.setState({ | ||
_this.mounted = true; | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleSubmit", function (event) { | ||
_this.handleSubmit = function (event) { | ||
if (event) { | ||
@@ -507,3 +483,3 @@ // sometimes not true, e.g. React Native | ||
return _this.form.submit(); | ||
}); | ||
}; | ||
@@ -717,5 +693,5 @@ var children = props.children, | ||
_defineProperty(ReactFinalForm, "childContextTypes", { | ||
ReactFinalForm.childContextTypes = { | ||
reactFinalForm: PropTypes.object | ||
}); | ||
}; | ||
@@ -732,8 +708,8 @@ var FormSpy = | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) { | ||
_this.subscribe = function (_ref, listener) { | ||
var subscription = _ref.subscription; | ||
_this.unsubscribe = _this.context.reactFinalForm.subscribe(listener, subscription || all$1); | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) { | ||
_this.notify = function (state) { | ||
_this.setState({ | ||
@@ -746,3 +722,3 @@ state: state | ||
} | ||
}); | ||
}; | ||
@@ -749,0 +725,0 @@ var initialState; // istanbul ignore next |
@@ -9,17 +9,2 @@ (function (global, factory) { | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _extends() { | ||
@@ -64,10 +49,2 @@ _extends = Object.assign || function (target) { | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
// | ||
@@ -206,3 +183,3 @@ function diffSubscription (a, b, keys) { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) { | ||
_this.subscribe = function (_ref, listener) { | ||
var isEqual = _ref.isEqual, | ||
@@ -219,11 +196,11 @@ name = _ref.name, | ||
}); | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) { | ||
_this.notify = function (state) { | ||
return _this.setState({ | ||
state: state | ||
}); | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handlers", { | ||
_this.handlers = { | ||
onBlur: function onBlur(event) { | ||
@@ -269,4 +246,3 @@ var state = _this.state.state; // this is to appease the Flow gods | ||
} | ||
}); | ||
}; | ||
var initialState; // istanbul ignore next | ||
@@ -352,2 +328,3 @@ | ||
submitSucceeded: otherState.submitSucceeded, | ||
submitting: otherState.submitting, | ||
touched: otherState.touched, | ||
@@ -415,7 +392,6 @@ valid: otherState.valid, | ||
_defineProperty(Field, "contextTypes", { | ||
Field.contextTypes = { | ||
reactFinalForm: PropTypes.object | ||
}); | ||
_defineProperty(Field, "defaultProps", { | ||
}; | ||
Field.defaultProps = { | ||
format: function format(value, name) { | ||
@@ -427,3 +403,3 @@ return value === undefined ? '' : value; | ||
} | ||
}); | ||
}; | ||
@@ -485,3 +461,3 @@ // | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) { | ||
_this.notify = function (state) { | ||
if (_this.mounted) { | ||
@@ -494,5 +470,5 @@ _this.setState({ | ||
_this.mounted = true; | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleSubmit", function (event) { | ||
_this.handleSubmit = function (event) { | ||
if (event) { | ||
@@ -511,3 +487,3 @@ // sometimes not true, e.g. React Native | ||
return _this.form.submit(); | ||
}); | ||
}; | ||
@@ -721,5 +697,5 @@ var children = props.children, | ||
_defineProperty(ReactFinalForm, "childContextTypes", { | ||
ReactFinalForm.childContextTypes = { | ||
reactFinalForm: PropTypes.object | ||
}); | ||
}; | ||
@@ -736,8 +712,8 @@ var FormSpy = | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subscribe", function (_ref, listener) { | ||
_this.subscribe = function (_ref, listener) { | ||
var subscription = _ref.subscription; | ||
_this.unsubscribe = _this.context.reactFinalForm.subscribe(listener, subscription || all$1); | ||
}); | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "notify", function (state) { | ||
_this.notify = function (state) { | ||
_this.setState({ | ||
@@ -750,3 +726,3 @@ state: state | ||
} | ||
}); | ||
}; | ||
@@ -753,0 +729,0 @@ var initialState; // istanbul ignore next |
@@ -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,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})}); | ||
!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 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 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 u="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product,c=s.fieldSubscriptionItems.reduce(function(t,e){return t[e]=!0,t},{}),r=function(r){function d(t,e){var a,n;return(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||c,{isEqual:n,getValidator:function(){return a.props.validate},validateFields:o})},a.notify=function(t){return a.setState({state:t})},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,u):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,submitting:l.submitting,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);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 f=function(t){return!(!t||"function"!=typeof t.stopPropagation)},i="3.6.0",l={"final-form":s.version,"react-final-form":i},p=s.formSubscriptionItems.reduce(function(t,e){return t[e]=!0,t},{}),a=function(a){function t(t){var e;(e=a.call(this,t)||this).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=s.createForm(i)}catch(t){}if(e.unsubscriptions=[],e.form){var o={};e.form.subscribe(function(t){o=t},n||p)(),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||p)),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){f(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:l}))},t}(h.Component);a.childContextTypes={reactFinalForm:e.object};var m=function(i){function t(e,t){var r,n;return(r=i.call(this,e,t)||this).subscribe=function(t,e){var n=t.subscription;r.unsubscribe=r.context.reactFinalForm.subscribe(e,n||p)},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){f(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);m.contextTypes={reactFinalForm:e.object},t.Field=r,t.Form=a,t.version=i,t.FormSpy=m,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=react-final-form.umd.min.js.map |
{ | ||
"name": "react-final-form", | ||
"version": "3.6.7", | ||
"version": "3.7.0", | ||
"description": "🏁 High performance subscription-based form state management for React", | ||
@@ -33,3 +33,2 @@ "main": "dist/react-final-form.cjs.js", | ||
"@babel/core": "^7.1.2", | ||
"@babel/plugin-external-helpers": "^7.0.0", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0", | ||
@@ -45,2 +44,3 @@ "@babel/plugin-proposal-decorators": "^7.0.0", | ||
"@babel/plugin-transform-flow-strip-types": "^7.0.0", | ||
"@babel/plugin-transform-runtime": "^7.1.0", | ||
"@babel/preset-env": "^7.0.0", | ||
@@ -58,3 +58,3 @@ "@babel/preset-flow": "^7.0.0", | ||
"eslint-plugin-babel": "^5.2.1", | ||
"eslint-plugin-flowtype": "^2.50.3", | ||
"eslint-plugin-flowtype": "^3.2.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
@@ -65,7 +65,7 @@ "eslint-plugin-jsx-a11y": "^6.1.2", | ||
"final-form": "^4.10.0", | ||
"flow-bin": "^0.82.0", | ||
"flow-bin": "^0.86.0", | ||
"glow": "^1.2.2", | ||
"husky": "^1.1.1", | ||
"jest": "^23.6.0", | ||
"lint-staged": "^7.3.0", | ||
"lint-staged": "^8.0.4", | ||
"nps": "^5.9.3", | ||
@@ -79,3 +79,3 @@ "nps-utils": "^1.7.0", | ||
"react-dom": "^16.5.2", | ||
"rollup": "^0.66.6", | ||
"rollup": "^0.67.1", | ||
"rollup-plugin-babel": "^4.0.1", | ||
@@ -91,3 +91,3 @@ "rollup-plugin-commonjs": "^9.2.0", | ||
"peerDependencies": { | ||
"final-form": "^4.7.3", | ||
"final-form": "^4.11.0", | ||
"prop-types": "^15.6.0", | ||
@@ -122,3 +122,6 @@ "react": "^15.3.0 || ^16.0.0-0" | ||
"url": "https://opencollective.com/final-form" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.1.2" | ||
} | ||
} |
@@ -18,3 +18,3 @@ # 🏁 React Final Form | ||
✅ 💥 [**3.0k gzipped**](https://bundlephobia.com/result?p=react-final-form) 💥 | ||
✅ 💥 [**2.9k gzipped**](https://bundlephobia.com/result?p=react-final-form) 💥 | ||
@@ -171,3 +171,3 @@ --- | ||
- [`subscription?: FieldSubscription`](#subscription-fieldsubscription) | ||
- [`validate?: (value: ?any, allValues: Object) => ?any`](#validate-value-any-allvalues-object--any) | ||
- [`validate?: (value: ?any, allValues: Object, meta: FieldState) => ?any`](#validate-value-any-allvalues-object--any) | ||
- [`validateFields?: string[]`](#validatefields-string) | ||
@@ -191,2 +191,3 @@ - [`value?: any`](#value-any) | ||
- [`meta.submitSucceeded?: boolean`](#metasubmitsucceeded-boolean) | ||
- [`meta.submitting?: boolean`](#metasubmitting-boolean) | ||
- [`meta.touched?: boolean`](#metatouched-boolean) | ||
@@ -509,5 +510,5 @@ - [`meta.valid?: boolean`](#metavalid-boolean) | ||
#### `validate?: (value: ?any, allValues: Object) => ?any` | ||
#### `validate?: (value: ?any, allValues: Object, meta: FieldState) => ?any` | ||
A function that takes the field value, and all the values of the form and | ||
A function that takes the field value, all the values of the form and the `meta` data about the field and | ||
returns an error if the value is invalid, or `undefined` if the value is valid. | ||
@@ -605,2 +606,6 @@ | ||
#### `meta.submitting?: boolean` | ||
[See the 🏁 Final Form docs on `submitting`](https://github.com/final-form/final-form#submitting-boolean). | ||
#### `meta.touched?: boolean` | ||
@@ -607,0 +612,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
874
145460
4
2252
+ Added@babel/runtime@^7.1.2