redux-freeform 5.8.2-beta.0 → 5.8.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/redux-freeform.cjs.js +57 -1156
- package/dist/redux-freeform.esm.js +57 -1157
- package/dist/redux-freeform.umd.js +57 -1156
- package/package.json +1 -1
|
@@ -9,37 +9,53 @@ const validatorToPredicate =
|
|
|
9
9
|
|
|
10
10
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
11
11
|
|
|
12
|
+
function getDefaultExportFromCjs (x) {
|
|
13
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
var dayjs_min = {exports: {}};
|
|
13
17
|
|
|
18
|
+
dayjs_min.exports;
|
|
19
|
+
|
|
14
20
|
(function (module, exports) {
|
|
15
|
-
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date"
|
|
16
|
-
}(dayjs_min));
|
|
21
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p=function(t){return t instanceof _},S=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),l=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(h){case c:return r?l(1,0):l(31,11);case f:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,l=this;r=Number(r);var $=O.p(h),y=function(t){var e=w(l);return O.w(e.date(e.date()+Math.round(t*r)),l)};if($===f)return this.set(f,this.$M+r);if($===c)return this.set(c,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},$={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||$[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,v=this-M,g=O.m(this,M);return g=($={},$[c]=g/12,$[f]=g,$[h]=g/3,$[o]=(v-m)/6048e5,$[a]=(v-m)/864e5,$[u]=v/n,$[s]=v/e,$[i]=v/t,$)[y]||v,l?g:O.a(g)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[g],w.Ls=D,w.p={},w}));
|
|
22
|
+
} (dayjs_min, dayjs_min.exports));
|
|
17
23
|
|
|
18
|
-
var
|
|
24
|
+
var dayjs_minExports = dayjs_min.exports;
|
|
25
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
19
26
|
|
|
20
27
|
var customParseFormat$1 = {exports: {}};
|
|
21
28
|
|
|
29
|
+
customParseFormat$1.exports;
|
|
30
|
+
|
|
22
31
|
(function (module, exports) {
|
|
23
|
-
!function(t
|
|
24
|
-
}(customParseFormat$1));
|
|
32
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
|
|
33
|
+
} (customParseFormat$1, customParseFormat$1.exports));
|
|
25
34
|
|
|
26
|
-
var
|
|
35
|
+
var customParseFormatExports = customParseFormat$1.exports;
|
|
36
|
+
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
27
37
|
|
|
28
38
|
var isSameOrBefore$1 = {exports: {}};
|
|
29
39
|
|
|
40
|
+
isSameOrBefore$1.exports;
|
|
41
|
+
|
|
30
42
|
(function (module, exports) {
|
|
31
|
-
!function(e,i){module.exports=i();}(commonjsGlobal,(function(){return function(e,i){i.prototype.isSameOrBefore=function(e,i){return this.isSame(e,i)||this.isBefore(e,i)};}}));
|
|
32
|
-
}(isSameOrBefore$1));
|
|
43
|
+
!function(e,i){module.exports=i();}(commonjsGlobal,(function(){return function(e,i){i.prototype.isSameOrBefore=function(e,i){return this.isSame(e,i)||this.isBefore(e,i)};}}));
|
|
44
|
+
} (isSameOrBefore$1, isSameOrBefore$1.exports));
|
|
33
45
|
|
|
34
|
-
var
|
|
46
|
+
var isSameOrBeforeExports = isSameOrBefore$1.exports;
|
|
47
|
+
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);
|
|
35
48
|
|
|
36
49
|
var isSameOrAfter$1 = {exports: {}};
|
|
37
50
|
|
|
51
|
+
isSameOrAfter$1.exports;
|
|
52
|
+
|
|
38
53
|
(function (module, exports) {
|
|
39
|
-
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e,t){t.prototype.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)};}}));
|
|
40
|
-
}(isSameOrAfter$1));
|
|
54
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e,t){t.prototype.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)};}}));
|
|
55
|
+
} (isSameOrAfter$1, isSameOrAfter$1.exports));
|
|
41
56
|
|
|
42
|
-
var
|
|
57
|
+
var isSameOrAfterExports = isSameOrAfter$1.exports;
|
|
58
|
+
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);
|
|
43
59
|
|
|
44
60
|
/* eslint-disable no-unused-vars */
|
|
45
61
|
|
|
@@ -55,12 +71,28 @@ dayjs.extend(isSameOrAfter);
|
|
|
55
71
|
|
|
56
72
|
let validatorFns = {};
|
|
57
73
|
|
|
74
|
+
const IS_CURRENCY = 'validator/IS_CURRENCY';
|
|
75
|
+
const IS_CURRENCY_ERROR = 'error/IS_CURRENCY';
|
|
76
|
+
const isCurrency = createValidator(IS_CURRENCY, IS_CURRENCY_ERROR);
|
|
77
|
+
validatorFns[IS_CURRENCY] = (value, args, form) => {
|
|
78
|
+
const parts = value.split('.');
|
|
79
|
+
if (parts.length > 2) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const decimalPart = parts[1];
|
|
83
|
+
// If there's a decimal part, ensure it's 1 or 2 digits
|
|
84
|
+
if (decimalPart) {
|
|
85
|
+
if (decimalPart.length > 2 || isNaN(decimalPart)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
58
91
|
const IS_PERCENTAGE = 'validator/IS_PERCENTAGE';
|
|
59
92
|
const IS_PERCENTAGE_ERROR = 'error/IS_PERCENTAGE';
|
|
60
93
|
const isPercentage = createValidator(IS_PERCENTAGE, IS_PERCENTAGE_ERROR);
|
|
61
94
|
validatorFns[IS_PERCENTAGE] = (value, args, form) => {
|
|
62
|
-
const parts =
|
|
63
|
-
// Ensure there are 1 or 2 parts (integer and optional decimal)
|
|
95
|
+
const parts = value.split('.');
|
|
64
96
|
if (parts.length > 2) {
|
|
65
97
|
return false;
|
|
66
98
|
}
|
|
@@ -183,7 +215,7 @@ validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
|
183
215
|
return value === dependentFieldValue;
|
|
184
216
|
};
|
|
185
217
|
|
|
186
|
-
const validateWhenErrorMessage = type =>
|
|
218
|
+
const validateWhenErrorMessage = (type) =>
|
|
187
219
|
`${type} was passed to validateWhen, but that validator type does not exist.
|
|
188
220
|
Please check that you are only calling validator creator functions exported from
|
|
189
221
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -196,7 +228,7 @@ const VALIDATE_WHEN_ERROR = 'error/VALIDATE_WHEN';
|
|
|
196
228
|
const validateWhen = (dependentValidator, primaryValidator, optionalFieldName) => ({
|
|
197
229
|
type: VALIDATE_WHEN,
|
|
198
230
|
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
199
|
-
error: dependentValidator.error
|
|
231
|
+
error: dependentValidator.error,
|
|
200
232
|
});
|
|
201
233
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
202
234
|
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
@@ -233,7 +265,7 @@ validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
|
233
265
|
: true;
|
|
234
266
|
};
|
|
235
267
|
|
|
236
|
-
const validateSumErrorMessage = type =>
|
|
268
|
+
const validateSumErrorMessage = (type) =>
|
|
237
269
|
`${type} was passed to validateSum, but that validator type does not exist.
|
|
238
270
|
Please check that you are only calling validator creator functions exported from
|
|
239
271
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -244,7 +276,7 @@ const VALIDATE_SUM_ERROR = 'error/VALIDATE_SUM';
|
|
|
244
276
|
const validateSum = (validator, fieldNamesArray) => ({
|
|
245
277
|
type: VALIDATE_SUM,
|
|
246
278
|
args: [validator, fieldNamesArray],
|
|
247
|
-
error: validator.error
|
|
279
|
+
error: validator.error,
|
|
248
280
|
});
|
|
249
281
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
250
282
|
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
@@ -400,7 +432,7 @@ validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
|
400
432
|
}
|
|
401
433
|
const sum = value
|
|
402
434
|
.split('')
|
|
403
|
-
.map(ch => parseInt(ch))
|
|
435
|
+
.map((ch) => parseInt(ch))
|
|
404
436
|
.reduce((acc, cur, idx) => {
|
|
405
437
|
switch (idx % 3) {
|
|
406
438
|
case 0:
|
|
@@ -476,7 +508,7 @@ validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
|
476
508
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
477
509
|
};
|
|
478
510
|
|
|
479
|
-
const runValidatorErrorMessage = type =>
|
|
511
|
+
const runValidatorErrorMessage = (type) =>
|
|
480
512
|
`${type} was passed to runValidator, but that validator type does not exist.
|
|
481
513
|
Please check that you are only calling validator creator functions exported from
|
|
482
514
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -493,8 +525,8 @@ const runValidator = (validator, value, form) => {
|
|
|
493
525
|
|
|
494
526
|
const runFormValidators = (fieldName, form, validators) => {
|
|
495
527
|
return validators
|
|
496
|
-
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
497
|
-
.filter(x => x !== null);
|
|
528
|
+
.map((v) => runValidator(v, form[fieldName].rawValue, form))
|
|
529
|
+
.filter((x) => x !== null);
|
|
498
530
|
};
|
|
499
531
|
|
|
500
532
|
const computeConstraints = (fieldName, form) => {
|
|
@@ -507,7 +539,7 @@ const computeErrors = (fieldName, form) => {
|
|
|
507
539
|
return runFormValidators(fieldName, form, validators);
|
|
508
540
|
};
|
|
509
541
|
|
|
510
|
-
const computeErrorEntries = formState => {
|
|
542
|
+
const computeErrorEntries = (formState) => {
|
|
511
543
|
const fields = Object.entries(formState);
|
|
512
544
|
for (let entry of fields) {
|
|
513
545
|
let fieldName = entry[0];
|
|
@@ -527,1139 +559,7 @@ const computeDirtyEntries = (formState, changedFieldName) => {
|
|
|
527
559
|
}
|
|
528
560
|
};
|
|
529
561
|
|
|
530
|
-
var obj;
|
|
531
|
-
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : ( obj = {}, obj["immer-nothing"] = true, obj );
|
|
532
|
-
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
533
|
-
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-state") : "__$immer_state";
|
|
534
|
-
function isDraft(value) {
|
|
535
|
-
return !!value && !!value[DRAFT_STATE];
|
|
536
|
-
}
|
|
537
|
-
function isDraftable(value) {
|
|
538
|
-
if (!value) { return false; }
|
|
539
|
-
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
540
|
-
}
|
|
541
|
-
function isPlainObject(value) {
|
|
542
|
-
if (!value || typeof value !== "object") { return false; }
|
|
543
|
-
if (Array.isArray(value)) { return true; }
|
|
544
|
-
var proto = Object.getPrototypeOf(value);
|
|
545
|
-
return !proto || proto === Object.prototype;
|
|
546
|
-
}
|
|
547
|
-
var assign = Object.assign || function assign(target, value) {
|
|
548
|
-
for (var key in value) {
|
|
549
|
-
if (has(value, key)) {
|
|
550
|
-
target[key] = value[key];
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
return target;
|
|
555
|
-
};
|
|
556
|
-
var ownKeys = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKeys : typeof Object.getOwnPropertySymbols !== "undefined" ? function (obj) { return Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj)); } : Object.getOwnPropertyNames;
|
|
557
|
-
function shallowCopy(base, invokeGetters) {
|
|
558
|
-
if ( invokeGetters === void 0 ) invokeGetters = false;
|
|
559
|
-
|
|
560
|
-
if (Array.isArray(base)) { return base.slice(); }
|
|
561
|
-
var clone = Object.create(Object.getPrototypeOf(base));
|
|
562
|
-
ownKeys(base).forEach(function (key) {
|
|
563
|
-
if (key === DRAFT_STATE) {
|
|
564
|
-
return; // Never copy over draft state.
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
var desc = Object.getOwnPropertyDescriptor(base, key);
|
|
568
|
-
var value = desc.value;
|
|
569
|
-
|
|
570
|
-
if (desc.get) {
|
|
571
|
-
if (!invokeGetters) {
|
|
572
|
-
throw new Error("Immer drafts cannot have computed properties");
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
value = desc.get.call(base);
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
if (desc.enumerable) {
|
|
579
|
-
clone[key] = value;
|
|
580
|
-
} else {
|
|
581
|
-
Object.defineProperty(clone, key, {
|
|
582
|
-
value: value,
|
|
583
|
-
writable: true,
|
|
584
|
-
configurable: true
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
return clone;
|
|
589
|
-
}
|
|
590
|
-
function each(value, cb) {
|
|
591
|
-
if (Array.isArray(value)) {
|
|
592
|
-
for (var i = 0; i < value.length; i++) { cb(i, value[i], value); }
|
|
593
|
-
} else {
|
|
594
|
-
ownKeys(value).forEach(function (key) { return cb(key, value[key], value); });
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
function isEnumerable(base, prop) {
|
|
598
|
-
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
599
|
-
return !!desc && desc.enumerable;
|
|
600
|
-
}
|
|
601
|
-
function has(thing, prop) {
|
|
602
|
-
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
603
|
-
}
|
|
604
|
-
function is(x, y) {
|
|
605
|
-
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
606
|
-
if (x === y) {
|
|
607
|
-
return x !== 0 || 1 / x === 1 / y;
|
|
608
|
-
} else {
|
|
609
|
-
return x !== x && y !== y;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
function clone(obj) {
|
|
613
|
-
if (!isDraftable(obj)) { return obj; }
|
|
614
|
-
if (Array.isArray(obj)) { return obj.map(clone); }
|
|
615
|
-
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
616
|
-
|
|
617
|
-
for (var key in obj) { cloned[key] = clone(obj[key]); }
|
|
618
|
-
|
|
619
|
-
return cloned;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
/** Each scope represents a `produce` call. */
|
|
623
|
-
|
|
624
|
-
var ImmerScope = function ImmerScope(parent) {
|
|
625
|
-
this.drafts = [];
|
|
626
|
-
this.parent = parent; // Whenever the modified draft contains a draft from another scope, we
|
|
627
|
-
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
628
|
-
|
|
629
|
-
this.canAutoFreeze = true; // To avoid prototype lookups:
|
|
630
|
-
|
|
631
|
-
this.patches = null;
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
635
|
-
if (patchListener) {
|
|
636
|
-
this.patches = [];
|
|
637
|
-
this.inversePatches = [];
|
|
638
|
-
this.patchListener = patchListener;
|
|
639
|
-
}
|
|
640
|
-
};
|
|
641
|
-
|
|
642
|
-
ImmerScope.prototype.revoke = function revoke$1 () {
|
|
643
|
-
this.leave();
|
|
644
|
-
this.drafts.forEach(revoke);
|
|
645
|
-
this.drafts = null; // Make draft-related methods throw.
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
ImmerScope.prototype.leave = function leave () {
|
|
649
|
-
if (this === ImmerScope.current) {
|
|
650
|
-
ImmerScope.current = this.parent;
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
ImmerScope.current = null;
|
|
654
|
-
|
|
655
|
-
ImmerScope.enter = function () {
|
|
656
|
-
return this.current = new ImmerScope(this.current);
|
|
657
|
-
};
|
|
658
|
-
|
|
659
|
-
function revoke(draft) {
|
|
660
|
-
draft[DRAFT_STATE].revoke();
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
// but share them all instead
|
|
664
|
-
|
|
665
|
-
var descriptors = {};
|
|
666
|
-
function willFinalize(scope, result, isReplaced) {
|
|
667
|
-
scope.drafts.forEach(function (draft) {
|
|
668
|
-
draft[DRAFT_STATE].finalizing = true;
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
if (!isReplaced) {
|
|
672
|
-
if (scope.patches) {
|
|
673
|
-
markChangesRecursively(scope.drafts[0]);
|
|
674
|
-
} // This is faster when we don't care about which attributes changed.
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
markChangesSweep(scope.drafts);
|
|
678
|
-
} // When a child draft is returned, look for changes.
|
|
679
|
-
else if (isDraft(result) && result[DRAFT_STATE].scope === scope) {
|
|
680
|
-
markChangesSweep(scope.drafts);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
function createProxy(base, parent) {
|
|
684
|
-
var isArray = Array.isArray(base);
|
|
685
|
-
var draft = clonePotentialDraft(base);
|
|
686
|
-
each(draft, function (prop) {
|
|
687
|
-
proxyProperty(draft, prop, isArray || isEnumerable(base, prop));
|
|
688
|
-
}); // See "proxy.js" for property documentation.
|
|
689
|
-
|
|
690
|
-
var scope = parent ? parent.scope : ImmerScope.current;
|
|
691
|
-
var state = {
|
|
692
|
-
scope: scope,
|
|
693
|
-
modified: false,
|
|
694
|
-
finalizing: false,
|
|
695
|
-
// es5 only
|
|
696
|
-
finalized: false,
|
|
697
|
-
assigned: {},
|
|
698
|
-
parent: parent,
|
|
699
|
-
base: base,
|
|
700
|
-
draft: draft,
|
|
701
|
-
copy: null,
|
|
702
|
-
revoke: revoke$1,
|
|
703
|
-
revoked: false // es5 only
|
|
704
|
-
|
|
705
|
-
};
|
|
706
|
-
createHiddenProperty(draft, DRAFT_STATE, state);
|
|
707
|
-
scope.drafts.push(draft);
|
|
708
|
-
return draft;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
function revoke$1() {
|
|
712
|
-
this.revoked = true;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
function source(state) {
|
|
716
|
-
return state.copy || state.base;
|
|
717
|
-
} // Access a property without creating an Immer draft.
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
function peek(draft, prop) {
|
|
721
|
-
var state = draft[DRAFT_STATE];
|
|
722
|
-
|
|
723
|
-
if (state && !state.finalizing) {
|
|
724
|
-
state.finalizing = true;
|
|
725
|
-
var value = draft[prop];
|
|
726
|
-
state.finalizing = false;
|
|
727
|
-
return value;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
return draft[prop];
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
function get(state, prop) {
|
|
734
|
-
assertUnrevoked(state);
|
|
735
|
-
var value = peek(source(state), prop);
|
|
736
|
-
if (state.finalizing) { return value; } // Create a draft if the value is unmodified.
|
|
737
|
-
|
|
738
|
-
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
739
|
-
prepareCopy(state);
|
|
740
|
-
return state.copy[prop] = createProxy(value, state);
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
return value;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
function set$1(state, prop, value) {
|
|
747
|
-
assertUnrevoked(state);
|
|
748
|
-
state.assigned[prop] = true;
|
|
749
|
-
|
|
750
|
-
if (!state.modified) {
|
|
751
|
-
if (is(value, peek(source(state), prop))) { return; }
|
|
752
|
-
markChanged(state);
|
|
753
|
-
prepareCopy(state);
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
state.copy[prop] = value;
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
function markChanged(state) {
|
|
760
|
-
if (!state.modified) {
|
|
761
|
-
state.modified = true;
|
|
762
|
-
if (state.parent) { markChanged(state.parent); }
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
function prepareCopy(state) {
|
|
767
|
-
if (!state.copy) { state.copy = clonePotentialDraft(state.base); }
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
function clonePotentialDraft(base) {
|
|
771
|
-
var state = base && base[DRAFT_STATE];
|
|
772
|
-
|
|
773
|
-
if (state) {
|
|
774
|
-
state.finalizing = true;
|
|
775
|
-
var draft = shallowCopy(state.draft, true);
|
|
776
|
-
state.finalizing = false;
|
|
777
|
-
return draft;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
return shallowCopy(base);
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
function proxyProperty(draft, prop, enumerable) {
|
|
784
|
-
var desc = descriptors[prop];
|
|
785
|
-
|
|
786
|
-
if (desc) {
|
|
787
|
-
desc.enumerable = enumerable;
|
|
788
|
-
} else {
|
|
789
|
-
descriptors[prop] = desc = {
|
|
790
|
-
configurable: true,
|
|
791
|
-
enumerable: enumerable,
|
|
792
|
-
|
|
793
|
-
get: function get$1() {
|
|
794
|
-
return get(this[DRAFT_STATE], prop);
|
|
795
|
-
},
|
|
796
|
-
|
|
797
|
-
set: function set$1$1(value) {
|
|
798
|
-
set$1(this[DRAFT_STATE], prop, value);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
Object.defineProperty(draft, prop, desc);
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
function assertUnrevoked(state) {
|
|
808
|
-
if (state.revoked === true) { throw new Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + JSON.stringify(source(state))); }
|
|
809
|
-
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
function markChangesSweep(drafts) {
|
|
813
|
-
// The natural order of drafts in the `scope` array is based on when they
|
|
814
|
-
// were accessed. By processing drafts in reverse natural order, we have a
|
|
815
|
-
// better chance of processing leaf nodes first. When a leaf node is known to
|
|
816
|
-
// have changed, we can avoid any traversal of its ancestor nodes.
|
|
817
|
-
for (var i = drafts.length - 1; i >= 0; i--) {
|
|
818
|
-
var state = drafts[i][DRAFT_STATE];
|
|
819
|
-
|
|
820
|
-
if (!state.modified) {
|
|
821
|
-
if (Array.isArray(state.base)) {
|
|
822
|
-
if (hasArrayChanges(state)) { markChanged(state); }
|
|
823
|
-
} else if (hasObjectChanges(state)) { markChanged(state); }
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
function markChangesRecursively(object) {
|
|
829
|
-
if (!object || typeof object !== "object") { return; }
|
|
830
|
-
var state = object[DRAFT_STATE];
|
|
831
|
-
if (!state) { return; }
|
|
832
|
-
var base = state.base;
|
|
833
|
-
var draft = state.draft;
|
|
834
|
-
var assigned = state.assigned;
|
|
835
|
-
|
|
836
|
-
if (!Array.isArray(object)) {
|
|
837
|
-
// Look for added keys.
|
|
838
|
-
Object.keys(draft).forEach(function (key) {
|
|
839
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
840
|
-
if (base[key] === undefined && !has(base, key)) {
|
|
841
|
-
assigned[key] = true;
|
|
842
|
-
markChanged(state);
|
|
843
|
-
} else if (!assigned[key]) {
|
|
844
|
-
// Only untouched properties trigger recursion.
|
|
845
|
-
markChangesRecursively(draft[key]);
|
|
846
|
-
}
|
|
847
|
-
}); // Look for removed keys.
|
|
848
|
-
|
|
849
|
-
Object.keys(base).forEach(function (key) {
|
|
850
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
851
|
-
if (draft[key] === undefined && !has(draft, key)) {
|
|
852
|
-
assigned[key] = false;
|
|
853
|
-
markChanged(state);
|
|
854
|
-
}
|
|
855
|
-
});
|
|
856
|
-
} else if (hasArrayChanges(state)) {
|
|
857
|
-
markChanged(state);
|
|
858
|
-
assigned.length = true;
|
|
859
|
-
|
|
860
|
-
if (draft.length < base.length) {
|
|
861
|
-
for (var i = draft.length; i < base.length; i++) { assigned[i] = false; }
|
|
862
|
-
} else {
|
|
863
|
-
for (var i$1 = base.length; i$1 < draft.length; i$1++) { assigned[i$1] = true; }
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
for (var i$2 = 0; i$2 < draft.length; i$2++) {
|
|
867
|
-
// Only untouched indices trigger recursion.
|
|
868
|
-
if (assigned[i$2] === undefined) { markChangesRecursively(draft[i$2]); }
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
function hasObjectChanges(state) {
|
|
874
|
-
var base = state.base;
|
|
875
|
-
var draft = state.draft; // Search for added keys and changed keys. Start at the back, because
|
|
876
|
-
// non-numeric keys are ordered by time of definition on the object.
|
|
877
|
-
|
|
878
|
-
var keys = Object.keys(draft);
|
|
879
|
-
|
|
880
|
-
for (var i = keys.length - 1; i >= 0; i--) {
|
|
881
|
-
var key = keys[i];
|
|
882
|
-
var baseValue = base[key]; // The `undefined` check is a fast path for pre-existing keys.
|
|
883
|
-
|
|
884
|
-
if (baseValue === undefined && !has(base, key)) {
|
|
885
|
-
return true;
|
|
886
|
-
} // Once a base key is deleted, future changes go undetected, because its
|
|
887
|
-
// descriptor is erased. This branch detects any missed changes.
|
|
888
|
-
else {
|
|
889
|
-
var value = draft[key];
|
|
890
|
-
var state$1 = value && value[DRAFT_STATE];
|
|
891
|
-
|
|
892
|
-
if (state$1 ? state$1.base !== baseValue : !is(value, baseValue)) {
|
|
893
|
-
return true;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
} // At this point, no keys were added or changed.
|
|
897
|
-
// Compare key count to determine if keys were deleted.
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
return keys.length !== Object.keys(base).length;
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
function hasArrayChanges(state) {
|
|
904
|
-
var draft = state.draft;
|
|
905
|
-
if (draft.length !== state.base.length) { return true; } // See #116
|
|
906
|
-
// If we first shorten the length, our array interceptors will be removed.
|
|
907
|
-
// If after that new items are added, result in the same original length,
|
|
908
|
-
// those last items will have no intercepting property.
|
|
909
|
-
// So if there is no own descriptor on the last position, we know that items were removed and added
|
|
910
|
-
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
911
|
-
// the last one
|
|
912
|
-
|
|
913
|
-
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
914
|
-
|
|
915
|
-
if (descriptor && !descriptor.get) { return true; } // For all other cases, we don't have to compare, as they would have been picked up by the index setters
|
|
916
|
-
|
|
917
|
-
return false;
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
function createHiddenProperty(target, prop, value) {
|
|
921
|
-
Object.defineProperty(target, prop, {
|
|
922
|
-
value: value,
|
|
923
|
-
enumerable: false,
|
|
924
|
-
writable: true
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
929
|
-
willFinalize: willFinalize,
|
|
930
|
-
createProxy: createProxy
|
|
931
|
-
});
|
|
932
|
-
|
|
933
|
-
function willFinalize$1() {}
|
|
934
|
-
function createProxy$1(base, parent) {
|
|
935
|
-
var scope = parent ? parent.scope : ImmerScope.current;
|
|
936
|
-
var state = {
|
|
937
|
-
// Track which produce call this is associated with.
|
|
938
|
-
scope: scope,
|
|
939
|
-
// True for both shallow and deep changes.
|
|
940
|
-
modified: false,
|
|
941
|
-
// Used during finalization.
|
|
942
|
-
finalized: false,
|
|
943
|
-
// Track which properties have been assigned (true) or deleted (false).
|
|
944
|
-
assigned: {},
|
|
945
|
-
// The parent draft state.
|
|
946
|
-
parent: parent,
|
|
947
|
-
// The base state.
|
|
948
|
-
base: base,
|
|
949
|
-
// The base proxy.
|
|
950
|
-
draft: null,
|
|
951
|
-
// Any property proxies.
|
|
952
|
-
drafts: {},
|
|
953
|
-
// The base copy with any updated values.
|
|
954
|
-
copy: null,
|
|
955
|
-
// Called by the `produce` function.
|
|
956
|
-
revoke: null
|
|
957
|
-
};
|
|
958
|
-
var ref = Array.isArray(base) ? // [state] is used for arrays, to make sure the proxy is array-ish and not violate invariants,
|
|
959
|
-
// although state itself is an object
|
|
960
|
-
Proxy.revocable([state], arrayTraps) : Proxy.revocable(state, objectTraps);
|
|
961
|
-
var revoke = ref.revoke;
|
|
962
|
-
var proxy = ref.proxy;
|
|
963
|
-
state.draft = proxy;
|
|
964
|
-
state.revoke = revoke;
|
|
965
|
-
scope.drafts.push(proxy);
|
|
966
|
-
return proxy;
|
|
967
|
-
}
|
|
968
|
-
var objectTraps = {
|
|
969
|
-
get: get$1,
|
|
970
|
-
|
|
971
|
-
has: function has(target, prop) {
|
|
972
|
-
return prop in source$1(target);
|
|
973
|
-
},
|
|
974
|
-
|
|
975
|
-
ownKeys: function ownKeys(target) {
|
|
976
|
-
return Reflect.ownKeys(source$1(target));
|
|
977
|
-
},
|
|
978
|
-
|
|
979
|
-
set: set$1$1,
|
|
980
|
-
deleteProperty: deleteProperty,
|
|
981
|
-
getOwnPropertyDescriptor: getOwnPropertyDescriptor,
|
|
982
|
-
|
|
983
|
-
defineProperty: function defineProperty() {
|
|
984
|
-
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
985
|
-
},
|
|
986
|
-
|
|
987
|
-
getPrototypeOf: function getPrototypeOf(target) {
|
|
988
|
-
return Object.getPrototypeOf(target.base);
|
|
989
|
-
},
|
|
990
|
-
|
|
991
|
-
setPrototypeOf: function setPrototypeOf() {
|
|
992
|
-
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
};
|
|
996
|
-
var arrayTraps = {};
|
|
997
|
-
each(objectTraps, function (key, fn) {
|
|
998
|
-
arrayTraps[key] = function () {
|
|
999
|
-
arguments[0] = arguments[0][0];
|
|
1000
|
-
return fn.apply(this, arguments);
|
|
1001
|
-
};
|
|
1002
|
-
});
|
|
1003
|
-
|
|
1004
|
-
arrayTraps.deleteProperty = function (state, prop) {
|
|
1005
|
-
if (isNaN(parseInt(prop))) {
|
|
1006
|
-
throw new Error("Immer only supports deleting array indices"); // prettier-ignore
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
return objectTraps.deleteProperty.call(this, state[0], prop);
|
|
1010
|
-
};
|
|
1011
|
-
|
|
1012
|
-
arrayTraps.set = function (state, prop, value) {
|
|
1013
|
-
if (prop !== "length" && isNaN(parseInt(prop))) {
|
|
1014
|
-
throw new Error("Immer only supports setting array indices and the 'length' property"); // prettier-ignore
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
return objectTraps.set.call(this, state[0], prop, value);
|
|
1018
|
-
}; // returns the object we should be reading the current value from, which is base, until some change has been made
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
function source$1(state) {
|
|
1022
|
-
return state.copy || state.base;
|
|
1023
|
-
} // Access a property without creating an Immer draft.
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
function peek$1(draft, prop) {
|
|
1027
|
-
var state = draft[DRAFT_STATE];
|
|
1028
|
-
var desc = Reflect.getOwnPropertyDescriptor(state ? source$1(state) : draft, prop);
|
|
1029
|
-
return desc && desc.value;
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
function get$1(state, prop) {
|
|
1033
|
-
if (prop === DRAFT_STATE) { return state; }
|
|
1034
|
-
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
1035
|
-
|
|
1036
|
-
if (!state.modified && has(drafts, prop)) {
|
|
1037
|
-
return drafts[prop];
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
var value = source$1(state)[prop];
|
|
1041
|
-
|
|
1042
|
-
if (state.finalized || !isDraftable(value)) {
|
|
1043
|
-
return value;
|
|
1044
|
-
} // Check for existing draft in modified state.
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
if (state.modified) {
|
|
1048
|
-
// Assigned values are never drafted. This catches any drafts we created, too.
|
|
1049
|
-
if (value !== peek$1(state.base, prop)) { return value; } // Store drafts on the copy (when one exists).
|
|
1050
|
-
|
|
1051
|
-
drafts = state.copy;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
return drafts[prop] = createProxy$1(value, state);
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
function set$1$1(state, prop, value) {
|
|
1058
|
-
if (!state.modified) {
|
|
1059
|
-
var baseValue = peek$1(state.base, prop); // Optimize based on value's truthiness. Truthy values are guaranteed to
|
|
1060
|
-
// never be undefined, so we can avoid the `in` operator. Lastly, truthy
|
|
1061
|
-
// values may be drafts, but falsy values are never drafts.
|
|
1062
|
-
|
|
1063
|
-
var isUnchanged = value ? is(baseValue, value) || value === state.drafts[prop] : is(baseValue, value) && prop in state.base;
|
|
1064
|
-
if (isUnchanged) { return true; }
|
|
1065
|
-
markChanged$1(state);
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
state.assigned[prop] = true;
|
|
1069
|
-
state.copy[prop] = value;
|
|
1070
|
-
return true;
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
function deleteProperty(state, prop) {
|
|
1074
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
1075
|
-
if (peek$1(state.base, prop) !== undefined || prop in state.base) {
|
|
1076
|
-
state.assigned[prop] = false;
|
|
1077
|
-
markChanged$1(state);
|
|
1078
|
-
} else if (state.assigned[prop]) {
|
|
1079
|
-
// if an originally not assigned property was deleted
|
|
1080
|
-
delete state.assigned[prop];
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
if (state.copy) { delete state.copy[prop]; }
|
|
1084
|
-
return true;
|
|
1085
|
-
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
1086
|
-
// the same guarantee in ES5 mode.
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
function getOwnPropertyDescriptor(state, prop) {
|
|
1090
|
-
var owner = source$1(state);
|
|
1091
|
-
var desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
1092
|
-
|
|
1093
|
-
if (desc) {
|
|
1094
|
-
desc.writable = true;
|
|
1095
|
-
desc.configurable = !Array.isArray(owner) || prop !== "length";
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
return desc;
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
function markChanged$1(state) {
|
|
1102
|
-
if (!state.modified) {
|
|
1103
|
-
state.modified = true;
|
|
1104
|
-
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
1105
|
-
state.drafts = null;
|
|
1106
|
-
if (state.parent) { markChanged$1(state.parent); }
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
1111
|
-
willFinalize: willFinalize$1,
|
|
1112
|
-
createProxy: createProxy$1
|
|
1113
|
-
});
|
|
1114
|
-
|
|
1115
|
-
function generatePatches(state, basePath, patches, inversePatches) {
|
|
1116
|
-
Array.isArray(state.base) ? generateArrayPatches(state, basePath, patches, inversePatches) : generateObjectPatches(state, basePath, patches, inversePatches);
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
1120
|
-
var assign, assign$1;
|
|
1121
|
-
|
|
1122
|
-
var base = state.base;
|
|
1123
|
-
var copy = state.copy;
|
|
1124
|
-
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
1125
|
-
|
|
1126
|
-
if (copy.length < base.length) {
|
|
1127
|
-
(assign = [copy, base], base = assign[0], copy = assign[1]);
|
|
1128
|
-
(assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1]);
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
var delta = copy.length - base.length; // Find the first replaced index.
|
|
1132
|
-
|
|
1133
|
-
var start = 0;
|
|
1134
|
-
|
|
1135
|
-
while (base[start] === copy[start] && start < base.length) {
|
|
1136
|
-
++start;
|
|
1137
|
-
} // Find the last replaced index. Search from the end to optimize splice patches.
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
var end = base.length;
|
|
1141
|
-
|
|
1142
|
-
while (end > start && base[end - 1] === copy[end + delta - 1]) {
|
|
1143
|
-
--end;
|
|
1144
|
-
} // Process replaced indices.
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
for (var i = start; i < end; ++i) {
|
|
1148
|
-
if (assigned[i] && copy[i] !== base[i]) {
|
|
1149
|
-
var path = basePath.concat([i]);
|
|
1150
|
-
patches.push({
|
|
1151
|
-
op: "replace",
|
|
1152
|
-
path: path,
|
|
1153
|
-
value: copy[i]
|
|
1154
|
-
});
|
|
1155
|
-
inversePatches.push({
|
|
1156
|
-
op: "replace",
|
|
1157
|
-
path: path,
|
|
1158
|
-
value: base[i]
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
var replaceCount = patches.length; // Process added indices.
|
|
1164
|
-
|
|
1165
|
-
for (var i$1 = end + delta - 1; i$1 >= end; --i$1) {
|
|
1166
|
-
var path$1 = basePath.concat([i$1]);
|
|
1167
|
-
patches[replaceCount + i$1 - end] = {
|
|
1168
|
-
op: "add",
|
|
1169
|
-
path: path$1,
|
|
1170
|
-
value: copy[i$1]
|
|
1171
|
-
};
|
|
1172
|
-
inversePatches.push({
|
|
1173
|
-
op: "remove",
|
|
1174
|
-
path: path$1
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
1180
|
-
var base = state.base;
|
|
1181
|
-
var copy = state.copy;
|
|
1182
|
-
each(state.assigned, function (key, assignedValue) {
|
|
1183
|
-
var origValue = base[key];
|
|
1184
|
-
var value = copy[key];
|
|
1185
|
-
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
1186
|
-
if (origValue === value && op === "replace") { return; }
|
|
1187
|
-
var path = basePath.concat(key);
|
|
1188
|
-
patches.push(op === "remove" ? {
|
|
1189
|
-
op: op,
|
|
1190
|
-
path: path
|
|
1191
|
-
} : {
|
|
1192
|
-
op: op,
|
|
1193
|
-
path: path,
|
|
1194
|
-
value: value
|
|
1195
|
-
});
|
|
1196
|
-
inversePatches.push(op === "add" ? {
|
|
1197
|
-
op: "remove",
|
|
1198
|
-
path: path
|
|
1199
|
-
} : op === "remove" ? {
|
|
1200
|
-
op: "add",
|
|
1201
|
-
path: path,
|
|
1202
|
-
value: origValue
|
|
1203
|
-
} : {
|
|
1204
|
-
op: "replace",
|
|
1205
|
-
path: path,
|
|
1206
|
-
value: origValue
|
|
1207
|
-
});
|
|
1208
|
-
});
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
var applyPatches = function (draft, patches) {
|
|
1212
|
-
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
1213
|
-
var patch = list[i$1];
|
|
1214
|
-
|
|
1215
|
-
var path = patch.path;
|
|
1216
|
-
var op = patch.op;
|
|
1217
|
-
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
1218
|
-
|
|
1219
|
-
if (!path.length) { throw new Error("Illegal state"); }
|
|
1220
|
-
var base = draft;
|
|
1221
|
-
|
|
1222
|
-
for (var i = 0; i < path.length - 1; i++) {
|
|
1223
|
-
base = base[path[i]];
|
|
1224
|
-
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
var key = path[path.length - 1];
|
|
1228
|
-
|
|
1229
|
-
switch (op) {
|
|
1230
|
-
case "replace":
|
|
1231
|
-
// if value is an object, then it's assigned by reference
|
|
1232
|
-
// in the following add or remove ops, the value field inside the patch will also be modifyed
|
|
1233
|
-
// so we use value from the cloned patch
|
|
1234
|
-
base[key] = value;
|
|
1235
|
-
break;
|
|
1236
|
-
|
|
1237
|
-
case "add":
|
|
1238
|
-
if (Array.isArray(base)) {
|
|
1239
|
-
// TODO: support "foo/-" paths for appending to an array
|
|
1240
|
-
base.splice(key, 0, value);
|
|
1241
|
-
} else {
|
|
1242
|
-
base[key] = value;
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
break;
|
|
1246
|
-
|
|
1247
|
-
case "remove":
|
|
1248
|
-
if (Array.isArray(base)) {
|
|
1249
|
-
base.splice(key, 1);
|
|
1250
|
-
} else {
|
|
1251
|
-
delete base[key];
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
break;
|
|
1255
|
-
|
|
1256
|
-
default:
|
|
1257
|
-
throw new Error("Unsupported patch operation: " + op);
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
return draft;
|
|
1262
|
-
};
|
|
1263
|
-
|
|
1264
|
-
function verifyMinified() {}
|
|
1265
|
-
|
|
1266
|
-
var configDefaults = {
|
|
1267
|
-
useProxies: typeof Proxy !== "undefined" && typeof Reflect !== "undefined",
|
|
1268
|
-
autoFreeze: typeof process !== "undefined" ? process.env.NODE_ENV !== "production" : verifyMinified.name === "verifyMinified",
|
|
1269
|
-
onAssign: null,
|
|
1270
|
-
onDelete: null,
|
|
1271
|
-
onCopy: null
|
|
1272
|
-
};
|
|
1273
|
-
var Immer = function Immer(config) {
|
|
1274
|
-
assign(this, configDefaults, config);
|
|
1275
|
-
this.setUseProxies(this.useProxies);
|
|
1276
|
-
this.produce = this.produce.bind(this);
|
|
1277
|
-
};
|
|
1278
|
-
|
|
1279
|
-
Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
1280
|
-
var this$1$1 = this;
|
|
1281
|
-
|
|
1282
|
-
// curried invocation
|
|
1283
|
-
if (typeof base === "function" && typeof recipe !== "function") {
|
|
1284
|
-
var defaultBase = recipe;
|
|
1285
|
-
recipe = base;
|
|
1286
|
-
var self = this;
|
|
1287
|
-
return function curriedProduce(base) {
|
|
1288
|
-
var this$1$1 = this;
|
|
1289
|
-
if ( base === void 0 ) base = defaultBase;
|
|
1290
|
-
var args = [], len = arguments.length - 1;
|
|
1291
|
-
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
1292
|
-
|
|
1293
|
-
return self.produce(base, function (draft) { return recipe.call.apply(recipe, [ this$1$1, draft ].concat( args )); }); // prettier-ignore
|
|
1294
|
-
};
|
|
1295
|
-
} // prettier-ignore
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
{
|
|
1299
|
-
if (typeof recipe !== "function") {
|
|
1300
|
-
throw new Error("The first or second argument to `produce` must be a function");
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
if (patchListener !== undefined && typeof patchListener !== "function") {
|
|
1304
|
-
throw new Error("The third argument to `produce` must be a function or undefined");
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
var result; // Only plain objects, arrays, and "immerable classes" are drafted.
|
|
1308
|
-
|
|
1309
|
-
if (isDraftable(base)) {
|
|
1310
|
-
var scope = ImmerScope.enter();
|
|
1311
|
-
var proxy = this.createProxy(base);
|
|
1312
|
-
var hasError = true;
|
|
1313
|
-
|
|
1314
|
-
try {
|
|
1315
|
-
result = recipe(proxy);
|
|
1316
|
-
hasError = false;
|
|
1317
|
-
} finally {
|
|
1318
|
-
// finally instead of catch + rethrow better preserves original stack
|
|
1319
|
-
if (hasError) { scope.revoke(); }else { scope.leave(); }
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
if (result instanceof Promise) {
|
|
1323
|
-
return result.then(function (result) {
|
|
1324
|
-
scope.usePatches(patchListener);
|
|
1325
|
-
return this$1$1.processResult(result, scope);
|
|
1326
|
-
}, function (error) {
|
|
1327
|
-
scope.revoke();
|
|
1328
|
-
throw error;
|
|
1329
|
-
});
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
scope.usePatches(patchListener);
|
|
1333
|
-
return this.processResult(result, scope);
|
|
1334
|
-
} else {
|
|
1335
|
-
result = recipe(base);
|
|
1336
|
-
if (result === undefined) { return base; }
|
|
1337
|
-
return result !== NOTHING ? result : undefined;
|
|
1338
|
-
}
|
|
1339
|
-
};
|
|
1340
|
-
|
|
1341
|
-
Immer.prototype.produceWithPatches = function produceWithPatches (arg1, arg2, arg3) {
|
|
1342
|
-
var this$1$1 = this;
|
|
1343
|
-
|
|
1344
|
-
if (typeof arg1 === "function") {
|
|
1345
|
-
return function (state) {
|
|
1346
|
-
var args = [], len = arguments.length - 1;
|
|
1347
|
-
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
1348
|
-
|
|
1349
|
-
return this$1$1.produceWithPatches(state, function (draft) { return arg1.apply(void 0, [ draft ].concat( args )); });
|
|
1350
|
-
};
|
|
1351
|
-
} // non-curried form
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
if (arg3) { throw new Error("A patch listener cannot be passed to produceWithPatches"); }
|
|
1355
|
-
var patches, inversePatches;
|
|
1356
|
-
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
1357
|
-
patches = p;
|
|
1358
|
-
inversePatches = ip;
|
|
1359
|
-
});
|
|
1360
|
-
return [nextState, patches, inversePatches];
|
|
1361
|
-
};
|
|
1362
|
-
|
|
1363
|
-
Immer.prototype.createDraft = function createDraft (base) {
|
|
1364
|
-
if (!isDraftable(base)) {
|
|
1365
|
-
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
var scope = ImmerScope.enter();
|
|
1369
|
-
var proxy = this.createProxy(base);
|
|
1370
|
-
proxy[DRAFT_STATE].isManual = true;
|
|
1371
|
-
scope.leave();
|
|
1372
|
-
return proxy;
|
|
1373
|
-
};
|
|
1374
|
-
|
|
1375
|
-
Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
1376
|
-
var state = draft && draft[DRAFT_STATE];
|
|
1377
|
-
|
|
1378
|
-
if (!state || !state.isManual) {
|
|
1379
|
-
throw new Error("First argument to `finishDraft` must be a draft returned by `createDraft`"); // prettier-ignore
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
if (state.finalized) {
|
|
1383
|
-
throw new Error("The given draft is already finalized"); // prettier-ignore
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
var scope = state.scope;
|
|
1387
|
-
scope.usePatches(patchListener);
|
|
1388
|
-
return this.processResult(undefined, scope);
|
|
1389
|
-
};
|
|
1390
|
-
|
|
1391
|
-
Immer.prototype.setAutoFreeze = function setAutoFreeze (value) {
|
|
1392
|
-
this.autoFreeze = value;
|
|
1393
|
-
};
|
|
1394
|
-
|
|
1395
|
-
Immer.prototype.setUseProxies = function setUseProxies (value) {
|
|
1396
|
-
this.useProxies = value;
|
|
1397
|
-
assign(this, value ? modernProxy : legacyProxy);
|
|
1398
|
-
};
|
|
1399
|
-
|
|
1400
|
-
Immer.prototype.applyPatches = function applyPatches$1 (base, patches) {
|
|
1401
|
-
// If a patch replaces the entire state, take that replacement as base
|
|
1402
|
-
// before applying patches
|
|
1403
|
-
var i;
|
|
1404
|
-
|
|
1405
|
-
for (i = patches.length - 1; i >= 0; i--) {
|
|
1406
|
-
var patch = patches[i];
|
|
1407
|
-
|
|
1408
|
-
if (patch.path.length === 0 && patch.op === "replace") {
|
|
1409
|
-
base = patch.value;
|
|
1410
|
-
break;
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
if (isDraft(base)) {
|
|
1415
|
-
// N.B: never hits if some patch a replacement, patches are never drafts
|
|
1416
|
-
return applyPatches(base, patches);
|
|
1417
|
-
} // Otherwise, produce a copy of the base state.
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
return this.produce(base, function (draft) { return applyPatches(draft, patches.slice(i + 1)); });
|
|
1421
|
-
};
|
|
1422
|
-
/** @internal */
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
Immer.prototype.processResult = function processResult (result, scope) {
|
|
1426
|
-
var baseDraft = scope.drafts[0];
|
|
1427
|
-
var isReplaced = result !== undefined && result !== baseDraft;
|
|
1428
|
-
this.willFinalize(scope, result, isReplaced);
|
|
1429
|
-
|
|
1430
|
-
if (isReplaced) {
|
|
1431
|
-
if (baseDraft[DRAFT_STATE].modified) {
|
|
1432
|
-
scope.revoke();
|
|
1433
|
-
throw new Error("An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft."); // prettier-ignore
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
if (isDraftable(result)) {
|
|
1437
|
-
// Finalize the result in case it contains (or is) a subset of the draft.
|
|
1438
|
-
result = this.finalize(result, null, scope);
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
if (scope.patches) {
|
|
1442
|
-
scope.patches.push({
|
|
1443
|
-
op: "replace",
|
|
1444
|
-
path: [],
|
|
1445
|
-
value: result
|
|
1446
|
-
});
|
|
1447
|
-
scope.inversePatches.push({
|
|
1448
|
-
op: "replace",
|
|
1449
|
-
path: [],
|
|
1450
|
-
value: baseDraft[DRAFT_STATE].base
|
|
1451
|
-
});
|
|
1452
|
-
}
|
|
1453
|
-
} else {
|
|
1454
|
-
// Finalize the base draft.
|
|
1455
|
-
result = this.finalize(baseDraft, [], scope);
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
scope.revoke();
|
|
1459
|
-
|
|
1460
|
-
if (scope.patches) {
|
|
1461
|
-
scope.patchListener(scope.patches, scope.inversePatches);
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
return result !== NOTHING ? result : undefined;
|
|
1465
|
-
};
|
|
1466
|
-
/**
|
|
1467
|
-
* @internal
|
|
1468
|
-
* Finalize a draft, returning either the unmodified base state or a modified
|
|
1469
|
-
* copy of the base state.
|
|
1470
|
-
*/
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
1474
|
-
var this$1$1 = this;
|
|
1475
|
-
|
|
1476
|
-
var state = draft[DRAFT_STATE];
|
|
1477
|
-
|
|
1478
|
-
if (!state) {
|
|
1479
|
-
if (Object.isFrozen(draft)) { return draft; }
|
|
1480
|
-
return this.finalizeTree(draft, null, scope);
|
|
1481
|
-
} // Never finalize drafts owned by another scope.
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
if (state.scope !== scope) {
|
|
1485
|
-
return draft;
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
if (!state.modified) {
|
|
1489
|
-
return state.base;
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
if (!state.finalized) {
|
|
1493
|
-
state.finalized = true;
|
|
1494
|
-
this.finalizeTree(state.draft, path, scope);
|
|
1495
|
-
|
|
1496
|
-
if (this.onDelete) {
|
|
1497
|
-
// The `assigned` object is unreliable with ES5 drafts.
|
|
1498
|
-
if (this.useProxies) {
|
|
1499
|
-
var assigned = state.assigned;
|
|
1500
|
-
|
|
1501
|
-
for (var prop in assigned) {
|
|
1502
|
-
if (!assigned[prop]) { this.onDelete(state, prop); }
|
|
1503
|
-
}
|
|
1504
|
-
} else {
|
|
1505
|
-
var base = state.base;
|
|
1506
|
-
var copy = state.copy;
|
|
1507
|
-
each(base, function (prop) {
|
|
1508
|
-
if (!has(copy, prop)) { this$1$1.onDelete(state, prop); }
|
|
1509
|
-
});
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
if (this.onCopy) {
|
|
1514
|
-
this.onCopy(state);
|
|
1515
|
-
} // At this point, all descendants of `state.copy` have been finalized,
|
|
1516
|
-
// so we can be sure that `scope.canAutoFreeze` is accurate.
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
if (this.autoFreeze && scope.canAutoFreeze) {
|
|
1520
|
-
Object.freeze(state.copy);
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
if (path && scope.patches) {
|
|
1524
|
-
generatePatches(state, path, scope.patches, scope.inversePatches);
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
return state.copy;
|
|
1529
|
-
};
|
|
1530
|
-
/**
|
|
1531
|
-
* @internal
|
|
1532
|
-
* Finalize all drafts in the given state tree.
|
|
1533
|
-
*/
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
Immer.prototype.finalizeTree = function finalizeTree (root, rootPath, scope) {
|
|
1537
|
-
var this$1$1 = this;
|
|
1538
|
-
|
|
1539
|
-
var state = root[DRAFT_STATE];
|
|
1540
|
-
|
|
1541
|
-
if (state) {
|
|
1542
|
-
if (!this.useProxies) {
|
|
1543
|
-
// Create the final copy, with added keys and without deleted keys.
|
|
1544
|
-
state.copy = shallowCopy(state.draft, true);
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
root = state.copy;
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
var needPatches = !!rootPath && !!scope.patches;
|
|
1551
|
-
|
|
1552
|
-
var finalizeProperty = function (prop, value, parent) {
|
|
1553
|
-
if (value === parent) {
|
|
1554
|
-
throw Error("Immer forbids circular references");
|
|
1555
|
-
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
var isDraftProp = !!state && parent === root;
|
|
1559
|
-
|
|
1560
|
-
if (isDraft(value)) {
|
|
1561
|
-
var path = isDraftProp && needPatches && !state.assigned[prop] ? rootPath.concat(prop) : null; // Drafts owned by `scope` are finalized here.
|
|
1562
|
-
|
|
1563
|
-
value = this$1$1.finalize(value, path, scope); // Drafts from another scope must prevent auto-freezing.
|
|
1564
|
-
|
|
1565
|
-
if (isDraft(value)) {
|
|
1566
|
-
scope.canAutoFreeze = false;
|
|
1567
|
-
} // Preserve non-enumerable properties.
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
if (Array.isArray(parent) || isEnumerable(parent, prop)) {
|
|
1571
|
-
parent[prop] = value;
|
|
1572
|
-
} else {
|
|
1573
|
-
Object.defineProperty(parent, prop, {
|
|
1574
|
-
value: value
|
|
1575
|
-
});
|
|
1576
|
-
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
if (isDraftProp && value === state.base[prop]) { return; }
|
|
1580
|
-
} // Unchanged draft properties are ignored.
|
|
1581
|
-
else if (isDraftProp && is(value, state.base[prop])) {
|
|
1582
|
-
return;
|
|
1583
|
-
} // Search new objects for unfinalized drafts. Frozen objects should never contain drafts.
|
|
1584
|
-
else if (isDraftable(value) && !Object.isFrozen(value)) {
|
|
1585
|
-
each(value, finalizeProperty);
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
if (isDraftProp && this$1$1.onAssign) {
|
|
1589
|
-
this$1$1.onAssign(state, prop, value);
|
|
1590
|
-
}
|
|
1591
|
-
};
|
|
1592
|
-
|
|
1593
|
-
each(root, finalizeProperty);
|
|
1594
|
-
return root;
|
|
1595
|
-
};
|
|
1596
|
-
|
|
1597
|
-
var immer = new Immer();
|
|
1598
|
-
/**
|
|
1599
|
-
* The `produce` function takes a value and a "recipe function" (whose
|
|
1600
|
-
* return value often depends on the base state). The recipe function is
|
|
1601
|
-
* free to mutate its first argument however it wants. All mutations are
|
|
1602
|
-
* only ever applied to a __copy__ of the base state.
|
|
1603
|
-
*
|
|
1604
|
-
* Pass only a function to create a "curried producer" which relieves you
|
|
1605
|
-
* from passing the recipe function every time.
|
|
1606
|
-
*
|
|
1607
|
-
* Only plain objects and arrays are made mutable. All other objects are
|
|
1608
|
-
* considered uncopyable.
|
|
1609
|
-
*
|
|
1610
|
-
* Note: This function is __bound__ to its `Immer` instance.
|
|
1611
|
-
*
|
|
1612
|
-
* @param {any} base - the initial state
|
|
1613
|
-
* @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified
|
|
1614
|
-
* @param {Function} patchListener - optional function that will be called with all the patches produced here
|
|
1615
|
-
* @returns {any} a new state, or the initial state if nothing was modified
|
|
1616
|
-
*/
|
|
1617
|
-
|
|
1618
|
-
var produce = immer.produce;
|
|
1619
|
-
/**
|
|
1620
|
-
* Like `produce`, but `produceWithPatches` always returns a tuple
|
|
1621
|
-
* [nextState, patches, inversePatches] (instead of just the next state)
|
|
1622
|
-
*/
|
|
1623
|
-
|
|
1624
|
-
immer.produceWithPatches.bind(immer);
|
|
1625
|
-
/**
|
|
1626
|
-
* Pass true to automatically freeze all copies created by Immer.
|
|
1627
|
-
*
|
|
1628
|
-
* By default, auto-freezing is disabled in production.
|
|
1629
|
-
*/
|
|
1630
|
-
|
|
1631
|
-
immer.setAutoFreeze.bind(immer);
|
|
1632
|
-
/**
|
|
1633
|
-
* Pass true to use the ES2015 `Proxy` class when creating drafts, which is
|
|
1634
|
-
* always faster than using ES5 proxies.
|
|
1635
|
-
*
|
|
1636
|
-
* By default, feature detection is used, so calling this is rarely necessary.
|
|
1637
|
-
*/
|
|
1638
|
-
|
|
1639
|
-
immer.setUseProxies.bind(immer);
|
|
1640
|
-
/**
|
|
1641
|
-
* Apply an array of Immer patches to the first argument.
|
|
1642
|
-
*
|
|
1643
|
-
* This function is a producer, which means copy-on-write is in effect.
|
|
1644
|
-
*/
|
|
1645
|
-
|
|
1646
|
-
immer.applyPatches.bind(immer);
|
|
1647
|
-
/**
|
|
1648
|
-
* Create an Immer draft from the given base state, which may be a draft itself.
|
|
1649
|
-
* The draft can be modified until you finalize it with the `finishDraft` function.
|
|
1650
|
-
*/
|
|
1651
|
-
|
|
1652
|
-
immer.createDraft.bind(immer);
|
|
1653
|
-
/**
|
|
1654
|
-
* Finalize an Immer draft from a `createDraft` call, returning the base state
|
|
1655
|
-
* (if no changes were made) or a modified copy. The draft must *not* be
|
|
1656
|
-
* mutated afterwards.
|
|
1657
|
-
*
|
|
1658
|
-
* Pass a function as the 2nd argument to generate Immer patches based on the
|
|
1659
|
-
* changes that were made.
|
|
1660
|
-
*/
|
|
1661
|
-
|
|
1662
|
-
immer.finishDraft.bind(immer);
|
|
562
|
+
function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){var r;return !!n&&(function(n){if(!n||"object"!=typeof n)return !1;var r=Object.getPrototypeOf(n);if(null===r)return !0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v(n))}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=!1),y(n)||r(n)||!t(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,!0)}),!0)),n}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function g(n){O(n),n.p.forEach(S),n.p=null;}function O(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=!0;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b("ES5").S(e,r,o),o?(i[Q].P&&(g(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o,u=o,a=!1;3===e.i&&(u=new Set(o),o.clear(),a=!0),i(u,(function(r,i){return A(n,e,o,r,i,t,a)})),x(n,o,!1),t&&n.u&&b("Patches").N(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s,v){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var p=M(e,c,s&&i&&3!==i.i&&!u(i.R,a)?s.concat(a):void 0);if(f(o,a,p),!r(p))return;e.m=!1;}else v&&o.add(c);if(t(c)&&!y(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){void 0===t&&(t=!1),!n.l&&n.h.D&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=!0,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function N(n,r,t){var e=s(r)?b("MapSet").F(r,t):v(r)?b("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function R(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=!0,e=D(r,c),u.I=!1;}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=!1,!0;if(c(t,i)&&(void 0!==t||u(n.t,r)))return !0;E(n),k(n);}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=!0),!0},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.R[r]=!1,E(n),k(n)):delete n.R[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=N(e,r,void 0),v=!0;try{f=i(s),v=!1;}finally{v?g(c):O(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d(f,!0),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=R(e));var i=w(this),o=N(this,e,void 0);return o[Q].C=!0,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.O=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);var produce = fn;
|
|
1663
563
|
|
|
1664
564
|
const createInitialState = (formConfig) => {
|
|
1665
565
|
let initialForm = {};
|
|
@@ -1812,6 +712,7 @@ exports.hasNumber = hasNumber;
|
|
|
1812
712
|
exports.hasSpecialCharacter = hasSpecialCharacter;
|
|
1813
713
|
exports.hasUppercaseLetter = hasUppercaseLetter;
|
|
1814
714
|
exports.includedIn = includedIn;
|
|
715
|
+
exports.isCurrency = isCurrency;
|
|
1815
716
|
exports.isPercentage = isPercentage;
|
|
1816
717
|
exports.isProbablyEmail = isProbablyEmail;
|
|
1817
718
|
exports.isRoutingNumber = isRoutingNumber;
|