@thecb/components 9.1.4-beta.6 → 9.2.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 +1364 -310
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1364 -310
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/country-dropdown/CountryDropdown.js +1 -3
- package/src/components/atoms/dropdown/Dropdown.js +2 -3
- package/src/components/atoms/form-layouts/FormInput.js +0 -3
- package/src/components/atoms/form-select/FormSelect.js +1 -3
- package/src/components/atoms/layouts/Motion.styled.js +1 -1
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +1 -3
- package/src/components/molecules/address-form/AddressForm.js +1 -10
- package/src/components/molecules/payment-form-ach/PaymentFormACH.js +3 -22
- package/src/components/molecules/payment-form-ach/PaymentFormACH.state.js +2 -2
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +1 -18
- package/src/components/molecules/radio-section/RadioSection.js +1 -4
- package/src/components/molecules/radio-section/RadioSection.stories.js +3 -4
- package/src/components/molecules/radio-section/radio-button/RadioButton.js +1 -3
- package/src/components/molecules/toast-notification/ToastNotification.js +90 -0
- package/src/components/molecules/toast-notification/ToastNotification.stories.js +36 -0
- package/src/components/molecules/toast-notification/index.d.ts +1 -0
- package/src/components/molecules/toast-notification/index.js +3 -0
- package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +0 -49322
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/atoms/.DS_Store +0 -0
- package/src/components/atoms/icons/.DS_Store +0 -0
- package/src/util/formUtils.js +0 -9
package/dist/index.cjs.js
CHANGED
|
@@ -12406,7 +12406,7 @@ if (typeof window !== "undefined") {
|
|
|
12406
12406
|
var MotionWrapper = styled__default(motion.div).withConfig({
|
|
12407
12407
|
displayName: "Motionstyled__MotionWrapper",
|
|
12408
12408
|
componentId: "sc-1m6r1io-0"
|
|
12409
|
-
})(["position:", ";display:", ";box-sizing:border-box;padding:", ";border:", ";border-color:", ";border-
|
|
12409
|
+
})(["position:", ";display:", ";box-sizing:border-box;padding:", ";border:", ";border-color:", ";border-size:", ";border-style:", ";border-width:", ";border-radius:", ";background-color:", ";box-shadow:", ";min-height:", ";min-width:", ";height:", ";width:", ";text-align:", ";margin:", ";&:hover,&:focus{", ";}&:active{", ";}&:disabled{", ";}", ";"], function (_ref) {
|
|
12410
12410
|
var position = _ref.position;
|
|
12411
12411
|
return position;
|
|
12412
12412
|
}, function (_ref2) {
|
|
@@ -23768,9 +23768,7 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
23768
23768
|
_ref8$smoothScroll = _ref8.smoothScroll,
|
|
23769
23769
|
smoothScroll = _ref8$smoothScroll === void 0 ? true : _ref8$smoothScroll,
|
|
23770
23770
|
_ref8$ariaInvalid = _ref8.ariaInvalid,
|
|
23771
|
-
ariaInvalid = _ref8$ariaInvalid === void 0 ? false : _ref8$ariaInvalid
|
|
23772
|
-
_ref8$isRequired = _ref8.isRequired,
|
|
23773
|
-
isRequired = _ref8$isRequired === void 0 ? false : _ref8$isRequired;
|
|
23771
|
+
ariaInvalid = _ref8$ariaInvalid === void 0 ? false : _ref8$ariaInvalid;
|
|
23774
23772
|
|
|
23775
23773
|
var _useState = React.useState(""),
|
|
23776
23774
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -24041,7 +24039,7 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
24041
24039
|
},
|
|
24042
24040
|
padding: "12px",
|
|
24043
24041
|
placeholder: getSelection(),
|
|
24044
|
-
required: options.required
|
|
24042
|
+
required: options.required,
|
|
24045
24043
|
role: "combobox",
|
|
24046
24044
|
themeValues: themeValues,
|
|
24047
24045
|
title: hasTitles ? getSelection() : null,
|
|
@@ -24205,9 +24203,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
24205
24203
|
_ref$dataQa = _ref.dataQa,
|
|
24206
24204
|
dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa,
|
|
24207
24205
|
_ref$widthFitOptions = _ref.widthFitOptions,
|
|
24208
|
-
widthFitOptions = _ref$widthFitOptions === void 0 ? false : _ref$widthFitOptions
|
|
24209
|
-
_ref$isRequired = _ref.isRequired,
|
|
24210
|
-
isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired;
|
|
24206
|
+
widthFitOptions = _ref$widthFitOptions === void 0 ? false : _ref$widthFitOptions;
|
|
24211
24207
|
|
|
24212
24208
|
var _useState = React.useState(false),
|
|
24213
24209
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -24269,8 +24265,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
24269
24265
|
},
|
|
24270
24266
|
disabled: disabled,
|
|
24271
24267
|
autocompleteValue: autocompleteValue,
|
|
24272
|
-
smoothScroll: smoothScroll
|
|
24273
|
-
required: isRequired
|
|
24268
|
+
smoothScroll: smoothScroll
|
|
24274
24269
|
}), /*#__PURE__*/React__default.createElement(Stack, {
|
|
24275
24270
|
direction: "row",
|
|
24276
24271
|
justify: "space-between"
|
|
@@ -25040,9 +25035,7 @@ var CountryDropdown = function CountryDropdown(_ref) {
|
|
|
25040
25035
|
showErrors = _ref.showErrors,
|
|
25041
25036
|
onChange = _ref.onChange,
|
|
25042
25037
|
_ref$dataQa = _ref.dataQa,
|
|
25043
|
-
dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa
|
|
25044
|
-
_ref$isRequired = _ref.isRequired,
|
|
25045
|
-
isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired;
|
|
25038
|
+
dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa;
|
|
25046
25039
|
return /*#__PURE__*/React__default.createElement(FormSelect$1, {
|
|
25047
25040
|
options: options,
|
|
25048
25041
|
field: field,
|
|
@@ -25052,8 +25045,7 @@ var CountryDropdown = function CountryDropdown(_ref) {
|
|
|
25052
25045
|
errorMessages: errorMessages,
|
|
25053
25046
|
showErrors: showErrors,
|
|
25054
25047
|
onChange: onChange,
|
|
25055
|
-
autocompleteValue: "country-name"
|
|
25056
|
-
isRequired: isRequired
|
|
25048
|
+
autocompleteValue: "country-name"
|
|
25057
25049
|
});
|
|
25058
25050
|
};
|
|
25059
25051
|
|
|
@@ -25898,7 +25890,7 @@ var fallbackValues$k = {
|
|
|
25898
25890
|
};
|
|
25899
25891
|
|
|
25900
25892
|
var _excluded$p = ["showErrors", "themeValues"],
|
|
25901
|
-
_excluded2 = ["type", "labelTextWhenNoError", "errorMessages", "isNum", "isEmail", "helperModal", "field", "fieldActions", "showErrors", "formatter", "decorator", "themeValues", "background", "customHeight", "autocompleteValue", "extraStyles", "removeFromValue", "dataQa"
|
|
25893
|
+
_excluded2 = ["type", "labelTextWhenNoError", "errorMessages", "isNum", "isEmail", "helperModal", "field", "fieldActions", "showErrors", "formatter", "decorator", "themeValues", "background", "customHeight", "autocompleteValue", "extraStyles", "removeFromValue", "dataQa"];
|
|
25902
25894
|
var InputField = styled__default.input.withConfig({
|
|
25903
25895
|
displayName: "FormInput__InputField",
|
|
25904
25896
|
componentId: "sc-l094r1-0"
|
|
@@ -25985,8 +25977,6 @@ var FormInput = function FormInput(_ref15) {
|
|
|
25985
25977
|
removeFromValue = _ref15.removeFromValue,
|
|
25986
25978
|
_ref15$dataQa = _ref15.dataQa,
|
|
25987
25979
|
dataQa = _ref15$dataQa === void 0 ? null : _ref15$dataQa,
|
|
25988
|
-
_ref15$isRequired = _ref15.isRequired,
|
|
25989
|
-
isRequired = _ref15$isRequired === void 0 ? false : _ref15$isRequired,
|
|
25990
25980
|
props = _objectWithoutProperties(_ref15, _excluded2);
|
|
25991
25981
|
|
|
25992
25982
|
var _useState = React.useState(false),
|
|
@@ -26073,8 +26063,7 @@ var FormInput = function FormInput(_ref15) {
|
|
|
26073
26063
|
$customHeight: customHeight,
|
|
26074
26064
|
$extraStyles: extraStyles,
|
|
26075
26065
|
"data-qa": dataQa || labelTextWhenNoError,
|
|
26076
|
-
autoComplete: autocompleteValue
|
|
26077
|
-
required: isRequired
|
|
26066
|
+
autoComplete: autocompleteValue
|
|
26078
26067
|
}, props)) : /*#__PURE__*/React__default.createElement(InputField, _extends({
|
|
26079
26068
|
"aria-labelledby": createIdFromString(labelTextWhenNoError),
|
|
26080
26069
|
"aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
|
|
@@ -26093,8 +26082,7 @@ var FormInput = function FormInput(_ref15) {
|
|
|
26093
26082
|
$customHeight: customHeight,
|
|
26094
26083
|
$extraStyles: extraStyles,
|
|
26095
26084
|
"data-qa": dataQa || labelTextWhenNoError,
|
|
26096
|
-
autoComplete: autocompleteValue
|
|
26097
|
-
required: isRequired
|
|
26085
|
+
autoComplete: autocompleteValue
|
|
26098
26086
|
}, props))), /*#__PURE__*/React__default.createElement(Stack, {
|
|
26099
26087
|
direction: "row",
|
|
26100
26088
|
justify: "space-between",
|
|
@@ -27276,9 +27264,7 @@ var RadioButton$1 = function RadioButton(_ref2) {
|
|
|
27276
27264
|
_ref2$ariaLabelledBy = _ref2.ariaLabelledBy,
|
|
27277
27265
|
ariaLabelledBy = _ref2$ariaLabelledBy === void 0 ? "" : _ref2$ariaLabelledBy,
|
|
27278
27266
|
_ref2$ariaLabel = _ref2.ariaLabel,
|
|
27279
|
-
ariaLabel = _ref2$ariaLabel === void 0 ? null : _ref2$ariaLabel
|
|
27280
|
-
_ref2$required = _ref2.required,
|
|
27281
|
-
required = _ref2$required === void 0 ? false : _ref2$required;
|
|
27267
|
+
ariaLabel = _ref2$ariaLabel === void 0 ? null : _ref2$ariaLabel;
|
|
27282
27268
|
var buttonBorder = {
|
|
27283
27269
|
onFocused: {
|
|
27284
27270
|
borderColor: themeValues.activeColor,
|
|
@@ -27338,8 +27324,7 @@ var RadioButton$1 = function RadioButton(_ref2) {
|
|
|
27338
27324
|
disabled: disabled,
|
|
27339
27325
|
onClick: toggleRadio,
|
|
27340
27326
|
"aria-describedby": ariaDescribedBy,
|
|
27341
|
-
tabIndex: "-1"
|
|
27342
|
-
required: required
|
|
27327
|
+
tabIndex: "-1"
|
|
27343
27328
|
}, extraProps)), /*#__PURE__*/React__default.createElement(Motion, {
|
|
27344
27329
|
borderWidth: "1px",
|
|
27345
27330
|
borderStyle: "solid",
|
|
@@ -38029,9 +38014,7 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
|
|
|
38029
38014
|
field = _ref.field,
|
|
38030
38015
|
fieldActions = _ref.fieldActions,
|
|
38031
38016
|
showErrors = _ref.showErrors,
|
|
38032
|
-
countryCode = _ref.countryCode
|
|
38033
|
-
_ref$isRequired = _ref.isRequired,
|
|
38034
|
-
isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired;
|
|
38017
|
+
countryCode = _ref.countryCode;
|
|
38035
38018
|
var placeholder = countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
|
|
38036
38019
|
var options = [placeholder].concat(_toConsumableArray(getOptions(countryCode)));
|
|
38037
38020
|
return /*#__PURE__*/React__default.createElement(FormSelect$1, {
|
|
@@ -38041,8 +38024,7 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
|
|
|
38041
38024
|
labelTextWhenNoError: labelTextWhenNoError,
|
|
38042
38025
|
errorMessages: errorMessages,
|
|
38043
38026
|
showErrors: showErrors,
|
|
38044
|
-
autocompleteValue: "address-level1"
|
|
38045
|
-
isRequired: isRequired
|
|
38027
|
+
autocompleteValue: "address-level1"
|
|
38046
38028
|
});
|
|
38047
38029
|
};
|
|
38048
38030
|
|
|
@@ -38666,52 +38648,44 @@ var TableHeading_styled = styled__default.th.withConfig({
|
|
|
38666
38648
|
return extraStyles;
|
|
38667
38649
|
});
|
|
38668
38650
|
|
|
38669
|
-
const validatorToPredicate =
|
|
38670
|
-
|
|
38671
|
-
|
|
38672
|
-
|
|
38651
|
+
const validatorToPredicate = (validatorFn, emptyCase) => (
|
|
38652
|
+
value,
|
|
38653
|
+
...rest
|
|
38654
|
+
) => (value === "" ? emptyCase : validatorFn(value, ...rest));
|
|
38673
38655
|
|
|
38674
38656
|
var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
38675
38657
|
|
|
38676
|
-
function getDefaultExportFromCjs (x) {
|
|
38677
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
38678
|
-
}
|
|
38679
|
-
|
|
38680
38658
|
var dayjs_min = {exports: {}};
|
|
38681
38659
|
|
|
38682
38660
|
(function (module, exports) {
|
|
38683
|
-
|
|
38684
|
-
}
|
|
38661
|
+
!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}));
|
|
38662
|
+
}(dayjs_min));
|
|
38685
38663
|
|
|
38686
|
-
var
|
|
38687
|
-
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
38664
|
+
var dayjs = dayjs_min.exports;
|
|
38688
38665
|
|
|
38689
38666
|
var customParseFormat$1 = {exports: {}};
|
|
38690
38667
|
|
|
38691
38668
|
(function (module, exports) {
|
|
38692
|
-
|
|
38693
|
-
}
|
|
38669
|
+
!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);};}}));
|
|
38670
|
+
}(customParseFormat$1));
|
|
38694
38671
|
|
|
38695
|
-
var
|
|
38696
|
-
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
38672
|
+
var customParseFormat = customParseFormat$1.exports;
|
|
38697
38673
|
|
|
38698
38674
|
var isSameOrBefore$1 = {exports: {}};
|
|
38699
38675
|
|
|
38700
38676
|
(function (module, exports) {
|
|
38701
|
-
|
|
38702
|
-
}
|
|
38677
|
+
!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)};}}));
|
|
38678
|
+
}(isSameOrBefore$1));
|
|
38703
38679
|
|
|
38704
|
-
var
|
|
38705
|
-
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);
|
|
38680
|
+
var isSameOrBefore = isSameOrBefore$1.exports;
|
|
38706
38681
|
|
|
38707
38682
|
var isSameOrAfter$1 = {exports: {}};
|
|
38708
38683
|
|
|
38709
38684
|
(function (module, exports) {
|
|
38710
|
-
|
|
38711
|
-
}
|
|
38685
|
+
!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)};}}));
|
|
38686
|
+
}(isSameOrAfter$1));
|
|
38712
38687
|
|
|
38713
|
-
var
|
|
38714
|
-
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);
|
|
38688
|
+
var isSameOrAfter = isSameOrAfter$1.exports;
|
|
38715
38689
|
|
|
38716
38690
|
/* eslint-disable no-unused-vars */
|
|
38717
38691
|
|
|
@@ -38727,24 +38701,24 @@ dayjs.extend(isSameOrAfter);
|
|
|
38727
38701
|
|
|
38728
38702
|
let validatorFns = {};
|
|
38729
38703
|
|
|
38730
|
-
const INCLUDED_IN =
|
|
38731
|
-
const INCLUDED_IN_ERROR =
|
|
38704
|
+
const INCLUDED_IN = "validator/INCLUDED_IN";
|
|
38705
|
+
const INCLUDED_IN_ERROR = "error/INCLUDED_IN";
|
|
38732
38706
|
const includedIn = createValidator(INCLUDED_IN, INCLUDED_IN_ERROR);
|
|
38733
38707
|
validatorFns[INCLUDED_IN] = (value, args, form) =>
|
|
38734
38708
|
Array.isArray(args[0]) ? args[0].includes(value) : args[0] === value;
|
|
38735
38709
|
|
|
38736
|
-
const REQUIRED =
|
|
38737
|
-
const REQUIRED_ERROR =
|
|
38710
|
+
const REQUIRED = "validator/REQUIRED";
|
|
38711
|
+
const REQUIRED_ERROR = "error/REQUIRED";
|
|
38738
38712
|
const required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
38739
|
-
validatorFns[REQUIRED] = (value, args, form) => value !==
|
|
38713
|
+
validatorFns[REQUIRED] = (value, args, form) => value !== "";
|
|
38740
38714
|
|
|
38741
|
-
const ONLY_INTEGERS =
|
|
38742
|
-
const ONLY_INTEGERS_ERROR =
|
|
38715
|
+
const ONLY_INTEGERS = "validator/ONLY_INTEGERS";
|
|
38716
|
+
const ONLY_INTEGERS_ERROR = "error/ONLY_INTEGERS";
|
|
38743
38717
|
const onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
38744
38718
|
validatorFns[ONLY_INTEGERS] = (value, args, form) => /^(-?\d+)?$/.test(value);
|
|
38745
38719
|
|
|
38746
|
-
const ONLY_NATURALS =
|
|
38747
|
-
const ONLY_NATURALS_ERROR =
|
|
38720
|
+
const ONLY_NATURALS = "validator/ONLY_NATURALS";
|
|
38721
|
+
const ONLY_NATURALS_ERROR = "error/ONLY_NATURALS";
|
|
38748
38722
|
const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
38749
38723
|
validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
|
|
38750
38724
|
|
|
@@ -38757,8 +38731,8 @@ not tested as validation function
|
|
|
38757
38731
|
to validate exp date instead use combo of:
|
|
38758
38732
|
required(), hasLength(), isValidMonth(), dateAfterToday()
|
|
38759
38733
|
*/
|
|
38760
|
-
const ONLY_EXPIRATION_DATE =
|
|
38761
|
-
const ONLY_EXPIRATION_DATE_ERROR =
|
|
38734
|
+
const ONLY_EXPIRATION_DATE = "validator/ONLY_EXPIRATION_DATE";
|
|
38735
|
+
const ONLY_EXPIRATION_DATE_ERROR = "error/ONLY_EXPIRATION_DATE";
|
|
38762
38736
|
const onlyExpirationDate = createValidator(
|
|
38763
38737
|
ONLY_EXPIRATION_DATE,
|
|
38764
38738
|
ONLY_EXPIRATION_DATE_ERROR
|
|
@@ -38766,63 +38740,64 @@ const onlyExpirationDate = createValidator(
|
|
|
38766
38740
|
validatorFns[ONLY_EXPIRATION_DATE] = (value, args, form) =>
|
|
38767
38741
|
/^(\d?\d?\/?\d?\d?)?$/.test(value);
|
|
38768
38742
|
|
|
38769
|
-
const NUMBER_LESS_THAN =
|
|
38770
|
-
const NUMBER_LESS_THAN_ERROR =
|
|
38743
|
+
const NUMBER_LESS_THAN = "validator/NUMBER_LESS_THAN";
|
|
38744
|
+
const NUMBER_LESS_THAN_ERROR = "error/NUMBER_LESS_THAN";
|
|
38771
38745
|
const numberLessThan = createValidator(
|
|
38772
38746
|
NUMBER_LESS_THAN,
|
|
38773
38747
|
NUMBER_LESS_THAN_ERROR
|
|
38774
38748
|
);
|
|
38775
38749
|
validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
38776
|
-
if (value ===
|
|
38750
|
+
if (value === "") {
|
|
38777
38751
|
return true;
|
|
38778
38752
|
}
|
|
38779
38753
|
return Number(value) < args[0];
|
|
38780
38754
|
};
|
|
38781
38755
|
|
|
38782
|
-
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
38756
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
38757
|
+
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
38783
38758
|
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
38784
|
-
|
|
38759
|
+
"error/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
38785
38760
|
const numberLessThanOrEqualTo = createValidator(
|
|
38786
38761
|
NUMBER_LESS_THAN_OR_EQUAL_TO,
|
|
38787
38762
|
NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR
|
|
38788
38763
|
);
|
|
38789
38764
|
validatorFns[NUMBER_LESS_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38790
|
-
if (value ===
|
|
38765
|
+
if (value === "") {
|
|
38791
38766
|
return true;
|
|
38792
38767
|
}
|
|
38793
38768
|
return Number(value) <= args[0];
|
|
38794
38769
|
};
|
|
38795
38770
|
|
|
38796
|
-
const NUMBER_GREATER_THAN =
|
|
38797
|
-
const NUMBER_GREATER_THAN_ERROR =
|
|
38771
|
+
const NUMBER_GREATER_THAN = "validator/NUMBER_GREATER_THAN";
|
|
38772
|
+
const NUMBER_GREATER_THAN_ERROR = "error/NUMBER_GREATER_THAN";
|
|
38798
38773
|
const numberGreaterThan = createValidator(
|
|
38799
38774
|
NUMBER_GREATER_THAN,
|
|
38800
38775
|
NUMBER_GREATER_THAN_ERROR
|
|
38801
38776
|
);
|
|
38802
38777
|
validatorFns[NUMBER_GREATER_THAN] = (value, args, form) => {
|
|
38803
|
-
if (value ===
|
|
38778
|
+
if (value === "") {
|
|
38804
38779
|
return true;
|
|
38805
38780
|
}
|
|
38806
38781
|
return Number(value) > args[0];
|
|
38807
38782
|
};
|
|
38808
38783
|
|
|
38809
38784
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO =
|
|
38810
|
-
|
|
38785
|
+
"validator/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
38811
38786
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR =
|
|
38812
|
-
|
|
38787
|
+
"error/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
38813
38788
|
const numberGreaterThanOrEqualTo = createValidator(
|
|
38814
38789
|
NUMBER_GREATER_THAN_OR_EQUAL_TO,
|
|
38815
38790
|
NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR
|
|
38816
38791
|
);
|
|
38817
38792
|
validatorFns[NUMBER_GREATER_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38818
|
-
if (value ===
|
|
38793
|
+
if (value === "") {
|
|
38819
38794
|
return true;
|
|
38820
38795
|
}
|
|
38821
38796
|
return Number(value) >= args[0];
|
|
38822
38797
|
};
|
|
38823
38798
|
|
|
38824
|
-
const MATCHES_FIELD =
|
|
38825
|
-
const MATCHES_FIELD_ERROR$1 =
|
|
38799
|
+
const MATCHES_FIELD = "validator/MATCHES_FIELD";
|
|
38800
|
+
const MATCHES_FIELD_ERROR$1 = "error/MATCHES_FIELD";
|
|
38826
38801
|
const matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
|
|
38827
38802
|
validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
38828
38803
|
const dependentField = form[args[0]];
|
|
@@ -38835,7 +38810,7 @@ validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
|
38835
38810
|
return value === dependentFieldValue;
|
|
38836
38811
|
};
|
|
38837
38812
|
|
|
38838
|
-
const validateWhenErrorMessage =
|
|
38813
|
+
const validateWhenErrorMessage = type =>
|
|
38839
38814
|
`${type} was passed to validateWhen, but that validator type does not exist.
|
|
38840
38815
|
Please check that you are only calling validator creator functions exported from
|
|
38841
38816
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -38843,21 +38818,25 @@ const validateWhenErrorMessage = (type) =>
|
|
|
38843
38818
|
createFormState). Also make sure you aren't passing validateWhen() to validateWhen
|
|
38844
38819
|
as the primary validator.`;
|
|
38845
38820
|
|
|
38846
|
-
const VALIDATE_WHEN =
|
|
38847
|
-
const VALIDATE_WHEN_ERROR =
|
|
38848
|
-
const validateWhen = (
|
|
38821
|
+
const VALIDATE_WHEN = "validator/VALIDATE_WHEN";
|
|
38822
|
+
const VALIDATE_WHEN_ERROR = "error/VALIDATE_WHEN";
|
|
38823
|
+
const validateWhen = (
|
|
38824
|
+
dependentValidator,
|
|
38825
|
+
primaryValidator,
|
|
38826
|
+
optionalFieldName
|
|
38827
|
+
) => ({
|
|
38849
38828
|
type: VALIDATE_WHEN,
|
|
38850
38829
|
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
38851
|
-
error: dependentValidator.error
|
|
38830
|
+
error: dependentValidator.error
|
|
38852
38831
|
});
|
|
38853
38832
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
38854
38833
|
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
38855
38834
|
const [dependentValidator, primaryValidator, optionalFieldName] = args;
|
|
38856
|
-
const dependsOnOtherField = typeof optionalFieldName ===
|
|
38835
|
+
const dependsOnOtherField = typeof optionalFieldName === "string";
|
|
38857
38836
|
|
|
38858
38837
|
if (
|
|
38859
38838
|
primaryValidator.type === undefined ||
|
|
38860
|
-
typeof validatorFns[primaryValidator.type] !==
|
|
38839
|
+
typeof validatorFns[primaryValidator.type] !== "function"
|
|
38861
38840
|
) {
|
|
38862
38841
|
throw new Error(validateWhenErrorMessage(primaryValidator.type));
|
|
38863
38842
|
}
|
|
@@ -38881,22 +38860,26 @@ validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
|
38881
38860
|
);
|
|
38882
38861
|
|
|
38883
38862
|
return primaryPredicatePassed
|
|
38884
|
-
? validatorFns[dependentValidator.type](
|
|
38863
|
+
? validatorFns[dependentValidator.type](
|
|
38864
|
+
value,
|
|
38865
|
+
dependentValidator.args,
|
|
38866
|
+
form
|
|
38867
|
+
)
|
|
38885
38868
|
: true;
|
|
38886
38869
|
};
|
|
38887
38870
|
|
|
38888
|
-
const validateSumErrorMessage =
|
|
38871
|
+
const validateSumErrorMessage = type =>
|
|
38889
38872
|
`${type} was passed to validateSum, but that validator type does not exist.
|
|
38890
38873
|
Please check that you are only calling validator creator functions exported from
|
|
38891
38874
|
redux-freeform in your form config and that you didn't forget to
|
|
38892
38875
|
invoke the validator creator (you cannot pass the functions themselves to
|
|
38893
38876
|
createFormState).`;
|
|
38894
|
-
const VALIDATE_SUM =
|
|
38895
|
-
const VALIDATE_SUM_ERROR =
|
|
38877
|
+
const VALIDATE_SUM = "validator/VALIDATE_SUM";
|
|
38878
|
+
const VALIDATE_SUM_ERROR = "error/VALIDATE_SUM";
|
|
38896
38879
|
const validateSum = (validator, fieldNamesArray) => ({
|
|
38897
38880
|
type: VALIDATE_SUM,
|
|
38898
38881
|
args: [validator, fieldNamesArray],
|
|
38899
|
-
error: validator.error
|
|
38882
|
+
error: validator.error
|
|
38900
38883
|
});
|
|
38901
38884
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
38902
38885
|
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
@@ -38904,7 +38887,7 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38904
38887
|
|
|
38905
38888
|
if (
|
|
38906
38889
|
validator.type === undefined ||
|
|
38907
|
-
typeof validatorFns[validator.type] !==
|
|
38890
|
+
typeof validatorFns[validator.type] !== "function"
|
|
38908
38891
|
) {
|
|
38909
38892
|
throw new Error(validateSumErrorMessage(validator.type));
|
|
38910
38893
|
}
|
|
@@ -38925,35 +38908,37 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38925
38908
|
return validatorFns[validator.type](sum, validator.args, form);
|
|
38926
38909
|
};
|
|
38927
38910
|
|
|
38928
|
-
const HAS_LENGTH =
|
|
38929
|
-
const HAS_LENGTH_ERROR =
|
|
38911
|
+
const HAS_LENGTH = "validator/HAS_LENGTH";
|
|
38912
|
+
const HAS_LENGTH_ERROR = "error/HAS_LENGTH";
|
|
38930
38913
|
const hasLength = createValidator(HAS_LENGTH, HAS_LENGTH_ERROR);
|
|
38931
38914
|
validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
38932
|
-
if (value ===
|
|
38915
|
+
if (value === "") {
|
|
38933
38916
|
return true;
|
|
38934
38917
|
}
|
|
38935
38918
|
const min = args[0];
|
|
38936
38919
|
const max = args[1];
|
|
38937
38920
|
if (max == undefined || min == undefined) {
|
|
38938
38921
|
throw new Error(
|
|
38939
|
-
|
|
38922
|
+
"Max and min need to be defined for hasLength, both or one of them is undefined"
|
|
38940
38923
|
);
|
|
38941
38924
|
}
|
|
38942
38925
|
if (max < min) {
|
|
38943
|
-
throw new Error(
|
|
38926
|
+
throw new Error(
|
|
38927
|
+
"hasLength validator was passed a min greater than the max"
|
|
38928
|
+
);
|
|
38944
38929
|
}
|
|
38945
38930
|
const valueLength = value.length;
|
|
38946
38931
|
return max >= valueLength && valueLength >= min;
|
|
38947
38932
|
};
|
|
38948
38933
|
|
|
38949
|
-
const DATE_BEFORE_TODAY =
|
|
38950
|
-
const DATE_BEFORE_TODAY_ERROR =
|
|
38934
|
+
const DATE_BEFORE_TODAY = "validator/DATE_BEFORE_TODAY";
|
|
38935
|
+
const DATE_BEFORE_TODAY_ERROR = "error/DATE_BEFORE_TODAY";
|
|
38951
38936
|
const dateBeforeToday = createValidator(
|
|
38952
38937
|
DATE_BEFORE_TODAY,
|
|
38953
38938
|
DATE_BEFORE_TODAY_ERROR
|
|
38954
38939
|
);
|
|
38955
38940
|
validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
38956
|
-
if (value ===
|
|
38941
|
+
if (value === "") {
|
|
38957
38942
|
return true;
|
|
38958
38943
|
}
|
|
38959
38944
|
const dateFormat = args[0];
|
|
@@ -38962,7 +38947,7 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
38962
38947
|
|
|
38963
38948
|
if (dateFormat == undefined || unit == undefined) {
|
|
38964
38949
|
throw new Error(
|
|
38965
|
-
|
|
38950
|
+
"Date format and unit need to be defined for dateBeforeToday, one or both are undefined"
|
|
38966
38951
|
);
|
|
38967
38952
|
}
|
|
38968
38953
|
const now = dayjs();
|
|
@@ -38974,14 +38959,14 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
38974
38959
|
return dateValue.isBefore(now, unit);
|
|
38975
38960
|
};
|
|
38976
38961
|
|
|
38977
|
-
const DATE_AFTER_TODAY =
|
|
38978
|
-
const DATE_AFTER_TODAY_ERROR =
|
|
38962
|
+
const DATE_AFTER_TODAY = "validator/DATE_AFTER_TODAY";
|
|
38963
|
+
const DATE_AFTER_TODAY_ERROR = "error/DATE_AFTER_TODAY";
|
|
38979
38964
|
const dateAfterToday = createValidator(
|
|
38980
38965
|
DATE_AFTER_TODAY,
|
|
38981
38966
|
DATE_AFTER_TODAY_ERROR
|
|
38982
38967
|
);
|
|
38983
38968
|
validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
38984
|
-
if (value ===
|
|
38969
|
+
if (value === "") {
|
|
38985
38970
|
return true;
|
|
38986
38971
|
}
|
|
38987
38972
|
const dateFormat = args[0];
|
|
@@ -38990,7 +38975,7 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
38990
38975
|
|
|
38991
38976
|
if (dateFormat == undefined || unit == undefined) {
|
|
38992
38977
|
throw new Error(
|
|
38993
|
-
|
|
38978
|
+
"Date format and unit need to be defined for dateAfterToday, one or both are undefined"
|
|
38994
38979
|
);
|
|
38995
38980
|
}
|
|
38996
38981
|
const now = dayjs();
|
|
@@ -39002,11 +38987,14 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
39002
38987
|
return dateValue.isAfter(now, unit);
|
|
39003
38988
|
};
|
|
39004
38989
|
|
|
39005
|
-
const IS_VALID_MONTH =
|
|
39006
|
-
const IS_VALID_MONTH_ERROR =
|
|
39007
|
-
const isValidMonth = createValidator(
|
|
38990
|
+
const IS_VALID_MONTH = "validator/IS_VALID_MONTH";
|
|
38991
|
+
const IS_VALID_MONTH_ERROR = "error/IS_VALID_MONTH";
|
|
38992
|
+
const isValidMonth = createValidator(
|
|
38993
|
+
IS_VALID_MONTH,
|
|
38994
|
+
IS_VALID_MONTH_ERROR
|
|
38995
|
+
);
|
|
39008
38996
|
validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
39009
|
-
if (value ===
|
|
38997
|
+
if (value === "") {
|
|
39010
38998
|
return true;
|
|
39011
38999
|
}
|
|
39012
39000
|
// Function takes one argument representing the character position
|
|
@@ -39016,43 +39004,43 @@ validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
|
39016
39004
|
// Only works with two digit months (01, 02, 03, etc)
|
|
39017
39005
|
const monthStartPosition = parseInt(args[0]);
|
|
39018
39006
|
const monthEndPosition = monthStartPosition + 2;
|
|
39019
|
-
if (
|
|
39020
|
-
throw new Error(
|
|
39007
|
+
if (monthStartPosition === NaN) {
|
|
39008
|
+
throw new Error("Month start position has to be a valid integer string");
|
|
39021
39009
|
}
|
|
39022
39010
|
const month = parseInt(value.slice(monthStartPosition, monthEndPosition));
|
|
39023
|
-
if (
|
|
39011
|
+
if (month === NaN) {
|
|
39024
39012
|
return false;
|
|
39025
39013
|
}
|
|
39026
39014
|
return month >= 1 && month <= 12;
|
|
39027
39015
|
};
|
|
39028
39016
|
|
|
39029
|
-
const MATCHES_REGEX =
|
|
39030
|
-
const MATCHES_REGEX_ERROR =
|
|
39017
|
+
const MATCHES_REGEX = "validator/MATCHES_REGEX";
|
|
39018
|
+
const MATCHES_REGEX_ERROR = "error/MATCHES_REGEX";
|
|
39031
39019
|
const matchesRegex = createValidator(MATCHES_REGEX, MATCHES_REGEX_ERROR);
|
|
39032
39020
|
validatorFns[MATCHES_REGEX] = (value, args, form) => {
|
|
39033
|
-
if (value ===
|
|
39021
|
+
if (value === "") {
|
|
39034
39022
|
return true;
|
|
39035
39023
|
}
|
|
39036
39024
|
return new RegExp(args[0]).test(value); // new RexExp never throws an error, no matter the input
|
|
39037
39025
|
};
|
|
39038
39026
|
|
|
39039
39027
|
// based on http://www.brainjar.com/js/validation/
|
|
39040
|
-
const IS_ROUTING_NUMBER =
|
|
39041
|
-
const IS_ROUTING_NUMBER_ERROR =
|
|
39028
|
+
const IS_ROUTING_NUMBER = "validator/IS_ROUTING_NUMBER";
|
|
39029
|
+
const IS_ROUTING_NUMBER_ERROR = "error/IS_ROUTING_NUMBER";
|
|
39042
39030
|
const isRoutingNumber = createValidator(
|
|
39043
39031
|
IS_ROUTING_NUMBER,
|
|
39044
39032
|
IS_ROUTING_NUMBER_ERROR
|
|
39045
39033
|
);
|
|
39046
39034
|
validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
39047
|
-
if (value ===
|
|
39035
|
+
if (value === "") {
|
|
39048
39036
|
return true;
|
|
39049
39037
|
}
|
|
39050
39038
|
if (value.length != 9) {
|
|
39051
39039
|
return false;
|
|
39052
39040
|
}
|
|
39053
39041
|
const sum = value
|
|
39054
|
-
.split(
|
|
39055
|
-
.map(
|
|
39042
|
+
.split("")
|
|
39043
|
+
.map(ch => parseInt(ch))
|
|
39056
39044
|
.reduce((acc, cur, idx) => {
|
|
39057
39045
|
switch (idx % 3) {
|
|
39058
39046
|
case 0:
|
|
@@ -39066,69 +39054,69 @@ validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
|
39066
39054
|
return sum != 0 && sum % 10 == 0;
|
|
39067
39055
|
};
|
|
39068
39056
|
|
|
39069
|
-
const HAS_NUMBER =
|
|
39070
|
-
const HAS_NUMBER_ERROR$1 =
|
|
39057
|
+
const HAS_NUMBER = "validator/HAS_NUMBER";
|
|
39058
|
+
const HAS_NUMBER_ERROR$1 = "error/HAS_NUMBER";
|
|
39071
39059
|
const hasNumber = createValidator(HAS_NUMBER, HAS_NUMBER_ERROR$1);
|
|
39072
39060
|
validatorFns[HAS_NUMBER] = (value, args, form) => {
|
|
39073
|
-
if (value ===
|
|
39061
|
+
if (value === "") {
|
|
39074
39062
|
return true;
|
|
39075
39063
|
}
|
|
39076
39064
|
return new RegExp(/[0-9]/).test(value);
|
|
39077
39065
|
};
|
|
39078
39066
|
|
|
39079
|
-
const HAS_LOWERCASE_LETTER =
|
|
39080
|
-
const HAS_LOWERCASE_LETTER_ERROR$1 =
|
|
39067
|
+
const HAS_LOWERCASE_LETTER = "validator/HAS_LOWERCASE_LETTER";
|
|
39068
|
+
const HAS_LOWERCASE_LETTER_ERROR$1 = "error/HAS_LOWERCASE_LETTER";
|
|
39081
39069
|
const hasLowercaseLetter = createValidator(
|
|
39082
39070
|
HAS_LOWERCASE_LETTER,
|
|
39083
39071
|
HAS_LOWERCASE_LETTER_ERROR$1
|
|
39084
39072
|
);
|
|
39085
39073
|
validatorFns[HAS_LOWERCASE_LETTER] = (value, args, form) => {
|
|
39086
|
-
if (value ===
|
|
39074
|
+
if (value === "") {
|
|
39087
39075
|
return true;
|
|
39088
39076
|
}
|
|
39089
39077
|
return new RegExp(/[a-z]/).test(value);
|
|
39090
39078
|
};
|
|
39091
39079
|
|
|
39092
|
-
const HAS_UPPERCASE_LETTER =
|
|
39093
|
-
const HAS_UPPERCASE_LETTER_ERROR$1 =
|
|
39080
|
+
const HAS_UPPERCASE_LETTER = "validator/HAS_UPPERCASE_LETTER";
|
|
39081
|
+
const HAS_UPPERCASE_LETTER_ERROR$1 = "error/HAS_UPPERCASE_LETTER";
|
|
39094
39082
|
const hasUppercaseLetter = createValidator(
|
|
39095
39083
|
HAS_UPPERCASE_LETTER,
|
|
39096
39084
|
HAS_UPPERCASE_LETTER_ERROR$1
|
|
39097
39085
|
);
|
|
39098
39086
|
validatorFns[HAS_UPPERCASE_LETTER] = (value, args, form) => {
|
|
39099
|
-
if (value ===
|
|
39087
|
+
if (value === "") {
|
|
39100
39088
|
return true;
|
|
39101
39089
|
}
|
|
39102
39090
|
return new RegExp(/[A-Z]/).test(value);
|
|
39103
39091
|
};
|
|
39104
39092
|
|
|
39105
|
-
const HAS_SPECIAL_CHARACTER =
|
|
39106
|
-
const HAS_SPECIAL_CHARACTER_ERROR$1 =
|
|
39093
|
+
const HAS_SPECIAL_CHARACTER = "validator/HAS_SPECIAL_CHARACTER";
|
|
39094
|
+
const HAS_SPECIAL_CHARACTER_ERROR$1 = "error/HAS_SPECIAL_CHARACTER";
|
|
39107
39095
|
const hasSpecialCharacter = createValidator(
|
|
39108
39096
|
HAS_SPECIAL_CHARACTER,
|
|
39109
39097
|
HAS_SPECIAL_CHARACTER_ERROR$1
|
|
39110
39098
|
);
|
|
39111
39099
|
validatorFns[HAS_SPECIAL_CHARACTER] = (value, args, form) => {
|
|
39112
|
-
if (value ===
|
|
39100
|
+
if (value === "") {
|
|
39113
39101
|
return true;
|
|
39114
39102
|
}
|
|
39115
39103
|
return new RegExp(/[!@#$%^&*.?]/).test(value);
|
|
39116
39104
|
};
|
|
39117
39105
|
|
|
39118
|
-
const IS_PROBABLY_EMAIL =
|
|
39119
|
-
const IS_PROBABLY_EMAIL_ERROR =
|
|
39106
|
+
const IS_PROBABLY_EMAIL = "validator/IS_PROBABLY_EMAIL";
|
|
39107
|
+
const IS_PROBABLY_EMAIL_ERROR = "error/IS_PROBABLY_EMAIL";
|
|
39120
39108
|
const isProbablyEmail = createValidator(
|
|
39121
39109
|
IS_PROBABLY_EMAIL,
|
|
39122
39110
|
IS_PROBABLY_EMAIL_ERROR
|
|
39123
39111
|
);
|
|
39124
39112
|
validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
39125
|
-
if (value ===
|
|
39113
|
+
if (value === "") {
|
|
39126
39114
|
return true;
|
|
39127
39115
|
}
|
|
39128
39116
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
39129
39117
|
};
|
|
39130
39118
|
|
|
39131
|
-
const runValidatorErrorMessage =
|
|
39119
|
+
const runValidatorErrorMessage = type =>
|
|
39132
39120
|
`${type} was passed to runValidator, but that validator type does not exist.
|
|
39133
39121
|
Please check that you are only calling validator creator functions exported from
|
|
39134
39122
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -39143,53 +39131,1165 @@ const runValidator = (validator, value, form) => {
|
|
|
39143
39131
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
39144
39132
|
};
|
|
39145
39133
|
|
|
39146
|
-
const
|
|
39134
|
+
const _computeErrors = (fieldName, form, validators) => {
|
|
39147
39135
|
return validators
|
|
39148
|
-
.map(
|
|
39149
|
-
.filter(
|
|
39136
|
+
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
39137
|
+
.filter(x => x !== null);
|
|
39150
39138
|
};
|
|
39151
39139
|
|
|
39152
39140
|
const computeConstraints = (fieldName, form) => {
|
|
39153
39141
|
const constraints = form[fieldName].constraints;
|
|
39154
|
-
return
|
|
39142
|
+
return _computeErrors(fieldName, form, constraints);
|
|
39155
39143
|
};
|
|
39156
39144
|
|
|
39157
39145
|
const computeErrors = (fieldName, form) => {
|
|
39158
39146
|
const validators = form[fieldName].validators;
|
|
39159
|
-
return
|
|
39147
|
+
return _computeErrors(fieldName, form, validators);
|
|
39148
|
+
};
|
|
39149
|
+
|
|
39150
|
+
var obj;
|
|
39151
|
+
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : ( obj = {}, obj["immer-nothing"] = true, obj );
|
|
39152
|
+
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
39153
|
+
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-state") : "__$immer_state";
|
|
39154
|
+
function isDraft(value) {
|
|
39155
|
+
return !!value && !!value[DRAFT_STATE];
|
|
39156
|
+
}
|
|
39157
|
+
function isDraftable(value) {
|
|
39158
|
+
if (!value) { return false; }
|
|
39159
|
+
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
39160
|
+
}
|
|
39161
|
+
function isPlainObject(value) {
|
|
39162
|
+
if (!value || typeof value !== "object") { return false; }
|
|
39163
|
+
if (Array.isArray(value)) { return true; }
|
|
39164
|
+
var proto = Object.getPrototypeOf(value);
|
|
39165
|
+
return !proto || proto === Object.prototype;
|
|
39166
|
+
}
|
|
39167
|
+
var assign = Object.assign || function assign(target, value) {
|
|
39168
|
+
for (var key in value) {
|
|
39169
|
+
if (has$1(value, key)) {
|
|
39170
|
+
target[key] = value[key];
|
|
39171
|
+
}
|
|
39172
|
+
}
|
|
39173
|
+
|
|
39174
|
+
return target;
|
|
39175
|
+
};
|
|
39176
|
+
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;
|
|
39177
|
+
function shallowCopy(base, invokeGetters) {
|
|
39178
|
+
if ( invokeGetters === void 0 ) invokeGetters = false;
|
|
39179
|
+
|
|
39180
|
+
if (Array.isArray(base)) { return base.slice(); }
|
|
39181
|
+
var clone = Object.create(Object.getPrototypeOf(base));
|
|
39182
|
+
ownKeys$2(base).forEach(function (key) {
|
|
39183
|
+
if (key === DRAFT_STATE) {
|
|
39184
|
+
return; // Never copy over draft state.
|
|
39185
|
+
}
|
|
39186
|
+
|
|
39187
|
+
var desc = Object.getOwnPropertyDescriptor(base, key);
|
|
39188
|
+
var value = desc.value;
|
|
39189
|
+
|
|
39190
|
+
if (desc.get) {
|
|
39191
|
+
if (!invokeGetters) {
|
|
39192
|
+
throw new Error("Immer drafts cannot have computed properties");
|
|
39193
|
+
}
|
|
39194
|
+
|
|
39195
|
+
value = desc.get.call(base);
|
|
39196
|
+
}
|
|
39197
|
+
|
|
39198
|
+
if (desc.enumerable) {
|
|
39199
|
+
clone[key] = value;
|
|
39200
|
+
} else {
|
|
39201
|
+
Object.defineProperty(clone, key, {
|
|
39202
|
+
value: value,
|
|
39203
|
+
writable: true,
|
|
39204
|
+
configurable: true
|
|
39205
|
+
});
|
|
39206
|
+
}
|
|
39207
|
+
});
|
|
39208
|
+
return clone;
|
|
39209
|
+
}
|
|
39210
|
+
function each(value, cb) {
|
|
39211
|
+
if (Array.isArray(value)) {
|
|
39212
|
+
for (var i = 0; i < value.length; i++) { cb(i, value[i], value); }
|
|
39213
|
+
} else {
|
|
39214
|
+
ownKeys$2(value).forEach(function (key) { return cb(key, value[key], value); });
|
|
39215
|
+
}
|
|
39216
|
+
}
|
|
39217
|
+
function isEnumerable(base, prop) {
|
|
39218
|
+
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
39219
|
+
return !!desc && desc.enumerable;
|
|
39220
|
+
}
|
|
39221
|
+
function has$1(thing, prop) {
|
|
39222
|
+
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
39223
|
+
}
|
|
39224
|
+
function is(x, y) {
|
|
39225
|
+
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
39226
|
+
if (x === y) {
|
|
39227
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
39228
|
+
} else {
|
|
39229
|
+
return x !== x && y !== y;
|
|
39230
|
+
}
|
|
39231
|
+
}
|
|
39232
|
+
function clone(obj) {
|
|
39233
|
+
if (!isDraftable(obj)) { return obj; }
|
|
39234
|
+
if (Array.isArray(obj)) { return obj.map(clone); }
|
|
39235
|
+
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
39236
|
+
|
|
39237
|
+
for (var key in obj) { cloned[key] = clone(obj[key]); }
|
|
39238
|
+
|
|
39239
|
+
return cloned;
|
|
39240
|
+
}
|
|
39241
|
+
|
|
39242
|
+
/** Each scope represents a `produce` call. */
|
|
39243
|
+
|
|
39244
|
+
var ImmerScope = function ImmerScope(parent) {
|
|
39245
|
+
this.drafts = [];
|
|
39246
|
+
this.parent = parent; // Whenever the modified draft contains a draft from another scope, we
|
|
39247
|
+
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
39248
|
+
|
|
39249
|
+
this.canAutoFreeze = true; // To avoid prototype lookups:
|
|
39250
|
+
|
|
39251
|
+
this.patches = null;
|
|
39160
39252
|
};
|
|
39161
39253
|
|
|
39162
|
-
|
|
39163
|
-
|
|
39164
|
-
|
|
39165
|
-
|
|
39166
|
-
|
|
39167
|
-
formState[fieldName].errors = errors;
|
|
39168
|
-
formState[fieldName].hasErrors = errors.length > 0;
|
|
39254
|
+
ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
39255
|
+
if (patchListener) {
|
|
39256
|
+
this.patches = [];
|
|
39257
|
+
this.inversePatches = [];
|
|
39258
|
+
this.patchListener = patchListener;
|
|
39169
39259
|
}
|
|
39170
39260
|
};
|
|
39171
39261
|
|
|
39172
|
-
|
|
39173
|
-
|
|
39174
|
-
|
|
39175
|
-
|
|
39176
|
-
|
|
39177
|
-
|
|
39178
|
-
|
|
39262
|
+
ImmerScope.prototype.revoke = function revoke$1 () {
|
|
39263
|
+
this.leave();
|
|
39264
|
+
this.drafts.forEach(revoke);
|
|
39265
|
+
this.drafts = null; // Make draft-related methods throw.
|
|
39266
|
+
};
|
|
39267
|
+
|
|
39268
|
+
ImmerScope.prototype.leave = function leave () {
|
|
39269
|
+
if (this === ImmerScope.current) {
|
|
39270
|
+
ImmerScope.current = this.parent;
|
|
39179
39271
|
}
|
|
39180
39272
|
};
|
|
39273
|
+
ImmerScope.current = null;
|
|
39274
|
+
|
|
39275
|
+
ImmerScope.enter = function () {
|
|
39276
|
+
return this.current = new ImmerScope(this.current);
|
|
39277
|
+
};
|
|
39278
|
+
|
|
39279
|
+
function revoke(draft) {
|
|
39280
|
+
draft[DRAFT_STATE].revoke();
|
|
39281
|
+
}
|
|
39282
|
+
|
|
39283
|
+
// but share them all instead
|
|
39284
|
+
|
|
39285
|
+
var descriptors$1 = {};
|
|
39286
|
+
function willFinalize(scope, result, isReplaced) {
|
|
39287
|
+
scope.drafts.forEach(function (draft) {
|
|
39288
|
+
draft[DRAFT_STATE].finalizing = true;
|
|
39289
|
+
});
|
|
39290
|
+
|
|
39291
|
+
if (!isReplaced) {
|
|
39292
|
+
if (scope.patches) {
|
|
39293
|
+
markChangesRecursively(scope.drafts[0]);
|
|
39294
|
+
} // This is faster when we don't care about which attributes changed.
|
|
39295
|
+
|
|
39296
|
+
|
|
39297
|
+
markChangesSweep(scope.drafts);
|
|
39298
|
+
} // When a child draft is returned, look for changes.
|
|
39299
|
+
else if (isDraft(result) && result[DRAFT_STATE].scope === scope) {
|
|
39300
|
+
markChangesSweep(scope.drafts);
|
|
39301
|
+
}
|
|
39302
|
+
}
|
|
39303
|
+
function createProxy(base, parent) {
|
|
39304
|
+
var isArray = Array.isArray(base);
|
|
39305
|
+
var draft = clonePotentialDraft(base);
|
|
39306
|
+
each(draft, function (prop) {
|
|
39307
|
+
proxyProperty(draft, prop, isArray || isEnumerable(base, prop));
|
|
39308
|
+
}); // See "proxy.js" for property documentation.
|
|
39309
|
+
|
|
39310
|
+
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39311
|
+
var state = {
|
|
39312
|
+
scope: scope,
|
|
39313
|
+
modified: false,
|
|
39314
|
+
finalizing: false,
|
|
39315
|
+
// es5 only
|
|
39316
|
+
finalized: false,
|
|
39317
|
+
assigned: {},
|
|
39318
|
+
parent: parent,
|
|
39319
|
+
base: base,
|
|
39320
|
+
draft: draft,
|
|
39321
|
+
copy: null,
|
|
39322
|
+
revoke: revoke$1,
|
|
39323
|
+
revoked: false // es5 only
|
|
39324
|
+
|
|
39325
|
+
};
|
|
39326
|
+
createHiddenProperty(draft, DRAFT_STATE, state);
|
|
39327
|
+
scope.drafts.push(draft);
|
|
39328
|
+
return draft;
|
|
39329
|
+
}
|
|
39330
|
+
|
|
39331
|
+
function revoke$1() {
|
|
39332
|
+
this.revoked = true;
|
|
39333
|
+
}
|
|
39334
|
+
|
|
39335
|
+
function source(state) {
|
|
39336
|
+
return state.copy || state.base;
|
|
39337
|
+
} // Access a property without creating an Immer draft.
|
|
39338
|
+
|
|
39339
|
+
|
|
39340
|
+
function peek(draft, prop) {
|
|
39341
|
+
var state = draft[DRAFT_STATE];
|
|
39342
|
+
|
|
39343
|
+
if (state && !state.finalizing) {
|
|
39344
|
+
state.finalizing = true;
|
|
39345
|
+
var value = draft[prop];
|
|
39346
|
+
state.finalizing = false;
|
|
39347
|
+
return value;
|
|
39348
|
+
}
|
|
39349
|
+
|
|
39350
|
+
return draft[prop];
|
|
39351
|
+
}
|
|
39352
|
+
|
|
39353
|
+
function get$1(state, prop) {
|
|
39354
|
+
assertUnrevoked(state);
|
|
39355
|
+
var value = peek(source(state), prop);
|
|
39356
|
+
if (state.finalizing) { return value; } // Create a draft if the value is unmodified.
|
|
39357
|
+
|
|
39358
|
+
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
39359
|
+
prepareCopy(state);
|
|
39360
|
+
return state.copy[prop] = createProxy(value, state);
|
|
39361
|
+
}
|
|
39362
|
+
|
|
39363
|
+
return value;
|
|
39364
|
+
}
|
|
39365
|
+
|
|
39366
|
+
function set$1(state, prop, value) {
|
|
39367
|
+
assertUnrevoked(state);
|
|
39368
|
+
state.assigned[prop] = true;
|
|
39369
|
+
|
|
39370
|
+
if (!state.modified) {
|
|
39371
|
+
if (is(value, peek(source(state), prop))) { return; }
|
|
39372
|
+
markChanged(state);
|
|
39373
|
+
prepareCopy(state);
|
|
39374
|
+
}
|
|
39375
|
+
|
|
39376
|
+
state.copy[prop] = value;
|
|
39377
|
+
}
|
|
39378
|
+
|
|
39379
|
+
function markChanged(state) {
|
|
39380
|
+
if (!state.modified) {
|
|
39381
|
+
state.modified = true;
|
|
39382
|
+
if (state.parent) { markChanged(state.parent); }
|
|
39383
|
+
}
|
|
39384
|
+
}
|
|
39385
|
+
|
|
39386
|
+
function prepareCopy(state) {
|
|
39387
|
+
if (!state.copy) { state.copy = clonePotentialDraft(state.base); }
|
|
39388
|
+
}
|
|
39389
|
+
|
|
39390
|
+
function clonePotentialDraft(base) {
|
|
39391
|
+
var state = base && base[DRAFT_STATE];
|
|
39392
|
+
|
|
39393
|
+
if (state) {
|
|
39394
|
+
state.finalizing = true;
|
|
39395
|
+
var draft = shallowCopy(state.draft, true);
|
|
39396
|
+
state.finalizing = false;
|
|
39397
|
+
return draft;
|
|
39398
|
+
}
|
|
39399
|
+
|
|
39400
|
+
return shallowCopy(base);
|
|
39401
|
+
}
|
|
39402
|
+
|
|
39403
|
+
function proxyProperty(draft, prop, enumerable) {
|
|
39404
|
+
var desc = descriptors$1[prop];
|
|
39405
|
+
|
|
39406
|
+
if (desc) {
|
|
39407
|
+
desc.enumerable = enumerable;
|
|
39408
|
+
} else {
|
|
39409
|
+
descriptors$1[prop] = desc = {
|
|
39410
|
+
configurable: true,
|
|
39411
|
+
enumerable: enumerable,
|
|
39412
|
+
|
|
39413
|
+
get: function get$1$1() {
|
|
39414
|
+
return get$1(this[DRAFT_STATE], prop);
|
|
39415
|
+
},
|
|
39416
|
+
|
|
39417
|
+
set: function set$1$1(value) {
|
|
39418
|
+
set$1(this[DRAFT_STATE], prop, value);
|
|
39419
|
+
}
|
|
39420
|
+
|
|
39421
|
+
};
|
|
39422
|
+
}
|
|
39423
|
+
|
|
39424
|
+
Object.defineProperty(draft, prop, desc);
|
|
39425
|
+
}
|
|
39426
|
+
|
|
39427
|
+
function assertUnrevoked(state) {
|
|
39428
|
+
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))); }
|
|
39429
|
+
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
39430
|
+
|
|
39431
|
+
|
|
39432
|
+
function markChangesSweep(drafts) {
|
|
39433
|
+
// The natural order of drafts in the `scope` array is based on when they
|
|
39434
|
+
// were accessed. By processing drafts in reverse natural order, we have a
|
|
39435
|
+
// better chance of processing leaf nodes first. When a leaf node is known to
|
|
39436
|
+
// have changed, we can avoid any traversal of its ancestor nodes.
|
|
39437
|
+
for (var i = drafts.length - 1; i >= 0; i--) {
|
|
39438
|
+
var state = drafts[i][DRAFT_STATE];
|
|
39439
|
+
|
|
39440
|
+
if (!state.modified) {
|
|
39441
|
+
if (Array.isArray(state.base)) {
|
|
39442
|
+
if (hasArrayChanges(state)) { markChanged(state); }
|
|
39443
|
+
} else if (hasObjectChanges(state)) { markChanged(state); }
|
|
39444
|
+
}
|
|
39445
|
+
}
|
|
39446
|
+
}
|
|
39181
39447
|
|
|
39182
|
-
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;
|
|
39448
|
+
function markChangesRecursively(object) {
|
|
39449
|
+
if (!object || typeof object !== "object") { return; }
|
|
39450
|
+
var state = object[DRAFT_STATE];
|
|
39451
|
+
if (!state) { return; }
|
|
39452
|
+
var base = state.base;
|
|
39453
|
+
var draft = state.draft;
|
|
39454
|
+
var assigned = state.assigned;
|
|
39455
|
+
|
|
39456
|
+
if (!Array.isArray(object)) {
|
|
39457
|
+
// Look for added keys.
|
|
39458
|
+
Object.keys(draft).forEach(function (key) {
|
|
39459
|
+
// The `undefined` check is a fast path for pre-existing keys.
|
|
39460
|
+
if (base[key] === undefined && !has$1(base, key)) {
|
|
39461
|
+
assigned[key] = true;
|
|
39462
|
+
markChanged(state);
|
|
39463
|
+
} else if (!assigned[key]) {
|
|
39464
|
+
// Only untouched properties trigger recursion.
|
|
39465
|
+
markChangesRecursively(draft[key]);
|
|
39466
|
+
}
|
|
39467
|
+
}); // Look for removed keys.
|
|
39468
|
+
|
|
39469
|
+
Object.keys(base).forEach(function (key) {
|
|
39470
|
+
// The `undefined` check is a fast path for pre-existing keys.
|
|
39471
|
+
if (draft[key] === undefined && !has$1(draft, key)) {
|
|
39472
|
+
assigned[key] = false;
|
|
39473
|
+
markChanged(state);
|
|
39474
|
+
}
|
|
39475
|
+
});
|
|
39476
|
+
} else if (hasArrayChanges(state)) {
|
|
39477
|
+
markChanged(state);
|
|
39478
|
+
assigned.length = true;
|
|
39479
|
+
|
|
39480
|
+
if (draft.length < base.length) {
|
|
39481
|
+
for (var i = draft.length; i < base.length; i++) { assigned[i] = false; }
|
|
39482
|
+
} else {
|
|
39483
|
+
for (var i$1 = base.length; i$1 < draft.length; i$1++) { assigned[i$1] = true; }
|
|
39484
|
+
}
|
|
39485
|
+
|
|
39486
|
+
for (var i$2 = 0; i$2 < draft.length; i$2++) {
|
|
39487
|
+
// Only untouched indices trigger recursion.
|
|
39488
|
+
if (assigned[i$2] === undefined) { markChangesRecursively(draft[i$2]); }
|
|
39489
|
+
}
|
|
39490
|
+
}
|
|
39491
|
+
}
|
|
39492
|
+
|
|
39493
|
+
function hasObjectChanges(state) {
|
|
39494
|
+
var base = state.base;
|
|
39495
|
+
var draft = state.draft; // Search for added keys and changed keys. Start at the back, because
|
|
39496
|
+
// non-numeric keys are ordered by time of definition on the object.
|
|
39497
|
+
|
|
39498
|
+
var keys = Object.keys(draft);
|
|
39499
|
+
|
|
39500
|
+
for (var i = keys.length - 1; i >= 0; i--) {
|
|
39501
|
+
var key = keys[i];
|
|
39502
|
+
var baseValue = base[key]; // The `undefined` check is a fast path for pre-existing keys.
|
|
39503
|
+
|
|
39504
|
+
if (baseValue === undefined && !has$1(base, key)) {
|
|
39505
|
+
return true;
|
|
39506
|
+
} // Once a base key is deleted, future changes go undetected, because its
|
|
39507
|
+
// descriptor is erased. This branch detects any missed changes.
|
|
39508
|
+
else {
|
|
39509
|
+
var value = draft[key];
|
|
39510
|
+
var state$1 = value && value[DRAFT_STATE];
|
|
39511
|
+
|
|
39512
|
+
if (state$1 ? state$1.base !== baseValue : !is(value, baseValue)) {
|
|
39513
|
+
return true;
|
|
39514
|
+
}
|
|
39515
|
+
}
|
|
39516
|
+
} // At this point, no keys were added or changed.
|
|
39517
|
+
// Compare key count to determine if keys were deleted.
|
|
39518
|
+
|
|
39519
|
+
|
|
39520
|
+
return keys.length !== Object.keys(base).length;
|
|
39521
|
+
}
|
|
39522
|
+
|
|
39523
|
+
function hasArrayChanges(state) {
|
|
39524
|
+
var draft = state.draft;
|
|
39525
|
+
if (draft.length !== state.base.length) { return true; } // See #116
|
|
39526
|
+
// If we first shorten the length, our array interceptors will be removed.
|
|
39527
|
+
// If after that new items are added, result in the same original length,
|
|
39528
|
+
// those last items will have no intercepting property.
|
|
39529
|
+
// So if there is no own descriptor on the last position, we know that items were removed and added
|
|
39530
|
+
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
39531
|
+
// the last one
|
|
39532
|
+
|
|
39533
|
+
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
39534
|
+
|
|
39535
|
+
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
|
|
39536
|
+
|
|
39537
|
+
return false;
|
|
39538
|
+
}
|
|
39539
|
+
|
|
39540
|
+
function createHiddenProperty(target, prop, value) {
|
|
39541
|
+
Object.defineProperty(target, prop, {
|
|
39542
|
+
value: value,
|
|
39543
|
+
enumerable: false,
|
|
39544
|
+
writable: true
|
|
39545
|
+
});
|
|
39546
|
+
}
|
|
39547
|
+
|
|
39548
|
+
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
39549
|
+
willFinalize: willFinalize,
|
|
39550
|
+
createProxy: createProxy
|
|
39551
|
+
});
|
|
39552
|
+
|
|
39553
|
+
function willFinalize$1() {}
|
|
39554
|
+
function createProxy$1(base, parent) {
|
|
39555
|
+
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39556
|
+
var state = {
|
|
39557
|
+
// Track which produce call this is associated with.
|
|
39558
|
+
scope: scope,
|
|
39559
|
+
// True for both shallow and deep changes.
|
|
39560
|
+
modified: false,
|
|
39561
|
+
// Used during finalization.
|
|
39562
|
+
finalized: false,
|
|
39563
|
+
// Track which properties have been assigned (true) or deleted (false).
|
|
39564
|
+
assigned: {},
|
|
39565
|
+
// The parent draft state.
|
|
39566
|
+
parent: parent,
|
|
39567
|
+
// The base state.
|
|
39568
|
+
base: base,
|
|
39569
|
+
// The base proxy.
|
|
39570
|
+
draft: null,
|
|
39571
|
+
// Any property proxies.
|
|
39572
|
+
drafts: {},
|
|
39573
|
+
// The base copy with any updated values.
|
|
39574
|
+
copy: null,
|
|
39575
|
+
// Called by the `produce` function.
|
|
39576
|
+
revoke: null
|
|
39577
|
+
};
|
|
39578
|
+
var ref = Array.isArray(base) ? // [state] is used for arrays, to make sure the proxy is array-ish and not violate invariants,
|
|
39579
|
+
// although state itself is an object
|
|
39580
|
+
Proxy.revocable([state], arrayTraps) : Proxy.revocable(state, objectTraps);
|
|
39581
|
+
var revoke = ref.revoke;
|
|
39582
|
+
var proxy = ref.proxy;
|
|
39583
|
+
state.draft = proxy;
|
|
39584
|
+
state.revoke = revoke;
|
|
39585
|
+
scope.drafts.push(proxy);
|
|
39586
|
+
return proxy;
|
|
39587
|
+
}
|
|
39588
|
+
var objectTraps = {
|
|
39589
|
+
get: get$1$1,
|
|
39590
|
+
|
|
39591
|
+
has: function has(target, prop) {
|
|
39592
|
+
return prop in source$1(target);
|
|
39593
|
+
},
|
|
39594
|
+
|
|
39595
|
+
ownKeys: function ownKeys(target) {
|
|
39596
|
+
return Reflect.ownKeys(source$1(target));
|
|
39597
|
+
},
|
|
39598
|
+
|
|
39599
|
+
set: set$1$1,
|
|
39600
|
+
deleteProperty: deleteProperty,
|
|
39601
|
+
getOwnPropertyDescriptor: getOwnPropertyDescriptor$2,
|
|
39602
|
+
|
|
39603
|
+
defineProperty: function defineProperty() {
|
|
39604
|
+
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
39605
|
+
},
|
|
39606
|
+
|
|
39607
|
+
getPrototypeOf: function getPrototypeOf(target) {
|
|
39608
|
+
return Object.getPrototypeOf(target.base);
|
|
39609
|
+
},
|
|
39610
|
+
|
|
39611
|
+
setPrototypeOf: function setPrototypeOf() {
|
|
39612
|
+
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
39613
|
+
}
|
|
39614
|
+
|
|
39615
|
+
};
|
|
39616
|
+
var arrayTraps = {};
|
|
39617
|
+
each(objectTraps, function (key, fn) {
|
|
39618
|
+
arrayTraps[key] = function () {
|
|
39619
|
+
arguments[0] = arguments[0][0];
|
|
39620
|
+
return fn.apply(this, arguments);
|
|
39621
|
+
};
|
|
39622
|
+
});
|
|
39623
|
+
|
|
39624
|
+
arrayTraps.deleteProperty = function (state, prop) {
|
|
39625
|
+
if (isNaN(parseInt(prop))) {
|
|
39626
|
+
throw new Error("Immer only supports deleting array indices"); // prettier-ignore
|
|
39627
|
+
}
|
|
39628
|
+
|
|
39629
|
+
return objectTraps.deleteProperty.call(this, state[0], prop);
|
|
39630
|
+
};
|
|
39631
|
+
|
|
39632
|
+
arrayTraps.set = function (state, prop, value) {
|
|
39633
|
+
if (prop !== "length" && isNaN(parseInt(prop))) {
|
|
39634
|
+
throw new Error("Immer only supports setting array indices and the 'length' property"); // prettier-ignore
|
|
39635
|
+
}
|
|
39636
|
+
|
|
39637
|
+
return objectTraps.set.call(this, state[0], prop, value);
|
|
39638
|
+
}; // returns the object we should be reading the current value from, which is base, until some change has been made
|
|
39639
|
+
|
|
39640
|
+
|
|
39641
|
+
function source$1(state) {
|
|
39642
|
+
return state.copy || state.base;
|
|
39643
|
+
} // Access a property without creating an Immer draft.
|
|
39644
|
+
|
|
39645
|
+
|
|
39646
|
+
function peek$1(draft, prop) {
|
|
39647
|
+
var state = draft[DRAFT_STATE];
|
|
39648
|
+
var desc = Reflect.getOwnPropertyDescriptor(state ? source$1(state) : draft, prop);
|
|
39649
|
+
return desc && desc.value;
|
|
39650
|
+
}
|
|
39651
|
+
|
|
39652
|
+
function get$1$1(state, prop) {
|
|
39653
|
+
if (prop === DRAFT_STATE) { return state; }
|
|
39654
|
+
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
39655
|
+
|
|
39656
|
+
if (!state.modified && has$1(drafts, prop)) {
|
|
39657
|
+
return drafts[prop];
|
|
39658
|
+
}
|
|
39659
|
+
|
|
39660
|
+
var value = source$1(state)[prop];
|
|
39661
|
+
|
|
39662
|
+
if (state.finalized || !isDraftable(value)) {
|
|
39663
|
+
return value;
|
|
39664
|
+
} // Check for existing draft in modified state.
|
|
39665
|
+
|
|
39666
|
+
|
|
39667
|
+
if (state.modified) {
|
|
39668
|
+
// Assigned values are never drafted. This catches any drafts we created, too.
|
|
39669
|
+
if (value !== peek$1(state.base, prop)) { return value; } // Store drafts on the copy (when one exists).
|
|
39670
|
+
|
|
39671
|
+
drafts = state.copy;
|
|
39672
|
+
}
|
|
39673
|
+
|
|
39674
|
+
return drafts[prop] = createProxy$1(value, state);
|
|
39675
|
+
}
|
|
39676
|
+
|
|
39677
|
+
function set$1$1(state, prop, value) {
|
|
39678
|
+
if (!state.modified) {
|
|
39679
|
+
var baseValue = peek$1(state.base, prop); // Optimize based on value's truthiness. Truthy values are guaranteed to
|
|
39680
|
+
// never be undefined, so we can avoid the `in` operator. Lastly, truthy
|
|
39681
|
+
// values may be drafts, but falsy values are never drafts.
|
|
39682
|
+
|
|
39683
|
+
var isUnchanged = value ? is(baseValue, value) || value === state.drafts[prop] : is(baseValue, value) && prop in state.base;
|
|
39684
|
+
if (isUnchanged) { return true; }
|
|
39685
|
+
markChanged$1(state);
|
|
39686
|
+
}
|
|
39687
|
+
|
|
39688
|
+
state.assigned[prop] = true;
|
|
39689
|
+
state.copy[prop] = value;
|
|
39690
|
+
return true;
|
|
39691
|
+
}
|
|
39692
|
+
|
|
39693
|
+
function deleteProperty(state, prop) {
|
|
39694
|
+
// The `undefined` check is a fast path for pre-existing keys.
|
|
39695
|
+
if (peek$1(state.base, prop) !== undefined || prop in state.base) {
|
|
39696
|
+
state.assigned[prop] = false;
|
|
39697
|
+
markChanged$1(state);
|
|
39698
|
+
} else if (state.assigned[prop]) {
|
|
39699
|
+
// if an originally not assigned property was deleted
|
|
39700
|
+
delete state.assigned[prop];
|
|
39701
|
+
}
|
|
39702
|
+
|
|
39703
|
+
if (state.copy) { delete state.copy[prop]; }
|
|
39704
|
+
return true;
|
|
39705
|
+
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
39706
|
+
// the same guarantee in ES5 mode.
|
|
39707
|
+
|
|
39708
|
+
|
|
39709
|
+
function getOwnPropertyDescriptor$2(state, prop) {
|
|
39710
|
+
var owner = source$1(state);
|
|
39711
|
+
var desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
39712
|
+
|
|
39713
|
+
if (desc) {
|
|
39714
|
+
desc.writable = true;
|
|
39715
|
+
desc.configurable = !Array.isArray(owner) || prop !== "length";
|
|
39716
|
+
}
|
|
39717
|
+
|
|
39718
|
+
return desc;
|
|
39719
|
+
}
|
|
39720
|
+
|
|
39721
|
+
function markChanged$1(state) {
|
|
39722
|
+
if (!state.modified) {
|
|
39723
|
+
state.modified = true;
|
|
39724
|
+
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
39725
|
+
state.drafts = null;
|
|
39726
|
+
if (state.parent) { markChanged$1(state.parent); }
|
|
39727
|
+
}
|
|
39728
|
+
}
|
|
39729
|
+
|
|
39730
|
+
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
39731
|
+
willFinalize: willFinalize$1,
|
|
39732
|
+
createProxy: createProxy$1
|
|
39733
|
+
});
|
|
39734
|
+
|
|
39735
|
+
function generatePatches(state, basePath, patches, inversePatches) {
|
|
39736
|
+
Array.isArray(state.base) ? generateArrayPatches(state, basePath, patches, inversePatches) : generateObjectPatches(state, basePath, patches, inversePatches);
|
|
39737
|
+
}
|
|
39738
|
+
|
|
39739
|
+
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
39740
|
+
var assign, assign$1;
|
|
39741
|
+
|
|
39742
|
+
var base = state.base;
|
|
39743
|
+
var copy = state.copy;
|
|
39744
|
+
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
39745
|
+
|
|
39746
|
+
if (copy.length < base.length) {
|
|
39747
|
+
(assign = [copy, base], base = assign[0], copy = assign[1]);
|
|
39748
|
+
(assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1]);
|
|
39749
|
+
}
|
|
39750
|
+
|
|
39751
|
+
var delta = copy.length - base.length; // Find the first replaced index.
|
|
39752
|
+
|
|
39753
|
+
var start = 0;
|
|
39754
|
+
|
|
39755
|
+
while (base[start] === copy[start] && start < base.length) {
|
|
39756
|
+
++start;
|
|
39757
|
+
} // Find the last replaced index. Search from the end to optimize splice patches.
|
|
39758
|
+
|
|
39759
|
+
|
|
39760
|
+
var end = base.length;
|
|
39761
|
+
|
|
39762
|
+
while (end > start && base[end - 1] === copy[end + delta - 1]) {
|
|
39763
|
+
--end;
|
|
39764
|
+
} // Process replaced indices.
|
|
39765
|
+
|
|
39766
|
+
|
|
39767
|
+
for (var i = start; i < end; ++i) {
|
|
39768
|
+
if (assigned[i] && copy[i] !== base[i]) {
|
|
39769
|
+
var path = basePath.concat([i]);
|
|
39770
|
+
patches.push({
|
|
39771
|
+
op: "replace",
|
|
39772
|
+
path: path,
|
|
39773
|
+
value: copy[i]
|
|
39774
|
+
});
|
|
39775
|
+
inversePatches.push({
|
|
39776
|
+
op: "replace",
|
|
39777
|
+
path: path,
|
|
39778
|
+
value: base[i]
|
|
39779
|
+
});
|
|
39780
|
+
}
|
|
39781
|
+
}
|
|
39183
39782
|
|
|
39184
|
-
|
|
39783
|
+
var replaceCount = patches.length; // Process added indices.
|
|
39784
|
+
|
|
39785
|
+
for (var i$1 = end + delta - 1; i$1 >= end; --i$1) {
|
|
39786
|
+
var path$1 = basePath.concat([i$1]);
|
|
39787
|
+
patches[replaceCount + i$1 - end] = {
|
|
39788
|
+
op: "add",
|
|
39789
|
+
path: path$1,
|
|
39790
|
+
value: copy[i$1]
|
|
39791
|
+
};
|
|
39792
|
+
inversePatches.push({
|
|
39793
|
+
op: "remove",
|
|
39794
|
+
path: path$1
|
|
39795
|
+
});
|
|
39796
|
+
}
|
|
39797
|
+
}
|
|
39798
|
+
|
|
39799
|
+
function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
39800
|
+
var base = state.base;
|
|
39801
|
+
var copy = state.copy;
|
|
39802
|
+
each(state.assigned, function (key, assignedValue) {
|
|
39803
|
+
var origValue = base[key];
|
|
39804
|
+
var value = copy[key];
|
|
39805
|
+
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
39806
|
+
if (origValue === value && op === "replace") { return; }
|
|
39807
|
+
var path = basePath.concat(key);
|
|
39808
|
+
patches.push(op === "remove" ? {
|
|
39809
|
+
op: op,
|
|
39810
|
+
path: path
|
|
39811
|
+
} : {
|
|
39812
|
+
op: op,
|
|
39813
|
+
path: path,
|
|
39814
|
+
value: value
|
|
39815
|
+
});
|
|
39816
|
+
inversePatches.push(op === "add" ? {
|
|
39817
|
+
op: "remove",
|
|
39818
|
+
path: path
|
|
39819
|
+
} : op === "remove" ? {
|
|
39820
|
+
op: "add",
|
|
39821
|
+
path: path,
|
|
39822
|
+
value: origValue
|
|
39823
|
+
} : {
|
|
39824
|
+
op: "replace",
|
|
39825
|
+
path: path,
|
|
39826
|
+
value: origValue
|
|
39827
|
+
});
|
|
39828
|
+
});
|
|
39829
|
+
}
|
|
39830
|
+
|
|
39831
|
+
var applyPatches = function (draft, patches) {
|
|
39832
|
+
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
39833
|
+
var patch = list[i$1];
|
|
39834
|
+
|
|
39835
|
+
var path = patch.path;
|
|
39836
|
+
var op = patch.op;
|
|
39837
|
+
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
39838
|
+
|
|
39839
|
+
if (!path.length) { throw new Error("Illegal state"); }
|
|
39840
|
+
var base = draft;
|
|
39841
|
+
|
|
39842
|
+
for (var i = 0; i < path.length - 1; i++) {
|
|
39843
|
+
base = base[path[i]];
|
|
39844
|
+
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
39845
|
+
}
|
|
39846
|
+
|
|
39847
|
+
var key = path[path.length - 1];
|
|
39848
|
+
|
|
39849
|
+
switch (op) {
|
|
39850
|
+
case "replace":
|
|
39851
|
+
// if value is an object, then it's assigned by reference
|
|
39852
|
+
// in the following add or remove ops, the value field inside the patch will also be modifyed
|
|
39853
|
+
// so we use value from the cloned patch
|
|
39854
|
+
base[key] = value;
|
|
39855
|
+
break;
|
|
39856
|
+
|
|
39857
|
+
case "add":
|
|
39858
|
+
if (Array.isArray(base)) {
|
|
39859
|
+
// TODO: support "foo/-" paths for appending to an array
|
|
39860
|
+
base.splice(key, 0, value);
|
|
39861
|
+
} else {
|
|
39862
|
+
base[key] = value;
|
|
39863
|
+
}
|
|
39864
|
+
|
|
39865
|
+
break;
|
|
39866
|
+
|
|
39867
|
+
case "remove":
|
|
39868
|
+
if (Array.isArray(base)) {
|
|
39869
|
+
base.splice(key, 1);
|
|
39870
|
+
} else {
|
|
39871
|
+
delete base[key];
|
|
39872
|
+
}
|
|
39873
|
+
|
|
39874
|
+
break;
|
|
39875
|
+
|
|
39876
|
+
default:
|
|
39877
|
+
throw new Error("Unsupported patch operation: " + op);
|
|
39878
|
+
}
|
|
39879
|
+
}
|
|
39880
|
+
|
|
39881
|
+
return draft;
|
|
39882
|
+
};
|
|
39883
|
+
|
|
39884
|
+
function verifyMinified() {}
|
|
39885
|
+
|
|
39886
|
+
var configDefaults = {
|
|
39887
|
+
useProxies: typeof Proxy !== "undefined" && typeof Reflect !== "undefined",
|
|
39888
|
+
autoFreeze: typeof process !== "undefined" ? process.env.NODE_ENV !== "production" : verifyMinified.name === "verifyMinified",
|
|
39889
|
+
onAssign: null,
|
|
39890
|
+
onDelete: null,
|
|
39891
|
+
onCopy: null
|
|
39892
|
+
};
|
|
39893
|
+
var Immer = function Immer(config) {
|
|
39894
|
+
assign(this, configDefaults, config);
|
|
39895
|
+
this.setUseProxies(this.useProxies);
|
|
39896
|
+
this.produce = this.produce.bind(this);
|
|
39897
|
+
};
|
|
39898
|
+
|
|
39899
|
+
Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
39900
|
+
var this$1$1 = this;
|
|
39901
|
+
|
|
39902
|
+
// curried invocation
|
|
39903
|
+
if (typeof base === "function" && typeof recipe !== "function") {
|
|
39904
|
+
var defaultBase = recipe;
|
|
39905
|
+
recipe = base;
|
|
39906
|
+
var self = this;
|
|
39907
|
+
return function curriedProduce(base) {
|
|
39908
|
+
var this$1$1 = this;
|
|
39909
|
+
if ( base === void 0 ) base = defaultBase;
|
|
39910
|
+
var args = [], len = arguments.length - 1;
|
|
39911
|
+
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
39912
|
+
|
|
39913
|
+
return self.produce(base, function (draft) { return recipe.call.apply(recipe, [ this$1$1, draft ].concat( args )); }); // prettier-ignore
|
|
39914
|
+
};
|
|
39915
|
+
} // prettier-ignore
|
|
39916
|
+
|
|
39917
|
+
|
|
39918
|
+
{
|
|
39919
|
+
if (typeof recipe !== "function") {
|
|
39920
|
+
throw new Error("The first or second argument to `produce` must be a function");
|
|
39921
|
+
}
|
|
39922
|
+
|
|
39923
|
+
if (patchListener !== undefined && typeof patchListener !== "function") {
|
|
39924
|
+
throw new Error("The third argument to `produce` must be a function or undefined");
|
|
39925
|
+
}
|
|
39926
|
+
}
|
|
39927
|
+
var result; // Only plain objects, arrays, and "immerable classes" are drafted.
|
|
39928
|
+
|
|
39929
|
+
if (isDraftable(base)) {
|
|
39930
|
+
var scope = ImmerScope.enter();
|
|
39931
|
+
var proxy = this.createProxy(base);
|
|
39932
|
+
var hasError = true;
|
|
39933
|
+
|
|
39934
|
+
try {
|
|
39935
|
+
result = recipe(proxy);
|
|
39936
|
+
hasError = false;
|
|
39937
|
+
} finally {
|
|
39938
|
+
// finally instead of catch + rethrow better preserves original stack
|
|
39939
|
+
if (hasError) { scope.revoke(); }else { scope.leave(); }
|
|
39940
|
+
}
|
|
39941
|
+
|
|
39942
|
+
if (result instanceof Promise) {
|
|
39943
|
+
return result.then(function (result) {
|
|
39944
|
+
scope.usePatches(patchListener);
|
|
39945
|
+
return this$1$1.processResult(result, scope);
|
|
39946
|
+
}, function (error) {
|
|
39947
|
+
scope.revoke();
|
|
39948
|
+
throw error;
|
|
39949
|
+
});
|
|
39950
|
+
}
|
|
39951
|
+
|
|
39952
|
+
scope.usePatches(patchListener);
|
|
39953
|
+
return this.processResult(result, scope);
|
|
39954
|
+
} else {
|
|
39955
|
+
result = recipe(base);
|
|
39956
|
+
if (result === undefined) { return base; }
|
|
39957
|
+
return result !== NOTHING ? result : undefined;
|
|
39958
|
+
}
|
|
39959
|
+
};
|
|
39960
|
+
|
|
39961
|
+
Immer.prototype.produceWithPatches = function produceWithPatches (arg1, arg2, arg3) {
|
|
39962
|
+
var this$1$1 = this;
|
|
39963
|
+
|
|
39964
|
+
if (typeof arg1 === "function") {
|
|
39965
|
+
return function (state) {
|
|
39966
|
+
var args = [], len = arguments.length - 1;
|
|
39967
|
+
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
39968
|
+
|
|
39969
|
+
return this$1$1.produceWithPatches(state, function (draft) { return arg1.apply(void 0, [ draft ].concat( args )); });
|
|
39970
|
+
};
|
|
39971
|
+
} // non-curried form
|
|
39972
|
+
|
|
39973
|
+
|
|
39974
|
+
if (arg3) { throw new Error("A patch listener cannot be passed to produceWithPatches"); }
|
|
39975
|
+
var patches, inversePatches;
|
|
39976
|
+
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
39977
|
+
patches = p;
|
|
39978
|
+
inversePatches = ip;
|
|
39979
|
+
});
|
|
39980
|
+
return [nextState, patches, inversePatches];
|
|
39981
|
+
};
|
|
39982
|
+
|
|
39983
|
+
Immer.prototype.createDraft = function createDraft (base) {
|
|
39984
|
+
if (!isDraftable(base)) {
|
|
39985
|
+
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
39986
|
+
}
|
|
39987
|
+
|
|
39988
|
+
var scope = ImmerScope.enter();
|
|
39989
|
+
var proxy = this.createProxy(base);
|
|
39990
|
+
proxy[DRAFT_STATE].isManual = true;
|
|
39991
|
+
scope.leave();
|
|
39992
|
+
return proxy;
|
|
39993
|
+
};
|
|
39994
|
+
|
|
39995
|
+
Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
39996
|
+
var state = draft && draft[DRAFT_STATE];
|
|
39997
|
+
|
|
39998
|
+
if (!state || !state.isManual) {
|
|
39999
|
+
throw new Error("First argument to `finishDraft` must be a draft returned by `createDraft`"); // prettier-ignore
|
|
40000
|
+
}
|
|
40001
|
+
|
|
40002
|
+
if (state.finalized) {
|
|
40003
|
+
throw new Error("The given draft is already finalized"); // prettier-ignore
|
|
40004
|
+
}
|
|
40005
|
+
|
|
40006
|
+
var scope = state.scope;
|
|
40007
|
+
scope.usePatches(patchListener);
|
|
40008
|
+
return this.processResult(undefined, scope);
|
|
40009
|
+
};
|
|
40010
|
+
|
|
40011
|
+
Immer.prototype.setAutoFreeze = function setAutoFreeze (value) {
|
|
40012
|
+
this.autoFreeze = value;
|
|
40013
|
+
};
|
|
40014
|
+
|
|
40015
|
+
Immer.prototype.setUseProxies = function setUseProxies (value) {
|
|
40016
|
+
this.useProxies = value;
|
|
40017
|
+
assign(this, value ? modernProxy : legacyProxy);
|
|
40018
|
+
};
|
|
40019
|
+
|
|
40020
|
+
Immer.prototype.applyPatches = function applyPatches$1 (base, patches) {
|
|
40021
|
+
// If a patch replaces the entire state, take that replacement as base
|
|
40022
|
+
// before applying patches
|
|
40023
|
+
var i;
|
|
40024
|
+
|
|
40025
|
+
for (i = patches.length - 1; i >= 0; i--) {
|
|
40026
|
+
var patch = patches[i];
|
|
40027
|
+
|
|
40028
|
+
if (patch.path.length === 0 && patch.op === "replace") {
|
|
40029
|
+
base = patch.value;
|
|
40030
|
+
break;
|
|
40031
|
+
}
|
|
40032
|
+
}
|
|
40033
|
+
|
|
40034
|
+
if (isDraft(base)) {
|
|
40035
|
+
// N.B: never hits if some patch a replacement, patches are never drafts
|
|
40036
|
+
return applyPatches(base, patches);
|
|
40037
|
+
} // Otherwise, produce a copy of the base state.
|
|
40038
|
+
|
|
40039
|
+
|
|
40040
|
+
return this.produce(base, function (draft) { return applyPatches(draft, patches.slice(i + 1)); });
|
|
40041
|
+
};
|
|
40042
|
+
/** @internal */
|
|
40043
|
+
|
|
40044
|
+
|
|
40045
|
+
Immer.prototype.processResult = function processResult (result, scope) {
|
|
40046
|
+
var baseDraft = scope.drafts[0];
|
|
40047
|
+
var isReplaced = result !== undefined && result !== baseDraft;
|
|
40048
|
+
this.willFinalize(scope, result, isReplaced);
|
|
40049
|
+
|
|
40050
|
+
if (isReplaced) {
|
|
40051
|
+
if (baseDraft[DRAFT_STATE].modified) {
|
|
40052
|
+
scope.revoke();
|
|
40053
|
+
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
|
|
40054
|
+
}
|
|
40055
|
+
|
|
40056
|
+
if (isDraftable(result)) {
|
|
40057
|
+
// Finalize the result in case it contains (or is) a subset of the draft.
|
|
40058
|
+
result = this.finalize(result, null, scope);
|
|
40059
|
+
}
|
|
40060
|
+
|
|
40061
|
+
if (scope.patches) {
|
|
40062
|
+
scope.patches.push({
|
|
40063
|
+
op: "replace",
|
|
40064
|
+
path: [],
|
|
40065
|
+
value: result
|
|
40066
|
+
});
|
|
40067
|
+
scope.inversePatches.push({
|
|
40068
|
+
op: "replace",
|
|
40069
|
+
path: [],
|
|
40070
|
+
value: baseDraft[DRAFT_STATE].base
|
|
40071
|
+
});
|
|
40072
|
+
}
|
|
40073
|
+
} else {
|
|
40074
|
+
// Finalize the base draft.
|
|
40075
|
+
result = this.finalize(baseDraft, [], scope);
|
|
40076
|
+
}
|
|
40077
|
+
|
|
40078
|
+
scope.revoke();
|
|
40079
|
+
|
|
40080
|
+
if (scope.patches) {
|
|
40081
|
+
scope.patchListener(scope.patches, scope.inversePatches);
|
|
40082
|
+
}
|
|
40083
|
+
|
|
40084
|
+
return result !== NOTHING ? result : undefined;
|
|
40085
|
+
};
|
|
40086
|
+
/**
|
|
40087
|
+
* @internal
|
|
40088
|
+
* Finalize a draft, returning either the unmodified base state or a modified
|
|
40089
|
+
* copy of the base state.
|
|
40090
|
+
*/
|
|
40091
|
+
|
|
40092
|
+
|
|
40093
|
+
Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
40094
|
+
var this$1$1 = this;
|
|
40095
|
+
|
|
40096
|
+
var state = draft[DRAFT_STATE];
|
|
40097
|
+
|
|
40098
|
+
if (!state) {
|
|
40099
|
+
if (Object.isFrozen(draft)) { return draft; }
|
|
40100
|
+
return this.finalizeTree(draft, null, scope);
|
|
40101
|
+
} // Never finalize drafts owned by another scope.
|
|
40102
|
+
|
|
40103
|
+
|
|
40104
|
+
if (state.scope !== scope) {
|
|
40105
|
+
return draft;
|
|
40106
|
+
}
|
|
40107
|
+
|
|
40108
|
+
if (!state.modified) {
|
|
40109
|
+
return state.base;
|
|
40110
|
+
}
|
|
40111
|
+
|
|
40112
|
+
if (!state.finalized) {
|
|
40113
|
+
state.finalized = true;
|
|
40114
|
+
this.finalizeTree(state.draft, path, scope);
|
|
40115
|
+
|
|
40116
|
+
if (this.onDelete) {
|
|
40117
|
+
// The `assigned` object is unreliable with ES5 drafts.
|
|
40118
|
+
if (this.useProxies) {
|
|
40119
|
+
var assigned = state.assigned;
|
|
40120
|
+
|
|
40121
|
+
for (var prop in assigned) {
|
|
40122
|
+
if (!assigned[prop]) { this.onDelete(state, prop); }
|
|
40123
|
+
}
|
|
40124
|
+
} else {
|
|
40125
|
+
var base = state.base;
|
|
40126
|
+
var copy = state.copy;
|
|
40127
|
+
each(base, function (prop) {
|
|
40128
|
+
if (!has$1(copy, prop)) { this$1$1.onDelete(state, prop); }
|
|
40129
|
+
});
|
|
40130
|
+
}
|
|
40131
|
+
}
|
|
40132
|
+
|
|
40133
|
+
if (this.onCopy) {
|
|
40134
|
+
this.onCopy(state);
|
|
40135
|
+
} // At this point, all descendants of `state.copy` have been finalized,
|
|
40136
|
+
// so we can be sure that `scope.canAutoFreeze` is accurate.
|
|
40137
|
+
|
|
40138
|
+
|
|
40139
|
+
if (this.autoFreeze && scope.canAutoFreeze) {
|
|
40140
|
+
Object.freeze(state.copy);
|
|
40141
|
+
}
|
|
40142
|
+
|
|
40143
|
+
if (path && scope.patches) {
|
|
40144
|
+
generatePatches(state, path, scope.patches, scope.inversePatches);
|
|
40145
|
+
}
|
|
40146
|
+
}
|
|
40147
|
+
|
|
40148
|
+
return state.copy;
|
|
40149
|
+
};
|
|
40150
|
+
/**
|
|
40151
|
+
* @internal
|
|
40152
|
+
* Finalize all drafts in the given state tree.
|
|
40153
|
+
*/
|
|
40154
|
+
|
|
40155
|
+
|
|
40156
|
+
Immer.prototype.finalizeTree = function finalizeTree (root, rootPath, scope) {
|
|
40157
|
+
var this$1$1 = this;
|
|
40158
|
+
|
|
40159
|
+
var state = root[DRAFT_STATE];
|
|
40160
|
+
|
|
40161
|
+
if (state) {
|
|
40162
|
+
if (!this.useProxies) {
|
|
40163
|
+
// Create the final copy, with added keys and without deleted keys.
|
|
40164
|
+
state.copy = shallowCopy(state.draft, true);
|
|
40165
|
+
}
|
|
40166
|
+
|
|
40167
|
+
root = state.copy;
|
|
40168
|
+
}
|
|
40169
|
+
|
|
40170
|
+
var needPatches = !!rootPath && !!scope.patches;
|
|
40171
|
+
|
|
40172
|
+
var finalizeProperty = function (prop, value, parent) {
|
|
40173
|
+
if (value === parent) {
|
|
40174
|
+
throw Error("Immer forbids circular references");
|
|
40175
|
+
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
40176
|
+
|
|
40177
|
+
|
|
40178
|
+
var isDraftProp = !!state && parent === root;
|
|
40179
|
+
|
|
40180
|
+
if (isDraft(value)) {
|
|
40181
|
+
var path = isDraftProp && needPatches && !state.assigned[prop] ? rootPath.concat(prop) : null; // Drafts owned by `scope` are finalized here.
|
|
40182
|
+
|
|
40183
|
+
value = this$1$1.finalize(value, path, scope); // Drafts from another scope must prevent auto-freezing.
|
|
40184
|
+
|
|
40185
|
+
if (isDraft(value)) {
|
|
40186
|
+
scope.canAutoFreeze = false;
|
|
40187
|
+
} // Preserve non-enumerable properties.
|
|
40188
|
+
|
|
40189
|
+
|
|
40190
|
+
if (Array.isArray(parent) || isEnumerable(parent, prop)) {
|
|
40191
|
+
parent[prop] = value;
|
|
40192
|
+
} else {
|
|
40193
|
+
Object.defineProperty(parent, prop, {
|
|
40194
|
+
value: value
|
|
40195
|
+
});
|
|
40196
|
+
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
40197
|
+
|
|
40198
|
+
|
|
40199
|
+
if (isDraftProp && value === state.base[prop]) { return; }
|
|
40200
|
+
} // Unchanged draft properties are ignored.
|
|
40201
|
+
else if (isDraftProp && is(value, state.base[prop])) {
|
|
40202
|
+
return;
|
|
40203
|
+
} // Search new objects for unfinalized drafts. Frozen objects should never contain drafts.
|
|
40204
|
+
else if (isDraftable(value) && !Object.isFrozen(value)) {
|
|
40205
|
+
each(value, finalizeProperty);
|
|
40206
|
+
}
|
|
40207
|
+
|
|
40208
|
+
if (isDraftProp && this$1$1.onAssign) {
|
|
40209
|
+
this$1$1.onAssign(state, prop, value);
|
|
40210
|
+
}
|
|
40211
|
+
};
|
|
40212
|
+
|
|
40213
|
+
each(root, finalizeProperty);
|
|
40214
|
+
return root;
|
|
40215
|
+
};
|
|
40216
|
+
|
|
40217
|
+
var immer = new Immer();
|
|
40218
|
+
/**
|
|
40219
|
+
* The `produce` function takes a value and a "recipe function" (whose
|
|
40220
|
+
* return value often depends on the base state). The recipe function is
|
|
40221
|
+
* free to mutate its first argument however it wants. All mutations are
|
|
40222
|
+
* only ever applied to a __copy__ of the base state.
|
|
40223
|
+
*
|
|
40224
|
+
* Pass only a function to create a "curried producer" which relieves you
|
|
40225
|
+
* from passing the recipe function every time.
|
|
40226
|
+
*
|
|
40227
|
+
* Only plain objects and arrays are made mutable. All other objects are
|
|
40228
|
+
* considered uncopyable.
|
|
40229
|
+
*
|
|
40230
|
+
* Note: This function is __bound__ to its `Immer` instance.
|
|
40231
|
+
*
|
|
40232
|
+
* @param {any} base - the initial state
|
|
40233
|
+
* @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified
|
|
40234
|
+
* @param {Function} patchListener - optional function that will be called with all the patches produced here
|
|
40235
|
+
* @returns {any} a new state, or the initial state if nothing was modified
|
|
40236
|
+
*/
|
|
40237
|
+
|
|
40238
|
+
var produce = immer.produce;
|
|
40239
|
+
/**
|
|
40240
|
+
* Like `produce`, but `produceWithPatches` always returns a tuple
|
|
40241
|
+
* [nextState, patches, inversePatches] (instead of just the next state)
|
|
40242
|
+
*/
|
|
40243
|
+
|
|
40244
|
+
immer.produceWithPatches.bind(immer);
|
|
40245
|
+
/**
|
|
40246
|
+
* Pass true to automatically freeze all copies created by Immer.
|
|
40247
|
+
*
|
|
40248
|
+
* By default, auto-freezing is disabled in production.
|
|
40249
|
+
*/
|
|
40250
|
+
|
|
40251
|
+
immer.setAutoFreeze.bind(immer);
|
|
40252
|
+
/**
|
|
40253
|
+
* Pass true to use the ES2015 `Proxy` class when creating drafts, which is
|
|
40254
|
+
* always faster than using ES5 proxies.
|
|
40255
|
+
*
|
|
40256
|
+
* By default, feature detection is used, so calling this is rarely necessary.
|
|
40257
|
+
*/
|
|
40258
|
+
|
|
40259
|
+
immer.setUseProxies.bind(immer);
|
|
40260
|
+
/**
|
|
40261
|
+
* Apply an array of Immer patches to the first argument.
|
|
40262
|
+
*
|
|
40263
|
+
* This function is a producer, which means copy-on-write is in effect.
|
|
40264
|
+
*/
|
|
40265
|
+
|
|
40266
|
+
immer.applyPatches.bind(immer);
|
|
40267
|
+
/**
|
|
40268
|
+
* Create an Immer draft from the given base state, which may be a draft itself.
|
|
40269
|
+
* The draft can be modified until you finalize it with the `finishDraft` function.
|
|
40270
|
+
*/
|
|
40271
|
+
|
|
40272
|
+
immer.createDraft.bind(immer);
|
|
40273
|
+
/**
|
|
40274
|
+
* Finalize an Immer draft from a `createDraft` call, returning the base state
|
|
40275
|
+
* (if no changes were made) or a modified copy. The draft must *not* be
|
|
40276
|
+
* mutated afterwards.
|
|
40277
|
+
*
|
|
40278
|
+
* Pass a function as the 2nd argument to generate Immer patches based on the
|
|
40279
|
+
* changes that were made.
|
|
40280
|
+
*/
|
|
40281
|
+
|
|
40282
|
+
immer.finishDraft.bind(immer);
|
|
40283
|
+
|
|
40284
|
+
const createInitialState = formConfig => {
|
|
39185
40285
|
let initialForm = {};
|
|
39186
40286
|
const formConfigKeys = Object.keys(formConfig);
|
|
39187
40287
|
for (let formKey of formConfigKeys) {
|
|
39188
40288
|
initialForm[formKey] = {
|
|
39189
40289
|
dirty: false,
|
|
39190
|
-
rawValue: formConfig[formKey].defaultValue ||
|
|
40290
|
+
rawValue: formConfig[formKey].defaultValue || "",
|
|
39191
40291
|
validators: formConfig[formKey].validators || [],
|
|
39192
|
-
constraints: formConfig[formKey].constraints || []
|
|
40292
|
+
constraints: formConfig[formKey].constraints || []
|
|
39193
40293
|
};
|
|
39194
40294
|
}
|
|
39195
40295
|
// Because validators require the entire form we have to do a
|
|
@@ -39200,99 +40300,82 @@ const createInitialState = (formConfig) => {
|
|
|
39200
40300
|
initialForm[formKey].errors = errors;
|
|
39201
40301
|
initialForm[formKey].hasErrors = errors.length > 0;
|
|
39202
40302
|
}
|
|
39203
|
-
|
|
39204
40303
|
return initialForm;
|
|
39205
40304
|
};
|
|
39206
40305
|
|
|
39207
|
-
const SET =
|
|
39208
|
-
const set$
|
|
40306
|
+
const SET = "field/SET";
|
|
40307
|
+
const set$2 = fieldName => value => ({
|
|
39209
40308
|
type: SET,
|
|
39210
|
-
payload: { fieldName, value }
|
|
40309
|
+
payload: { fieldName, value }
|
|
39211
40310
|
});
|
|
39212
40311
|
|
|
39213
|
-
const CLEAR =
|
|
40312
|
+
const CLEAR = "form/CLEAR";
|
|
39214
40313
|
const clear = () => ({ type: CLEAR });
|
|
39215
40314
|
|
|
39216
|
-
const ADD_VALIDATOR =
|
|
39217
|
-
const addValidator =
|
|
40315
|
+
const ADD_VALIDATOR = "field/ADD_VALIDATOR";
|
|
40316
|
+
const addValidator = fieldName => validator => ({
|
|
39218
40317
|
type: ADD_VALIDATOR,
|
|
39219
|
-
payload: { fieldName, validator }
|
|
39220
|
-
});
|
|
39221
|
-
|
|
39222
|
-
const REMOVE_VALIDATOR = 'field/REMOVE_VALIDATOR';
|
|
39223
|
-
const removeValidator = (fieldName) => (validator) => ({
|
|
39224
|
-
type: REMOVE_VALIDATOR,
|
|
39225
|
-
payload: { fieldName, validator },
|
|
40318
|
+
payload: { fieldName, validator }
|
|
39226
40319
|
});
|
|
39227
40320
|
|
|
39228
|
-
const
|
|
39229
|
-
|
|
39230
|
-
|
|
39231
|
-
|
|
39232
|
-
|
|
39233
|
-
|
|
39234
|
-
const
|
|
39235
|
-
|
|
39236
|
-
|
|
39237
|
-
|
|
39238
|
-
|
|
39239
|
-
|
|
39240
|
-
|
|
39241
|
-
|
|
39242
|
-
|
|
39243
|
-
|
|
39244
|
-
|
|
39245
|
-
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
39246
|
-
// If the change violates constraints, revert the change
|
|
39247
|
-
draftState[changedFieldName].rawValue = originalValue;
|
|
39248
|
-
return draftState;
|
|
39249
|
-
}
|
|
39250
|
-
|
|
39251
|
-
computeDirtyEntries(draftState, changedFieldName);
|
|
39252
|
-
computeErrorEntries(draftState);
|
|
39253
|
-
});
|
|
39254
|
-
}
|
|
39255
|
-
case CLEAR:
|
|
39256
|
-
return createInitialState(formConfig);
|
|
39257
|
-
case ADD_VALIDATOR: {
|
|
39258
|
-
const fieldWithOverride = action.payload.fieldName;
|
|
39259
|
-
const newValidator = action.payload.validator;
|
|
39260
|
-
|
|
39261
|
-
return produce(state, (draftState) => {
|
|
39262
|
-
draftState[fieldWithOverride].validators.push(newValidator);
|
|
39263
|
-
computeErrorEntries(draftState);
|
|
39264
|
-
});
|
|
39265
|
-
}
|
|
39266
|
-
case REMOVE_VALIDATOR: {
|
|
39267
|
-
const fieldToOverride = action.payload.fieldName;
|
|
39268
|
-
const targetValidator = action.payload.validator;
|
|
39269
|
-
|
|
39270
|
-
return produce(state, (draftState) => {
|
|
39271
|
-
let fieldValidators = draftState[fieldToOverride].validators;
|
|
39272
|
-
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
39273
|
-
(validator) => validator.type !== targetValidator.type
|
|
39274
|
-
);
|
|
39275
|
-
computeErrorEntries(draftState);
|
|
39276
|
-
});
|
|
39277
|
-
}
|
|
39278
|
-
case CLEAR_FIELD_VALIDATORS: {
|
|
39279
|
-
const fieldToClear = action.payload.fieldName;
|
|
40321
|
+
const createFormReducer = formConfig => (
|
|
40322
|
+
state = createInitialState(formConfig),
|
|
40323
|
+
action
|
|
40324
|
+
) => {
|
|
40325
|
+
switch (action.type) {
|
|
40326
|
+
case SET:
|
|
40327
|
+
const changedFieldName = action.payload.fieldName;
|
|
40328
|
+
const newRawValue = action.payload.value;
|
|
40329
|
+
|
|
40330
|
+
return produce(state, draftState => {
|
|
40331
|
+
let originalValue = draftState[changedFieldName].rawValue;
|
|
40332
|
+
draftState[changedFieldName].rawValue = newRawValue;
|
|
40333
|
+
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
40334
|
+
// If the change violates constraints, revert the change
|
|
40335
|
+
draftState[changedFieldName].rawValue = originalValue;
|
|
40336
|
+
return draftState;
|
|
40337
|
+
}
|
|
39280
40338
|
|
|
39281
|
-
|
|
39282
|
-
|
|
39283
|
-
|
|
39284
|
-
|
|
39285
|
-
|
|
39286
|
-
|
|
39287
|
-
|
|
39288
|
-
|
|
39289
|
-
|
|
40339
|
+
const fields = Object.entries(draftState);
|
|
40340
|
+
for (let entry of fields) {
|
|
40341
|
+
let fieldName = entry[0];
|
|
40342
|
+
let field = entry[1];
|
|
40343
|
+
let errors = computeErrors(fieldName, draftState);
|
|
40344
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
40345
|
+
draftState[fieldName].errors = errors;
|
|
40346
|
+
draftState[fieldName].dirty = dirty;
|
|
40347
|
+
draftState[fieldName].hasErrors = errors.length > 0;
|
|
40348
|
+
}
|
|
40349
|
+
});
|
|
40350
|
+
case CLEAR:
|
|
40351
|
+
return createInitialState(formConfig);
|
|
40352
|
+
case ADD_VALIDATOR:
|
|
40353
|
+
const fieldWithOverride = action.payload.fieldName;
|
|
40354
|
+
const newValidator = action.payload.validator;
|
|
40355
|
+
|
|
40356
|
+
return produce(state, draftState => {
|
|
40357
|
+
draftState[fieldWithOverride].validators.push(newValidator);
|
|
40358
|
+
const fields = Object.entries(draftState);
|
|
40359
|
+
for (let entry of fields) {
|
|
40360
|
+
let fieldName = entry[0];
|
|
40361
|
+
let field = entry[1];
|
|
40362
|
+
let errors = computeErrors(fieldName, draftState);
|
|
40363
|
+
let dirty = field.dirty;
|
|
40364
|
+
draftState[fieldName].errors = errors;
|
|
40365
|
+
draftState[fieldName].dirty = dirty;
|
|
40366
|
+
draftState[fieldName].hasErrors = errors.length > 0;
|
|
40367
|
+
}
|
|
40368
|
+
});
|
|
40369
|
+
default:
|
|
40370
|
+
return state;
|
|
40371
|
+
}
|
|
40372
|
+
};
|
|
39290
40373
|
|
|
39291
|
-
const createMapDispatchToProps =
|
|
40374
|
+
const createMapDispatchToProps = formConfig => {
|
|
39292
40375
|
// Do memo-ization
|
|
39293
40376
|
let cachedDispatch;
|
|
39294
40377
|
let cacheValue;
|
|
39295
|
-
return
|
|
40378
|
+
return dispatch => {
|
|
39296
40379
|
if (dispatch == cachedDispatch) {
|
|
39297
40380
|
return cacheValue;
|
|
39298
40381
|
}
|
|
@@ -39301,11 +40384,8 @@ const createMapDispatchToProps = (formConfig) => {
|
|
|
39301
40384
|
const keys = Object.keys(formConfig);
|
|
39302
40385
|
for (let fieldName of keys) {
|
|
39303
40386
|
dispatchObj.fields[fieldName] = {
|
|
39304
|
-
set:
|
|
39305
|
-
addValidator:
|
|
39306
|
-
removeValidator: (validator) =>
|
|
39307
|
-
dispatch(removeValidator(fieldName)(validator)),
|
|
39308
|
-
clear: () => dispatch(clearFieldValidators(fieldName)()),
|
|
40387
|
+
set: value => dispatch(set$2(fieldName)(value)),
|
|
40388
|
+
addValidator: validator => dispatch(addValidator(fieldName)(validator))
|
|
39309
40389
|
};
|
|
39310
40390
|
}
|
|
39311
40391
|
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
@@ -39315,22 +40395,14 @@ const createMapDispatchToProps = (formConfig) => {
|
|
|
39315
40395
|
};
|
|
39316
40396
|
};
|
|
39317
40397
|
|
|
39318
|
-
const mapStateToProps =
|
|
40398
|
+
const mapStateToProps = state => ({ fields: state });
|
|
39319
40399
|
|
|
39320
|
-
const createFormState =
|
|
40400
|
+
const createFormState = formConfig => ({
|
|
39321
40401
|
reducer: createFormReducer(formConfig),
|
|
39322
40402
|
mapDispatchToProps: createMapDispatchToProps(formConfig),
|
|
39323
|
-
mapStateToProps: mapStateToProps
|
|
40403
|
+
mapStateToProps: mapStateToProps
|
|
39324
40404
|
});
|
|
39325
40405
|
|
|
39326
|
-
var getIsRequiredFromValidators = function getIsRequiredFromValidators(callbackFn) {
|
|
39327
|
-
return callbackFn(function (field) {
|
|
39328
|
-
return !!field.validators.find(function (validator) {
|
|
39329
|
-
return validator.type === "validator/REQUIRED";
|
|
39330
|
-
});
|
|
39331
|
-
}, []);
|
|
39332
|
-
};
|
|
39333
|
-
|
|
39334
40406
|
var AddressForm = function AddressForm(_ref) {
|
|
39335
40407
|
var _zipErrorMessages;
|
|
39336
40408
|
|
|
@@ -39389,8 +40461,7 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
39389
40461
|
}
|
|
39390
40462
|
},
|
|
39391
40463
|
showErrors: showErrors,
|
|
39392
|
-
dataQa: "Country"
|
|
39393
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.city)
|
|
40464
|
+
dataQa: "Country"
|
|
39394
40465
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
39395
40466
|
labelTextWhenNoError: "Address",
|
|
39396
40467
|
errorMessages: street1ErrorMessages,
|
|
@@ -39401,8 +40472,7 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
39401
40472
|
return e.key === "Enter" && handleSubmit(e);
|
|
39402
40473
|
},
|
|
39403
40474
|
autocompleteValue: "address-line1",
|
|
39404
|
-
dataQa: "Address"
|
|
39405
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.street1)
|
|
40475
|
+
dataQa: "Address"
|
|
39406
40476
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
39407
40477
|
labelTextWhenNoError: "Apt, Suite, Unit, Floor, etc. (Optional)",
|
|
39408
40478
|
field: fields.street2,
|
|
@@ -39412,8 +40482,7 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
39412
40482
|
return e.key === "Enter" && handleSubmit(e);
|
|
39413
40483
|
},
|
|
39414
40484
|
autocompleteValue: "address-line2",
|
|
39415
|
-
dataQa: "Address Line 2"
|
|
39416
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.street2)
|
|
40485
|
+
dataQa: "Address Line 2"
|
|
39417
40486
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
39418
40487
|
labelTextWhenNoError: "City",
|
|
39419
40488
|
errorMessages: cityErrorMessages,
|
|
@@ -39424,8 +40493,7 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
39424
40493
|
return e.key === "Enter" && handleSubmit(e);
|
|
39425
40494
|
},
|
|
39426
40495
|
autocompleteValue: "address-level2",
|
|
39427
|
-
dataQa: "City"
|
|
39428
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.city)
|
|
40496
|
+
dataQa: "City"
|
|
39429
40497
|
}), /*#__PURE__*/React__default.createElement(FormStateDropdown, {
|
|
39430
40498
|
labelTextWhenNoError: isUS ? "State" : "State or Province",
|
|
39431
40499
|
errorMessages: stateProvinceErrorMessages,
|
|
@@ -39436,8 +40504,7 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
39436
40504
|
onKeyDown: function onKeyDown(e) {
|
|
39437
40505
|
return e.key === "Enter" && handleSubmit(e);
|
|
39438
40506
|
},
|
|
39439
|
-
dataQa: "State or Province"
|
|
39440
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.stateProvince)
|
|
40507
|
+
dataQa: "State or Province"
|
|
39441
40508
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
39442
40509
|
isNum: isUS,
|
|
39443
40510
|
formatter: isUS ? zipFormat : null,
|
|
@@ -39450,8 +40517,7 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
39450
40517
|
return e.key === "Enter" && handleSubmit(e);
|
|
39451
40518
|
},
|
|
39452
40519
|
autocompleteValue: "postal-code",
|
|
39453
|
-
dataQa: "Zip code"
|
|
39454
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.zip)
|
|
40520
|
+
dataQa: "Zip code"
|
|
39455
40521
|
}), showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
|
|
39456
40522
|
name: "address checkbox",
|
|
39457
40523
|
title: "Save address to wallet",
|
|
@@ -42199,12 +43265,12 @@ LoginForm.mapDispatchToProps = mapDispatchToProps$5;
|
|
|
42199
43265
|
* This source code is licensed under the MIT license found in the
|
|
42200
43266
|
* LICENSE file in the root directory of this source tree.
|
|
42201
43267
|
*/
|
|
42202
|
-
var b$
|
|
42203
|
-
Symbol.for("react.suspense_list"):60120,r
|
|
42204
|
-
function z
|
|
42205
|
-
var Profiler=g
|
|
42206
|
-
var isMemo=function(a){return z
|
|
42207
|
-
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g
|
|
43268
|
+
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?
|
|
43269
|
+
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;
|
|
43270
|
+
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;
|
|
43271
|
+
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};
|
|
43272
|
+
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};
|
|
43273
|
+
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;
|
|
42208
43274
|
|
|
42209
43275
|
var reactIs_production_min = {
|
|
42210
43276
|
AsyncMode: AsyncMode,
|
|
@@ -42575,14 +43641,14 @@ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
|
42575
43641
|
|
|
42576
43642
|
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
42577
43643
|
|
|
42578
|
-
var has$
|
|
43644
|
+
var has$2 = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
42579
43645
|
|
|
42580
43646
|
var printWarning = function() {};
|
|
42581
43647
|
|
|
42582
43648
|
if (process.env.NODE_ENV !== 'production') {
|
|
42583
43649
|
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
42584
43650
|
var loggedTypeFailures = {};
|
|
42585
|
-
var has$
|
|
43651
|
+
var has$3 = has$2;
|
|
42586
43652
|
|
|
42587
43653
|
printWarning = function(text) {
|
|
42588
43654
|
var message = 'Warning: ' + text;
|
|
@@ -42612,7 +43678,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
42612
43678
|
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
42613
43679
|
if (process.env.NODE_ENV !== 'production') {
|
|
42614
43680
|
for (var typeSpecName in typeSpecs) {
|
|
42615
|
-
if (has$
|
|
43681
|
+
if (has$3(typeSpecs, typeSpecName)) {
|
|
42616
43682
|
var error;
|
|
42617
43683
|
// Prop type validation may throw. In case they do, we don't want to
|
|
42618
43684
|
// fail the render phase where it didn't fail before. So we log it.
|
|
@@ -43011,7 +44077,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
43011
44077
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
43012
44078
|
}
|
|
43013
44079
|
for (var key in propValue) {
|
|
43014
|
-
if (has$
|
|
44080
|
+
if (has$2(propValue, key)) {
|
|
43015
44081
|
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
43016
44082
|
if (error instanceof Error) {
|
|
43017
44083
|
return error;
|
|
@@ -43048,7 +44114,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
43048
44114
|
if (checkerResult == null) {
|
|
43049
44115
|
return null;
|
|
43050
44116
|
}
|
|
43051
|
-
if (checkerResult.data && has$
|
|
44117
|
+
if (checkerResult.data && has$2(checkerResult.data, 'expectedType')) {
|
|
43052
44118
|
expectedTypes.push(checkerResult.data.expectedType);
|
|
43053
44119
|
}
|
|
43054
44120
|
}
|
|
@@ -43108,7 +44174,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
43108
44174
|
var allKeys = objectAssign({}, props[propName], shapeTypes);
|
|
43109
44175
|
for (var key in allKeys) {
|
|
43110
44176
|
var checker = shapeTypes[key];
|
|
43111
|
-
if (has$
|
|
44177
|
+
if (has$2(shapeTypes, key) && typeof checker !== 'function') {
|
|
43112
44178
|
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
43113
44179
|
}
|
|
43114
44180
|
if (!checker) {
|
|
@@ -43846,7 +44912,7 @@ var index_esm = /*#__PURE__*/Object.freeze({
|
|
|
43846
44912
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
43847
44913
|
*/
|
|
43848
44914
|
|
|
43849
|
-
function ownKeys$
|
|
44915
|
+
function ownKeys$3(object, enumerableOnly) {
|
|
43850
44916
|
var keys = Object.keys(object);
|
|
43851
44917
|
|
|
43852
44918
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -43862,9 +44928,9 @@ function ownKeys$2(object, enumerableOnly) {
|
|
|
43862
44928
|
function _objectSpread2$1(target) {
|
|
43863
44929
|
for (var i = 1; i < arguments.length; i++) {
|
|
43864
44930
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
43865
|
-
i % 2 ? ownKeys$
|
|
44931
|
+
i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) {
|
|
43866
44932
|
_defineProperty$1(target, key, source[key]);
|
|
43867
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$
|
|
44933
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) {
|
|
43868
44934
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
43869
44935
|
});
|
|
43870
44936
|
}
|
|
@@ -47889,7 +48955,7 @@ var TermsAndConditions = function TermsAndConditions(_ref) {
|
|
|
47889
48955
|
};
|
|
47890
48956
|
|
|
47891
48957
|
var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
47892
|
-
var _routingNumberErrors,
|
|
48958
|
+
var _routingNumberErrors, _accountNumberErrors;
|
|
47893
48959
|
|
|
47894
48960
|
var _ref$variant = _ref.variant,
|
|
47895
48961
|
variant = _ref$variant === void 0 ? "default" : _ref$variant,
|
|
@@ -47932,9 +48998,12 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
47932
48998
|
var nameErrors = _defineProperty({}, required.error, "Name is required");
|
|
47933
48999
|
|
|
47934
49000
|
var routingNumberErrors = (_routingNumberErrors = {}, _defineProperty(_routingNumberErrors, required.error, "Routing number is required"), _defineProperty(_routingNumberErrors, hasLength.error, "Routing number must be 9 digits"), _defineProperty(_routingNumberErrors, isRoutingNumber.error, "Invalid routing number"), _routingNumberErrors);
|
|
47935
|
-
|
|
49001
|
+
|
|
49002
|
+
var confirmRoutingNumberErrors = _defineProperty({}, matchesField.error, "Confirm routing number field must match routing number");
|
|
49003
|
+
|
|
47936
49004
|
var accountNumberErrors = (_accountNumberErrors = {}, _defineProperty(_accountNumberErrors, required.error, "Account number is required"), _defineProperty(_accountNumberErrors, hasLength.error, "Account number must be between 5 and 17 digits"), _accountNumberErrors);
|
|
47937
|
-
|
|
49005
|
+
|
|
49006
|
+
var confirmAccountNumberErrors = _defineProperty({}, matchesField.error, "Confirm account number field must match account number");
|
|
47938
49007
|
|
|
47939
49008
|
var accountTypeErrors = _defineProperty({}, required.error, "Account type is required");
|
|
47940
49009
|
|
|
@@ -47952,8 +49021,7 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
47952
49021
|
onKeyDown: function onKeyDown(e) {
|
|
47953
49022
|
return e.key === "Enter" && handleSubmit(e);
|
|
47954
49023
|
},
|
|
47955
|
-
autocompleteValue: "name"
|
|
47956
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.name)
|
|
49024
|
+
autocompleteValue: "name"
|
|
47957
49025
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
47958
49026
|
labelTextWhenNoError: "Routing number",
|
|
47959
49027
|
dataQa: "Routing number",
|
|
@@ -47961,7 +49029,6 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
47961
49029
|
field: fields.routingNumber,
|
|
47962
49030
|
fieldActions: actions.fields.routingNumber,
|
|
47963
49031
|
showErrors: showErrors,
|
|
47964
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.routingNumber),
|
|
47965
49032
|
isNum: true,
|
|
47966
49033
|
helperModal: function helperModal() {
|
|
47967
49034
|
return /*#__PURE__*/React__default.createElement(AccountAndRoutingModal$1, {
|
|
@@ -47987,7 +49054,6 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
47987
49054
|
onKeyDown: function onKeyDown(e) {
|
|
47988
49055
|
return e.key === "Enter" && handleSubmit(e);
|
|
47989
49056
|
},
|
|
47990
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.confirmRoutingNumber),
|
|
47991
49057
|
isNum: true
|
|
47992
49058
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
47993
49059
|
labelTextWhenNoError: "Account number",
|
|
@@ -47996,7 +49062,6 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
47996
49062
|
field: fields.accountNumber,
|
|
47997
49063
|
fieldActions: actions.fields.accountNumber,
|
|
47998
49064
|
showErrors: showErrors,
|
|
47999
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.accountNumber),
|
|
48000
49065
|
isNum: true,
|
|
48001
49066
|
helperModal: function helperModal() {
|
|
48002
49067
|
return /*#__PURE__*/React__default.createElement(AccountAndRoutingModal$1, {
|
|
@@ -48022,7 +49087,6 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
48022
49087
|
onKeyDown: function onKeyDown(e) {
|
|
48023
49088
|
return e.key === "Enter" && handleSubmit(e);
|
|
48024
49089
|
},
|
|
48025
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.confirmAccountNumber),
|
|
48026
49090
|
isNum: true
|
|
48027
49091
|
}), allowBankAccountType && /*#__PURE__*/React__default.createElement(FormSelect$1, {
|
|
48028
49092
|
labelTextWhenNoError: "Account type",
|
|
@@ -48040,8 +49104,7 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
48040
49104
|
fieldActions: actions.fields.accountType,
|
|
48041
49105
|
showErrors: showErrors,
|
|
48042
49106
|
errorMessages: accountTypeErrors,
|
|
48043
|
-
field: fields.accountType
|
|
48044
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.accountType)
|
|
49107
|
+
field: fields.accountType
|
|
48045
49108
|
}), !hideDefaultPayment && /*#__PURE__*/React__default.createElement(Checkbox$1, {
|
|
48046
49109
|
title: "Save as Default Payment Method",
|
|
48047
49110
|
dataQa: "default-payment-ach",
|
|
@@ -48077,7 +49140,7 @@ var formConfig$6 = {
|
|
|
48077
49140
|
constraints: [onlyIntegers(), hasLength(0, 9)]
|
|
48078
49141
|
},
|
|
48079
49142
|
confirmRoutingNumber: {
|
|
48080
|
-
validators: [matchesField("routingNumber")
|
|
49143
|
+
validators: [matchesField("routingNumber")],
|
|
48081
49144
|
constraints: [onlyIntegers(), hasLength(0, 9)]
|
|
48082
49145
|
},
|
|
48083
49146
|
accountNumber: {
|
|
@@ -48085,7 +49148,7 @@ var formConfig$6 = {
|
|
|
48085
49148
|
constraints: [onlyIntegers(), hasLength(0, 17)]
|
|
48086
49149
|
},
|
|
48087
49150
|
confirmAccountNumber: {
|
|
48088
|
-
validators: [matchesField("accountNumber")
|
|
49151
|
+
validators: [matchesField("accountNumber")],
|
|
48089
49152
|
constraints: [onlyIntegers(), hasLength(0, 17)]
|
|
48090
49153
|
},
|
|
48091
49154
|
accountType: {
|
|
@@ -48168,8 +49231,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
48168
49231
|
}
|
|
48169
49232
|
},
|
|
48170
49233
|
showErrors: showErrors,
|
|
48171
|
-
dataQa: "Country"
|
|
48172
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.country)
|
|
49234
|
+
dataQa: "Country"
|
|
48173
49235
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
48174
49236
|
labelTextWhenNoError: "Name on card",
|
|
48175
49237
|
dataQa: "Name on card",
|
|
@@ -48180,8 +49242,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
48180
49242
|
onKeyDown: function onKeyDown(e) {
|
|
48181
49243
|
return e.key === "Enter" && handleSubmit(e);
|
|
48182
49244
|
},
|
|
48183
|
-
autocompleteValue: "cc-name"
|
|
48184
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.nameOnCard)
|
|
49245
|
+
autocompleteValue: "cc-name"
|
|
48185
49246
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
48186
49247
|
labelTextWhenNoError: "Credit card number",
|
|
48187
49248
|
dataQa: "Credit card number",
|
|
@@ -48194,8 +49255,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
48194
49255
|
return e.key === "Enter" && handleSubmit(e);
|
|
48195
49256
|
},
|
|
48196
49257
|
isNum: true,
|
|
48197
|
-
autocompleteValue: "cc-number"
|
|
48198
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.creditCardNumber)
|
|
49258
|
+
autocompleteValue: "cc-number"
|
|
48199
49259
|
}), /*#__PURE__*/React__default.createElement(FormInputRow, {
|
|
48200
49260
|
breakpoint: isMobile ? "1000rem" : "21rem",
|
|
48201
49261
|
childGap: isMobile ? "0rem" : "1rem"
|
|
@@ -48213,8 +49273,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
48213
49273
|
isNum: true,
|
|
48214
49274
|
removeFromValue: /\// // removes "/" from browser autofill
|
|
48215
49275
|
,
|
|
48216
|
-
autocompleteValue: "cc-exp"
|
|
48217
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.expirationDate)
|
|
49276
|
+
autocompleteValue: "cc-exp"
|
|
48218
49277
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
48219
49278
|
labelTextWhenNoError: "CVV",
|
|
48220
49279
|
dataQa: "CVV",
|
|
@@ -48227,8 +49286,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
48227
49286
|
onKeyDown: function onKeyDown(e) {
|
|
48228
49287
|
return e.key === "Enter" && handleSubmit(e);
|
|
48229
49288
|
},
|
|
48230
|
-
autocompleteValue: "cc-csc"
|
|
48231
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.cvv)
|
|
49289
|
+
autocompleteValue: "cc-csc"
|
|
48232
49290
|
})), !hideZipCode && /*#__PURE__*/React__default.createElement(Box, {
|
|
48233
49291
|
padding: isMobile ? "0" : "0 0.5rem 0 0",
|
|
48234
49292
|
width: isMobile ? "100%" : "50%"
|
|
@@ -48244,8 +49302,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
48244
49302
|
onKeyDown: function onKeyDown(e) {
|
|
48245
49303
|
return e.key === "Enter" && handleSubmit(e);
|
|
48246
49304
|
},
|
|
48247
|
-
autocompleteValue: "billing postal-code"
|
|
48248
|
-
isRequired: getIsRequiredFromValidators(React.useCallback)(fields.zipCode)
|
|
49305
|
+
autocompleteValue: "billing postal-code"
|
|
48249
49306
|
})), (showWalletCheckbox || showTerms) && /*#__PURE__*/React__default.createElement(Cluster, {
|
|
48250
49307
|
childGap: "4px",
|
|
48251
49308
|
align: "center"
|
|
@@ -48676,8 +49733,7 @@ var RadioSection = function RadioSection(_ref) {
|
|
|
48676
49733
|
extraStyles: borderStyles,
|
|
48677
49734
|
role: "radio",
|
|
48678
49735
|
"aria-checked": openSection === section.id,
|
|
48679
|
-
disabled: section.disabled
|
|
48680
|
-
required: section === null || section === void 0 ? void 0 : section.required
|
|
49736
|
+
"aria-disabled": section.disabled
|
|
48681
49737
|
}, /*#__PURE__*/React__default.createElement(Stack, {
|
|
48682
49738
|
childGap: "0"
|
|
48683
49739
|
}, /*#__PURE__*/React__default.createElement(Box, {
|
|
@@ -48707,8 +49763,6 @@ var RadioSection = function RadioSection(_ref) {
|
|
|
48707
49763
|
}, !section.hideRadioButton && /*#__PURE__*/React__default.createElement(Box, {
|
|
48708
49764
|
padding: "0"
|
|
48709
49765
|
}, /*#__PURE__*/React__default.createElement(RadioButton$2, {
|
|
48710
|
-
role: "radio",
|
|
48711
|
-
required: !!(section !== null && section !== void 0 && section.required),
|
|
48712
49766
|
id: "radio-input-".concat(idString(section)),
|
|
48713
49767
|
name: idString(section),
|
|
48714
49768
|
ariaDescribedBy: ariaDescribedBy,
|