@thecb/components 9.1.0-beta.6 → 9.1.0-beta.8
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 +267 -1360
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.esm.js +267 -1360
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/alert/Alert.js +7 -3
- package/src/components/atoms/dropdown/Dropdown.js +5 -5
- package/src/components/atoms/form-layouts/FormInput.js +1 -1
- package/src/components/atoms/form-layouts/index.d.ts +1 -1
- package/src/components/atoms/form-select/FormSelect.js +4 -2
- package/src/components/atoms/form-select/FormSelect.stories.js +8 -4
- package/src/components/atoms/form-select/index.d.ts +2 -1
- package/src/components/atoms/icons/icons.stories.js +0 -2
- package/src/components/atoms/layouts/Box.d.ts +1 -0
- package/src/components/atoms/layouts/Box.js +2 -0
- package/src/components/atoms/line-item/LineItem.js +6 -12
- package/src/components/atoms/searchable-select/SearchableSelect.js +2 -0
- package/src/components/atoms/searchable-select/SearchableSelect.stories.js +61 -0
- package/src/components/atoms/searchable-select/index.d.ts +1 -0
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +2 -3
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +1 -0
- package/src/components/molecules/address-form/AddressForm.js +1 -2
- package/src/components/molecules/partial-amount-form/PartialAmountForm.js +0 -2
- package/src/components/molecules/partial-amount-form/PartialAmountForm.state.js +0 -2
- package/src/components/molecules/phone-form/PhoneForm.js +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -6530,7 +6530,7 @@ var BoxWrapper = styled__default(function (_ref) {
|
|
|
6530
6530
|
});
|
|
6531
6531
|
/* eslint-enable no-unused-vars */
|
|
6532
6532
|
|
|
6533
|
-
var _excluded$3 = ["padding", "borderSize", "borderColor", "borderRadius", "boxShadow", "background", "color", "minHeight", "width", "minWidth", "maxWidth", "borderWidthOverride", "border", "textAlign", "hoverStyles", "activeStyles", "disabledStyles", "variant", "as", "onClick", "onKeyDown", "onMouseEnter", "onMouseLeave", "onFocus", "onBlur", "onTouchEnd", "theme", "hiddenStyles", "extraStyles", "srOnly", "dataQa", "children"];
|
|
6533
|
+
var _excluded$3 = ["autocompleteValue", "padding", "borderSize", "borderColor", "borderRadius", "boxShadow", "background", "color", "minHeight", "width", "minWidth", "maxWidth", "borderWidthOverride", "border", "textAlign", "hoverStyles", "activeStyles", "disabledStyles", "variant", "as", "onClick", "onKeyDown", "onMouseEnter", "onMouseLeave", "onFocus", "onBlur", "onTouchEnd", "theme", "hiddenStyles", "extraStyles", "srOnly", "dataQa", "children"];
|
|
6534
6534
|
/*
|
|
6535
6535
|
Box component to create generic boxes
|
|
6536
6536
|
Supply padding, border, background, and color values
|
|
@@ -6540,7 +6540,8 @@ var _excluded$3 = ["padding", "borderSize", "borderColor", "borderRadius", "boxS
|
|
|
6540
6540
|
*/
|
|
6541
6541
|
|
|
6542
6542
|
var Box = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
6543
|
-
var
|
|
6543
|
+
var autocompleteValue = _ref.autocompleteValue,
|
|
6544
|
+
_ref$padding = _ref.padding,
|
|
6544
6545
|
padding = _ref$padding === void 0 ? "16px" : _ref$padding,
|
|
6545
6546
|
_ref$borderSize = _ref.borderSize,
|
|
6546
6547
|
borderSize = _ref$borderSize === void 0 ? "0px" : _ref$borderSize,
|
|
@@ -6580,6 +6581,7 @@ var Box = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
6580
6581
|
rest = _objectWithoutProperties(_ref, _excluded$3);
|
|
6581
6582
|
|
|
6582
6583
|
return /*#__PURE__*/React__default.createElement(BoxWrapper, _extends({
|
|
6584
|
+
autoComplete: autocompleteValue,
|
|
6583
6585
|
padding: padding,
|
|
6584
6586
|
borderSize: borderSize,
|
|
6585
6587
|
borderColor: borderColor,
|
|
@@ -18762,7 +18764,13 @@ var Alert = function Alert(_ref) {
|
|
|
18762
18764
|
_ref$iconPadding = _ref.iconPadding,
|
|
18763
18765
|
iconPadding = _ref$iconPadding === void 0 ? "0 0 0 1rem" : _ref$iconPadding,
|
|
18764
18766
|
_ref$contentFullHeigh = _ref.contentFullHeight,
|
|
18765
|
-
contentFullHeight = _ref$contentFullHeigh === void 0 ? false : _ref$contentFullHeigh
|
|
18767
|
+
contentFullHeight = _ref$contentFullHeigh === void 0 ? false : _ref$contentFullHeigh,
|
|
18768
|
+
_ref$ariaRole = _ref.ariaRole,
|
|
18769
|
+
ariaRole = _ref$ariaRole === void 0 ? null : _ref$ariaRole,
|
|
18770
|
+
_ref$ariaAtomic = _ref.ariaAtomic,
|
|
18771
|
+
ariaAtomic = _ref$ariaAtomic === void 0 ? true : _ref$ariaAtomic,
|
|
18772
|
+
_ref$ariaLive = _ref.ariaLive,
|
|
18773
|
+
ariaLive = _ref$ariaLive === void 0 ? "polite" : _ref$ariaLive;
|
|
18766
18774
|
var Icon = AlertIcons[variant];
|
|
18767
18775
|
var contentPadding = maxContentWidth ? "".concat(padding, " 1rem") : innerContentPadding;
|
|
18768
18776
|
var content = /*#__PURE__*/React__default.createElement(Sidebar, {
|
|
@@ -18808,7 +18816,7 @@ var Alert = function Alert(_ref) {
|
|
|
18808
18816
|
minHeight: "100%",
|
|
18809
18817
|
onClick: onLinkClick
|
|
18810
18818
|
}, /*#__PURE__*/React__default.createElement(IconQuit, null))))));
|
|
18811
|
-
return /*#__PURE__*/React__default.createElement(Box, {
|
|
18819
|
+
return /*#__PURE__*/React__default.createElement(Box, _extends({
|
|
18812
18820
|
padding: padding,
|
|
18813
18821
|
width: "100%",
|
|
18814
18822
|
minHeight: height && parseInt(height) < 100 ? height : "100px",
|
|
@@ -18819,9 +18827,12 @@ var Alert = function Alert(_ref) {
|
|
|
18819
18827
|
borderSize: noBorder ? "0px" : "1px",
|
|
18820
18828
|
boxShadow: enableBoxShadow ? (_generateShadows = generateShadows()) === null || _generateShadows === void 0 ? void 0 : (_generateShadows$inse = _generateShadows.inset) === null || _generateShadows$inse === void 0 ? void 0 : _generateShadows$inse.base : "",
|
|
18821
18829
|
extraStyles: extraStyles,
|
|
18822
|
-
|
|
18823
|
-
|
|
18824
|
-
|
|
18830
|
+
"aria-live": ariaLive
|
|
18831
|
+
}, ariaAtomic !== null ? {
|
|
18832
|
+
"aria-atomic": ariaAtomic
|
|
18833
|
+
} : {}, ariaRole !== null ? {
|
|
18834
|
+
role: ariaRole
|
|
18835
|
+
} : {}), maxContentWidth ? /*#__PURE__*/React__default.createElement(Center, {
|
|
18825
18836
|
maxWidth: maxContentWidth
|
|
18826
18837
|
}, content) : content);
|
|
18827
18838
|
};
|
|
@@ -23749,8 +23760,7 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
23749
23760
|
autoEraseTypeAhead = _ref8$autoEraseTypeAh === void 0 ? true : _ref8$autoEraseTypeAh,
|
|
23750
23761
|
ariaLabelledby = _ref8.ariaLabelledby,
|
|
23751
23762
|
ariaDescribedby = _ref8.ariaDescribedby,
|
|
23752
|
-
|
|
23753
|
-
autocompleteValue = _ref8$autocompleteVal === void 0 ? null : _ref8$autocompleteVal,
|
|
23763
|
+
autocompleteValue = _ref8.autocompleteValue,
|
|
23754
23764
|
_ref8$smoothScroll = _ref8.smoothScroll,
|
|
23755
23765
|
smoothScroll = _ref8$smoothScroll === void 0 ? true : _ref8$smoothScroll,
|
|
23756
23766
|
_ref8$ariaInvalid = _ref8.ariaInvalid,
|
|
@@ -24079,7 +24089,7 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
24079
24089
|
}, /*#__PURE__*/React__default.createElement(Text$1, {
|
|
24080
24090
|
variant: "p",
|
|
24081
24091
|
color: choice.value === value ? WHITE : disabledValues.includes(choice.value) ? STORM_GREY : MINESHAFT_GREY,
|
|
24082
|
-
extraStyles: "padding-left: 16px
|
|
24092
|
+
extraStyles: "padding-left: 16px;\n cursor: ".concat(disabledValues.includes(choice.value) ? "default" : "pointer", ";\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;")
|
|
24083
24093
|
}, choice.text));
|
|
24084
24094
|
}))) : /*#__PURE__*/React__default.createElement(React.Fragment, null)));
|
|
24085
24095
|
};
|
|
@@ -24183,12 +24193,13 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
24183
24193
|
themeValues = _ref.themeValues,
|
|
24184
24194
|
_ref$hasTitles = _ref.hasTitles,
|
|
24185
24195
|
hasTitles = _ref$hasTitles === void 0 ? false : _ref$hasTitles,
|
|
24186
|
-
|
|
24187
|
-
autocompleteValue = _ref$autocompleteValu === void 0 ? null : _ref$autocompleteValu,
|
|
24196
|
+
autocompleteValue = _ref.autocompleteValue,
|
|
24188
24197
|
_ref$smoothScroll = _ref.smoothScroll,
|
|
24189
24198
|
smoothScroll = _ref$smoothScroll === void 0 ? true : _ref$smoothScroll,
|
|
24190
24199
|
_ref$dataQa = _ref.dataQa,
|
|
24191
|
-
dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa
|
|
24200
|
+
dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa,
|
|
24201
|
+
_ref$widthFitOptions = _ref.widthFitOptions,
|
|
24202
|
+
widthFitOptions = _ref$widthFitOptions === void 0 ? false : _ref$widthFitOptions;
|
|
24192
24203
|
|
|
24193
24204
|
var _useState = React.useState(false),
|
|
24194
24205
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -24231,6 +24242,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
24231
24242
|
ariaLabelledby: createIdFromString(labelTextWhenNoError),
|
|
24232
24243
|
ariaDescribedby: createIdFromString(labelTextWhenNoError, "error message"),
|
|
24233
24244
|
maxHeight: dropdownMaxHeight,
|
|
24245
|
+
widthFitOptions: widthFitOptions,
|
|
24234
24246
|
hasTitles: hasTitles,
|
|
24235
24247
|
placeholder: options[0] ? options[0].text : "",
|
|
24236
24248
|
options: options,
|
|
@@ -25956,8 +25968,7 @@ var FormInput = function FormInput(_ref15) {
|
|
|
25956
25968
|
themeValues = _ref15.themeValues,
|
|
25957
25969
|
background = _ref15.background,
|
|
25958
25970
|
customHeight = _ref15.customHeight,
|
|
25959
|
-
|
|
25960
|
-
autocompleteValue = _ref15$autocompleteVa === void 0 ? null : _ref15$autocompleteVa,
|
|
25971
|
+
autocompleteValue = _ref15.autocompleteValue,
|
|
25961
25972
|
extraStyles = _ref15.extraStyles,
|
|
25962
25973
|
removeFromValue = _ref15.removeFromValue,
|
|
25963
25974
|
_ref15$dataQa = _ref15.dataQa,
|
|
@@ -26627,12 +26638,11 @@ var LineItem = function LineItem(_ref) {
|
|
|
26627
26638
|
return visibleFields.includes(attr.key) && attr.key !== "description";
|
|
26628
26639
|
})) === null || _customAttributes$fil === void 0 ? void 0 : _customAttributes$fil.map(function (attr) {
|
|
26629
26640
|
return /*#__PURE__*/React__default.createElement(Paragraph$1, {
|
|
26630
|
-
variant:
|
|
26641
|
+
variant: "pS",
|
|
26631
26642
|
weight: "400",
|
|
26632
|
-
key: attr.key
|
|
26633
|
-
|
|
26634
|
-
|
|
26635
|
-
}, "".concat(formatAttrKeys(attr.key), ":")), /*#__PURE__*/React__default.createElement(Text$1, null, " ".concat(attr.value)));
|
|
26643
|
+
key: attr.key,
|
|
26644
|
+
color: STORM_GREY
|
|
26645
|
+
}, "".concat(formatAttrKeys(attr.key), ": ").concat(attr.value));
|
|
26636
26646
|
});
|
|
26637
26647
|
return /*#__PURE__*/React__default.createElement(Cluster, {
|
|
26638
26648
|
nowrap: true,
|
|
@@ -26647,7 +26657,7 @@ var LineItem = function LineItem(_ref) {
|
|
|
26647
26657
|
variant: themeValues.paragraphVariant,
|
|
26648
26658
|
weight: "400"
|
|
26649
26659
|
}, subDescription), visibleCustomAttrs && /*#__PURE__*/React__default.createElement(Stack, {
|
|
26650
|
-
childGap: "0"
|
|
26660
|
+
childGap: "0.25rem"
|
|
26651
26661
|
}, visibleCustomAttrs)), !!displayQuantity && /*#__PURE__*/React__default.createElement(Paragraph$1, {
|
|
26652
26662
|
variant: themeValues.paragraphVariant,
|
|
26653
26663
|
weight: themeValues.weightTitle
|
|
@@ -27339,7 +27349,8 @@ var fallbackValues$w = {
|
|
|
27339
27349
|
var SELECT_ALL = "Select All";
|
|
27340
27350
|
|
|
27341
27351
|
var SearchableSelect = function SearchableSelect(_ref) {
|
|
27342
|
-
var
|
|
27352
|
+
var autocompleteValue = _ref.autocompleteValue,
|
|
27353
|
+
items = _ref.items,
|
|
27343
27354
|
selectedItems = _ref.selectedItems,
|
|
27344
27355
|
allSelected = _ref.allSelected,
|
|
27345
27356
|
toggleSelectAllItems = _ref.toggleSelectAllItems,
|
|
@@ -27381,6 +27392,7 @@ var SearchableSelect = function SearchableSelect(_ref) {
|
|
|
27381
27392
|
border: themeValues.border,
|
|
27382
27393
|
extraStyles: disabled && "color: #6e727e; background-color: #f7f7f7; pointer-events: none;"
|
|
27383
27394
|
}, /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
27395
|
+
autocompleteValue: autocompleteValue,
|
|
27384
27396
|
errorMessages: {},
|
|
27385
27397
|
field: fields.searchTerm,
|
|
27386
27398
|
fieldActions: actions.fields.searchTerm,
|
|
@@ -37998,9 +38010,7 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
|
|
|
37998
38010
|
field = _ref.field,
|
|
37999
38011
|
fieldActions = _ref.fieldActions,
|
|
38000
38012
|
showErrors = _ref.showErrors,
|
|
38001
|
-
countryCode = _ref.countryCode
|
|
38002
|
-
_ref$autocompleteValu = _ref.autocompleteValue,
|
|
38003
|
-
autocompleteValue = _ref$autocompleteValu === void 0 ? null : _ref$autocompleteValu;
|
|
38013
|
+
countryCode = _ref.countryCode;
|
|
38004
38014
|
var placeholder = countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
|
|
38005
38015
|
var options = [placeholder].concat(_toConsumableArray(getOptions(countryCode)));
|
|
38006
38016
|
return /*#__PURE__*/React__default.createElement(FormSelect$1, {
|
|
@@ -38010,7 +38020,7 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
|
|
|
38010
38020
|
labelTextWhenNoError: labelTextWhenNoError,
|
|
38011
38021
|
errorMessages: errorMessages,
|
|
38012
38022
|
showErrors: showErrors,
|
|
38013
|
-
autocompleteValue:
|
|
38023
|
+
autocompleteValue: "address-level1"
|
|
38014
38024
|
});
|
|
38015
38025
|
};
|
|
38016
38026
|
|
|
@@ -38634,44 +38644,52 @@ var TableHeading_styled = styled__default.th.withConfig({
|
|
|
38634
38644
|
return extraStyles;
|
|
38635
38645
|
});
|
|
38636
38646
|
|
|
38637
|
-
const validatorToPredicate =
|
|
38638
|
-
|
|
38639
|
-
...rest
|
|
38640
|
-
|
|
38647
|
+
const validatorToPredicate =
|
|
38648
|
+
(validatorFn, emptyCase) =>
|
|
38649
|
+
(value, ...rest) =>
|
|
38650
|
+
value === '' ? emptyCase : validatorFn(value, ...rest);
|
|
38641
38651
|
|
|
38642
38652
|
var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
38643
38653
|
|
|
38654
|
+
function getDefaultExportFromCjs (x) {
|
|
38655
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
38656
|
+
}
|
|
38657
|
+
|
|
38644
38658
|
var dayjs_min = {exports: {}};
|
|
38645
38659
|
|
|
38646
38660
|
(function (module, exports) {
|
|
38647
|
-
!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"
|
|
38648
|
-
}(dayjs_min));
|
|
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",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p=function(t){return t instanceof _},S=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return O},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),l=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(h){case c:return r?l(1,0):l(31,11);case f:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,l=this;r=Number(r);var $=O.p(h),y=function(t){var e=w(l);return O.w(e.date(e.date()+Math.round(t*r)),l)};if($===f)return this.set(f,this.$M+r);if($===c)return this.set(c,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},$={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||$[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,v=this-M,g=O.m(this,M);return g=($={},$[c]=g/12,$[f]=g,$[h]=g/3,$[o]=(v-m)/6048e5,$[a]=(v-m)/864e5,$[u]=v/n,$[s]=v/e,$[i]=v/t,$)[y]||v,l?g:O.a(g)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[g],w.Ls=D,w.p={},w}));
|
|
38662
|
+
} (dayjs_min));
|
|
38649
38663
|
|
|
38650
|
-
var
|
|
38664
|
+
var dayjs_minExports = dayjs_min.exports;
|
|
38665
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
38651
38666
|
|
|
38652
38667
|
var customParseFormat$1 = {exports: {}};
|
|
38653
38668
|
|
|
38654
38669
|
(function (module, exports) {
|
|
38655
|
-
!function(t
|
|
38656
|
-
}(customParseFormat$1));
|
|
38670
|
+
!function(e,t){module.exports=t();}(commonjsGlobal$1,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
|
|
38671
|
+
} (customParseFormat$1));
|
|
38657
38672
|
|
|
38658
|
-
var
|
|
38673
|
+
var customParseFormatExports = customParseFormat$1.exports;
|
|
38674
|
+
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
38659
38675
|
|
|
38660
38676
|
var isSameOrBefore$1 = {exports: {}};
|
|
38661
38677
|
|
|
38662
38678
|
(function (module, exports) {
|
|
38663
|
-
!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)};}}));
|
|
38664
|
-
}(isSameOrBefore$1));
|
|
38679
|
+
!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)};}}));
|
|
38680
|
+
} (isSameOrBefore$1));
|
|
38665
38681
|
|
|
38666
|
-
var
|
|
38682
|
+
var isSameOrBeforeExports = isSameOrBefore$1.exports;
|
|
38683
|
+
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);
|
|
38667
38684
|
|
|
38668
38685
|
var isSameOrAfter$1 = {exports: {}};
|
|
38669
38686
|
|
|
38670
38687
|
(function (module, exports) {
|
|
38671
|
-
!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)};}}));
|
|
38672
|
-
}(isSameOrAfter$1));
|
|
38688
|
+
!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)};}}));
|
|
38689
|
+
} (isSameOrAfter$1));
|
|
38673
38690
|
|
|
38674
|
-
var
|
|
38691
|
+
var isSameOrAfterExports = isSameOrAfter$1.exports;
|
|
38692
|
+
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);
|
|
38675
38693
|
|
|
38676
38694
|
/* eslint-disable no-unused-vars */
|
|
38677
38695
|
|
|
@@ -38687,24 +38705,24 @@ dayjs.extend(isSameOrAfter);
|
|
|
38687
38705
|
|
|
38688
38706
|
let validatorFns = {};
|
|
38689
38707
|
|
|
38690
|
-
const INCLUDED_IN =
|
|
38691
|
-
const INCLUDED_IN_ERROR =
|
|
38708
|
+
const INCLUDED_IN = 'validator/INCLUDED_IN';
|
|
38709
|
+
const INCLUDED_IN_ERROR = 'error/INCLUDED_IN';
|
|
38692
38710
|
const includedIn = createValidator(INCLUDED_IN, INCLUDED_IN_ERROR);
|
|
38693
38711
|
validatorFns[INCLUDED_IN] = (value, args, form) =>
|
|
38694
38712
|
Array.isArray(args[0]) ? args[0].includes(value) : args[0] === value;
|
|
38695
38713
|
|
|
38696
|
-
const REQUIRED =
|
|
38697
|
-
const REQUIRED_ERROR =
|
|
38714
|
+
const REQUIRED = 'validator/REQUIRED';
|
|
38715
|
+
const REQUIRED_ERROR = 'error/REQUIRED';
|
|
38698
38716
|
const required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
38699
|
-
validatorFns[REQUIRED] = (value, args, form) => value !==
|
|
38717
|
+
validatorFns[REQUIRED] = (value, args, form) => value !== '';
|
|
38700
38718
|
|
|
38701
|
-
const ONLY_INTEGERS =
|
|
38702
|
-
const ONLY_INTEGERS_ERROR =
|
|
38719
|
+
const ONLY_INTEGERS = 'validator/ONLY_INTEGERS';
|
|
38720
|
+
const ONLY_INTEGERS_ERROR = 'error/ONLY_INTEGERS';
|
|
38703
38721
|
const onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
38704
38722
|
validatorFns[ONLY_INTEGERS] = (value, args, form) => /^(-?\d+)?$/.test(value);
|
|
38705
38723
|
|
|
38706
|
-
const ONLY_NATURALS =
|
|
38707
|
-
const ONLY_NATURALS_ERROR =
|
|
38724
|
+
const ONLY_NATURALS = 'validator/ONLY_NATURALS';
|
|
38725
|
+
const ONLY_NATURALS_ERROR = 'error/ONLY_NATURALS';
|
|
38708
38726
|
const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
38709
38727
|
validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
|
|
38710
38728
|
|
|
@@ -38717,8 +38735,8 @@ not tested as validation function
|
|
|
38717
38735
|
to validate exp date instead use combo of:
|
|
38718
38736
|
required(), hasLength(), isValidMonth(), dateAfterToday()
|
|
38719
38737
|
*/
|
|
38720
|
-
const ONLY_EXPIRATION_DATE =
|
|
38721
|
-
const ONLY_EXPIRATION_DATE_ERROR =
|
|
38738
|
+
const ONLY_EXPIRATION_DATE = 'validator/ONLY_EXPIRATION_DATE';
|
|
38739
|
+
const ONLY_EXPIRATION_DATE_ERROR = 'error/ONLY_EXPIRATION_DATE';
|
|
38722
38740
|
const onlyExpirationDate = createValidator(
|
|
38723
38741
|
ONLY_EXPIRATION_DATE,
|
|
38724
38742
|
ONLY_EXPIRATION_DATE_ERROR
|
|
@@ -38726,64 +38744,63 @@ const onlyExpirationDate = createValidator(
|
|
|
38726
38744
|
validatorFns[ONLY_EXPIRATION_DATE] = (value, args, form) =>
|
|
38727
38745
|
/^(\d?\d?\/?\d?\d?)?$/.test(value);
|
|
38728
38746
|
|
|
38729
|
-
const NUMBER_LESS_THAN =
|
|
38730
|
-
const NUMBER_LESS_THAN_ERROR =
|
|
38747
|
+
const NUMBER_LESS_THAN = 'validator/NUMBER_LESS_THAN';
|
|
38748
|
+
const NUMBER_LESS_THAN_ERROR = 'error/NUMBER_LESS_THAN';
|
|
38731
38749
|
const numberLessThan = createValidator(
|
|
38732
38750
|
NUMBER_LESS_THAN,
|
|
38733
38751
|
NUMBER_LESS_THAN_ERROR
|
|
38734
38752
|
);
|
|
38735
38753
|
validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
38736
|
-
if (value ===
|
|
38754
|
+
if (value === '') {
|
|
38737
38755
|
return true;
|
|
38738
38756
|
}
|
|
38739
38757
|
return Number(value) < args[0];
|
|
38740
38758
|
};
|
|
38741
38759
|
|
|
38742
|
-
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
38743
|
-
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
38760
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO = 'validator/NUMBER_LESS_THAN_OR_EQUAL_TO';
|
|
38744
38761
|
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
38745
|
-
|
|
38762
|
+
'error/NUMBER_LESS_THAN_OR_EQUAL_TO';
|
|
38746
38763
|
const numberLessThanOrEqualTo = createValidator(
|
|
38747
38764
|
NUMBER_LESS_THAN_OR_EQUAL_TO,
|
|
38748
38765
|
NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR
|
|
38749
38766
|
);
|
|
38750
38767
|
validatorFns[NUMBER_LESS_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38751
|
-
if (value ===
|
|
38768
|
+
if (value === '') {
|
|
38752
38769
|
return true;
|
|
38753
38770
|
}
|
|
38754
38771
|
return Number(value) <= args[0];
|
|
38755
38772
|
};
|
|
38756
38773
|
|
|
38757
|
-
const NUMBER_GREATER_THAN =
|
|
38758
|
-
const NUMBER_GREATER_THAN_ERROR =
|
|
38774
|
+
const NUMBER_GREATER_THAN = 'validator/NUMBER_GREATER_THAN';
|
|
38775
|
+
const NUMBER_GREATER_THAN_ERROR = 'error/NUMBER_GREATER_THAN';
|
|
38759
38776
|
const numberGreaterThan = createValidator(
|
|
38760
38777
|
NUMBER_GREATER_THAN,
|
|
38761
38778
|
NUMBER_GREATER_THAN_ERROR
|
|
38762
38779
|
);
|
|
38763
38780
|
validatorFns[NUMBER_GREATER_THAN] = (value, args, form) => {
|
|
38764
|
-
if (value ===
|
|
38781
|
+
if (value === '') {
|
|
38765
38782
|
return true;
|
|
38766
38783
|
}
|
|
38767
38784
|
return Number(value) > args[0];
|
|
38768
38785
|
};
|
|
38769
38786
|
|
|
38770
38787
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO =
|
|
38771
|
-
|
|
38788
|
+
'validator/NUMBER_GREATER_THAN_OR_EQUAL_TO';
|
|
38772
38789
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR =
|
|
38773
|
-
|
|
38790
|
+
'error/NUMBER_GREATER_THAN_OR_EQUAL_TO';
|
|
38774
38791
|
const numberGreaterThanOrEqualTo = createValidator(
|
|
38775
38792
|
NUMBER_GREATER_THAN_OR_EQUAL_TO,
|
|
38776
38793
|
NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR
|
|
38777
38794
|
);
|
|
38778
38795
|
validatorFns[NUMBER_GREATER_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38779
|
-
if (value ===
|
|
38796
|
+
if (value === '') {
|
|
38780
38797
|
return true;
|
|
38781
38798
|
}
|
|
38782
38799
|
return Number(value) >= args[0];
|
|
38783
38800
|
};
|
|
38784
38801
|
|
|
38785
|
-
const MATCHES_FIELD =
|
|
38786
|
-
const MATCHES_FIELD_ERROR$1 =
|
|
38802
|
+
const MATCHES_FIELD = 'validator/MATCHES_FIELD';
|
|
38803
|
+
const MATCHES_FIELD_ERROR$1 = 'error/MATCHES_FIELD';
|
|
38787
38804
|
const matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
|
|
38788
38805
|
validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
38789
38806
|
const dependentField = form[args[0]];
|
|
@@ -38796,7 +38813,7 @@ validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
|
38796
38813
|
return value === dependentFieldValue;
|
|
38797
38814
|
};
|
|
38798
38815
|
|
|
38799
|
-
const validateWhenErrorMessage = type =>
|
|
38816
|
+
const validateWhenErrorMessage = (type) =>
|
|
38800
38817
|
`${type} was passed to validateWhen, but that validator type does not exist.
|
|
38801
38818
|
Please check that you are only calling validator creator functions exported from
|
|
38802
38819
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -38804,25 +38821,21 @@ const validateWhenErrorMessage = type =>
|
|
|
38804
38821
|
createFormState). Also make sure you aren't passing validateWhen() to validateWhen
|
|
38805
38822
|
as the primary validator.`;
|
|
38806
38823
|
|
|
38807
|
-
const VALIDATE_WHEN =
|
|
38808
|
-
const VALIDATE_WHEN_ERROR =
|
|
38809
|
-
const validateWhen = (
|
|
38810
|
-
dependentValidator,
|
|
38811
|
-
primaryValidator,
|
|
38812
|
-
optionalFieldName
|
|
38813
|
-
) => ({
|
|
38824
|
+
const VALIDATE_WHEN = 'validator/VALIDATE_WHEN';
|
|
38825
|
+
const VALIDATE_WHEN_ERROR = 'error/VALIDATE_WHEN';
|
|
38826
|
+
const validateWhen = (dependentValidator, primaryValidator, optionalFieldName) => ({
|
|
38814
38827
|
type: VALIDATE_WHEN,
|
|
38815
38828
|
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
38816
|
-
error: dependentValidator.error
|
|
38829
|
+
error: dependentValidator.error,
|
|
38817
38830
|
});
|
|
38818
38831
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
38819
38832
|
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
38820
38833
|
const [dependentValidator, primaryValidator, optionalFieldName] = args;
|
|
38821
|
-
const dependsOnOtherField = typeof optionalFieldName ===
|
|
38834
|
+
const dependsOnOtherField = typeof optionalFieldName === 'string';
|
|
38822
38835
|
|
|
38823
38836
|
if (
|
|
38824
38837
|
primaryValidator.type === undefined ||
|
|
38825
|
-
typeof validatorFns[primaryValidator.type] !==
|
|
38838
|
+
typeof validatorFns[primaryValidator.type] !== 'function'
|
|
38826
38839
|
) {
|
|
38827
38840
|
throw new Error(validateWhenErrorMessage(primaryValidator.type));
|
|
38828
38841
|
}
|
|
@@ -38846,26 +38859,22 @@ validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
|
38846
38859
|
);
|
|
38847
38860
|
|
|
38848
38861
|
return primaryPredicatePassed
|
|
38849
|
-
? validatorFns[dependentValidator.type](
|
|
38850
|
-
value,
|
|
38851
|
-
dependentValidator.args,
|
|
38852
|
-
form
|
|
38853
|
-
)
|
|
38862
|
+
? validatorFns[dependentValidator.type](value, dependentValidator.args, form)
|
|
38854
38863
|
: true;
|
|
38855
38864
|
};
|
|
38856
38865
|
|
|
38857
|
-
const validateSumErrorMessage = type =>
|
|
38866
|
+
const validateSumErrorMessage = (type) =>
|
|
38858
38867
|
`${type} was passed to validateSum, but that validator type does not exist.
|
|
38859
38868
|
Please check that you are only calling validator creator functions exported from
|
|
38860
38869
|
redux-freeform in your form config and that you didn't forget to
|
|
38861
38870
|
invoke the validator creator (you cannot pass the functions themselves to
|
|
38862
38871
|
createFormState).`;
|
|
38863
|
-
const VALIDATE_SUM =
|
|
38864
|
-
const VALIDATE_SUM_ERROR =
|
|
38872
|
+
const VALIDATE_SUM = 'validator/VALIDATE_SUM';
|
|
38873
|
+
const VALIDATE_SUM_ERROR = 'error/VALIDATE_SUM';
|
|
38865
38874
|
const validateSum = (validator, fieldNamesArray) => ({
|
|
38866
38875
|
type: VALIDATE_SUM,
|
|
38867
38876
|
args: [validator, fieldNamesArray],
|
|
38868
|
-
error: validator.error
|
|
38877
|
+
error: validator.error,
|
|
38869
38878
|
});
|
|
38870
38879
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
38871
38880
|
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
@@ -38873,7 +38882,7 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38873
38882
|
|
|
38874
38883
|
if (
|
|
38875
38884
|
validator.type === undefined ||
|
|
38876
|
-
typeof validatorFns[validator.type] !==
|
|
38885
|
+
typeof validatorFns[validator.type] !== 'function'
|
|
38877
38886
|
) {
|
|
38878
38887
|
throw new Error(validateSumErrorMessage(validator.type));
|
|
38879
38888
|
}
|
|
@@ -38894,37 +38903,35 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38894
38903
|
return validatorFns[validator.type](sum, validator.args, form);
|
|
38895
38904
|
};
|
|
38896
38905
|
|
|
38897
|
-
const HAS_LENGTH =
|
|
38898
|
-
const HAS_LENGTH_ERROR =
|
|
38906
|
+
const HAS_LENGTH = 'validator/HAS_LENGTH';
|
|
38907
|
+
const HAS_LENGTH_ERROR = 'error/HAS_LENGTH';
|
|
38899
38908
|
const hasLength = createValidator(HAS_LENGTH, HAS_LENGTH_ERROR);
|
|
38900
38909
|
validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
38901
|
-
if (value ===
|
|
38910
|
+
if (value === '') {
|
|
38902
38911
|
return true;
|
|
38903
38912
|
}
|
|
38904
38913
|
const min = args[0];
|
|
38905
38914
|
const max = args[1];
|
|
38906
38915
|
if (max == undefined || min == undefined) {
|
|
38907
38916
|
throw new Error(
|
|
38908
|
-
|
|
38917
|
+
'Max and min need to be defined for hasLength, both or one of them is undefined'
|
|
38909
38918
|
);
|
|
38910
38919
|
}
|
|
38911
38920
|
if (max < min) {
|
|
38912
|
-
throw new Error(
|
|
38913
|
-
"hasLength validator was passed a min greater than the max"
|
|
38914
|
-
);
|
|
38921
|
+
throw new Error('hasLength validator was passed a min greater than the max');
|
|
38915
38922
|
}
|
|
38916
38923
|
const valueLength = value.length;
|
|
38917
38924
|
return max >= valueLength && valueLength >= min;
|
|
38918
38925
|
};
|
|
38919
38926
|
|
|
38920
|
-
const DATE_BEFORE_TODAY =
|
|
38921
|
-
const DATE_BEFORE_TODAY_ERROR =
|
|
38927
|
+
const DATE_BEFORE_TODAY = 'validator/DATE_BEFORE_TODAY';
|
|
38928
|
+
const DATE_BEFORE_TODAY_ERROR = 'error/DATE_BEFORE_TODAY';
|
|
38922
38929
|
const dateBeforeToday = createValidator(
|
|
38923
38930
|
DATE_BEFORE_TODAY,
|
|
38924
38931
|
DATE_BEFORE_TODAY_ERROR
|
|
38925
38932
|
);
|
|
38926
38933
|
validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
38927
|
-
if (value ===
|
|
38934
|
+
if (value === '') {
|
|
38928
38935
|
return true;
|
|
38929
38936
|
}
|
|
38930
38937
|
const dateFormat = args[0];
|
|
@@ -38933,7 +38940,7 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
38933
38940
|
|
|
38934
38941
|
if (dateFormat == undefined || unit == undefined) {
|
|
38935
38942
|
throw new Error(
|
|
38936
|
-
|
|
38943
|
+
'Date format and unit need to be defined for dateBeforeToday, one or both are undefined'
|
|
38937
38944
|
);
|
|
38938
38945
|
}
|
|
38939
38946
|
const now = dayjs();
|
|
@@ -38945,14 +38952,14 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
38945
38952
|
return dateValue.isBefore(now, unit);
|
|
38946
38953
|
};
|
|
38947
38954
|
|
|
38948
|
-
const DATE_AFTER_TODAY =
|
|
38949
|
-
const DATE_AFTER_TODAY_ERROR =
|
|
38955
|
+
const DATE_AFTER_TODAY = 'validator/DATE_AFTER_TODAY';
|
|
38956
|
+
const DATE_AFTER_TODAY_ERROR = 'error/DATE_AFTER_TODAY';
|
|
38950
38957
|
const dateAfterToday = createValidator(
|
|
38951
38958
|
DATE_AFTER_TODAY,
|
|
38952
38959
|
DATE_AFTER_TODAY_ERROR
|
|
38953
38960
|
);
|
|
38954
38961
|
validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
38955
|
-
if (value ===
|
|
38962
|
+
if (value === '') {
|
|
38956
38963
|
return true;
|
|
38957
38964
|
}
|
|
38958
38965
|
const dateFormat = args[0];
|
|
@@ -38961,7 +38968,7 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
38961
38968
|
|
|
38962
38969
|
if (dateFormat == undefined || unit == undefined) {
|
|
38963
38970
|
throw new Error(
|
|
38964
|
-
|
|
38971
|
+
'Date format and unit need to be defined for dateAfterToday, one or both are undefined'
|
|
38965
38972
|
);
|
|
38966
38973
|
}
|
|
38967
38974
|
const now = dayjs();
|
|
@@ -38973,14 +38980,11 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
38973
38980
|
return dateValue.isAfter(now, unit);
|
|
38974
38981
|
};
|
|
38975
38982
|
|
|
38976
|
-
const IS_VALID_MONTH =
|
|
38977
|
-
const IS_VALID_MONTH_ERROR =
|
|
38978
|
-
const isValidMonth = createValidator(
|
|
38979
|
-
IS_VALID_MONTH,
|
|
38980
|
-
IS_VALID_MONTH_ERROR
|
|
38981
|
-
);
|
|
38983
|
+
const IS_VALID_MONTH = 'validator/IS_VALID_MONTH';
|
|
38984
|
+
const IS_VALID_MONTH_ERROR = 'error/IS_VALID_MONTH';
|
|
38985
|
+
const isValidMonth = createValidator(IS_VALID_MONTH, IS_VALID_MONTH_ERROR);
|
|
38982
38986
|
validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
38983
|
-
if (value ===
|
|
38987
|
+
if (value === '') {
|
|
38984
38988
|
return true;
|
|
38985
38989
|
}
|
|
38986
38990
|
// Function takes one argument representing the character position
|
|
@@ -38990,43 +38994,43 @@ validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
|
38990
38994
|
// Only works with two digit months (01, 02, 03, etc)
|
|
38991
38995
|
const monthStartPosition = parseInt(args[0]);
|
|
38992
38996
|
const monthEndPosition = monthStartPosition + 2;
|
|
38993
|
-
if (monthStartPosition
|
|
38994
|
-
throw new Error(
|
|
38997
|
+
if (isNaN(monthStartPosition)) {
|
|
38998
|
+
throw new Error('Month start position has to be a valid integer string');
|
|
38995
38999
|
}
|
|
38996
39000
|
const month = parseInt(value.slice(monthStartPosition, monthEndPosition));
|
|
38997
|
-
if (month
|
|
39001
|
+
if (isNaN(month)) {
|
|
38998
39002
|
return false;
|
|
38999
39003
|
}
|
|
39000
39004
|
return month >= 1 && month <= 12;
|
|
39001
39005
|
};
|
|
39002
39006
|
|
|
39003
|
-
const MATCHES_REGEX =
|
|
39004
|
-
const MATCHES_REGEX_ERROR =
|
|
39007
|
+
const MATCHES_REGEX = 'validator/MATCHES_REGEX';
|
|
39008
|
+
const MATCHES_REGEX_ERROR = 'error/MATCHES_REGEX';
|
|
39005
39009
|
const matchesRegex = createValidator(MATCHES_REGEX, MATCHES_REGEX_ERROR);
|
|
39006
39010
|
validatorFns[MATCHES_REGEX] = (value, args, form) => {
|
|
39007
|
-
if (value ===
|
|
39011
|
+
if (value === '') {
|
|
39008
39012
|
return true;
|
|
39009
39013
|
}
|
|
39010
39014
|
return new RegExp(args[0]).test(value); // new RexExp never throws an error, no matter the input
|
|
39011
39015
|
};
|
|
39012
39016
|
|
|
39013
39017
|
// based on http://www.brainjar.com/js/validation/
|
|
39014
|
-
const IS_ROUTING_NUMBER =
|
|
39015
|
-
const IS_ROUTING_NUMBER_ERROR =
|
|
39018
|
+
const IS_ROUTING_NUMBER = 'validator/IS_ROUTING_NUMBER';
|
|
39019
|
+
const IS_ROUTING_NUMBER_ERROR = 'error/IS_ROUTING_NUMBER';
|
|
39016
39020
|
const isRoutingNumber = createValidator(
|
|
39017
39021
|
IS_ROUTING_NUMBER,
|
|
39018
39022
|
IS_ROUTING_NUMBER_ERROR
|
|
39019
39023
|
);
|
|
39020
39024
|
validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
39021
|
-
if (value ===
|
|
39025
|
+
if (value === '') {
|
|
39022
39026
|
return true;
|
|
39023
39027
|
}
|
|
39024
39028
|
if (value.length != 9) {
|
|
39025
39029
|
return false;
|
|
39026
39030
|
}
|
|
39027
39031
|
const sum = value
|
|
39028
|
-
.split(
|
|
39029
|
-
.map(ch => parseInt(ch))
|
|
39032
|
+
.split('')
|
|
39033
|
+
.map((ch) => parseInt(ch))
|
|
39030
39034
|
.reduce((acc, cur, idx) => {
|
|
39031
39035
|
switch (idx % 3) {
|
|
39032
39036
|
case 0:
|
|
@@ -39040,69 +39044,69 @@ validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
|
39040
39044
|
return sum != 0 && sum % 10 == 0;
|
|
39041
39045
|
};
|
|
39042
39046
|
|
|
39043
|
-
const HAS_NUMBER =
|
|
39044
|
-
const HAS_NUMBER_ERROR$1 =
|
|
39047
|
+
const HAS_NUMBER = 'validator/HAS_NUMBER';
|
|
39048
|
+
const HAS_NUMBER_ERROR$1 = 'error/HAS_NUMBER';
|
|
39045
39049
|
const hasNumber = createValidator(HAS_NUMBER, HAS_NUMBER_ERROR$1);
|
|
39046
39050
|
validatorFns[HAS_NUMBER] = (value, args, form) => {
|
|
39047
|
-
if (value ===
|
|
39051
|
+
if (value === '') {
|
|
39048
39052
|
return true;
|
|
39049
39053
|
}
|
|
39050
39054
|
return new RegExp(/[0-9]/).test(value);
|
|
39051
39055
|
};
|
|
39052
39056
|
|
|
39053
|
-
const HAS_LOWERCASE_LETTER =
|
|
39054
|
-
const HAS_LOWERCASE_LETTER_ERROR$1 =
|
|
39057
|
+
const HAS_LOWERCASE_LETTER = 'validator/HAS_LOWERCASE_LETTER';
|
|
39058
|
+
const HAS_LOWERCASE_LETTER_ERROR$1 = 'error/HAS_LOWERCASE_LETTER';
|
|
39055
39059
|
const hasLowercaseLetter = createValidator(
|
|
39056
39060
|
HAS_LOWERCASE_LETTER,
|
|
39057
39061
|
HAS_LOWERCASE_LETTER_ERROR$1
|
|
39058
39062
|
);
|
|
39059
39063
|
validatorFns[HAS_LOWERCASE_LETTER] = (value, args, form) => {
|
|
39060
|
-
if (value ===
|
|
39064
|
+
if (value === '') {
|
|
39061
39065
|
return true;
|
|
39062
39066
|
}
|
|
39063
39067
|
return new RegExp(/[a-z]/).test(value);
|
|
39064
39068
|
};
|
|
39065
39069
|
|
|
39066
|
-
const HAS_UPPERCASE_LETTER =
|
|
39067
|
-
const HAS_UPPERCASE_LETTER_ERROR$1 =
|
|
39070
|
+
const HAS_UPPERCASE_LETTER = 'validator/HAS_UPPERCASE_LETTER';
|
|
39071
|
+
const HAS_UPPERCASE_LETTER_ERROR$1 = 'error/HAS_UPPERCASE_LETTER';
|
|
39068
39072
|
const hasUppercaseLetter = createValidator(
|
|
39069
39073
|
HAS_UPPERCASE_LETTER,
|
|
39070
39074
|
HAS_UPPERCASE_LETTER_ERROR$1
|
|
39071
39075
|
);
|
|
39072
39076
|
validatorFns[HAS_UPPERCASE_LETTER] = (value, args, form) => {
|
|
39073
|
-
if (value ===
|
|
39077
|
+
if (value === '') {
|
|
39074
39078
|
return true;
|
|
39075
39079
|
}
|
|
39076
39080
|
return new RegExp(/[A-Z]/).test(value);
|
|
39077
39081
|
};
|
|
39078
39082
|
|
|
39079
|
-
const HAS_SPECIAL_CHARACTER =
|
|
39080
|
-
const HAS_SPECIAL_CHARACTER_ERROR$1 =
|
|
39083
|
+
const HAS_SPECIAL_CHARACTER = 'validator/HAS_SPECIAL_CHARACTER';
|
|
39084
|
+
const HAS_SPECIAL_CHARACTER_ERROR$1 = 'error/HAS_SPECIAL_CHARACTER';
|
|
39081
39085
|
const hasSpecialCharacter = createValidator(
|
|
39082
39086
|
HAS_SPECIAL_CHARACTER,
|
|
39083
39087
|
HAS_SPECIAL_CHARACTER_ERROR$1
|
|
39084
39088
|
);
|
|
39085
39089
|
validatorFns[HAS_SPECIAL_CHARACTER] = (value, args, form) => {
|
|
39086
|
-
if (value ===
|
|
39090
|
+
if (value === '') {
|
|
39087
39091
|
return true;
|
|
39088
39092
|
}
|
|
39089
39093
|
return new RegExp(/[!@#$%^&*.?]/).test(value);
|
|
39090
39094
|
};
|
|
39091
39095
|
|
|
39092
|
-
const IS_PROBABLY_EMAIL =
|
|
39093
|
-
const IS_PROBABLY_EMAIL_ERROR =
|
|
39096
|
+
const IS_PROBABLY_EMAIL = 'validator/IS_PROBABLY_EMAIL';
|
|
39097
|
+
const IS_PROBABLY_EMAIL_ERROR = 'error/IS_PROBABLY_EMAIL';
|
|
39094
39098
|
const isProbablyEmail = createValidator(
|
|
39095
39099
|
IS_PROBABLY_EMAIL,
|
|
39096
39100
|
IS_PROBABLY_EMAIL_ERROR
|
|
39097
39101
|
);
|
|
39098
39102
|
validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
39099
|
-
if (value ===
|
|
39103
|
+
if (value === '') {
|
|
39100
39104
|
return true;
|
|
39101
39105
|
}
|
|
39102
39106
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
39103
39107
|
};
|
|
39104
39108
|
|
|
39105
|
-
const runValidatorErrorMessage = type =>
|
|
39109
|
+
const runValidatorErrorMessage = (type) =>
|
|
39106
39110
|
`${type} was passed to runValidator, but that validator type does not exist.
|
|
39107
39111
|
Please check that you are only calling validator creator functions exported from
|
|
39108
39112
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -39117,1165 +39121,53 @@ const runValidator = (validator, value, form) => {
|
|
|
39117
39121
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
39118
39122
|
};
|
|
39119
39123
|
|
|
39120
|
-
const
|
|
39124
|
+
const runFormValidators = (fieldName, form, validators) => {
|
|
39121
39125
|
return validators
|
|
39122
|
-
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
39123
|
-
.filter(x => x !== null);
|
|
39126
|
+
.map((v) => runValidator(v, form[fieldName].rawValue, form))
|
|
39127
|
+
.filter((x) => x !== null);
|
|
39124
39128
|
};
|
|
39125
39129
|
|
|
39126
39130
|
const computeConstraints = (fieldName, form) => {
|
|
39127
39131
|
const constraints = form[fieldName].constraints;
|
|
39128
|
-
return
|
|
39132
|
+
return runFormValidators(fieldName, form, constraints);
|
|
39129
39133
|
};
|
|
39130
39134
|
|
|
39131
39135
|
const computeErrors = (fieldName, form) => {
|
|
39132
39136
|
const validators = form[fieldName].validators;
|
|
39133
|
-
return
|
|
39134
|
-
};
|
|
39135
|
-
|
|
39136
|
-
var obj;
|
|
39137
|
-
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : ( obj = {}, obj["immer-nothing"] = true, obj );
|
|
39138
|
-
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
39139
|
-
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-state") : "__$immer_state";
|
|
39140
|
-
function isDraft(value) {
|
|
39141
|
-
return !!value && !!value[DRAFT_STATE];
|
|
39142
|
-
}
|
|
39143
|
-
function isDraftable(value) {
|
|
39144
|
-
if (!value) { return false; }
|
|
39145
|
-
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
39146
|
-
}
|
|
39147
|
-
function isPlainObject(value) {
|
|
39148
|
-
if (!value || typeof value !== "object") { return false; }
|
|
39149
|
-
if (Array.isArray(value)) { return true; }
|
|
39150
|
-
var proto = Object.getPrototypeOf(value);
|
|
39151
|
-
return !proto || proto === Object.prototype;
|
|
39152
|
-
}
|
|
39153
|
-
var assign = Object.assign || function assign(target, value) {
|
|
39154
|
-
for (var key in value) {
|
|
39155
|
-
if (has$1(value, key)) {
|
|
39156
|
-
target[key] = value[key];
|
|
39157
|
-
}
|
|
39158
|
-
}
|
|
39159
|
-
|
|
39160
|
-
return target;
|
|
39161
|
-
};
|
|
39162
|
-
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;
|
|
39163
|
-
function shallowCopy(base, invokeGetters) {
|
|
39164
|
-
if ( invokeGetters === void 0 ) invokeGetters = false;
|
|
39165
|
-
|
|
39166
|
-
if (Array.isArray(base)) { return base.slice(); }
|
|
39167
|
-
var clone = Object.create(Object.getPrototypeOf(base));
|
|
39168
|
-
ownKeys$2(base).forEach(function (key) {
|
|
39169
|
-
if (key === DRAFT_STATE) {
|
|
39170
|
-
return; // Never copy over draft state.
|
|
39171
|
-
}
|
|
39172
|
-
|
|
39173
|
-
var desc = Object.getOwnPropertyDescriptor(base, key);
|
|
39174
|
-
var value = desc.value;
|
|
39175
|
-
|
|
39176
|
-
if (desc.get) {
|
|
39177
|
-
if (!invokeGetters) {
|
|
39178
|
-
throw new Error("Immer drafts cannot have computed properties");
|
|
39179
|
-
}
|
|
39180
|
-
|
|
39181
|
-
value = desc.get.call(base);
|
|
39182
|
-
}
|
|
39183
|
-
|
|
39184
|
-
if (desc.enumerable) {
|
|
39185
|
-
clone[key] = value;
|
|
39186
|
-
} else {
|
|
39187
|
-
Object.defineProperty(clone, key, {
|
|
39188
|
-
value: value,
|
|
39189
|
-
writable: true,
|
|
39190
|
-
configurable: true
|
|
39191
|
-
});
|
|
39192
|
-
}
|
|
39193
|
-
});
|
|
39194
|
-
return clone;
|
|
39195
|
-
}
|
|
39196
|
-
function each(value, cb) {
|
|
39197
|
-
if (Array.isArray(value)) {
|
|
39198
|
-
for (var i = 0; i < value.length; i++) { cb(i, value[i], value); }
|
|
39199
|
-
} else {
|
|
39200
|
-
ownKeys$2(value).forEach(function (key) { return cb(key, value[key], value); });
|
|
39201
|
-
}
|
|
39202
|
-
}
|
|
39203
|
-
function isEnumerable(base, prop) {
|
|
39204
|
-
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
39205
|
-
return !!desc && desc.enumerable;
|
|
39206
|
-
}
|
|
39207
|
-
function has$1(thing, prop) {
|
|
39208
|
-
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
39209
|
-
}
|
|
39210
|
-
function is(x, y) {
|
|
39211
|
-
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
39212
|
-
if (x === y) {
|
|
39213
|
-
return x !== 0 || 1 / x === 1 / y;
|
|
39214
|
-
} else {
|
|
39215
|
-
return x !== x && y !== y;
|
|
39216
|
-
}
|
|
39217
|
-
}
|
|
39218
|
-
function clone(obj) {
|
|
39219
|
-
if (!isDraftable(obj)) { return obj; }
|
|
39220
|
-
if (Array.isArray(obj)) { return obj.map(clone); }
|
|
39221
|
-
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
39222
|
-
|
|
39223
|
-
for (var key in obj) { cloned[key] = clone(obj[key]); }
|
|
39224
|
-
|
|
39225
|
-
return cloned;
|
|
39226
|
-
}
|
|
39227
|
-
|
|
39228
|
-
/** Each scope represents a `produce` call. */
|
|
39229
|
-
|
|
39230
|
-
var ImmerScope = function ImmerScope(parent) {
|
|
39231
|
-
this.drafts = [];
|
|
39232
|
-
this.parent = parent; // Whenever the modified draft contains a draft from another scope, we
|
|
39233
|
-
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
39234
|
-
|
|
39235
|
-
this.canAutoFreeze = true; // To avoid prototype lookups:
|
|
39236
|
-
|
|
39237
|
-
this.patches = null;
|
|
39238
|
-
};
|
|
39239
|
-
|
|
39240
|
-
ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
39241
|
-
if (patchListener) {
|
|
39242
|
-
this.patches = [];
|
|
39243
|
-
this.inversePatches = [];
|
|
39244
|
-
this.patchListener = patchListener;
|
|
39245
|
-
}
|
|
39246
|
-
};
|
|
39247
|
-
|
|
39248
|
-
ImmerScope.prototype.revoke = function revoke$1 () {
|
|
39249
|
-
this.leave();
|
|
39250
|
-
this.drafts.forEach(revoke);
|
|
39251
|
-
this.drafts = null; // Make draft-related methods throw.
|
|
39252
|
-
};
|
|
39253
|
-
|
|
39254
|
-
ImmerScope.prototype.leave = function leave () {
|
|
39255
|
-
if (this === ImmerScope.current) {
|
|
39256
|
-
ImmerScope.current = this.parent;
|
|
39257
|
-
}
|
|
39258
|
-
};
|
|
39259
|
-
ImmerScope.current = null;
|
|
39260
|
-
|
|
39261
|
-
ImmerScope.enter = function () {
|
|
39262
|
-
return this.current = new ImmerScope(this.current);
|
|
39263
|
-
};
|
|
39264
|
-
|
|
39265
|
-
function revoke(draft) {
|
|
39266
|
-
draft[DRAFT_STATE].revoke();
|
|
39267
|
-
}
|
|
39268
|
-
|
|
39269
|
-
// but share them all instead
|
|
39270
|
-
|
|
39271
|
-
var descriptors$1 = {};
|
|
39272
|
-
function willFinalize(scope, result, isReplaced) {
|
|
39273
|
-
scope.drafts.forEach(function (draft) {
|
|
39274
|
-
draft[DRAFT_STATE].finalizing = true;
|
|
39275
|
-
});
|
|
39276
|
-
|
|
39277
|
-
if (!isReplaced) {
|
|
39278
|
-
if (scope.patches) {
|
|
39279
|
-
markChangesRecursively(scope.drafts[0]);
|
|
39280
|
-
} // This is faster when we don't care about which attributes changed.
|
|
39281
|
-
|
|
39282
|
-
|
|
39283
|
-
markChangesSweep(scope.drafts);
|
|
39284
|
-
} // When a child draft is returned, look for changes.
|
|
39285
|
-
else if (isDraft(result) && result[DRAFT_STATE].scope === scope) {
|
|
39286
|
-
markChangesSweep(scope.drafts);
|
|
39287
|
-
}
|
|
39288
|
-
}
|
|
39289
|
-
function createProxy(base, parent) {
|
|
39290
|
-
var isArray = Array.isArray(base);
|
|
39291
|
-
var draft = clonePotentialDraft(base);
|
|
39292
|
-
each(draft, function (prop) {
|
|
39293
|
-
proxyProperty(draft, prop, isArray || isEnumerable(base, prop));
|
|
39294
|
-
}); // See "proxy.js" for property documentation.
|
|
39295
|
-
|
|
39296
|
-
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39297
|
-
var state = {
|
|
39298
|
-
scope: scope,
|
|
39299
|
-
modified: false,
|
|
39300
|
-
finalizing: false,
|
|
39301
|
-
// es5 only
|
|
39302
|
-
finalized: false,
|
|
39303
|
-
assigned: {},
|
|
39304
|
-
parent: parent,
|
|
39305
|
-
base: base,
|
|
39306
|
-
draft: draft,
|
|
39307
|
-
copy: null,
|
|
39308
|
-
revoke: revoke$1,
|
|
39309
|
-
revoked: false // es5 only
|
|
39310
|
-
|
|
39311
|
-
};
|
|
39312
|
-
createHiddenProperty(draft, DRAFT_STATE, state);
|
|
39313
|
-
scope.drafts.push(draft);
|
|
39314
|
-
return draft;
|
|
39315
|
-
}
|
|
39316
|
-
|
|
39317
|
-
function revoke$1() {
|
|
39318
|
-
this.revoked = true;
|
|
39319
|
-
}
|
|
39320
|
-
|
|
39321
|
-
function source(state) {
|
|
39322
|
-
return state.copy || state.base;
|
|
39323
|
-
} // Access a property without creating an Immer draft.
|
|
39324
|
-
|
|
39325
|
-
|
|
39326
|
-
function peek(draft, prop) {
|
|
39327
|
-
var state = draft[DRAFT_STATE];
|
|
39328
|
-
|
|
39329
|
-
if (state && !state.finalizing) {
|
|
39330
|
-
state.finalizing = true;
|
|
39331
|
-
var value = draft[prop];
|
|
39332
|
-
state.finalizing = false;
|
|
39333
|
-
return value;
|
|
39334
|
-
}
|
|
39335
|
-
|
|
39336
|
-
return draft[prop];
|
|
39337
|
-
}
|
|
39338
|
-
|
|
39339
|
-
function get$1(state, prop) {
|
|
39340
|
-
assertUnrevoked(state);
|
|
39341
|
-
var value = peek(source(state), prop);
|
|
39342
|
-
if (state.finalizing) { return value; } // Create a draft if the value is unmodified.
|
|
39343
|
-
|
|
39344
|
-
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
39345
|
-
prepareCopy(state);
|
|
39346
|
-
return state.copy[prop] = createProxy(value, state);
|
|
39347
|
-
}
|
|
39348
|
-
|
|
39349
|
-
return value;
|
|
39350
|
-
}
|
|
39351
|
-
|
|
39352
|
-
function set$1(state, prop, value) {
|
|
39353
|
-
assertUnrevoked(state);
|
|
39354
|
-
state.assigned[prop] = true;
|
|
39355
|
-
|
|
39356
|
-
if (!state.modified) {
|
|
39357
|
-
if (is(value, peek(source(state), prop))) { return; }
|
|
39358
|
-
markChanged(state);
|
|
39359
|
-
prepareCopy(state);
|
|
39360
|
-
}
|
|
39361
|
-
|
|
39362
|
-
state.copy[prop] = value;
|
|
39363
|
-
}
|
|
39364
|
-
|
|
39365
|
-
function markChanged(state) {
|
|
39366
|
-
if (!state.modified) {
|
|
39367
|
-
state.modified = true;
|
|
39368
|
-
if (state.parent) { markChanged(state.parent); }
|
|
39369
|
-
}
|
|
39370
|
-
}
|
|
39371
|
-
|
|
39372
|
-
function prepareCopy(state) {
|
|
39373
|
-
if (!state.copy) { state.copy = clonePotentialDraft(state.base); }
|
|
39374
|
-
}
|
|
39375
|
-
|
|
39376
|
-
function clonePotentialDraft(base) {
|
|
39377
|
-
var state = base && base[DRAFT_STATE];
|
|
39378
|
-
|
|
39379
|
-
if (state) {
|
|
39380
|
-
state.finalizing = true;
|
|
39381
|
-
var draft = shallowCopy(state.draft, true);
|
|
39382
|
-
state.finalizing = false;
|
|
39383
|
-
return draft;
|
|
39384
|
-
}
|
|
39385
|
-
|
|
39386
|
-
return shallowCopy(base);
|
|
39387
|
-
}
|
|
39388
|
-
|
|
39389
|
-
function proxyProperty(draft, prop, enumerable) {
|
|
39390
|
-
var desc = descriptors$1[prop];
|
|
39391
|
-
|
|
39392
|
-
if (desc) {
|
|
39393
|
-
desc.enumerable = enumerable;
|
|
39394
|
-
} else {
|
|
39395
|
-
descriptors$1[prop] = desc = {
|
|
39396
|
-
configurable: true,
|
|
39397
|
-
enumerable: enumerable,
|
|
39398
|
-
|
|
39399
|
-
get: function get$1$1() {
|
|
39400
|
-
return get$1(this[DRAFT_STATE], prop);
|
|
39401
|
-
},
|
|
39402
|
-
|
|
39403
|
-
set: function set$1$1(value) {
|
|
39404
|
-
set$1(this[DRAFT_STATE], prop, value);
|
|
39405
|
-
}
|
|
39406
|
-
|
|
39407
|
-
};
|
|
39408
|
-
}
|
|
39409
|
-
|
|
39410
|
-
Object.defineProperty(draft, prop, desc);
|
|
39411
|
-
}
|
|
39412
|
-
|
|
39413
|
-
function assertUnrevoked(state) {
|
|
39414
|
-
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))); }
|
|
39415
|
-
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
39416
|
-
|
|
39417
|
-
|
|
39418
|
-
function markChangesSweep(drafts) {
|
|
39419
|
-
// The natural order of drafts in the `scope` array is based on when they
|
|
39420
|
-
// were accessed. By processing drafts in reverse natural order, we have a
|
|
39421
|
-
// better chance of processing leaf nodes first. When a leaf node is known to
|
|
39422
|
-
// have changed, we can avoid any traversal of its ancestor nodes.
|
|
39423
|
-
for (var i = drafts.length - 1; i >= 0; i--) {
|
|
39424
|
-
var state = drafts[i][DRAFT_STATE];
|
|
39425
|
-
|
|
39426
|
-
if (!state.modified) {
|
|
39427
|
-
if (Array.isArray(state.base)) {
|
|
39428
|
-
if (hasArrayChanges(state)) { markChanged(state); }
|
|
39429
|
-
} else if (hasObjectChanges(state)) { markChanged(state); }
|
|
39430
|
-
}
|
|
39431
|
-
}
|
|
39432
|
-
}
|
|
39433
|
-
|
|
39434
|
-
function markChangesRecursively(object) {
|
|
39435
|
-
if (!object || typeof object !== "object") { return; }
|
|
39436
|
-
var state = object[DRAFT_STATE];
|
|
39437
|
-
if (!state) { return; }
|
|
39438
|
-
var base = state.base;
|
|
39439
|
-
var draft = state.draft;
|
|
39440
|
-
var assigned = state.assigned;
|
|
39441
|
-
|
|
39442
|
-
if (!Array.isArray(object)) {
|
|
39443
|
-
// Look for added keys.
|
|
39444
|
-
Object.keys(draft).forEach(function (key) {
|
|
39445
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39446
|
-
if (base[key] === undefined && !has$1(base, key)) {
|
|
39447
|
-
assigned[key] = true;
|
|
39448
|
-
markChanged(state);
|
|
39449
|
-
} else if (!assigned[key]) {
|
|
39450
|
-
// Only untouched properties trigger recursion.
|
|
39451
|
-
markChangesRecursively(draft[key]);
|
|
39452
|
-
}
|
|
39453
|
-
}); // Look for removed keys.
|
|
39454
|
-
|
|
39455
|
-
Object.keys(base).forEach(function (key) {
|
|
39456
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39457
|
-
if (draft[key] === undefined && !has$1(draft, key)) {
|
|
39458
|
-
assigned[key] = false;
|
|
39459
|
-
markChanged(state);
|
|
39460
|
-
}
|
|
39461
|
-
});
|
|
39462
|
-
} else if (hasArrayChanges(state)) {
|
|
39463
|
-
markChanged(state);
|
|
39464
|
-
assigned.length = true;
|
|
39465
|
-
|
|
39466
|
-
if (draft.length < base.length) {
|
|
39467
|
-
for (var i = draft.length; i < base.length; i++) { assigned[i] = false; }
|
|
39468
|
-
} else {
|
|
39469
|
-
for (var i$1 = base.length; i$1 < draft.length; i$1++) { assigned[i$1] = true; }
|
|
39470
|
-
}
|
|
39471
|
-
|
|
39472
|
-
for (var i$2 = 0; i$2 < draft.length; i$2++) {
|
|
39473
|
-
// Only untouched indices trigger recursion.
|
|
39474
|
-
if (assigned[i$2] === undefined) { markChangesRecursively(draft[i$2]); }
|
|
39475
|
-
}
|
|
39476
|
-
}
|
|
39477
|
-
}
|
|
39478
|
-
|
|
39479
|
-
function hasObjectChanges(state) {
|
|
39480
|
-
var base = state.base;
|
|
39481
|
-
var draft = state.draft; // Search for added keys and changed keys. Start at the back, because
|
|
39482
|
-
// non-numeric keys are ordered by time of definition on the object.
|
|
39483
|
-
|
|
39484
|
-
var keys = Object.keys(draft);
|
|
39485
|
-
|
|
39486
|
-
for (var i = keys.length - 1; i >= 0; i--) {
|
|
39487
|
-
var key = keys[i];
|
|
39488
|
-
var baseValue = base[key]; // The `undefined` check is a fast path for pre-existing keys.
|
|
39489
|
-
|
|
39490
|
-
if (baseValue === undefined && !has$1(base, key)) {
|
|
39491
|
-
return true;
|
|
39492
|
-
} // Once a base key is deleted, future changes go undetected, because its
|
|
39493
|
-
// descriptor is erased. This branch detects any missed changes.
|
|
39494
|
-
else {
|
|
39495
|
-
var value = draft[key];
|
|
39496
|
-
var state$1 = value && value[DRAFT_STATE];
|
|
39497
|
-
|
|
39498
|
-
if (state$1 ? state$1.base !== baseValue : !is(value, baseValue)) {
|
|
39499
|
-
return true;
|
|
39500
|
-
}
|
|
39501
|
-
}
|
|
39502
|
-
} // At this point, no keys were added or changed.
|
|
39503
|
-
// Compare key count to determine if keys were deleted.
|
|
39504
|
-
|
|
39505
|
-
|
|
39506
|
-
return keys.length !== Object.keys(base).length;
|
|
39507
|
-
}
|
|
39508
|
-
|
|
39509
|
-
function hasArrayChanges(state) {
|
|
39510
|
-
var draft = state.draft;
|
|
39511
|
-
if (draft.length !== state.base.length) { return true; } // See #116
|
|
39512
|
-
// If we first shorten the length, our array interceptors will be removed.
|
|
39513
|
-
// If after that new items are added, result in the same original length,
|
|
39514
|
-
// those last items will have no intercepting property.
|
|
39515
|
-
// So if there is no own descriptor on the last position, we know that items were removed and added
|
|
39516
|
-
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
39517
|
-
// the last one
|
|
39518
|
-
|
|
39519
|
-
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
39520
|
-
|
|
39521
|
-
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
|
|
39522
|
-
|
|
39523
|
-
return false;
|
|
39524
|
-
}
|
|
39525
|
-
|
|
39526
|
-
function createHiddenProperty(target, prop, value) {
|
|
39527
|
-
Object.defineProperty(target, prop, {
|
|
39528
|
-
value: value,
|
|
39529
|
-
enumerable: false,
|
|
39530
|
-
writable: true
|
|
39531
|
-
});
|
|
39532
|
-
}
|
|
39533
|
-
|
|
39534
|
-
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
39535
|
-
willFinalize: willFinalize,
|
|
39536
|
-
createProxy: createProxy
|
|
39537
|
-
});
|
|
39538
|
-
|
|
39539
|
-
function willFinalize$1() {}
|
|
39540
|
-
function createProxy$1(base, parent) {
|
|
39541
|
-
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39542
|
-
var state = {
|
|
39543
|
-
// Track which produce call this is associated with.
|
|
39544
|
-
scope: scope,
|
|
39545
|
-
// True for both shallow and deep changes.
|
|
39546
|
-
modified: false,
|
|
39547
|
-
// Used during finalization.
|
|
39548
|
-
finalized: false,
|
|
39549
|
-
// Track which properties have been assigned (true) or deleted (false).
|
|
39550
|
-
assigned: {},
|
|
39551
|
-
// The parent draft state.
|
|
39552
|
-
parent: parent,
|
|
39553
|
-
// The base state.
|
|
39554
|
-
base: base,
|
|
39555
|
-
// The base proxy.
|
|
39556
|
-
draft: null,
|
|
39557
|
-
// Any property proxies.
|
|
39558
|
-
drafts: {},
|
|
39559
|
-
// The base copy with any updated values.
|
|
39560
|
-
copy: null,
|
|
39561
|
-
// Called by the `produce` function.
|
|
39562
|
-
revoke: null
|
|
39563
|
-
};
|
|
39564
|
-
var ref = Array.isArray(base) ? // [state] is used for arrays, to make sure the proxy is array-ish and not violate invariants,
|
|
39565
|
-
// although state itself is an object
|
|
39566
|
-
Proxy.revocable([state], arrayTraps) : Proxy.revocable(state, objectTraps);
|
|
39567
|
-
var revoke = ref.revoke;
|
|
39568
|
-
var proxy = ref.proxy;
|
|
39569
|
-
state.draft = proxy;
|
|
39570
|
-
state.revoke = revoke;
|
|
39571
|
-
scope.drafts.push(proxy);
|
|
39572
|
-
return proxy;
|
|
39573
|
-
}
|
|
39574
|
-
var objectTraps = {
|
|
39575
|
-
get: get$1$1,
|
|
39576
|
-
|
|
39577
|
-
has: function has(target, prop) {
|
|
39578
|
-
return prop in source$1(target);
|
|
39579
|
-
},
|
|
39580
|
-
|
|
39581
|
-
ownKeys: function ownKeys(target) {
|
|
39582
|
-
return Reflect.ownKeys(source$1(target));
|
|
39583
|
-
},
|
|
39584
|
-
|
|
39585
|
-
set: set$1$1,
|
|
39586
|
-
deleteProperty: deleteProperty,
|
|
39587
|
-
getOwnPropertyDescriptor: getOwnPropertyDescriptor$2,
|
|
39588
|
-
|
|
39589
|
-
defineProperty: function defineProperty() {
|
|
39590
|
-
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
39591
|
-
},
|
|
39592
|
-
|
|
39593
|
-
getPrototypeOf: function getPrototypeOf(target) {
|
|
39594
|
-
return Object.getPrototypeOf(target.base);
|
|
39595
|
-
},
|
|
39596
|
-
|
|
39597
|
-
setPrototypeOf: function setPrototypeOf() {
|
|
39598
|
-
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
39599
|
-
}
|
|
39600
|
-
|
|
39601
|
-
};
|
|
39602
|
-
var arrayTraps = {};
|
|
39603
|
-
each(objectTraps, function (key, fn) {
|
|
39604
|
-
arrayTraps[key] = function () {
|
|
39605
|
-
arguments[0] = arguments[0][0];
|
|
39606
|
-
return fn.apply(this, arguments);
|
|
39607
|
-
};
|
|
39608
|
-
});
|
|
39609
|
-
|
|
39610
|
-
arrayTraps.deleteProperty = function (state, prop) {
|
|
39611
|
-
if (isNaN(parseInt(prop))) {
|
|
39612
|
-
throw new Error("Immer only supports deleting array indices"); // prettier-ignore
|
|
39613
|
-
}
|
|
39614
|
-
|
|
39615
|
-
return objectTraps.deleteProperty.call(this, state[0], prop);
|
|
39616
|
-
};
|
|
39617
|
-
|
|
39618
|
-
arrayTraps.set = function (state, prop, value) {
|
|
39619
|
-
if (prop !== "length" && isNaN(parseInt(prop))) {
|
|
39620
|
-
throw new Error("Immer only supports setting array indices and the 'length' property"); // prettier-ignore
|
|
39621
|
-
}
|
|
39622
|
-
|
|
39623
|
-
return objectTraps.set.call(this, state[0], prop, value);
|
|
39624
|
-
}; // returns the object we should be reading the current value from, which is base, until some change has been made
|
|
39625
|
-
|
|
39626
|
-
|
|
39627
|
-
function source$1(state) {
|
|
39628
|
-
return state.copy || state.base;
|
|
39629
|
-
} // Access a property without creating an Immer draft.
|
|
39630
|
-
|
|
39631
|
-
|
|
39632
|
-
function peek$1(draft, prop) {
|
|
39633
|
-
var state = draft[DRAFT_STATE];
|
|
39634
|
-
var desc = Reflect.getOwnPropertyDescriptor(state ? source$1(state) : draft, prop);
|
|
39635
|
-
return desc && desc.value;
|
|
39636
|
-
}
|
|
39637
|
-
|
|
39638
|
-
function get$1$1(state, prop) {
|
|
39639
|
-
if (prop === DRAFT_STATE) { return state; }
|
|
39640
|
-
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
39641
|
-
|
|
39642
|
-
if (!state.modified && has$1(drafts, prop)) {
|
|
39643
|
-
return drafts[prop];
|
|
39644
|
-
}
|
|
39645
|
-
|
|
39646
|
-
var value = source$1(state)[prop];
|
|
39647
|
-
|
|
39648
|
-
if (state.finalized || !isDraftable(value)) {
|
|
39649
|
-
return value;
|
|
39650
|
-
} // Check for existing draft in modified state.
|
|
39651
|
-
|
|
39652
|
-
|
|
39653
|
-
if (state.modified) {
|
|
39654
|
-
// Assigned values are never drafted. This catches any drafts we created, too.
|
|
39655
|
-
if (value !== peek$1(state.base, prop)) { return value; } // Store drafts on the copy (when one exists).
|
|
39656
|
-
|
|
39657
|
-
drafts = state.copy;
|
|
39658
|
-
}
|
|
39659
|
-
|
|
39660
|
-
return drafts[prop] = createProxy$1(value, state);
|
|
39661
|
-
}
|
|
39662
|
-
|
|
39663
|
-
function set$1$1(state, prop, value) {
|
|
39664
|
-
if (!state.modified) {
|
|
39665
|
-
var baseValue = peek$1(state.base, prop); // Optimize based on value's truthiness. Truthy values are guaranteed to
|
|
39666
|
-
// never be undefined, so we can avoid the `in` operator. Lastly, truthy
|
|
39667
|
-
// values may be drafts, but falsy values are never drafts.
|
|
39668
|
-
|
|
39669
|
-
var isUnchanged = value ? is(baseValue, value) || value === state.drafts[prop] : is(baseValue, value) && prop in state.base;
|
|
39670
|
-
if (isUnchanged) { return true; }
|
|
39671
|
-
markChanged$1(state);
|
|
39672
|
-
}
|
|
39673
|
-
|
|
39674
|
-
state.assigned[prop] = true;
|
|
39675
|
-
state.copy[prop] = value;
|
|
39676
|
-
return true;
|
|
39677
|
-
}
|
|
39678
|
-
|
|
39679
|
-
function deleteProperty(state, prop) {
|
|
39680
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39681
|
-
if (peek$1(state.base, prop) !== undefined || prop in state.base) {
|
|
39682
|
-
state.assigned[prop] = false;
|
|
39683
|
-
markChanged$1(state);
|
|
39684
|
-
} else if (state.assigned[prop]) {
|
|
39685
|
-
// if an originally not assigned property was deleted
|
|
39686
|
-
delete state.assigned[prop];
|
|
39687
|
-
}
|
|
39688
|
-
|
|
39689
|
-
if (state.copy) { delete state.copy[prop]; }
|
|
39690
|
-
return true;
|
|
39691
|
-
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
39692
|
-
// the same guarantee in ES5 mode.
|
|
39693
|
-
|
|
39694
|
-
|
|
39695
|
-
function getOwnPropertyDescriptor$2(state, prop) {
|
|
39696
|
-
var owner = source$1(state);
|
|
39697
|
-
var desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
39698
|
-
|
|
39699
|
-
if (desc) {
|
|
39700
|
-
desc.writable = true;
|
|
39701
|
-
desc.configurable = !Array.isArray(owner) || prop !== "length";
|
|
39702
|
-
}
|
|
39703
|
-
|
|
39704
|
-
return desc;
|
|
39705
|
-
}
|
|
39706
|
-
|
|
39707
|
-
function markChanged$1(state) {
|
|
39708
|
-
if (!state.modified) {
|
|
39709
|
-
state.modified = true;
|
|
39710
|
-
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
39711
|
-
state.drafts = null;
|
|
39712
|
-
if (state.parent) { markChanged$1(state.parent); }
|
|
39713
|
-
}
|
|
39714
|
-
}
|
|
39715
|
-
|
|
39716
|
-
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
39717
|
-
willFinalize: willFinalize$1,
|
|
39718
|
-
createProxy: createProxy$1
|
|
39719
|
-
});
|
|
39720
|
-
|
|
39721
|
-
function generatePatches(state, basePath, patches, inversePatches) {
|
|
39722
|
-
Array.isArray(state.base) ? generateArrayPatches(state, basePath, patches, inversePatches) : generateObjectPatches(state, basePath, patches, inversePatches);
|
|
39723
|
-
}
|
|
39724
|
-
|
|
39725
|
-
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
39726
|
-
var assign, assign$1;
|
|
39727
|
-
|
|
39728
|
-
var base = state.base;
|
|
39729
|
-
var copy = state.copy;
|
|
39730
|
-
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
39731
|
-
|
|
39732
|
-
if (copy.length < base.length) {
|
|
39733
|
-
(assign = [copy, base], base = assign[0], copy = assign[1]);
|
|
39734
|
-
(assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1]);
|
|
39735
|
-
}
|
|
39736
|
-
|
|
39737
|
-
var delta = copy.length - base.length; // Find the first replaced index.
|
|
39738
|
-
|
|
39739
|
-
var start = 0;
|
|
39740
|
-
|
|
39741
|
-
while (base[start] === copy[start] && start < base.length) {
|
|
39742
|
-
++start;
|
|
39743
|
-
} // Find the last replaced index. Search from the end to optimize splice patches.
|
|
39744
|
-
|
|
39745
|
-
|
|
39746
|
-
var end = base.length;
|
|
39747
|
-
|
|
39748
|
-
while (end > start && base[end - 1] === copy[end + delta - 1]) {
|
|
39749
|
-
--end;
|
|
39750
|
-
} // Process replaced indices.
|
|
39751
|
-
|
|
39752
|
-
|
|
39753
|
-
for (var i = start; i < end; ++i) {
|
|
39754
|
-
if (assigned[i] && copy[i] !== base[i]) {
|
|
39755
|
-
var path = basePath.concat([i]);
|
|
39756
|
-
patches.push({
|
|
39757
|
-
op: "replace",
|
|
39758
|
-
path: path,
|
|
39759
|
-
value: copy[i]
|
|
39760
|
-
});
|
|
39761
|
-
inversePatches.push({
|
|
39762
|
-
op: "replace",
|
|
39763
|
-
path: path,
|
|
39764
|
-
value: base[i]
|
|
39765
|
-
});
|
|
39766
|
-
}
|
|
39767
|
-
}
|
|
39768
|
-
|
|
39769
|
-
var replaceCount = patches.length; // Process added indices.
|
|
39770
|
-
|
|
39771
|
-
for (var i$1 = end + delta - 1; i$1 >= end; --i$1) {
|
|
39772
|
-
var path$1 = basePath.concat([i$1]);
|
|
39773
|
-
patches[replaceCount + i$1 - end] = {
|
|
39774
|
-
op: "add",
|
|
39775
|
-
path: path$1,
|
|
39776
|
-
value: copy[i$1]
|
|
39777
|
-
};
|
|
39778
|
-
inversePatches.push({
|
|
39779
|
-
op: "remove",
|
|
39780
|
-
path: path$1
|
|
39781
|
-
});
|
|
39782
|
-
}
|
|
39783
|
-
}
|
|
39784
|
-
|
|
39785
|
-
function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
39786
|
-
var base = state.base;
|
|
39787
|
-
var copy = state.copy;
|
|
39788
|
-
each(state.assigned, function (key, assignedValue) {
|
|
39789
|
-
var origValue = base[key];
|
|
39790
|
-
var value = copy[key];
|
|
39791
|
-
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
39792
|
-
if (origValue === value && op === "replace") { return; }
|
|
39793
|
-
var path = basePath.concat(key);
|
|
39794
|
-
patches.push(op === "remove" ? {
|
|
39795
|
-
op: op,
|
|
39796
|
-
path: path
|
|
39797
|
-
} : {
|
|
39798
|
-
op: op,
|
|
39799
|
-
path: path,
|
|
39800
|
-
value: value
|
|
39801
|
-
});
|
|
39802
|
-
inversePatches.push(op === "add" ? {
|
|
39803
|
-
op: "remove",
|
|
39804
|
-
path: path
|
|
39805
|
-
} : op === "remove" ? {
|
|
39806
|
-
op: "add",
|
|
39807
|
-
path: path,
|
|
39808
|
-
value: origValue
|
|
39809
|
-
} : {
|
|
39810
|
-
op: "replace",
|
|
39811
|
-
path: path,
|
|
39812
|
-
value: origValue
|
|
39813
|
-
});
|
|
39814
|
-
});
|
|
39815
|
-
}
|
|
39816
|
-
|
|
39817
|
-
var applyPatches = function (draft, patches) {
|
|
39818
|
-
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
39819
|
-
var patch = list[i$1];
|
|
39820
|
-
|
|
39821
|
-
var path = patch.path;
|
|
39822
|
-
var op = patch.op;
|
|
39823
|
-
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
39824
|
-
|
|
39825
|
-
if (!path.length) { throw new Error("Illegal state"); }
|
|
39826
|
-
var base = draft;
|
|
39827
|
-
|
|
39828
|
-
for (var i = 0; i < path.length - 1; i++) {
|
|
39829
|
-
base = base[path[i]];
|
|
39830
|
-
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
39831
|
-
}
|
|
39832
|
-
|
|
39833
|
-
var key = path[path.length - 1];
|
|
39834
|
-
|
|
39835
|
-
switch (op) {
|
|
39836
|
-
case "replace":
|
|
39837
|
-
// if value is an object, then it's assigned by reference
|
|
39838
|
-
// in the following add or remove ops, the value field inside the patch will also be modifyed
|
|
39839
|
-
// so we use value from the cloned patch
|
|
39840
|
-
base[key] = value;
|
|
39841
|
-
break;
|
|
39842
|
-
|
|
39843
|
-
case "add":
|
|
39844
|
-
if (Array.isArray(base)) {
|
|
39845
|
-
// TODO: support "foo/-" paths for appending to an array
|
|
39846
|
-
base.splice(key, 0, value);
|
|
39847
|
-
} else {
|
|
39848
|
-
base[key] = value;
|
|
39849
|
-
}
|
|
39850
|
-
|
|
39851
|
-
break;
|
|
39852
|
-
|
|
39853
|
-
case "remove":
|
|
39854
|
-
if (Array.isArray(base)) {
|
|
39855
|
-
base.splice(key, 1);
|
|
39856
|
-
} else {
|
|
39857
|
-
delete base[key];
|
|
39858
|
-
}
|
|
39859
|
-
|
|
39860
|
-
break;
|
|
39861
|
-
|
|
39862
|
-
default:
|
|
39863
|
-
throw new Error("Unsupported patch operation: " + op);
|
|
39864
|
-
}
|
|
39865
|
-
}
|
|
39866
|
-
|
|
39867
|
-
return draft;
|
|
39868
|
-
};
|
|
39869
|
-
|
|
39870
|
-
function verifyMinified() {}
|
|
39871
|
-
|
|
39872
|
-
var configDefaults = {
|
|
39873
|
-
useProxies: typeof Proxy !== "undefined" && typeof Reflect !== "undefined",
|
|
39874
|
-
autoFreeze: typeof process !== "undefined" ? process.env.NODE_ENV !== "production" : verifyMinified.name === "verifyMinified",
|
|
39875
|
-
onAssign: null,
|
|
39876
|
-
onDelete: null,
|
|
39877
|
-
onCopy: null
|
|
39878
|
-
};
|
|
39879
|
-
var Immer = function Immer(config) {
|
|
39880
|
-
assign(this, configDefaults, config);
|
|
39881
|
-
this.setUseProxies(this.useProxies);
|
|
39882
|
-
this.produce = this.produce.bind(this);
|
|
39883
|
-
};
|
|
39884
|
-
|
|
39885
|
-
Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
39886
|
-
var this$1$1 = this;
|
|
39887
|
-
|
|
39888
|
-
// curried invocation
|
|
39889
|
-
if (typeof base === "function" && typeof recipe !== "function") {
|
|
39890
|
-
var defaultBase = recipe;
|
|
39891
|
-
recipe = base;
|
|
39892
|
-
var self = this;
|
|
39893
|
-
return function curriedProduce(base) {
|
|
39894
|
-
var this$1$1 = this;
|
|
39895
|
-
if ( base === void 0 ) base = defaultBase;
|
|
39896
|
-
var args = [], len = arguments.length - 1;
|
|
39897
|
-
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
39898
|
-
|
|
39899
|
-
return self.produce(base, function (draft) { return recipe.call.apply(recipe, [ this$1$1, draft ].concat( args )); }); // prettier-ignore
|
|
39900
|
-
};
|
|
39901
|
-
} // prettier-ignore
|
|
39902
|
-
|
|
39903
|
-
|
|
39904
|
-
{
|
|
39905
|
-
if (typeof recipe !== "function") {
|
|
39906
|
-
throw new Error("The first or second argument to `produce` must be a function");
|
|
39907
|
-
}
|
|
39908
|
-
|
|
39909
|
-
if (patchListener !== undefined && typeof patchListener !== "function") {
|
|
39910
|
-
throw new Error("The third argument to `produce` must be a function or undefined");
|
|
39911
|
-
}
|
|
39912
|
-
}
|
|
39913
|
-
var result; // Only plain objects, arrays, and "immerable classes" are drafted.
|
|
39914
|
-
|
|
39915
|
-
if (isDraftable(base)) {
|
|
39916
|
-
var scope = ImmerScope.enter();
|
|
39917
|
-
var proxy = this.createProxy(base);
|
|
39918
|
-
var hasError = true;
|
|
39919
|
-
|
|
39920
|
-
try {
|
|
39921
|
-
result = recipe(proxy);
|
|
39922
|
-
hasError = false;
|
|
39923
|
-
} finally {
|
|
39924
|
-
// finally instead of catch + rethrow better preserves original stack
|
|
39925
|
-
if (hasError) { scope.revoke(); }else { scope.leave(); }
|
|
39926
|
-
}
|
|
39927
|
-
|
|
39928
|
-
if (result instanceof Promise) {
|
|
39929
|
-
return result.then(function (result) {
|
|
39930
|
-
scope.usePatches(patchListener);
|
|
39931
|
-
return this$1$1.processResult(result, scope);
|
|
39932
|
-
}, function (error) {
|
|
39933
|
-
scope.revoke();
|
|
39934
|
-
throw error;
|
|
39935
|
-
});
|
|
39936
|
-
}
|
|
39937
|
-
|
|
39938
|
-
scope.usePatches(patchListener);
|
|
39939
|
-
return this.processResult(result, scope);
|
|
39940
|
-
} else {
|
|
39941
|
-
result = recipe(base);
|
|
39942
|
-
if (result === undefined) { return base; }
|
|
39943
|
-
return result !== NOTHING ? result : undefined;
|
|
39944
|
-
}
|
|
39945
|
-
};
|
|
39946
|
-
|
|
39947
|
-
Immer.prototype.produceWithPatches = function produceWithPatches (arg1, arg2, arg3) {
|
|
39948
|
-
var this$1$1 = this;
|
|
39949
|
-
|
|
39950
|
-
if (typeof arg1 === "function") {
|
|
39951
|
-
return function (state) {
|
|
39952
|
-
var args = [], len = arguments.length - 1;
|
|
39953
|
-
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
39954
|
-
|
|
39955
|
-
return this$1$1.produceWithPatches(state, function (draft) { return arg1.apply(void 0, [ draft ].concat( args )); });
|
|
39956
|
-
};
|
|
39957
|
-
} // non-curried form
|
|
39958
|
-
|
|
39959
|
-
|
|
39960
|
-
if (arg3) { throw new Error("A patch listener cannot be passed to produceWithPatches"); }
|
|
39961
|
-
var patches, inversePatches;
|
|
39962
|
-
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
39963
|
-
patches = p;
|
|
39964
|
-
inversePatches = ip;
|
|
39965
|
-
});
|
|
39966
|
-
return [nextState, patches, inversePatches];
|
|
39967
|
-
};
|
|
39968
|
-
|
|
39969
|
-
Immer.prototype.createDraft = function createDraft (base) {
|
|
39970
|
-
if (!isDraftable(base)) {
|
|
39971
|
-
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
39972
|
-
}
|
|
39973
|
-
|
|
39974
|
-
var scope = ImmerScope.enter();
|
|
39975
|
-
var proxy = this.createProxy(base);
|
|
39976
|
-
proxy[DRAFT_STATE].isManual = true;
|
|
39977
|
-
scope.leave();
|
|
39978
|
-
return proxy;
|
|
39979
|
-
};
|
|
39980
|
-
|
|
39981
|
-
Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
39982
|
-
var state = draft && draft[DRAFT_STATE];
|
|
39983
|
-
|
|
39984
|
-
if (!state || !state.isManual) {
|
|
39985
|
-
throw new Error("First argument to `finishDraft` must be a draft returned by `createDraft`"); // prettier-ignore
|
|
39986
|
-
}
|
|
39987
|
-
|
|
39988
|
-
if (state.finalized) {
|
|
39989
|
-
throw new Error("The given draft is already finalized"); // prettier-ignore
|
|
39990
|
-
}
|
|
39991
|
-
|
|
39992
|
-
var scope = state.scope;
|
|
39993
|
-
scope.usePatches(patchListener);
|
|
39994
|
-
return this.processResult(undefined, scope);
|
|
39995
|
-
};
|
|
39996
|
-
|
|
39997
|
-
Immer.prototype.setAutoFreeze = function setAutoFreeze (value) {
|
|
39998
|
-
this.autoFreeze = value;
|
|
39999
|
-
};
|
|
40000
|
-
|
|
40001
|
-
Immer.prototype.setUseProxies = function setUseProxies (value) {
|
|
40002
|
-
this.useProxies = value;
|
|
40003
|
-
assign(this, value ? modernProxy : legacyProxy);
|
|
40004
|
-
};
|
|
40005
|
-
|
|
40006
|
-
Immer.prototype.applyPatches = function applyPatches$1 (base, patches) {
|
|
40007
|
-
// If a patch replaces the entire state, take that replacement as base
|
|
40008
|
-
// before applying patches
|
|
40009
|
-
var i;
|
|
40010
|
-
|
|
40011
|
-
for (i = patches.length - 1; i >= 0; i--) {
|
|
40012
|
-
var patch = patches[i];
|
|
40013
|
-
|
|
40014
|
-
if (patch.path.length === 0 && patch.op === "replace") {
|
|
40015
|
-
base = patch.value;
|
|
40016
|
-
break;
|
|
40017
|
-
}
|
|
40018
|
-
}
|
|
40019
|
-
|
|
40020
|
-
if (isDraft(base)) {
|
|
40021
|
-
// N.B: never hits if some patch a replacement, patches are never drafts
|
|
40022
|
-
return applyPatches(base, patches);
|
|
40023
|
-
} // Otherwise, produce a copy of the base state.
|
|
40024
|
-
|
|
40025
|
-
|
|
40026
|
-
return this.produce(base, function (draft) { return applyPatches(draft, patches.slice(i + 1)); });
|
|
40027
|
-
};
|
|
40028
|
-
/** @internal */
|
|
40029
|
-
|
|
40030
|
-
|
|
40031
|
-
Immer.prototype.processResult = function processResult (result, scope) {
|
|
40032
|
-
var baseDraft = scope.drafts[0];
|
|
40033
|
-
var isReplaced = result !== undefined && result !== baseDraft;
|
|
40034
|
-
this.willFinalize(scope, result, isReplaced);
|
|
40035
|
-
|
|
40036
|
-
if (isReplaced) {
|
|
40037
|
-
if (baseDraft[DRAFT_STATE].modified) {
|
|
40038
|
-
scope.revoke();
|
|
40039
|
-
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
|
|
40040
|
-
}
|
|
40041
|
-
|
|
40042
|
-
if (isDraftable(result)) {
|
|
40043
|
-
// Finalize the result in case it contains (or is) a subset of the draft.
|
|
40044
|
-
result = this.finalize(result, null, scope);
|
|
40045
|
-
}
|
|
40046
|
-
|
|
40047
|
-
if (scope.patches) {
|
|
40048
|
-
scope.patches.push({
|
|
40049
|
-
op: "replace",
|
|
40050
|
-
path: [],
|
|
40051
|
-
value: result
|
|
40052
|
-
});
|
|
40053
|
-
scope.inversePatches.push({
|
|
40054
|
-
op: "replace",
|
|
40055
|
-
path: [],
|
|
40056
|
-
value: baseDraft[DRAFT_STATE].base
|
|
40057
|
-
});
|
|
40058
|
-
}
|
|
40059
|
-
} else {
|
|
40060
|
-
// Finalize the base draft.
|
|
40061
|
-
result = this.finalize(baseDraft, [], scope);
|
|
40062
|
-
}
|
|
40063
|
-
|
|
40064
|
-
scope.revoke();
|
|
40065
|
-
|
|
40066
|
-
if (scope.patches) {
|
|
40067
|
-
scope.patchListener(scope.patches, scope.inversePatches);
|
|
40068
|
-
}
|
|
40069
|
-
|
|
40070
|
-
return result !== NOTHING ? result : undefined;
|
|
39137
|
+
return runFormValidators(fieldName, form, validators);
|
|
40071
39138
|
};
|
|
40072
|
-
/**
|
|
40073
|
-
* @internal
|
|
40074
|
-
* Finalize a draft, returning either the unmodified base state or a modified
|
|
40075
|
-
* copy of the base state.
|
|
40076
|
-
*/
|
|
40077
|
-
|
|
40078
|
-
|
|
40079
|
-
Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
40080
|
-
var this$1$1 = this;
|
|
40081
39139
|
|
|
40082
|
-
|
|
40083
|
-
|
|
40084
|
-
|
|
40085
|
-
|
|
40086
|
-
|
|
40087
|
-
|
|
40088
|
-
|
|
40089
|
-
|
|
40090
|
-
if (state.scope !== scope) {
|
|
40091
|
-
return draft;
|
|
40092
|
-
}
|
|
40093
|
-
|
|
40094
|
-
if (!state.modified) {
|
|
40095
|
-
return state.base;
|
|
39140
|
+
const computeErrorEntries = (formState) => {
|
|
39141
|
+
const fields = Object.entries(formState);
|
|
39142
|
+
for (let entry of fields) {
|
|
39143
|
+
let fieldName = entry[0];
|
|
39144
|
+
let errors = computeErrors(fieldName, formState);
|
|
39145
|
+
formState[fieldName].errors = errors;
|
|
39146
|
+
formState[fieldName].hasErrors = errors.length > 0;
|
|
40096
39147
|
}
|
|
40097
|
-
|
|
40098
|
-
if (!state.finalized) {
|
|
40099
|
-
state.finalized = true;
|
|
40100
|
-
this.finalizeTree(state.draft, path, scope);
|
|
40101
|
-
|
|
40102
|
-
if (this.onDelete) {
|
|
40103
|
-
// The `assigned` object is unreliable with ES5 drafts.
|
|
40104
|
-
if (this.useProxies) {
|
|
40105
|
-
var assigned = state.assigned;
|
|
40106
|
-
|
|
40107
|
-
for (var prop in assigned) {
|
|
40108
|
-
if (!assigned[prop]) { this.onDelete(state, prop); }
|
|
40109
|
-
}
|
|
40110
|
-
} else {
|
|
40111
|
-
var base = state.base;
|
|
40112
|
-
var copy = state.copy;
|
|
40113
|
-
each(base, function (prop) {
|
|
40114
|
-
if (!has$1(copy, prop)) { this$1$1.onDelete(state, prop); }
|
|
40115
|
-
});
|
|
40116
|
-
}
|
|
40117
|
-
}
|
|
40118
|
-
|
|
40119
|
-
if (this.onCopy) {
|
|
40120
|
-
this.onCopy(state);
|
|
40121
|
-
} // At this point, all descendants of `state.copy` have been finalized,
|
|
40122
|
-
// so we can be sure that `scope.canAutoFreeze` is accurate.
|
|
40123
|
-
|
|
40124
|
-
|
|
40125
|
-
if (this.autoFreeze && scope.canAutoFreeze) {
|
|
40126
|
-
Object.freeze(state.copy);
|
|
40127
|
-
}
|
|
40128
|
-
|
|
40129
|
-
if (path && scope.patches) {
|
|
40130
|
-
generatePatches(state, path, scope.patches, scope.inversePatches);
|
|
40131
|
-
}
|
|
40132
|
-
}
|
|
40133
|
-
|
|
40134
|
-
return state.copy;
|
|
40135
39148
|
};
|
|
40136
|
-
/**
|
|
40137
|
-
* @internal
|
|
40138
|
-
* Finalize all drafts in the given state tree.
|
|
40139
|
-
*/
|
|
40140
39149
|
|
|
40141
|
-
|
|
40142
|
-
|
|
40143
|
-
|
|
40144
|
-
|
|
40145
|
-
|
|
40146
|
-
|
|
40147
|
-
|
|
40148
|
-
if (!this.useProxies) {
|
|
40149
|
-
// Create the final copy, with added keys and without deleted keys.
|
|
40150
|
-
state.copy = shallowCopy(state.draft, true);
|
|
40151
|
-
}
|
|
40152
|
-
|
|
40153
|
-
root = state.copy;
|
|
39150
|
+
const computeDirtyEntries = (formState, changedFieldName) => {
|
|
39151
|
+
const fields = Object.entries(formState);
|
|
39152
|
+
for (let entry of fields) {
|
|
39153
|
+
let fieldName = entry[0];
|
|
39154
|
+
let field = entry[1];
|
|
39155
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
39156
|
+
formState[fieldName].dirty = dirty;
|
|
40154
39157
|
}
|
|
40155
|
-
|
|
40156
|
-
var needPatches = !!rootPath && !!scope.patches;
|
|
40157
|
-
|
|
40158
|
-
var finalizeProperty = function (prop, value, parent) {
|
|
40159
|
-
if (value === parent) {
|
|
40160
|
-
throw Error("Immer forbids circular references");
|
|
40161
|
-
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
40162
|
-
|
|
40163
|
-
|
|
40164
|
-
var isDraftProp = !!state && parent === root;
|
|
40165
|
-
|
|
40166
|
-
if (isDraft(value)) {
|
|
40167
|
-
var path = isDraftProp && needPatches && !state.assigned[prop] ? rootPath.concat(prop) : null; // Drafts owned by `scope` are finalized here.
|
|
40168
|
-
|
|
40169
|
-
value = this$1$1.finalize(value, path, scope); // Drafts from another scope must prevent auto-freezing.
|
|
40170
|
-
|
|
40171
|
-
if (isDraft(value)) {
|
|
40172
|
-
scope.canAutoFreeze = false;
|
|
40173
|
-
} // Preserve non-enumerable properties.
|
|
40174
|
-
|
|
40175
|
-
|
|
40176
|
-
if (Array.isArray(parent) || isEnumerable(parent, prop)) {
|
|
40177
|
-
parent[prop] = value;
|
|
40178
|
-
} else {
|
|
40179
|
-
Object.defineProperty(parent, prop, {
|
|
40180
|
-
value: value
|
|
40181
|
-
});
|
|
40182
|
-
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
40183
|
-
|
|
40184
|
-
|
|
40185
|
-
if (isDraftProp && value === state.base[prop]) { return; }
|
|
40186
|
-
} // Unchanged draft properties are ignored.
|
|
40187
|
-
else if (isDraftProp && is(value, state.base[prop])) {
|
|
40188
|
-
return;
|
|
40189
|
-
} // Search new objects for unfinalized drafts. Frozen objects should never contain drafts.
|
|
40190
|
-
else if (isDraftable(value) && !Object.isFrozen(value)) {
|
|
40191
|
-
each(value, finalizeProperty);
|
|
40192
|
-
}
|
|
40193
|
-
|
|
40194
|
-
if (isDraftProp && this$1$1.onAssign) {
|
|
40195
|
-
this$1$1.onAssign(state, prop, value);
|
|
40196
|
-
}
|
|
40197
|
-
};
|
|
40198
|
-
|
|
40199
|
-
each(root, finalizeProperty);
|
|
40200
|
-
return root;
|
|
40201
39158
|
};
|
|
40202
39159
|
|
|
40203
|
-
var immer = new Immer();
|
|
40204
|
-
/**
|
|
40205
|
-
* The `produce` function takes a value and a "recipe function" (whose
|
|
40206
|
-
* return value often depends on the base state). The recipe function is
|
|
40207
|
-
* free to mutate its first argument however it wants. All mutations are
|
|
40208
|
-
* only ever applied to a __copy__ of the base state.
|
|
40209
|
-
*
|
|
40210
|
-
* Pass only a function to create a "curried producer" which relieves you
|
|
40211
|
-
* from passing the recipe function every time.
|
|
40212
|
-
*
|
|
40213
|
-
* Only plain objects and arrays are made mutable. All other objects are
|
|
40214
|
-
* considered uncopyable.
|
|
40215
|
-
*
|
|
40216
|
-
* Note: This function is __bound__ to its `Immer` instance.
|
|
40217
|
-
*
|
|
40218
|
-
* @param {any} base - the initial state
|
|
40219
|
-
* @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified
|
|
40220
|
-
* @param {Function} patchListener - optional function that will be called with all the patches produced here
|
|
40221
|
-
* @returns {any} a new state, or the initial state if nothing was modified
|
|
40222
|
-
*/
|
|
40223
|
-
|
|
40224
|
-
var produce = immer.produce;
|
|
40225
|
-
/**
|
|
40226
|
-
* Like `produce`, but `produceWithPatches` always returns a tuple
|
|
40227
|
-
* [nextState, patches, inversePatches] (instead of just the next state)
|
|
40228
|
-
*/
|
|
40229
|
-
|
|
40230
|
-
immer.produceWithPatches.bind(immer);
|
|
40231
|
-
/**
|
|
40232
|
-
* Pass true to automatically freeze all copies created by Immer.
|
|
40233
|
-
*
|
|
40234
|
-
* By default, auto-freezing is disabled in production.
|
|
40235
|
-
*/
|
|
40236
|
-
|
|
40237
|
-
immer.setAutoFreeze.bind(immer);
|
|
40238
|
-
/**
|
|
40239
|
-
* Pass true to use the ES2015 `Proxy` class when creating drafts, which is
|
|
40240
|
-
* always faster than using ES5 proxies.
|
|
40241
|
-
*
|
|
40242
|
-
* By default, feature detection is used, so calling this is rarely necessary.
|
|
40243
|
-
*/
|
|
39160
|
+
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;
|
|
40244
39161
|
|
|
40245
|
-
|
|
40246
|
-
/**
|
|
40247
|
-
* Apply an array of Immer patches to the first argument.
|
|
40248
|
-
*
|
|
40249
|
-
* This function is a producer, which means copy-on-write is in effect.
|
|
40250
|
-
*/
|
|
40251
|
-
|
|
40252
|
-
immer.applyPatches.bind(immer);
|
|
40253
|
-
/**
|
|
40254
|
-
* Create an Immer draft from the given base state, which may be a draft itself.
|
|
40255
|
-
* The draft can be modified until you finalize it with the `finishDraft` function.
|
|
40256
|
-
*/
|
|
40257
|
-
|
|
40258
|
-
immer.createDraft.bind(immer);
|
|
40259
|
-
/**
|
|
40260
|
-
* Finalize an Immer draft from a `createDraft` call, returning the base state
|
|
40261
|
-
* (if no changes were made) or a modified copy. The draft must *not* be
|
|
40262
|
-
* mutated afterwards.
|
|
40263
|
-
*
|
|
40264
|
-
* Pass a function as the 2nd argument to generate Immer patches based on the
|
|
40265
|
-
* changes that were made.
|
|
40266
|
-
*/
|
|
40267
|
-
|
|
40268
|
-
immer.finishDraft.bind(immer);
|
|
40269
|
-
|
|
40270
|
-
const createInitialState = formConfig => {
|
|
39162
|
+
const createInitialState = (formConfig) => {
|
|
40271
39163
|
let initialForm = {};
|
|
40272
39164
|
const formConfigKeys = Object.keys(formConfig);
|
|
40273
39165
|
for (let formKey of formConfigKeys) {
|
|
40274
39166
|
initialForm[formKey] = {
|
|
40275
39167
|
dirty: false,
|
|
40276
|
-
rawValue: formConfig[formKey].defaultValue ||
|
|
39168
|
+
rawValue: formConfig[formKey].defaultValue || '',
|
|
40277
39169
|
validators: formConfig[formKey].validators || [],
|
|
40278
|
-
constraints: formConfig[formKey].constraints || []
|
|
39170
|
+
constraints: formConfig[formKey].constraints || [],
|
|
40279
39171
|
};
|
|
40280
39172
|
}
|
|
40281
39173
|
// Because validators require the entire form we have to do a
|
|
@@ -40286,82 +39178,99 @@ const createInitialState = formConfig => {
|
|
|
40286
39178
|
initialForm[formKey].errors = errors;
|
|
40287
39179
|
initialForm[formKey].hasErrors = errors.length > 0;
|
|
40288
39180
|
}
|
|
39181
|
+
|
|
40289
39182
|
return initialForm;
|
|
40290
39183
|
};
|
|
40291
39184
|
|
|
40292
|
-
const SET =
|
|
40293
|
-
const set$
|
|
39185
|
+
const SET = 'field/SET';
|
|
39186
|
+
const set$1 = (fieldName) => (value) => ({
|
|
40294
39187
|
type: SET,
|
|
40295
|
-
payload: { fieldName, value }
|
|
39188
|
+
payload: { fieldName, value },
|
|
40296
39189
|
});
|
|
40297
39190
|
|
|
40298
|
-
const CLEAR =
|
|
39191
|
+
const CLEAR = 'form/CLEAR';
|
|
40299
39192
|
const clear = () => ({ type: CLEAR });
|
|
40300
39193
|
|
|
40301
|
-
const ADD_VALIDATOR =
|
|
40302
|
-
const addValidator = fieldName => validator => ({
|
|
39194
|
+
const ADD_VALIDATOR = 'field/ADD_VALIDATOR';
|
|
39195
|
+
const addValidator = (fieldName) => (validator) => ({
|
|
40303
39196
|
type: ADD_VALIDATOR,
|
|
40304
|
-
payload: { fieldName, validator }
|
|
39197
|
+
payload: { fieldName, validator },
|
|
40305
39198
|
});
|
|
40306
39199
|
|
|
40307
|
-
const
|
|
40308
|
-
|
|
40309
|
-
|
|
40310
|
-
|
|
40311
|
-
|
|
40312
|
-
case SET:
|
|
40313
|
-
const changedFieldName = action.payload.fieldName;
|
|
40314
|
-
const newRawValue = action.payload.value;
|
|
40315
|
-
|
|
40316
|
-
return produce(state, draftState => {
|
|
40317
|
-
let originalValue = draftState[changedFieldName].rawValue;
|
|
40318
|
-
draftState[changedFieldName].rawValue = newRawValue;
|
|
40319
|
-
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
40320
|
-
// If the change violates constraints, revert the change
|
|
40321
|
-
draftState[changedFieldName].rawValue = originalValue;
|
|
40322
|
-
return draftState;
|
|
40323
|
-
}
|
|
39200
|
+
const REMOVE_VALIDATOR = 'field/REMOVE_VALIDATOR';
|
|
39201
|
+
const removeValidator = (fieldName) => (validator) => ({
|
|
39202
|
+
type: REMOVE_VALIDATOR,
|
|
39203
|
+
payload: { fieldName, validator },
|
|
39204
|
+
});
|
|
40324
39205
|
|
|
40325
|
-
|
|
40326
|
-
|
|
40327
|
-
|
|
40328
|
-
|
|
40329
|
-
|
|
40330
|
-
|
|
40331
|
-
|
|
40332
|
-
|
|
40333
|
-
|
|
40334
|
-
|
|
40335
|
-
|
|
40336
|
-
|
|
40337
|
-
|
|
40338
|
-
|
|
40339
|
-
|
|
40340
|
-
|
|
40341
|
-
|
|
40342
|
-
|
|
40343
|
-
|
|
40344
|
-
|
|
40345
|
-
|
|
40346
|
-
|
|
40347
|
-
|
|
40348
|
-
|
|
40349
|
-
|
|
40350
|
-
|
|
40351
|
-
|
|
40352
|
-
|
|
40353
|
-
|
|
40354
|
-
|
|
40355
|
-
|
|
40356
|
-
|
|
40357
|
-
|
|
40358
|
-
|
|
39206
|
+
const CLEAR_FIELD_VALIDATORS = 'field/CLEAR_FIELD_VALIDATORS';
|
|
39207
|
+
const clearFieldValidators = (fieldName) => () => ({
|
|
39208
|
+
type: CLEAR_FIELD_VALIDATORS,
|
|
39209
|
+
payload: { fieldName },
|
|
39210
|
+
});
|
|
39211
|
+
|
|
39212
|
+
const createFormReducer =
|
|
39213
|
+
(formConfig) =>
|
|
39214
|
+
(state = createInitialState(formConfig), action) => {
|
|
39215
|
+
switch (action.type) {
|
|
39216
|
+
case SET: {
|
|
39217
|
+
const changedFieldName = action.payload.fieldName;
|
|
39218
|
+
const newRawValue = action.payload.value;
|
|
39219
|
+
|
|
39220
|
+
return produce(state, (draftState) => {
|
|
39221
|
+
let originalValue = draftState[changedFieldName].rawValue;
|
|
39222
|
+
draftState[changedFieldName].rawValue = newRawValue;
|
|
39223
|
+
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
39224
|
+
// If the change violates constraints, revert the change
|
|
39225
|
+
draftState[changedFieldName].rawValue = originalValue;
|
|
39226
|
+
return draftState;
|
|
39227
|
+
}
|
|
39228
|
+
|
|
39229
|
+
computeDirtyEntries(draftState, changedFieldName);
|
|
39230
|
+
computeErrorEntries(draftState);
|
|
39231
|
+
});
|
|
39232
|
+
}
|
|
39233
|
+
case CLEAR:
|
|
39234
|
+
return createInitialState(formConfig);
|
|
39235
|
+
case ADD_VALIDATOR: {
|
|
39236
|
+
const fieldWithOverride = action.payload.fieldName;
|
|
39237
|
+
const newValidator = action.payload.validator;
|
|
39238
|
+
|
|
39239
|
+
return produce(state, (draftState) => {
|
|
39240
|
+
draftState[fieldWithOverride].validators.push(newValidator);
|
|
39241
|
+
computeErrorEntries(draftState);
|
|
39242
|
+
});
|
|
39243
|
+
}
|
|
39244
|
+
case REMOVE_VALIDATOR: {
|
|
39245
|
+
const fieldToOverride = action.payload.fieldName;
|
|
39246
|
+
const targetValidator = action.payload.validator;
|
|
39247
|
+
|
|
39248
|
+
return produce(state, (draftState) => {
|
|
39249
|
+
let fieldValidators = draftState[fieldToOverride].validators;
|
|
39250
|
+
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
39251
|
+
(validator) => validator.type !== targetValidator.type
|
|
39252
|
+
);
|
|
39253
|
+
computeErrorEntries(draftState);
|
|
39254
|
+
});
|
|
39255
|
+
}
|
|
39256
|
+
case CLEAR_FIELD_VALIDATORS: {
|
|
39257
|
+
const fieldToClear = action.payload.fieldName;
|
|
39258
|
+
|
|
39259
|
+
return produce(state, (draftState) => {
|
|
39260
|
+
draftState[fieldToClear].validators = [];
|
|
39261
|
+
computeErrorEntries(draftState);
|
|
39262
|
+
});
|
|
39263
|
+
}
|
|
39264
|
+
default:
|
|
39265
|
+
return state;
|
|
39266
|
+
}
|
|
39267
|
+
};
|
|
40359
39268
|
|
|
40360
|
-
const createMapDispatchToProps = formConfig => {
|
|
39269
|
+
const createMapDispatchToProps = (formConfig) => {
|
|
40361
39270
|
// Do memo-ization
|
|
40362
39271
|
let cachedDispatch;
|
|
40363
39272
|
let cacheValue;
|
|
40364
|
-
return dispatch => {
|
|
39273
|
+
return (dispatch) => {
|
|
40365
39274
|
if (dispatch == cachedDispatch) {
|
|
40366
39275
|
return cacheValue;
|
|
40367
39276
|
}
|
|
@@ -40370,8 +39279,11 @@ const createMapDispatchToProps = formConfig => {
|
|
|
40370
39279
|
const keys = Object.keys(formConfig);
|
|
40371
39280
|
for (let fieldName of keys) {
|
|
40372
39281
|
dispatchObj.fields[fieldName] = {
|
|
40373
|
-
set: value => dispatch(set$
|
|
40374
|
-
addValidator: validator => dispatch(addValidator(fieldName)(validator))
|
|
39282
|
+
set: (value) => dispatch(set$1(fieldName)(value)),
|
|
39283
|
+
addValidator: (validator) => dispatch(addValidator(fieldName)(validator)),
|
|
39284
|
+
removeValidator: (validator) =>
|
|
39285
|
+
dispatch(removeValidator(fieldName)(validator)),
|
|
39286
|
+
clear: () => dispatch(clearFieldValidators(fieldName)()),
|
|
40375
39287
|
};
|
|
40376
39288
|
}
|
|
40377
39289
|
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
@@ -40381,12 +39293,12 @@ const createMapDispatchToProps = formConfig => {
|
|
|
40381
39293
|
};
|
|
40382
39294
|
};
|
|
40383
39295
|
|
|
40384
|
-
const mapStateToProps = state => ({ fields: state });
|
|
39296
|
+
const mapStateToProps = (state) => ({ fields: state });
|
|
40385
39297
|
|
|
40386
|
-
const createFormState = formConfig => ({
|
|
39298
|
+
const createFormState = (formConfig) => ({
|
|
40387
39299
|
reducer: createFormReducer(formConfig),
|
|
40388
39300
|
mapDispatchToProps: createMapDispatchToProps(formConfig),
|
|
40389
|
-
mapStateToProps: mapStateToProps
|
|
39301
|
+
mapStateToProps: mapStateToProps,
|
|
40390
39302
|
});
|
|
40391
39303
|
|
|
40392
39304
|
var AddressForm = function AddressForm(_ref) {
|
|
@@ -40478,7 +39390,7 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
40478
39390
|
onKeyDown: function onKeyDown(e) {
|
|
40479
39391
|
return e.key === "Enter" && handleSubmit(e);
|
|
40480
39392
|
},
|
|
40481
|
-
autocompleteValue: "
|
|
39393
|
+
autocompleteValue: "address-level2",
|
|
40482
39394
|
dataQa: "City"
|
|
40483
39395
|
}), /*#__PURE__*/React__default.createElement(FormStateDropdown, {
|
|
40484
39396
|
labelTextWhenNoError: isUS ? "State" : "State or Province",
|
|
@@ -40490,7 +39402,6 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
40490
39402
|
onKeyDown: function onKeyDown(e) {
|
|
40491
39403
|
return e.key === "Enter" && handleSubmit(e);
|
|
40492
39404
|
},
|
|
40493
|
-
autocompleteValue: "administrative-area",
|
|
40494
39405
|
dataQa: "State or Province"
|
|
40495
39406
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
40496
39407
|
isNum: isUS,
|
|
@@ -43252,12 +42163,12 @@ LoginForm.mapDispatchToProps = mapDispatchToProps$5;
|
|
|
43252
42163
|
* This source code is licensed under the MIT license found in the
|
|
43253
42164
|
* LICENSE file in the root directory of this source tree.
|
|
43254
42165
|
*/
|
|
43255
|
-
var b$
|
|
43256
|
-
Symbol.for("react.suspense_list"):60120,r=b$
|
|
43257
|
-
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c$
|
|
43258
|
-
var Profiler=g;var StrictMode=f$
|
|
43259
|
-
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$
|
|
43260
|
-
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f$
|
|
42166
|
+
var b$2="function"===typeof Symbol&&Symbol.for,c$2=b$2?Symbol.for("react.element"):60103,d$1=b$2?Symbol.for("react.portal"):60106,e=b$2?Symbol.for("react.fragment"):60107,f$7=b$2?Symbol.for("react.strict_mode"):60108,g$1=b$2?Symbol.for("react.profiler"):60114,h$1=b$2?Symbol.for("react.provider"):60109,k$1=b$2?Symbol.for("react.context"):60110,l$1=b$2?Symbol.for("react.async_mode"):60111,m=b$2?Symbol.for("react.concurrent_mode"):60111,n$1=b$2?Symbol.for("react.forward_ref"):60112,p$1=b$2?Symbol.for("react.suspense"):60113,q$1=b$2?
|
|
42167
|
+
Symbol.for("react.suspense_list"):60120,r$1=b$2?Symbol.for("react.memo"):60115,t$1=b$2?Symbol.for("react.lazy"):60116,v$1=b$2?Symbol.for("react.block"):60121,w$1=b$2?Symbol.for("react.fundamental"):60117,x$1=b$2?Symbol.for("react.responder"):60118,y$1=b$2?Symbol.for("react.scope"):60119;
|
|
42168
|
+
function z$1(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c$2:switch(a=a.type,a){case l$1:case m:case e:case g$1:case f$7:case p$1:return a;default:switch(a=a&&a.$$typeof,a){case k$1:case n$1:case t$1:case r$1:case h$1:return a;default:return u}}case d$1:return u}}}function A$1(a){return z$1(a)===m}var AsyncMode=l$1;var ConcurrentMode=m;var ContextConsumer=k$1;var ContextProvider=h$1;var Element$1=c$2;var ForwardRef=n$1;var Fragment=e;var Lazy=t$1;var Memo=r$1;var Portal=d$1;
|
|
42169
|
+
var Profiler=g$1;var StrictMode=f$7;var Suspense=p$1;var isAsyncMode=function(a){return A$1(a)||z$1(a)===l$1};var isConcurrentMode=A$1;var isContextConsumer=function(a){return z$1(a)===k$1};var isContextProvider=function(a){return z$1(a)===h$1};var isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c$2};var isForwardRef=function(a){return z$1(a)===n$1};var isFragment=function(a){return z$1(a)===e};var isLazy=function(a){return z$1(a)===t$1};
|
|
42170
|
+
var isMemo=function(a){return z$1(a)===r$1};var isPortal=function(a){return z$1(a)===d$1};var isProfiler=function(a){return z$1(a)===g$1};var isStrictMode=function(a){return z$1(a)===f$7};var isSuspense=function(a){return z$1(a)===p$1};
|
|
42171
|
+
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g$1||a===f$7||a===p$1||a===q$1||"object"===typeof a&&null!==a&&(a.$$typeof===t$1||a.$$typeof===r$1||a.$$typeof===h$1||a.$$typeof===k$1||a.$$typeof===n$1||a.$$typeof===w$1||a.$$typeof===x$1||a.$$typeof===y$1||a.$$typeof===v$1)};var typeOf=z$1;
|
|
43261
42172
|
|
|
43262
42173
|
var reactIs_production_min = {
|
|
43263
42174
|
AsyncMode: AsyncMode,
|
|
@@ -43628,14 +42539,14 @@ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
|
43628
42539
|
|
|
43629
42540
|
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
43630
42541
|
|
|
43631
|
-
var has$
|
|
42542
|
+
var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
43632
42543
|
|
|
43633
42544
|
var printWarning = function() {};
|
|
43634
42545
|
|
|
43635
42546
|
if (process.env.NODE_ENV !== 'production') {
|
|
43636
42547
|
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
43637
42548
|
var loggedTypeFailures = {};
|
|
43638
|
-
var has$
|
|
42549
|
+
var has$2 = has$1;
|
|
43639
42550
|
|
|
43640
42551
|
printWarning = function(text) {
|
|
43641
42552
|
var message = 'Warning: ' + text;
|
|
@@ -43665,7 +42576,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
43665
42576
|
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
43666
42577
|
if (process.env.NODE_ENV !== 'production') {
|
|
43667
42578
|
for (var typeSpecName in typeSpecs) {
|
|
43668
|
-
if (has$
|
|
42579
|
+
if (has$2(typeSpecs, typeSpecName)) {
|
|
43669
42580
|
var error;
|
|
43670
42581
|
// Prop type validation may throw. In case they do, we don't want to
|
|
43671
42582
|
// fail the render phase where it didn't fail before. So we log it.
|
|
@@ -44064,7 +42975,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44064
42975
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
44065
42976
|
}
|
|
44066
42977
|
for (var key in propValue) {
|
|
44067
|
-
if (has$
|
|
42978
|
+
if (has$1(propValue, key)) {
|
|
44068
42979
|
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
44069
42980
|
if (error instanceof Error) {
|
|
44070
42981
|
return error;
|
|
@@ -44101,7 +43012,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44101
43012
|
if (checkerResult == null) {
|
|
44102
43013
|
return null;
|
|
44103
43014
|
}
|
|
44104
|
-
if (checkerResult.data && has$
|
|
43015
|
+
if (checkerResult.data && has$1(checkerResult.data, 'expectedType')) {
|
|
44105
43016
|
expectedTypes.push(checkerResult.data.expectedType);
|
|
44106
43017
|
}
|
|
44107
43018
|
}
|
|
@@ -44161,7 +43072,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44161
43072
|
var allKeys = objectAssign({}, props[propName], shapeTypes);
|
|
44162
43073
|
for (var key in allKeys) {
|
|
44163
43074
|
var checker = shapeTypes[key];
|
|
44164
|
-
if (has$
|
|
43075
|
+
if (has$1(shapeTypes, key) && typeof checker !== 'function') {
|
|
44165
43076
|
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
44166
43077
|
}
|
|
44167
43078
|
if (!checker) {
|
|
@@ -44899,7 +43810,7 @@ var index_esm = /*#__PURE__*/Object.freeze({
|
|
|
44899
43810
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
44900
43811
|
*/
|
|
44901
43812
|
|
|
44902
|
-
function ownKeys$
|
|
43813
|
+
function ownKeys$2(object, enumerableOnly) {
|
|
44903
43814
|
var keys = Object.keys(object);
|
|
44904
43815
|
|
|
44905
43816
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -44915,9 +43826,9 @@ function ownKeys$3(object, enumerableOnly) {
|
|
|
44915
43826
|
function _objectSpread2$1(target) {
|
|
44916
43827
|
for (var i = 1; i < arguments.length; i++) {
|
|
44917
43828
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
44918
|
-
i % 2 ? ownKeys$
|
|
43829
|
+
i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) {
|
|
44919
43830
|
_defineProperty$1(target, key, source[key]);
|
|
44920
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$
|
|
43831
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) {
|
|
44921
43832
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
44922
43833
|
});
|
|
44923
43834
|
}
|
|
@@ -47827,8 +46738,6 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
47827
46738
|
actions = _ref.actions,
|
|
47828
46739
|
_ref$showErrors = _ref.showErrors,
|
|
47829
46740
|
showErrors = _ref$showErrors === void 0 ? false : _ref$showErrors;
|
|
47830
|
-
console.log("fields", fields);
|
|
47831
|
-
console.log("actions", actions);
|
|
47832
46741
|
|
|
47833
46742
|
if (clearOnDismount) {
|
|
47834
46743
|
useEffect(function () {
|
|
@@ -47891,14 +46800,12 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
|
|
|
47891
46800
|
var blockPartialPaymentOverpay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
47892
46801
|
var formConfig = lineItems.reduce(function (acc, item) {
|
|
47893
46802
|
var validators = createPartialAmountFormValidators(item, lineItems, maximum, minimum, blockPartialPaymentOverpay);
|
|
47894
|
-
console.log("item and validators", item, validators);
|
|
47895
46803
|
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, item.id, {
|
|
47896
46804
|
validators: validators,
|
|
47897
46805
|
constraints: [onlyNaturals()],
|
|
47898
46806
|
defaultValue: String(item.amount)
|
|
47899
46807
|
}));
|
|
47900
46808
|
}, {});
|
|
47901
|
-
console.log("form config is", formConfig);
|
|
47902
46809
|
|
|
47903
46810
|
var _createFormState = createFormState(formConfig),
|
|
47904
46811
|
reducer = _createFormState.reducer,
|
|
@@ -49501,7 +48408,7 @@ var PhoneForm = function PhoneForm(_ref) {
|
|
|
49501
48408
|
onKeyUp: function onKeyUp(e) {
|
|
49502
48409
|
return e.key === "Enter" && handleSubmit(e);
|
|
49503
48410
|
},
|
|
49504
|
-
autocompleteValue: "tel",
|
|
48411
|
+
autocompleteValue: "tel-national",
|
|
49505
48412
|
dataQa: "Phone number",
|
|
49506
48413
|
isNum: true
|
|
49507
48414
|
}), showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
|