@thecb/components 9.0.3-beta.8 → 9.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1359 -275
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1359 -275
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/components/atoms/.DS_Store +0 -0
- package/src/components/atoms/line-item/LineItem.js +39 -24
- package/src/components/{atoms/icons → molecules}/.DS_Store +0 -0
- package/src/components/molecules/radio-section/RadioSection.js +12 -28
- package/src/components/molecules/radio-section/radio-button/RadioButton.js +3 -12
- package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +0 -49322
- package/src/components/.DS_Store +0 -0
- /package/src/components/atoms/icons/{ExternalLinkIcon.js → ExternalLinkicon.js} +0 -0
package/dist/index.cjs.js
CHANGED
|
@@ -26603,12 +26603,26 @@ var fallbackValues$q = {
|
|
|
26603
26603
|
};
|
|
26604
26604
|
|
|
26605
26605
|
var LineItem = function LineItem(_ref) {
|
|
26606
|
+
var _customAttributes$fil;
|
|
26607
|
+
|
|
26606
26608
|
var description = _ref.description,
|
|
26607
26609
|
subDescription = _ref.subDescription,
|
|
26608
26610
|
amount = _ref.amount,
|
|
26609
26611
|
themeValues = _ref.themeValues,
|
|
26612
|
+
customAttributes = _ref.customAttributes,
|
|
26613
|
+
_ref$visibleFields = _ref.visibleFields,
|
|
26614
|
+
visibleFields = _ref$visibleFields === void 0 ? [] : _ref$visibleFields,
|
|
26610
26615
|
_ref$displayQuantity = _ref.displayQuantity,
|
|
26611
26616
|
displayQuantity = _ref$displayQuantity === void 0 ? null : _ref$displayQuantity;
|
|
26617
|
+
var visibleCustomAttrs = customAttributes === null || customAttributes === void 0 ? void 0 : (_customAttributes$fil = customAttributes.filter(function (attr) {
|
|
26618
|
+
return visibleFields.includes(attr.key);
|
|
26619
|
+
})) === null || _customAttributes$fil === void 0 ? void 0 : _customAttributes$fil.map(function (attr) {
|
|
26620
|
+
return /*#__PURE__*/React__default.createElement(Paragraph$1, {
|
|
26621
|
+
variant: themeValues.paragraphVariant,
|
|
26622
|
+
weight: "400",
|
|
26623
|
+
key: attr.key
|
|
26624
|
+
}, "".concat(attr.key, ": ").concat(attr.value));
|
|
26625
|
+
});
|
|
26612
26626
|
return /*#__PURE__*/React__default.createElement(Cluster, {
|
|
26613
26627
|
nowrap: true,
|
|
26614
26628
|
justify: "space-between",
|
|
@@ -26621,7 +26635,9 @@ var LineItem = function LineItem(_ref) {
|
|
|
26621
26635
|
}, description), /*#__PURE__*/React__default.createElement(Paragraph$1, {
|
|
26622
26636
|
variant: themeValues.paragraphVariant,
|
|
26623
26637
|
weight: "400"
|
|
26624
|
-
}, subDescription)
|
|
26638
|
+
}, subDescription), visibleCustomAttrs && /*#__PURE__*/React__default.createElement(Stack, {
|
|
26639
|
+
childGap: "0"
|
|
26640
|
+
}, visibleCustomAttrs)), !!displayQuantity && /*#__PURE__*/React__default.createElement(Paragraph$1, {
|
|
26625
26641
|
variant: themeValues.paragraphVariant,
|
|
26626
26642
|
weight: themeValues.weightTitle
|
|
26627
26643
|
}, "x".concat(displayQuantity)), /*#__PURE__*/React__default.createElement(Paragraph$1, {
|
|
@@ -27219,11 +27235,7 @@ var RadioButton$1 = function RadioButton(_ref2) {
|
|
|
27219
27235
|
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
27220
27236
|
_ref2$ariaDescribedBy = _ref2.ariaDescribedBy,
|
|
27221
27237
|
ariaDescribedBy = _ref2$ariaDescribedBy === void 0 ? "" : _ref2$ariaDescribedBy,
|
|
27222
|
-
themeValues = _ref2.themeValues
|
|
27223
|
-
_ref2$ariaLabelledBy = _ref2.ariaLabelledBy,
|
|
27224
|
-
ariaLabelledBy = _ref2$ariaLabelledBy === void 0 ? "" : _ref2$ariaLabelledBy,
|
|
27225
|
-
_ref2$ariaLabel = _ref2.ariaLabel,
|
|
27226
|
-
ariaLabel = _ref2$ariaLabel === void 0 ? null : _ref2$ariaLabel;
|
|
27238
|
+
themeValues = _ref2.themeValues;
|
|
27227
27239
|
var buttonBorder = {
|
|
27228
27240
|
onFocused: {
|
|
27229
27241
|
borderColor: themeValues.activeColor,
|
|
@@ -27264,27 +27276,19 @@ var RadioButton$1 = function RadioButton(_ref2) {
|
|
|
27264
27276
|
width: "0px"
|
|
27265
27277
|
}
|
|
27266
27278
|
};
|
|
27267
|
-
var extraProps = {};
|
|
27268
|
-
|
|
27269
|
-
if (ariaLabelledBy && ariaLabelledBy.length) {
|
|
27270
|
-
extraProps["aria-labelledby"] = ariaLabelledBy;
|
|
27271
|
-
} else if (ariaLabel && ariaLabel !== null) {
|
|
27272
|
-
extraProps["aria-label"] = ariaLabel;
|
|
27273
|
-
}
|
|
27274
|
-
|
|
27275
27279
|
return /*#__PURE__*/React__default.createElement(Motion, {
|
|
27276
27280
|
position: "relative",
|
|
27277
27281
|
padding: "0",
|
|
27278
27282
|
initial: "off",
|
|
27279
27283
|
animate: radioOn ? radioFocused ? "onFocused" : "on" : radioFocused ? "offFocused" : "off"
|
|
27280
|
-
}, /*#__PURE__*/React__default.createElement(HiddenRadioButton,
|
|
27281
|
-
|
|
27282
|
-
|
|
27284
|
+
}, /*#__PURE__*/React__default.createElement(HiddenRadioButton, {
|
|
27285
|
+
id: "#radio-".concat(name),
|
|
27286
|
+
"aria-label": name,
|
|
27283
27287
|
disabled: disabled,
|
|
27284
27288
|
onClick: toggleRadio,
|
|
27285
27289
|
"aria-describedby": ariaDescribedBy,
|
|
27286
27290
|
tabIndex: "-1"
|
|
27287
|
-
}
|
|
27291
|
+
}), /*#__PURE__*/React__default.createElement(Motion, {
|
|
27288
27292
|
borderWidth: "1px",
|
|
27289
27293
|
borderStyle: "solid",
|
|
27290
27294
|
borderRadius: "12px",
|
|
@@ -38607,52 +38611,44 @@ var TableHeading_styled = styled__default.th.withConfig({
|
|
|
38607
38611
|
return extraStyles;
|
|
38608
38612
|
});
|
|
38609
38613
|
|
|
38610
|
-
const validatorToPredicate =
|
|
38611
|
-
|
|
38612
|
-
|
|
38613
|
-
|
|
38614
|
+
const validatorToPredicate = (validatorFn, emptyCase) => (
|
|
38615
|
+
value,
|
|
38616
|
+
...rest
|
|
38617
|
+
) => (value === "" ? emptyCase : validatorFn(value, ...rest));
|
|
38614
38618
|
|
|
38615
38619
|
var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
38616
38620
|
|
|
38617
|
-
function getDefaultExportFromCjs (x) {
|
|
38618
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
38619
|
-
}
|
|
38620
|
-
|
|
38621
38621
|
var dayjs_min = {exports: {}};
|
|
38622
38622
|
|
|
38623
38623
|
(function (module, exports) {
|
|
38624
|
-
|
|
38625
|
-
}
|
|
38624
|
+
!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",$="Invalid Date",l=/^(\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("_")},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={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}},D="en",v={};v[D]=M;var p=function(t){return t instanceof _},S=function(t,e,n){var r;if(!t)return D;if("string"==typeof t)v[t]&&(r=t),e&&(v[t]=e,r=t);else {var i=t.name;v[i]=t,r=i;}return !n&&r&&(D=r),r||!n&&D},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=g;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(l);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()===$)},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),$=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)},l=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,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var D=this.$locale().weekStart||0,v=(y<D?y+7:y)-D;return $(r?m-v:m+(6-v),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"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":""),$=(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],l=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 $&&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,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||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||$;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].substr(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},l={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||l[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,D=O.m(this,M);return D=(l={},l[c]=D/12,l[f]=D,l[h]=D/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?D:O.a(D)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return v[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}(),b=_.prototype;return w.prototype=b,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){b[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=v[D],w.Ls=v,w.p={},w}));
|
|
38625
|
+
}(dayjs_min));
|
|
38626
38626
|
|
|
38627
|
-
var
|
|
38628
|
-
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
38627
|
+
var dayjs = dayjs_min.exports;
|
|
38629
38628
|
|
|
38630
38629
|
var customParseFormat$1 = {exports: {}};
|
|
38631
38630
|
|
|
38632
38631
|
(function (module, exports) {
|
|
38633
|
-
|
|
38634
|
-
}
|
|
38632
|
+
!function(t,e){module.exports=e();}(commonjsGlobal$1,(function(){var t={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"},e=/(\[[^[]*\])|([-:/.()\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(t){return (t=+t)+(t>68?1900:2e3)};var a=function(t){return function(e){this[t]=+e;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(t){(this.zone||(this.zone={})).offset=function(t){if(!t)return 0;if("Z"===t)return 0;var e=t.match(/([+-]|\d\d)/g),n=60*e[1]+(+e[2]||0);return 0===n?0:"+"===e[0]?-n:n}(t);}],u=function(t){var e=o[t];return e&&(e.indexOf?e:e.s.concat(e.f))},h=function(t,e){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(t.indexOf(r(i,0,e))>-1){n=i>12;break}}else n=t===(e?"pm":"PM");return n},d={A:[i,function(t){this.afternoon=h(t,!1);}],a:[i,function(t){this.afternoon=h(t,!0);}],S:[/\d/,function(t){this.milliseconds=100*+t;}],SS:[n,function(t){this.milliseconds=10*+t;}],SSS:[/\d{3}/,function(t){this.milliseconds=+t;}],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(t){var e=o.ordinal,n=t.match(/\d+/);if(this.day=n[0],e)for(var r=1;r<=31;r+=1)e(r).replace(/\[|\]/g,"")===t&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(t){var e=u("months"),n=(u("monthsShort")||e.map((function(t){return t.substr(0,3)}))).indexOf(t)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(t){var e=u("months").indexOf(t)+1;if(e<1)throw new Error;this.month=e%12||e;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(t){this.year=s(t);}],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(e,n,r){var o=r&&r.toUpperCase();return n||i[r]||t[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,e,n){return e||n.slice(1)}))}))).match(e),a=s.length,f=0;f<a;f+=1){var u=s[f],h=d[u],c=h&&h[0],l=h&&h[1];s[f]=l?{regex:c,parser:l}:u.replace(/^\[|\]$/g,"");}return function(t){for(var e={},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,u=t.substr(r),h=o.exec(u)[0];f.call(e,h),t=t.replace(h,"");}}return function(t){var e=t.afternoon;if(void 0!==e){var n=t.hours;e?n<12&&(t.hours+=12):12===n&&(t.hours=0),delete t.afternoon;}}(e),e}}return function(t,e,n){n.p.customParseFormat=!0,t&&t.parseTwoDigitYear&&(s=t.parseTwoDigitYear);var r=e.prototype,i=r.parse;r.parse=function(t){var e=t.date,r=t.utc,s=t.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],u=!0===s[3],h=f||u,d=s[2];u&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(t,e,n){try{if(["x","X"].indexOf(e)>-1)return new Date(("X"===e?1e3:1)*t);var r=c(e)(t),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,u=r.seconds,h=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=u||0,g=h||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(t){return new Date("")}}(e,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),h&&e!=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,t);};}}));
|
|
38633
|
+
}(customParseFormat$1));
|
|
38635
38634
|
|
|
38636
|
-
var
|
|
38637
|
-
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
38635
|
+
var customParseFormat = customParseFormat$1.exports;
|
|
38638
38636
|
|
|
38639
38637
|
var isSameOrBefore$1 = {exports: {}};
|
|
38640
38638
|
|
|
38641
38639
|
(function (module, exports) {
|
|
38642
|
-
|
|
38643
|
-
}
|
|
38640
|
+
!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)};}}));
|
|
38641
|
+
}(isSameOrBefore$1));
|
|
38644
38642
|
|
|
38645
|
-
var
|
|
38646
|
-
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);
|
|
38643
|
+
var isSameOrBefore = isSameOrBefore$1.exports;
|
|
38647
38644
|
|
|
38648
38645
|
var isSameOrAfter$1 = {exports: {}};
|
|
38649
38646
|
|
|
38650
38647
|
(function (module, exports) {
|
|
38651
|
-
|
|
38652
|
-
}
|
|
38648
|
+
!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)};}}));
|
|
38649
|
+
}(isSameOrAfter$1));
|
|
38653
38650
|
|
|
38654
|
-
var
|
|
38655
|
-
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);
|
|
38651
|
+
var isSameOrAfter = isSameOrAfter$1.exports;
|
|
38656
38652
|
|
|
38657
38653
|
/* eslint-disable no-unused-vars */
|
|
38658
38654
|
|
|
@@ -38668,24 +38664,24 @@ dayjs.extend(isSameOrAfter);
|
|
|
38668
38664
|
|
|
38669
38665
|
let validatorFns = {};
|
|
38670
38666
|
|
|
38671
|
-
const INCLUDED_IN =
|
|
38672
|
-
const INCLUDED_IN_ERROR =
|
|
38667
|
+
const INCLUDED_IN = "validator/INCLUDED_IN";
|
|
38668
|
+
const INCLUDED_IN_ERROR = "error/INCLUDED_IN";
|
|
38673
38669
|
const includedIn = createValidator(INCLUDED_IN, INCLUDED_IN_ERROR);
|
|
38674
38670
|
validatorFns[INCLUDED_IN] = (value, args, form) =>
|
|
38675
38671
|
Array.isArray(args[0]) ? args[0].includes(value) : args[0] === value;
|
|
38676
38672
|
|
|
38677
|
-
const REQUIRED =
|
|
38678
|
-
const REQUIRED_ERROR =
|
|
38673
|
+
const REQUIRED = "validator/REQUIRED";
|
|
38674
|
+
const REQUIRED_ERROR = "error/REQUIRED";
|
|
38679
38675
|
const required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
38680
|
-
validatorFns[REQUIRED] = (value, args, form) => value !==
|
|
38676
|
+
validatorFns[REQUIRED] = (value, args, form) => value !== "";
|
|
38681
38677
|
|
|
38682
|
-
const ONLY_INTEGERS =
|
|
38683
|
-
const ONLY_INTEGERS_ERROR =
|
|
38678
|
+
const ONLY_INTEGERS = "validator/ONLY_INTEGERS";
|
|
38679
|
+
const ONLY_INTEGERS_ERROR = "error/ONLY_INTEGERS";
|
|
38684
38680
|
const onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
38685
38681
|
validatorFns[ONLY_INTEGERS] = (value, args, form) => /^(-?\d+)?$/.test(value);
|
|
38686
38682
|
|
|
38687
|
-
const ONLY_NATURALS =
|
|
38688
|
-
const ONLY_NATURALS_ERROR =
|
|
38683
|
+
const ONLY_NATURALS = "validator/ONLY_NATURALS";
|
|
38684
|
+
const ONLY_NATURALS_ERROR = "error/ONLY_NATURALS";
|
|
38689
38685
|
const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
38690
38686
|
validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
|
|
38691
38687
|
|
|
@@ -38698,8 +38694,8 @@ not tested as validation function
|
|
|
38698
38694
|
to validate exp date instead use combo of:
|
|
38699
38695
|
required(), hasLength(), isValidMonth(), dateAfterToday()
|
|
38700
38696
|
*/
|
|
38701
|
-
const ONLY_EXPIRATION_DATE =
|
|
38702
|
-
const ONLY_EXPIRATION_DATE_ERROR =
|
|
38697
|
+
const ONLY_EXPIRATION_DATE = "validator/ONLY_EXPIRATION_DATE";
|
|
38698
|
+
const ONLY_EXPIRATION_DATE_ERROR = "error/ONLY_EXPIRATION_DATE";
|
|
38703
38699
|
const onlyExpirationDate = createValidator(
|
|
38704
38700
|
ONLY_EXPIRATION_DATE,
|
|
38705
38701
|
ONLY_EXPIRATION_DATE_ERROR
|
|
@@ -38707,63 +38703,64 @@ const onlyExpirationDate = createValidator(
|
|
|
38707
38703
|
validatorFns[ONLY_EXPIRATION_DATE] = (value, args, form) =>
|
|
38708
38704
|
/^(\d?\d?\/?\d?\d?)?$/.test(value);
|
|
38709
38705
|
|
|
38710
|
-
const NUMBER_LESS_THAN =
|
|
38711
|
-
const NUMBER_LESS_THAN_ERROR =
|
|
38706
|
+
const NUMBER_LESS_THAN = "validator/NUMBER_LESS_THAN";
|
|
38707
|
+
const NUMBER_LESS_THAN_ERROR = "error/NUMBER_LESS_THAN";
|
|
38712
38708
|
const numberLessThan = createValidator(
|
|
38713
38709
|
NUMBER_LESS_THAN,
|
|
38714
38710
|
NUMBER_LESS_THAN_ERROR
|
|
38715
38711
|
);
|
|
38716
38712
|
validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
38717
|
-
if (value ===
|
|
38713
|
+
if (value === "") {
|
|
38718
38714
|
return true;
|
|
38719
38715
|
}
|
|
38720
38716
|
return Number(value) < args[0];
|
|
38721
38717
|
};
|
|
38722
38718
|
|
|
38723
|
-
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
38719
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
38720
|
+
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
38724
38721
|
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
38725
|
-
|
|
38722
|
+
"error/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
38726
38723
|
const numberLessThanOrEqualTo = createValidator(
|
|
38727
38724
|
NUMBER_LESS_THAN_OR_EQUAL_TO,
|
|
38728
38725
|
NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR
|
|
38729
38726
|
);
|
|
38730
38727
|
validatorFns[NUMBER_LESS_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38731
|
-
if (value ===
|
|
38728
|
+
if (value === "") {
|
|
38732
38729
|
return true;
|
|
38733
38730
|
}
|
|
38734
38731
|
return Number(value) <= args[0];
|
|
38735
38732
|
};
|
|
38736
38733
|
|
|
38737
|
-
const NUMBER_GREATER_THAN =
|
|
38738
|
-
const NUMBER_GREATER_THAN_ERROR =
|
|
38734
|
+
const NUMBER_GREATER_THAN = "validator/NUMBER_GREATER_THAN";
|
|
38735
|
+
const NUMBER_GREATER_THAN_ERROR = "error/NUMBER_GREATER_THAN";
|
|
38739
38736
|
const numberGreaterThan = createValidator(
|
|
38740
38737
|
NUMBER_GREATER_THAN,
|
|
38741
38738
|
NUMBER_GREATER_THAN_ERROR
|
|
38742
38739
|
);
|
|
38743
38740
|
validatorFns[NUMBER_GREATER_THAN] = (value, args, form) => {
|
|
38744
|
-
if (value ===
|
|
38741
|
+
if (value === "") {
|
|
38745
38742
|
return true;
|
|
38746
38743
|
}
|
|
38747
38744
|
return Number(value) > args[0];
|
|
38748
38745
|
};
|
|
38749
38746
|
|
|
38750
38747
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO =
|
|
38751
|
-
|
|
38748
|
+
"validator/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
38752
38749
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR =
|
|
38753
|
-
|
|
38750
|
+
"error/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
38754
38751
|
const numberGreaterThanOrEqualTo = createValidator(
|
|
38755
38752
|
NUMBER_GREATER_THAN_OR_EQUAL_TO,
|
|
38756
38753
|
NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR
|
|
38757
38754
|
);
|
|
38758
38755
|
validatorFns[NUMBER_GREATER_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38759
|
-
if (value ===
|
|
38756
|
+
if (value === "") {
|
|
38760
38757
|
return true;
|
|
38761
38758
|
}
|
|
38762
38759
|
return Number(value) >= args[0];
|
|
38763
38760
|
};
|
|
38764
38761
|
|
|
38765
|
-
const MATCHES_FIELD =
|
|
38766
|
-
const MATCHES_FIELD_ERROR$1 =
|
|
38762
|
+
const MATCHES_FIELD = "validator/MATCHES_FIELD";
|
|
38763
|
+
const MATCHES_FIELD_ERROR$1 = "error/MATCHES_FIELD";
|
|
38767
38764
|
const matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
|
|
38768
38765
|
validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
38769
38766
|
const dependentField = form[args[0]];
|
|
@@ -38776,7 +38773,7 @@ validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
|
38776
38773
|
return value === dependentFieldValue;
|
|
38777
38774
|
};
|
|
38778
38775
|
|
|
38779
|
-
const validateWhenErrorMessage =
|
|
38776
|
+
const validateWhenErrorMessage = type =>
|
|
38780
38777
|
`${type} was passed to validateWhen, but that validator type does not exist.
|
|
38781
38778
|
Please check that you are only calling validator creator functions exported from
|
|
38782
38779
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -38784,21 +38781,25 @@ const validateWhenErrorMessage = (type) =>
|
|
|
38784
38781
|
createFormState). Also make sure you aren't passing validateWhen() to validateWhen
|
|
38785
38782
|
as the primary validator.`;
|
|
38786
38783
|
|
|
38787
|
-
const VALIDATE_WHEN =
|
|
38788
|
-
const VALIDATE_WHEN_ERROR =
|
|
38789
|
-
const validateWhen = (
|
|
38784
|
+
const VALIDATE_WHEN = "validator/VALIDATE_WHEN";
|
|
38785
|
+
const VALIDATE_WHEN_ERROR = "error/VALIDATE_WHEN";
|
|
38786
|
+
const validateWhen = (
|
|
38787
|
+
dependentValidator,
|
|
38788
|
+
primaryValidator,
|
|
38789
|
+
optionalFieldName
|
|
38790
|
+
) => ({
|
|
38790
38791
|
type: VALIDATE_WHEN,
|
|
38791
38792
|
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
38792
|
-
error: dependentValidator.error
|
|
38793
|
+
error: dependentValidator.error
|
|
38793
38794
|
});
|
|
38794
38795
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
38795
38796
|
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
38796
38797
|
const [dependentValidator, primaryValidator, optionalFieldName] = args;
|
|
38797
|
-
const dependsOnOtherField = typeof optionalFieldName ===
|
|
38798
|
+
const dependsOnOtherField = typeof optionalFieldName === "string";
|
|
38798
38799
|
|
|
38799
38800
|
if (
|
|
38800
38801
|
primaryValidator.type === undefined ||
|
|
38801
|
-
typeof validatorFns[primaryValidator.type] !==
|
|
38802
|
+
typeof validatorFns[primaryValidator.type] !== "function"
|
|
38802
38803
|
) {
|
|
38803
38804
|
throw new Error(validateWhenErrorMessage(primaryValidator.type));
|
|
38804
38805
|
}
|
|
@@ -38822,22 +38823,26 @@ validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
|
38822
38823
|
);
|
|
38823
38824
|
|
|
38824
38825
|
return primaryPredicatePassed
|
|
38825
|
-
? validatorFns[dependentValidator.type](
|
|
38826
|
+
? validatorFns[dependentValidator.type](
|
|
38827
|
+
value,
|
|
38828
|
+
dependentValidator.args,
|
|
38829
|
+
form
|
|
38830
|
+
)
|
|
38826
38831
|
: true;
|
|
38827
38832
|
};
|
|
38828
38833
|
|
|
38829
|
-
const validateSumErrorMessage =
|
|
38834
|
+
const validateSumErrorMessage = type =>
|
|
38830
38835
|
`${type} was passed to validateSum, but that validator type does not exist.
|
|
38831
38836
|
Please check that you are only calling validator creator functions exported from
|
|
38832
38837
|
redux-freeform in your form config and that you didn't forget to
|
|
38833
38838
|
invoke the validator creator (you cannot pass the functions themselves to
|
|
38834
38839
|
createFormState).`;
|
|
38835
|
-
const VALIDATE_SUM =
|
|
38836
|
-
const VALIDATE_SUM_ERROR =
|
|
38840
|
+
const VALIDATE_SUM = "validator/VALIDATE_SUM";
|
|
38841
|
+
const VALIDATE_SUM_ERROR = "error/VALIDATE_SUM";
|
|
38837
38842
|
const validateSum = (validator, fieldNamesArray) => ({
|
|
38838
38843
|
type: VALIDATE_SUM,
|
|
38839
38844
|
args: [validator, fieldNamesArray],
|
|
38840
|
-
error: validator.error
|
|
38845
|
+
error: validator.error
|
|
38841
38846
|
});
|
|
38842
38847
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
38843
38848
|
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
@@ -38845,7 +38850,7 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38845
38850
|
|
|
38846
38851
|
if (
|
|
38847
38852
|
validator.type === undefined ||
|
|
38848
|
-
typeof validatorFns[validator.type] !==
|
|
38853
|
+
typeof validatorFns[validator.type] !== "function"
|
|
38849
38854
|
) {
|
|
38850
38855
|
throw new Error(validateSumErrorMessage(validator.type));
|
|
38851
38856
|
}
|
|
@@ -38866,35 +38871,37 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38866
38871
|
return validatorFns[validator.type](sum, validator.args, form);
|
|
38867
38872
|
};
|
|
38868
38873
|
|
|
38869
|
-
const HAS_LENGTH =
|
|
38870
|
-
const HAS_LENGTH_ERROR =
|
|
38874
|
+
const HAS_LENGTH = "validator/HAS_LENGTH";
|
|
38875
|
+
const HAS_LENGTH_ERROR = "error/HAS_LENGTH";
|
|
38871
38876
|
const hasLength = createValidator(HAS_LENGTH, HAS_LENGTH_ERROR);
|
|
38872
38877
|
validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
38873
|
-
if (value ===
|
|
38878
|
+
if (value === "") {
|
|
38874
38879
|
return true;
|
|
38875
38880
|
}
|
|
38876
38881
|
const min = args[0];
|
|
38877
38882
|
const max = args[1];
|
|
38878
38883
|
if (max == undefined || min == undefined) {
|
|
38879
38884
|
throw new Error(
|
|
38880
|
-
|
|
38885
|
+
"Max and min need to be defined for hasLength, both or one of them is undefined"
|
|
38881
38886
|
);
|
|
38882
38887
|
}
|
|
38883
38888
|
if (max < min) {
|
|
38884
|
-
throw new Error(
|
|
38889
|
+
throw new Error(
|
|
38890
|
+
"hasLength validator was passed a min greater than the max"
|
|
38891
|
+
);
|
|
38885
38892
|
}
|
|
38886
38893
|
const valueLength = value.length;
|
|
38887
38894
|
return max >= valueLength && valueLength >= min;
|
|
38888
38895
|
};
|
|
38889
38896
|
|
|
38890
|
-
const DATE_BEFORE_TODAY =
|
|
38891
|
-
const DATE_BEFORE_TODAY_ERROR =
|
|
38897
|
+
const DATE_BEFORE_TODAY = "validator/DATE_BEFORE_TODAY";
|
|
38898
|
+
const DATE_BEFORE_TODAY_ERROR = "error/DATE_BEFORE_TODAY";
|
|
38892
38899
|
const dateBeforeToday = createValidator(
|
|
38893
38900
|
DATE_BEFORE_TODAY,
|
|
38894
38901
|
DATE_BEFORE_TODAY_ERROR
|
|
38895
38902
|
);
|
|
38896
38903
|
validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
38897
|
-
if (value ===
|
|
38904
|
+
if (value === "") {
|
|
38898
38905
|
return true;
|
|
38899
38906
|
}
|
|
38900
38907
|
const dateFormat = args[0];
|
|
@@ -38903,7 +38910,7 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
38903
38910
|
|
|
38904
38911
|
if (dateFormat == undefined || unit == undefined) {
|
|
38905
38912
|
throw new Error(
|
|
38906
|
-
|
|
38913
|
+
"Date format and unit need to be defined for dateBeforeToday, one or both are undefined"
|
|
38907
38914
|
);
|
|
38908
38915
|
}
|
|
38909
38916
|
const now = dayjs();
|
|
@@ -38915,14 +38922,14 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
38915
38922
|
return dateValue.isBefore(now, unit);
|
|
38916
38923
|
};
|
|
38917
38924
|
|
|
38918
|
-
const DATE_AFTER_TODAY =
|
|
38919
|
-
const DATE_AFTER_TODAY_ERROR =
|
|
38925
|
+
const DATE_AFTER_TODAY = "validator/DATE_AFTER_TODAY";
|
|
38926
|
+
const DATE_AFTER_TODAY_ERROR = "error/DATE_AFTER_TODAY";
|
|
38920
38927
|
const dateAfterToday = createValidator(
|
|
38921
38928
|
DATE_AFTER_TODAY,
|
|
38922
38929
|
DATE_AFTER_TODAY_ERROR
|
|
38923
38930
|
);
|
|
38924
38931
|
validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
38925
|
-
if (value ===
|
|
38932
|
+
if (value === "") {
|
|
38926
38933
|
return true;
|
|
38927
38934
|
}
|
|
38928
38935
|
const dateFormat = args[0];
|
|
@@ -38931,7 +38938,7 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
38931
38938
|
|
|
38932
38939
|
if (dateFormat == undefined || unit == undefined) {
|
|
38933
38940
|
throw new Error(
|
|
38934
|
-
|
|
38941
|
+
"Date format and unit need to be defined for dateAfterToday, one or both are undefined"
|
|
38935
38942
|
);
|
|
38936
38943
|
}
|
|
38937
38944
|
const now = dayjs();
|
|
@@ -38943,11 +38950,14 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
38943
38950
|
return dateValue.isAfter(now, unit);
|
|
38944
38951
|
};
|
|
38945
38952
|
|
|
38946
|
-
const IS_VALID_MONTH =
|
|
38947
|
-
const IS_VALID_MONTH_ERROR =
|
|
38948
|
-
const isValidMonth = createValidator(
|
|
38953
|
+
const IS_VALID_MONTH = "validator/IS_VALID_MONTH";
|
|
38954
|
+
const IS_VALID_MONTH_ERROR = "error/IS_VALID_MONTH";
|
|
38955
|
+
const isValidMonth = createValidator(
|
|
38956
|
+
IS_VALID_MONTH,
|
|
38957
|
+
IS_VALID_MONTH_ERROR
|
|
38958
|
+
);
|
|
38949
38959
|
validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
38950
|
-
if (value ===
|
|
38960
|
+
if (value === "") {
|
|
38951
38961
|
return true;
|
|
38952
38962
|
}
|
|
38953
38963
|
// Function takes one argument representing the character position
|
|
@@ -38957,43 +38967,43 @@ validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
|
38957
38967
|
// Only works with two digit months (01, 02, 03, etc)
|
|
38958
38968
|
const monthStartPosition = parseInt(args[0]);
|
|
38959
38969
|
const monthEndPosition = monthStartPosition + 2;
|
|
38960
|
-
if (
|
|
38961
|
-
throw new Error(
|
|
38970
|
+
if (monthStartPosition === NaN) {
|
|
38971
|
+
throw new Error("Month start position has to be a valid integer string");
|
|
38962
38972
|
}
|
|
38963
38973
|
const month = parseInt(value.slice(monthStartPosition, monthEndPosition));
|
|
38964
|
-
if (
|
|
38974
|
+
if (month === NaN) {
|
|
38965
38975
|
return false;
|
|
38966
38976
|
}
|
|
38967
38977
|
return month >= 1 && month <= 12;
|
|
38968
38978
|
};
|
|
38969
38979
|
|
|
38970
|
-
const MATCHES_REGEX =
|
|
38971
|
-
const MATCHES_REGEX_ERROR =
|
|
38980
|
+
const MATCHES_REGEX = "validator/MATCHES_REGEX";
|
|
38981
|
+
const MATCHES_REGEX_ERROR = "error/MATCHES_REGEX";
|
|
38972
38982
|
const matchesRegex = createValidator(MATCHES_REGEX, MATCHES_REGEX_ERROR);
|
|
38973
38983
|
validatorFns[MATCHES_REGEX] = (value, args, form) => {
|
|
38974
|
-
if (value ===
|
|
38984
|
+
if (value === "") {
|
|
38975
38985
|
return true;
|
|
38976
38986
|
}
|
|
38977
38987
|
return new RegExp(args[0]).test(value); // new RexExp never throws an error, no matter the input
|
|
38978
38988
|
};
|
|
38979
38989
|
|
|
38980
38990
|
// based on http://www.brainjar.com/js/validation/
|
|
38981
|
-
const IS_ROUTING_NUMBER =
|
|
38982
|
-
const IS_ROUTING_NUMBER_ERROR =
|
|
38991
|
+
const IS_ROUTING_NUMBER = "validator/IS_ROUTING_NUMBER";
|
|
38992
|
+
const IS_ROUTING_NUMBER_ERROR = "error/IS_ROUTING_NUMBER";
|
|
38983
38993
|
const isRoutingNumber = createValidator(
|
|
38984
38994
|
IS_ROUTING_NUMBER,
|
|
38985
38995
|
IS_ROUTING_NUMBER_ERROR
|
|
38986
38996
|
);
|
|
38987
38997
|
validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
38988
|
-
if (value ===
|
|
38998
|
+
if (value === "") {
|
|
38989
38999
|
return true;
|
|
38990
39000
|
}
|
|
38991
39001
|
if (value.length != 9) {
|
|
38992
39002
|
return false;
|
|
38993
39003
|
}
|
|
38994
39004
|
const sum = value
|
|
38995
|
-
.split(
|
|
38996
|
-
.map(
|
|
39005
|
+
.split("")
|
|
39006
|
+
.map(ch => parseInt(ch))
|
|
38997
39007
|
.reduce((acc, cur, idx) => {
|
|
38998
39008
|
switch (idx % 3) {
|
|
38999
39009
|
case 0:
|
|
@@ -39007,69 +39017,69 @@ validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
|
39007
39017
|
return sum != 0 && sum % 10 == 0;
|
|
39008
39018
|
};
|
|
39009
39019
|
|
|
39010
|
-
const HAS_NUMBER =
|
|
39011
|
-
const HAS_NUMBER_ERROR$1 =
|
|
39020
|
+
const HAS_NUMBER = "validator/HAS_NUMBER";
|
|
39021
|
+
const HAS_NUMBER_ERROR$1 = "error/HAS_NUMBER";
|
|
39012
39022
|
const hasNumber = createValidator(HAS_NUMBER, HAS_NUMBER_ERROR$1);
|
|
39013
39023
|
validatorFns[HAS_NUMBER] = (value, args, form) => {
|
|
39014
|
-
if (value ===
|
|
39024
|
+
if (value === "") {
|
|
39015
39025
|
return true;
|
|
39016
39026
|
}
|
|
39017
39027
|
return new RegExp(/[0-9]/).test(value);
|
|
39018
39028
|
};
|
|
39019
39029
|
|
|
39020
|
-
const HAS_LOWERCASE_LETTER =
|
|
39021
|
-
const HAS_LOWERCASE_LETTER_ERROR$1 =
|
|
39030
|
+
const HAS_LOWERCASE_LETTER = "validator/HAS_LOWERCASE_LETTER";
|
|
39031
|
+
const HAS_LOWERCASE_LETTER_ERROR$1 = "error/HAS_LOWERCASE_LETTER";
|
|
39022
39032
|
const hasLowercaseLetter = createValidator(
|
|
39023
39033
|
HAS_LOWERCASE_LETTER,
|
|
39024
39034
|
HAS_LOWERCASE_LETTER_ERROR$1
|
|
39025
39035
|
);
|
|
39026
39036
|
validatorFns[HAS_LOWERCASE_LETTER] = (value, args, form) => {
|
|
39027
|
-
if (value ===
|
|
39037
|
+
if (value === "") {
|
|
39028
39038
|
return true;
|
|
39029
39039
|
}
|
|
39030
39040
|
return new RegExp(/[a-z]/).test(value);
|
|
39031
39041
|
};
|
|
39032
39042
|
|
|
39033
|
-
const HAS_UPPERCASE_LETTER =
|
|
39034
|
-
const HAS_UPPERCASE_LETTER_ERROR$1 =
|
|
39043
|
+
const HAS_UPPERCASE_LETTER = "validator/HAS_UPPERCASE_LETTER";
|
|
39044
|
+
const HAS_UPPERCASE_LETTER_ERROR$1 = "error/HAS_UPPERCASE_LETTER";
|
|
39035
39045
|
const hasUppercaseLetter = createValidator(
|
|
39036
39046
|
HAS_UPPERCASE_LETTER,
|
|
39037
39047
|
HAS_UPPERCASE_LETTER_ERROR$1
|
|
39038
39048
|
);
|
|
39039
39049
|
validatorFns[HAS_UPPERCASE_LETTER] = (value, args, form) => {
|
|
39040
|
-
if (value ===
|
|
39050
|
+
if (value === "") {
|
|
39041
39051
|
return true;
|
|
39042
39052
|
}
|
|
39043
39053
|
return new RegExp(/[A-Z]/).test(value);
|
|
39044
39054
|
};
|
|
39045
39055
|
|
|
39046
|
-
const HAS_SPECIAL_CHARACTER =
|
|
39047
|
-
const HAS_SPECIAL_CHARACTER_ERROR$1 =
|
|
39056
|
+
const HAS_SPECIAL_CHARACTER = "validator/HAS_SPECIAL_CHARACTER";
|
|
39057
|
+
const HAS_SPECIAL_CHARACTER_ERROR$1 = "error/HAS_SPECIAL_CHARACTER";
|
|
39048
39058
|
const hasSpecialCharacter = createValidator(
|
|
39049
39059
|
HAS_SPECIAL_CHARACTER,
|
|
39050
39060
|
HAS_SPECIAL_CHARACTER_ERROR$1
|
|
39051
39061
|
);
|
|
39052
39062
|
validatorFns[HAS_SPECIAL_CHARACTER] = (value, args, form) => {
|
|
39053
|
-
if (value ===
|
|
39063
|
+
if (value === "") {
|
|
39054
39064
|
return true;
|
|
39055
39065
|
}
|
|
39056
39066
|
return new RegExp(/[!@#$%^&*.?]/).test(value);
|
|
39057
39067
|
};
|
|
39058
39068
|
|
|
39059
|
-
const IS_PROBABLY_EMAIL =
|
|
39060
|
-
const IS_PROBABLY_EMAIL_ERROR =
|
|
39069
|
+
const IS_PROBABLY_EMAIL = "validator/IS_PROBABLY_EMAIL";
|
|
39070
|
+
const IS_PROBABLY_EMAIL_ERROR = "error/IS_PROBABLY_EMAIL";
|
|
39061
39071
|
const isProbablyEmail = createValidator(
|
|
39062
39072
|
IS_PROBABLY_EMAIL,
|
|
39063
39073
|
IS_PROBABLY_EMAIL_ERROR
|
|
39064
39074
|
);
|
|
39065
39075
|
validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
39066
|
-
if (value ===
|
|
39076
|
+
if (value === "") {
|
|
39067
39077
|
return true;
|
|
39068
39078
|
}
|
|
39069
39079
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
39070
39080
|
};
|
|
39071
39081
|
|
|
39072
|
-
const runValidatorErrorMessage =
|
|
39082
|
+
const runValidatorErrorMessage = type =>
|
|
39073
39083
|
`${type} was passed to runValidator, but that validator type does not exist.
|
|
39074
39084
|
Please check that you are only calling validator creator functions exported from
|
|
39075
39085
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -39084,53 +39094,1165 @@ const runValidator = (validator, value, form) => {
|
|
|
39084
39094
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
39085
39095
|
};
|
|
39086
39096
|
|
|
39087
|
-
const
|
|
39097
|
+
const _computeErrors = (fieldName, form, validators) => {
|
|
39088
39098
|
return validators
|
|
39089
|
-
.map(
|
|
39090
|
-
.filter(
|
|
39099
|
+
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
39100
|
+
.filter(x => x !== null);
|
|
39091
39101
|
};
|
|
39092
39102
|
|
|
39093
39103
|
const computeConstraints = (fieldName, form) => {
|
|
39094
39104
|
const constraints = form[fieldName].constraints;
|
|
39095
|
-
return
|
|
39105
|
+
return _computeErrors(fieldName, form, constraints);
|
|
39096
39106
|
};
|
|
39097
39107
|
|
|
39098
39108
|
const computeErrors = (fieldName, form) => {
|
|
39099
39109
|
const validators = form[fieldName].validators;
|
|
39100
|
-
return
|
|
39110
|
+
return _computeErrors(fieldName, form, validators);
|
|
39111
|
+
};
|
|
39112
|
+
|
|
39113
|
+
var obj;
|
|
39114
|
+
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : ( obj = {}, obj["immer-nothing"] = true, obj );
|
|
39115
|
+
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
39116
|
+
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-state") : "__$immer_state";
|
|
39117
|
+
function isDraft(value) {
|
|
39118
|
+
return !!value && !!value[DRAFT_STATE];
|
|
39119
|
+
}
|
|
39120
|
+
function isDraftable(value) {
|
|
39121
|
+
if (!value) { return false; }
|
|
39122
|
+
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
39123
|
+
}
|
|
39124
|
+
function isPlainObject(value) {
|
|
39125
|
+
if (!value || typeof value !== "object") { return false; }
|
|
39126
|
+
if (Array.isArray(value)) { return true; }
|
|
39127
|
+
var proto = Object.getPrototypeOf(value);
|
|
39128
|
+
return !proto || proto === Object.prototype;
|
|
39129
|
+
}
|
|
39130
|
+
var assign = Object.assign || function assign(target, value) {
|
|
39131
|
+
for (var key in value) {
|
|
39132
|
+
if (has$1(value, key)) {
|
|
39133
|
+
target[key] = value[key];
|
|
39134
|
+
}
|
|
39135
|
+
}
|
|
39136
|
+
|
|
39137
|
+
return target;
|
|
39138
|
+
};
|
|
39139
|
+
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;
|
|
39140
|
+
function shallowCopy(base, invokeGetters) {
|
|
39141
|
+
if ( invokeGetters === void 0 ) invokeGetters = false;
|
|
39142
|
+
|
|
39143
|
+
if (Array.isArray(base)) { return base.slice(); }
|
|
39144
|
+
var clone = Object.create(Object.getPrototypeOf(base));
|
|
39145
|
+
ownKeys$2(base).forEach(function (key) {
|
|
39146
|
+
if (key === DRAFT_STATE) {
|
|
39147
|
+
return; // Never copy over draft state.
|
|
39148
|
+
}
|
|
39149
|
+
|
|
39150
|
+
var desc = Object.getOwnPropertyDescriptor(base, key);
|
|
39151
|
+
var value = desc.value;
|
|
39152
|
+
|
|
39153
|
+
if (desc.get) {
|
|
39154
|
+
if (!invokeGetters) {
|
|
39155
|
+
throw new Error("Immer drafts cannot have computed properties");
|
|
39156
|
+
}
|
|
39157
|
+
|
|
39158
|
+
value = desc.get.call(base);
|
|
39159
|
+
}
|
|
39160
|
+
|
|
39161
|
+
if (desc.enumerable) {
|
|
39162
|
+
clone[key] = value;
|
|
39163
|
+
} else {
|
|
39164
|
+
Object.defineProperty(clone, key, {
|
|
39165
|
+
value: value,
|
|
39166
|
+
writable: true,
|
|
39167
|
+
configurable: true
|
|
39168
|
+
});
|
|
39169
|
+
}
|
|
39170
|
+
});
|
|
39171
|
+
return clone;
|
|
39172
|
+
}
|
|
39173
|
+
function each(value, cb) {
|
|
39174
|
+
if (Array.isArray(value)) {
|
|
39175
|
+
for (var i = 0; i < value.length; i++) { cb(i, value[i], value); }
|
|
39176
|
+
} else {
|
|
39177
|
+
ownKeys$2(value).forEach(function (key) { return cb(key, value[key], value); });
|
|
39178
|
+
}
|
|
39179
|
+
}
|
|
39180
|
+
function isEnumerable(base, prop) {
|
|
39181
|
+
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
39182
|
+
return !!desc && desc.enumerable;
|
|
39183
|
+
}
|
|
39184
|
+
function has$1(thing, prop) {
|
|
39185
|
+
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
39186
|
+
}
|
|
39187
|
+
function is(x, y) {
|
|
39188
|
+
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
39189
|
+
if (x === y) {
|
|
39190
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
39191
|
+
} else {
|
|
39192
|
+
return x !== x && y !== y;
|
|
39193
|
+
}
|
|
39194
|
+
}
|
|
39195
|
+
function clone(obj) {
|
|
39196
|
+
if (!isDraftable(obj)) { return obj; }
|
|
39197
|
+
if (Array.isArray(obj)) { return obj.map(clone); }
|
|
39198
|
+
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
39199
|
+
|
|
39200
|
+
for (var key in obj) { cloned[key] = clone(obj[key]); }
|
|
39201
|
+
|
|
39202
|
+
return cloned;
|
|
39203
|
+
}
|
|
39204
|
+
|
|
39205
|
+
/** Each scope represents a `produce` call. */
|
|
39206
|
+
|
|
39207
|
+
var ImmerScope = function ImmerScope(parent) {
|
|
39208
|
+
this.drafts = [];
|
|
39209
|
+
this.parent = parent; // Whenever the modified draft contains a draft from another scope, we
|
|
39210
|
+
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
39211
|
+
|
|
39212
|
+
this.canAutoFreeze = true; // To avoid prototype lookups:
|
|
39213
|
+
|
|
39214
|
+
this.patches = null;
|
|
39215
|
+
};
|
|
39216
|
+
|
|
39217
|
+
ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
39218
|
+
if (patchListener) {
|
|
39219
|
+
this.patches = [];
|
|
39220
|
+
this.inversePatches = [];
|
|
39221
|
+
this.patchListener = patchListener;
|
|
39222
|
+
}
|
|
39223
|
+
};
|
|
39224
|
+
|
|
39225
|
+
ImmerScope.prototype.revoke = function revoke$1 () {
|
|
39226
|
+
this.leave();
|
|
39227
|
+
this.drafts.forEach(revoke);
|
|
39228
|
+
this.drafts = null; // Make draft-related methods throw.
|
|
39229
|
+
};
|
|
39230
|
+
|
|
39231
|
+
ImmerScope.prototype.leave = function leave () {
|
|
39232
|
+
if (this === ImmerScope.current) {
|
|
39233
|
+
ImmerScope.current = this.parent;
|
|
39234
|
+
}
|
|
39235
|
+
};
|
|
39236
|
+
ImmerScope.current = null;
|
|
39237
|
+
|
|
39238
|
+
ImmerScope.enter = function () {
|
|
39239
|
+
return this.current = new ImmerScope(this.current);
|
|
39240
|
+
};
|
|
39241
|
+
|
|
39242
|
+
function revoke(draft) {
|
|
39243
|
+
draft[DRAFT_STATE].revoke();
|
|
39244
|
+
}
|
|
39245
|
+
|
|
39246
|
+
// but share them all instead
|
|
39247
|
+
|
|
39248
|
+
var descriptors$1 = {};
|
|
39249
|
+
function willFinalize(scope, result, isReplaced) {
|
|
39250
|
+
scope.drafts.forEach(function (draft) {
|
|
39251
|
+
draft[DRAFT_STATE].finalizing = true;
|
|
39252
|
+
});
|
|
39253
|
+
|
|
39254
|
+
if (!isReplaced) {
|
|
39255
|
+
if (scope.patches) {
|
|
39256
|
+
markChangesRecursively(scope.drafts[0]);
|
|
39257
|
+
} // This is faster when we don't care about which attributes changed.
|
|
39258
|
+
|
|
39259
|
+
|
|
39260
|
+
markChangesSweep(scope.drafts);
|
|
39261
|
+
} // When a child draft is returned, look for changes.
|
|
39262
|
+
else if (isDraft(result) && result[DRAFT_STATE].scope === scope) {
|
|
39263
|
+
markChangesSweep(scope.drafts);
|
|
39264
|
+
}
|
|
39265
|
+
}
|
|
39266
|
+
function createProxy(base, parent) {
|
|
39267
|
+
var isArray = Array.isArray(base);
|
|
39268
|
+
var draft = clonePotentialDraft(base);
|
|
39269
|
+
each(draft, function (prop) {
|
|
39270
|
+
proxyProperty(draft, prop, isArray || isEnumerable(base, prop));
|
|
39271
|
+
}); // See "proxy.js" for property documentation.
|
|
39272
|
+
|
|
39273
|
+
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39274
|
+
var state = {
|
|
39275
|
+
scope: scope,
|
|
39276
|
+
modified: false,
|
|
39277
|
+
finalizing: false,
|
|
39278
|
+
// es5 only
|
|
39279
|
+
finalized: false,
|
|
39280
|
+
assigned: {},
|
|
39281
|
+
parent: parent,
|
|
39282
|
+
base: base,
|
|
39283
|
+
draft: draft,
|
|
39284
|
+
copy: null,
|
|
39285
|
+
revoke: revoke$1,
|
|
39286
|
+
revoked: false // es5 only
|
|
39287
|
+
|
|
39288
|
+
};
|
|
39289
|
+
createHiddenProperty(draft, DRAFT_STATE, state);
|
|
39290
|
+
scope.drafts.push(draft);
|
|
39291
|
+
return draft;
|
|
39292
|
+
}
|
|
39293
|
+
|
|
39294
|
+
function revoke$1() {
|
|
39295
|
+
this.revoked = true;
|
|
39296
|
+
}
|
|
39297
|
+
|
|
39298
|
+
function source(state) {
|
|
39299
|
+
return state.copy || state.base;
|
|
39300
|
+
} // Access a property without creating an Immer draft.
|
|
39301
|
+
|
|
39302
|
+
|
|
39303
|
+
function peek(draft, prop) {
|
|
39304
|
+
var state = draft[DRAFT_STATE];
|
|
39305
|
+
|
|
39306
|
+
if (state && !state.finalizing) {
|
|
39307
|
+
state.finalizing = true;
|
|
39308
|
+
var value = draft[prop];
|
|
39309
|
+
state.finalizing = false;
|
|
39310
|
+
return value;
|
|
39311
|
+
}
|
|
39312
|
+
|
|
39313
|
+
return draft[prop];
|
|
39314
|
+
}
|
|
39315
|
+
|
|
39316
|
+
function get$1(state, prop) {
|
|
39317
|
+
assertUnrevoked(state);
|
|
39318
|
+
var value = peek(source(state), prop);
|
|
39319
|
+
if (state.finalizing) { return value; } // Create a draft if the value is unmodified.
|
|
39320
|
+
|
|
39321
|
+
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
39322
|
+
prepareCopy(state);
|
|
39323
|
+
return state.copy[prop] = createProxy(value, state);
|
|
39324
|
+
}
|
|
39325
|
+
|
|
39326
|
+
return value;
|
|
39327
|
+
}
|
|
39328
|
+
|
|
39329
|
+
function set$1(state, prop, value) {
|
|
39330
|
+
assertUnrevoked(state);
|
|
39331
|
+
state.assigned[prop] = true;
|
|
39332
|
+
|
|
39333
|
+
if (!state.modified) {
|
|
39334
|
+
if (is(value, peek(source(state), prop))) { return; }
|
|
39335
|
+
markChanged(state);
|
|
39336
|
+
prepareCopy(state);
|
|
39337
|
+
}
|
|
39338
|
+
|
|
39339
|
+
state.copy[prop] = value;
|
|
39340
|
+
}
|
|
39341
|
+
|
|
39342
|
+
function markChanged(state) {
|
|
39343
|
+
if (!state.modified) {
|
|
39344
|
+
state.modified = true;
|
|
39345
|
+
if (state.parent) { markChanged(state.parent); }
|
|
39346
|
+
}
|
|
39347
|
+
}
|
|
39348
|
+
|
|
39349
|
+
function prepareCopy(state) {
|
|
39350
|
+
if (!state.copy) { state.copy = clonePotentialDraft(state.base); }
|
|
39351
|
+
}
|
|
39352
|
+
|
|
39353
|
+
function clonePotentialDraft(base) {
|
|
39354
|
+
var state = base && base[DRAFT_STATE];
|
|
39355
|
+
|
|
39356
|
+
if (state) {
|
|
39357
|
+
state.finalizing = true;
|
|
39358
|
+
var draft = shallowCopy(state.draft, true);
|
|
39359
|
+
state.finalizing = false;
|
|
39360
|
+
return draft;
|
|
39361
|
+
}
|
|
39362
|
+
|
|
39363
|
+
return shallowCopy(base);
|
|
39364
|
+
}
|
|
39365
|
+
|
|
39366
|
+
function proxyProperty(draft, prop, enumerable) {
|
|
39367
|
+
var desc = descriptors$1[prop];
|
|
39368
|
+
|
|
39369
|
+
if (desc) {
|
|
39370
|
+
desc.enumerable = enumerable;
|
|
39371
|
+
} else {
|
|
39372
|
+
descriptors$1[prop] = desc = {
|
|
39373
|
+
configurable: true,
|
|
39374
|
+
enumerable: enumerable,
|
|
39375
|
+
|
|
39376
|
+
get: function get$1$1() {
|
|
39377
|
+
return get$1(this[DRAFT_STATE], prop);
|
|
39378
|
+
},
|
|
39379
|
+
|
|
39380
|
+
set: function set$1$1(value) {
|
|
39381
|
+
set$1(this[DRAFT_STATE], prop, value);
|
|
39382
|
+
}
|
|
39383
|
+
|
|
39384
|
+
};
|
|
39385
|
+
}
|
|
39386
|
+
|
|
39387
|
+
Object.defineProperty(draft, prop, desc);
|
|
39388
|
+
}
|
|
39389
|
+
|
|
39390
|
+
function assertUnrevoked(state) {
|
|
39391
|
+
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))); }
|
|
39392
|
+
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
39393
|
+
|
|
39394
|
+
|
|
39395
|
+
function markChangesSweep(drafts) {
|
|
39396
|
+
// The natural order of drafts in the `scope` array is based on when they
|
|
39397
|
+
// were accessed. By processing drafts in reverse natural order, we have a
|
|
39398
|
+
// better chance of processing leaf nodes first. When a leaf node is known to
|
|
39399
|
+
// have changed, we can avoid any traversal of its ancestor nodes.
|
|
39400
|
+
for (var i = drafts.length - 1; i >= 0; i--) {
|
|
39401
|
+
var state = drafts[i][DRAFT_STATE];
|
|
39402
|
+
|
|
39403
|
+
if (!state.modified) {
|
|
39404
|
+
if (Array.isArray(state.base)) {
|
|
39405
|
+
if (hasArrayChanges(state)) { markChanged(state); }
|
|
39406
|
+
} else if (hasObjectChanges(state)) { markChanged(state); }
|
|
39407
|
+
}
|
|
39408
|
+
}
|
|
39409
|
+
}
|
|
39410
|
+
|
|
39411
|
+
function markChangesRecursively(object) {
|
|
39412
|
+
if (!object || typeof object !== "object") { return; }
|
|
39413
|
+
var state = object[DRAFT_STATE];
|
|
39414
|
+
if (!state) { return; }
|
|
39415
|
+
var base = state.base;
|
|
39416
|
+
var draft = state.draft;
|
|
39417
|
+
var assigned = state.assigned;
|
|
39418
|
+
|
|
39419
|
+
if (!Array.isArray(object)) {
|
|
39420
|
+
// Look for added keys.
|
|
39421
|
+
Object.keys(draft).forEach(function (key) {
|
|
39422
|
+
// The `undefined` check is a fast path for pre-existing keys.
|
|
39423
|
+
if (base[key] === undefined && !has$1(base, key)) {
|
|
39424
|
+
assigned[key] = true;
|
|
39425
|
+
markChanged(state);
|
|
39426
|
+
} else if (!assigned[key]) {
|
|
39427
|
+
// Only untouched properties trigger recursion.
|
|
39428
|
+
markChangesRecursively(draft[key]);
|
|
39429
|
+
}
|
|
39430
|
+
}); // Look for removed keys.
|
|
39431
|
+
|
|
39432
|
+
Object.keys(base).forEach(function (key) {
|
|
39433
|
+
// The `undefined` check is a fast path for pre-existing keys.
|
|
39434
|
+
if (draft[key] === undefined && !has$1(draft, key)) {
|
|
39435
|
+
assigned[key] = false;
|
|
39436
|
+
markChanged(state);
|
|
39437
|
+
}
|
|
39438
|
+
});
|
|
39439
|
+
} else if (hasArrayChanges(state)) {
|
|
39440
|
+
markChanged(state);
|
|
39441
|
+
assigned.length = true;
|
|
39442
|
+
|
|
39443
|
+
if (draft.length < base.length) {
|
|
39444
|
+
for (var i = draft.length; i < base.length; i++) { assigned[i] = false; }
|
|
39445
|
+
} else {
|
|
39446
|
+
for (var i$1 = base.length; i$1 < draft.length; i$1++) { assigned[i$1] = true; }
|
|
39447
|
+
}
|
|
39448
|
+
|
|
39449
|
+
for (var i$2 = 0; i$2 < draft.length; i$2++) {
|
|
39450
|
+
// Only untouched indices trigger recursion.
|
|
39451
|
+
if (assigned[i$2] === undefined) { markChangesRecursively(draft[i$2]); }
|
|
39452
|
+
}
|
|
39453
|
+
}
|
|
39454
|
+
}
|
|
39455
|
+
|
|
39456
|
+
function hasObjectChanges(state) {
|
|
39457
|
+
var base = state.base;
|
|
39458
|
+
var draft = state.draft; // Search for added keys and changed keys. Start at the back, because
|
|
39459
|
+
// non-numeric keys are ordered by time of definition on the object.
|
|
39460
|
+
|
|
39461
|
+
var keys = Object.keys(draft);
|
|
39462
|
+
|
|
39463
|
+
for (var i = keys.length - 1; i >= 0; i--) {
|
|
39464
|
+
var key = keys[i];
|
|
39465
|
+
var baseValue = base[key]; // The `undefined` check is a fast path for pre-existing keys.
|
|
39466
|
+
|
|
39467
|
+
if (baseValue === undefined && !has$1(base, key)) {
|
|
39468
|
+
return true;
|
|
39469
|
+
} // Once a base key is deleted, future changes go undetected, because its
|
|
39470
|
+
// descriptor is erased. This branch detects any missed changes.
|
|
39471
|
+
else {
|
|
39472
|
+
var value = draft[key];
|
|
39473
|
+
var state$1 = value && value[DRAFT_STATE];
|
|
39474
|
+
|
|
39475
|
+
if (state$1 ? state$1.base !== baseValue : !is(value, baseValue)) {
|
|
39476
|
+
return true;
|
|
39477
|
+
}
|
|
39478
|
+
}
|
|
39479
|
+
} // At this point, no keys were added or changed.
|
|
39480
|
+
// Compare key count to determine if keys were deleted.
|
|
39481
|
+
|
|
39482
|
+
|
|
39483
|
+
return keys.length !== Object.keys(base).length;
|
|
39484
|
+
}
|
|
39485
|
+
|
|
39486
|
+
function hasArrayChanges(state) {
|
|
39487
|
+
var draft = state.draft;
|
|
39488
|
+
if (draft.length !== state.base.length) { return true; } // See #116
|
|
39489
|
+
// If we first shorten the length, our array interceptors will be removed.
|
|
39490
|
+
// If after that new items are added, result in the same original length,
|
|
39491
|
+
// those last items will have no intercepting property.
|
|
39492
|
+
// So if there is no own descriptor on the last position, we know that items were removed and added
|
|
39493
|
+
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
39494
|
+
// the last one
|
|
39495
|
+
|
|
39496
|
+
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
39497
|
+
|
|
39498
|
+
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
|
|
39499
|
+
|
|
39500
|
+
return false;
|
|
39501
|
+
}
|
|
39502
|
+
|
|
39503
|
+
function createHiddenProperty(target, prop, value) {
|
|
39504
|
+
Object.defineProperty(target, prop, {
|
|
39505
|
+
value: value,
|
|
39506
|
+
enumerable: false,
|
|
39507
|
+
writable: true
|
|
39508
|
+
});
|
|
39509
|
+
}
|
|
39510
|
+
|
|
39511
|
+
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
39512
|
+
willFinalize: willFinalize,
|
|
39513
|
+
createProxy: createProxy
|
|
39514
|
+
});
|
|
39515
|
+
|
|
39516
|
+
function willFinalize$1() {}
|
|
39517
|
+
function createProxy$1(base, parent) {
|
|
39518
|
+
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39519
|
+
var state = {
|
|
39520
|
+
// Track which produce call this is associated with.
|
|
39521
|
+
scope: scope,
|
|
39522
|
+
// True for both shallow and deep changes.
|
|
39523
|
+
modified: false,
|
|
39524
|
+
// Used during finalization.
|
|
39525
|
+
finalized: false,
|
|
39526
|
+
// Track which properties have been assigned (true) or deleted (false).
|
|
39527
|
+
assigned: {},
|
|
39528
|
+
// The parent draft state.
|
|
39529
|
+
parent: parent,
|
|
39530
|
+
// The base state.
|
|
39531
|
+
base: base,
|
|
39532
|
+
// The base proxy.
|
|
39533
|
+
draft: null,
|
|
39534
|
+
// Any property proxies.
|
|
39535
|
+
drafts: {},
|
|
39536
|
+
// The base copy with any updated values.
|
|
39537
|
+
copy: null,
|
|
39538
|
+
// Called by the `produce` function.
|
|
39539
|
+
revoke: null
|
|
39540
|
+
};
|
|
39541
|
+
var ref = Array.isArray(base) ? // [state] is used for arrays, to make sure the proxy is array-ish and not violate invariants,
|
|
39542
|
+
// although state itself is an object
|
|
39543
|
+
Proxy.revocable([state], arrayTraps) : Proxy.revocable(state, objectTraps);
|
|
39544
|
+
var revoke = ref.revoke;
|
|
39545
|
+
var proxy = ref.proxy;
|
|
39546
|
+
state.draft = proxy;
|
|
39547
|
+
state.revoke = revoke;
|
|
39548
|
+
scope.drafts.push(proxy);
|
|
39549
|
+
return proxy;
|
|
39550
|
+
}
|
|
39551
|
+
var objectTraps = {
|
|
39552
|
+
get: get$1$1,
|
|
39553
|
+
|
|
39554
|
+
has: function has(target, prop) {
|
|
39555
|
+
return prop in source$1(target);
|
|
39556
|
+
},
|
|
39557
|
+
|
|
39558
|
+
ownKeys: function ownKeys(target) {
|
|
39559
|
+
return Reflect.ownKeys(source$1(target));
|
|
39560
|
+
},
|
|
39561
|
+
|
|
39562
|
+
set: set$1$1,
|
|
39563
|
+
deleteProperty: deleteProperty,
|
|
39564
|
+
getOwnPropertyDescriptor: getOwnPropertyDescriptor$2,
|
|
39565
|
+
|
|
39566
|
+
defineProperty: function defineProperty() {
|
|
39567
|
+
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
39568
|
+
},
|
|
39569
|
+
|
|
39570
|
+
getPrototypeOf: function getPrototypeOf(target) {
|
|
39571
|
+
return Object.getPrototypeOf(target.base);
|
|
39572
|
+
},
|
|
39573
|
+
|
|
39574
|
+
setPrototypeOf: function setPrototypeOf() {
|
|
39575
|
+
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
39576
|
+
}
|
|
39577
|
+
|
|
39578
|
+
};
|
|
39579
|
+
var arrayTraps = {};
|
|
39580
|
+
each(objectTraps, function (key, fn) {
|
|
39581
|
+
arrayTraps[key] = function () {
|
|
39582
|
+
arguments[0] = arguments[0][0];
|
|
39583
|
+
return fn.apply(this, arguments);
|
|
39584
|
+
};
|
|
39585
|
+
});
|
|
39586
|
+
|
|
39587
|
+
arrayTraps.deleteProperty = function (state, prop) {
|
|
39588
|
+
if (isNaN(parseInt(prop))) {
|
|
39589
|
+
throw new Error("Immer only supports deleting array indices"); // prettier-ignore
|
|
39590
|
+
}
|
|
39591
|
+
|
|
39592
|
+
return objectTraps.deleteProperty.call(this, state[0], prop);
|
|
39593
|
+
};
|
|
39594
|
+
|
|
39595
|
+
arrayTraps.set = function (state, prop, value) {
|
|
39596
|
+
if (prop !== "length" && isNaN(parseInt(prop))) {
|
|
39597
|
+
throw new Error("Immer only supports setting array indices and the 'length' property"); // prettier-ignore
|
|
39598
|
+
}
|
|
39599
|
+
|
|
39600
|
+
return objectTraps.set.call(this, state[0], prop, value);
|
|
39601
|
+
}; // returns the object we should be reading the current value from, which is base, until some change has been made
|
|
39602
|
+
|
|
39603
|
+
|
|
39604
|
+
function source$1(state) {
|
|
39605
|
+
return state.copy || state.base;
|
|
39606
|
+
} // Access a property without creating an Immer draft.
|
|
39607
|
+
|
|
39608
|
+
|
|
39609
|
+
function peek$1(draft, prop) {
|
|
39610
|
+
var state = draft[DRAFT_STATE];
|
|
39611
|
+
var desc = Reflect.getOwnPropertyDescriptor(state ? source$1(state) : draft, prop);
|
|
39612
|
+
return desc && desc.value;
|
|
39613
|
+
}
|
|
39614
|
+
|
|
39615
|
+
function get$1$1(state, prop) {
|
|
39616
|
+
if (prop === DRAFT_STATE) { return state; }
|
|
39617
|
+
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
39618
|
+
|
|
39619
|
+
if (!state.modified && has$1(drafts, prop)) {
|
|
39620
|
+
return drafts[prop];
|
|
39621
|
+
}
|
|
39622
|
+
|
|
39623
|
+
var value = source$1(state)[prop];
|
|
39624
|
+
|
|
39625
|
+
if (state.finalized || !isDraftable(value)) {
|
|
39626
|
+
return value;
|
|
39627
|
+
} // Check for existing draft in modified state.
|
|
39628
|
+
|
|
39629
|
+
|
|
39630
|
+
if (state.modified) {
|
|
39631
|
+
// Assigned values are never drafted. This catches any drafts we created, too.
|
|
39632
|
+
if (value !== peek$1(state.base, prop)) { return value; } // Store drafts on the copy (when one exists).
|
|
39633
|
+
|
|
39634
|
+
drafts = state.copy;
|
|
39635
|
+
}
|
|
39636
|
+
|
|
39637
|
+
return drafts[prop] = createProxy$1(value, state);
|
|
39638
|
+
}
|
|
39639
|
+
|
|
39640
|
+
function set$1$1(state, prop, value) {
|
|
39641
|
+
if (!state.modified) {
|
|
39642
|
+
var baseValue = peek$1(state.base, prop); // Optimize based on value's truthiness. Truthy values are guaranteed to
|
|
39643
|
+
// never be undefined, so we can avoid the `in` operator. Lastly, truthy
|
|
39644
|
+
// values may be drafts, but falsy values are never drafts.
|
|
39645
|
+
|
|
39646
|
+
var isUnchanged = value ? is(baseValue, value) || value === state.drafts[prop] : is(baseValue, value) && prop in state.base;
|
|
39647
|
+
if (isUnchanged) { return true; }
|
|
39648
|
+
markChanged$1(state);
|
|
39649
|
+
}
|
|
39650
|
+
|
|
39651
|
+
state.assigned[prop] = true;
|
|
39652
|
+
state.copy[prop] = value;
|
|
39653
|
+
return true;
|
|
39654
|
+
}
|
|
39655
|
+
|
|
39656
|
+
function deleteProperty(state, prop) {
|
|
39657
|
+
// The `undefined` check is a fast path for pre-existing keys.
|
|
39658
|
+
if (peek$1(state.base, prop) !== undefined || prop in state.base) {
|
|
39659
|
+
state.assigned[prop] = false;
|
|
39660
|
+
markChanged$1(state);
|
|
39661
|
+
} else if (state.assigned[prop]) {
|
|
39662
|
+
// if an originally not assigned property was deleted
|
|
39663
|
+
delete state.assigned[prop];
|
|
39664
|
+
}
|
|
39665
|
+
|
|
39666
|
+
if (state.copy) { delete state.copy[prop]; }
|
|
39667
|
+
return true;
|
|
39668
|
+
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
39669
|
+
// the same guarantee in ES5 mode.
|
|
39670
|
+
|
|
39671
|
+
|
|
39672
|
+
function getOwnPropertyDescriptor$2(state, prop) {
|
|
39673
|
+
var owner = source$1(state);
|
|
39674
|
+
var desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
39675
|
+
|
|
39676
|
+
if (desc) {
|
|
39677
|
+
desc.writable = true;
|
|
39678
|
+
desc.configurable = !Array.isArray(owner) || prop !== "length";
|
|
39679
|
+
}
|
|
39680
|
+
|
|
39681
|
+
return desc;
|
|
39682
|
+
}
|
|
39683
|
+
|
|
39684
|
+
function markChanged$1(state) {
|
|
39685
|
+
if (!state.modified) {
|
|
39686
|
+
state.modified = true;
|
|
39687
|
+
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
39688
|
+
state.drafts = null;
|
|
39689
|
+
if (state.parent) { markChanged$1(state.parent); }
|
|
39690
|
+
}
|
|
39691
|
+
}
|
|
39692
|
+
|
|
39693
|
+
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
39694
|
+
willFinalize: willFinalize$1,
|
|
39695
|
+
createProxy: createProxy$1
|
|
39696
|
+
});
|
|
39697
|
+
|
|
39698
|
+
function generatePatches(state, basePath, patches, inversePatches) {
|
|
39699
|
+
Array.isArray(state.base) ? generateArrayPatches(state, basePath, patches, inversePatches) : generateObjectPatches(state, basePath, patches, inversePatches);
|
|
39700
|
+
}
|
|
39701
|
+
|
|
39702
|
+
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
39703
|
+
var assign, assign$1;
|
|
39704
|
+
|
|
39705
|
+
var base = state.base;
|
|
39706
|
+
var copy = state.copy;
|
|
39707
|
+
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
39708
|
+
|
|
39709
|
+
if (copy.length < base.length) {
|
|
39710
|
+
(assign = [copy, base], base = assign[0], copy = assign[1]);
|
|
39711
|
+
(assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1]);
|
|
39712
|
+
}
|
|
39713
|
+
|
|
39714
|
+
var delta = copy.length - base.length; // Find the first replaced index.
|
|
39715
|
+
|
|
39716
|
+
var start = 0;
|
|
39717
|
+
|
|
39718
|
+
while (base[start] === copy[start] && start < base.length) {
|
|
39719
|
+
++start;
|
|
39720
|
+
} // Find the last replaced index. Search from the end to optimize splice patches.
|
|
39721
|
+
|
|
39722
|
+
|
|
39723
|
+
var end = base.length;
|
|
39724
|
+
|
|
39725
|
+
while (end > start && base[end - 1] === copy[end + delta - 1]) {
|
|
39726
|
+
--end;
|
|
39727
|
+
} // Process replaced indices.
|
|
39728
|
+
|
|
39729
|
+
|
|
39730
|
+
for (var i = start; i < end; ++i) {
|
|
39731
|
+
if (assigned[i] && copy[i] !== base[i]) {
|
|
39732
|
+
var path = basePath.concat([i]);
|
|
39733
|
+
patches.push({
|
|
39734
|
+
op: "replace",
|
|
39735
|
+
path: path,
|
|
39736
|
+
value: copy[i]
|
|
39737
|
+
});
|
|
39738
|
+
inversePatches.push({
|
|
39739
|
+
op: "replace",
|
|
39740
|
+
path: path,
|
|
39741
|
+
value: base[i]
|
|
39742
|
+
});
|
|
39743
|
+
}
|
|
39744
|
+
}
|
|
39745
|
+
|
|
39746
|
+
var replaceCount = patches.length; // Process added indices.
|
|
39747
|
+
|
|
39748
|
+
for (var i$1 = end + delta - 1; i$1 >= end; --i$1) {
|
|
39749
|
+
var path$1 = basePath.concat([i$1]);
|
|
39750
|
+
patches[replaceCount + i$1 - end] = {
|
|
39751
|
+
op: "add",
|
|
39752
|
+
path: path$1,
|
|
39753
|
+
value: copy[i$1]
|
|
39754
|
+
};
|
|
39755
|
+
inversePatches.push({
|
|
39756
|
+
op: "remove",
|
|
39757
|
+
path: path$1
|
|
39758
|
+
});
|
|
39759
|
+
}
|
|
39760
|
+
}
|
|
39761
|
+
|
|
39762
|
+
function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
39763
|
+
var base = state.base;
|
|
39764
|
+
var copy = state.copy;
|
|
39765
|
+
each(state.assigned, function (key, assignedValue) {
|
|
39766
|
+
var origValue = base[key];
|
|
39767
|
+
var value = copy[key];
|
|
39768
|
+
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
39769
|
+
if (origValue === value && op === "replace") { return; }
|
|
39770
|
+
var path = basePath.concat(key);
|
|
39771
|
+
patches.push(op === "remove" ? {
|
|
39772
|
+
op: op,
|
|
39773
|
+
path: path
|
|
39774
|
+
} : {
|
|
39775
|
+
op: op,
|
|
39776
|
+
path: path,
|
|
39777
|
+
value: value
|
|
39778
|
+
});
|
|
39779
|
+
inversePatches.push(op === "add" ? {
|
|
39780
|
+
op: "remove",
|
|
39781
|
+
path: path
|
|
39782
|
+
} : op === "remove" ? {
|
|
39783
|
+
op: "add",
|
|
39784
|
+
path: path,
|
|
39785
|
+
value: origValue
|
|
39786
|
+
} : {
|
|
39787
|
+
op: "replace",
|
|
39788
|
+
path: path,
|
|
39789
|
+
value: origValue
|
|
39790
|
+
});
|
|
39791
|
+
});
|
|
39792
|
+
}
|
|
39793
|
+
|
|
39794
|
+
var applyPatches = function (draft, patches) {
|
|
39795
|
+
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
39796
|
+
var patch = list[i$1];
|
|
39797
|
+
|
|
39798
|
+
var path = patch.path;
|
|
39799
|
+
var op = patch.op;
|
|
39800
|
+
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
39801
|
+
|
|
39802
|
+
if (!path.length) { throw new Error("Illegal state"); }
|
|
39803
|
+
var base = draft;
|
|
39804
|
+
|
|
39805
|
+
for (var i = 0; i < path.length - 1; i++) {
|
|
39806
|
+
base = base[path[i]];
|
|
39807
|
+
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
39808
|
+
}
|
|
39809
|
+
|
|
39810
|
+
var key = path[path.length - 1];
|
|
39811
|
+
|
|
39812
|
+
switch (op) {
|
|
39813
|
+
case "replace":
|
|
39814
|
+
// if value is an object, then it's assigned by reference
|
|
39815
|
+
// in the following add or remove ops, the value field inside the patch will also be modifyed
|
|
39816
|
+
// so we use value from the cloned patch
|
|
39817
|
+
base[key] = value;
|
|
39818
|
+
break;
|
|
39819
|
+
|
|
39820
|
+
case "add":
|
|
39821
|
+
if (Array.isArray(base)) {
|
|
39822
|
+
// TODO: support "foo/-" paths for appending to an array
|
|
39823
|
+
base.splice(key, 0, value);
|
|
39824
|
+
} else {
|
|
39825
|
+
base[key] = value;
|
|
39826
|
+
}
|
|
39827
|
+
|
|
39828
|
+
break;
|
|
39829
|
+
|
|
39830
|
+
case "remove":
|
|
39831
|
+
if (Array.isArray(base)) {
|
|
39832
|
+
base.splice(key, 1);
|
|
39833
|
+
} else {
|
|
39834
|
+
delete base[key];
|
|
39835
|
+
}
|
|
39836
|
+
|
|
39837
|
+
break;
|
|
39838
|
+
|
|
39839
|
+
default:
|
|
39840
|
+
throw new Error("Unsupported patch operation: " + op);
|
|
39841
|
+
}
|
|
39842
|
+
}
|
|
39843
|
+
|
|
39844
|
+
return draft;
|
|
39845
|
+
};
|
|
39846
|
+
|
|
39847
|
+
function verifyMinified() {}
|
|
39848
|
+
|
|
39849
|
+
var configDefaults = {
|
|
39850
|
+
useProxies: typeof Proxy !== "undefined" && typeof Reflect !== "undefined",
|
|
39851
|
+
autoFreeze: typeof process !== "undefined" ? process.env.NODE_ENV !== "production" : verifyMinified.name === "verifyMinified",
|
|
39852
|
+
onAssign: null,
|
|
39853
|
+
onDelete: null,
|
|
39854
|
+
onCopy: null
|
|
39855
|
+
};
|
|
39856
|
+
var Immer = function Immer(config) {
|
|
39857
|
+
assign(this, configDefaults, config);
|
|
39858
|
+
this.setUseProxies(this.useProxies);
|
|
39859
|
+
this.produce = this.produce.bind(this);
|
|
39860
|
+
};
|
|
39861
|
+
|
|
39862
|
+
Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
39863
|
+
var this$1$1 = this;
|
|
39864
|
+
|
|
39865
|
+
// curried invocation
|
|
39866
|
+
if (typeof base === "function" && typeof recipe !== "function") {
|
|
39867
|
+
var defaultBase = recipe;
|
|
39868
|
+
recipe = base;
|
|
39869
|
+
var self = this;
|
|
39870
|
+
return function curriedProduce(base) {
|
|
39871
|
+
var this$1$1 = this;
|
|
39872
|
+
if ( base === void 0 ) base = defaultBase;
|
|
39873
|
+
var args = [], len = arguments.length - 1;
|
|
39874
|
+
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
39875
|
+
|
|
39876
|
+
return self.produce(base, function (draft) { return recipe.call.apply(recipe, [ this$1$1, draft ].concat( args )); }); // prettier-ignore
|
|
39877
|
+
};
|
|
39878
|
+
} // prettier-ignore
|
|
39879
|
+
|
|
39880
|
+
|
|
39881
|
+
{
|
|
39882
|
+
if (typeof recipe !== "function") {
|
|
39883
|
+
throw new Error("The first or second argument to `produce` must be a function");
|
|
39884
|
+
}
|
|
39885
|
+
|
|
39886
|
+
if (patchListener !== undefined && typeof patchListener !== "function") {
|
|
39887
|
+
throw new Error("The third argument to `produce` must be a function or undefined");
|
|
39888
|
+
}
|
|
39889
|
+
}
|
|
39890
|
+
var result; // Only plain objects, arrays, and "immerable classes" are drafted.
|
|
39891
|
+
|
|
39892
|
+
if (isDraftable(base)) {
|
|
39893
|
+
var scope = ImmerScope.enter();
|
|
39894
|
+
var proxy = this.createProxy(base);
|
|
39895
|
+
var hasError = true;
|
|
39896
|
+
|
|
39897
|
+
try {
|
|
39898
|
+
result = recipe(proxy);
|
|
39899
|
+
hasError = false;
|
|
39900
|
+
} finally {
|
|
39901
|
+
// finally instead of catch + rethrow better preserves original stack
|
|
39902
|
+
if (hasError) { scope.revoke(); }else { scope.leave(); }
|
|
39903
|
+
}
|
|
39904
|
+
|
|
39905
|
+
if (result instanceof Promise) {
|
|
39906
|
+
return result.then(function (result) {
|
|
39907
|
+
scope.usePatches(patchListener);
|
|
39908
|
+
return this$1$1.processResult(result, scope);
|
|
39909
|
+
}, function (error) {
|
|
39910
|
+
scope.revoke();
|
|
39911
|
+
throw error;
|
|
39912
|
+
});
|
|
39913
|
+
}
|
|
39914
|
+
|
|
39915
|
+
scope.usePatches(patchListener);
|
|
39916
|
+
return this.processResult(result, scope);
|
|
39917
|
+
} else {
|
|
39918
|
+
result = recipe(base);
|
|
39919
|
+
if (result === undefined) { return base; }
|
|
39920
|
+
return result !== NOTHING ? result : undefined;
|
|
39921
|
+
}
|
|
39922
|
+
};
|
|
39923
|
+
|
|
39924
|
+
Immer.prototype.produceWithPatches = function produceWithPatches (arg1, arg2, arg3) {
|
|
39925
|
+
var this$1$1 = this;
|
|
39926
|
+
|
|
39927
|
+
if (typeof arg1 === "function") {
|
|
39928
|
+
return function (state) {
|
|
39929
|
+
var args = [], len = arguments.length - 1;
|
|
39930
|
+
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
39931
|
+
|
|
39932
|
+
return this$1$1.produceWithPatches(state, function (draft) { return arg1.apply(void 0, [ draft ].concat( args )); });
|
|
39933
|
+
};
|
|
39934
|
+
} // non-curried form
|
|
39935
|
+
|
|
39936
|
+
|
|
39937
|
+
if (arg3) { throw new Error("A patch listener cannot be passed to produceWithPatches"); }
|
|
39938
|
+
var patches, inversePatches;
|
|
39939
|
+
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
39940
|
+
patches = p;
|
|
39941
|
+
inversePatches = ip;
|
|
39942
|
+
});
|
|
39943
|
+
return [nextState, patches, inversePatches];
|
|
39944
|
+
};
|
|
39945
|
+
|
|
39946
|
+
Immer.prototype.createDraft = function createDraft (base) {
|
|
39947
|
+
if (!isDraftable(base)) {
|
|
39948
|
+
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
39949
|
+
}
|
|
39950
|
+
|
|
39951
|
+
var scope = ImmerScope.enter();
|
|
39952
|
+
var proxy = this.createProxy(base);
|
|
39953
|
+
proxy[DRAFT_STATE].isManual = true;
|
|
39954
|
+
scope.leave();
|
|
39955
|
+
return proxy;
|
|
39956
|
+
};
|
|
39957
|
+
|
|
39958
|
+
Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
39959
|
+
var state = draft && draft[DRAFT_STATE];
|
|
39960
|
+
|
|
39961
|
+
if (!state || !state.isManual) {
|
|
39962
|
+
throw new Error("First argument to `finishDraft` must be a draft returned by `createDraft`"); // prettier-ignore
|
|
39963
|
+
}
|
|
39964
|
+
|
|
39965
|
+
if (state.finalized) {
|
|
39966
|
+
throw new Error("The given draft is already finalized"); // prettier-ignore
|
|
39967
|
+
}
|
|
39968
|
+
|
|
39969
|
+
var scope = state.scope;
|
|
39970
|
+
scope.usePatches(patchListener);
|
|
39971
|
+
return this.processResult(undefined, scope);
|
|
39972
|
+
};
|
|
39973
|
+
|
|
39974
|
+
Immer.prototype.setAutoFreeze = function setAutoFreeze (value) {
|
|
39975
|
+
this.autoFreeze = value;
|
|
39976
|
+
};
|
|
39977
|
+
|
|
39978
|
+
Immer.prototype.setUseProxies = function setUseProxies (value) {
|
|
39979
|
+
this.useProxies = value;
|
|
39980
|
+
assign(this, value ? modernProxy : legacyProxy);
|
|
39981
|
+
};
|
|
39982
|
+
|
|
39983
|
+
Immer.prototype.applyPatches = function applyPatches$1 (base, patches) {
|
|
39984
|
+
// If a patch replaces the entire state, take that replacement as base
|
|
39985
|
+
// before applying patches
|
|
39986
|
+
var i;
|
|
39987
|
+
|
|
39988
|
+
for (i = patches.length - 1; i >= 0; i--) {
|
|
39989
|
+
var patch = patches[i];
|
|
39990
|
+
|
|
39991
|
+
if (patch.path.length === 0 && patch.op === "replace") {
|
|
39992
|
+
base = patch.value;
|
|
39993
|
+
break;
|
|
39994
|
+
}
|
|
39995
|
+
}
|
|
39996
|
+
|
|
39997
|
+
if (isDraft(base)) {
|
|
39998
|
+
// N.B: never hits if some patch a replacement, patches are never drafts
|
|
39999
|
+
return applyPatches(base, patches);
|
|
40000
|
+
} // Otherwise, produce a copy of the base state.
|
|
40001
|
+
|
|
40002
|
+
|
|
40003
|
+
return this.produce(base, function (draft) { return applyPatches(draft, patches.slice(i + 1)); });
|
|
40004
|
+
};
|
|
40005
|
+
/** @internal */
|
|
40006
|
+
|
|
40007
|
+
|
|
40008
|
+
Immer.prototype.processResult = function processResult (result, scope) {
|
|
40009
|
+
var baseDraft = scope.drafts[0];
|
|
40010
|
+
var isReplaced = result !== undefined && result !== baseDraft;
|
|
40011
|
+
this.willFinalize(scope, result, isReplaced);
|
|
40012
|
+
|
|
40013
|
+
if (isReplaced) {
|
|
40014
|
+
if (baseDraft[DRAFT_STATE].modified) {
|
|
40015
|
+
scope.revoke();
|
|
40016
|
+
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
|
|
40017
|
+
}
|
|
40018
|
+
|
|
40019
|
+
if (isDraftable(result)) {
|
|
40020
|
+
// Finalize the result in case it contains (or is) a subset of the draft.
|
|
40021
|
+
result = this.finalize(result, null, scope);
|
|
40022
|
+
}
|
|
40023
|
+
|
|
40024
|
+
if (scope.patches) {
|
|
40025
|
+
scope.patches.push({
|
|
40026
|
+
op: "replace",
|
|
40027
|
+
path: [],
|
|
40028
|
+
value: result
|
|
40029
|
+
});
|
|
40030
|
+
scope.inversePatches.push({
|
|
40031
|
+
op: "replace",
|
|
40032
|
+
path: [],
|
|
40033
|
+
value: baseDraft[DRAFT_STATE].base
|
|
40034
|
+
});
|
|
40035
|
+
}
|
|
40036
|
+
} else {
|
|
40037
|
+
// Finalize the base draft.
|
|
40038
|
+
result = this.finalize(baseDraft, [], scope);
|
|
40039
|
+
}
|
|
40040
|
+
|
|
40041
|
+
scope.revoke();
|
|
40042
|
+
|
|
40043
|
+
if (scope.patches) {
|
|
40044
|
+
scope.patchListener(scope.patches, scope.inversePatches);
|
|
40045
|
+
}
|
|
40046
|
+
|
|
40047
|
+
return result !== NOTHING ? result : undefined;
|
|
39101
40048
|
};
|
|
40049
|
+
/**
|
|
40050
|
+
* @internal
|
|
40051
|
+
* Finalize a draft, returning either the unmodified base state or a modified
|
|
40052
|
+
* copy of the base state.
|
|
40053
|
+
*/
|
|
40054
|
+
|
|
40055
|
+
|
|
40056
|
+
Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
40057
|
+
var this$1$1 = this;
|
|
40058
|
+
|
|
40059
|
+
var state = draft[DRAFT_STATE];
|
|
40060
|
+
|
|
40061
|
+
if (!state) {
|
|
40062
|
+
if (Object.isFrozen(draft)) { return draft; }
|
|
40063
|
+
return this.finalizeTree(draft, null, scope);
|
|
40064
|
+
} // Never finalize drafts owned by another scope.
|
|
40065
|
+
|
|
40066
|
+
|
|
40067
|
+
if (state.scope !== scope) {
|
|
40068
|
+
return draft;
|
|
40069
|
+
}
|
|
40070
|
+
|
|
40071
|
+
if (!state.modified) {
|
|
40072
|
+
return state.base;
|
|
40073
|
+
}
|
|
39102
40074
|
|
|
39103
|
-
|
|
39104
|
-
|
|
39105
|
-
|
|
39106
|
-
|
|
39107
|
-
|
|
39108
|
-
|
|
39109
|
-
|
|
40075
|
+
if (!state.finalized) {
|
|
40076
|
+
state.finalized = true;
|
|
40077
|
+
this.finalizeTree(state.draft, path, scope);
|
|
40078
|
+
|
|
40079
|
+
if (this.onDelete) {
|
|
40080
|
+
// The `assigned` object is unreliable with ES5 drafts.
|
|
40081
|
+
if (this.useProxies) {
|
|
40082
|
+
var assigned = state.assigned;
|
|
40083
|
+
|
|
40084
|
+
for (var prop in assigned) {
|
|
40085
|
+
if (!assigned[prop]) { this.onDelete(state, prop); }
|
|
40086
|
+
}
|
|
40087
|
+
} else {
|
|
40088
|
+
var base = state.base;
|
|
40089
|
+
var copy = state.copy;
|
|
40090
|
+
each(base, function (prop) {
|
|
40091
|
+
if (!has$1(copy, prop)) { this$1$1.onDelete(state, prop); }
|
|
40092
|
+
});
|
|
40093
|
+
}
|
|
40094
|
+
}
|
|
40095
|
+
|
|
40096
|
+
if (this.onCopy) {
|
|
40097
|
+
this.onCopy(state);
|
|
40098
|
+
} // At this point, all descendants of `state.copy` have been finalized,
|
|
40099
|
+
// so we can be sure that `scope.canAutoFreeze` is accurate.
|
|
40100
|
+
|
|
40101
|
+
|
|
40102
|
+
if (this.autoFreeze && scope.canAutoFreeze) {
|
|
40103
|
+
Object.freeze(state.copy);
|
|
40104
|
+
}
|
|
40105
|
+
|
|
40106
|
+
if (path && scope.patches) {
|
|
40107
|
+
generatePatches(state, path, scope.patches, scope.inversePatches);
|
|
40108
|
+
}
|
|
39110
40109
|
}
|
|
40110
|
+
|
|
40111
|
+
return state.copy;
|
|
39111
40112
|
};
|
|
40113
|
+
/**
|
|
40114
|
+
* @internal
|
|
40115
|
+
* Finalize all drafts in the given state tree.
|
|
40116
|
+
*/
|
|
40117
|
+
|
|
40118
|
+
|
|
40119
|
+
Immer.prototype.finalizeTree = function finalizeTree (root, rootPath, scope) {
|
|
40120
|
+
var this$1$1 = this;
|
|
40121
|
+
|
|
40122
|
+
var state = root[DRAFT_STATE];
|
|
39112
40123
|
|
|
39113
|
-
|
|
39114
|
-
|
|
39115
|
-
|
|
39116
|
-
|
|
39117
|
-
|
|
39118
|
-
|
|
39119
|
-
|
|
40124
|
+
if (state) {
|
|
40125
|
+
if (!this.useProxies) {
|
|
40126
|
+
// Create the final copy, with added keys and without deleted keys.
|
|
40127
|
+
state.copy = shallowCopy(state.draft, true);
|
|
40128
|
+
}
|
|
40129
|
+
|
|
40130
|
+
root = state.copy;
|
|
39120
40131
|
}
|
|
40132
|
+
|
|
40133
|
+
var needPatches = !!rootPath && !!scope.patches;
|
|
40134
|
+
|
|
40135
|
+
var finalizeProperty = function (prop, value, parent) {
|
|
40136
|
+
if (value === parent) {
|
|
40137
|
+
throw Error("Immer forbids circular references");
|
|
40138
|
+
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
40139
|
+
|
|
40140
|
+
|
|
40141
|
+
var isDraftProp = !!state && parent === root;
|
|
40142
|
+
|
|
40143
|
+
if (isDraft(value)) {
|
|
40144
|
+
var path = isDraftProp && needPatches && !state.assigned[prop] ? rootPath.concat(prop) : null; // Drafts owned by `scope` are finalized here.
|
|
40145
|
+
|
|
40146
|
+
value = this$1$1.finalize(value, path, scope); // Drafts from another scope must prevent auto-freezing.
|
|
40147
|
+
|
|
40148
|
+
if (isDraft(value)) {
|
|
40149
|
+
scope.canAutoFreeze = false;
|
|
40150
|
+
} // Preserve non-enumerable properties.
|
|
40151
|
+
|
|
40152
|
+
|
|
40153
|
+
if (Array.isArray(parent) || isEnumerable(parent, prop)) {
|
|
40154
|
+
parent[prop] = value;
|
|
40155
|
+
} else {
|
|
40156
|
+
Object.defineProperty(parent, prop, {
|
|
40157
|
+
value: value
|
|
40158
|
+
});
|
|
40159
|
+
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
40160
|
+
|
|
40161
|
+
|
|
40162
|
+
if (isDraftProp && value === state.base[prop]) { return; }
|
|
40163
|
+
} // Unchanged draft properties are ignored.
|
|
40164
|
+
else if (isDraftProp && is(value, state.base[prop])) {
|
|
40165
|
+
return;
|
|
40166
|
+
} // Search new objects for unfinalized drafts. Frozen objects should never contain drafts.
|
|
40167
|
+
else if (isDraftable(value) && !Object.isFrozen(value)) {
|
|
40168
|
+
each(value, finalizeProperty);
|
|
40169
|
+
}
|
|
40170
|
+
|
|
40171
|
+
if (isDraftProp && this$1$1.onAssign) {
|
|
40172
|
+
this$1$1.onAssign(state, prop, value);
|
|
40173
|
+
}
|
|
40174
|
+
};
|
|
40175
|
+
|
|
40176
|
+
each(root, finalizeProperty);
|
|
40177
|
+
return root;
|
|
39121
40178
|
};
|
|
39122
40179
|
|
|
39123
|
-
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;
|
|
40180
|
+
var immer = new Immer();
|
|
40181
|
+
/**
|
|
40182
|
+
* The `produce` function takes a value and a "recipe function" (whose
|
|
40183
|
+
* return value often depends on the base state). The recipe function is
|
|
40184
|
+
* free to mutate its first argument however it wants. All mutations are
|
|
40185
|
+
* only ever applied to a __copy__ of the base state.
|
|
40186
|
+
*
|
|
40187
|
+
* Pass only a function to create a "curried producer" which relieves you
|
|
40188
|
+
* from passing the recipe function every time.
|
|
40189
|
+
*
|
|
40190
|
+
* Only plain objects and arrays are made mutable. All other objects are
|
|
40191
|
+
* considered uncopyable.
|
|
40192
|
+
*
|
|
40193
|
+
* Note: This function is __bound__ to its `Immer` instance.
|
|
40194
|
+
*
|
|
40195
|
+
* @param {any} base - the initial state
|
|
40196
|
+
* @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified
|
|
40197
|
+
* @param {Function} patchListener - optional function that will be called with all the patches produced here
|
|
40198
|
+
* @returns {any} a new state, or the initial state if nothing was modified
|
|
40199
|
+
*/
|
|
40200
|
+
|
|
40201
|
+
var produce = immer.produce;
|
|
40202
|
+
/**
|
|
40203
|
+
* Like `produce`, but `produceWithPatches` always returns a tuple
|
|
40204
|
+
* [nextState, patches, inversePatches] (instead of just the next state)
|
|
40205
|
+
*/
|
|
40206
|
+
|
|
40207
|
+
immer.produceWithPatches.bind(immer);
|
|
40208
|
+
/**
|
|
40209
|
+
* Pass true to automatically freeze all copies created by Immer.
|
|
40210
|
+
*
|
|
40211
|
+
* By default, auto-freezing is disabled in production.
|
|
40212
|
+
*/
|
|
40213
|
+
|
|
40214
|
+
immer.setAutoFreeze.bind(immer);
|
|
40215
|
+
/**
|
|
40216
|
+
* Pass true to use the ES2015 `Proxy` class when creating drafts, which is
|
|
40217
|
+
* always faster than using ES5 proxies.
|
|
40218
|
+
*
|
|
40219
|
+
* By default, feature detection is used, so calling this is rarely necessary.
|
|
40220
|
+
*/
|
|
40221
|
+
|
|
40222
|
+
immer.setUseProxies.bind(immer);
|
|
40223
|
+
/**
|
|
40224
|
+
* Apply an array of Immer patches to the first argument.
|
|
40225
|
+
*
|
|
40226
|
+
* This function is a producer, which means copy-on-write is in effect.
|
|
40227
|
+
*/
|
|
40228
|
+
|
|
40229
|
+
immer.applyPatches.bind(immer);
|
|
40230
|
+
/**
|
|
40231
|
+
* Create an Immer draft from the given base state, which may be a draft itself.
|
|
40232
|
+
* The draft can be modified until you finalize it with the `finishDraft` function.
|
|
40233
|
+
*/
|
|
40234
|
+
|
|
40235
|
+
immer.createDraft.bind(immer);
|
|
40236
|
+
/**
|
|
40237
|
+
* Finalize an Immer draft from a `createDraft` call, returning the base state
|
|
40238
|
+
* (if no changes were made) or a modified copy. The draft must *not* be
|
|
40239
|
+
* mutated afterwards.
|
|
40240
|
+
*
|
|
40241
|
+
* Pass a function as the 2nd argument to generate Immer patches based on the
|
|
40242
|
+
* changes that were made.
|
|
40243
|
+
*/
|
|
39124
40244
|
|
|
39125
|
-
|
|
40245
|
+
immer.finishDraft.bind(immer);
|
|
40246
|
+
|
|
40247
|
+
const createInitialState = formConfig => {
|
|
39126
40248
|
let initialForm = {};
|
|
39127
40249
|
const formConfigKeys = Object.keys(formConfig);
|
|
39128
40250
|
for (let formKey of formConfigKeys) {
|
|
39129
40251
|
initialForm[formKey] = {
|
|
39130
40252
|
dirty: false,
|
|
39131
|
-
rawValue: formConfig[formKey].defaultValue ||
|
|
40253
|
+
rawValue: formConfig[formKey].defaultValue || "",
|
|
39132
40254
|
validators: formConfig[formKey].validators || [],
|
|
39133
|
-
constraints: formConfig[formKey].constraints || []
|
|
40255
|
+
constraints: formConfig[formKey].constraints || []
|
|
39134
40256
|
};
|
|
39135
40257
|
}
|
|
39136
40258
|
// Because validators require the entire form we have to do a
|
|
@@ -39141,99 +40263,82 @@ const createInitialState = (formConfig) => {
|
|
|
39141
40263
|
initialForm[formKey].errors = errors;
|
|
39142
40264
|
initialForm[formKey].hasErrors = errors.length > 0;
|
|
39143
40265
|
}
|
|
39144
|
-
|
|
39145
40266
|
return initialForm;
|
|
39146
40267
|
};
|
|
39147
40268
|
|
|
39148
|
-
const SET =
|
|
39149
|
-
const set$
|
|
40269
|
+
const SET = "field/SET";
|
|
40270
|
+
const set$2 = fieldName => value => ({
|
|
39150
40271
|
type: SET,
|
|
39151
|
-
payload: { fieldName, value }
|
|
40272
|
+
payload: { fieldName, value }
|
|
39152
40273
|
});
|
|
39153
40274
|
|
|
39154
|
-
const CLEAR =
|
|
40275
|
+
const CLEAR = "form/CLEAR";
|
|
39155
40276
|
const clear = () => ({ type: CLEAR });
|
|
39156
40277
|
|
|
39157
|
-
const ADD_VALIDATOR =
|
|
39158
|
-
const addValidator =
|
|
40278
|
+
const ADD_VALIDATOR = "field/ADD_VALIDATOR";
|
|
40279
|
+
const addValidator = fieldName => validator => ({
|
|
39159
40280
|
type: ADD_VALIDATOR,
|
|
39160
|
-
payload: { fieldName, validator }
|
|
39161
|
-
});
|
|
39162
|
-
|
|
39163
|
-
const REMOVE_VALIDATOR = 'field/REMOVE_VALIDATOR';
|
|
39164
|
-
const removeValidator = (fieldName) => (validator) => ({
|
|
39165
|
-
type: REMOVE_VALIDATOR,
|
|
39166
|
-
payload: { fieldName, validator },
|
|
40281
|
+
payload: { fieldName, validator }
|
|
39167
40282
|
});
|
|
39168
40283
|
|
|
39169
|
-
const
|
|
39170
|
-
|
|
39171
|
-
|
|
39172
|
-
|
|
39173
|
-
|
|
39174
|
-
|
|
39175
|
-
const
|
|
39176
|
-
|
|
39177
|
-
|
|
39178
|
-
|
|
39179
|
-
|
|
39180
|
-
|
|
39181
|
-
|
|
39182
|
-
|
|
39183
|
-
|
|
39184
|
-
|
|
39185
|
-
|
|
39186
|
-
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
39187
|
-
// If the change violates constraints, revert the change
|
|
39188
|
-
draftState[changedFieldName].rawValue = originalValue;
|
|
39189
|
-
return draftState;
|
|
39190
|
-
}
|
|
39191
|
-
|
|
39192
|
-
computeDirtyEntries(draftState, changedFieldName);
|
|
39193
|
-
computeErrorEntries(draftState);
|
|
39194
|
-
});
|
|
39195
|
-
}
|
|
39196
|
-
case CLEAR:
|
|
39197
|
-
return createInitialState(formConfig);
|
|
39198
|
-
case ADD_VALIDATOR: {
|
|
39199
|
-
const fieldWithOverride = action.payload.fieldName;
|
|
39200
|
-
const newValidator = action.payload.validator;
|
|
39201
|
-
|
|
39202
|
-
return produce(state, (draftState) => {
|
|
39203
|
-
draftState[fieldWithOverride].validators.push(newValidator);
|
|
39204
|
-
computeErrorEntries(draftState);
|
|
39205
|
-
});
|
|
39206
|
-
}
|
|
39207
|
-
case REMOVE_VALIDATOR: {
|
|
39208
|
-
const fieldToOverride = action.payload.fieldName;
|
|
39209
|
-
const targetValidator = action.payload.validator;
|
|
39210
|
-
|
|
39211
|
-
return produce(state, (draftState) => {
|
|
39212
|
-
let fieldValidators = draftState[fieldToOverride].validators;
|
|
39213
|
-
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
39214
|
-
(validator) => validator.type !== targetValidator.type
|
|
39215
|
-
);
|
|
39216
|
-
computeErrorEntries(draftState);
|
|
39217
|
-
});
|
|
39218
|
-
}
|
|
39219
|
-
case CLEAR_FIELD_VALIDATORS: {
|
|
39220
|
-
const fieldToClear = action.payload.fieldName;
|
|
40284
|
+
const createFormReducer = formConfig => (
|
|
40285
|
+
state = createInitialState(formConfig),
|
|
40286
|
+
action
|
|
40287
|
+
) => {
|
|
40288
|
+
switch (action.type) {
|
|
40289
|
+
case SET:
|
|
40290
|
+
const changedFieldName = action.payload.fieldName;
|
|
40291
|
+
const newRawValue = action.payload.value;
|
|
40292
|
+
|
|
40293
|
+
return produce(state, draftState => {
|
|
40294
|
+
let originalValue = draftState[changedFieldName].rawValue;
|
|
40295
|
+
draftState[changedFieldName].rawValue = newRawValue;
|
|
40296
|
+
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
40297
|
+
// If the change violates constraints, revert the change
|
|
40298
|
+
draftState[changedFieldName].rawValue = originalValue;
|
|
40299
|
+
return draftState;
|
|
40300
|
+
}
|
|
39221
40301
|
|
|
39222
|
-
|
|
39223
|
-
|
|
39224
|
-
|
|
39225
|
-
|
|
39226
|
-
|
|
39227
|
-
|
|
39228
|
-
|
|
39229
|
-
|
|
39230
|
-
|
|
40302
|
+
const fields = Object.entries(draftState);
|
|
40303
|
+
for (let entry of fields) {
|
|
40304
|
+
let fieldName = entry[0];
|
|
40305
|
+
let field = entry[1];
|
|
40306
|
+
let errors = computeErrors(fieldName, draftState);
|
|
40307
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
40308
|
+
draftState[fieldName].errors = errors;
|
|
40309
|
+
draftState[fieldName].dirty = dirty;
|
|
40310
|
+
draftState[fieldName].hasErrors = errors.length > 0;
|
|
40311
|
+
}
|
|
40312
|
+
});
|
|
40313
|
+
case CLEAR:
|
|
40314
|
+
return createInitialState(formConfig);
|
|
40315
|
+
case ADD_VALIDATOR:
|
|
40316
|
+
const fieldWithOverride = action.payload.fieldName;
|
|
40317
|
+
const newValidator = action.payload.validator;
|
|
40318
|
+
|
|
40319
|
+
return produce(state, draftState => {
|
|
40320
|
+
draftState[fieldWithOverride].validators.push(newValidator);
|
|
40321
|
+
const fields = Object.entries(draftState);
|
|
40322
|
+
for (let entry of fields) {
|
|
40323
|
+
let fieldName = entry[0];
|
|
40324
|
+
let field = entry[1];
|
|
40325
|
+
let errors = computeErrors(fieldName, draftState);
|
|
40326
|
+
let dirty = field.dirty;
|
|
40327
|
+
draftState[fieldName].errors = errors;
|
|
40328
|
+
draftState[fieldName].dirty = dirty;
|
|
40329
|
+
draftState[fieldName].hasErrors = errors.length > 0;
|
|
40330
|
+
}
|
|
40331
|
+
});
|
|
40332
|
+
default:
|
|
40333
|
+
return state;
|
|
40334
|
+
}
|
|
40335
|
+
};
|
|
39231
40336
|
|
|
39232
|
-
const createMapDispatchToProps =
|
|
40337
|
+
const createMapDispatchToProps = formConfig => {
|
|
39233
40338
|
// Do memo-ization
|
|
39234
40339
|
let cachedDispatch;
|
|
39235
40340
|
let cacheValue;
|
|
39236
|
-
return
|
|
40341
|
+
return dispatch => {
|
|
39237
40342
|
if (dispatch == cachedDispatch) {
|
|
39238
40343
|
return cacheValue;
|
|
39239
40344
|
}
|
|
@@ -39242,11 +40347,8 @@ const createMapDispatchToProps = (formConfig) => {
|
|
|
39242
40347
|
const keys = Object.keys(formConfig);
|
|
39243
40348
|
for (let fieldName of keys) {
|
|
39244
40349
|
dispatchObj.fields[fieldName] = {
|
|
39245
|
-
set:
|
|
39246
|
-
addValidator:
|
|
39247
|
-
removeValidator: (validator) =>
|
|
39248
|
-
dispatch(removeValidator(fieldName)(validator)),
|
|
39249
|
-
clear: () => dispatch(clearFieldValidators(fieldName)()),
|
|
40350
|
+
set: value => dispatch(set$2(fieldName)(value)),
|
|
40351
|
+
addValidator: validator => dispatch(addValidator(fieldName)(validator))
|
|
39250
40352
|
};
|
|
39251
40353
|
}
|
|
39252
40354
|
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
@@ -39256,12 +40358,12 @@ const createMapDispatchToProps = (formConfig) => {
|
|
|
39256
40358
|
};
|
|
39257
40359
|
};
|
|
39258
40360
|
|
|
39259
|
-
const mapStateToProps =
|
|
40361
|
+
const mapStateToProps = state => ({ fields: state });
|
|
39260
40362
|
|
|
39261
|
-
const createFormState =
|
|
40363
|
+
const createFormState = formConfig => ({
|
|
39262
40364
|
reducer: createFormReducer(formConfig),
|
|
39263
40365
|
mapDispatchToProps: createMapDispatchToProps(formConfig),
|
|
39264
|
-
mapStateToProps: mapStateToProps
|
|
40366
|
+
mapStateToProps: mapStateToProps
|
|
39265
40367
|
});
|
|
39266
40368
|
|
|
39267
40369
|
var AddressForm = function AddressForm(_ref) {
|
|
@@ -42127,12 +43229,12 @@ LoginForm.mapDispatchToProps = mapDispatchToProps$5;
|
|
|
42127
43229
|
* This source code is licensed under the MIT license found in the
|
|
42128
43230
|
* LICENSE file in the root directory of this source tree.
|
|
42129
43231
|
*/
|
|
42130
|
-
var b$
|
|
42131
|
-
Symbol.for("react.suspense_list"):60120,r
|
|
42132
|
-
function z
|
|
42133
|
-
var Profiler=g
|
|
42134
|
-
var isMemo=function(a){return z
|
|
42135
|
-
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g
|
|
43232
|
+
var b$1="function"===typeof Symbol&&Symbol.for,c$1=b$1?Symbol.for("react.element"):60103,d=b$1?Symbol.for("react.portal"):60106,e=b$1?Symbol.for("react.fragment"):60107,f$6=b$1?Symbol.for("react.strict_mode"):60108,g=b$1?Symbol.for("react.profiler"):60114,h=b$1?Symbol.for("react.provider"):60109,k=b$1?Symbol.for("react.context"):60110,l=b$1?Symbol.for("react.async_mode"):60111,m=b$1?Symbol.for("react.concurrent_mode"):60111,n=b$1?Symbol.for("react.forward_ref"):60112,p=b$1?Symbol.for("react.suspense"):60113,q=b$1?
|
|
43233
|
+
Symbol.for("react.suspense_list"):60120,r=b$1?Symbol.for("react.memo"):60115,t=b$1?Symbol.for("react.lazy"):60116,v=b$1?Symbol.for("react.block"):60121,w=b$1?Symbol.for("react.fundamental"):60117,x=b$1?Symbol.for("react.responder"):60118,y=b$1?Symbol.for("react.scope"):60119;
|
|
43234
|
+
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c$1:switch(a=a.type,a){case l:case m:case e:case g:case f$6:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}var AsyncMode=l;var ConcurrentMode=m;var ContextConsumer=k;var ContextProvider=h;var Element$1=c$1;var ForwardRef=n;var Fragment=e;var Lazy=t;var Memo=r;var Portal=d;
|
|
43235
|
+
var Profiler=g;var StrictMode=f$6;var Suspense=p;var isAsyncMode=function(a){return A(a)||z(a)===l};var isConcurrentMode=A;var isContextConsumer=function(a){return z(a)===k};var isContextProvider=function(a){return z(a)===h};var isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c$1};var isForwardRef=function(a){return z(a)===n};var isFragment=function(a){return z(a)===e};var isLazy=function(a){return z(a)===t};
|
|
43236
|
+
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$6};var isSuspense=function(a){return z(a)===p};
|
|
43237
|
+
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f$6||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};var typeOf=z;
|
|
42136
43238
|
|
|
42137
43239
|
var reactIs_production_min = {
|
|
42138
43240
|
AsyncMode: AsyncMode,
|
|
@@ -42503,14 +43605,14 @@ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
|
42503
43605
|
|
|
42504
43606
|
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
42505
43607
|
|
|
42506
|
-
var has$
|
|
43608
|
+
var has$2 = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
42507
43609
|
|
|
42508
43610
|
var printWarning = function() {};
|
|
42509
43611
|
|
|
42510
43612
|
if (process.env.NODE_ENV !== 'production') {
|
|
42511
43613
|
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
42512
43614
|
var loggedTypeFailures = {};
|
|
42513
|
-
var has$
|
|
43615
|
+
var has$3 = has$2;
|
|
42514
43616
|
|
|
42515
43617
|
printWarning = function(text) {
|
|
42516
43618
|
var message = 'Warning: ' + text;
|
|
@@ -42540,7 +43642,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
42540
43642
|
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
42541
43643
|
if (process.env.NODE_ENV !== 'production') {
|
|
42542
43644
|
for (var typeSpecName in typeSpecs) {
|
|
42543
|
-
if (has$
|
|
43645
|
+
if (has$3(typeSpecs, typeSpecName)) {
|
|
42544
43646
|
var error;
|
|
42545
43647
|
// Prop type validation may throw. In case they do, we don't want to
|
|
42546
43648
|
// fail the render phase where it didn't fail before. So we log it.
|
|
@@ -42939,7 +44041,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
42939
44041
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
42940
44042
|
}
|
|
42941
44043
|
for (var key in propValue) {
|
|
42942
|
-
if (has$
|
|
44044
|
+
if (has$2(propValue, key)) {
|
|
42943
44045
|
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
42944
44046
|
if (error instanceof Error) {
|
|
42945
44047
|
return error;
|
|
@@ -42976,7 +44078,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
42976
44078
|
if (checkerResult == null) {
|
|
42977
44079
|
return null;
|
|
42978
44080
|
}
|
|
42979
|
-
if (checkerResult.data && has$
|
|
44081
|
+
if (checkerResult.data && has$2(checkerResult.data, 'expectedType')) {
|
|
42980
44082
|
expectedTypes.push(checkerResult.data.expectedType);
|
|
42981
44083
|
}
|
|
42982
44084
|
}
|
|
@@ -43036,7 +44138,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
43036
44138
|
var allKeys = objectAssign({}, props[propName], shapeTypes);
|
|
43037
44139
|
for (var key in allKeys) {
|
|
43038
44140
|
var checker = shapeTypes[key];
|
|
43039
|
-
if (has$
|
|
44141
|
+
if (has$2(shapeTypes, key) && typeof checker !== 'function') {
|
|
43040
44142
|
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
43041
44143
|
}
|
|
43042
44144
|
if (!checker) {
|
|
@@ -43774,7 +44876,7 @@ var index_esm = /*#__PURE__*/Object.freeze({
|
|
|
43774
44876
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
43775
44877
|
*/
|
|
43776
44878
|
|
|
43777
|
-
function ownKeys$
|
|
44879
|
+
function ownKeys$3(object, enumerableOnly) {
|
|
43778
44880
|
var keys = Object.keys(object);
|
|
43779
44881
|
|
|
43780
44882
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -43790,9 +44892,9 @@ function ownKeys$2(object, enumerableOnly) {
|
|
|
43790
44892
|
function _objectSpread2$1(target) {
|
|
43791
44893
|
for (var i = 1; i < arguments.length; i++) {
|
|
43792
44894
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
43793
|
-
i % 2 ? ownKeys$
|
|
44895
|
+
i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) {
|
|
43794
44896
|
_defineProperty$1(target, key, source[key]);
|
|
43795
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$
|
|
44897
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) {
|
|
43796
44898
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
43797
44899
|
});
|
|
43798
44900
|
}
|
|
@@ -48486,10 +49588,6 @@ var fallbackValues$Q = {
|
|
|
48486
49588
|
|
|
48487
49589
|
*/
|
|
48488
49590
|
|
|
48489
|
-
var computeSectionId = function computeSectionId(section) {
|
|
48490
|
-
return typeof section.title === "string" ? createIdFromString(section.title) : section.id;
|
|
48491
|
-
};
|
|
48492
|
-
|
|
48493
49591
|
var RadioSection = function RadioSection(_ref) {
|
|
48494
49592
|
var themeValues = _ref.themeValues,
|
|
48495
49593
|
isMobile = _ref.isMobile,
|
|
@@ -48507,15 +49605,10 @@ var RadioSection = function RadioSection(_ref) {
|
|
|
48507
49605
|
openHeight = _ref$openHeight === void 0 ? "auto" : _ref$openHeight,
|
|
48508
49606
|
_ref$containerStyles = _ref.containerStyles,
|
|
48509
49607
|
containerStyles = _ref$containerStyles === void 0 ? "" : _ref$containerStyles,
|
|
48510
|
-
ariaDescribedBy = _ref.ariaDescribedBy
|
|
48511
|
-
_ref$rightContentRole = _ref.rightContentRole,
|
|
48512
|
-
rightContentRole = _ref$rightContentRole === void 0 ? null : _ref$rightContentRole,
|
|
48513
|
-
_ref$ariaLabel = _ref.ariaLabel,
|
|
48514
|
-
_ref$rightIconsLabel = _ref.rightIconsLabel,
|
|
48515
|
-
rightIconsLabel = _ref$rightIconsLabel === void 0 ? null : _ref$rightIconsLabel;
|
|
49608
|
+
ariaDescribedBy = _ref.ariaDescribedBy;
|
|
48516
49609
|
|
|
48517
49610
|
var handleKeyDown = function handleKeyDown(id, e) {
|
|
48518
|
-
if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13
|
|
49611
|
+
if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13) {
|
|
48519
49612
|
toggleOpenSection(id);
|
|
48520
49613
|
}
|
|
48521
49614
|
};
|
|
@@ -48567,8 +49660,7 @@ var RadioSection = function RadioSection(_ref) {
|
|
|
48567
49660
|
borderRadius: "4px",
|
|
48568
49661
|
extraStyles: containerStyles
|
|
48569
49662
|
}, /*#__PURE__*/React__default.createElement(Stack, {
|
|
48570
|
-
childGap: "0"
|
|
48571
|
-
role: "radiogroup"
|
|
49663
|
+
childGap: "0"
|
|
48572
49664
|
}, sections.filter(function (section) {
|
|
48573
49665
|
return !section.hidden;
|
|
48574
49666
|
}).map(function (section) {
|
|
@@ -48587,9 +49679,7 @@ var RadioSection = function RadioSection(_ref) {
|
|
|
48587
49679
|
animate: openSection === section.id ? "open" : "closed",
|
|
48588
49680
|
initial: initiallyOpen ? "open" : "closed",
|
|
48589
49681
|
key: "item-".concat(section.id),
|
|
48590
|
-
extraStyles: borderStyles
|
|
48591
|
-
role: "radio",
|
|
48592
|
-
"aria-checked": openSection === section.id
|
|
49682
|
+
extraStyles: borderStyles
|
|
48593
49683
|
}, /*#__PURE__*/React__default.createElement(Stack, {
|
|
48594
49684
|
childGap: "0"
|
|
48595
49685
|
}, /*#__PURE__*/React__default.createElement(Box, {
|
|
@@ -48619,10 +49709,8 @@ var RadioSection = function RadioSection(_ref) {
|
|
|
48619
49709
|
}, !section.hideRadioButton && /*#__PURE__*/React__default.createElement(Box, {
|
|
48620
49710
|
padding: "0"
|
|
48621
49711
|
}, /*#__PURE__*/React__default.createElement(RadioButton$2, {
|
|
48622
|
-
|
|
48623
|
-
name: computeSectionId(section),
|
|
49712
|
+
name: typeof section.title === "string" ? createIdFromString(section.title) : section.id,
|
|
48624
49713
|
ariaDescribedBy: ariaDescribedBy,
|
|
48625
|
-
ariaLabelledBy: "radio-input-".concat(computeSectionId(section)),
|
|
48626
49714
|
radioOn: openSection === section.id,
|
|
48627
49715
|
radioFocused: focused === section.id,
|
|
48628
49716
|
toggleRadio: section.disabled ? noop : function () {
|
|
@@ -48634,22 +49722,18 @@ var RadioSection = function RadioSection(_ref) {
|
|
|
48634
49722
|
}, section.titleIcon), /*#__PURE__*/React__default.createElement(Box, {
|
|
48635
49723
|
padding: section.titleIcon ? "0 0 0 8px" : "0"
|
|
48636
49724
|
}, /*#__PURE__*/React__default.createElement(Text$1, {
|
|
48637
|
-
|
|
48638
|
-
color: CHARADE_GREY
|
|
48639
|
-
htmlFor: "radio-input-".concat(computeSectionId(section))
|
|
49725
|
+
variant: "p",
|
|
49726
|
+
color: CHARADE_GREY
|
|
48640
49727
|
}, section.title))), section.rightIcons && /*#__PURE__*/React__default.createElement(Cluster, {
|
|
48641
|
-
childGap: "0.5rem"
|
|
48642
|
-
"aria-label": rightIconsLabel
|
|
49728
|
+
childGap: "0.5rem"
|
|
48643
49729
|
}, section.rightIcons.map(function (icon) {
|
|
48644
|
-
return /*#__PURE__*/React__default.createElement(RightIcon,
|
|
49730
|
+
return /*#__PURE__*/React__default.createElement(RightIcon, {
|
|
48645
49731
|
src: icon.img,
|
|
48646
49732
|
key: icon.img,
|
|
48647
49733
|
fade: !icon.enabled,
|
|
48648
49734
|
isMobile: isMobile,
|
|
48649
49735
|
alt: icon.altText
|
|
48650
|
-
}
|
|
48651
|
-
role: rightContentRole || "presentation"
|
|
48652
|
-
} : {}));
|
|
49736
|
+
});
|
|
48653
49737
|
})), section.rightTitleContent && /*#__PURE__*/React__default.createElement(React.Fragment, null, section.rightTitleContent))), /*#__PURE__*/React__default.createElement(AnimatePresence, {
|
|
48654
49738
|
initial: false
|
|
48655
49739
|
}, openSection === section.id && /*#__PURE__*/React__default.createElement(Motion, {
|