react-final-form
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -339,13 +339,14 @@ 'use strict'; | ||
var input = _extends({ name: name, value: value }, this.handlers); | ||
warning(!_value || (rest.type === 'radio' || rest.type === 'checkbox') && component === 'input', 'The value prop on Field is ONLY for use with component="input" and type="radio" or type="checkbox".'); | ||
if (rest.type === 'checkbox') { | ||
if (_value === undefined) { | ||
input.checked = !!value; | ||
} else { | ||
input.checked = Array.isArray(value) && ~value.indexOf(_value); | ||
if (component === 'input') { | ||
if (rest.type === 'checkbox') { | ||
if (_value === undefined) { | ||
input.checked = !!value; | ||
} else { | ||
input.checked = Array.isArray(value) && ~value.indexOf(_value); | ||
input.value = _value; | ||
} | ||
} else if (rest.type === 'radio') { | ||
input.checked = value === _value; | ||
input.value = _value; | ||
} | ||
} else if (rest.type === 'radio') { | ||
input.checked = value === _value; | ||
input.value = _value; | ||
} | ||
@@ -355,2 +356,3 @@ if (component === 'select' && rest.multiple) { | ||
} | ||
if (typeof children === 'function') { | ||
@@ -357,0 +359,0 @@ return children(_extends({ input: input, meta: meta }, rest)); |
@@ -333,13 +333,14 @@ import { PureComponent, createElement } from 'react'; | ||
var input = _extends({ name: name, value: value }, this.handlers); | ||
warning(!_value || (rest.type === 'radio' || rest.type === 'checkbox') && component === 'input', 'The value prop on Field is ONLY for use with component="input" and type="radio" or type="checkbox".'); | ||
if (rest.type === 'checkbox') { | ||
if (_value === undefined) { | ||
input.checked = !!value; | ||
} else { | ||
input.checked = Array.isArray(value) && ~value.indexOf(_value); | ||
if (component === 'input') { | ||
if (rest.type === 'checkbox') { | ||
if (_value === undefined) { | ||
input.checked = !!value; | ||
} else { | ||
input.checked = Array.isArray(value) && ~value.indexOf(_value); | ||
input.value = _value; | ||
} | ||
} else if (rest.type === 'radio') { | ||
input.checked = value === _value; | ||
input.value = _value; | ||
} | ||
} else if (rest.type === 'radio') { | ||
input.checked = value === _value; | ||
input.value = _value; | ||
} | ||
@@ -349,2 +350,3 @@ if (component === 'select' && rest.multiple) { | ||
} | ||
if (typeof children === 'function') { | ||
@@ -351,0 +353,0 @@ return children(_extends({ input: input, meta: meta }, rest)); |
@@ -336,13 +336,14 @@ (function (global, factory) { | ||
var input = _extends({ name: name, value: value }, this.handlers); | ||
warning(!_value || (rest.type === 'radio' || rest.type === 'checkbox') && component === 'input', 'The value prop on Field is ONLY for use with component="input" and type="radio" or type="checkbox".'); | ||
if (rest.type === 'checkbox') { | ||
if (_value === undefined) { | ||
input.checked = !!value; | ||
} else { | ||
input.checked = Array.isArray(value) && ~value.indexOf(_value); | ||
if (component === 'input') { | ||
if (rest.type === 'checkbox') { | ||
if (_value === undefined) { | ||
input.checked = !!value; | ||
} else { | ||
input.checked = Array.isArray(value) && ~value.indexOf(_value); | ||
input.value = _value; | ||
} | ||
} else if (rest.type === 'radio') { | ||
input.checked = value === _value; | ||
input.value = _value; | ||
} | ||
} else if (rest.type === 'radio') { | ||
input.checked = value === _value; | ||
input.value = _value; | ||
} | ||
@@ -352,2 +353,3 @@ if (component === 'select' && rest.multiple) { | ||
} | ||
if (typeof children === 'function') { | ||
@@ -354,0 +356,0 @@ return children(_extends({ input: input, meta: meta }, rest)); |
@@ -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,e,n,r){"use strict";n=n&&n.hasOwnProperty("default")?n.default:n;var i=function(t,e){};function o(t,e,n){return t?!e||n.some(function(n){return t[n]!==e[n]}):!!e}var a="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},u=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},s=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),c=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},l=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)},f=function(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},p=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 m(t,n){var r=t.render,i=t.children,o=t.component,a=f(t,["render","children","component"]);return o?e.createElement(o,c({},a,{children:i,render:r})):r?r(c({},a,{children:i})):"function"!=typeof i?null:i(a)}var b="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product,h=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,u=i.checked;switch(o){case"checkbox":if(void 0!==n){if(u)return Array.isArray(e)?e.concat(n):[n];if(!Array.isArray(e))return e;var s=e.indexOf(n);return s<0?e:e.slice(0,s).concat(e.slice(s+1))}return!!u;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}},v=r.fieldSubscriptionItems.reduce(function(t,e){return t[e]=!0,t},{}),d=function(t){function n(t,e){u(this,n);var r=p(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));r.subscribe=function(t,e){var n=t.isEqual,i=t.name,o=t.subscription,a=t.validateFields;r.unsubscribe=r.context.reactFinalForm.registerField(i,e,o||v,{isEqual:n,getValidator:function(){return r.props.validate},validateFields:a})},r.notify=function(t){return r.setState({state:t})},r.handlers={onBlur:function(t){r.state.state.blur()},onChange:function(t){var e=r.props,n=e.parse,i=e.value,o=t&&t.target?h(t,r.state.state.value,i,b):t;r.state.state.change(null!==n?n(o,r.props.name):o)},onFocus:function(t){r.state.state.focus()}};var o=void 0;return i(e.reactFinalForm,"Field must be used inside of a ReactFinalForm component"),r.context.reactFinalForm&&r.subscribe(t,function(t){o?r.notify(t):o=t}),r.state={state:o||{}},r}return l(n,t),s(n,[{key:"componentWillReceiveProps",value:function(t){var e=t.name,n=t.subscription;(this.props.name!==e||o(this.props.subscription,n,r.fieldSubscriptionItems))&&this.context.reactFinalForm&&(this.unsubscribe(),this.subscribe(t,this.notify))}},{key:"componentWillUnmount",value:function(){this.unsubscribe()}},{key:"render",value:function(){var t=this.props,n=t.allowNull,r=t.component,i=t.children,o=t.format,a=(t.parse,t.isEqual,t.name),u=(t.subscription,t.validate,t.validateFields,t.value),s=f(t,["allowNull","component","children","format","parse","isEqual","name","subscription","validate","validateFields","value"]),l=this.state.state,p=(l.blur,l.change,l.focus,l.value),b=(l.name,f(l,["blur","change","focus","value","name"]));null!==o&&(p=o(p,a)),null!==p||n||(p="");var h=c({name:a,value:p},this.handlers);return"checkbox"===s.type?void 0===u?h.checked=!!p:(h.checked=Array.isArray(p)&&~p.indexOf(u),h.value=u):"radio"===s.type&&(h.checked=p===u,h.value=u),"select"===r&&s.multiple&&(h.value=h.value||[]),"function"==typeof i?i(c({input:h,meta:b},s)):"string"==typeof r?e.createElement(r,c({},h,{children:i},s)):m(c({input:h,meta:b,children:i,component:r},s))}}]),n}(e.PureComponent);d.contextTypes={reactFinalForm:n.object},d.defaultProps={format:function(t,e){return void 0===t?"":t},parse:function(t,e){return""===t?void 0:t}};var y={"final-form":r.version,"react-final-form":w},F=r.formSubscriptionItems.reduce(function(t,e){return t[e]=!0,t},{}),g=function(t){function e(t){u(this,e);var n=p(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));n.notify=function(t){return n.setState({state:t})},n.handleSubmit=function(t){return t&&t.preventDefault(),n.form.submit()};t.children,t.component;var o=t.debug,a=t.decorators,s=t.initialValues,c=t.mutators,l=t.onSubmit,f=(t.render,t.subscription),m={debug:o,initialValues:s,mutators:c,onSubmit:l,validate:t.validate,validateOnBlur:t.validateOnBlur};try{n.form=r.createForm(m)}catch(t){i(!1,t.message)}var b=void 0;return n.unsubscriptions=[],n.form&&n.unsubscriptions.push(n.form.subscribe(function(t){b?n.notify(t):b=t},f||F)),n.state={state:b},a&&a.forEach(function(t){n.unsubscriptions.push(t(n.form))}),n}return l(e,t),s(e,[{key:"getChildContext",value:function(){return{reactFinalForm:this.form}}},{key:"componentWillReceiveProps",value:function(t){(function(t,e){if(t===e)return!0;if("object"!==(void 0===t?"undefined":a(t))||!t||"object"!==(void 0===e?"undefined":a(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 u=n[o];if(!i(u)||t[u]!==e[u])return!1}return!0})(this.props.initialValues,t.initialValues)||this.form.initialize(t.initialValues)}},{key:"componentWillUnmount",value:function(){this.unsubscriptions.forEach(function(t){return t()})}},{key:"render",value:function(){var t=this.props,e=(t.debug,t.initialValues,t.mutators,t.onSubmit,t.subscription,t.validate,t.validateOnBlur,f(t,["debug","initialValues","mutators","onSubmit","subscription","validate","validateOnBlur"]));return m(c({},e,this.state.state,{mutators:this.form&&this.form.mutators,batch:this.form&&this.form.batch,blur:this.form&&this.form.blur,change:this.form&&this.form.change,focus:this.form&&this.form.focus,handleSubmit:this.handleSubmit,initialize:this.form&&this.form.initialize,reset:this.form&&this.form.reset,__versions:y}))}}]),e}(e.PureComponent);g.childContextTypes={reactFinalForm:n.object},g.displayName="ReactFinalForm("+r.version+")("+w+")";var O=function(t){function e(t,n){u(this,e);var r=p(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));r.subscribe=function(t,e){var n=t.subscription;r.unsubscribe=r.context.reactFinalForm.subscribe(e,n||F)},r.notify=function(t){r.setState({state:t}),r.props.onChange&&r.props.onChange(t)};var o=void 0;return i(n.reactFinalForm,"FormSpy must be used inside of a ReactFinalForm component"),r.context.reactFinalForm&&r.subscribe(t,function(e){o?r.notify(e):(o=e,t.onChange&&t.onChange(e))}),r.state={state:o},r}return l(e,t),s(e,[{key:"componentWillReceiveProps",value:function(t){var e=t.subscription;o(this.props.subscription,e,r.formSubscriptionItems)&&this.context.reactFinalForm&&(this.unsubscribe(),this.subscribe(t,this.notify))}},{key:"componentWillUnmount",value:function(){this.unsubscribe()}},{key:"render",value:function(){var t=this.props,e=t.onChange,n=(t.subscription,f(t,["onChange","subscription"])),r=this.context.reactFinalForm;return e?null:m(c({},n,this.state.state,{mutators:r&&r.mutators,batch:r&&r.batch,blur:r&&r.blur,change:r&&r.change,focus:r&&r.focus,initialize:r&&r.initialize,reset:r&&r.reset}))}}]),e}(e.PureComponent);O.contextTypes={reactFinalForm:n.object};var w="3.0.1";t.version=w,t.Field=d,t.Form=g,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,e,n,r){"use strict";n=n&&n.hasOwnProperty("default")?n.default:n;var i=function(t,e){};function o(t,e,n){return t?!e||n.some(function(n){return t[n]!==e[n]}):!!e}var a="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},u=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},s=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),c=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},l=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)},f=function(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},p=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 m(t,n){var r=t.render,i=t.children,o=t.component,a=f(t,["render","children","component"]);return o?e.createElement(o,c({},a,{children:i,render:r})):r?r(c({},a,{children:i})):"function"!=typeof i?null:i(a)}var b="undefined"!=typeof window&&window.navigator&&window.navigator.product&&"ReactNative"===window.navigator.product,h=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,u=i.checked;switch(o){case"checkbox":if(void 0!==n){if(u)return Array.isArray(e)?e.concat(n):[n];if(!Array.isArray(e))return e;var s=e.indexOf(n);return s<0?e:e.slice(0,s).concat(e.slice(s+1))}return!!u;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}},v=r.fieldSubscriptionItems.reduce(function(t,e){return t[e]=!0,t},{}),d=function(t){function n(t,e){u(this,n);var r=p(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));r.subscribe=function(t,e){var n=t.isEqual,i=t.name,o=t.subscription,a=t.validateFields;r.unsubscribe=r.context.reactFinalForm.registerField(i,e,o||v,{isEqual:n,getValidator:function(){return r.props.validate},validateFields:a})},r.notify=function(t){return r.setState({state:t})},r.handlers={onBlur:function(t){r.state.state.blur()},onChange:function(t){var e=r.props,n=e.parse,i=e.value,o=t&&t.target?h(t,r.state.state.value,i,b):t;r.state.state.change(null!==n?n(o,r.props.name):o)},onFocus:function(t){r.state.state.focus()}};var o=void 0;return i(e.reactFinalForm,"Field must be used inside of a ReactFinalForm component"),r.context.reactFinalForm&&r.subscribe(t,function(t){o?r.notify(t):o=t}),r.state={state:o||{}},r}return l(n,t),s(n,[{key:"componentWillReceiveProps",value:function(t){var e=t.name,n=t.subscription;(this.props.name!==e||o(this.props.subscription,n,r.fieldSubscriptionItems))&&this.context.reactFinalForm&&(this.unsubscribe(),this.subscribe(t,this.notify))}},{key:"componentWillUnmount",value:function(){this.unsubscribe()}},{key:"render",value:function(){var t=this.props,n=t.allowNull,r=t.component,i=t.children,o=t.format,a=(t.parse,t.isEqual,t.name),u=(t.subscription,t.validate,t.validateFields,t.value),s=f(t,["allowNull","component","children","format","parse","isEqual","name","subscription","validate","validateFields","value"]),l=this.state.state,p=(l.blur,l.change,l.focus,l.value),b=(l.name,f(l,["blur","change","focus","value","name"]));null!==o&&(p=o(p,a)),null!==p||n||(p="");var h=c({name:a,value:p},this.handlers);return"input"===r&&("checkbox"===s.type?void 0===u?h.checked=!!p:(h.checked=Array.isArray(p)&&~p.indexOf(u),h.value=u):"radio"===s.type&&(h.checked=p===u,h.value=u)),"select"===r&&s.multiple&&(h.value=h.value||[]),"function"==typeof i?i(c({input:h,meta:b},s)):"string"==typeof r?e.createElement(r,c({},h,{children:i},s)):m(c({input:h,meta:b,children:i,component:r},s))}}]),n}(e.PureComponent);d.contextTypes={reactFinalForm:n.object},d.defaultProps={format:function(t,e){return void 0===t?"":t},parse:function(t,e){return""===t?void 0:t}};var y={"final-form":r.version,"react-final-form":w},F=r.formSubscriptionItems.reduce(function(t,e){return t[e]=!0,t},{}),g=function(t){function e(t){u(this,e);var n=p(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));n.notify=function(t){return n.setState({state:t})},n.handleSubmit=function(t){return t&&t.preventDefault(),n.form.submit()};t.children,t.component;var o=t.debug,a=t.decorators,s=t.initialValues,c=t.mutators,l=t.onSubmit,f=(t.render,t.subscription),m={debug:o,initialValues:s,mutators:c,onSubmit:l,validate:t.validate,validateOnBlur:t.validateOnBlur};try{n.form=r.createForm(m)}catch(t){i(!1,t.message)}var b=void 0;return n.unsubscriptions=[],n.form&&n.unsubscriptions.push(n.form.subscribe(function(t){b?n.notify(t):b=t},f||F)),n.state={state:b},a&&a.forEach(function(t){n.unsubscriptions.push(t(n.form))}),n}return l(e,t),s(e,[{key:"getChildContext",value:function(){return{reactFinalForm:this.form}}},{key:"componentWillReceiveProps",value:function(t){(function(t,e){if(t===e)return!0;if("object"!==(void 0===t?"undefined":a(t))||!t||"object"!==(void 0===e?"undefined":a(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 u=n[o];if(!i(u)||t[u]!==e[u])return!1}return!0})(this.props.initialValues,t.initialValues)||this.form.initialize(t.initialValues)}},{key:"componentWillUnmount",value:function(){this.unsubscriptions.forEach(function(t){return t()})}},{key:"render",value:function(){var t=this.props,e=(t.debug,t.initialValues,t.mutators,t.onSubmit,t.subscription,t.validate,t.validateOnBlur,f(t,["debug","initialValues","mutators","onSubmit","subscription","validate","validateOnBlur"]));return m(c({},e,this.state.state,{mutators:this.form&&this.form.mutators,batch:this.form&&this.form.batch,blur:this.form&&this.form.blur,change:this.form&&this.form.change,focus:this.form&&this.form.focus,handleSubmit:this.handleSubmit,initialize:this.form&&this.form.initialize,reset:this.form&&this.form.reset,__versions:y}))}}]),e}(e.PureComponent);g.childContextTypes={reactFinalForm:n.object},g.displayName="ReactFinalForm("+r.version+")("+w+")";var O=function(t){function e(t,n){u(this,e);var r=p(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));r.subscribe=function(t,e){var n=t.subscription;r.unsubscribe=r.context.reactFinalForm.subscribe(e,n||F)},r.notify=function(t){r.setState({state:t}),r.props.onChange&&r.props.onChange(t)};var o=void 0;return i(n.reactFinalForm,"FormSpy must be used inside of a ReactFinalForm component"),r.context.reactFinalForm&&r.subscribe(t,function(e){o?r.notify(e):(o=e,t.onChange&&t.onChange(e))}),r.state={state:o},r}return l(e,t),s(e,[{key:"componentWillReceiveProps",value:function(t){var e=t.subscription;o(this.props.subscription,e,r.formSubscriptionItems)&&this.context.reactFinalForm&&(this.unsubscribe(),this.subscribe(t,this.notify))}},{key:"componentWillUnmount",value:function(){this.unsubscribe()}},{key:"render",value:function(){var t=this.props,e=t.onChange,n=(t.subscription,f(t,["onChange","subscription"])),r=this.context.reactFinalForm;return e?null:m(c({},n,this.state.state,{mutators:r&&r.mutators,batch:r&&r.batch,blur:r&&r.blur,change:r&&r.change,focus:r&&r.focus,initialize:r&&r.initialize,reset:r&&r.reset}))}}]),e}(e.PureComponent);O.contextTypes={reactFinalForm:n.object};var w="3.0.1";t.version=w,t.Field=d,t.Form=g,t.FormSpy=O,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=react-final-form.umd.min.js.map |
{ | ||
"name": "react-final-form", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": | ||
@@ -5,0 +5,0 @@ "🏁 High performance subscription-based form state management for React", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
1715
105292