@thecb/components 9.2.0 → 9.2.2-beta.0
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/index.cjs.js +230 -1328
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +230 -1328
- package/dist/index.esm.js.map +1 -1
- package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +49322 -0
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/atoms/.DS_Store +0 -0
- package/src/components/atoms/dropdown/Dropdown.js +2 -4
- package/src/components/atoms/icons/.DS_Store +0 -0
package/dist/index.cjs.js
CHANGED
|
@@ -23996,7 +23996,7 @@ var Dropdown = function Dropdown(_ref13) {
|
|
|
23996
23996
|
}
|
|
23997
23997
|
|
|
23998
23998
|
setFilteredOptions(options.filter(function (option) {
|
|
23999
|
-
return option.value.toLowerCase().
|
|
23999
|
+
return option.value.toLowerCase().match(inputValue.toLowerCase());
|
|
24000
24000
|
}));
|
|
24001
24001
|
}, [inputValue]);
|
|
24002
24002
|
React.useEffect(function () {
|
|
@@ -38747,44 +38747,52 @@ var TableHeading_styled = styled__default.th.withConfig({
|
|
|
38747
38747
|
return extraStyles;
|
|
38748
38748
|
});
|
|
38749
38749
|
|
|
38750
|
-
const validatorToPredicate =
|
|
38751
|
-
|
|
38752
|
-
...rest
|
|
38753
|
-
|
|
38750
|
+
const validatorToPredicate =
|
|
38751
|
+
(validatorFn, emptyCase) =>
|
|
38752
|
+
(value, ...rest) =>
|
|
38753
|
+
value === '' ? emptyCase : validatorFn(value, ...rest);
|
|
38754
38754
|
|
|
38755
38755
|
var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
38756
38756
|
|
|
38757
|
+
function getDefaultExportFromCjs (x) {
|
|
38758
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
38759
|
+
}
|
|
38760
|
+
|
|
38757
38761
|
var dayjs_min = {exports: {}};
|
|
38758
38762
|
|
|
38759
38763
|
(function (module, exports) {
|
|
38760
|
-
!function(t,e){module.exports=e();}(commonjsGlobal$1,(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"
|
|
38761
|
-
}(dayjs_min));
|
|
38764
|
+
!function(t,e){module.exports=e();}(commonjsGlobal$1,(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}));
|
|
38765
|
+
} (dayjs_min));
|
|
38762
38766
|
|
|
38763
|
-
var
|
|
38767
|
+
var dayjs_minExports = dayjs_min.exports;
|
|
38768
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
38764
38769
|
|
|
38765
38770
|
var customParseFormat$1 = {exports: {}};
|
|
38766
38771
|
|
|
38767
38772
|
(function (module, exports) {
|
|
38768
|
-
!function(t
|
|
38769
|
-
}(customParseFormat$1));
|
|
38773
|
+
!function(e,t){module.exports=t();}(commonjsGlobal$1,(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);};}}));
|
|
38774
|
+
} (customParseFormat$1));
|
|
38770
38775
|
|
|
38771
|
-
var
|
|
38776
|
+
var customParseFormatExports = customParseFormat$1.exports;
|
|
38777
|
+
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
38772
38778
|
|
|
38773
38779
|
var isSameOrBefore$1 = {exports: {}};
|
|
38774
38780
|
|
|
38775
38781
|
(function (module, exports) {
|
|
38776
|
-
!function(e,i){module.exports=i();}(commonjsGlobal$1,(function(){return function(e,i){i.prototype.isSameOrBefore=function(e,i){return this.isSame(e,i)||this.isBefore(e,i)};}}));
|
|
38777
|
-
}(isSameOrBefore$1));
|
|
38782
|
+
!function(e,i){module.exports=i();}(commonjsGlobal$1,(function(){return function(e,i){i.prototype.isSameOrBefore=function(e,i){return this.isSame(e,i)||this.isBefore(e,i)};}}));
|
|
38783
|
+
} (isSameOrBefore$1));
|
|
38778
38784
|
|
|
38779
|
-
var
|
|
38785
|
+
var isSameOrBeforeExports = isSameOrBefore$1.exports;
|
|
38786
|
+
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);
|
|
38780
38787
|
|
|
38781
38788
|
var isSameOrAfter$1 = {exports: {}};
|
|
38782
38789
|
|
|
38783
38790
|
(function (module, exports) {
|
|
38784
|
-
!function(e,t){module.exports=t();}(commonjsGlobal$1,(function(){return function(e,t){t.prototype.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)};}}));
|
|
38785
|
-
}(isSameOrAfter$1));
|
|
38791
|
+
!function(e,t){module.exports=t();}(commonjsGlobal$1,(function(){return function(e,t){t.prototype.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)};}}));
|
|
38792
|
+
} (isSameOrAfter$1));
|
|
38786
38793
|
|
|
38787
|
-
var
|
|
38794
|
+
var isSameOrAfterExports = isSameOrAfter$1.exports;
|
|
38795
|
+
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);
|
|
38788
38796
|
|
|
38789
38797
|
/* eslint-disable no-unused-vars */
|
|
38790
38798
|
|
|
@@ -38800,24 +38808,24 @@ dayjs.extend(isSameOrAfter);
|
|
|
38800
38808
|
|
|
38801
38809
|
let validatorFns = {};
|
|
38802
38810
|
|
|
38803
|
-
const INCLUDED_IN =
|
|
38804
|
-
const INCLUDED_IN_ERROR =
|
|
38811
|
+
const INCLUDED_IN = 'validator/INCLUDED_IN';
|
|
38812
|
+
const INCLUDED_IN_ERROR = 'error/INCLUDED_IN';
|
|
38805
38813
|
const includedIn = createValidator(INCLUDED_IN, INCLUDED_IN_ERROR);
|
|
38806
38814
|
validatorFns[INCLUDED_IN] = (value, args, form) =>
|
|
38807
38815
|
Array.isArray(args[0]) ? args[0].includes(value) : args[0] === value;
|
|
38808
38816
|
|
|
38809
|
-
const REQUIRED =
|
|
38810
|
-
const REQUIRED_ERROR =
|
|
38817
|
+
const REQUIRED = 'validator/REQUIRED';
|
|
38818
|
+
const REQUIRED_ERROR = 'error/REQUIRED';
|
|
38811
38819
|
const required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
38812
|
-
validatorFns[REQUIRED] = (value, args, form) => value !==
|
|
38820
|
+
validatorFns[REQUIRED] = (value, args, form) => value !== '';
|
|
38813
38821
|
|
|
38814
|
-
const ONLY_INTEGERS =
|
|
38815
|
-
const ONLY_INTEGERS_ERROR =
|
|
38822
|
+
const ONLY_INTEGERS = 'validator/ONLY_INTEGERS';
|
|
38823
|
+
const ONLY_INTEGERS_ERROR = 'error/ONLY_INTEGERS';
|
|
38816
38824
|
const onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
38817
38825
|
validatorFns[ONLY_INTEGERS] = (value, args, form) => /^(-?\d+)?$/.test(value);
|
|
38818
38826
|
|
|
38819
|
-
const ONLY_NATURALS =
|
|
38820
|
-
const ONLY_NATURALS_ERROR =
|
|
38827
|
+
const ONLY_NATURALS = 'validator/ONLY_NATURALS';
|
|
38828
|
+
const ONLY_NATURALS_ERROR = 'error/ONLY_NATURALS';
|
|
38821
38829
|
const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
38822
38830
|
validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
|
|
38823
38831
|
|
|
@@ -38830,8 +38838,8 @@ not tested as validation function
|
|
|
38830
38838
|
to validate exp date instead use combo of:
|
|
38831
38839
|
required(), hasLength(), isValidMonth(), dateAfterToday()
|
|
38832
38840
|
*/
|
|
38833
|
-
const ONLY_EXPIRATION_DATE =
|
|
38834
|
-
const ONLY_EXPIRATION_DATE_ERROR =
|
|
38841
|
+
const ONLY_EXPIRATION_DATE = 'validator/ONLY_EXPIRATION_DATE';
|
|
38842
|
+
const ONLY_EXPIRATION_DATE_ERROR = 'error/ONLY_EXPIRATION_DATE';
|
|
38835
38843
|
const onlyExpirationDate = createValidator(
|
|
38836
38844
|
ONLY_EXPIRATION_DATE,
|
|
38837
38845
|
ONLY_EXPIRATION_DATE_ERROR
|
|
@@ -38839,64 +38847,63 @@ const onlyExpirationDate = createValidator(
|
|
|
38839
38847
|
validatorFns[ONLY_EXPIRATION_DATE] = (value, args, form) =>
|
|
38840
38848
|
/^(\d?\d?\/?\d?\d?)?$/.test(value);
|
|
38841
38849
|
|
|
38842
|
-
const NUMBER_LESS_THAN =
|
|
38843
|
-
const NUMBER_LESS_THAN_ERROR =
|
|
38850
|
+
const NUMBER_LESS_THAN = 'validator/NUMBER_LESS_THAN';
|
|
38851
|
+
const NUMBER_LESS_THAN_ERROR = 'error/NUMBER_LESS_THAN';
|
|
38844
38852
|
const numberLessThan = createValidator(
|
|
38845
38853
|
NUMBER_LESS_THAN,
|
|
38846
38854
|
NUMBER_LESS_THAN_ERROR
|
|
38847
38855
|
);
|
|
38848
38856
|
validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
38849
|
-
if (value ===
|
|
38857
|
+
if (value === '') {
|
|
38850
38858
|
return true;
|
|
38851
38859
|
}
|
|
38852
38860
|
return Number(value) < args[0];
|
|
38853
38861
|
};
|
|
38854
38862
|
|
|
38855
|
-
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
38856
|
-
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
38863
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO = 'validator/NUMBER_LESS_THAN_OR_EQUAL_TO';
|
|
38857
38864
|
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
38858
|
-
|
|
38865
|
+
'error/NUMBER_LESS_THAN_OR_EQUAL_TO';
|
|
38859
38866
|
const numberLessThanOrEqualTo = createValidator(
|
|
38860
38867
|
NUMBER_LESS_THAN_OR_EQUAL_TO,
|
|
38861
38868
|
NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR
|
|
38862
38869
|
);
|
|
38863
38870
|
validatorFns[NUMBER_LESS_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38864
|
-
if (value ===
|
|
38871
|
+
if (value === '') {
|
|
38865
38872
|
return true;
|
|
38866
38873
|
}
|
|
38867
38874
|
return Number(value) <= args[0];
|
|
38868
38875
|
};
|
|
38869
38876
|
|
|
38870
|
-
const NUMBER_GREATER_THAN =
|
|
38871
|
-
const NUMBER_GREATER_THAN_ERROR =
|
|
38877
|
+
const NUMBER_GREATER_THAN = 'validator/NUMBER_GREATER_THAN';
|
|
38878
|
+
const NUMBER_GREATER_THAN_ERROR = 'error/NUMBER_GREATER_THAN';
|
|
38872
38879
|
const numberGreaterThan = createValidator(
|
|
38873
38880
|
NUMBER_GREATER_THAN,
|
|
38874
38881
|
NUMBER_GREATER_THAN_ERROR
|
|
38875
38882
|
);
|
|
38876
38883
|
validatorFns[NUMBER_GREATER_THAN] = (value, args, form) => {
|
|
38877
|
-
if (value ===
|
|
38884
|
+
if (value === '') {
|
|
38878
38885
|
return true;
|
|
38879
38886
|
}
|
|
38880
38887
|
return Number(value) > args[0];
|
|
38881
38888
|
};
|
|
38882
38889
|
|
|
38883
38890
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO =
|
|
38884
|
-
|
|
38891
|
+
'validator/NUMBER_GREATER_THAN_OR_EQUAL_TO';
|
|
38885
38892
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR =
|
|
38886
|
-
|
|
38893
|
+
'error/NUMBER_GREATER_THAN_OR_EQUAL_TO';
|
|
38887
38894
|
const numberGreaterThanOrEqualTo = createValidator(
|
|
38888
38895
|
NUMBER_GREATER_THAN_OR_EQUAL_TO,
|
|
38889
38896
|
NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR
|
|
38890
38897
|
);
|
|
38891
38898
|
validatorFns[NUMBER_GREATER_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38892
|
-
if (value ===
|
|
38899
|
+
if (value === '') {
|
|
38893
38900
|
return true;
|
|
38894
38901
|
}
|
|
38895
38902
|
return Number(value) >= args[0];
|
|
38896
38903
|
};
|
|
38897
38904
|
|
|
38898
|
-
const MATCHES_FIELD =
|
|
38899
|
-
const MATCHES_FIELD_ERROR$1 =
|
|
38905
|
+
const MATCHES_FIELD = 'validator/MATCHES_FIELD';
|
|
38906
|
+
const MATCHES_FIELD_ERROR$1 = 'error/MATCHES_FIELD';
|
|
38900
38907
|
const matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
|
|
38901
38908
|
validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
38902
38909
|
const dependentField = form[args[0]];
|
|
@@ -38909,7 +38916,7 @@ validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
|
38909
38916
|
return value === dependentFieldValue;
|
|
38910
38917
|
};
|
|
38911
38918
|
|
|
38912
|
-
const validateWhenErrorMessage = type =>
|
|
38919
|
+
const validateWhenErrorMessage = (type) =>
|
|
38913
38920
|
`${type} was passed to validateWhen, but that validator type does not exist.
|
|
38914
38921
|
Please check that you are only calling validator creator functions exported from
|
|
38915
38922
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -38917,25 +38924,21 @@ const validateWhenErrorMessage = type =>
|
|
|
38917
38924
|
createFormState). Also make sure you aren't passing validateWhen() to validateWhen
|
|
38918
38925
|
as the primary validator.`;
|
|
38919
38926
|
|
|
38920
|
-
const VALIDATE_WHEN =
|
|
38921
|
-
const VALIDATE_WHEN_ERROR =
|
|
38922
|
-
const validateWhen = (
|
|
38923
|
-
dependentValidator,
|
|
38924
|
-
primaryValidator,
|
|
38925
|
-
optionalFieldName
|
|
38926
|
-
) => ({
|
|
38927
|
+
const VALIDATE_WHEN = 'validator/VALIDATE_WHEN';
|
|
38928
|
+
const VALIDATE_WHEN_ERROR = 'error/VALIDATE_WHEN';
|
|
38929
|
+
const validateWhen = (dependentValidator, primaryValidator, optionalFieldName) => ({
|
|
38927
38930
|
type: VALIDATE_WHEN,
|
|
38928
38931
|
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
38929
|
-
error: dependentValidator.error
|
|
38932
|
+
error: dependentValidator.error,
|
|
38930
38933
|
});
|
|
38931
38934
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
38932
38935
|
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
38933
38936
|
const [dependentValidator, primaryValidator, optionalFieldName] = args;
|
|
38934
|
-
const dependsOnOtherField = typeof optionalFieldName ===
|
|
38937
|
+
const dependsOnOtherField = typeof optionalFieldName === 'string';
|
|
38935
38938
|
|
|
38936
38939
|
if (
|
|
38937
38940
|
primaryValidator.type === undefined ||
|
|
38938
|
-
typeof validatorFns[primaryValidator.type] !==
|
|
38941
|
+
typeof validatorFns[primaryValidator.type] !== 'function'
|
|
38939
38942
|
) {
|
|
38940
38943
|
throw new Error(validateWhenErrorMessage(primaryValidator.type));
|
|
38941
38944
|
}
|
|
@@ -38959,26 +38962,22 @@ validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
|
38959
38962
|
);
|
|
38960
38963
|
|
|
38961
38964
|
return primaryPredicatePassed
|
|
38962
|
-
? validatorFns[dependentValidator.type](
|
|
38963
|
-
value,
|
|
38964
|
-
dependentValidator.args,
|
|
38965
|
-
form
|
|
38966
|
-
)
|
|
38965
|
+
? validatorFns[dependentValidator.type](value, dependentValidator.args, form)
|
|
38967
38966
|
: true;
|
|
38968
38967
|
};
|
|
38969
38968
|
|
|
38970
|
-
const validateSumErrorMessage = type =>
|
|
38969
|
+
const validateSumErrorMessage = (type) =>
|
|
38971
38970
|
`${type} was passed to validateSum, but that validator type does not exist.
|
|
38972
38971
|
Please check that you are only calling validator creator functions exported from
|
|
38973
38972
|
redux-freeform in your form config and that you didn't forget to
|
|
38974
38973
|
invoke the validator creator (you cannot pass the functions themselves to
|
|
38975
38974
|
createFormState).`;
|
|
38976
|
-
const VALIDATE_SUM =
|
|
38977
|
-
const VALIDATE_SUM_ERROR =
|
|
38975
|
+
const VALIDATE_SUM = 'validator/VALIDATE_SUM';
|
|
38976
|
+
const VALIDATE_SUM_ERROR = 'error/VALIDATE_SUM';
|
|
38978
38977
|
const validateSum = (validator, fieldNamesArray) => ({
|
|
38979
38978
|
type: VALIDATE_SUM,
|
|
38980
38979
|
args: [validator, fieldNamesArray],
|
|
38981
|
-
error: validator.error
|
|
38980
|
+
error: validator.error,
|
|
38982
38981
|
});
|
|
38983
38982
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
38984
38983
|
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
@@ -38986,7 +38985,7 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38986
38985
|
|
|
38987
38986
|
if (
|
|
38988
38987
|
validator.type === undefined ||
|
|
38989
|
-
typeof validatorFns[validator.type] !==
|
|
38988
|
+
typeof validatorFns[validator.type] !== 'function'
|
|
38990
38989
|
) {
|
|
38991
38990
|
throw new Error(validateSumErrorMessage(validator.type));
|
|
38992
38991
|
}
|
|
@@ -39007,37 +39006,35 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
39007
39006
|
return validatorFns[validator.type](sum, validator.args, form);
|
|
39008
39007
|
};
|
|
39009
39008
|
|
|
39010
|
-
const HAS_LENGTH =
|
|
39011
|
-
const HAS_LENGTH_ERROR =
|
|
39009
|
+
const HAS_LENGTH = 'validator/HAS_LENGTH';
|
|
39010
|
+
const HAS_LENGTH_ERROR = 'error/HAS_LENGTH';
|
|
39012
39011
|
const hasLength = createValidator(HAS_LENGTH, HAS_LENGTH_ERROR);
|
|
39013
39012
|
validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
39014
|
-
if (value ===
|
|
39013
|
+
if (value === '') {
|
|
39015
39014
|
return true;
|
|
39016
39015
|
}
|
|
39017
39016
|
const min = args[0];
|
|
39018
39017
|
const max = args[1];
|
|
39019
39018
|
if (max == undefined || min == undefined) {
|
|
39020
39019
|
throw new Error(
|
|
39021
|
-
|
|
39020
|
+
'Max and min need to be defined for hasLength, both or one of them is undefined'
|
|
39022
39021
|
);
|
|
39023
39022
|
}
|
|
39024
39023
|
if (max < min) {
|
|
39025
|
-
throw new Error(
|
|
39026
|
-
"hasLength validator was passed a min greater than the max"
|
|
39027
|
-
);
|
|
39024
|
+
throw new Error('hasLength validator was passed a min greater than the max');
|
|
39028
39025
|
}
|
|
39029
39026
|
const valueLength = value.length;
|
|
39030
39027
|
return max >= valueLength && valueLength >= min;
|
|
39031
39028
|
};
|
|
39032
39029
|
|
|
39033
|
-
const DATE_BEFORE_TODAY =
|
|
39034
|
-
const DATE_BEFORE_TODAY_ERROR =
|
|
39030
|
+
const DATE_BEFORE_TODAY = 'validator/DATE_BEFORE_TODAY';
|
|
39031
|
+
const DATE_BEFORE_TODAY_ERROR = 'error/DATE_BEFORE_TODAY';
|
|
39035
39032
|
const dateBeforeToday = createValidator(
|
|
39036
39033
|
DATE_BEFORE_TODAY,
|
|
39037
39034
|
DATE_BEFORE_TODAY_ERROR
|
|
39038
39035
|
);
|
|
39039
39036
|
validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
39040
|
-
if (value ===
|
|
39037
|
+
if (value === '') {
|
|
39041
39038
|
return true;
|
|
39042
39039
|
}
|
|
39043
39040
|
const dateFormat = args[0];
|
|
@@ -39046,7 +39043,7 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
39046
39043
|
|
|
39047
39044
|
if (dateFormat == undefined || unit == undefined) {
|
|
39048
39045
|
throw new Error(
|
|
39049
|
-
|
|
39046
|
+
'Date format and unit need to be defined for dateBeforeToday, one or both are undefined'
|
|
39050
39047
|
);
|
|
39051
39048
|
}
|
|
39052
39049
|
const now = dayjs();
|
|
@@ -39058,14 +39055,14 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
39058
39055
|
return dateValue.isBefore(now, unit);
|
|
39059
39056
|
};
|
|
39060
39057
|
|
|
39061
|
-
const DATE_AFTER_TODAY =
|
|
39062
|
-
const DATE_AFTER_TODAY_ERROR =
|
|
39058
|
+
const DATE_AFTER_TODAY = 'validator/DATE_AFTER_TODAY';
|
|
39059
|
+
const DATE_AFTER_TODAY_ERROR = 'error/DATE_AFTER_TODAY';
|
|
39063
39060
|
const dateAfterToday = createValidator(
|
|
39064
39061
|
DATE_AFTER_TODAY,
|
|
39065
39062
|
DATE_AFTER_TODAY_ERROR
|
|
39066
39063
|
);
|
|
39067
39064
|
validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
39068
|
-
if (value ===
|
|
39065
|
+
if (value === '') {
|
|
39069
39066
|
return true;
|
|
39070
39067
|
}
|
|
39071
39068
|
const dateFormat = args[0];
|
|
@@ -39074,7 +39071,7 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
39074
39071
|
|
|
39075
39072
|
if (dateFormat == undefined || unit == undefined) {
|
|
39076
39073
|
throw new Error(
|
|
39077
|
-
|
|
39074
|
+
'Date format and unit need to be defined for dateAfterToday, one or both are undefined'
|
|
39078
39075
|
);
|
|
39079
39076
|
}
|
|
39080
39077
|
const now = dayjs();
|
|
@@ -39086,14 +39083,11 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
39086
39083
|
return dateValue.isAfter(now, unit);
|
|
39087
39084
|
};
|
|
39088
39085
|
|
|
39089
|
-
const IS_VALID_MONTH =
|
|
39090
|
-
const IS_VALID_MONTH_ERROR =
|
|
39091
|
-
const isValidMonth = createValidator(
|
|
39092
|
-
IS_VALID_MONTH,
|
|
39093
|
-
IS_VALID_MONTH_ERROR
|
|
39094
|
-
);
|
|
39086
|
+
const IS_VALID_MONTH = 'validator/IS_VALID_MONTH';
|
|
39087
|
+
const IS_VALID_MONTH_ERROR = 'error/IS_VALID_MONTH';
|
|
39088
|
+
const isValidMonth = createValidator(IS_VALID_MONTH, IS_VALID_MONTH_ERROR);
|
|
39095
39089
|
validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
39096
|
-
if (value ===
|
|
39090
|
+
if (value === '') {
|
|
39097
39091
|
return true;
|
|
39098
39092
|
}
|
|
39099
39093
|
// Function takes one argument representing the character position
|
|
@@ -39103,43 +39097,43 @@ validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
|
39103
39097
|
// Only works with two digit months (01, 02, 03, etc)
|
|
39104
39098
|
const monthStartPosition = parseInt(args[0]);
|
|
39105
39099
|
const monthEndPosition = monthStartPosition + 2;
|
|
39106
|
-
if (monthStartPosition
|
|
39107
|
-
throw new Error(
|
|
39100
|
+
if (isNaN(monthStartPosition)) {
|
|
39101
|
+
throw new Error('Month start position has to be a valid integer string');
|
|
39108
39102
|
}
|
|
39109
39103
|
const month = parseInt(value.slice(monthStartPosition, monthEndPosition));
|
|
39110
|
-
if (month
|
|
39104
|
+
if (isNaN(month)) {
|
|
39111
39105
|
return false;
|
|
39112
39106
|
}
|
|
39113
39107
|
return month >= 1 && month <= 12;
|
|
39114
39108
|
};
|
|
39115
39109
|
|
|
39116
|
-
const MATCHES_REGEX =
|
|
39117
|
-
const MATCHES_REGEX_ERROR =
|
|
39110
|
+
const MATCHES_REGEX = 'validator/MATCHES_REGEX';
|
|
39111
|
+
const MATCHES_REGEX_ERROR = 'error/MATCHES_REGEX';
|
|
39118
39112
|
const matchesRegex = createValidator(MATCHES_REGEX, MATCHES_REGEX_ERROR);
|
|
39119
39113
|
validatorFns[MATCHES_REGEX] = (value, args, form) => {
|
|
39120
|
-
if (value ===
|
|
39114
|
+
if (value === '') {
|
|
39121
39115
|
return true;
|
|
39122
39116
|
}
|
|
39123
39117
|
return new RegExp(args[0]).test(value); // new RexExp never throws an error, no matter the input
|
|
39124
39118
|
};
|
|
39125
39119
|
|
|
39126
39120
|
// based on http://www.brainjar.com/js/validation/
|
|
39127
|
-
const IS_ROUTING_NUMBER =
|
|
39128
|
-
const IS_ROUTING_NUMBER_ERROR =
|
|
39121
|
+
const IS_ROUTING_NUMBER = 'validator/IS_ROUTING_NUMBER';
|
|
39122
|
+
const IS_ROUTING_NUMBER_ERROR = 'error/IS_ROUTING_NUMBER';
|
|
39129
39123
|
const isRoutingNumber = createValidator(
|
|
39130
39124
|
IS_ROUTING_NUMBER,
|
|
39131
39125
|
IS_ROUTING_NUMBER_ERROR
|
|
39132
39126
|
);
|
|
39133
39127
|
validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
39134
|
-
if (value ===
|
|
39128
|
+
if (value === '') {
|
|
39135
39129
|
return true;
|
|
39136
39130
|
}
|
|
39137
39131
|
if (value.length != 9) {
|
|
39138
39132
|
return false;
|
|
39139
39133
|
}
|
|
39140
39134
|
const sum = value
|
|
39141
|
-
.split(
|
|
39142
|
-
.map(ch => parseInt(ch))
|
|
39135
|
+
.split('')
|
|
39136
|
+
.map((ch) => parseInt(ch))
|
|
39143
39137
|
.reduce((acc, cur, idx) => {
|
|
39144
39138
|
switch (idx % 3) {
|
|
39145
39139
|
case 0:
|
|
@@ -39153,69 +39147,69 @@ validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
|
39153
39147
|
return sum != 0 && sum % 10 == 0;
|
|
39154
39148
|
};
|
|
39155
39149
|
|
|
39156
|
-
const HAS_NUMBER =
|
|
39157
|
-
const HAS_NUMBER_ERROR$1 =
|
|
39150
|
+
const HAS_NUMBER = 'validator/HAS_NUMBER';
|
|
39151
|
+
const HAS_NUMBER_ERROR$1 = 'error/HAS_NUMBER';
|
|
39158
39152
|
const hasNumber = createValidator(HAS_NUMBER, HAS_NUMBER_ERROR$1);
|
|
39159
39153
|
validatorFns[HAS_NUMBER] = (value, args, form) => {
|
|
39160
|
-
if (value ===
|
|
39154
|
+
if (value === '') {
|
|
39161
39155
|
return true;
|
|
39162
39156
|
}
|
|
39163
39157
|
return new RegExp(/[0-9]/).test(value);
|
|
39164
39158
|
};
|
|
39165
39159
|
|
|
39166
|
-
const HAS_LOWERCASE_LETTER =
|
|
39167
|
-
const HAS_LOWERCASE_LETTER_ERROR$1 =
|
|
39160
|
+
const HAS_LOWERCASE_LETTER = 'validator/HAS_LOWERCASE_LETTER';
|
|
39161
|
+
const HAS_LOWERCASE_LETTER_ERROR$1 = 'error/HAS_LOWERCASE_LETTER';
|
|
39168
39162
|
const hasLowercaseLetter = createValidator(
|
|
39169
39163
|
HAS_LOWERCASE_LETTER,
|
|
39170
39164
|
HAS_LOWERCASE_LETTER_ERROR$1
|
|
39171
39165
|
);
|
|
39172
39166
|
validatorFns[HAS_LOWERCASE_LETTER] = (value, args, form) => {
|
|
39173
|
-
if (value ===
|
|
39167
|
+
if (value === '') {
|
|
39174
39168
|
return true;
|
|
39175
39169
|
}
|
|
39176
39170
|
return new RegExp(/[a-z]/).test(value);
|
|
39177
39171
|
};
|
|
39178
39172
|
|
|
39179
|
-
const HAS_UPPERCASE_LETTER =
|
|
39180
|
-
const HAS_UPPERCASE_LETTER_ERROR$1 =
|
|
39173
|
+
const HAS_UPPERCASE_LETTER = 'validator/HAS_UPPERCASE_LETTER';
|
|
39174
|
+
const HAS_UPPERCASE_LETTER_ERROR$1 = 'error/HAS_UPPERCASE_LETTER';
|
|
39181
39175
|
const hasUppercaseLetter = createValidator(
|
|
39182
39176
|
HAS_UPPERCASE_LETTER,
|
|
39183
39177
|
HAS_UPPERCASE_LETTER_ERROR$1
|
|
39184
39178
|
);
|
|
39185
39179
|
validatorFns[HAS_UPPERCASE_LETTER] = (value, args, form) => {
|
|
39186
|
-
if (value ===
|
|
39180
|
+
if (value === '') {
|
|
39187
39181
|
return true;
|
|
39188
39182
|
}
|
|
39189
39183
|
return new RegExp(/[A-Z]/).test(value);
|
|
39190
39184
|
};
|
|
39191
39185
|
|
|
39192
|
-
const HAS_SPECIAL_CHARACTER =
|
|
39193
|
-
const HAS_SPECIAL_CHARACTER_ERROR$1 =
|
|
39186
|
+
const HAS_SPECIAL_CHARACTER = 'validator/HAS_SPECIAL_CHARACTER';
|
|
39187
|
+
const HAS_SPECIAL_CHARACTER_ERROR$1 = 'error/HAS_SPECIAL_CHARACTER';
|
|
39194
39188
|
const hasSpecialCharacter = createValidator(
|
|
39195
39189
|
HAS_SPECIAL_CHARACTER,
|
|
39196
39190
|
HAS_SPECIAL_CHARACTER_ERROR$1
|
|
39197
39191
|
);
|
|
39198
39192
|
validatorFns[HAS_SPECIAL_CHARACTER] = (value, args, form) => {
|
|
39199
|
-
if (value ===
|
|
39193
|
+
if (value === '') {
|
|
39200
39194
|
return true;
|
|
39201
39195
|
}
|
|
39202
39196
|
return new RegExp(/[!@#$%^&*.?]/).test(value);
|
|
39203
39197
|
};
|
|
39204
39198
|
|
|
39205
|
-
const IS_PROBABLY_EMAIL =
|
|
39206
|
-
const IS_PROBABLY_EMAIL_ERROR =
|
|
39199
|
+
const IS_PROBABLY_EMAIL = 'validator/IS_PROBABLY_EMAIL';
|
|
39200
|
+
const IS_PROBABLY_EMAIL_ERROR = 'error/IS_PROBABLY_EMAIL';
|
|
39207
39201
|
const isProbablyEmail = createValidator(
|
|
39208
39202
|
IS_PROBABLY_EMAIL,
|
|
39209
39203
|
IS_PROBABLY_EMAIL_ERROR
|
|
39210
39204
|
);
|
|
39211
39205
|
validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
39212
|
-
if (value ===
|
|
39206
|
+
if (value === '') {
|
|
39213
39207
|
return true;
|
|
39214
39208
|
}
|
|
39215
39209
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
39216
39210
|
};
|
|
39217
39211
|
|
|
39218
|
-
const runValidatorErrorMessage = type =>
|
|
39212
|
+
const runValidatorErrorMessage = (type) =>
|
|
39219
39213
|
`${type} was passed to runValidator, but that validator type does not exist.
|
|
39220
39214
|
Please check that you are only calling validator creator functions exported from
|
|
39221
39215
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -39230,1165 +39224,53 @@ const runValidator = (validator, value, form) => {
|
|
|
39230
39224
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
39231
39225
|
};
|
|
39232
39226
|
|
|
39233
|
-
const
|
|
39227
|
+
const runFormValidators = (fieldName, form, validators) => {
|
|
39234
39228
|
return validators
|
|
39235
|
-
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
39236
|
-
.filter(x => x !== null);
|
|
39229
|
+
.map((v) => runValidator(v, form[fieldName].rawValue, form))
|
|
39230
|
+
.filter((x) => x !== null);
|
|
39237
39231
|
};
|
|
39238
39232
|
|
|
39239
39233
|
const computeConstraints = (fieldName, form) => {
|
|
39240
39234
|
const constraints = form[fieldName].constraints;
|
|
39241
|
-
return
|
|
39235
|
+
return runFormValidators(fieldName, form, constraints);
|
|
39242
39236
|
};
|
|
39243
39237
|
|
|
39244
39238
|
const computeErrors = (fieldName, form) => {
|
|
39245
39239
|
const validators = form[fieldName].validators;
|
|
39246
|
-
return
|
|
39247
|
-
};
|
|
39248
|
-
|
|
39249
|
-
var obj;
|
|
39250
|
-
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : ( obj = {}, obj["immer-nothing"] = true, obj );
|
|
39251
|
-
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
39252
|
-
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-state") : "__$immer_state";
|
|
39253
|
-
function isDraft(value) {
|
|
39254
|
-
return !!value && !!value[DRAFT_STATE];
|
|
39255
|
-
}
|
|
39256
|
-
function isDraftable(value) {
|
|
39257
|
-
if (!value) { return false; }
|
|
39258
|
-
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
39259
|
-
}
|
|
39260
|
-
function isPlainObject(value) {
|
|
39261
|
-
if (!value || typeof value !== "object") { return false; }
|
|
39262
|
-
if (Array.isArray(value)) { return true; }
|
|
39263
|
-
var proto = Object.getPrototypeOf(value);
|
|
39264
|
-
return !proto || proto === Object.prototype;
|
|
39265
|
-
}
|
|
39266
|
-
var assign = Object.assign || function assign(target, value) {
|
|
39267
|
-
for (var key in value) {
|
|
39268
|
-
if (has$1(value, key)) {
|
|
39269
|
-
target[key] = value[key];
|
|
39270
|
-
}
|
|
39271
|
-
}
|
|
39272
|
-
|
|
39273
|
-
return target;
|
|
39274
|
-
};
|
|
39275
|
-
var ownKeys$2 = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKeys : typeof Object.getOwnPropertySymbols !== "undefined" ? function (obj) { return Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj)); } : Object.getOwnPropertyNames;
|
|
39276
|
-
function shallowCopy(base, invokeGetters) {
|
|
39277
|
-
if ( invokeGetters === void 0 ) invokeGetters = false;
|
|
39278
|
-
|
|
39279
|
-
if (Array.isArray(base)) { return base.slice(); }
|
|
39280
|
-
var clone = Object.create(Object.getPrototypeOf(base));
|
|
39281
|
-
ownKeys$2(base).forEach(function (key) {
|
|
39282
|
-
if (key === DRAFT_STATE) {
|
|
39283
|
-
return; // Never copy over draft state.
|
|
39284
|
-
}
|
|
39285
|
-
|
|
39286
|
-
var desc = Object.getOwnPropertyDescriptor(base, key);
|
|
39287
|
-
var value = desc.value;
|
|
39288
|
-
|
|
39289
|
-
if (desc.get) {
|
|
39290
|
-
if (!invokeGetters) {
|
|
39291
|
-
throw new Error("Immer drafts cannot have computed properties");
|
|
39292
|
-
}
|
|
39293
|
-
|
|
39294
|
-
value = desc.get.call(base);
|
|
39295
|
-
}
|
|
39296
|
-
|
|
39297
|
-
if (desc.enumerable) {
|
|
39298
|
-
clone[key] = value;
|
|
39299
|
-
} else {
|
|
39300
|
-
Object.defineProperty(clone, key, {
|
|
39301
|
-
value: value,
|
|
39302
|
-
writable: true,
|
|
39303
|
-
configurable: true
|
|
39304
|
-
});
|
|
39305
|
-
}
|
|
39306
|
-
});
|
|
39307
|
-
return clone;
|
|
39308
|
-
}
|
|
39309
|
-
function each(value, cb) {
|
|
39310
|
-
if (Array.isArray(value)) {
|
|
39311
|
-
for (var i = 0; i < value.length; i++) { cb(i, value[i], value); }
|
|
39312
|
-
} else {
|
|
39313
|
-
ownKeys$2(value).forEach(function (key) { return cb(key, value[key], value); });
|
|
39314
|
-
}
|
|
39315
|
-
}
|
|
39316
|
-
function isEnumerable(base, prop) {
|
|
39317
|
-
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
39318
|
-
return !!desc && desc.enumerable;
|
|
39319
|
-
}
|
|
39320
|
-
function has$1(thing, prop) {
|
|
39321
|
-
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
39322
|
-
}
|
|
39323
|
-
function is(x, y) {
|
|
39324
|
-
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
39325
|
-
if (x === y) {
|
|
39326
|
-
return x !== 0 || 1 / x === 1 / y;
|
|
39327
|
-
} else {
|
|
39328
|
-
return x !== x && y !== y;
|
|
39329
|
-
}
|
|
39330
|
-
}
|
|
39331
|
-
function clone(obj) {
|
|
39332
|
-
if (!isDraftable(obj)) { return obj; }
|
|
39333
|
-
if (Array.isArray(obj)) { return obj.map(clone); }
|
|
39334
|
-
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
39335
|
-
|
|
39336
|
-
for (var key in obj) { cloned[key] = clone(obj[key]); }
|
|
39337
|
-
|
|
39338
|
-
return cloned;
|
|
39339
|
-
}
|
|
39340
|
-
|
|
39341
|
-
/** Each scope represents a `produce` call. */
|
|
39342
|
-
|
|
39343
|
-
var ImmerScope = function ImmerScope(parent) {
|
|
39344
|
-
this.drafts = [];
|
|
39345
|
-
this.parent = parent; // Whenever the modified draft contains a draft from another scope, we
|
|
39346
|
-
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
39347
|
-
|
|
39348
|
-
this.canAutoFreeze = true; // To avoid prototype lookups:
|
|
39349
|
-
|
|
39350
|
-
this.patches = null;
|
|
39351
|
-
};
|
|
39352
|
-
|
|
39353
|
-
ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
39354
|
-
if (patchListener) {
|
|
39355
|
-
this.patches = [];
|
|
39356
|
-
this.inversePatches = [];
|
|
39357
|
-
this.patchListener = patchListener;
|
|
39358
|
-
}
|
|
39359
|
-
};
|
|
39360
|
-
|
|
39361
|
-
ImmerScope.prototype.revoke = function revoke$1 () {
|
|
39362
|
-
this.leave();
|
|
39363
|
-
this.drafts.forEach(revoke);
|
|
39364
|
-
this.drafts = null; // Make draft-related methods throw.
|
|
39365
|
-
};
|
|
39366
|
-
|
|
39367
|
-
ImmerScope.prototype.leave = function leave () {
|
|
39368
|
-
if (this === ImmerScope.current) {
|
|
39369
|
-
ImmerScope.current = this.parent;
|
|
39370
|
-
}
|
|
39371
|
-
};
|
|
39372
|
-
ImmerScope.current = null;
|
|
39373
|
-
|
|
39374
|
-
ImmerScope.enter = function () {
|
|
39375
|
-
return this.current = new ImmerScope(this.current);
|
|
39376
|
-
};
|
|
39377
|
-
|
|
39378
|
-
function revoke(draft) {
|
|
39379
|
-
draft[DRAFT_STATE].revoke();
|
|
39380
|
-
}
|
|
39381
|
-
|
|
39382
|
-
// but share them all instead
|
|
39383
|
-
|
|
39384
|
-
var descriptors$1 = {};
|
|
39385
|
-
function willFinalize(scope, result, isReplaced) {
|
|
39386
|
-
scope.drafts.forEach(function (draft) {
|
|
39387
|
-
draft[DRAFT_STATE].finalizing = true;
|
|
39388
|
-
});
|
|
39389
|
-
|
|
39390
|
-
if (!isReplaced) {
|
|
39391
|
-
if (scope.patches) {
|
|
39392
|
-
markChangesRecursively(scope.drafts[0]);
|
|
39393
|
-
} // This is faster when we don't care about which attributes changed.
|
|
39394
|
-
|
|
39395
|
-
|
|
39396
|
-
markChangesSweep(scope.drafts);
|
|
39397
|
-
} // When a child draft is returned, look for changes.
|
|
39398
|
-
else if (isDraft(result) && result[DRAFT_STATE].scope === scope) {
|
|
39399
|
-
markChangesSweep(scope.drafts);
|
|
39400
|
-
}
|
|
39401
|
-
}
|
|
39402
|
-
function createProxy(base, parent) {
|
|
39403
|
-
var isArray = Array.isArray(base);
|
|
39404
|
-
var draft = clonePotentialDraft(base);
|
|
39405
|
-
each(draft, function (prop) {
|
|
39406
|
-
proxyProperty(draft, prop, isArray || isEnumerable(base, prop));
|
|
39407
|
-
}); // See "proxy.js" for property documentation.
|
|
39408
|
-
|
|
39409
|
-
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39410
|
-
var state = {
|
|
39411
|
-
scope: scope,
|
|
39412
|
-
modified: false,
|
|
39413
|
-
finalizing: false,
|
|
39414
|
-
// es5 only
|
|
39415
|
-
finalized: false,
|
|
39416
|
-
assigned: {},
|
|
39417
|
-
parent: parent,
|
|
39418
|
-
base: base,
|
|
39419
|
-
draft: draft,
|
|
39420
|
-
copy: null,
|
|
39421
|
-
revoke: revoke$1,
|
|
39422
|
-
revoked: false // es5 only
|
|
39423
|
-
|
|
39424
|
-
};
|
|
39425
|
-
createHiddenProperty(draft, DRAFT_STATE, state);
|
|
39426
|
-
scope.drafts.push(draft);
|
|
39427
|
-
return draft;
|
|
39428
|
-
}
|
|
39429
|
-
|
|
39430
|
-
function revoke$1() {
|
|
39431
|
-
this.revoked = true;
|
|
39432
|
-
}
|
|
39433
|
-
|
|
39434
|
-
function source(state) {
|
|
39435
|
-
return state.copy || state.base;
|
|
39436
|
-
} // Access a property without creating an Immer draft.
|
|
39437
|
-
|
|
39438
|
-
|
|
39439
|
-
function peek(draft, prop) {
|
|
39440
|
-
var state = draft[DRAFT_STATE];
|
|
39441
|
-
|
|
39442
|
-
if (state && !state.finalizing) {
|
|
39443
|
-
state.finalizing = true;
|
|
39444
|
-
var value = draft[prop];
|
|
39445
|
-
state.finalizing = false;
|
|
39446
|
-
return value;
|
|
39447
|
-
}
|
|
39448
|
-
|
|
39449
|
-
return draft[prop];
|
|
39450
|
-
}
|
|
39451
|
-
|
|
39452
|
-
function get$1(state, prop) {
|
|
39453
|
-
assertUnrevoked(state);
|
|
39454
|
-
var value = peek(source(state), prop);
|
|
39455
|
-
if (state.finalizing) { return value; } // Create a draft if the value is unmodified.
|
|
39456
|
-
|
|
39457
|
-
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
39458
|
-
prepareCopy(state);
|
|
39459
|
-
return state.copy[prop] = createProxy(value, state);
|
|
39460
|
-
}
|
|
39461
|
-
|
|
39462
|
-
return value;
|
|
39463
|
-
}
|
|
39464
|
-
|
|
39465
|
-
function set$1(state, prop, value) {
|
|
39466
|
-
assertUnrevoked(state);
|
|
39467
|
-
state.assigned[prop] = true;
|
|
39468
|
-
|
|
39469
|
-
if (!state.modified) {
|
|
39470
|
-
if (is(value, peek(source(state), prop))) { return; }
|
|
39471
|
-
markChanged(state);
|
|
39472
|
-
prepareCopy(state);
|
|
39473
|
-
}
|
|
39474
|
-
|
|
39475
|
-
state.copy[prop] = value;
|
|
39476
|
-
}
|
|
39477
|
-
|
|
39478
|
-
function markChanged(state) {
|
|
39479
|
-
if (!state.modified) {
|
|
39480
|
-
state.modified = true;
|
|
39481
|
-
if (state.parent) { markChanged(state.parent); }
|
|
39482
|
-
}
|
|
39483
|
-
}
|
|
39484
|
-
|
|
39485
|
-
function prepareCopy(state) {
|
|
39486
|
-
if (!state.copy) { state.copy = clonePotentialDraft(state.base); }
|
|
39487
|
-
}
|
|
39488
|
-
|
|
39489
|
-
function clonePotentialDraft(base) {
|
|
39490
|
-
var state = base && base[DRAFT_STATE];
|
|
39491
|
-
|
|
39492
|
-
if (state) {
|
|
39493
|
-
state.finalizing = true;
|
|
39494
|
-
var draft = shallowCopy(state.draft, true);
|
|
39495
|
-
state.finalizing = false;
|
|
39496
|
-
return draft;
|
|
39497
|
-
}
|
|
39498
|
-
|
|
39499
|
-
return shallowCopy(base);
|
|
39500
|
-
}
|
|
39501
|
-
|
|
39502
|
-
function proxyProperty(draft, prop, enumerable) {
|
|
39503
|
-
var desc = descriptors$1[prop];
|
|
39504
|
-
|
|
39505
|
-
if (desc) {
|
|
39506
|
-
desc.enumerable = enumerable;
|
|
39507
|
-
} else {
|
|
39508
|
-
descriptors$1[prop] = desc = {
|
|
39509
|
-
configurable: true,
|
|
39510
|
-
enumerable: enumerable,
|
|
39511
|
-
|
|
39512
|
-
get: function get$1$1() {
|
|
39513
|
-
return get$1(this[DRAFT_STATE], prop);
|
|
39514
|
-
},
|
|
39515
|
-
|
|
39516
|
-
set: function set$1$1(value) {
|
|
39517
|
-
set$1(this[DRAFT_STATE], prop, value);
|
|
39518
|
-
}
|
|
39519
|
-
|
|
39520
|
-
};
|
|
39521
|
-
}
|
|
39522
|
-
|
|
39523
|
-
Object.defineProperty(draft, prop, desc);
|
|
39524
|
-
}
|
|
39525
|
-
|
|
39526
|
-
function assertUnrevoked(state) {
|
|
39527
|
-
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))); }
|
|
39528
|
-
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
39529
|
-
|
|
39530
|
-
|
|
39531
|
-
function markChangesSweep(drafts) {
|
|
39532
|
-
// The natural order of drafts in the `scope` array is based on when they
|
|
39533
|
-
// were accessed. By processing drafts in reverse natural order, we have a
|
|
39534
|
-
// better chance of processing leaf nodes first. When a leaf node is known to
|
|
39535
|
-
// have changed, we can avoid any traversal of its ancestor nodes.
|
|
39536
|
-
for (var i = drafts.length - 1; i >= 0; i--) {
|
|
39537
|
-
var state = drafts[i][DRAFT_STATE];
|
|
39538
|
-
|
|
39539
|
-
if (!state.modified) {
|
|
39540
|
-
if (Array.isArray(state.base)) {
|
|
39541
|
-
if (hasArrayChanges(state)) { markChanged(state); }
|
|
39542
|
-
} else if (hasObjectChanges(state)) { markChanged(state); }
|
|
39543
|
-
}
|
|
39544
|
-
}
|
|
39545
|
-
}
|
|
39546
|
-
|
|
39547
|
-
function markChangesRecursively(object) {
|
|
39548
|
-
if (!object || typeof object !== "object") { return; }
|
|
39549
|
-
var state = object[DRAFT_STATE];
|
|
39550
|
-
if (!state) { return; }
|
|
39551
|
-
var base = state.base;
|
|
39552
|
-
var draft = state.draft;
|
|
39553
|
-
var assigned = state.assigned;
|
|
39554
|
-
|
|
39555
|
-
if (!Array.isArray(object)) {
|
|
39556
|
-
// Look for added keys.
|
|
39557
|
-
Object.keys(draft).forEach(function (key) {
|
|
39558
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39559
|
-
if (base[key] === undefined && !has$1(base, key)) {
|
|
39560
|
-
assigned[key] = true;
|
|
39561
|
-
markChanged(state);
|
|
39562
|
-
} else if (!assigned[key]) {
|
|
39563
|
-
// Only untouched properties trigger recursion.
|
|
39564
|
-
markChangesRecursively(draft[key]);
|
|
39565
|
-
}
|
|
39566
|
-
}); // Look for removed keys.
|
|
39567
|
-
|
|
39568
|
-
Object.keys(base).forEach(function (key) {
|
|
39569
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39570
|
-
if (draft[key] === undefined && !has$1(draft, key)) {
|
|
39571
|
-
assigned[key] = false;
|
|
39572
|
-
markChanged(state);
|
|
39573
|
-
}
|
|
39574
|
-
});
|
|
39575
|
-
} else if (hasArrayChanges(state)) {
|
|
39576
|
-
markChanged(state);
|
|
39577
|
-
assigned.length = true;
|
|
39578
|
-
|
|
39579
|
-
if (draft.length < base.length) {
|
|
39580
|
-
for (var i = draft.length; i < base.length; i++) { assigned[i] = false; }
|
|
39581
|
-
} else {
|
|
39582
|
-
for (var i$1 = base.length; i$1 < draft.length; i$1++) { assigned[i$1] = true; }
|
|
39583
|
-
}
|
|
39584
|
-
|
|
39585
|
-
for (var i$2 = 0; i$2 < draft.length; i$2++) {
|
|
39586
|
-
// Only untouched indices trigger recursion.
|
|
39587
|
-
if (assigned[i$2] === undefined) { markChangesRecursively(draft[i$2]); }
|
|
39588
|
-
}
|
|
39589
|
-
}
|
|
39590
|
-
}
|
|
39591
|
-
|
|
39592
|
-
function hasObjectChanges(state) {
|
|
39593
|
-
var base = state.base;
|
|
39594
|
-
var draft = state.draft; // Search for added keys and changed keys. Start at the back, because
|
|
39595
|
-
// non-numeric keys are ordered by time of definition on the object.
|
|
39596
|
-
|
|
39597
|
-
var keys = Object.keys(draft);
|
|
39598
|
-
|
|
39599
|
-
for (var i = keys.length - 1; i >= 0; i--) {
|
|
39600
|
-
var key = keys[i];
|
|
39601
|
-
var baseValue = base[key]; // The `undefined` check is a fast path for pre-existing keys.
|
|
39602
|
-
|
|
39603
|
-
if (baseValue === undefined && !has$1(base, key)) {
|
|
39604
|
-
return true;
|
|
39605
|
-
} // Once a base key is deleted, future changes go undetected, because its
|
|
39606
|
-
// descriptor is erased. This branch detects any missed changes.
|
|
39607
|
-
else {
|
|
39608
|
-
var value = draft[key];
|
|
39609
|
-
var state$1 = value && value[DRAFT_STATE];
|
|
39610
|
-
|
|
39611
|
-
if (state$1 ? state$1.base !== baseValue : !is(value, baseValue)) {
|
|
39612
|
-
return true;
|
|
39613
|
-
}
|
|
39614
|
-
}
|
|
39615
|
-
} // At this point, no keys were added or changed.
|
|
39616
|
-
// Compare key count to determine if keys were deleted.
|
|
39617
|
-
|
|
39618
|
-
|
|
39619
|
-
return keys.length !== Object.keys(base).length;
|
|
39620
|
-
}
|
|
39621
|
-
|
|
39622
|
-
function hasArrayChanges(state) {
|
|
39623
|
-
var draft = state.draft;
|
|
39624
|
-
if (draft.length !== state.base.length) { return true; } // See #116
|
|
39625
|
-
// If we first shorten the length, our array interceptors will be removed.
|
|
39626
|
-
// If after that new items are added, result in the same original length,
|
|
39627
|
-
// those last items will have no intercepting property.
|
|
39628
|
-
// So if there is no own descriptor on the last position, we know that items were removed and added
|
|
39629
|
-
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
39630
|
-
// the last one
|
|
39631
|
-
|
|
39632
|
-
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
39633
|
-
|
|
39634
|
-
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
|
|
39635
|
-
|
|
39636
|
-
return false;
|
|
39637
|
-
}
|
|
39638
|
-
|
|
39639
|
-
function createHiddenProperty(target, prop, value) {
|
|
39640
|
-
Object.defineProperty(target, prop, {
|
|
39641
|
-
value: value,
|
|
39642
|
-
enumerable: false,
|
|
39643
|
-
writable: true
|
|
39644
|
-
});
|
|
39645
|
-
}
|
|
39646
|
-
|
|
39647
|
-
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
39648
|
-
willFinalize: willFinalize,
|
|
39649
|
-
createProxy: createProxy
|
|
39650
|
-
});
|
|
39651
|
-
|
|
39652
|
-
function willFinalize$1() {}
|
|
39653
|
-
function createProxy$1(base, parent) {
|
|
39654
|
-
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39655
|
-
var state = {
|
|
39656
|
-
// Track which produce call this is associated with.
|
|
39657
|
-
scope: scope,
|
|
39658
|
-
// True for both shallow and deep changes.
|
|
39659
|
-
modified: false,
|
|
39660
|
-
// Used during finalization.
|
|
39661
|
-
finalized: false,
|
|
39662
|
-
// Track which properties have been assigned (true) or deleted (false).
|
|
39663
|
-
assigned: {},
|
|
39664
|
-
// The parent draft state.
|
|
39665
|
-
parent: parent,
|
|
39666
|
-
// The base state.
|
|
39667
|
-
base: base,
|
|
39668
|
-
// The base proxy.
|
|
39669
|
-
draft: null,
|
|
39670
|
-
// Any property proxies.
|
|
39671
|
-
drafts: {},
|
|
39672
|
-
// The base copy with any updated values.
|
|
39673
|
-
copy: null,
|
|
39674
|
-
// Called by the `produce` function.
|
|
39675
|
-
revoke: null
|
|
39676
|
-
};
|
|
39677
|
-
var ref = Array.isArray(base) ? // [state] is used for arrays, to make sure the proxy is array-ish and not violate invariants,
|
|
39678
|
-
// although state itself is an object
|
|
39679
|
-
Proxy.revocable([state], arrayTraps) : Proxy.revocable(state, objectTraps);
|
|
39680
|
-
var revoke = ref.revoke;
|
|
39681
|
-
var proxy = ref.proxy;
|
|
39682
|
-
state.draft = proxy;
|
|
39683
|
-
state.revoke = revoke;
|
|
39684
|
-
scope.drafts.push(proxy);
|
|
39685
|
-
return proxy;
|
|
39686
|
-
}
|
|
39687
|
-
var objectTraps = {
|
|
39688
|
-
get: get$1$1,
|
|
39689
|
-
|
|
39690
|
-
has: function has(target, prop) {
|
|
39691
|
-
return prop in source$1(target);
|
|
39692
|
-
},
|
|
39693
|
-
|
|
39694
|
-
ownKeys: function ownKeys(target) {
|
|
39695
|
-
return Reflect.ownKeys(source$1(target));
|
|
39696
|
-
},
|
|
39697
|
-
|
|
39698
|
-
set: set$1$1,
|
|
39699
|
-
deleteProperty: deleteProperty,
|
|
39700
|
-
getOwnPropertyDescriptor: getOwnPropertyDescriptor$2,
|
|
39701
|
-
|
|
39702
|
-
defineProperty: function defineProperty() {
|
|
39703
|
-
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
39704
|
-
},
|
|
39705
|
-
|
|
39706
|
-
getPrototypeOf: function getPrototypeOf(target) {
|
|
39707
|
-
return Object.getPrototypeOf(target.base);
|
|
39708
|
-
},
|
|
39709
|
-
|
|
39710
|
-
setPrototypeOf: function setPrototypeOf() {
|
|
39711
|
-
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
39712
|
-
}
|
|
39713
|
-
|
|
39714
|
-
};
|
|
39715
|
-
var arrayTraps = {};
|
|
39716
|
-
each(objectTraps, function (key, fn) {
|
|
39717
|
-
arrayTraps[key] = function () {
|
|
39718
|
-
arguments[0] = arguments[0][0];
|
|
39719
|
-
return fn.apply(this, arguments);
|
|
39720
|
-
};
|
|
39721
|
-
});
|
|
39722
|
-
|
|
39723
|
-
arrayTraps.deleteProperty = function (state, prop) {
|
|
39724
|
-
if (isNaN(parseInt(prop))) {
|
|
39725
|
-
throw new Error("Immer only supports deleting array indices"); // prettier-ignore
|
|
39726
|
-
}
|
|
39727
|
-
|
|
39728
|
-
return objectTraps.deleteProperty.call(this, state[0], prop);
|
|
39729
|
-
};
|
|
39730
|
-
|
|
39731
|
-
arrayTraps.set = function (state, prop, value) {
|
|
39732
|
-
if (prop !== "length" && isNaN(parseInt(prop))) {
|
|
39733
|
-
throw new Error("Immer only supports setting array indices and the 'length' property"); // prettier-ignore
|
|
39734
|
-
}
|
|
39735
|
-
|
|
39736
|
-
return objectTraps.set.call(this, state[0], prop, value);
|
|
39737
|
-
}; // returns the object we should be reading the current value from, which is base, until some change has been made
|
|
39738
|
-
|
|
39739
|
-
|
|
39740
|
-
function source$1(state) {
|
|
39741
|
-
return state.copy || state.base;
|
|
39742
|
-
} // Access a property without creating an Immer draft.
|
|
39743
|
-
|
|
39744
|
-
|
|
39745
|
-
function peek$1(draft, prop) {
|
|
39746
|
-
var state = draft[DRAFT_STATE];
|
|
39747
|
-
var desc = Reflect.getOwnPropertyDescriptor(state ? source$1(state) : draft, prop);
|
|
39748
|
-
return desc && desc.value;
|
|
39749
|
-
}
|
|
39750
|
-
|
|
39751
|
-
function get$1$1(state, prop) {
|
|
39752
|
-
if (prop === DRAFT_STATE) { return state; }
|
|
39753
|
-
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
39754
|
-
|
|
39755
|
-
if (!state.modified && has$1(drafts, prop)) {
|
|
39756
|
-
return drafts[prop];
|
|
39757
|
-
}
|
|
39758
|
-
|
|
39759
|
-
var value = source$1(state)[prop];
|
|
39760
|
-
|
|
39761
|
-
if (state.finalized || !isDraftable(value)) {
|
|
39762
|
-
return value;
|
|
39763
|
-
} // Check for existing draft in modified state.
|
|
39764
|
-
|
|
39765
|
-
|
|
39766
|
-
if (state.modified) {
|
|
39767
|
-
// Assigned values are never drafted. This catches any drafts we created, too.
|
|
39768
|
-
if (value !== peek$1(state.base, prop)) { return value; } // Store drafts on the copy (when one exists).
|
|
39769
|
-
|
|
39770
|
-
drafts = state.copy;
|
|
39771
|
-
}
|
|
39772
|
-
|
|
39773
|
-
return drafts[prop] = createProxy$1(value, state);
|
|
39774
|
-
}
|
|
39775
|
-
|
|
39776
|
-
function set$1$1(state, prop, value) {
|
|
39777
|
-
if (!state.modified) {
|
|
39778
|
-
var baseValue = peek$1(state.base, prop); // Optimize based on value's truthiness. Truthy values are guaranteed to
|
|
39779
|
-
// never be undefined, so we can avoid the `in` operator. Lastly, truthy
|
|
39780
|
-
// values may be drafts, but falsy values are never drafts.
|
|
39781
|
-
|
|
39782
|
-
var isUnchanged = value ? is(baseValue, value) || value === state.drafts[prop] : is(baseValue, value) && prop in state.base;
|
|
39783
|
-
if (isUnchanged) { return true; }
|
|
39784
|
-
markChanged$1(state);
|
|
39785
|
-
}
|
|
39786
|
-
|
|
39787
|
-
state.assigned[prop] = true;
|
|
39788
|
-
state.copy[prop] = value;
|
|
39789
|
-
return true;
|
|
39790
|
-
}
|
|
39791
|
-
|
|
39792
|
-
function deleteProperty(state, prop) {
|
|
39793
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39794
|
-
if (peek$1(state.base, prop) !== undefined || prop in state.base) {
|
|
39795
|
-
state.assigned[prop] = false;
|
|
39796
|
-
markChanged$1(state);
|
|
39797
|
-
} else if (state.assigned[prop]) {
|
|
39798
|
-
// if an originally not assigned property was deleted
|
|
39799
|
-
delete state.assigned[prop];
|
|
39800
|
-
}
|
|
39801
|
-
|
|
39802
|
-
if (state.copy) { delete state.copy[prop]; }
|
|
39803
|
-
return true;
|
|
39804
|
-
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
39805
|
-
// the same guarantee in ES5 mode.
|
|
39806
|
-
|
|
39807
|
-
|
|
39808
|
-
function getOwnPropertyDescriptor$2(state, prop) {
|
|
39809
|
-
var owner = source$1(state);
|
|
39810
|
-
var desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
39811
|
-
|
|
39812
|
-
if (desc) {
|
|
39813
|
-
desc.writable = true;
|
|
39814
|
-
desc.configurable = !Array.isArray(owner) || prop !== "length";
|
|
39815
|
-
}
|
|
39816
|
-
|
|
39817
|
-
return desc;
|
|
39818
|
-
}
|
|
39819
|
-
|
|
39820
|
-
function markChanged$1(state) {
|
|
39821
|
-
if (!state.modified) {
|
|
39822
|
-
state.modified = true;
|
|
39823
|
-
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
39824
|
-
state.drafts = null;
|
|
39825
|
-
if (state.parent) { markChanged$1(state.parent); }
|
|
39826
|
-
}
|
|
39827
|
-
}
|
|
39828
|
-
|
|
39829
|
-
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
39830
|
-
willFinalize: willFinalize$1,
|
|
39831
|
-
createProxy: createProxy$1
|
|
39832
|
-
});
|
|
39833
|
-
|
|
39834
|
-
function generatePatches(state, basePath, patches, inversePatches) {
|
|
39835
|
-
Array.isArray(state.base) ? generateArrayPatches(state, basePath, patches, inversePatches) : generateObjectPatches(state, basePath, patches, inversePatches);
|
|
39836
|
-
}
|
|
39837
|
-
|
|
39838
|
-
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
39839
|
-
var assign, assign$1;
|
|
39840
|
-
|
|
39841
|
-
var base = state.base;
|
|
39842
|
-
var copy = state.copy;
|
|
39843
|
-
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
39844
|
-
|
|
39845
|
-
if (copy.length < base.length) {
|
|
39846
|
-
(assign = [copy, base], base = assign[0], copy = assign[1]);
|
|
39847
|
-
(assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1]);
|
|
39848
|
-
}
|
|
39849
|
-
|
|
39850
|
-
var delta = copy.length - base.length; // Find the first replaced index.
|
|
39851
|
-
|
|
39852
|
-
var start = 0;
|
|
39853
|
-
|
|
39854
|
-
while (base[start] === copy[start] && start < base.length) {
|
|
39855
|
-
++start;
|
|
39856
|
-
} // Find the last replaced index. Search from the end to optimize splice patches.
|
|
39857
|
-
|
|
39858
|
-
|
|
39859
|
-
var end = base.length;
|
|
39860
|
-
|
|
39861
|
-
while (end > start && base[end - 1] === copy[end + delta - 1]) {
|
|
39862
|
-
--end;
|
|
39863
|
-
} // Process replaced indices.
|
|
39864
|
-
|
|
39865
|
-
|
|
39866
|
-
for (var i = start; i < end; ++i) {
|
|
39867
|
-
if (assigned[i] && copy[i] !== base[i]) {
|
|
39868
|
-
var path = basePath.concat([i]);
|
|
39869
|
-
patches.push({
|
|
39870
|
-
op: "replace",
|
|
39871
|
-
path: path,
|
|
39872
|
-
value: copy[i]
|
|
39873
|
-
});
|
|
39874
|
-
inversePatches.push({
|
|
39875
|
-
op: "replace",
|
|
39876
|
-
path: path,
|
|
39877
|
-
value: base[i]
|
|
39878
|
-
});
|
|
39879
|
-
}
|
|
39880
|
-
}
|
|
39881
|
-
|
|
39882
|
-
var replaceCount = patches.length; // Process added indices.
|
|
39883
|
-
|
|
39884
|
-
for (var i$1 = end + delta - 1; i$1 >= end; --i$1) {
|
|
39885
|
-
var path$1 = basePath.concat([i$1]);
|
|
39886
|
-
patches[replaceCount + i$1 - end] = {
|
|
39887
|
-
op: "add",
|
|
39888
|
-
path: path$1,
|
|
39889
|
-
value: copy[i$1]
|
|
39890
|
-
};
|
|
39891
|
-
inversePatches.push({
|
|
39892
|
-
op: "remove",
|
|
39893
|
-
path: path$1
|
|
39894
|
-
});
|
|
39895
|
-
}
|
|
39896
|
-
}
|
|
39897
|
-
|
|
39898
|
-
function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
39899
|
-
var base = state.base;
|
|
39900
|
-
var copy = state.copy;
|
|
39901
|
-
each(state.assigned, function (key, assignedValue) {
|
|
39902
|
-
var origValue = base[key];
|
|
39903
|
-
var value = copy[key];
|
|
39904
|
-
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
39905
|
-
if (origValue === value && op === "replace") { return; }
|
|
39906
|
-
var path = basePath.concat(key);
|
|
39907
|
-
patches.push(op === "remove" ? {
|
|
39908
|
-
op: op,
|
|
39909
|
-
path: path
|
|
39910
|
-
} : {
|
|
39911
|
-
op: op,
|
|
39912
|
-
path: path,
|
|
39913
|
-
value: value
|
|
39914
|
-
});
|
|
39915
|
-
inversePatches.push(op === "add" ? {
|
|
39916
|
-
op: "remove",
|
|
39917
|
-
path: path
|
|
39918
|
-
} : op === "remove" ? {
|
|
39919
|
-
op: "add",
|
|
39920
|
-
path: path,
|
|
39921
|
-
value: origValue
|
|
39922
|
-
} : {
|
|
39923
|
-
op: "replace",
|
|
39924
|
-
path: path,
|
|
39925
|
-
value: origValue
|
|
39926
|
-
});
|
|
39927
|
-
});
|
|
39928
|
-
}
|
|
39929
|
-
|
|
39930
|
-
var applyPatches = function (draft, patches) {
|
|
39931
|
-
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
39932
|
-
var patch = list[i$1];
|
|
39933
|
-
|
|
39934
|
-
var path = patch.path;
|
|
39935
|
-
var op = patch.op;
|
|
39936
|
-
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
39937
|
-
|
|
39938
|
-
if (!path.length) { throw new Error("Illegal state"); }
|
|
39939
|
-
var base = draft;
|
|
39940
|
-
|
|
39941
|
-
for (var i = 0; i < path.length - 1; i++) {
|
|
39942
|
-
base = base[path[i]];
|
|
39943
|
-
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
39944
|
-
}
|
|
39945
|
-
|
|
39946
|
-
var key = path[path.length - 1];
|
|
39947
|
-
|
|
39948
|
-
switch (op) {
|
|
39949
|
-
case "replace":
|
|
39950
|
-
// if value is an object, then it's assigned by reference
|
|
39951
|
-
// in the following add or remove ops, the value field inside the patch will also be modifyed
|
|
39952
|
-
// so we use value from the cloned patch
|
|
39953
|
-
base[key] = value;
|
|
39954
|
-
break;
|
|
39955
|
-
|
|
39956
|
-
case "add":
|
|
39957
|
-
if (Array.isArray(base)) {
|
|
39958
|
-
// TODO: support "foo/-" paths for appending to an array
|
|
39959
|
-
base.splice(key, 0, value);
|
|
39960
|
-
} else {
|
|
39961
|
-
base[key] = value;
|
|
39962
|
-
}
|
|
39963
|
-
|
|
39964
|
-
break;
|
|
39965
|
-
|
|
39966
|
-
case "remove":
|
|
39967
|
-
if (Array.isArray(base)) {
|
|
39968
|
-
base.splice(key, 1);
|
|
39969
|
-
} else {
|
|
39970
|
-
delete base[key];
|
|
39971
|
-
}
|
|
39972
|
-
|
|
39973
|
-
break;
|
|
39974
|
-
|
|
39975
|
-
default:
|
|
39976
|
-
throw new Error("Unsupported patch operation: " + op);
|
|
39977
|
-
}
|
|
39978
|
-
}
|
|
39979
|
-
|
|
39980
|
-
return draft;
|
|
39240
|
+
return runFormValidators(fieldName, form, validators);
|
|
39981
39241
|
};
|
|
39982
39242
|
|
|
39983
|
-
|
|
39984
|
-
|
|
39985
|
-
|
|
39986
|
-
|
|
39987
|
-
|
|
39988
|
-
|
|
39989
|
-
|
|
39990
|
-
onCopy: null
|
|
39991
|
-
};
|
|
39992
|
-
var Immer = function Immer(config) {
|
|
39993
|
-
assign(this, configDefaults, config);
|
|
39994
|
-
this.setUseProxies(this.useProxies);
|
|
39995
|
-
this.produce = this.produce.bind(this);
|
|
39996
|
-
};
|
|
39997
|
-
|
|
39998
|
-
Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
39999
|
-
var this$1$1 = this;
|
|
40000
|
-
|
|
40001
|
-
// curried invocation
|
|
40002
|
-
if (typeof base === "function" && typeof recipe !== "function") {
|
|
40003
|
-
var defaultBase = recipe;
|
|
40004
|
-
recipe = base;
|
|
40005
|
-
var self = this;
|
|
40006
|
-
return function curriedProduce(base) {
|
|
40007
|
-
var this$1$1 = this;
|
|
40008
|
-
if ( base === void 0 ) base = defaultBase;
|
|
40009
|
-
var args = [], len = arguments.length - 1;
|
|
40010
|
-
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
40011
|
-
|
|
40012
|
-
return self.produce(base, function (draft) { return recipe.call.apply(recipe, [ this$1$1, draft ].concat( args )); }); // prettier-ignore
|
|
40013
|
-
};
|
|
40014
|
-
} // prettier-ignore
|
|
40015
|
-
|
|
40016
|
-
|
|
40017
|
-
{
|
|
40018
|
-
if (typeof recipe !== "function") {
|
|
40019
|
-
throw new Error("The first or second argument to `produce` must be a function");
|
|
40020
|
-
}
|
|
40021
|
-
|
|
40022
|
-
if (patchListener !== undefined && typeof patchListener !== "function") {
|
|
40023
|
-
throw new Error("The third argument to `produce` must be a function or undefined");
|
|
40024
|
-
}
|
|
40025
|
-
}
|
|
40026
|
-
var result; // Only plain objects, arrays, and "immerable classes" are drafted.
|
|
40027
|
-
|
|
40028
|
-
if (isDraftable(base)) {
|
|
40029
|
-
var scope = ImmerScope.enter();
|
|
40030
|
-
var proxy = this.createProxy(base);
|
|
40031
|
-
var hasError = true;
|
|
40032
|
-
|
|
40033
|
-
try {
|
|
40034
|
-
result = recipe(proxy);
|
|
40035
|
-
hasError = false;
|
|
40036
|
-
} finally {
|
|
40037
|
-
// finally instead of catch + rethrow better preserves original stack
|
|
40038
|
-
if (hasError) { scope.revoke(); }else { scope.leave(); }
|
|
40039
|
-
}
|
|
40040
|
-
|
|
40041
|
-
if (result instanceof Promise) {
|
|
40042
|
-
return result.then(function (result) {
|
|
40043
|
-
scope.usePatches(patchListener);
|
|
40044
|
-
return this$1$1.processResult(result, scope);
|
|
40045
|
-
}, function (error) {
|
|
40046
|
-
scope.revoke();
|
|
40047
|
-
throw error;
|
|
40048
|
-
});
|
|
40049
|
-
}
|
|
40050
|
-
|
|
40051
|
-
scope.usePatches(patchListener);
|
|
40052
|
-
return this.processResult(result, scope);
|
|
40053
|
-
} else {
|
|
40054
|
-
result = recipe(base);
|
|
40055
|
-
if (result === undefined) { return base; }
|
|
40056
|
-
return result !== NOTHING ? result : undefined;
|
|
39243
|
+
const computeErrorEntries = (formState) => {
|
|
39244
|
+
const fields = Object.entries(formState);
|
|
39245
|
+
for (let entry of fields) {
|
|
39246
|
+
let fieldName = entry[0];
|
|
39247
|
+
let errors = computeErrors(fieldName, formState);
|
|
39248
|
+
formState[fieldName].errors = errors;
|
|
39249
|
+
formState[fieldName].hasErrors = errors.length > 0;
|
|
40057
39250
|
}
|
|
40058
39251
|
};
|
|
40059
39252
|
|
|
40060
|
-
|
|
40061
|
-
|
|
40062
|
-
|
|
40063
|
-
|
|
40064
|
-
|
|
40065
|
-
|
|
40066
|
-
|
|
40067
|
-
|
|
40068
|
-
return this$1$1.produceWithPatches(state, function (draft) { return arg1.apply(void 0, [ draft ].concat( args )); });
|
|
40069
|
-
};
|
|
40070
|
-
} // non-curried form
|
|
40071
|
-
|
|
40072
|
-
|
|
40073
|
-
if (arg3) { throw new Error("A patch listener cannot be passed to produceWithPatches"); }
|
|
40074
|
-
var patches, inversePatches;
|
|
40075
|
-
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
40076
|
-
patches = p;
|
|
40077
|
-
inversePatches = ip;
|
|
40078
|
-
});
|
|
40079
|
-
return [nextState, patches, inversePatches];
|
|
40080
|
-
};
|
|
40081
|
-
|
|
40082
|
-
Immer.prototype.createDraft = function createDraft (base) {
|
|
40083
|
-
if (!isDraftable(base)) {
|
|
40084
|
-
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
40085
|
-
}
|
|
40086
|
-
|
|
40087
|
-
var scope = ImmerScope.enter();
|
|
40088
|
-
var proxy = this.createProxy(base);
|
|
40089
|
-
proxy[DRAFT_STATE].isManual = true;
|
|
40090
|
-
scope.leave();
|
|
40091
|
-
return proxy;
|
|
40092
|
-
};
|
|
40093
|
-
|
|
40094
|
-
Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
40095
|
-
var state = draft && draft[DRAFT_STATE];
|
|
40096
|
-
|
|
40097
|
-
if (!state || !state.isManual) {
|
|
40098
|
-
throw new Error("First argument to `finishDraft` must be a draft returned by `createDraft`"); // prettier-ignore
|
|
40099
|
-
}
|
|
40100
|
-
|
|
40101
|
-
if (state.finalized) {
|
|
40102
|
-
throw new Error("The given draft is already finalized"); // prettier-ignore
|
|
39253
|
+
const computeDirtyEntries = (formState, changedFieldName) => {
|
|
39254
|
+
const fields = Object.entries(formState);
|
|
39255
|
+
for (let entry of fields) {
|
|
39256
|
+
let fieldName = entry[0];
|
|
39257
|
+
let field = entry[1];
|
|
39258
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
39259
|
+
formState[fieldName].dirty = dirty;
|
|
40103
39260
|
}
|
|
40104
|
-
|
|
40105
|
-
var scope = state.scope;
|
|
40106
|
-
scope.usePatches(patchListener);
|
|
40107
|
-
return this.processResult(undefined, scope);
|
|
40108
39261
|
};
|
|
40109
39262
|
|
|
40110
|
-
Immer.prototype.setAutoFreeze = function setAutoFreeze (value) {
|
|
40111
|
-
this.autoFreeze = value;
|
|
40112
|
-
};
|
|
39263
|
+
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$1(n,r){return 2===o(n)?n.get(r):n[r]}function f$6(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c$1(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$1(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$1("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$1("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$1("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$1("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$6(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$1("MapSet").F(r,t):v(r)?b$1("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$1("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$1("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$1(u.t,r)===t||f$6(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$1(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$1("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$1("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;
|
|
40113
39264
|
|
|
40114
|
-
|
|
40115
|
-
this.useProxies = value;
|
|
40116
|
-
assign(this, value ? modernProxy : legacyProxy);
|
|
40117
|
-
};
|
|
40118
|
-
|
|
40119
|
-
Immer.prototype.applyPatches = function applyPatches$1 (base, patches) {
|
|
40120
|
-
// If a patch replaces the entire state, take that replacement as base
|
|
40121
|
-
// before applying patches
|
|
40122
|
-
var i;
|
|
40123
|
-
|
|
40124
|
-
for (i = patches.length - 1; i >= 0; i--) {
|
|
40125
|
-
var patch = patches[i];
|
|
40126
|
-
|
|
40127
|
-
if (patch.path.length === 0 && patch.op === "replace") {
|
|
40128
|
-
base = patch.value;
|
|
40129
|
-
break;
|
|
40130
|
-
}
|
|
40131
|
-
}
|
|
40132
|
-
|
|
40133
|
-
if (isDraft(base)) {
|
|
40134
|
-
// N.B: never hits if some patch a replacement, patches are never drafts
|
|
40135
|
-
return applyPatches(base, patches);
|
|
40136
|
-
} // Otherwise, produce a copy of the base state.
|
|
40137
|
-
|
|
40138
|
-
|
|
40139
|
-
return this.produce(base, function (draft) { return applyPatches(draft, patches.slice(i + 1)); });
|
|
40140
|
-
};
|
|
40141
|
-
/** @internal */
|
|
40142
|
-
|
|
40143
|
-
|
|
40144
|
-
Immer.prototype.processResult = function processResult (result, scope) {
|
|
40145
|
-
var baseDraft = scope.drafts[0];
|
|
40146
|
-
var isReplaced = result !== undefined && result !== baseDraft;
|
|
40147
|
-
this.willFinalize(scope, result, isReplaced);
|
|
40148
|
-
|
|
40149
|
-
if (isReplaced) {
|
|
40150
|
-
if (baseDraft[DRAFT_STATE].modified) {
|
|
40151
|
-
scope.revoke();
|
|
40152
|
-
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
|
|
40153
|
-
}
|
|
40154
|
-
|
|
40155
|
-
if (isDraftable(result)) {
|
|
40156
|
-
// Finalize the result in case it contains (or is) a subset of the draft.
|
|
40157
|
-
result = this.finalize(result, null, scope);
|
|
40158
|
-
}
|
|
40159
|
-
|
|
40160
|
-
if (scope.patches) {
|
|
40161
|
-
scope.patches.push({
|
|
40162
|
-
op: "replace",
|
|
40163
|
-
path: [],
|
|
40164
|
-
value: result
|
|
40165
|
-
});
|
|
40166
|
-
scope.inversePatches.push({
|
|
40167
|
-
op: "replace",
|
|
40168
|
-
path: [],
|
|
40169
|
-
value: baseDraft[DRAFT_STATE].base
|
|
40170
|
-
});
|
|
40171
|
-
}
|
|
40172
|
-
} else {
|
|
40173
|
-
// Finalize the base draft.
|
|
40174
|
-
result = this.finalize(baseDraft, [], scope);
|
|
40175
|
-
}
|
|
40176
|
-
|
|
40177
|
-
scope.revoke();
|
|
40178
|
-
|
|
40179
|
-
if (scope.patches) {
|
|
40180
|
-
scope.patchListener(scope.patches, scope.inversePatches);
|
|
40181
|
-
}
|
|
40182
|
-
|
|
40183
|
-
return result !== NOTHING ? result : undefined;
|
|
40184
|
-
};
|
|
40185
|
-
/**
|
|
40186
|
-
* @internal
|
|
40187
|
-
* Finalize a draft, returning either the unmodified base state or a modified
|
|
40188
|
-
* copy of the base state.
|
|
40189
|
-
*/
|
|
40190
|
-
|
|
40191
|
-
|
|
40192
|
-
Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
40193
|
-
var this$1$1 = this;
|
|
40194
|
-
|
|
40195
|
-
var state = draft[DRAFT_STATE];
|
|
40196
|
-
|
|
40197
|
-
if (!state) {
|
|
40198
|
-
if (Object.isFrozen(draft)) { return draft; }
|
|
40199
|
-
return this.finalizeTree(draft, null, scope);
|
|
40200
|
-
} // Never finalize drafts owned by another scope.
|
|
40201
|
-
|
|
40202
|
-
|
|
40203
|
-
if (state.scope !== scope) {
|
|
40204
|
-
return draft;
|
|
40205
|
-
}
|
|
40206
|
-
|
|
40207
|
-
if (!state.modified) {
|
|
40208
|
-
return state.base;
|
|
40209
|
-
}
|
|
40210
|
-
|
|
40211
|
-
if (!state.finalized) {
|
|
40212
|
-
state.finalized = true;
|
|
40213
|
-
this.finalizeTree(state.draft, path, scope);
|
|
40214
|
-
|
|
40215
|
-
if (this.onDelete) {
|
|
40216
|
-
// The `assigned` object is unreliable with ES5 drafts.
|
|
40217
|
-
if (this.useProxies) {
|
|
40218
|
-
var assigned = state.assigned;
|
|
40219
|
-
|
|
40220
|
-
for (var prop in assigned) {
|
|
40221
|
-
if (!assigned[prop]) { this.onDelete(state, prop); }
|
|
40222
|
-
}
|
|
40223
|
-
} else {
|
|
40224
|
-
var base = state.base;
|
|
40225
|
-
var copy = state.copy;
|
|
40226
|
-
each(base, function (prop) {
|
|
40227
|
-
if (!has$1(copy, prop)) { this$1$1.onDelete(state, prop); }
|
|
40228
|
-
});
|
|
40229
|
-
}
|
|
40230
|
-
}
|
|
40231
|
-
|
|
40232
|
-
if (this.onCopy) {
|
|
40233
|
-
this.onCopy(state);
|
|
40234
|
-
} // At this point, all descendants of `state.copy` have been finalized,
|
|
40235
|
-
// so we can be sure that `scope.canAutoFreeze` is accurate.
|
|
40236
|
-
|
|
40237
|
-
|
|
40238
|
-
if (this.autoFreeze && scope.canAutoFreeze) {
|
|
40239
|
-
Object.freeze(state.copy);
|
|
40240
|
-
}
|
|
40241
|
-
|
|
40242
|
-
if (path && scope.patches) {
|
|
40243
|
-
generatePatches(state, path, scope.patches, scope.inversePatches);
|
|
40244
|
-
}
|
|
40245
|
-
}
|
|
40246
|
-
|
|
40247
|
-
return state.copy;
|
|
40248
|
-
};
|
|
40249
|
-
/**
|
|
40250
|
-
* @internal
|
|
40251
|
-
* Finalize all drafts in the given state tree.
|
|
40252
|
-
*/
|
|
40253
|
-
|
|
40254
|
-
|
|
40255
|
-
Immer.prototype.finalizeTree = function finalizeTree (root, rootPath, scope) {
|
|
40256
|
-
var this$1$1 = this;
|
|
40257
|
-
|
|
40258
|
-
var state = root[DRAFT_STATE];
|
|
40259
|
-
|
|
40260
|
-
if (state) {
|
|
40261
|
-
if (!this.useProxies) {
|
|
40262
|
-
// Create the final copy, with added keys and without deleted keys.
|
|
40263
|
-
state.copy = shallowCopy(state.draft, true);
|
|
40264
|
-
}
|
|
40265
|
-
|
|
40266
|
-
root = state.copy;
|
|
40267
|
-
}
|
|
40268
|
-
|
|
40269
|
-
var needPatches = !!rootPath && !!scope.patches;
|
|
40270
|
-
|
|
40271
|
-
var finalizeProperty = function (prop, value, parent) {
|
|
40272
|
-
if (value === parent) {
|
|
40273
|
-
throw Error("Immer forbids circular references");
|
|
40274
|
-
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
40275
|
-
|
|
40276
|
-
|
|
40277
|
-
var isDraftProp = !!state && parent === root;
|
|
40278
|
-
|
|
40279
|
-
if (isDraft(value)) {
|
|
40280
|
-
var path = isDraftProp && needPatches && !state.assigned[prop] ? rootPath.concat(prop) : null; // Drafts owned by `scope` are finalized here.
|
|
40281
|
-
|
|
40282
|
-
value = this$1$1.finalize(value, path, scope); // Drafts from another scope must prevent auto-freezing.
|
|
40283
|
-
|
|
40284
|
-
if (isDraft(value)) {
|
|
40285
|
-
scope.canAutoFreeze = false;
|
|
40286
|
-
} // Preserve non-enumerable properties.
|
|
40287
|
-
|
|
40288
|
-
|
|
40289
|
-
if (Array.isArray(parent) || isEnumerable(parent, prop)) {
|
|
40290
|
-
parent[prop] = value;
|
|
40291
|
-
} else {
|
|
40292
|
-
Object.defineProperty(parent, prop, {
|
|
40293
|
-
value: value
|
|
40294
|
-
});
|
|
40295
|
-
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
40296
|
-
|
|
40297
|
-
|
|
40298
|
-
if (isDraftProp && value === state.base[prop]) { return; }
|
|
40299
|
-
} // Unchanged draft properties are ignored.
|
|
40300
|
-
else if (isDraftProp && is(value, state.base[prop])) {
|
|
40301
|
-
return;
|
|
40302
|
-
} // Search new objects for unfinalized drafts. Frozen objects should never contain drafts.
|
|
40303
|
-
else if (isDraftable(value) && !Object.isFrozen(value)) {
|
|
40304
|
-
each(value, finalizeProperty);
|
|
40305
|
-
}
|
|
40306
|
-
|
|
40307
|
-
if (isDraftProp && this$1$1.onAssign) {
|
|
40308
|
-
this$1$1.onAssign(state, prop, value);
|
|
40309
|
-
}
|
|
40310
|
-
};
|
|
40311
|
-
|
|
40312
|
-
each(root, finalizeProperty);
|
|
40313
|
-
return root;
|
|
40314
|
-
};
|
|
40315
|
-
|
|
40316
|
-
var immer = new Immer();
|
|
40317
|
-
/**
|
|
40318
|
-
* The `produce` function takes a value and a "recipe function" (whose
|
|
40319
|
-
* return value often depends on the base state). The recipe function is
|
|
40320
|
-
* free to mutate its first argument however it wants. All mutations are
|
|
40321
|
-
* only ever applied to a __copy__ of the base state.
|
|
40322
|
-
*
|
|
40323
|
-
* Pass only a function to create a "curried producer" which relieves you
|
|
40324
|
-
* from passing the recipe function every time.
|
|
40325
|
-
*
|
|
40326
|
-
* Only plain objects and arrays are made mutable. All other objects are
|
|
40327
|
-
* considered uncopyable.
|
|
40328
|
-
*
|
|
40329
|
-
* Note: This function is __bound__ to its `Immer` instance.
|
|
40330
|
-
*
|
|
40331
|
-
* @param {any} base - the initial state
|
|
40332
|
-
* @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified
|
|
40333
|
-
* @param {Function} patchListener - optional function that will be called with all the patches produced here
|
|
40334
|
-
* @returns {any} a new state, or the initial state if nothing was modified
|
|
40335
|
-
*/
|
|
40336
|
-
|
|
40337
|
-
var produce = immer.produce;
|
|
40338
|
-
/**
|
|
40339
|
-
* Like `produce`, but `produceWithPatches` always returns a tuple
|
|
40340
|
-
* [nextState, patches, inversePatches] (instead of just the next state)
|
|
40341
|
-
*/
|
|
40342
|
-
|
|
40343
|
-
immer.produceWithPatches.bind(immer);
|
|
40344
|
-
/**
|
|
40345
|
-
* Pass true to automatically freeze all copies created by Immer.
|
|
40346
|
-
*
|
|
40347
|
-
* By default, auto-freezing is disabled in production.
|
|
40348
|
-
*/
|
|
40349
|
-
|
|
40350
|
-
immer.setAutoFreeze.bind(immer);
|
|
40351
|
-
/**
|
|
40352
|
-
* Pass true to use the ES2015 `Proxy` class when creating drafts, which is
|
|
40353
|
-
* always faster than using ES5 proxies.
|
|
40354
|
-
*
|
|
40355
|
-
* By default, feature detection is used, so calling this is rarely necessary.
|
|
40356
|
-
*/
|
|
40357
|
-
|
|
40358
|
-
immer.setUseProxies.bind(immer);
|
|
40359
|
-
/**
|
|
40360
|
-
* Apply an array of Immer patches to the first argument.
|
|
40361
|
-
*
|
|
40362
|
-
* This function is a producer, which means copy-on-write is in effect.
|
|
40363
|
-
*/
|
|
40364
|
-
|
|
40365
|
-
immer.applyPatches.bind(immer);
|
|
40366
|
-
/**
|
|
40367
|
-
* Create an Immer draft from the given base state, which may be a draft itself.
|
|
40368
|
-
* The draft can be modified until you finalize it with the `finishDraft` function.
|
|
40369
|
-
*/
|
|
40370
|
-
|
|
40371
|
-
immer.createDraft.bind(immer);
|
|
40372
|
-
/**
|
|
40373
|
-
* Finalize an Immer draft from a `createDraft` call, returning the base state
|
|
40374
|
-
* (if no changes were made) or a modified copy. The draft must *not* be
|
|
40375
|
-
* mutated afterwards.
|
|
40376
|
-
*
|
|
40377
|
-
* Pass a function as the 2nd argument to generate Immer patches based on the
|
|
40378
|
-
* changes that were made.
|
|
40379
|
-
*/
|
|
40380
|
-
|
|
40381
|
-
immer.finishDraft.bind(immer);
|
|
40382
|
-
|
|
40383
|
-
const createInitialState = formConfig => {
|
|
39265
|
+
const createInitialState = (formConfig) => {
|
|
40384
39266
|
let initialForm = {};
|
|
40385
39267
|
const formConfigKeys = Object.keys(formConfig);
|
|
40386
39268
|
for (let formKey of formConfigKeys) {
|
|
40387
39269
|
initialForm[formKey] = {
|
|
40388
39270
|
dirty: false,
|
|
40389
|
-
rawValue: formConfig[formKey].defaultValue ||
|
|
39271
|
+
rawValue: formConfig[formKey].defaultValue || '',
|
|
40390
39272
|
validators: formConfig[formKey].validators || [],
|
|
40391
|
-
constraints: formConfig[formKey].constraints || []
|
|
39273
|
+
constraints: formConfig[formKey].constraints || [],
|
|
40392
39274
|
};
|
|
40393
39275
|
}
|
|
40394
39276
|
// Because validators require the entire form we have to do a
|
|
@@ -40399,82 +39281,99 @@ const createInitialState = formConfig => {
|
|
|
40399
39281
|
initialForm[formKey].errors = errors;
|
|
40400
39282
|
initialForm[formKey].hasErrors = errors.length > 0;
|
|
40401
39283
|
}
|
|
39284
|
+
|
|
40402
39285
|
return initialForm;
|
|
40403
39286
|
};
|
|
40404
39287
|
|
|
40405
|
-
const SET =
|
|
40406
|
-
const set$
|
|
39288
|
+
const SET = 'field/SET';
|
|
39289
|
+
const set$1 = (fieldName) => (value) => ({
|
|
40407
39290
|
type: SET,
|
|
40408
|
-
payload: { fieldName, value }
|
|
39291
|
+
payload: { fieldName, value },
|
|
40409
39292
|
});
|
|
40410
39293
|
|
|
40411
|
-
const CLEAR =
|
|
39294
|
+
const CLEAR = 'form/CLEAR';
|
|
40412
39295
|
const clear = () => ({ type: CLEAR });
|
|
40413
39296
|
|
|
40414
|
-
const ADD_VALIDATOR =
|
|
40415
|
-
const addValidator = fieldName => validator => ({
|
|
39297
|
+
const ADD_VALIDATOR = 'field/ADD_VALIDATOR';
|
|
39298
|
+
const addValidator = (fieldName) => (validator) => ({
|
|
40416
39299
|
type: ADD_VALIDATOR,
|
|
40417
|
-
payload: { fieldName, validator }
|
|
39300
|
+
payload: { fieldName, validator },
|
|
40418
39301
|
});
|
|
40419
39302
|
|
|
40420
|
-
const
|
|
40421
|
-
|
|
40422
|
-
|
|
40423
|
-
|
|
40424
|
-
|
|
40425
|
-
case SET:
|
|
40426
|
-
const changedFieldName = action.payload.fieldName;
|
|
40427
|
-
const newRawValue = action.payload.value;
|
|
40428
|
-
|
|
40429
|
-
return produce(state, draftState => {
|
|
40430
|
-
let originalValue = draftState[changedFieldName].rawValue;
|
|
40431
|
-
draftState[changedFieldName].rawValue = newRawValue;
|
|
40432
|
-
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
40433
|
-
// If the change violates constraints, revert the change
|
|
40434
|
-
draftState[changedFieldName].rawValue = originalValue;
|
|
40435
|
-
return draftState;
|
|
40436
|
-
}
|
|
39303
|
+
const REMOVE_VALIDATOR = 'field/REMOVE_VALIDATOR';
|
|
39304
|
+
const removeValidator = (fieldName) => (validator) => ({
|
|
39305
|
+
type: REMOVE_VALIDATOR,
|
|
39306
|
+
payload: { fieldName, validator },
|
|
39307
|
+
});
|
|
40437
39308
|
|
|
40438
|
-
|
|
40439
|
-
|
|
40440
|
-
|
|
40441
|
-
|
|
40442
|
-
|
|
40443
|
-
|
|
40444
|
-
|
|
40445
|
-
|
|
40446
|
-
|
|
40447
|
-
|
|
40448
|
-
|
|
40449
|
-
|
|
40450
|
-
|
|
40451
|
-
|
|
40452
|
-
|
|
40453
|
-
|
|
40454
|
-
|
|
40455
|
-
|
|
40456
|
-
|
|
40457
|
-
|
|
40458
|
-
|
|
40459
|
-
|
|
40460
|
-
|
|
40461
|
-
|
|
40462
|
-
|
|
40463
|
-
|
|
40464
|
-
|
|
40465
|
-
|
|
40466
|
-
|
|
40467
|
-
|
|
40468
|
-
|
|
40469
|
-
|
|
40470
|
-
|
|
40471
|
-
|
|
39309
|
+
const CLEAR_FIELD_VALIDATORS = 'field/CLEAR_FIELD_VALIDATORS';
|
|
39310
|
+
const clearFieldValidators = (fieldName) => () => ({
|
|
39311
|
+
type: CLEAR_FIELD_VALIDATORS,
|
|
39312
|
+
payload: { fieldName },
|
|
39313
|
+
});
|
|
39314
|
+
|
|
39315
|
+
const createFormReducer =
|
|
39316
|
+
(formConfig) =>
|
|
39317
|
+
(state = createInitialState(formConfig), action) => {
|
|
39318
|
+
switch (action.type) {
|
|
39319
|
+
case SET: {
|
|
39320
|
+
const changedFieldName = action.payload.fieldName;
|
|
39321
|
+
const newRawValue = action.payload.value;
|
|
39322
|
+
|
|
39323
|
+
return produce(state, (draftState) => {
|
|
39324
|
+
let originalValue = draftState[changedFieldName].rawValue;
|
|
39325
|
+
draftState[changedFieldName].rawValue = newRawValue;
|
|
39326
|
+
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
39327
|
+
// If the change violates constraints, revert the change
|
|
39328
|
+
draftState[changedFieldName].rawValue = originalValue;
|
|
39329
|
+
return draftState;
|
|
39330
|
+
}
|
|
39331
|
+
|
|
39332
|
+
computeDirtyEntries(draftState, changedFieldName);
|
|
39333
|
+
computeErrorEntries(draftState);
|
|
39334
|
+
});
|
|
39335
|
+
}
|
|
39336
|
+
case CLEAR:
|
|
39337
|
+
return createInitialState(formConfig);
|
|
39338
|
+
case ADD_VALIDATOR: {
|
|
39339
|
+
const fieldWithOverride = action.payload.fieldName;
|
|
39340
|
+
const newValidator = action.payload.validator;
|
|
39341
|
+
|
|
39342
|
+
return produce(state, (draftState) => {
|
|
39343
|
+
draftState[fieldWithOverride].validators.push(newValidator);
|
|
39344
|
+
computeErrorEntries(draftState);
|
|
39345
|
+
});
|
|
39346
|
+
}
|
|
39347
|
+
case REMOVE_VALIDATOR: {
|
|
39348
|
+
const fieldToOverride = action.payload.fieldName;
|
|
39349
|
+
const targetValidator = action.payload.validator;
|
|
39350
|
+
|
|
39351
|
+
return produce(state, (draftState) => {
|
|
39352
|
+
let fieldValidators = draftState[fieldToOverride].validators;
|
|
39353
|
+
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
39354
|
+
(validator) => validator.type !== targetValidator.type
|
|
39355
|
+
);
|
|
39356
|
+
computeErrorEntries(draftState);
|
|
39357
|
+
});
|
|
39358
|
+
}
|
|
39359
|
+
case CLEAR_FIELD_VALIDATORS: {
|
|
39360
|
+
const fieldToClear = action.payload.fieldName;
|
|
39361
|
+
|
|
39362
|
+
return produce(state, (draftState) => {
|
|
39363
|
+
draftState[fieldToClear].validators = [];
|
|
39364
|
+
computeErrorEntries(draftState);
|
|
39365
|
+
});
|
|
39366
|
+
}
|
|
39367
|
+
default:
|
|
39368
|
+
return state;
|
|
39369
|
+
}
|
|
39370
|
+
};
|
|
40472
39371
|
|
|
40473
|
-
const createMapDispatchToProps = formConfig => {
|
|
39372
|
+
const createMapDispatchToProps = (formConfig) => {
|
|
40474
39373
|
// Do memo-ization
|
|
40475
39374
|
let cachedDispatch;
|
|
40476
39375
|
let cacheValue;
|
|
40477
|
-
return dispatch => {
|
|
39376
|
+
return (dispatch) => {
|
|
40478
39377
|
if (dispatch == cachedDispatch) {
|
|
40479
39378
|
return cacheValue;
|
|
40480
39379
|
}
|
|
@@ -40483,8 +39382,11 @@ const createMapDispatchToProps = formConfig => {
|
|
|
40483
39382
|
const keys = Object.keys(formConfig);
|
|
40484
39383
|
for (let fieldName of keys) {
|
|
40485
39384
|
dispatchObj.fields[fieldName] = {
|
|
40486
|
-
set: value => dispatch(set$
|
|
40487
|
-
addValidator: validator => dispatch(addValidator(fieldName)(validator))
|
|
39385
|
+
set: (value) => dispatch(set$1(fieldName)(value)),
|
|
39386
|
+
addValidator: (validator) => dispatch(addValidator(fieldName)(validator)),
|
|
39387
|
+
removeValidator: (validator) =>
|
|
39388
|
+
dispatch(removeValidator(fieldName)(validator)),
|
|
39389
|
+
clear: () => dispatch(clearFieldValidators(fieldName)()),
|
|
40488
39390
|
};
|
|
40489
39391
|
}
|
|
40490
39392
|
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
@@ -40494,12 +39396,12 @@ const createMapDispatchToProps = formConfig => {
|
|
|
40494
39396
|
};
|
|
40495
39397
|
};
|
|
40496
39398
|
|
|
40497
|
-
const mapStateToProps = state => ({ fields: state });
|
|
39399
|
+
const mapStateToProps = (state) => ({ fields: state });
|
|
40498
39400
|
|
|
40499
|
-
const createFormState = formConfig => ({
|
|
39401
|
+
const createFormState = (formConfig) => ({
|
|
40500
39402
|
reducer: createFormReducer(formConfig),
|
|
40501
39403
|
mapDispatchToProps: createMapDispatchToProps(formConfig),
|
|
40502
|
-
mapStateToProps: mapStateToProps
|
|
39404
|
+
mapStateToProps: mapStateToProps,
|
|
40503
39405
|
});
|
|
40504
39406
|
|
|
40505
39407
|
var AddressForm = function AddressForm(_ref) {
|
|
@@ -43364,12 +42266,12 @@ LoginForm.mapDispatchToProps = mapDispatchToProps$5;
|
|
|
43364
42266
|
* This source code is licensed under the MIT license found in the
|
|
43365
42267
|
* LICENSE file in the root directory of this source tree.
|
|
43366
42268
|
*/
|
|
43367
|
-
var b$
|
|
43368
|
-
Symbol.for("react.suspense_list"):60120,r=b$
|
|
43369
|
-
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c$
|
|
43370
|
-
var Profiler=g;var StrictMode=f$
|
|
43371
|
-
var isMemo=function(a){return z(a)===r};var isPortal=function(a){return z(a)===d};var isProfiler=function(a){return z(a)===g};var isStrictMode=function(a){return z(a)===f$
|
|
43372
|
-
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f$
|
|
42269
|
+
var b$2="function"===typeof Symbol&&Symbol.for,c$2=b$2?Symbol.for("react.element"):60103,d$1=b$2?Symbol.for("react.portal"):60106,e=b$2?Symbol.for("react.fragment"):60107,f$7=b$2?Symbol.for("react.strict_mode"):60108,g$1=b$2?Symbol.for("react.profiler"):60114,h$1=b$2?Symbol.for("react.provider"):60109,k$1=b$2?Symbol.for("react.context"):60110,l$1=b$2?Symbol.for("react.async_mode"):60111,m=b$2?Symbol.for("react.concurrent_mode"):60111,n$1=b$2?Symbol.for("react.forward_ref"):60112,p$1=b$2?Symbol.for("react.suspense"):60113,q$1=b$2?
|
|
42270
|
+
Symbol.for("react.suspense_list"):60120,r$1=b$2?Symbol.for("react.memo"):60115,t$1=b$2?Symbol.for("react.lazy"):60116,v$1=b$2?Symbol.for("react.block"):60121,w$1=b$2?Symbol.for("react.fundamental"):60117,x$1=b$2?Symbol.for("react.responder"):60118,y$1=b$2?Symbol.for("react.scope"):60119;
|
|
42271
|
+
function z$1(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c$2:switch(a=a.type,a){case l$1:case m:case e:case g$1:case f$7:case p$1:return a;default:switch(a=a&&a.$$typeof,a){case k$1:case n$1:case t$1:case r$1:case h$1:return a;default:return u}}case d$1:return u}}}function A$1(a){return z$1(a)===m}var AsyncMode=l$1;var ConcurrentMode=m;var ContextConsumer=k$1;var ContextProvider=h$1;var Element$1=c$2;var ForwardRef=n$1;var Fragment=e;var Lazy=t$1;var Memo=r$1;var Portal=d$1;
|
|
42272
|
+
var Profiler=g$1;var StrictMode=f$7;var Suspense=p$1;var isAsyncMode=function(a){return A$1(a)||z$1(a)===l$1};var isConcurrentMode=A$1;var isContextConsumer=function(a){return z$1(a)===k$1};var isContextProvider=function(a){return z$1(a)===h$1};var isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c$2};var isForwardRef=function(a){return z$1(a)===n$1};var isFragment=function(a){return z$1(a)===e};var isLazy=function(a){return z$1(a)===t$1};
|
|
42273
|
+
var isMemo=function(a){return z$1(a)===r$1};var isPortal=function(a){return z$1(a)===d$1};var isProfiler=function(a){return z$1(a)===g$1};var isStrictMode=function(a){return z$1(a)===f$7};var isSuspense=function(a){return z$1(a)===p$1};
|
|
42274
|
+
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g$1||a===f$7||a===p$1||a===q$1||"object"===typeof a&&null!==a&&(a.$$typeof===t$1||a.$$typeof===r$1||a.$$typeof===h$1||a.$$typeof===k$1||a.$$typeof===n$1||a.$$typeof===w$1||a.$$typeof===x$1||a.$$typeof===y$1||a.$$typeof===v$1)};var typeOf=z$1;
|
|
43373
42275
|
|
|
43374
42276
|
var reactIs_production_min = {
|
|
43375
42277
|
AsyncMode: AsyncMode,
|
|
@@ -43740,14 +42642,14 @@ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
|
43740
42642
|
|
|
43741
42643
|
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
43742
42644
|
|
|
43743
|
-
var has$
|
|
42645
|
+
var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
43744
42646
|
|
|
43745
42647
|
var printWarning = function() {};
|
|
43746
42648
|
|
|
43747
42649
|
if (process.env.NODE_ENV !== 'production') {
|
|
43748
42650
|
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
43749
42651
|
var loggedTypeFailures = {};
|
|
43750
|
-
var has$
|
|
42652
|
+
var has$2 = has$1;
|
|
43751
42653
|
|
|
43752
42654
|
printWarning = function(text) {
|
|
43753
42655
|
var message = 'Warning: ' + text;
|
|
@@ -43777,7 +42679,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
43777
42679
|
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
43778
42680
|
if (process.env.NODE_ENV !== 'production') {
|
|
43779
42681
|
for (var typeSpecName in typeSpecs) {
|
|
43780
|
-
if (has$
|
|
42682
|
+
if (has$2(typeSpecs, typeSpecName)) {
|
|
43781
42683
|
var error;
|
|
43782
42684
|
// Prop type validation may throw. In case they do, we don't want to
|
|
43783
42685
|
// fail the render phase where it didn't fail before. So we log it.
|
|
@@ -44176,7 +43078,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44176
43078
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
44177
43079
|
}
|
|
44178
43080
|
for (var key in propValue) {
|
|
44179
|
-
if (has$
|
|
43081
|
+
if (has$1(propValue, key)) {
|
|
44180
43082
|
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
44181
43083
|
if (error instanceof Error) {
|
|
44182
43084
|
return error;
|
|
@@ -44213,7 +43115,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44213
43115
|
if (checkerResult == null) {
|
|
44214
43116
|
return null;
|
|
44215
43117
|
}
|
|
44216
|
-
if (checkerResult.data && has$
|
|
43118
|
+
if (checkerResult.data && has$1(checkerResult.data, 'expectedType')) {
|
|
44217
43119
|
expectedTypes.push(checkerResult.data.expectedType);
|
|
44218
43120
|
}
|
|
44219
43121
|
}
|
|
@@ -44273,7 +43175,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44273
43175
|
var allKeys = objectAssign({}, props[propName], shapeTypes);
|
|
44274
43176
|
for (var key in allKeys) {
|
|
44275
43177
|
var checker = shapeTypes[key];
|
|
44276
|
-
if (has$
|
|
43178
|
+
if (has$1(shapeTypes, key) && typeof checker !== 'function') {
|
|
44277
43179
|
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
44278
43180
|
}
|
|
44279
43181
|
if (!checker) {
|
|
@@ -45011,7 +43913,7 @@ var index_esm = /*#__PURE__*/Object.freeze({
|
|
|
45011
43913
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
45012
43914
|
*/
|
|
45013
43915
|
|
|
45014
|
-
function ownKeys$
|
|
43916
|
+
function ownKeys$2(object, enumerableOnly) {
|
|
45015
43917
|
var keys = Object.keys(object);
|
|
45016
43918
|
|
|
45017
43919
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -45027,9 +43929,9 @@ function ownKeys$3(object, enumerableOnly) {
|
|
|
45027
43929
|
function _objectSpread2$1(target) {
|
|
45028
43930
|
for (var i = 1; i < arguments.length; i++) {
|
|
45029
43931
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
45030
|
-
i % 2 ? ownKeys$
|
|
43932
|
+
i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) {
|
|
45031
43933
|
_defineProperty$1(target, key, source[key]);
|
|
45032
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$
|
|
43934
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) {
|
|
45033
43935
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
45034
43936
|
});
|
|
45035
43937
|
}
|