@thecb/components 9.0.0-beta.8 → 9.0.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 +311 -1369
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +311 -1370
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/atoms/country-dropdown/CountryDropdown.js +1 -1
- package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +0 -1
- package/src/components/atoms/dropdown/Dropdown.js +9 -9
- package/src/components/atoms/form-layouts/FormInput.js +2 -3
- package/src/components/atoms/form-layouts/index.d.ts +1 -1
- package/src/components/atoms/form-select/index.d.ts +1 -1
- package/src/components/molecules/account-and-routing-modal/AccountAndRoutingModal.js +0 -1
- package/src/components/molecules/link-card/index.d.ts +1 -1
- package/src/components/molecules/partial-amount-form/PartialAmountForm.state.js +40 -22
- package/src/components/molecules/partial-amount-form/index.js +9 -2
- package/src/components/molecules/payment-details/PaymentDetails.js +36 -16
- package/src/components/molecules/phone-form/PhoneForm.js +1 -0
- package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV1.js +1 -2
- package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV2.js +0 -1
- package/src/components/atoms/state-province-dropdown/index.d.ts +0 -26
package/dist/index.cjs.js
CHANGED
|
@@ -24072,13 +24072,14 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
24072
24072
|
"data-qa": choice.text,
|
|
24073
24073
|
themeValues: themeValues,
|
|
24074
24074
|
title: hasTitles ? choice.text : null,
|
|
24075
|
+
role: "option",
|
|
24075
24076
|
onFocus: function onFocus() {
|
|
24076
24077
|
return setFocusedRef(optionRefs.current[i]);
|
|
24077
24078
|
}
|
|
24078
24079
|
}, /*#__PURE__*/React__default.createElement(Text$1, {
|
|
24079
24080
|
variant: "p",
|
|
24080
24081
|
color: choice.value === value ? WHITE : disabledValues.includes(choice.value) ? STORM_GREY : MINESHAFT_GREY,
|
|
24081
|
-
extraStyles: "padding-left: 16px; \n
|
|
24082
|
+
extraStyles: "padding-left: 16px; \n cursor: ".concat(disabledValues.includes(choice.value) ? "default" : "pointer", "; \n white-space: nowrap; \n overflow: hidden; \n text-overflow: ellipsis;")
|
|
24082
24083
|
}, choice.text));
|
|
24083
24084
|
}))) : /*#__PURE__*/React__default.createElement(React.Fragment, null)));
|
|
24084
24085
|
};
|
|
@@ -25010,7 +25011,8 @@ var options = [{
|
|
|
25010
25011
|
}];
|
|
25011
25012
|
|
|
25012
25013
|
var CountryDropdown = function CountryDropdown(_ref) {
|
|
25013
|
-
var
|
|
25014
|
+
var _ref$labelTextWhenNoE = _ref.labelTextWhenNoError,
|
|
25015
|
+
labelTextWhenNoError = _ref$labelTextWhenNoE === void 0 ? "Country" : _ref$labelTextWhenNoE,
|
|
25014
25016
|
errorMessages = _ref.errorMessages,
|
|
25015
25017
|
field = _ref.field,
|
|
25016
25018
|
fieldActions = _ref.fieldActions,
|
|
@@ -25955,10 +25957,11 @@ var FormInput = function FormInput(_ref15) {
|
|
|
25955
25957
|
background = _ref15.background,
|
|
25956
25958
|
customHeight = _ref15.customHeight,
|
|
25957
25959
|
_ref15$autocompleteVa = _ref15.autocompleteValue,
|
|
25958
|
-
autocompleteValue = _ref15$autocompleteVa === void 0 ?
|
|
25960
|
+
autocompleteValue = _ref15$autocompleteVa === void 0 ? null : _ref15$autocompleteVa,
|
|
25959
25961
|
extraStyles = _ref15.extraStyles,
|
|
25960
25962
|
removeFromValue = _ref15.removeFromValue,
|
|
25961
|
-
dataQa = _ref15.dataQa,
|
|
25963
|
+
_ref15$dataQa = _ref15.dataQa,
|
|
25964
|
+
dataQa = _ref15$dataQa === void 0 ? null : _ref15$dataQa,
|
|
25962
25965
|
props = _objectWithoutProperties(_ref15, _excluded2);
|
|
25963
25966
|
|
|
25964
25967
|
var _useState = React.useState(false),
|
|
@@ -26069,8 +26072,7 @@ var FormInput = function FormInput(_ref15) {
|
|
|
26069
26072
|
direction: "row",
|
|
26070
26073
|
justify: "space-between",
|
|
26071
26074
|
"aria-live": "polite",
|
|
26072
|
-
"aria-atomic": true
|
|
26073
|
-
"data-qa": "".concat(labelTextWhenNoError, " error message")
|
|
26075
|
+
"aria-atomic": true
|
|
26074
26076
|
}, field.hasErrors && field.dirty || field.hasErrors && showErrors ? /*#__PURE__*/React__default.createElement(Text$1, {
|
|
26075
26077
|
color: ERROR_COLOR,
|
|
26076
26078
|
variant: "pXS",
|
|
@@ -38593,44 +38595,52 @@ var TableHeading_styled = styled__default.th.withConfig({
|
|
|
38593
38595
|
return extraStyles;
|
|
38594
38596
|
});
|
|
38595
38597
|
|
|
38596
|
-
const validatorToPredicate =
|
|
38597
|
-
|
|
38598
|
-
...rest
|
|
38599
|
-
|
|
38598
|
+
const validatorToPredicate =
|
|
38599
|
+
(validatorFn, emptyCase) =>
|
|
38600
|
+
(value, ...rest) =>
|
|
38601
|
+
value === '' ? emptyCase : validatorFn(value, ...rest);
|
|
38600
38602
|
|
|
38601
38603
|
var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
38602
38604
|
|
|
38605
|
+
function getDefaultExportFromCjs (x) {
|
|
38606
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
38607
|
+
}
|
|
38608
|
+
|
|
38603
38609
|
var dayjs_min = {exports: {}};
|
|
38604
38610
|
|
|
38605
38611
|
(function (module, exports) {
|
|
38606
|
-
!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"
|
|
38607
|
-
}(dayjs_min));
|
|
38612
|
+
!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}));
|
|
38613
|
+
} (dayjs_min));
|
|
38608
38614
|
|
|
38609
|
-
var
|
|
38615
|
+
var dayjs_minExports = dayjs_min.exports;
|
|
38616
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
38610
38617
|
|
|
38611
38618
|
var customParseFormat$1 = {exports: {}};
|
|
38612
38619
|
|
|
38613
38620
|
(function (module, exports) {
|
|
38614
|
-
!function(t
|
|
38615
|
-
}(customParseFormat$1));
|
|
38621
|
+
!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);};}}));
|
|
38622
|
+
} (customParseFormat$1));
|
|
38616
38623
|
|
|
38617
|
-
var
|
|
38624
|
+
var customParseFormatExports = customParseFormat$1.exports;
|
|
38625
|
+
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
38618
38626
|
|
|
38619
38627
|
var isSameOrBefore$1 = {exports: {}};
|
|
38620
38628
|
|
|
38621
38629
|
(function (module, exports) {
|
|
38622
|
-
!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)};}}));
|
|
38623
|
-
}(isSameOrBefore$1));
|
|
38630
|
+
!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)};}}));
|
|
38631
|
+
} (isSameOrBefore$1));
|
|
38624
38632
|
|
|
38625
|
-
var
|
|
38633
|
+
var isSameOrBeforeExports = isSameOrBefore$1.exports;
|
|
38634
|
+
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);
|
|
38626
38635
|
|
|
38627
38636
|
var isSameOrAfter$1 = {exports: {}};
|
|
38628
38637
|
|
|
38629
38638
|
(function (module, exports) {
|
|
38630
|
-
!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)};}}));
|
|
38631
|
-
}(isSameOrAfter$1));
|
|
38639
|
+
!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)};}}));
|
|
38640
|
+
} (isSameOrAfter$1));
|
|
38632
38641
|
|
|
38633
|
-
var
|
|
38642
|
+
var isSameOrAfterExports = isSameOrAfter$1.exports;
|
|
38643
|
+
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);
|
|
38634
38644
|
|
|
38635
38645
|
/* eslint-disable no-unused-vars */
|
|
38636
38646
|
|
|
@@ -38646,24 +38656,24 @@ dayjs.extend(isSameOrAfter);
|
|
|
38646
38656
|
|
|
38647
38657
|
let validatorFns = {};
|
|
38648
38658
|
|
|
38649
|
-
const INCLUDED_IN =
|
|
38650
|
-
const INCLUDED_IN_ERROR =
|
|
38659
|
+
const INCLUDED_IN = 'validator/INCLUDED_IN';
|
|
38660
|
+
const INCLUDED_IN_ERROR = 'error/INCLUDED_IN';
|
|
38651
38661
|
const includedIn = createValidator(INCLUDED_IN, INCLUDED_IN_ERROR);
|
|
38652
38662
|
validatorFns[INCLUDED_IN] = (value, args, form) =>
|
|
38653
38663
|
Array.isArray(args[0]) ? args[0].includes(value) : args[0] === value;
|
|
38654
38664
|
|
|
38655
|
-
const REQUIRED =
|
|
38656
|
-
const REQUIRED_ERROR =
|
|
38665
|
+
const REQUIRED = 'validator/REQUIRED';
|
|
38666
|
+
const REQUIRED_ERROR = 'error/REQUIRED';
|
|
38657
38667
|
const required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
38658
|
-
validatorFns[REQUIRED] = (value, args, form) => value !==
|
|
38668
|
+
validatorFns[REQUIRED] = (value, args, form) => value !== '';
|
|
38659
38669
|
|
|
38660
|
-
const ONLY_INTEGERS =
|
|
38661
|
-
const ONLY_INTEGERS_ERROR =
|
|
38670
|
+
const ONLY_INTEGERS = 'validator/ONLY_INTEGERS';
|
|
38671
|
+
const ONLY_INTEGERS_ERROR = 'error/ONLY_INTEGERS';
|
|
38662
38672
|
const onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
38663
38673
|
validatorFns[ONLY_INTEGERS] = (value, args, form) => /^(-?\d+)?$/.test(value);
|
|
38664
38674
|
|
|
38665
|
-
const ONLY_NATURALS =
|
|
38666
|
-
const ONLY_NATURALS_ERROR =
|
|
38675
|
+
const ONLY_NATURALS = 'validator/ONLY_NATURALS';
|
|
38676
|
+
const ONLY_NATURALS_ERROR = 'error/ONLY_NATURALS';
|
|
38667
38677
|
const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
38668
38678
|
validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
|
|
38669
38679
|
|
|
@@ -38676,8 +38686,8 @@ not tested as validation function
|
|
|
38676
38686
|
to validate exp date instead use combo of:
|
|
38677
38687
|
required(), hasLength(), isValidMonth(), dateAfterToday()
|
|
38678
38688
|
*/
|
|
38679
|
-
const ONLY_EXPIRATION_DATE =
|
|
38680
|
-
const ONLY_EXPIRATION_DATE_ERROR =
|
|
38689
|
+
const ONLY_EXPIRATION_DATE = 'validator/ONLY_EXPIRATION_DATE';
|
|
38690
|
+
const ONLY_EXPIRATION_DATE_ERROR = 'error/ONLY_EXPIRATION_DATE';
|
|
38681
38691
|
const onlyExpirationDate = createValidator(
|
|
38682
38692
|
ONLY_EXPIRATION_DATE,
|
|
38683
38693
|
ONLY_EXPIRATION_DATE_ERROR
|
|
@@ -38685,64 +38695,63 @@ const onlyExpirationDate = createValidator(
|
|
|
38685
38695
|
validatorFns[ONLY_EXPIRATION_DATE] = (value, args, form) =>
|
|
38686
38696
|
/^(\d?\d?\/?\d?\d?)?$/.test(value);
|
|
38687
38697
|
|
|
38688
|
-
const NUMBER_LESS_THAN =
|
|
38689
|
-
const NUMBER_LESS_THAN_ERROR =
|
|
38698
|
+
const NUMBER_LESS_THAN = 'validator/NUMBER_LESS_THAN';
|
|
38699
|
+
const NUMBER_LESS_THAN_ERROR = 'error/NUMBER_LESS_THAN';
|
|
38690
38700
|
const numberLessThan = createValidator(
|
|
38691
38701
|
NUMBER_LESS_THAN,
|
|
38692
38702
|
NUMBER_LESS_THAN_ERROR
|
|
38693
38703
|
);
|
|
38694
38704
|
validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
38695
|
-
if (value ===
|
|
38705
|
+
if (value === '') {
|
|
38696
38706
|
return true;
|
|
38697
38707
|
}
|
|
38698
38708
|
return Number(value) < args[0];
|
|
38699
38709
|
};
|
|
38700
38710
|
|
|
38701
|
-
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
38702
|
-
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
38711
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO = 'validator/NUMBER_LESS_THAN_OR_EQUAL_TO';
|
|
38703
38712
|
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
38704
|
-
|
|
38713
|
+
'error/NUMBER_LESS_THAN_OR_EQUAL_TO';
|
|
38705
38714
|
const numberLessThanOrEqualTo = createValidator(
|
|
38706
38715
|
NUMBER_LESS_THAN_OR_EQUAL_TO,
|
|
38707
38716
|
NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR
|
|
38708
38717
|
);
|
|
38709
38718
|
validatorFns[NUMBER_LESS_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38710
|
-
if (value ===
|
|
38719
|
+
if (value === '') {
|
|
38711
38720
|
return true;
|
|
38712
38721
|
}
|
|
38713
38722
|
return Number(value) <= args[0];
|
|
38714
38723
|
};
|
|
38715
38724
|
|
|
38716
|
-
const NUMBER_GREATER_THAN =
|
|
38717
|
-
const NUMBER_GREATER_THAN_ERROR =
|
|
38725
|
+
const NUMBER_GREATER_THAN = 'validator/NUMBER_GREATER_THAN';
|
|
38726
|
+
const NUMBER_GREATER_THAN_ERROR = 'error/NUMBER_GREATER_THAN';
|
|
38718
38727
|
const numberGreaterThan = createValidator(
|
|
38719
38728
|
NUMBER_GREATER_THAN,
|
|
38720
38729
|
NUMBER_GREATER_THAN_ERROR
|
|
38721
38730
|
);
|
|
38722
38731
|
validatorFns[NUMBER_GREATER_THAN] = (value, args, form) => {
|
|
38723
|
-
if (value ===
|
|
38732
|
+
if (value === '') {
|
|
38724
38733
|
return true;
|
|
38725
38734
|
}
|
|
38726
38735
|
return Number(value) > args[0];
|
|
38727
38736
|
};
|
|
38728
38737
|
|
|
38729
38738
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO =
|
|
38730
|
-
|
|
38739
|
+
'validator/NUMBER_GREATER_THAN_OR_EQUAL_TO';
|
|
38731
38740
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR =
|
|
38732
|
-
|
|
38741
|
+
'error/NUMBER_GREATER_THAN_OR_EQUAL_TO';
|
|
38733
38742
|
const numberGreaterThanOrEqualTo = createValidator(
|
|
38734
38743
|
NUMBER_GREATER_THAN_OR_EQUAL_TO,
|
|
38735
38744
|
NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR
|
|
38736
38745
|
);
|
|
38737
38746
|
validatorFns[NUMBER_GREATER_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38738
|
-
if (value ===
|
|
38747
|
+
if (value === '') {
|
|
38739
38748
|
return true;
|
|
38740
38749
|
}
|
|
38741
38750
|
return Number(value) >= args[0];
|
|
38742
38751
|
};
|
|
38743
38752
|
|
|
38744
|
-
const MATCHES_FIELD =
|
|
38745
|
-
const MATCHES_FIELD_ERROR$1 =
|
|
38753
|
+
const MATCHES_FIELD = 'validator/MATCHES_FIELD';
|
|
38754
|
+
const MATCHES_FIELD_ERROR$1 = 'error/MATCHES_FIELD';
|
|
38746
38755
|
const matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
|
|
38747
38756
|
validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
38748
38757
|
const dependentField = form[args[0]];
|
|
@@ -38755,7 +38764,7 @@ validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
|
38755
38764
|
return value === dependentFieldValue;
|
|
38756
38765
|
};
|
|
38757
38766
|
|
|
38758
|
-
const validateWhenErrorMessage = type =>
|
|
38767
|
+
const validateWhenErrorMessage = (type) =>
|
|
38759
38768
|
`${type} was passed to validateWhen, but that validator type does not exist.
|
|
38760
38769
|
Please check that you are only calling validator creator functions exported from
|
|
38761
38770
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -38763,25 +38772,21 @@ const validateWhenErrorMessage = type =>
|
|
|
38763
38772
|
createFormState). Also make sure you aren't passing validateWhen() to validateWhen
|
|
38764
38773
|
as the primary validator.`;
|
|
38765
38774
|
|
|
38766
|
-
const VALIDATE_WHEN =
|
|
38767
|
-
const VALIDATE_WHEN_ERROR =
|
|
38768
|
-
const validateWhen = (
|
|
38769
|
-
dependentValidator,
|
|
38770
|
-
primaryValidator,
|
|
38771
|
-
optionalFieldName
|
|
38772
|
-
) => ({
|
|
38775
|
+
const VALIDATE_WHEN = 'validator/VALIDATE_WHEN';
|
|
38776
|
+
const VALIDATE_WHEN_ERROR = 'error/VALIDATE_WHEN';
|
|
38777
|
+
const validateWhen = (dependentValidator, primaryValidator, optionalFieldName) => ({
|
|
38773
38778
|
type: VALIDATE_WHEN,
|
|
38774
38779
|
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
38775
|
-
error: dependentValidator.error
|
|
38780
|
+
error: dependentValidator.error,
|
|
38776
38781
|
});
|
|
38777
38782
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
38778
38783
|
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
38779
38784
|
const [dependentValidator, primaryValidator, optionalFieldName] = args;
|
|
38780
|
-
const dependsOnOtherField = typeof optionalFieldName ===
|
|
38785
|
+
const dependsOnOtherField = typeof optionalFieldName === 'string';
|
|
38781
38786
|
|
|
38782
38787
|
if (
|
|
38783
38788
|
primaryValidator.type === undefined ||
|
|
38784
|
-
typeof validatorFns[primaryValidator.type] !==
|
|
38789
|
+
typeof validatorFns[primaryValidator.type] !== 'function'
|
|
38785
38790
|
) {
|
|
38786
38791
|
throw new Error(validateWhenErrorMessage(primaryValidator.type));
|
|
38787
38792
|
}
|
|
@@ -38805,26 +38810,22 @@ validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
|
38805
38810
|
);
|
|
38806
38811
|
|
|
38807
38812
|
return primaryPredicatePassed
|
|
38808
|
-
? validatorFns[dependentValidator.type](
|
|
38809
|
-
value,
|
|
38810
|
-
dependentValidator.args,
|
|
38811
|
-
form
|
|
38812
|
-
)
|
|
38813
|
+
? validatorFns[dependentValidator.type](value, dependentValidator.args, form)
|
|
38813
38814
|
: true;
|
|
38814
38815
|
};
|
|
38815
38816
|
|
|
38816
|
-
const validateSumErrorMessage = type =>
|
|
38817
|
+
const validateSumErrorMessage = (type) =>
|
|
38817
38818
|
`${type} was passed to validateSum, but that validator type does not exist.
|
|
38818
38819
|
Please check that you are only calling validator creator functions exported from
|
|
38819
38820
|
redux-freeform in your form config and that you didn't forget to
|
|
38820
38821
|
invoke the validator creator (you cannot pass the functions themselves to
|
|
38821
38822
|
createFormState).`;
|
|
38822
|
-
const VALIDATE_SUM =
|
|
38823
|
-
const VALIDATE_SUM_ERROR =
|
|
38823
|
+
const VALIDATE_SUM = 'validator/VALIDATE_SUM';
|
|
38824
|
+
const VALIDATE_SUM_ERROR = 'error/VALIDATE_SUM';
|
|
38824
38825
|
const validateSum = (validator, fieldNamesArray) => ({
|
|
38825
38826
|
type: VALIDATE_SUM,
|
|
38826
38827
|
args: [validator, fieldNamesArray],
|
|
38827
|
-
error: validator.error
|
|
38828
|
+
error: validator.error,
|
|
38828
38829
|
});
|
|
38829
38830
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
38830
38831
|
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
@@ -38832,7 +38833,7 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38832
38833
|
|
|
38833
38834
|
if (
|
|
38834
38835
|
validator.type === undefined ||
|
|
38835
|
-
typeof validatorFns[validator.type] !==
|
|
38836
|
+
typeof validatorFns[validator.type] !== 'function'
|
|
38836
38837
|
) {
|
|
38837
38838
|
throw new Error(validateSumErrorMessage(validator.type));
|
|
38838
38839
|
}
|
|
@@ -38853,37 +38854,35 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38853
38854
|
return validatorFns[validator.type](sum, validator.args, form);
|
|
38854
38855
|
};
|
|
38855
38856
|
|
|
38856
|
-
const HAS_LENGTH =
|
|
38857
|
-
const HAS_LENGTH_ERROR =
|
|
38857
|
+
const HAS_LENGTH = 'validator/HAS_LENGTH';
|
|
38858
|
+
const HAS_LENGTH_ERROR = 'error/HAS_LENGTH';
|
|
38858
38859
|
const hasLength = createValidator(HAS_LENGTH, HAS_LENGTH_ERROR);
|
|
38859
38860
|
validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
38860
|
-
if (value ===
|
|
38861
|
+
if (value === '') {
|
|
38861
38862
|
return true;
|
|
38862
38863
|
}
|
|
38863
38864
|
const min = args[0];
|
|
38864
38865
|
const max = args[1];
|
|
38865
38866
|
if (max == undefined || min == undefined) {
|
|
38866
38867
|
throw new Error(
|
|
38867
|
-
|
|
38868
|
+
'Max and min need to be defined for hasLength, both or one of them is undefined'
|
|
38868
38869
|
);
|
|
38869
38870
|
}
|
|
38870
38871
|
if (max < min) {
|
|
38871
|
-
throw new Error(
|
|
38872
|
-
"hasLength validator was passed a min greater than the max"
|
|
38873
|
-
);
|
|
38872
|
+
throw new Error('hasLength validator was passed a min greater than the max');
|
|
38874
38873
|
}
|
|
38875
38874
|
const valueLength = value.length;
|
|
38876
38875
|
return max >= valueLength && valueLength >= min;
|
|
38877
38876
|
};
|
|
38878
38877
|
|
|
38879
|
-
const DATE_BEFORE_TODAY =
|
|
38880
|
-
const DATE_BEFORE_TODAY_ERROR =
|
|
38878
|
+
const DATE_BEFORE_TODAY = 'validator/DATE_BEFORE_TODAY';
|
|
38879
|
+
const DATE_BEFORE_TODAY_ERROR = 'error/DATE_BEFORE_TODAY';
|
|
38881
38880
|
const dateBeforeToday = createValidator(
|
|
38882
38881
|
DATE_BEFORE_TODAY,
|
|
38883
38882
|
DATE_BEFORE_TODAY_ERROR
|
|
38884
38883
|
);
|
|
38885
38884
|
validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
38886
|
-
if (value ===
|
|
38885
|
+
if (value === '') {
|
|
38887
38886
|
return true;
|
|
38888
38887
|
}
|
|
38889
38888
|
const dateFormat = args[0];
|
|
@@ -38892,7 +38891,7 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
38892
38891
|
|
|
38893
38892
|
if (dateFormat == undefined || unit == undefined) {
|
|
38894
38893
|
throw new Error(
|
|
38895
|
-
|
|
38894
|
+
'Date format and unit need to be defined for dateBeforeToday, one or both are undefined'
|
|
38896
38895
|
);
|
|
38897
38896
|
}
|
|
38898
38897
|
const now = dayjs();
|
|
@@ -38904,14 +38903,14 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
38904
38903
|
return dateValue.isBefore(now, unit);
|
|
38905
38904
|
};
|
|
38906
38905
|
|
|
38907
|
-
const DATE_AFTER_TODAY =
|
|
38908
|
-
const DATE_AFTER_TODAY_ERROR =
|
|
38906
|
+
const DATE_AFTER_TODAY = 'validator/DATE_AFTER_TODAY';
|
|
38907
|
+
const DATE_AFTER_TODAY_ERROR = 'error/DATE_AFTER_TODAY';
|
|
38909
38908
|
const dateAfterToday = createValidator(
|
|
38910
38909
|
DATE_AFTER_TODAY,
|
|
38911
38910
|
DATE_AFTER_TODAY_ERROR
|
|
38912
38911
|
);
|
|
38913
38912
|
validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
38914
|
-
if (value ===
|
|
38913
|
+
if (value === '') {
|
|
38915
38914
|
return true;
|
|
38916
38915
|
}
|
|
38917
38916
|
const dateFormat = args[0];
|
|
@@ -38920,7 +38919,7 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
38920
38919
|
|
|
38921
38920
|
if (dateFormat == undefined || unit == undefined) {
|
|
38922
38921
|
throw new Error(
|
|
38923
|
-
|
|
38922
|
+
'Date format and unit need to be defined for dateAfterToday, one or both are undefined'
|
|
38924
38923
|
);
|
|
38925
38924
|
}
|
|
38926
38925
|
const now = dayjs();
|
|
@@ -38932,14 +38931,11 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
38932
38931
|
return dateValue.isAfter(now, unit);
|
|
38933
38932
|
};
|
|
38934
38933
|
|
|
38935
|
-
const IS_VALID_MONTH =
|
|
38936
|
-
const IS_VALID_MONTH_ERROR =
|
|
38937
|
-
const isValidMonth = createValidator(
|
|
38938
|
-
IS_VALID_MONTH,
|
|
38939
|
-
IS_VALID_MONTH_ERROR
|
|
38940
|
-
);
|
|
38934
|
+
const IS_VALID_MONTH = 'validator/IS_VALID_MONTH';
|
|
38935
|
+
const IS_VALID_MONTH_ERROR = 'error/IS_VALID_MONTH';
|
|
38936
|
+
const isValidMonth = createValidator(IS_VALID_MONTH, IS_VALID_MONTH_ERROR);
|
|
38941
38937
|
validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
38942
|
-
if (value ===
|
|
38938
|
+
if (value === '') {
|
|
38943
38939
|
return true;
|
|
38944
38940
|
}
|
|
38945
38941
|
// Function takes one argument representing the character position
|
|
@@ -38949,43 +38945,43 @@ validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
|
38949
38945
|
// Only works with two digit months (01, 02, 03, etc)
|
|
38950
38946
|
const monthStartPosition = parseInt(args[0]);
|
|
38951
38947
|
const monthEndPosition = monthStartPosition + 2;
|
|
38952
|
-
if (monthStartPosition
|
|
38953
|
-
throw new Error(
|
|
38948
|
+
if (isNaN(monthStartPosition)) {
|
|
38949
|
+
throw new Error('Month start position has to be a valid integer string');
|
|
38954
38950
|
}
|
|
38955
38951
|
const month = parseInt(value.slice(monthStartPosition, monthEndPosition));
|
|
38956
|
-
if (month
|
|
38952
|
+
if (isNaN(month)) {
|
|
38957
38953
|
return false;
|
|
38958
38954
|
}
|
|
38959
38955
|
return month >= 1 && month <= 12;
|
|
38960
38956
|
};
|
|
38961
38957
|
|
|
38962
|
-
const MATCHES_REGEX =
|
|
38963
|
-
const MATCHES_REGEX_ERROR =
|
|
38958
|
+
const MATCHES_REGEX = 'validator/MATCHES_REGEX';
|
|
38959
|
+
const MATCHES_REGEX_ERROR = 'error/MATCHES_REGEX';
|
|
38964
38960
|
const matchesRegex = createValidator(MATCHES_REGEX, MATCHES_REGEX_ERROR);
|
|
38965
38961
|
validatorFns[MATCHES_REGEX] = (value, args, form) => {
|
|
38966
|
-
if (value ===
|
|
38962
|
+
if (value === '') {
|
|
38967
38963
|
return true;
|
|
38968
38964
|
}
|
|
38969
38965
|
return new RegExp(args[0]).test(value); // new RexExp never throws an error, no matter the input
|
|
38970
38966
|
};
|
|
38971
38967
|
|
|
38972
38968
|
// based on http://www.brainjar.com/js/validation/
|
|
38973
|
-
const IS_ROUTING_NUMBER =
|
|
38974
|
-
const IS_ROUTING_NUMBER_ERROR =
|
|
38969
|
+
const IS_ROUTING_NUMBER = 'validator/IS_ROUTING_NUMBER';
|
|
38970
|
+
const IS_ROUTING_NUMBER_ERROR = 'error/IS_ROUTING_NUMBER';
|
|
38975
38971
|
const isRoutingNumber = createValidator(
|
|
38976
38972
|
IS_ROUTING_NUMBER,
|
|
38977
38973
|
IS_ROUTING_NUMBER_ERROR
|
|
38978
38974
|
);
|
|
38979
38975
|
validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
38980
|
-
if (value ===
|
|
38976
|
+
if (value === '') {
|
|
38981
38977
|
return true;
|
|
38982
38978
|
}
|
|
38983
38979
|
if (value.length != 9) {
|
|
38984
38980
|
return false;
|
|
38985
38981
|
}
|
|
38986
38982
|
const sum = value
|
|
38987
|
-
.split(
|
|
38988
|
-
.map(ch => parseInt(ch))
|
|
38983
|
+
.split('')
|
|
38984
|
+
.map((ch) => parseInt(ch))
|
|
38989
38985
|
.reduce((acc, cur, idx) => {
|
|
38990
38986
|
switch (idx % 3) {
|
|
38991
38987
|
case 0:
|
|
@@ -38999,69 +38995,69 @@ validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
|
38999
38995
|
return sum != 0 && sum % 10 == 0;
|
|
39000
38996
|
};
|
|
39001
38997
|
|
|
39002
|
-
const HAS_NUMBER =
|
|
39003
|
-
const HAS_NUMBER_ERROR$1 =
|
|
38998
|
+
const HAS_NUMBER = 'validator/HAS_NUMBER';
|
|
38999
|
+
const HAS_NUMBER_ERROR$1 = 'error/HAS_NUMBER';
|
|
39004
39000
|
const hasNumber = createValidator(HAS_NUMBER, HAS_NUMBER_ERROR$1);
|
|
39005
39001
|
validatorFns[HAS_NUMBER] = (value, args, form) => {
|
|
39006
|
-
if (value ===
|
|
39002
|
+
if (value === '') {
|
|
39007
39003
|
return true;
|
|
39008
39004
|
}
|
|
39009
39005
|
return new RegExp(/[0-9]/).test(value);
|
|
39010
39006
|
};
|
|
39011
39007
|
|
|
39012
|
-
const HAS_LOWERCASE_LETTER =
|
|
39013
|
-
const HAS_LOWERCASE_LETTER_ERROR$1 =
|
|
39008
|
+
const HAS_LOWERCASE_LETTER = 'validator/HAS_LOWERCASE_LETTER';
|
|
39009
|
+
const HAS_LOWERCASE_LETTER_ERROR$1 = 'error/HAS_LOWERCASE_LETTER';
|
|
39014
39010
|
const hasLowercaseLetter = createValidator(
|
|
39015
39011
|
HAS_LOWERCASE_LETTER,
|
|
39016
39012
|
HAS_LOWERCASE_LETTER_ERROR$1
|
|
39017
39013
|
);
|
|
39018
39014
|
validatorFns[HAS_LOWERCASE_LETTER] = (value, args, form) => {
|
|
39019
|
-
if (value ===
|
|
39015
|
+
if (value === '') {
|
|
39020
39016
|
return true;
|
|
39021
39017
|
}
|
|
39022
39018
|
return new RegExp(/[a-z]/).test(value);
|
|
39023
39019
|
};
|
|
39024
39020
|
|
|
39025
|
-
const HAS_UPPERCASE_LETTER =
|
|
39026
|
-
const HAS_UPPERCASE_LETTER_ERROR$1 =
|
|
39021
|
+
const HAS_UPPERCASE_LETTER = 'validator/HAS_UPPERCASE_LETTER';
|
|
39022
|
+
const HAS_UPPERCASE_LETTER_ERROR$1 = 'error/HAS_UPPERCASE_LETTER';
|
|
39027
39023
|
const hasUppercaseLetter = createValidator(
|
|
39028
39024
|
HAS_UPPERCASE_LETTER,
|
|
39029
39025
|
HAS_UPPERCASE_LETTER_ERROR$1
|
|
39030
39026
|
);
|
|
39031
39027
|
validatorFns[HAS_UPPERCASE_LETTER] = (value, args, form) => {
|
|
39032
|
-
if (value ===
|
|
39028
|
+
if (value === '') {
|
|
39033
39029
|
return true;
|
|
39034
39030
|
}
|
|
39035
39031
|
return new RegExp(/[A-Z]/).test(value);
|
|
39036
39032
|
};
|
|
39037
39033
|
|
|
39038
|
-
const HAS_SPECIAL_CHARACTER =
|
|
39039
|
-
const HAS_SPECIAL_CHARACTER_ERROR$1 =
|
|
39034
|
+
const HAS_SPECIAL_CHARACTER = 'validator/HAS_SPECIAL_CHARACTER';
|
|
39035
|
+
const HAS_SPECIAL_CHARACTER_ERROR$1 = 'error/HAS_SPECIAL_CHARACTER';
|
|
39040
39036
|
const hasSpecialCharacter = createValidator(
|
|
39041
39037
|
HAS_SPECIAL_CHARACTER,
|
|
39042
39038
|
HAS_SPECIAL_CHARACTER_ERROR$1
|
|
39043
39039
|
);
|
|
39044
39040
|
validatorFns[HAS_SPECIAL_CHARACTER] = (value, args, form) => {
|
|
39045
|
-
if (value ===
|
|
39041
|
+
if (value === '') {
|
|
39046
39042
|
return true;
|
|
39047
39043
|
}
|
|
39048
39044
|
return new RegExp(/[!@#$%^&*.?]/).test(value);
|
|
39049
39045
|
};
|
|
39050
39046
|
|
|
39051
|
-
const IS_PROBABLY_EMAIL =
|
|
39052
|
-
const IS_PROBABLY_EMAIL_ERROR =
|
|
39047
|
+
const IS_PROBABLY_EMAIL = 'validator/IS_PROBABLY_EMAIL';
|
|
39048
|
+
const IS_PROBABLY_EMAIL_ERROR = 'error/IS_PROBABLY_EMAIL';
|
|
39053
39049
|
const isProbablyEmail = createValidator(
|
|
39054
39050
|
IS_PROBABLY_EMAIL,
|
|
39055
39051
|
IS_PROBABLY_EMAIL_ERROR
|
|
39056
39052
|
);
|
|
39057
39053
|
validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
39058
|
-
if (value ===
|
|
39054
|
+
if (value === '') {
|
|
39059
39055
|
return true;
|
|
39060
39056
|
}
|
|
39061
39057
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
39062
39058
|
};
|
|
39063
39059
|
|
|
39064
|
-
const runValidatorErrorMessage = type =>
|
|
39060
|
+
const runValidatorErrorMessage = (type) =>
|
|
39065
39061
|
`${type} was passed to runValidator, but that validator type does not exist.
|
|
39066
39062
|
Please check that you are only calling validator creator functions exported from
|
|
39067
39063
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -39076,1165 +39072,53 @@ const runValidator = (validator, value, form) => {
|
|
|
39076
39072
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
39077
39073
|
};
|
|
39078
39074
|
|
|
39079
|
-
const
|
|
39075
|
+
const runFormValidators = (fieldName, form, validators) => {
|
|
39080
39076
|
return validators
|
|
39081
|
-
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
39082
|
-
.filter(x => x !== null);
|
|
39077
|
+
.map((v) => runValidator(v, form[fieldName].rawValue, form))
|
|
39078
|
+
.filter((x) => x !== null);
|
|
39083
39079
|
};
|
|
39084
39080
|
|
|
39085
39081
|
const computeConstraints = (fieldName, form) => {
|
|
39086
39082
|
const constraints = form[fieldName].constraints;
|
|
39087
|
-
return
|
|
39083
|
+
return runFormValidators(fieldName, form, constraints);
|
|
39088
39084
|
};
|
|
39089
39085
|
|
|
39090
39086
|
const computeErrors = (fieldName, form) => {
|
|
39091
39087
|
const validators = form[fieldName].validators;
|
|
39092
|
-
return
|
|
39093
|
-
};
|
|
39094
|
-
|
|
39095
|
-
var obj;
|
|
39096
|
-
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : ( obj = {}, obj["immer-nothing"] = true, obj );
|
|
39097
|
-
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
39098
|
-
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-state") : "__$immer_state";
|
|
39099
|
-
function isDraft(value) {
|
|
39100
|
-
return !!value && !!value[DRAFT_STATE];
|
|
39101
|
-
}
|
|
39102
|
-
function isDraftable(value) {
|
|
39103
|
-
if (!value) { return false; }
|
|
39104
|
-
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
39105
|
-
}
|
|
39106
|
-
function isPlainObject(value) {
|
|
39107
|
-
if (!value || typeof value !== "object") { return false; }
|
|
39108
|
-
if (Array.isArray(value)) { return true; }
|
|
39109
|
-
var proto = Object.getPrototypeOf(value);
|
|
39110
|
-
return !proto || proto === Object.prototype;
|
|
39111
|
-
}
|
|
39112
|
-
var assign = Object.assign || function assign(target, value) {
|
|
39113
|
-
for (var key in value) {
|
|
39114
|
-
if (has$1(value, key)) {
|
|
39115
|
-
target[key] = value[key];
|
|
39116
|
-
}
|
|
39117
|
-
}
|
|
39118
|
-
|
|
39119
|
-
return target;
|
|
39088
|
+
return runFormValidators(fieldName, form, validators);
|
|
39120
39089
|
};
|
|
39121
|
-
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;
|
|
39122
|
-
function shallowCopy(base, invokeGetters) {
|
|
39123
|
-
if ( invokeGetters === void 0 ) invokeGetters = false;
|
|
39124
|
-
|
|
39125
|
-
if (Array.isArray(base)) { return base.slice(); }
|
|
39126
|
-
var clone = Object.create(Object.getPrototypeOf(base));
|
|
39127
|
-
ownKeys$2(base).forEach(function (key) {
|
|
39128
|
-
if (key === DRAFT_STATE) {
|
|
39129
|
-
return; // Never copy over draft state.
|
|
39130
|
-
}
|
|
39131
|
-
|
|
39132
|
-
var desc = Object.getOwnPropertyDescriptor(base, key);
|
|
39133
|
-
var value = desc.value;
|
|
39134
|
-
|
|
39135
|
-
if (desc.get) {
|
|
39136
|
-
if (!invokeGetters) {
|
|
39137
|
-
throw new Error("Immer drafts cannot have computed properties");
|
|
39138
|
-
}
|
|
39139
|
-
|
|
39140
|
-
value = desc.get.call(base);
|
|
39141
|
-
}
|
|
39142
|
-
|
|
39143
|
-
if (desc.enumerable) {
|
|
39144
|
-
clone[key] = value;
|
|
39145
|
-
} else {
|
|
39146
|
-
Object.defineProperty(clone, key, {
|
|
39147
|
-
value: value,
|
|
39148
|
-
writable: true,
|
|
39149
|
-
configurable: true
|
|
39150
|
-
});
|
|
39151
|
-
}
|
|
39152
|
-
});
|
|
39153
|
-
return clone;
|
|
39154
|
-
}
|
|
39155
|
-
function each(value, cb) {
|
|
39156
|
-
if (Array.isArray(value)) {
|
|
39157
|
-
for (var i = 0; i < value.length; i++) { cb(i, value[i], value); }
|
|
39158
|
-
} else {
|
|
39159
|
-
ownKeys$2(value).forEach(function (key) { return cb(key, value[key], value); });
|
|
39160
|
-
}
|
|
39161
|
-
}
|
|
39162
|
-
function isEnumerable(base, prop) {
|
|
39163
|
-
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
39164
|
-
return !!desc && desc.enumerable;
|
|
39165
|
-
}
|
|
39166
|
-
function has$1(thing, prop) {
|
|
39167
|
-
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
39168
|
-
}
|
|
39169
|
-
function is(x, y) {
|
|
39170
|
-
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
39171
|
-
if (x === y) {
|
|
39172
|
-
return x !== 0 || 1 / x === 1 / y;
|
|
39173
|
-
} else {
|
|
39174
|
-
return x !== x && y !== y;
|
|
39175
|
-
}
|
|
39176
|
-
}
|
|
39177
|
-
function clone(obj) {
|
|
39178
|
-
if (!isDraftable(obj)) { return obj; }
|
|
39179
|
-
if (Array.isArray(obj)) { return obj.map(clone); }
|
|
39180
|
-
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
39181
|
-
|
|
39182
|
-
for (var key in obj) { cloned[key] = clone(obj[key]); }
|
|
39183
|
-
|
|
39184
|
-
return cloned;
|
|
39185
|
-
}
|
|
39186
|
-
|
|
39187
|
-
/** Each scope represents a `produce` call. */
|
|
39188
|
-
|
|
39189
|
-
var ImmerScope = function ImmerScope(parent) {
|
|
39190
|
-
this.drafts = [];
|
|
39191
|
-
this.parent = parent; // Whenever the modified draft contains a draft from another scope, we
|
|
39192
|
-
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
39193
|
-
|
|
39194
|
-
this.canAutoFreeze = true; // To avoid prototype lookups:
|
|
39195
|
-
|
|
39196
|
-
this.patches = null;
|
|
39197
|
-
};
|
|
39198
|
-
|
|
39199
|
-
ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
39200
|
-
if (patchListener) {
|
|
39201
|
-
this.patches = [];
|
|
39202
|
-
this.inversePatches = [];
|
|
39203
|
-
this.patchListener = patchListener;
|
|
39204
|
-
}
|
|
39205
|
-
};
|
|
39206
|
-
|
|
39207
|
-
ImmerScope.prototype.revoke = function revoke$1 () {
|
|
39208
|
-
this.leave();
|
|
39209
|
-
this.drafts.forEach(revoke);
|
|
39210
|
-
this.drafts = null; // Make draft-related methods throw.
|
|
39211
|
-
};
|
|
39212
|
-
|
|
39213
|
-
ImmerScope.prototype.leave = function leave () {
|
|
39214
|
-
if (this === ImmerScope.current) {
|
|
39215
|
-
ImmerScope.current = this.parent;
|
|
39216
|
-
}
|
|
39217
|
-
};
|
|
39218
|
-
ImmerScope.current = null;
|
|
39219
|
-
|
|
39220
|
-
ImmerScope.enter = function () {
|
|
39221
|
-
return this.current = new ImmerScope(this.current);
|
|
39222
|
-
};
|
|
39223
|
-
|
|
39224
|
-
function revoke(draft) {
|
|
39225
|
-
draft[DRAFT_STATE].revoke();
|
|
39226
|
-
}
|
|
39227
|
-
|
|
39228
|
-
// but share them all instead
|
|
39229
|
-
|
|
39230
|
-
var descriptors$1 = {};
|
|
39231
|
-
function willFinalize(scope, result, isReplaced) {
|
|
39232
|
-
scope.drafts.forEach(function (draft) {
|
|
39233
|
-
draft[DRAFT_STATE].finalizing = true;
|
|
39234
|
-
});
|
|
39235
|
-
|
|
39236
|
-
if (!isReplaced) {
|
|
39237
|
-
if (scope.patches) {
|
|
39238
|
-
markChangesRecursively(scope.drafts[0]);
|
|
39239
|
-
} // This is faster when we don't care about which attributes changed.
|
|
39240
|
-
|
|
39241
|
-
|
|
39242
|
-
markChangesSweep(scope.drafts);
|
|
39243
|
-
} // When a child draft is returned, look for changes.
|
|
39244
|
-
else if (isDraft(result) && result[DRAFT_STATE].scope === scope) {
|
|
39245
|
-
markChangesSweep(scope.drafts);
|
|
39246
|
-
}
|
|
39247
|
-
}
|
|
39248
|
-
function createProxy(base, parent) {
|
|
39249
|
-
var isArray = Array.isArray(base);
|
|
39250
|
-
var draft = clonePotentialDraft(base);
|
|
39251
|
-
each(draft, function (prop) {
|
|
39252
|
-
proxyProperty(draft, prop, isArray || isEnumerable(base, prop));
|
|
39253
|
-
}); // See "proxy.js" for property documentation.
|
|
39254
|
-
|
|
39255
|
-
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39256
|
-
var state = {
|
|
39257
|
-
scope: scope,
|
|
39258
|
-
modified: false,
|
|
39259
|
-
finalizing: false,
|
|
39260
|
-
// es5 only
|
|
39261
|
-
finalized: false,
|
|
39262
|
-
assigned: {},
|
|
39263
|
-
parent: parent,
|
|
39264
|
-
base: base,
|
|
39265
|
-
draft: draft,
|
|
39266
|
-
copy: null,
|
|
39267
|
-
revoke: revoke$1,
|
|
39268
|
-
revoked: false // es5 only
|
|
39269
|
-
|
|
39270
|
-
};
|
|
39271
|
-
createHiddenProperty(draft, DRAFT_STATE, state);
|
|
39272
|
-
scope.drafts.push(draft);
|
|
39273
|
-
return draft;
|
|
39274
|
-
}
|
|
39275
|
-
|
|
39276
|
-
function revoke$1() {
|
|
39277
|
-
this.revoked = true;
|
|
39278
|
-
}
|
|
39279
|
-
|
|
39280
|
-
function source(state) {
|
|
39281
|
-
return state.copy || state.base;
|
|
39282
|
-
} // Access a property without creating an Immer draft.
|
|
39283
|
-
|
|
39284
|
-
|
|
39285
|
-
function peek(draft, prop) {
|
|
39286
|
-
var state = draft[DRAFT_STATE];
|
|
39287
|
-
|
|
39288
|
-
if (state && !state.finalizing) {
|
|
39289
|
-
state.finalizing = true;
|
|
39290
|
-
var value = draft[prop];
|
|
39291
|
-
state.finalizing = false;
|
|
39292
|
-
return value;
|
|
39293
|
-
}
|
|
39294
|
-
|
|
39295
|
-
return draft[prop];
|
|
39296
|
-
}
|
|
39297
|
-
|
|
39298
|
-
function get$1(state, prop) {
|
|
39299
|
-
assertUnrevoked(state);
|
|
39300
|
-
var value = peek(source(state), prop);
|
|
39301
|
-
if (state.finalizing) { return value; } // Create a draft if the value is unmodified.
|
|
39302
|
-
|
|
39303
|
-
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
39304
|
-
prepareCopy(state);
|
|
39305
|
-
return state.copy[prop] = createProxy(value, state);
|
|
39306
|
-
}
|
|
39307
|
-
|
|
39308
|
-
return value;
|
|
39309
|
-
}
|
|
39310
|
-
|
|
39311
|
-
function set$1(state, prop, value) {
|
|
39312
|
-
assertUnrevoked(state);
|
|
39313
|
-
state.assigned[prop] = true;
|
|
39314
|
-
|
|
39315
|
-
if (!state.modified) {
|
|
39316
|
-
if (is(value, peek(source(state), prop))) { return; }
|
|
39317
|
-
markChanged(state);
|
|
39318
|
-
prepareCopy(state);
|
|
39319
|
-
}
|
|
39320
|
-
|
|
39321
|
-
state.copy[prop] = value;
|
|
39322
|
-
}
|
|
39323
|
-
|
|
39324
|
-
function markChanged(state) {
|
|
39325
|
-
if (!state.modified) {
|
|
39326
|
-
state.modified = true;
|
|
39327
|
-
if (state.parent) { markChanged(state.parent); }
|
|
39328
|
-
}
|
|
39329
|
-
}
|
|
39330
|
-
|
|
39331
|
-
function prepareCopy(state) {
|
|
39332
|
-
if (!state.copy) { state.copy = clonePotentialDraft(state.base); }
|
|
39333
|
-
}
|
|
39334
|
-
|
|
39335
|
-
function clonePotentialDraft(base) {
|
|
39336
|
-
var state = base && base[DRAFT_STATE];
|
|
39337
|
-
|
|
39338
|
-
if (state) {
|
|
39339
|
-
state.finalizing = true;
|
|
39340
|
-
var draft = shallowCopy(state.draft, true);
|
|
39341
|
-
state.finalizing = false;
|
|
39342
|
-
return draft;
|
|
39343
|
-
}
|
|
39344
|
-
|
|
39345
|
-
return shallowCopy(base);
|
|
39346
|
-
}
|
|
39347
|
-
|
|
39348
|
-
function proxyProperty(draft, prop, enumerable) {
|
|
39349
|
-
var desc = descriptors$1[prop];
|
|
39350
|
-
|
|
39351
|
-
if (desc) {
|
|
39352
|
-
desc.enumerable = enumerable;
|
|
39353
|
-
} else {
|
|
39354
|
-
descriptors$1[prop] = desc = {
|
|
39355
|
-
configurable: true,
|
|
39356
|
-
enumerable: enumerable,
|
|
39357
|
-
|
|
39358
|
-
get: function get$1$1() {
|
|
39359
|
-
return get$1(this[DRAFT_STATE], prop);
|
|
39360
|
-
},
|
|
39361
|
-
|
|
39362
|
-
set: function set$1$1(value) {
|
|
39363
|
-
set$1(this[DRAFT_STATE], prop, value);
|
|
39364
|
-
}
|
|
39365
|
-
|
|
39366
|
-
};
|
|
39367
|
-
}
|
|
39368
|
-
|
|
39369
|
-
Object.defineProperty(draft, prop, desc);
|
|
39370
|
-
}
|
|
39371
|
-
|
|
39372
|
-
function assertUnrevoked(state) {
|
|
39373
|
-
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))); }
|
|
39374
|
-
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
39375
|
-
|
|
39376
|
-
|
|
39377
|
-
function markChangesSweep(drafts) {
|
|
39378
|
-
// The natural order of drafts in the `scope` array is based on when they
|
|
39379
|
-
// were accessed. By processing drafts in reverse natural order, we have a
|
|
39380
|
-
// better chance of processing leaf nodes first. When a leaf node is known to
|
|
39381
|
-
// have changed, we can avoid any traversal of its ancestor nodes.
|
|
39382
|
-
for (var i = drafts.length - 1; i >= 0; i--) {
|
|
39383
|
-
var state = drafts[i][DRAFT_STATE];
|
|
39384
|
-
|
|
39385
|
-
if (!state.modified) {
|
|
39386
|
-
if (Array.isArray(state.base)) {
|
|
39387
|
-
if (hasArrayChanges(state)) { markChanged(state); }
|
|
39388
|
-
} else if (hasObjectChanges(state)) { markChanged(state); }
|
|
39389
|
-
}
|
|
39390
|
-
}
|
|
39391
|
-
}
|
|
39392
|
-
|
|
39393
|
-
function markChangesRecursively(object) {
|
|
39394
|
-
if (!object || typeof object !== "object") { return; }
|
|
39395
|
-
var state = object[DRAFT_STATE];
|
|
39396
|
-
if (!state) { return; }
|
|
39397
|
-
var base = state.base;
|
|
39398
|
-
var draft = state.draft;
|
|
39399
|
-
var assigned = state.assigned;
|
|
39400
|
-
|
|
39401
|
-
if (!Array.isArray(object)) {
|
|
39402
|
-
// Look for added keys.
|
|
39403
|
-
Object.keys(draft).forEach(function (key) {
|
|
39404
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39405
|
-
if (base[key] === undefined && !has$1(base, key)) {
|
|
39406
|
-
assigned[key] = true;
|
|
39407
|
-
markChanged(state);
|
|
39408
|
-
} else if (!assigned[key]) {
|
|
39409
|
-
// Only untouched properties trigger recursion.
|
|
39410
|
-
markChangesRecursively(draft[key]);
|
|
39411
|
-
}
|
|
39412
|
-
}); // Look for removed keys.
|
|
39413
|
-
|
|
39414
|
-
Object.keys(base).forEach(function (key) {
|
|
39415
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39416
|
-
if (draft[key] === undefined && !has$1(draft, key)) {
|
|
39417
|
-
assigned[key] = false;
|
|
39418
|
-
markChanged(state);
|
|
39419
|
-
}
|
|
39420
|
-
});
|
|
39421
|
-
} else if (hasArrayChanges(state)) {
|
|
39422
|
-
markChanged(state);
|
|
39423
|
-
assigned.length = true;
|
|
39424
|
-
|
|
39425
|
-
if (draft.length < base.length) {
|
|
39426
|
-
for (var i = draft.length; i < base.length; i++) { assigned[i] = false; }
|
|
39427
|
-
} else {
|
|
39428
|
-
for (var i$1 = base.length; i$1 < draft.length; i$1++) { assigned[i$1] = true; }
|
|
39429
|
-
}
|
|
39430
39090
|
|
|
39431
|
-
|
|
39432
|
-
|
|
39433
|
-
|
|
39434
|
-
|
|
39091
|
+
const computeErrorEntries = (formState) => {
|
|
39092
|
+
const fields = Object.entries(formState);
|
|
39093
|
+
for (let entry of fields) {
|
|
39094
|
+
let fieldName = entry[0];
|
|
39095
|
+
let errors = computeErrors(fieldName, formState);
|
|
39096
|
+
formState[fieldName].errors = errors;
|
|
39097
|
+
formState[fieldName].hasErrors = errors.length > 0;
|
|
39435
39098
|
}
|
|
39436
|
-
}
|
|
39437
|
-
|
|
39438
|
-
function hasObjectChanges(state) {
|
|
39439
|
-
var base = state.base;
|
|
39440
|
-
var draft = state.draft; // Search for added keys and changed keys. Start at the back, because
|
|
39441
|
-
// non-numeric keys are ordered by time of definition on the object.
|
|
39442
|
-
|
|
39443
|
-
var keys = Object.keys(draft);
|
|
39444
|
-
|
|
39445
|
-
for (var i = keys.length - 1; i >= 0; i--) {
|
|
39446
|
-
var key = keys[i];
|
|
39447
|
-
var baseValue = base[key]; // The `undefined` check is a fast path for pre-existing keys.
|
|
39448
|
-
|
|
39449
|
-
if (baseValue === undefined && !has$1(base, key)) {
|
|
39450
|
-
return true;
|
|
39451
|
-
} // Once a base key is deleted, future changes go undetected, because its
|
|
39452
|
-
// descriptor is erased. This branch detects any missed changes.
|
|
39453
|
-
else {
|
|
39454
|
-
var value = draft[key];
|
|
39455
|
-
var state$1 = value && value[DRAFT_STATE];
|
|
39456
|
-
|
|
39457
|
-
if (state$1 ? state$1.base !== baseValue : !is(value, baseValue)) {
|
|
39458
|
-
return true;
|
|
39459
|
-
}
|
|
39460
|
-
}
|
|
39461
|
-
} // At this point, no keys were added or changed.
|
|
39462
|
-
// Compare key count to determine if keys were deleted.
|
|
39463
|
-
|
|
39464
|
-
|
|
39465
|
-
return keys.length !== Object.keys(base).length;
|
|
39466
|
-
}
|
|
39467
|
-
|
|
39468
|
-
function hasArrayChanges(state) {
|
|
39469
|
-
var draft = state.draft;
|
|
39470
|
-
if (draft.length !== state.base.length) { return true; } // See #116
|
|
39471
|
-
// If we first shorten the length, our array interceptors will be removed.
|
|
39472
|
-
// If after that new items are added, result in the same original length,
|
|
39473
|
-
// those last items will have no intercepting property.
|
|
39474
|
-
// So if there is no own descriptor on the last position, we know that items were removed and added
|
|
39475
|
-
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
39476
|
-
// the last one
|
|
39477
|
-
|
|
39478
|
-
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
39479
|
-
|
|
39480
|
-
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
|
|
39481
|
-
|
|
39482
|
-
return false;
|
|
39483
|
-
}
|
|
39484
|
-
|
|
39485
|
-
function createHiddenProperty(target, prop, value) {
|
|
39486
|
-
Object.defineProperty(target, prop, {
|
|
39487
|
-
value: value,
|
|
39488
|
-
enumerable: false,
|
|
39489
|
-
writable: true
|
|
39490
|
-
});
|
|
39491
|
-
}
|
|
39492
|
-
|
|
39493
|
-
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
39494
|
-
willFinalize: willFinalize,
|
|
39495
|
-
createProxy: createProxy
|
|
39496
|
-
});
|
|
39497
|
-
|
|
39498
|
-
function willFinalize$1() {}
|
|
39499
|
-
function createProxy$1(base, parent) {
|
|
39500
|
-
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39501
|
-
var state = {
|
|
39502
|
-
// Track which produce call this is associated with.
|
|
39503
|
-
scope: scope,
|
|
39504
|
-
// True for both shallow and deep changes.
|
|
39505
|
-
modified: false,
|
|
39506
|
-
// Used during finalization.
|
|
39507
|
-
finalized: false,
|
|
39508
|
-
// Track which properties have been assigned (true) or deleted (false).
|
|
39509
|
-
assigned: {},
|
|
39510
|
-
// The parent draft state.
|
|
39511
|
-
parent: parent,
|
|
39512
|
-
// The base state.
|
|
39513
|
-
base: base,
|
|
39514
|
-
// The base proxy.
|
|
39515
|
-
draft: null,
|
|
39516
|
-
// Any property proxies.
|
|
39517
|
-
drafts: {},
|
|
39518
|
-
// The base copy with any updated values.
|
|
39519
|
-
copy: null,
|
|
39520
|
-
// Called by the `produce` function.
|
|
39521
|
-
revoke: null
|
|
39522
|
-
};
|
|
39523
|
-
var ref = Array.isArray(base) ? // [state] is used for arrays, to make sure the proxy is array-ish and not violate invariants,
|
|
39524
|
-
// although state itself is an object
|
|
39525
|
-
Proxy.revocable([state], arrayTraps) : Proxy.revocable(state, objectTraps);
|
|
39526
|
-
var revoke = ref.revoke;
|
|
39527
|
-
var proxy = ref.proxy;
|
|
39528
|
-
state.draft = proxy;
|
|
39529
|
-
state.revoke = revoke;
|
|
39530
|
-
scope.drafts.push(proxy);
|
|
39531
|
-
return proxy;
|
|
39532
|
-
}
|
|
39533
|
-
var objectTraps = {
|
|
39534
|
-
get: get$1$1,
|
|
39535
|
-
|
|
39536
|
-
has: function has(target, prop) {
|
|
39537
|
-
return prop in source$1(target);
|
|
39538
|
-
},
|
|
39539
|
-
|
|
39540
|
-
ownKeys: function ownKeys(target) {
|
|
39541
|
-
return Reflect.ownKeys(source$1(target));
|
|
39542
|
-
},
|
|
39543
|
-
|
|
39544
|
-
set: set$1$1,
|
|
39545
|
-
deleteProperty: deleteProperty,
|
|
39546
|
-
getOwnPropertyDescriptor: getOwnPropertyDescriptor$2,
|
|
39547
|
-
|
|
39548
|
-
defineProperty: function defineProperty() {
|
|
39549
|
-
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
39550
|
-
},
|
|
39551
|
-
|
|
39552
|
-
getPrototypeOf: function getPrototypeOf(target) {
|
|
39553
|
-
return Object.getPrototypeOf(target.base);
|
|
39554
|
-
},
|
|
39555
|
-
|
|
39556
|
-
setPrototypeOf: function setPrototypeOf() {
|
|
39557
|
-
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
39558
|
-
}
|
|
39559
|
-
|
|
39560
39099
|
};
|
|
39561
|
-
var arrayTraps = {};
|
|
39562
|
-
each(objectTraps, function (key, fn) {
|
|
39563
|
-
arrayTraps[key] = function () {
|
|
39564
|
-
arguments[0] = arguments[0][0];
|
|
39565
|
-
return fn.apply(this, arguments);
|
|
39566
|
-
};
|
|
39567
|
-
});
|
|
39568
39100
|
|
|
39569
|
-
|
|
39570
|
-
|
|
39571
|
-
|
|
39101
|
+
const computeDirtyEntries = (formState, changedFieldName) => {
|
|
39102
|
+
const fields = Object.entries(formState);
|
|
39103
|
+
for (let entry of fields) {
|
|
39104
|
+
let fieldName = entry[0];
|
|
39105
|
+
let field = entry[1];
|
|
39106
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
39107
|
+
formState[fieldName].dirty = dirty;
|
|
39572
39108
|
}
|
|
39573
|
-
|
|
39574
|
-
return objectTraps.deleteProperty.call(this, state[0], prop);
|
|
39575
39109
|
};
|
|
39576
39110
|
|
|
39577
|
-
arrayTraps.set = function (state, prop, value) {
|
|
39578
|
-
if (prop !== "length" && isNaN(parseInt(prop))) {
|
|
39579
|
-
throw new Error("Immer only supports setting array indices and the 'length' property"); // prettier-ignore
|
|
39580
|
-
}
|
|
39581
|
-
|
|
39582
|
-
return objectTraps.set.call(this, state[0], prop, value);
|
|
39583
|
-
}; // returns the object we should be reading the current value from, which is base, until some change has been made
|
|
39584
|
-
|
|
39585
|
-
|
|
39586
|
-
function source$1(state) {
|
|
39587
|
-
return state.copy || state.base;
|
|
39588
|
-
} // Access a property without creating an Immer draft.
|
|
39589
|
-
|
|
39590
|
-
|
|
39591
|
-
function peek$1(draft, prop) {
|
|
39592
|
-
var state = draft[DRAFT_STATE];
|
|
39593
|
-
var desc = Reflect.getOwnPropertyDescriptor(state ? source$1(state) : draft, prop);
|
|
39594
|
-
return desc && desc.value;
|
|
39595
|
-
}
|
|
39596
|
-
|
|
39597
|
-
function get$1$1(state, prop) {
|
|
39598
|
-
if (prop === DRAFT_STATE) { return state; }
|
|
39599
|
-
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
39600
|
-
|
|
39601
|
-
if (!state.modified && has$1(drafts, prop)) {
|
|
39602
|
-
return drafts[prop];
|
|
39603
|
-
}
|
|
39604
|
-
|
|
39605
|
-
var value = source$1(state)[prop];
|
|
39606
|
-
|
|
39607
|
-
if (state.finalized || !isDraftable(value)) {
|
|
39608
|
-
return value;
|
|
39609
|
-
} // Check for existing draft in modified state.
|
|
39111
|
+
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;
|
|
39610
39112
|
|
|
39611
|
-
|
|
39612
|
-
if (state.modified) {
|
|
39613
|
-
// Assigned values are never drafted. This catches any drafts we created, too.
|
|
39614
|
-
if (value !== peek$1(state.base, prop)) { return value; } // Store drafts on the copy (when one exists).
|
|
39615
|
-
|
|
39616
|
-
drafts = state.copy;
|
|
39617
|
-
}
|
|
39618
|
-
|
|
39619
|
-
return drafts[prop] = createProxy$1(value, state);
|
|
39620
|
-
}
|
|
39621
|
-
|
|
39622
|
-
function set$1$1(state, prop, value) {
|
|
39623
|
-
if (!state.modified) {
|
|
39624
|
-
var baseValue = peek$1(state.base, prop); // Optimize based on value's truthiness. Truthy values are guaranteed to
|
|
39625
|
-
// never be undefined, so we can avoid the `in` operator. Lastly, truthy
|
|
39626
|
-
// values may be drafts, but falsy values are never drafts.
|
|
39627
|
-
|
|
39628
|
-
var isUnchanged = value ? is(baseValue, value) || value === state.drafts[prop] : is(baseValue, value) && prop in state.base;
|
|
39629
|
-
if (isUnchanged) { return true; }
|
|
39630
|
-
markChanged$1(state);
|
|
39631
|
-
}
|
|
39632
|
-
|
|
39633
|
-
state.assigned[prop] = true;
|
|
39634
|
-
state.copy[prop] = value;
|
|
39635
|
-
return true;
|
|
39636
|
-
}
|
|
39637
|
-
|
|
39638
|
-
function deleteProperty(state, prop) {
|
|
39639
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39640
|
-
if (peek$1(state.base, prop) !== undefined || prop in state.base) {
|
|
39641
|
-
state.assigned[prop] = false;
|
|
39642
|
-
markChanged$1(state);
|
|
39643
|
-
} else if (state.assigned[prop]) {
|
|
39644
|
-
// if an originally not assigned property was deleted
|
|
39645
|
-
delete state.assigned[prop];
|
|
39646
|
-
}
|
|
39647
|
-
|
|
39648
|
-
if (state.copy) { delete state.copy[prop]; }
|
|
39649
|
-
return true;
|
|
39650
|
-
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
39651
|
-
// the same guarantee in ES5 mode.
|
|
39652
|
-
|
|
39653
|
-
|
|
39654
|
-
function getOwnPropertyDescriptor$2(state, prop) {
|
|
39655
|
-
var owner = source$1(state);
|
|
39656
|
-
var desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
39657
|
-
|
|
39658
|
-
if (desc) {
|
|
39659
|
-
desc.writable = true;
|
|
39660
|
-
desc.configurable = !Array.isArray(owner) || prop !== "length";
|
|
39661
|
-
}
|
|
39662
|
-
|
|
39663
|
-
return desc;
|
|
39664
|
-
}
|
|
39665
|
-
|
|
39666
|
-
function markChanged$1(state) {
|
|
39667
|
-
if (!state.modified) {
|
|
39668
|
-
state.modified = true;
|
|
39669
|
-
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
39670
|
-
state.drafts = null;
|
|
39671
|
-
if (state.parent) { markChanged$1(state.parent); }
|
|
39672
|
-
}
|
|
39673
|
-
}
|
|
39674
|
-
|
|
39675
|
-
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
39676
|
-
willFinalize: willFinalize$1,
|
|
39677
|
-
createProxy: createProxy$1
|
|
39678
|
-
});
|
|
39679
|
-
|
|
39680
|
-
function generatePatches(state, basePath, patches, inversePatches) {
|
|
39681
|
-
Array.isArray(state.base) ? generateArrayPatches(state, basePath, patches, inversePatches) : generateObjectPatches(state, basePath, patches, inversePatches);
|
|
39682
|
-
}
|
|
39683
|
-
|
|
39684
|
-
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
39685
|
-
var assign, assign$1;
|
|
39686
|
-
|
|
39687
|
-
var base = state.base;
|
|
39688
|
-
var copy = state.copy;
|
|
39689
|
-
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
39690
|
-
|
|
39691
|
-
if (copy.length < base.length) {
|
|
39692
|
-
(assign = [copy, base], base = assign[0], copy = assign[1]);
|
|
39693
|
-
(assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1]);
|
|
39694
|
-
}
|
|
39695
|
-
|
|
39696
|
-
var delta = copy.length - base.length; // Find the first replaced index.
|
|
39697
|
-
|
|
39698
|
-
var start = 0;
|
|
39699
|
-
|
|
39700
|
-
while (base[start] === copy[start] && start < base.length) {
|
|
39701
|
-
++start;
|
|
39702
|
-
} // Find the last replaced index. Search from the end to optimize splice patches.
|
|
39703
|
-
|
|
39704
|
-
|
|
39705
|
-
var end = base.length;
|
|
39706
|
-
|
|
39707
|
-
while (end > start && base[end - 1] === copy[end + delta - 1]) {
|
|
39708
|
-
--end;
|
|
39709
|
-
} // Process replaced indices.
|
|
39710
|
-
|
|
39711
|
-
|
|
39712
|
-
for (var i = start; i < end; ++i) {
|
|
39713
|
-
if (assigned[i] && copy[i] !== base[i]) {
|
|
39714
|
-
var path = basePath.concat([i]);
|
|
39715
|
-
patches.push({
|
|
39716
|
-
op: "replace",
|
|
39717
|
-
path: path,
|
|
39718
|
-
value: copy[i]
|
|
39719
|
-
});
|
|
39720
|
-
inversePatches.push({
|
|
39721
|
-
op: "replace",
|
|
39722
|
-
path: path,
|
|
39723
|
-
value: base[i]
|
|
39724
|
-
});
|
|
39725
|
-
}
|
|
39726
|
-
}
|
|
39727
|
-
|
|
39728
|
-
var replaceCount = patches.length; // Process added indices.
|
|
39729
|
-
|
|
39730
|
-
for (var i$1 = end + delta - 1; i$1 >= end; --i$1) {
|
|
39731
|
-
var path$1 = basePath.concat([i$1]);
|
|
39732
|
-
patches[replaceCount + i$1 - end] = {
|
|
39733
|
-
op: "add",
|
|
39734
|
-
path: path$1,
|
|
39735
|
-
value: copy[i$1]
|
|
39736
|
-
};
|
|
39737
|
-
inversePatches.push({
|
|
39738
|
-
op: "remove",
|
|
39739
|
-
path: path$1
|
|
39740
|
-
});
|
|
39741
|
-
}
|
|
39742
|
-
}
|
|
39743
|
-
|
|
39744
|
-
function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
39745
|
-
var base = state.base;
|
|
39746
|
-
var copy = state.copy;
|
|
39747
|
-
each(state.assigned, function (key, assignedValue) {
|
|
39748
|
-
var origValue = base[key];
|
|
39749
|
-
var value = copy[key];
|
|
39750
|
-
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
39751
|
-
if (origValue === value && op === "replace") { return; }
|
|
39752
|
-
var path = basePath.concat(key);
|
|
39753
|
-
patches.push(op === "remove" ? {
|
|
39754
|
-
op: op,
|
|
39755
|
-
path: path
|
|
39756
|
-
} : {
|
|
39757
|
-
op: op,
|
|
39758
|
-
path: path,
|
|
39759
|
-
value: value
|
|
39760
|
-
});
|
|
39761
|
-
inversePatches.push(op === "add" ? {
|
|
39762
|
-
op: "remove",
|
|
39763
|
-
path: path
|
|
39764
|
-
} : op === "remove" ? {
|
|
39765
|
-
op: "add",
|
|
39766
|
-
path: path,
|
|
39767
|
-
value: origValue
|
|
39768
|
-
} : {
|
|
39769
|
-
op: "replace",
|
|
39770
|
-
path: path,
|
|
39771
|
-
value: origValue
|
|
39772
|
-
});
|
|
39773
|
-
});
|
|
39774
|
-
}
|
|
39775
|
-
|
|
39776
|
-
var applyPatches = function (draft, patches) {
|
|
39777
|
-
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
39778
|
-
var patch = list[i$1];
|
|
39779
|
-
|
|
39780
|
-
var path = patch.path;
|
|
39781
|
-
var op = patch.op;
|
|
39782
|
-
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
39783
|
-
|
|
39784
|
-
if (!path.length) { throw new Error("Illegal state"); }
|
|
39785
|
-
var base = draft;
|
|
39786
|
-
|
|
39787
|
-
for (var i = 0; i < path.length - 1; i++) {
|
|
39788
|
-
base = base[path[i]];
|
|
39789
|
-
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
39790
|
-
}
|
|
39791
|
-
|
|
39792
|
-
var key = path[path.length - 1];
|
|
39793
|
-
|
|
39794
|
-
switch (op) {
|
|
39795
|
-
case "replace":
|
|
39796
|
-
// if value is an object, then it's assigned by reference
|
|
39797
|
-
// in the following add or remove ops, the value field inside the patch will also be modifyed
|
|
39798
|
-
// so we use value from the cloned patch
|
|
39799
|
-
base[key] = value;
|
|
39800
|
-
break;
|
|
39801
|
-
|
|
39802
|
-
case "add":
|
|
39803
|
-
if (Array.isArray(base)) {
|
|
39804
|
-
// TODO: support "foo/-" paths for appending to an array
|
|
39805
|
-
base.splice(key, 0, value);
|
|
39806
|
-
} else {
|
|
39807
|
-
base[key] = value;
|
|
39808
|
-
}
|
|
39809
|
-
|
|
39810
|
-
break;
|
|
39811
|
-
|
|
39812
|
-
case "remove":
|
|
39813
|
-
if (Array.isArray(base)) {
|
|
39814
|
-
base.splice(key, 1);
|
|
39815
|
-
} else {
|
|
39816
|
-
delete base[key];
|
|
39817
|
-
}
|
|
39818
|
-
|
|
39819
|
-
break;
|
|
39820
|
-
|
|
39821
|
-
default:
|
|
39822
|
-
throw new Error("Unsupported patch operation: " + op);
|
|
39823
|
-
}
|
|
39824
|
-
}
|
|
39825
|
-
|
|
39826
|
-
return draft;
|
|
39827
|
-
};
|
|
39828
|
-
|
|
39829
|
-
function verifyMinified() {}
|
|
39830
|
-
|
|
39831
|
-
var configDefaults = {
|
|
39832
|
-
useProxies: typeof Proxy !== "undefined" && typeof Reflect !== "undefined",
|
|
39833
|
-
autoFreeze: typeof process !== "undefined" ? process.env.NODE_ENV !== "production" : verifyMinified.name === "verifyMinified",
|
|
39834
|
-
onAssign: null,
|
|
39835
|
-
onDelete: null,
|
|
39836
|
-
onCopy: null
|
|
39837
|
-
};
|
|
39838
|
-
var Immer = function Immer(config) {
|
|
39839
|
-
assign(this, configDefaults, config);
|
|
39840
|
-
this.setUseProxies(this.useProxies);
|
|
39841
|
-
this.produce = this.produce.bind(this);
|
|
39842
|
-
};
|
|
39843
|
-
|
|
39844
|
-
Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
39845
|
-
var this$1$1 = this;
|
|
39846
|
-
|
|
39847
|
-
// curried invocation
|
|
39848
|
-
if (typeof base === "function" && typeof recipe !== "function") {
|
|
39849
|
-
var defaultBase = recipe;
|
|
39850
|
-
recipe = base;
|
|
39851
|
-
var self = this;
|
|
39852
|
-
return function curriedProduce(base) {
|
|
39853
|
-
var this$1$1 = this;
|
|
39854
|
-
if ( base === void 0 ) base = defaultBase;
|
|
39855
|
-
var args = [], len = arguments.length - 1;
|
|
39856
|
-
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
39857
|
-
|
|
39858
|
-
return self.produce(base, function (draft) { return recipe.call.apply(recipe, [ this$1$1, draft ].concat( args )); }); // prettier-ignore
|
|
39859
|
-
};
|
|
39860
|
-
} // prettier-ignore
|
|
39861
|
-
|
|
39862
|
-
|
|
39863
|
-
{
|
|
39864
|
-
if (typeof recipe !== "function") {
|
|
39865
|
-
throw new Error("The first or second argument to `produce` must be a function");
|
|
39866
|
-
}
|
|
39867
|
-
|
|
39868
|
-
if (patchListener !== undefined && typeof patchListener !== "function") {
|
|
39869
|
-
throw new Error("The third argument to `produce` must be a function or undefined");
|
|
39870
|
-
}
|
|
39871
|
-
}
|
|
39872
|
-
var result; // Only plain objects, arrays, and "immerable classes" are drafted.
|
|
39873
|
-
|
|
39874
|
-
if (isDraftable(base)) {
|
|
39875
|
-
var scope = ImmerScope.enter();
|
|
39876
|
-
var proxy = this.createProxy(base);
|
|
39877
|
-
var hasError = true;
|
|
39878
|
-
|
|
39879
|
-
try {
|
|
39880
|
-
result = recipe(proxy);
|
|
39881
|
-
hasError = false;
|
|
39882
|
-
} finally {
|
|
39883
|
-
// finally instead of catch + rethrow better preserves original stack
|
|
39884
|
-
if (hasError) { scope.revoke(); }else { scope.leave(); }
|
|
39885
|
-
}
|
|
39886
|
-
|
|
39887
|
-
if (result instanceof Promise) {
|
|
39888
|
-
return result.then(function (result) {
|
|
39889
|
-
scope.usePatches(patchListener);
|
|
39890
|
-
return this$1$1.processResult(result, scope);
|
|
39891
|
-
}, function (error) {
|
|
39892
|
-
scope.revoke();
|
|
39893
|
-
throw error;
|
|
39894
|
-
});
|
|
39895
|
-
}
|
|
39896
|
-
|
|
39897
|
-
scope.usePatches(patchListener);
|
|
39898
|
-
return this.processResult(result, scope);
|
|
39899
|
-
} else {
|
|
39900
|
-
result = recipe(base);
|
|
39901
|
-
if (result === undefined) { return base; }
|
|
39902
|
-
return result !== NOTHING ? result : undefined;
|
|
39903
|
-
}
|
|
39904
|
-
};
|
|
39905
|
-
|
|
39906
|
-
Immer.prototype.produceWithPatches = function produceWithPatches (arg1, arg2, arg3) {
|
|
39907
|
-
var this$1$1 = this;
|
|
39908
|
-
|
|
39909
|
-
if (typeof arg1 === "function") {
|
|
39910
|
-
return function (state) {
|
|
39911
|
-
var args = [], len = arguments.length - 1;
|
|
39912
|
-
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
39913
|
-
|
|
39914
|
-
return this$1$1.produceWithPatches(state, function (draft) { return arg1.apply(void 0, [ draft ].concat( args )); });
|
|
39915
|
-
};
|
|
39916
|
-
} // non-curried form
|
|
39917
|
-
|
|
39918
|
-
|
|
39919
|
-
if (arg3) { throw new Error("A patch listener cannot be passed to produceWithPatches"); }
|
|
39920
|
-
var patches, inversePatches;
|
|
39921
|
-
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
39922
|
-
patches = p;
|
|
39923
|
-
inversePatches = ip;
|
|
39924
|
-
});
|
|
39925
|
-
return [nextState, patches, inversePatches];
|
|
39926
|
-
};
|
|
39927
|
-
|
|
39928
|
-
Immer.prototype.createDraft = function createDraft (base) {
|
|
39929
|
-
if (!isDraftable(base)) {
|
|
39930
|
-
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
39931
|
-
}
|
|
39932
|
-
|
|
39933
|
-
var scope = ImmerScope.enter();
|
|
39934
|
-
var proxy = this.createProxy(base);
|
|
39935
|
-
proxy[DRAFT_STATE].isManual = true;
|
|
39936
|
-
scope.leave();
|
|
39937
|
-
return proxy;
|
|
39938
|
-
};
|
|
39939
|
-
|
|
39940
|
-
Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
39941
|
-
var state = draft && draft[DRAFT_STATE];
|
|
39942
|
-
|
|
39943
|
-
if (!state || !state.isManual) {
|
|
39944
|
-
throw new Error("First argument to `finishDraft` must be a draft returned by `createDraft`"); // prettier-ignore
|
|
39945
|
-
}
|
|
39946
|
-
|
|
39947
|
-
if (state.finalized) {
|
|
39948
|
-
throw new Error("The given draft is already finalized"); // prettier-ignore
|
|
39949
|
-
}
|
|
39950
|
-
|
|
39951
|
-
var scope = state.scope;
|
|
39952
|
-
scope.usePatches(patchListener);
|
|
39953
|
-
return this.processResult(undefined, scope);
|
|
39954
|
-
};
|
|
39955
|
-
|
|
39956
|
-
Immer.prototype.setAutoFreeze = function setAutoFreeze (value) {
|
|
39957
|
-
this.autoFreeze = value;
|
|
39958
|
-
};
|
|
39959
|
-
|
|
39960
|
-
Immer.prototype.setUseProxies = function setUseProxies (value) {
|
|
39961
|
-
this.useProxies = value;
|
|
39962
|
-
assign(this, value ? modernProxy : legacyProxy);
|
|
39963
|
-
};
|
|
39964
|
-
|
|
39965
|
-
Immer.prototype.applyPatches = function applyPatches$1 (base, patches) {
|
|
39966
|
-
// If a patch replaces the entire state, take that replacement as base
|
|
39967
|
-
// before applying patches
|
|
39968
|
-
var i;
|
|
39969
|
-
|
|
39970
|
-
for (i = patches.length - 1; i >= 0; i--) {
|
|
39971
|
-
var patch = patches[i];
|
|
39972
|
-
|
|
39973
|
-
if (patch.path.length === 0 && patch.op === "replace") {
|
|
39974
|
-
base = patch.value;
|
|
39975
|
-
break;
|
|
39976
|
-
}
|
|
39977
|
-
}
|
|
39978
|
-
|
|
39979
|
-
if (isDraft(base)) {
|
|
39980
|
-
// N.B: never hits if some patch a replacement, patches are never drafts
|
|
39981
|
-
return applyPatches(base, patches);
|
|
39982
|
-
} // Otherwise, produce a copy of the base state.
|
|
39983
|
-
|
|
39984
|
-
|
|
39985
|
-
return this.produce(base, function (draft) { return applyPatches(draft, patches.slice(i + 1)); });
|
|
39986
|
-
};
|
|
39987
|
-
/** @internal */
|
|
39988
|
-
|
|
39989
|
-
|
|
39990
|
-
Immer.prototype.processResult = function processResult (result, scope) {
|
|
39991
|
-
var baseDraft = scope.drafts[0];
|
|
39992
|
-
var isReplaced = result !== undefined && result !== baseDraft;
|
|
39993
|
-
this.willFinalize(scope, result, isReplaced);
|
|
39994
|
-
|
|
39995
|
-
if (isReplaced) {
|
|
39996
|
-
if (baseDraft[DRAFT_STATE].modified) {
|
|
39997
|
-
scope.revoke();
|
|
39998
|
-
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
|
|
39999
|
-
}
|
|
40000
|
-
|
|
40001
|
-
if (isDraftable(result)) {
|
|
40002
|
-
// Finalize the result in case it contains (or is) a subset of the draft.
|
|
40003
|
-
result = this.finalize(result, null, scope);
|
|
40004
|
-
}
|
|
40005
|
-
|
|
40006
|
-
if (scope.patches) {
|
|
40007
|
-
scope.patches.push({
|
|
40008
|
-
op: "replace",
|
|
40009
|
-
path: [],
|
|
40010
|
-
value: result
|
|
40011
|
-
});
|
|
40012
|
-
scope.inversePatches.push({
|
|
40013
|
-
op: "replace",
|
|
40014
|
-
path: [],
|
|
40015
|
-
value: baseDraft[DRAFT_STATE].base
|
|
40016
|
-
});
|
|
40017
|
-
}
|
|
40018
|
-
} else {
|
|
40019
|
-
// Finalize the base draft.
|
|
40020
|
-
result = this.finalize(baseDraft, [], scope);
|
|
40021
|
-
}
|
|
40022
|
-
|
|
40023
|
-
scope.revoke();
|
|
40024
|
-
|
|
40025
|
-
if (scope.patches) {
|
|
40026
|
-
scope.patchListener(scope.patches, scope.inversePatches);
|
|
40027
|
-
}
|
|
40028
|
-
|
|
40029
|
-
return result !== NOTHING ? result : undefined;
|
|
40030
|
-
};
|
|
40031
|
-
/**
|
|
40032
|
-
* @internal
|
|
40033
|
-
* Finalize a draft, returning either the unmodified base state or a modified
|
|
40034
|
-
* copy of the base state.
|
|
40035
|
-
*/
|
|
40036
|
-
|
|
40037
|
-
|
|
40038
|
-
Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
40039
|
-
var this$1$1 = this;
|
|
40040
|
-
|
|
40041
|
-
var state = draft[DRAFT_STATE];
|
|
40042
|
-
|
|
40043
|
-
if (!state) {
|
|
40044
|
-
if (Object.isFrozen(draft)) { return draft; }
|
|
40045
|
-
return this.finalizeTree(draft, null, scope);
|
|
40046
|
-
} // Never finalize drafts owned by another scope.
|
|
40047
|
-
|
|
40048
|
-
|
|
40049
|
-
if (state.scope !== scope) {
|
|
40050
|
-
return draft;
|
|
40051
|
-
}
|
|
40052
|
-
|
|
40053
|
-
if (!state.modified) {
|
|
40054
|
-
return state.base;
|
|
40055
|
-
}
|
|
40056
|
-
|
|
40057
|
-
if (!state.finalized) {
|
|
40058
|
-
state.finalized = true;
|
|
40059
|
-
this.finalizeTree(state.draft, path, scope);
|
|
40060
|
-
|
|
40061
|
-
if (this.onDelete) {
|
|
40062
|
-
// The `assigned` object is unreliable with ES5 drafts.
|
|
40063
|
-
if (this.useProxies) {
|
|
40064
|
-
var assigned = state.assigned;
|
|
40065
|
-
|
|
40066
|
-
for (var prop in assigned) {
|
|
40067
|
-
if (!assigned[prop]) { this.onDelete(state, prop); }
|
|
40068
|
-
}
|
|
40069
|
-
} else {
|
|
40070
|
-
var base = state.base;
|
|
40071
|
-
var copy = state.copy;
|
|
40072
|
-
each(base, function (prop) {
|
|
40073
|
-
if (!has$1(copy, prop)) { this$1$1.onDelete(state, prop); }
|
|
40074
|
-
});
|
|
40075
|
-
}
|
|
40076
|
-
}
|
|
40077
|
-
|
|
40078
|
-
if (this.onCopy) {
|
|
40079
|
-
this.onCopy(state);
|
|
40080
|
-
} // At this point, all descendants of `state.copy` have been finalized,
|
|
40081
|
-
// so we can be sure that `scope.canAutoFreeze` is accurate.
|
|
40082
|
-
|
|
40083
|
-
|
|
40084
|
-
if (this.autoFreeze && scope.canAutoFreeze) {
|
|
40085
|
-
Object.freeze(state.copy);
|
|
40086
|
-
}
|
|
40087
|
-
|
|
40088
|
-
if (path && scope.patches) {
|
|
40089
|
-
generatePatches(state, path, scope.patches, scope.inversePatches);
|
|
40090
|
-
}
|
|
40091
|
-
}
|
|
40092
|
-
|
|
40093
|
-
return state.copy;
|
|
40094
|
-
};
|
|
40095
|
-
/**
|
|
40096
|
-
* @internal
|
|
40097
|
-
* Finalize all drafts in the given state tree.
|
|
40098
|
-
*/
|
|
40099
|
-
|
|
40100
|
-
|
|
40101
|
-
Immer.prototype.finalizeTree = function finalizeTree (root, rootPath, scope) {
|
|
40102
|
-
var this$1$1 = this;
|
|
40103
|
-
|
|
40104
|
-
var state = root[DRAFT_STATE];
|
|
40105
|
-
|
|
40106
|
-
if (state) {
|
|
40107
|
-
if (!this.useProxies) {
|
|
40108
|
-
// Create the final copy, with added keys and without deleted keys.
|
|
40109
|
-
state.copy = shallowCopy(state.draft, true);
|
|
40110
|
-
}
|
|
40111
|
-
|
|
40112
|
-
root = state.copy;
|
|
40113
|
-
}
|
|
40114
|
-
|
|
40115
|
-
var needPatches = !!rootPath && !!scope.patches;
|
|
40116
|
-
|
|
40117
|
-
var finalizeProperty = function (prop, value, parent) {
|
|
40118
|
-
if (value === parent) {
|
|
40119
|
-
throw Error("Immer forbids circular references");
|
|
40120
|
-
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
40121
|
-
|
|
40122
|
-
|
|
40123
|
-
var isDraftProp = !!state && parent === root;
|
|
40124
|
-
|
|
40125
|
-
if (isDraft(value)) {
|
|
40126
|
-
var path = isDraftProp && needPatches && !state.assigned[prop] ? rootPath.concat(prop) : null; // Drafts owned by `scope` are finalized here.
|
|
40127
|
-
|
|
40128
|
-
value = this$1$1.finalize(value, path, scope); // Drafts from another scope must prevent auto-freezing.
|
|
40129
|
-
|
|
40130
|
-
if (isDraft(value)) {
|
|
40131
|
-
scope.canAutoFreeze = false;
|
|
40132
|
-
} // Preserve non-enumerable properties.
|
|
40133
|
-
|
|
40134
|
-
|
|
40135
|
-
if (Array.isArray(parent) || isEnumerable(parent, prop)) {
|
|
40136
|
-
parent[prop] = value;
|
|
40137
|
-
} else {
|
|
40138
|
-
Object.defineProperty(parent, prop, {
|
|
40139
|
-
value: value
|
|
40140
|
-
});
|
|
40141
|
-
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
40142
|
-
|
|
40143
|
-
|
|
40144
|
-
if (isDraftProp && value === state.base[prop]) { return; }
|
|
40145
|
-
} // Unchanged draft properties are ignored.
|
|
40146
|
-
else if (isDraftProp && is(value, state.base[prop])) {
|
|
40147
|
-
return;
|
|
40148
|
-
} // Search new objects for unfinalized drafts. Frozen objects should never contain drafts.
|
|
40149
|
-
else if (isDraftable(value) && !Object.isFrozen(value)) {
|
|
40150
|
-
each(value, finalizeProperty);
|
|
40151
|
-
}
|
|
40152
|
-
|
|
40153
|
-
if (isDraftProp && this$1$1.onAssign) {
|
|
40154
|
-
this$1$1.onAssign(state, prop, value);
|
|
40155
|
-
}
|
|
40156
|
-
};
|
|
40157
|
-
|
|
40158
|
-
each(root, finalizeProperty);
|
|
40159
|
-
return root;
|
|
40160
|
-
};
|
|
40161
|
-
|
|
40162
|
-
var immer = new Immer();
|
|
40163
|
-
/**
|
|
40164
|
-
* The `produce` function takes a value and a "recipe function" (whose
|
|
40165
|
-
* return value often depends on the base state). The recipe function is
|
|
40166
|
-
* free to mutate its first argument however it wants. All mutations are
|
|
40167
|
-
* only ever applied to a __copy__ of the base state.
|
|
40168
|
-
*
|
|
40169
|
-
* Pass only a function to create a "curried producer" which relieves you
|
|
40170
|
-
* from passing the recipe function every time.
|
|
40171
|
-
*
|
|
40172
|
-
* Only plain objects and arrays are made mutable. All other objects are
|
|
40173
|
-
* considered uncopyable.
|
|
40174
|
-
*
|
|
40175
|
-
* Note: This function is __bound__ to its `Immer` instance.
|
|
40176
|
-
*
|
|
40177
|
-
* @param {any} base - the initial state
|
|
40178
|
-
* @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified
|
|
40179
|
-
* @param {Function} patchListener - optional function that will be called with all the patches produced here
|
|
40180
|
-
* @returns {any} a new state, or the initial state if nothing was modified
|
|
40181
|
-
*/
|
|
40182
|
-
|
|
40183
|
-
var produce = immer.produce;
|
|
40184
|
-
/**
|
|
40185
|
-
* Like `produce`, but `produceWithPatches` always returns a tuple
|
|
40186
|
-
* [nextState, patches, inversePatches] (instead of just the next state)
|
|
40187
|
-
*/
|
|
40188
|
-
|
|
40189
|
-
immer.produceWithPatches.bind(immer);
|
|
40190
|
-
/**
|
|
40191
|
-
* Pass true to automatically freeze all copies created by Immer.
|
|
40192
|
-
*
|
|
40193
|
-
* By default, auto-freezing is disabled in production.
|
|
40194
|
-
*/
|
|
40195
|
-
|
|
40196
|
-
immer.setAutoFreeze.bind(immer);
|
|
40197
|
-
/**
|
|
40198
|
-
* Pass true to use the ES2015 `Proxy` class when creating drafts, which is
|
|
40199
|
-
* always faster than using ES5 proxies.
|
|
40200
|
-
*
|
|
40201
|
-
* By default, feature detection is used, so calling this is rarely necessary.
|
|
40202
|
-
*/
|
|
40203
|
-
|
|
40204
|
-
immer.setUseProxies.bind(immer);
|
|
40205
|
-
/**
|
|
40206
|
-
* Apply an array of Immer patches to the first argument.
|
|
40207
|
-
*
|
|
40208
|
-
* This function is a producer, which means copy-on-write is in effect.
|
|
40209
|
-
*/
|
|
40210
|
-
|
|
40211
|
-
immer.applyPatches.bind(immer);
|
|
40212
|
-
/**
|
|
40213
|
-
* Create an Immer draft from the given base state, which may be a draft itself.
|
|
40214
|
-
* The draft can be modified until you finalize it with the `finishDraft` function.
|
|
40215
|
-
*/
|
|
40216
|
-
|
|
40217
|
-
immer.createDraft.bind(immer);
|
|
40218
|
-
/**
|
|
40219
|
-
* Finalize an Immer draft from a `createDraft` call, returning the base state
|
|
40220
|
-
* (if no changes were made) or a modified copy. The draft must *not* be
|
|
40221
|
-
* mutated afterwards.
|
|
40222
|
-
*
|
|
40223
|
-
* Pass a function as the 2nd argument to generate Immer patches based on the
|
|
40224
|
-
* changes that were made.
|
|
40225
|
-
*/
|
|
40226
|
-
|
|
40227
|
-
immer.finishDraft.bind(immer);
|
|
40228
|
-
|
|
40229
|
-
const createInitialState = formConfig => {
|
|
39113
|
+
const createInitialState = (formConfig) => {
|
|
40230
39114
|
let initialForm = {};
|
|
40231
39115
|
const formConfigKeys = Object.keys(formConfig);
|
|
40232
39116
|
for (let formKey of formConfigKeys) {
|
|
40233
39117
|
initialForm[formKey] = {
|
|
40234
39118
|
dirty: false,
|
|
40235
|
-
rawValue: formConfig[formKey].defaultValue ||
|
|
39119
|
+
rawValue: formConfig[formKey].defaultValue || '',
|
|
40236
39120
|
validators: formConfig[formKey].validators || [],
|
|
40237
|
-
constraints: formConfig[formKey].constraints || []
|
|
39121
|
+
constraints: formConfig[formKey].constraints || [],
|
|
40238
39122
|
};
|
|
40239
39123
|
}
|
|
40240
39124
|
// Because validators require the entire form we have to do a
|
|
@@ -40245,82 +39129,99 @@ const createInitialState = formConfig => {
|
|
|
40245
39129
|
initialForm[formKey].errors = errors;
|
|
40246
39130
|
initialForm[formKey].hasErrors = errors.length > 0;
|
|
40247
39131
|
}
|
|
39132
|
+
|
|
40248
39133
|
return initialForm;
|
|
40249
39134
|
};
|
|
40250
39135
|
|
|
40251
|
-
const SET =
|
|
40252
|
-
const set$
|
|
39136
|
+
const SET = 'field/SET';
|
|
39137
|
+
const set$1 = (fieldName) => (value) => ({
|
|
40253
39138
|
type: SET,
|
|
40254
|
-
payload: { fieldName, value }
|
|
39139
|
+
payload: { fieldName, value },
|
|
40255
39140
|
});
|
|
40256
39141
|
|
|
40257
|
-
const CLEAR =
|
|
39142
|
+
const CLEAR = 'form/CLEAR';
|
|
40258
39143
|
const clear = () => ({ type: CLEAR });
|
|
40259
39144
|
|
|
40260
|
-
const ADD_VALIDATOR =
|
|
40261
|
-
const addValidator = fieldName => validator => ({
|
|
39145
|
+
const ADD_VALIDATOR = 'field/ADD_VALIDATOR';
|
|
39146
|
+
const addValidator = (fieldName) => (validator) => ({
|
|
40262
39147
|
type: ADD_VALIDATOR,
|
|
40263
|
-
payload: { fieldName, validator }
|
|
39148
|
+
payload: { fieldName, validator },
|
|
40264
39149
|
});
|
|
40265
39150
|
|
|
40266
|
-
const
|
|
40267
|
-
|
|
40268
|
-
|
|
40269
|
-
|
|
40270
|
-
|
|
40271
|
-
case SET:
|
|
40272
|
-
const changedFieldName = action.payload.fieldName;
|
|
40273
|
-
const newRawValue = action.payload.value;
|
|
40274
|
-
|
|
40275
|
-
return produce(state, draftState => {
|
|
40276
|
-
let originalValue = draftState[changedFieldName].rawValue;
|
|
40277
|
-
draftState[changedFieldName].rawValue = newRawValue;
|
|
40278
|
-
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
40279
|
-
// If the change violates constraints, revert the change
|
|
40280
|
-
draftState[changedFieldName].rawValue = originalValue;
|
|
40281
|
-
return draftState;
|
|
40282
|
-
}
|
|
39151
|
+
const REMOVE_VALIDATOR = 'field/REMOVE_VALIDATOR';
|
|
39152
|
+
const removeValidator = (fieldName) => (validator) => ({
|
|
39153
|
+
type: REMOVE_VALIDATOR,
|
|
39154
|
+
payload: { fieldName, validator },
|
|
39155
|
+
});
|
|
40283
39156
|
|
|
40284
|
-
|
|
40285
|
-
|
|
40286
|
-
|
|
40287
|
-
|
|
40288
|
-
|
|
40289
|
-
|
|
40290
|
-
|
|
40291
|
-
|
|
40292
|
-
|
|
40293
|
-
|
|
40294
|
-
|
|
40295
|
-
|
|
40296
|
-
|
|
40297
|
-
|
|
40298
|
-
|
|
40299
|
-
|
|
40300
|
-
|
|
40301
|
-
|
|
40302
|
-
|
|
40303
|
-
|
|
40304
|
-
|
|
40305
|
-
|
|
40306
|
-
|
|
40307
|
-
|
|
40308
|
-
|
|
40309
|
-
|
|
40310
|
-
|
|
40311
|
-
|
|
40312
|
-
|
|
40313
|
-
|
|
40314
|
-
|
|
40315
|
-
|
|
40316
|
-
|
|
40317
|
-
|
|
39157
|
+
const CLEAR_FIELD_VALIDATORS = 'field/CLEAR_FIELD_VALIDATORS';
|
|
39158
|
+
const clearFieldValidators = (fieldName) => () => ({
|
|
39159
|
+
type: CLEAR_FIELD_VALIDATORS,
|
|
39160
|
+
payload: { fieldName },
|
|
39161
|
+
});
|
|
39162
|
+
|
|
39163
|
+
const createFormReducer =
|
|
39164
|
+
(formConfig) =>
|
|
39165
|
+
(state = createInitialState(formConfig), action) => {
|
|
39166
|
+
switch (action.type) {
|
|
39167
|
+
case SET: {
|
|
39168
|
+
const changedFieldName = action.payload.fieldName;
|
|
39169
|
+
const newRawValue = action.payload.value;
|
|
39170
|
+
|
|
39171
|
+
return produce(state, (draftState) => {
|
|
39172
|
+
let originalValue = draftState[changedFieldName].rawValue;
|
|
39173
|
+
draftState[changedFieldName].rawValue = newRawValue;
|
|
39174
|
+
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
39175
|
+
// If the change violates constraints, revert the change
|
|
39176
|
+
draftState[changedFieldName].rawValue = originalValue;
|
|
39177
|
+
return draftState;
|
|
39178
|
+
}
|
|
39179
|
+
|
|
39180
|
+
computeDirtyEntries(draftState, changedFieldName);
|
|
39181
|
+
computeErrorEntries(draftState);
|
|
39182
|
+
});
|
|
39183
|
+
}
|
|
39184
|
+
case CLEAR:
|
|
39185
|
+
return createInitialState(formConfig);
|
|
39186
|
+
case ADD_VALIDATOR: {
|
|
39187
|
+
const fieldWithOverride = action.payload.fieldName;
|
|
39188
|
+
const newValidator = action.payload.validator;
|
|
39189
|
+
|
|
39190
|
+
return produce(state, (draftState) => {
|
|
39191
|
+
draftState[fieldWithOverride].validators.push(newValidator);
|
|
39192
|
+
computeErrorEntries(draftState);
|
|
39193
|
+
});
|
|
39194
|
+
}
|
|
39195
|
+
case REMOVE_VALIDATOR: {
|
|
39196
|
+
const fieldToOverride = action.payload.fieldName;
|
|
39197
|
+
const targetValidator = action.payload.validator;
|
|
39198
|
+
|
|
39199
|
+
return produce(state, (draftState) => {
|
|
39200
|
+
let fieldValidators = draftState[fieldToOverride].validators;
|
|
39201
|
+
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
39202
|
+
(validator) => validator.type !== targetValidator.type
|
|
39203
|
+
);
|
|
39204
|
+
computeErrorEntries(draftState);
|
|
39205
|
+
});
|
|
39206
|
+
}
|
|
39207
|
+
case CLEAR_FIELD_VALIDATORS: {
|
|
39208
|
+
const fieldToClear = action.payload.fieldName;
|
|
40318
39209
|
|
|
40319
|
-
|
|
39210
|
+
return produce(state, (draftState) => {
|
|
39211
|
+
draftState[fieldToClear].validators = [];
|
|
39212
|
+
computeErrorEntries(draftState);
|
|
39213
|
+
});
|
|
39214
|
+
}
|
|
39215
|
+
default:
|
|
39216
|
+
return state;
|
|
39217
|
+
}
|
|
39218
|
+
};
|
|
39219
|
+
|
|
39220
|
+
const createMapDispatchToProps = (formConfig) => {
|
|
40320
39221
|
// Do memo-ization
|
|
40321
39222
|
let cachedDispatch;
|
|
40322
39223
|
let cacheValue;
|
|
40323
|
-
return dispatch => {
|
|
39224
|
+
return (dispatch) => {
|
|
40324
39225
|
if (dispatch == cachedDispatch) {
|
|
40325
39226
|
return cacheValue;
|
|
40326
39227
|
}
|
|
@@ -40329,8 +39230,11 @@ const createMapDispatchToProps = formConfig => {
|
|
|
40329
39230
|
const keys = Object.keys(formConfig);
|
|
40330
39231
|
for (let fieldName of keys) {
|
|
40331
39232
|
dispatchObj.fields[fieldName] = {
|
|
40332
|
-
set: value => dispatch(set$
|
|
40333
|
-
addValidator: validator => dispatch(addValidator(fieldName)(validator))
|
|
39233
|
+
set: (value) => dispatch(set$1(fieldName)(value)),
|
|
39234
|
+
addValidator: (validator) => dispatch(addValidator(fieldName)(validator)),
|
|
39235
|
+
removeValidator: (validator) =>
|
|
39236
|
+
dispatch(removeValidator(fieldName)(validator)),
|
|
39237
|
+
clear: () => dispatch(clearFieldValidators(fieldName)()),
|
|
40334
39238
|
};
|
|
40335
39239
|
}
|
|
40336
39240
|
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
@@ -40340,12 +39244,12 @@ const createMapDispatchToProps = formConfig => {
|
|
|
40340
39244
|
};
|
|
40341
39245
|
};
|
|
40342
39246
|
|
|
40343
|
-
const mapStateToProps = state => ({ fields: state });
|
|
39247
|
+
const mapStateToProps = (state) => ({ fields: state });
|
|
40344
39248
|
|
|
40345
|
-
const createFormState = formConfig => ({
|
|
39249
|
+
const createFormState = (formConfig) => ({
|
|
40346
39250
|
reducer: createFormReducer(formConfig),
|
|
40347
39251
|
mapDispatchToProps: createMapDispatchToProps(formConfig),
|
|
40348
|
-
mapStateToProps: mapStateToProps
|
|
39252
|
+
mapStateToProps: mapStateToProps,
|
|
40349
39253
|
});
|
|
40350
39254
|
|
|
40351
39255
|
var AddressForm = function AddressForm(_ref) {
|
|
@@ -43211,12 +42115,12 @@ LoginForm.mapDispatchToProps = mapDispatchToProps$5;
|
|
|
43211
42115
|
* This source code is licensed under the MIT license found in the
|
|
43212
42116
|
* LICENSE file in the root directory of this source tree.
|
|
43213
42117
|
*/
|
|
43214
|
-
var b$
|
|
43215
|
-
Symbol.for("react.suspense_list"):60120,r=b$
|
|
43216
|
-
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c$
|
|
43217
|
-
var Profiler=g;var StrictMode=f$
|
|
43218
|
-
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$
|
|
43219
|
-
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f$
|
|
42118
|
+
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?
|
|
42119
|
+
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;
|
|
42120
|
+
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;
|
|
42121
|
+
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};
|
|
42122
|
+
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};
|
|
42123
|
+
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;
|
|
43220
42124
|
|
|
43221
42125
|
var reactIs_production_min = {
|
|
43222
42126
|
AsyncMode: AsyncMode,
|
|
@@ -43587,14 +42491,14 @@ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
|
43587
42491
|
|
|
43588
42492
|
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
43589
42493
|
|
|
43590
|
-
var has$
|
|
42494
|
+
var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
43591
42495
|
|
|
43592
42496
|
var printWarning = function() {};
|
|
43593
42497
|
|
|
43594
42498
|
if (process.env.NODE_ENV !== 'production') {
|
|
43595
42499
|
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
43596
42500
|
var loggedTypeFailures = {};
|
|
43597
|
-
var has$
|
|
42501
|
+
var has$2 = has$1;
|
|
43598
42502
|
|
|
43599
42503
|
printWarning = function(text) {
|
|
43600
42504
|
var message = 'Warning: ' + text;
|
|
@@ -43624,7 +42528,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
43624
42528
|
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
43625
42529
|
if (process.env.NODE_ENV !== 'production') {
|
|
43626
42530
|
for (var typeSpecName in typeSpecs) {
|
|
43627
|
-
if (has$
|
|
42531
|
+
if (has$2(typeSpecs, typeSpecName)) {
|
|
43628
42532
|
var error;
|
|
43629
42533
|
// Prop type validation may throw. In case they do, we don't want to
|
|
43630
42534
|
// fail the render phase where it didn't fail before. So we log it.
|
|
@@ -44023,7 +42927,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44023
42927
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
44024
42928
|
}
|
|
44025
42929
|
for (var key in propValue) {
|
|
44026
|
-
if (has$
|
|
42930
|
+
if (has$1(propValue, key)) {
|
|
44027
42931
|
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
44028
42932
|
if (error instanceof Error) {
|
|
44029
42933
|
return error;
|
|
@@ -44060,7 +42964,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44060
42964
|
if (checkerResult == null) {
|
|
44061
42965
|
return null;
|
|
44062
42966
|
}
|
|
44063
|
-
if (checkerResult.data && has$
|
|
42967
|
+
if (checkerResult.data && has$1(checkerResult.data, 'expectedType')) {
|
|
44064
42968
|
expectedTypes.push(checkerResult.data.expectedType);
|
|
44065
42969
|
}
|
|
44066
42970
|
}
|
|
@@ -44120,7 +43024,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44120
43024
|
var allKeys = objectAssign({}, props[propName], shapeTypes);
|
|
44121
43025
|
for (var key in allKeys) {
|
|
44122
43026
|
var checker = shapeTypes[key];
|
|
44123
|
-
if (has$
|
|
43027
|
+
if (has$1(shapeTypes, key) && typeof checker !== 'function') {
|
|
44124
43028
|
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
44125
43029
|
}
|
|
44126
43030
|
if (!checker) {
|
|
@@ -44858,7 +43762,7 @@ var index_esm = /*#__PURE__*/Object.freeze({
|
|
|
44858
43762
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
44859
43763
|
*/
|
|
44860
43764
|
|
|
44861
|
-
function ownKeys$
|
|
43765
|
+
function ownKeys$2(object, enumerableOnly) {
|
|
44862
43766
|
var keys = Object.keys(object);
|
|
44863
43767
|
|
|
44864
43768
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -44874,9 +43778,9 @@ function ownKeys$3(object, enumerableOnly) {
|
|
|
44874
43778
|
function _objectSpread2$1(target) {
|
|
44875
43779
|
for (var i = 1; i < arguments.length; i++) {
|
|
44876
43780
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
44877
|
-
i % 2 ? ownKeys$
|
|
43781
|
+
i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) {
|
|
44878
43782
|
_defineProperty$1(target, key, source[key]);
|
|
44879
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$
|
|
43783
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) {
|
|
44880
43784
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
44881
43785
|
});
|
|
44882
43786
|
}
|
|
@@ -47847,24 +46751,7 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
|
|
|
47847
46751
|
var minimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
47848
46752
|
var blockPartialPaymentOverpay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
47849
46753
|
var formConfig = lineItems.reduce(function (acc, item) {
|
|
47850
|
-
var validators =
|
|
47851
|
-
return lineItem != item;
|
|
47852
|
-
}).reduce(function (acc, curr) {
|
|
47853
|
-
return [].concat(_toConsumableArray(acc), [curr.id]);
|
|
47854
|
-
}, []))];
|
|
47855
|
-
|
|
47856
|
-
if (!!maximum) {
|
|
47857
|
-
validators.push(validateSum(numberLessThanOrEqualTo(maximum), lineItems.filter(function (lineItem) {
|
|
47858
|
-
return lineItem != item;
|
|
47859
|
-
}).reduce(function (acc, curr) {
|
|
47860
|
-
return [].concat(_toConsumableArray(acc), [curr.id]);
|
|
47861
|
-
}, [])));
|
|
47862
|
-
}
|
|
47863
|
-
|
|
47864
|
-
if (blockPartialPaymentOverpay) {
|
|
47865
|
-
validators.push(numberLessThanOrEqualTo(item.amount));
|
|
47866
|
-
}
|
|
47867
|
-
|
|
46754
|
+
var validators = createPartialAmountFormValidators(item, lineItems, maximum, minimum, blockPartialPaymentOverpay);
|
|
47868
46755
|
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, item.id, {
|
|
47869
46756
|
validators: validators,
|
|
47870
46757
|
constraints: [onlyNaturals()],
|
|
@@ -47883,6 +46770,29 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
|
|
|
47883
46770
|
partialAmountFormMapDispatchToProps: mapDispatchToProps
|
|
47884
46771
|
};
|
|
47885
46772
|
};
|
|
46773
|
+
var createPartialAmountFormValidators = function createPartialAmountFormValidators(item, lineItems, maximum) {
|
|
46774
|
+
var minimum = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
46775
|
+
var blockPartialPaymentOverpay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
46776
|
+
var validators = [required(), validateSum(numberGreaterThanOrEqualTo(minimum), lineItems.filter(function (lineItem) {
|
|
46777
|
+
return lineItem != item;
|
|
46778
|
+
}).reduce(function (acc, curr) {
|
|
46779
|
+
return [].concat(_toConsumableArray(acc), [curr.id]);
|
|
46780
|
+
}, []))];
|
|
46781
|
+
|
|
46782
|
+
if (!!maximum) {
|
|
46783
|
+
validators.push(validateSum(numberLessThanOrEqualTo(maximum), lineItems.filter(function (lineItem) {
|
|
46784
|
+
return lineItem != item;
|
|
46785
|
+
}).reduce(function (acc, curr) {
|
|
46786
|
+
return [].concat(_toConsumableArray(acc), [curr.id]);
|
|
46787
|
+
}, [])));
|
|
46788
|
+
}
|
|
46789
|
+
|
|
46790
|
+
if (blockPartialPaymentOverpay) {
|
|
46791
|
+
validators.push(numberLessThanOrEqualTo(item.amount));
|
|
46792
|
+
}
|
|
46793
|
+
|
|
46794
|
+
return validators;
|
|
46795
|
+
};
|
|
47886
46796
|
|
|
47887
46797
|
var arrowColor = WHITE;
|
|
47888
46798
|
var numberColor = MATISSE_BLUE;
|
|
@@ -48261,22 +47171,57 @@ var PaymentDetailsContent = function PaymentDetailsContent(_ref) {
|
|
|
48261
47171
|
var LoadingDetails = function LoadingDetails() {
|
|
48262
47172
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
48263
47173
|
padding: "0",
|
|
48264
|
-
background: GRECIAN_GREY,
|
|
48265
|
-
borderRadius: "4px",
|
|
48266
47174
|
minHeight: "196px"
|
|
48267
|
-
}, /*#__PURE__*/React__default.createElement(Cover, {
|
|
48268
|
-
minHeight: "196px",
|
|
48269
|
-
singleChild: true,
|
|
48270
|
-
fillCenter: true
|
|
48271
|
-
}, /*#__PURE__*/React__default.createElement(Center, {
|
|
48272
|
-
intrinsic: true
|
|
48273
47175
|
}, /*#__PURE__*/React__default.createElement(Box, {
|
|
48274
47176
|
padding: "0",
|
|
48275
|
-
extraStyles: "
|
|
47177
|
+
extraStyles: "position: absolute;\n height: 200px;\n width: 100%;\n display: flex;\n justify-content: center;\n align-items: center;"
|
|
48276
47178
|
}, /*#__PURE__*/React__default.createElement(Spinner$2, {
|
|
48277
47179
|
size: "100",
|
|
48278
47180
|
centerSpinner: true
|
|
48279
|
-
}))
|
|
47181
|
+
})), /*#__PURE__*/React__default.createElement(Stack, {
|
|
47182
|
+
childGap: "16px"
|
|
47183
|
+
}, /*#__PURE__*/React__default.createElement(Cluster, {
|
|
47184
|
+
nowrap: true,
|
|
47185
|
+
justify: "space-between",
|
|
47186
|
+
align: "start"
|
|
47187
|
+
}, /*#__PURE__*/React__default.createElement(LoadingLine, {
|
|
47188
|
+
exactWidth: "110",
|
|
47189
|
+
height: "27px"
|
|
47190
|
+
}), /*#__PURE__*/React__default.createElement(LoadingLine, {
|
|
47191
|
+
exactWidth: "60",
|
|
47192
|
+
height: "27px"
|
|
47193
|
+
})), /*#__PURE__*/React__default.createElement(SolidDivider$1, null), /*#__PURE__*/React__default.createElement(Box, {
|
|
47194
|
+
padding: "0.5rem 0"
|
|
47195
|
+
}, /*#__PURE__*/React__default.createElement(Cluster, {
|
|
47196
|
+
justify: "space-between",
|
|
47197
|
+
align: "start"
|
|
47198
|
+
}, /*#__PURE__*/React__default.createElement(LoadingLine, {
|
|
47199
|
+
exactWidth: "80",
|
|
47200
|
+
height: "27px"
|
|
47201
|
+
}), /*#__PURE__*/React__default.createElement(LoadingLine, {
|
|
47202
|
+
exactWidth: "60",
|
|
47203
|
+
height: "27px"
|
|
47204
|
+
})), /*#__PURE__*/React__default.createElement(Box, {
|
|
47205
|
+
padding: "4px 0"
|
|
47206
|
+
}), /*#__PURE__*/React__default.createElement(Cluster, {
|
|
47207
|
+
justify: "space-between",
|
|
47208
|
+
align: "start"
|
|
47209
|
+
}, /*#__PURE__*/React__default.createElement(LoadingLine, {
|
|
47210
|
+
exactWidth: "100",
|
|
47211
|
+
height: "27px"
|
|
47212
|
+
}), /*#__PURE__*/React__default.createElement(LoadingLine, {
|
|
47213
|
+
exactWidth: "50",
|
|
47214
|
+
height: "27px"
|
|
47215
|
+
}))), /*#__PURE__*/React__default.createElement(SolidDivider$1, null), /*#__PURE__*/React__default.createElement(Stack, {
|
|
47216
|
+
justify: "space-between",
|
|
47217
|
+
direction: "row"
|
|
47218
|
+
}, /*#__PURE__*/React__default.createElement(LoadingLine, {
|
|
47219
|
+
exactWidth: "55",
|
|
47220
|
+
height: "30px"
|
|
47221
|
+
}), /*#__PURE__*/React__default.createElement(LoadingLine, {
|
|
47222
|
+
exactWidth: "70",
|
|
47223
|
+
height: "30px"
|
|
47224
|
+
}))));
|
|
48280
47225
|
};
|
|
48281
47226
|
|
|
48282
47227
|
var ErrorDetails = function ErrorDetails() {
|
|
@@ -48565,7 +47510,6 @@ var AccountAndRoutingModal = function AccountAndRoutingModal(_ref) {
|
|
|
48565
47510
|
toggleOpen(false);
|
|
48566
47511
|
}
|
|
48567
47512
|
}, /*#__PURE__*/React__default.createElement(Text$1, {
|
|
48568
|
-
role: "button",
|
|
48569
47513
|
variant: "pS",
|
|
48570
47514
|
onClick: function onClick() {
|
|
48571
47515
|
return toggleOpen(true);
|
|
@@ -48693,12 +47637,9 @@ var TermsAndConditionsControlV1 = function TermsAndConditionsControlV1(_ref) {
|
|
|
48693
47637
|
showTerms = _useState2[0],
|
|
48694
47638
|
toggleShowTerms = _useState2[1];
|
|
48695
47639
|
|
|
48696
|
-
return /*#__PURE__*/React__default.createElement(DisplayBox$1, {
|
|
48697
|
-
dataQa: "TermsAndConditionsControlV1"
|
|
48698
|
-
}, /*#__PURE__*/React__default.createElement(Stack, null, /*#__PURE__*/React__default.createElement(Checkbox$1, {
|
|
47640
|
+
return /*#__PURE__*/React__default.createElement(DisplayBox$1, null, /*#__PURE__*/React__default.createElement(Stack, null, /*#__PURE__*/React__default.createElement(Checkbox$1, {
|
|
48699
47641
|
name: "terms",
|
|
48700
47642
|
title: "Terms and Conditions",
|
|
48701
|
-
dataQa: "Terms and Conditions",
|
|
48702
47643
|
error: error,
|
|
48703
47644
|
checked: isChecked,
|
|
48704
47645
|
onChange: onCheck
|
|
@@ -48799,8 +47740,7 @@ var TermsAndConditionsControlV2 = function TermsAndConditionsControlV2(_ref) {
|
|
|
48799
47740
|
minWidth: displayInline ? "0" : "100%",
|
|
48800
47741
|
background: displayInline ? "transparent" : containerBackground,
|
|
48801
47742
|
boxShadow: displayInline ? "none" : standardBoxShadow,
|
|
48802
|
-
borderRadius: displayInline ? "0" : "4px"
|
|
48803
|
-
dataQa: "TermsAndConditionsControlV2"
|
|
47743
|
+
borderRadius: displayInline ? "0" : "4px"
|
|
48804
47744
|
}, /*#__PURE__*/React__default.createElement(Stack, {
|
|
48805
47745
|
childGap: "0"
|
|
48806
47746
|
}, html && /*#__PURE__*/React__default.createElement(Box, {
|
|
@@ -49421,7 +48361,8 @@ var PhoneForm = function PhoneForm(_ref) {
|
|
|
49421
48361
|
return e.key === "Enter" && handleSubmit(e);
|
|
49422
48362
|
},
|
|
49423
48363
|
autocompleteValue: "tel",
|
|
49424
|
-
dataQa: "Phone number"
|
|
48364
|
+
dataQa: "Phone number",
|
|
48365
|
+
isNum: true
|
|
49425
48366
|
}), showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
|
|
49426
48367
|
name: "phone checkbox",
|
|
49427
48368
|
title: "Save phone number to wallet",
|
|
@@ -50755,6 +49696,7 @@ exports.XCircleIconSmall = XCircleIconSmall;
|
|
|
50755
49696
|
exports.cardRegistry = cardRegistry;
|
|
50756
49697
|
exports.constants = index$5;
|
|
50757
49698
|
exports.createPartialAmountFormState = createPartialAmountFormState;
|
|
49699
|
+
exports.createPartialAmountFormValidators = createPartialAmountFormValidators;
|
|
50758
49700
|
exports.util = index$4;
|
|
50759
49701
|
exports.withWindowSize = withWindowSize;
|
|
50760
49702
|
//# sourceMappingURL=index.cjs.js.map
|