react-final-form
Advanced tools
Comparing version 6.3.2 to 6.3.3
@@ -122,3 +122,3 @@ 'use strict'; | ||
var version = "6.3.2"; | ||
var version = "6.3.3"; | ||
@@ -125,0 +125,0 @@ var addLazyState = function addLazyState(dest, state, keys) { |
@@ -115,3 +115,3 @@ import _extends from '@babel/runtime/helpers/esm/extends'; | ||
var version = "6.3.2"; | ||
var version = "6.3.3"; | ||
@@ -118,0 +118,0 @@ var addLazyState = function addLazyState(dest, state, keys) { |
@@ -151,3 +151,3 @@ (function (global, factory) { | ||
var version = "6.3.2"; | ||
var version = "6.3.3"; | ||
@@ -154,0 +154,0 @@ var addLazyState = function addLazyState(dest, state, keys) { |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("final-form")):"function"==typeof define&&define.amd?define(["exports","react","final-form"],t):t((e=e||self)["react-final-form"]={},e.React,e.FinalForm)}(this,function(e,x,F){"use strict";var E="default"in x?x.default:x;function R(){return(R=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function V(e,t){if(null==e)return{};var n,r,i={},u=Object.keys(e);for(r=0;r<u.length;r++)n=u[r],0<=t.indexOf(n)||(i[n]=e[n]);return i}function w(e,t,n){var r=e.render,i=e.children,u=e.component,a=V(e,["render","children","component"]);if(u)return x.createElement(u,Object.assign(t,a,{children:i,render:r}));if(r)return r(void 0===i?Object.assign(t,a):Object.assign(t,a,{children:i}));if("function"!=typeof i)throw new Error("Must specify either a render prop, a render function as children, or a component prop to "+n);return i(Object.assign(t,a))}function C(e,t,n){void 0===n&&(n=function(e,t){return e===t});var r=E.useRef(e);E.useEffect(function(){n(e,r.current)||(t(),r.current=e)})}var j=function(e,t){if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var i=Object.prototype.hasOwnProperty.bind(t),u=0;u<n.length;u++){var a=n[u];if(!i(a)||e[a]!==t[a])return!1}return!0},k=function(e){return!(!e||"function"!=typeof e.stopPropagation)},B=x.createContext();function q(e){var t=E.useRef(e);return E.useEffect(function(){t.current=e}),t}function P(t,n,e){e.forEach(function(e){Object.defineProperty(t,e,{get:function(){return n[e]},enumerable:!0})})}var t="6.3.2",U=function(e,t){return P(e,t,["active","dirty","dirtyFields","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","pristine","submitError","submitErrors","submitFailed","submitSucceeded","submitting","touched","valid","validating","values","visited"])},A={"final-form":F.version,"react-final-form":t},D=F.formSubscriptionItems.reduce(function(e,t){return e[t]=!0,e},{});function n(e){var t=e.debug,n=e.decorators,r=e.destroyOnUnregister,i=e.form,u=e.initialValues,a=e.initialValuesEqual,o=e.keepDirtyOnReinitialize,c=e.mutators,l=e.onSubmit,f=e.subscription,s=void 0===f?D:f,d=e.validate,v=e.validateOnBlur,m=V(e,["debug","decorators","destroyOnUnregister","form","initialValues","initialValuesEqual","keepDirtyOnReinitialize","mutators","onSubmit","subscription","validate","validateOnBlur"]),p={debug:t,destroyOnUnregister:r,initialValues:u,keepDirtyOnReinitialize:o,mutators:c,onSubmit:l,validate:d,validateOnBlur:v},b=function(e){var t=E.useRef();return t.current||(t.current=e()),t.current}(function(){var e=i||F.createForm(p);return e.pauseValidation(),e}),g=x.useState(function(){var t={};return b.subscribe(function(e){t=e},s)(),t}),y=g[0],h=g[1],O=q(y);x.useEffect(function(){b.isValidationPaused()&&b.resumeValidation();var e=[b.subscribe(function(e){j(e,O.current)||h(e)},s)].concat(n?n.map(function(e){return e(b)}):[]);return function(){b.pauseValidation(),e.reverse().forEach(function(e){return e()})}},[n]),C(t,function(){b.setConfig("debug",t)}),C(r,function(){b.destroyOnUnregister=!!r}),C(u,function(){b.setConfig("initialValues",u)},a||j),C(o,function(){b.setConfig("keepDirtyOnReinitialize",o)}),C(c,function(){b.setConfig("mutators",c)}),C(l,function(){b.setConfig("onSubmit",l)}),C(d,function(){b.setConfig("validate",d)}),C(v,function(){b.setConfig("validateOnBlur",v)});var S={form:R({},b,{reset:function(e){k(e)?b.reset():b.reset(e)}}),handleSubmit:function(e){return e&&("function"==typeof e.preventDefault&&e.preventDefault(),"function"==typeof e.stopPropagation&&e.stopPropagation()),b.submit()}};return U(S,y),x.createElement(B.Provider,{value:b},w(R({},m,{__versions:A}),S,"ReactFinalForm"))}function N(e){var t=x.useContext(B);if(!t)throw new Error((e||"useForm")+" must be used inside of a <Form> component");return t}function o(e){var t=void 0===e?{}:e,n=t.onChange,r=t.subscription,i=void 0===r?D:r,u=N("useFormState"),a=x.useRef(!0),o=x.useRef(n);o.current=n;var c=x.useState(function(){var t={};return u.subscribe(function(e){t=e},i)(),n&&n(t),t}),l=c[0],f=c[1];x.useEffect(function(){return u.subscribe(function(e){a.current?a.current=!1:(f(e),o.current&&o.current(e))},i)},[]);var s={};return U(s,l),s}function r(e){var t=e.onChange,n=e.subscription,r=V(e,["onChange","subscription"]),i=N("FormSpy"),u=o({onChange:t,subscription:n});if(t)return null;var a={form:R({},i,{reset:function(e){k(e)?i.reset():i.reset(e)}})};return w(R({},r,{},a),u,"FormSpy")}function z(e){return void 0===e?"":e}function _(e){return""===e?void 0:e}var I="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product,L=F.fieldSubscriptionItems.reduce(function(e,t){return e[t]=!0,e},{});function S(n,e){void 0===e&&(e={});function r(e){return O.registerField(n,e,b,{afterSubmit:i,beforeSubmit:function(){var e=S.current,t=e.beforeSubmit,n=e.formatOnBlur,r=e.format,i=void 0===r?z:r;if(n){var u=O.getFieldState(V.name).value,a=i(u,V.name);a!==u&&V.change(a)}return t&&t()},defaultValue:o,getValidator:function(){return S.current.validate},initialValue:s,isEqual:function(e,t){return(S.current.isEqual||function(e,t){return e===t})(e,t)},validateFields:y})}var t=e,i=t.afterSubmit,u=t.allowNull,a=t.component,o=t.defaultValue,c=t.format,l=void 0===c?z:c,f=t.formatOnBlur,s=t.initialValue,d=t.multiple,v=t.parse,m=void 0===v?_:v,p=t.subscription,b=void 0===p?L:p,g=t.type,y=t.validateFields,h=t.value,O=N("useField"),S=q(e),F=x.useRef(!0),E=x.useState(function(){var t={},e=O.destroyOnUnregister;return O.destroyOnUnregister=!1,r(function(e){t=e})(),O.destroyOnUnregister=e,t}),V=E[0],w=E[1];x.useEffect(function(){return r(function(e){F.current?F.current=!1:w(e)})},[n,o,s]);var C={onBlur:x.useCallback(function(e){if(V.blur(),f){var t=O.getFieldState(V.name);V.change(l(t.value,V.name))}},[V.name,l,f]),onChange:x.useCallback(function(e){var t=e&&e.target?function(e,t,n,r){if(!r&&e.nativeEvent&&void 0!==e.nativeEvent.text)return e.nativeEvent.text;if(r&&e.nativeEvent)return e.nativeEvent.text;var i=e.target,u=i.type,a=i.value,o=i.checked;switch(u){case"checkbox":if(void 0===n)return!!o;if(o)return Array.isArray(t)?t.concat(n):[n];if(!Array.isArray(t))return t;var c=t.indexOf(n);return c<0?t:t.slice(0,c).concat(t.slice(c+1));case"select-multiple":return function(e){var t=[];if(e)for(var n=0;n<e.length;n++){var r=e[n];r.selected&&t.push(r.value)}return t}(e.target.options);default:return a}}(e,V.value,h,I):e;V.change(m(t,n))},[h,n,m,V.change,V.value,g]),onFocus:x.useCallback(function(e){V.focus()},[])},j={};!function(e,t){P(e,t,["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","validating","visited"])}(j,V);var k=R({name:n,get value(){var e=V.value;return f?"input"===a&&(e=z(e)):e=l(e,n),null!==e||u||(e=""),"checkbox"===g||"radio"===g?h:"select"===a&&d?e||[]:e},get checked(){return"checkbox"===g?void 0===h?!!V.value:!(!Array.isArray(V.value)||!~V.value.indexOf(h)):"radio"===g?V.value===h:void 0}},C);return d&&(k.multiple=d),void 0!==g&&(k.type=g),{input:k,meta:j}}e.Field=function(e){var t=e.afterSubmit,n=e.allowNull,r=e.beforeSubmit,i=e.children,u=e.component,a=e.defaultValue,o=e.format,c=e.formatOnBlur,l=e.initialValue,f=e.isEqual,s=e.multiple,d=e.name,v=e.parse,m=e.subscription,p=e.type,b=e.validate,g=e.validateFields,y=e.value,h=V(e,["afterSubmit","allowNull","beforeSubmit","children","component","defaultValue","format","formatOnBlur","initialValue","isEqual","multiple","name","parse","subscription","type","validate","validateFields","value"]),O=S(d,{afterSubmit:t,allowNull:n,beforeSubmit:r,children:i,component:u,defaultValue:a,format:o,formatOnBlur:c,initialValue:l,isEqual:f,multiple:s,parse:v,subscription:m,type:p,validate:b,validateFields:g,value:y});return"function"==typeof i?i(R({},O,{},h)):"string"==typeof u?x.createElement(u,R({},O.input,{children:i},h)):w(R({children:i,component:u},h),O,"Field("+d+")")},e.Form=n,e.FormSpy=r,e.useField=S,e.useForm=N,e.useFormState=o,e.version=t,e.withTypes=function(){return{Form:n,FormSpy:r}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("final-form")):"function"==typeof define&&define.amd?define(["exports","react","final-form"],t):t((e=e||self)["react-final-form"]={},e.React,e.FinalForm)}(this,function(e,x,F){"use strict";var E="default"in x?x.default:x;function R(){return(R=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function V(e,t){if(null==e)return{};var n,r,i={},u=Object.keys(e);for(r=0;r<u.length;r++)n=u[r],0<=t.indexOf(n)||(i[n]=e[n]);return i}function w(e,t,n){var r=e.render,i=e.children,u=e.component,a=V(e,["render","children","component"]);if(u)return x.createElement(u,Object.assign(t,a,{children:i,render:r}));if(r)return r(void 0===i?Object.assign(t,a):Object.assign(t,a,{children:i}));if("function"!=typeof i)throw new Error("Must specify either a render prop, a render function as children, or a component prop to "+n);return i(Object.assign(t,a))}function C(e,t,n){void 0===n&&(n=function(e,t){return e===t});var r=E.useRef(e);E.useEffect(function(){n(e,r.current)||(t(),r.current=e)})}var j=function(e,t){if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var i=Object.prototype.hasOwnProperty.bind(t),u=0;u<n.length;u++){var a=n[u];if(!i(a)||e[a]!==t[a])return!1}return!0},k=function(e){return!(!e||"function"!=typeof e.stopPropagation)},B=x.createContext();function q(e){var t=E.useRef(e);return E.useEffect(function(){t.current=e}),t}function P(t,n,e){e.forEach(function(e){Object.defineProperty(t,e,{get:function(){return n[e]},enumerable:!0})})}var t="6.3.3",U=function(e,t){return P(e,t,["active","dirty","dirtyFields","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","pristine","submitError","submitErrors","submitFailed","submitSucceeded","submitting","touched","valid","validating","values","visited"])},A={"final-form":F.version,"react-final-form":t},D=F.formSubscriptionItems.reduce(function(e,t){return e[t]=!0,e},{});function n(e){var t=e.debug,n=e.decorators,r=e.destroyOnUnregister,i=e.form,u=e.initialValues,a=e.initialValuesEqual,o=e.keepDirtyOnReinitialize,c=e.mutators,l=e.onSubmit,f=e.subscription,s=void 0===f?D:f,d=e.validate,v=e.validateOnBlur,m=V(e,["debug","decorators","destroyOnUnregister","form","initialValues","initialValuesEqual","keepDirtyOnReinitialize","mutators","onSubmit","subscription","validate","validateOnBlur"]),p={debug:t,destroyOnUnregister:r,initialValues:u,keepDirtyOnReinitialize:o,mutators:c,onSubmit:l,validate:d,validateOnBlur:v},b=function(e){var t=E.useRef();return t.current||(t.current=e()),t.current}(function(){var e=i||F.createForm(p);return e.pauseValidation(),e}),g=x.useState(function(){var t={};return b.subscribe(function(e){t=e},s)(),t}),y=g[0],h=g[1],O=q(y);x.useEffect(function(){b.isValidationPaused()&&b.resumeValidation();var e=[b.subscribe(function(e){j(e,O.current)||h(e)},s)].concat(n?n.map(function(e){return e(b)}):[]);return function(){b.pauseValidation(),e.reverse().forEach(function(e){return e()})}},[n]),C(t,function(){b.setConfig("debug",t)}),C(r,function(){b.destroyOnUnregister=!!r}),C(u,function(){b.setConfig("initialValues",u)},a||j),C(o,function(){b.setConfig("keepDirtyOnReinitialize",o)}),C(c,function(){b.setConfig("mutators",c)}),C(l,function(){b.setConfig("onSubmit",l)}),C(d,function(){b.setConfig("validate",d)}),C(v,function(){b.setConfig("validateOnBlur",v)});var S={form:R({},b,{reset:function(e){k(e)?b.reset():b.reset(e)}}),handleSubmit:function(e){return e&&("function"==typeof e.preventDefault&&e.preventDefault(),"function"==typeof e.stopPropagation&&e.stopPropagation()),b.submit()}};return U(S,y),x.createElement(B.Provider,{value:b},w(R({},m,{__versions:A}),S,"ReactFinalForm"))}function N(e){var t=x.useContext(B);if(!t)throw new Error((e||"useForm")+" must be used inside of a <Form> component");return t}function o(e){var t=void 0===e?{}:e,n=t.onChange,r=t.subscription,i=void 0===r?D:r,u=N("useFormState"),a=x.useRef(!0),o=x.useRef(n);o.current=n;var c=x.useState(function(){var t={};return u.subscribe(function(e){t=e},i)(),n&&n(t),t}),l=c[0],f=c[1];x.useEffect(function(){return u.subscribe(function(e){a.current?a.current=!1:(f(e),o.current&&o.current(e))},i)},[]);var s={};return U(s,l),s}function r(e){var t=e.onChange,n=e.subscription,r=V(e,["onChange","subscription"]),i=N("FormSpy"),u=o({onChange:t,subscription:n});if(t)return null;var a={form:R({},i,{reset:function(e){k(e)?i.reset():i.reset(e)}})};return w(R({},r,{},a),u,"FormSpy")}function z(e){return void 0===e?"":e}function _(e){return""===e?void 0:e}var I="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product,L=F.fieldSubscriptionItems.reduce(function(e,t){return e[t]=!0,e},{});function S(n,e){void 0===e&&(e={});function r(e){return O.registerField(n,e,b,{afterSubmit:i,beforeSubmit:function(){var e=S.current,t=e.beforeSubmit,n=e.formatOnBlur,r=e.format,i=void 0===r?z:r;if(n){var u=O.getFieldState(V.name).value,a=i(u,V.name);a!==u&&V.change(a)}return t&&t()},defaultValue:o,getValidator:function(){return S.current.validate},initialValue:s,isEqual:function(e,t){return(S.current.isEqual||function(e,t){return e===t})(e,t)},validateFields:y})}var t=e,i=t.afterSubmit,u=t.allowNull,a=t.component,o=t.defaultValue,c=t.format,l=void 0===c?z:c,f=t.formatOnBlur,s=t.initialValue,d=t.multiple,v=t.parse,m=void 0===v?_:v,p=t.subscription,b=void 0===p?L:p,g=t.type,y=t.validateFields,h=t.value,O=N("useField"),S=q(e),F=x.useRef(!0),E=x.useState(function(){var t={},e=O.destroyOnUnregister;return O.destroyOnUnregister=!1,r(function(e){t=e})(),O.destroyOnUnregister=e,t}),V=E[0],w=E[1];x.useEffect(function(){return r(function(e){F.current?F.current=!1:w(e)})},[n,o,s]);var C={onBlur:x.useCallback(function(e){if(V.blur(),f){var t=O.getFieldState(V.name);V.change(l(t.value,V.name))}},[V.name,l,f]),onChange:x.useCallback(function(e){var t=e&&e.target?function(e,t,n,r){if(!r&&e.nativeEvent&&void 0!==e.nativeEvent.text)return e.nativeEvent.text;if(r&&e.nativeEvent)return e.nativeEvent.text;var i=e.target,u=i.type,a=i.value,o=i.checked;switch(u){case"checkbox":if(void 0===n)return!!o;if(o)return Array.isArray(t)?t.concat(n):[n];if(!Array.isArray(t))return t;var c=t.indexOf(n);return c<0?t:t.slice(0,c).concat(t.slice(c+1));case"select-multiple":return function(e){var t=[];if(e)for(var n=0;n<e.length;n++){var r=e[n];r.selected&&t.push(r.value)}return t}(e.target.options);default:return a}}(e,V.value,h,I):e;V.change(m(t,n))},[h,n,m,V.change,V.value,g]),onFocus:x.useCallback(function(e){V.focus()},[])},j={};!function(e,t){P(e,t,["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","validating","visited"])}(j,V);var k=R({name:n,get value(){var e=V.value;return f?"input"===a&&(e=z(e)):e=l(e,n),null!==e||u||(e=""),"checkbox"===g||"radio"===g?h:"select"===a&&d?e||[]:e},get checked(){return"checkbox"===g?void 0===h?!!V.value:!(!Array.isArray(V.value)||!~V.value.indexOf(h)):"radio"===g?V.value===h:void 0}},C);return d&&(k.multiple=d),void 0!==g&&(k.type=g),{input:k,meta:j}}e.Field=function(e){var t=e.afterSubmit,n=e.allowNull,r=e.beforeSubmit,i=e.children,u=e.component,a=e.defaultValue,o=e.format,c=e.formatOnBlur,l=e.initialValue,f=e.isEqual,s=e.multiple,d=e.name,v=e.parse,m=e.subscription,p=e.type,b=e.validate,g=e.validateFields,y=e.value,h=V(e,["afterSubmit","allowNull","beforeSubmit","children","component","defaultValue","format","formatOnBlur","initialValue","isEqual","multiple","name","parse","subscription","type","validate","validateFields","value"]),O=S(d,{afterSubmit:t,allowNull:n,beforeSubmit:r,children:i,component:u,defaultValue:a,format:o,formatOnBlur:c,initialValue:l,isEqual:f,multiple:s,parse:v,subscription:m,type:p,validate:b,validateFields:g,value:y});return"function"==typeof i?i(R({},O,{},h)):"string"==typeof u?x.createElement(u,R({},O.input,{children:i},h)):w(R({children:i,component:u},h),O,"Field("+d+")")},e.Form=n,e.FormSpy=r,e.useField=S,e.useForm=N,e.useFormState=o,e.version=t,e.withTypes=function(){return{Form:n,FormSpy:r}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=react-final-form.umd.min.js.map |
{ | ||
"name": "react-final-form", | ||
"version": "6.3.2", | ||
"version": "6.3.3", | ||
"description": "🏁 High performance subscription-based form state management for React", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-final-form.cjs.js", |
@@ -80,3 +80,3 @@ import * as React from 'react'; | ||
defaultValue?: FieldValue; | ||
format?: (value: any, name: string) => any; | ||
format?: (value: FieldValue, name: string) => any; | ||
formatOnBlur?: boolean; | ||
@@ -86,3 +86,3 @@ initialValue?: FieldValue; | ||
multiple?: boolean; | ||
parse?: (value: FieldValue, name: string) => FieldValue; | ||
parse?: (value: any, name: string) => FieldValue; | ||
subscription?: FieldSubscription; | ||
@@ -89,0 +89,0 @@ type?: string; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package