@thecb/components 9.2.0 → 9.2.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +323 -1364
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +323 -1364
- package/dist/index.esm.js.map +1 -1
- package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +49322 -0
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/atoms/.DS_Store +0 -0
- package/src/components/atoms/checkbox/Checkbox.js +3 -1
- package/src/components/atoms/checkbox/Checkbox.stories.js +3 -2
- package/src/components/atoms/country-dropdown/CountryDropdown.js +3 -1
- package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +1 -0
- package/src/components/atoms/dropdown/Dropdown.js +7 -3
- package/src/components/atoms/form-layouts/FormInput.js +3 -0
- package/src/components/atoms/form-select/FormSelect.js +22 -9
- package/src/components/atoms/form-select/FormSelect.stories.js +2 -2
- package/src/components/atoms/icons/.DS_Store +0 -0
- package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.js +9 -6
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +4 -1
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +1 -0
- package/src/components/molecules/address-form/AddressForm.js +6 -0
- package/src/components/molecules/payment-form-ach/PaymentFormACH.js +6 -0
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +6 -0
- package/src/components/molecules/radio-group/RadioGroup.js +1 -1
- package/src/components/molecules/radio-section/RadioSection.js +1 -0
- package/src/components/molecules/radio-section/RadioSection.stories.js +3 -2
- package/src/components/molecules/radio-section/radio-button/RadioButton.js +4 -1
package/dist/index.esm.js
CHANGED
|
@@ -22126,7 +22126,9 @@ var Checkbox = function Checkbox(_ref4) {
|
|
|
22126
22126
|
extraStyles = _ref4.extraStyles,
|
|
22127
22127
|
textExtraStyles = _ref4.textExtraStyles,
|
|
22128
22128
|
_ref4$dataQa = _ref4.dataQa,
|
|
22129
|
-
dataQa = _ref4$dataQa === void 0 ? null : _ref4$dataQa
|
|
22129
|
+
dataQa = _ref4$dataQa === void 0 ? null : _ref4$dataQa,
|
|
22130
|
+
_ref4$isRequired = _ref4.isRequired,
|
|
22131
|
+
isRequired = _ref4$isRequired === void 0 ? false : _ref4$isRequired;
|
|
22130
22132
|
|
|
22131
22133
|
var _useState = useState(false),
|
|
22132
22134
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -22180,7 +22182,8 @@ var Checkbox = function Checkbox(_ref4) {
|
|
|
22180
22182
|
errorStyles: themeValues.errorStyles,
|
|
22181
22183
|
disabledStyles: themeValues.disabledStyles,
|
|
22182
22184
|
disabledCheckedStyles: themeValues.disabledCheckedStyles,
|
|
22183
|
-
focusedStyles: themeValues.focusedStyles
|
|
22185
|
+
focusedStyles: themeValues.focusedStyles,
|
|
22186
|
+
"aria-required": isRequired
|
|
22184
22187
|
}, /*#__PURE__*/React.createElement(CheckboxIcon, {
|
|
22185
22188
|
viewBox: "0 0 24 24",
|
|
22186
22189
|
disabled: disabled,
|
|
@@ -23791,7 +23794,11 @@ var Dropdown = function Dropdown(_ref13) {
|
|
|
23791
23794
|
_ref13$smoothScroll = _ref13.smoothScroll,
|
|
23792
23795
|
smoothScroll = _ref13$smoothScroll === void 0 ? true : _ref13$smoothScroll,
|
|
23793
23796
|
_ref13$ariaInvalid = _ref13.ariaInvalid,
|
|
23794
|
-
ariaInvalid = _ref13$ariaInvalid === void 0 ? false : _ref13$ariaInvalid
|
|
23797
|
+
ariaInvalid = _ref13$ariaInvalid === void 0 ? false : _ref13$ariaInvalid,
|
|
23798
|
+
_ref13$isRequired = _ref13.isRequired,
|
|
23799
|
+
isRequired = _ref13$isRequired === void 0 ? false : _ref13$isRequired;
|
|
23800
|
+
|
|
23801
|
+
var required = options.required || isRequired;
|
|
23795
23802
|
|
|
23796
23803
|
var _useState = useState(""),
|
|
23797
23804
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -24040,7 +24047,7 @@ var Dropdown = function Dropdown(_ref13) {
|
|
|
24040
24047
|
"aria-labelledby": ariaLabelledby,
|
|
24041
24048
|
"aria-describedby": ariaDescribedby,
|
|
24042
24049
|
"aria-expanded": isOpen,
|
|
24043
|
-
"aria-required":
|
|
24050
|
+
"aria-required": required,
|
|
24044
24051
|
"aria-invalid": ariaInvalid,
|
|
24045
24052
|
background: isOpen ? themeValues.hoverColor : WHITE,
|
|
24046
24053
|
borderRadius: "2px",
|
|
@@ -24062,7 +24069,6 @@ var Dropdown = function Dropdown(_ref13) {
|
|
|
24062
24069
|
},
|
|
24063
24070
|
padding: "12px",
|
|
24064
24071
|
placeholder: getSelection(),
|
|
24065
|
-
required: options.required,
|
|
24066
24072
|
role: "combobox",
|
|
24067
24073
|
themeValues: themeValues,
|
|
24068
24074
|
title: hasTitles ? getSelection() : null,
|
|
@@ -24070,6 +24076,9 @@ var Dropdown = function Dropdown(_ref13) {
|
|
|
24070
24076
|
tabIndex: 0,
|
|
24071
24077
|
value: inputValue,
|
|
24072
24078
|
width: "100%"
|
|
24079
|
+
/* Non-semantic elements need the aria-* version of the attribute */
|
|
24080
|
+
,
|
|
24081
|
+
"aria-disabled": disabledValues.includes(inputValue)
|
|
24073
24082
|
}), /*#__PURE__*/React.createElement(IconWrapper, {
|
|
24074
24083
|
open: isOpen,
|
|
24075
24084
|
onClick: _onClick
|
|
@@ -24080,7 +24089,8 @@ var Dropdown = function Dropdown(_ref13) {
|
|
|
24080
24089
|
widthFitOptions: widthFitOptions,
|
|
24081
24090
|
tabIndex: 0,
|
|
24082
24091
|
role: "listbox",
|
|
24083
|
-
id: "".concat(ariaLabelledby, "_listbox")
|
|
24092
|
+
id: "".concat(ariaLabelledby, "_listbox"),
|
|
24093
|
+
required: required
|
|
24084
24094
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
24085
24095
|
childGap: "0",
|
|
24086
24096
|
as: "ul"
|
|
@@ -24230,7 +24240,9 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
24230
24240
|
_ref$dataQa = _ref.dataQa,
|
|
24231
24241
|
dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa,
|
|
24232
24242
|
_ref$widthFitOptions = _ref.widthFitOptions,
|
|
24233
|
-
widthFitOptions = _ref$widthFitOptions === void 0 ? false : _ref$widthFitOptions
|
|
24243
|
+
widthFitOptions = _ref$widthFitOptions === void 0 ? false : _ref$widthFitOptions,
|
|
24244
|
+
_ref$isRequired = _ref.isRequired,
|
|
24245
|
+
isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired;
|
|
24234
24246
|
|
|
24235
24247
|
var _useState = useState(false),
|
|
24236
24248
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -24238,6 +24250,17 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
24238
24250
|
setOpen = _useState2[1];
|
|
24239
24251
|
|
|
24240
24252
|
var dropdownRef = useRef(null);
|
|
24253
|
+
var required = (options === null || options === void 0 ? void 0 : options.required) || isRequired;
|
|
24254
|
+
var labelId = useMemo(function () {
|
|
24255
|
+
return function (labelTextWhenNoError) {
|
|
24256
|
+
return createIdFromString(labelTextWhenNoError);
|
|
24257
|
+
};
|
|
24258
|
+
}, [labelTextWhenNoError]);
|
|
24259
|
+
var descriptionId = useMemo(function () {
|
|
24260
|
+
return function (field, labelTextWhenNoError) {
|
|
24261
|
+
return field.hasErrors && field.dirty ? labelId(labelTextWhenNoError) + "error-message" : "";
|
|
24262
|
+
};
|
|
24263
|
+
}, [field, labelTextWhenNoError]);
|
|
24241
24264
|
|
|
24242
24265
|
var handleClickAway = function handleClickAway(event) {
|
|
24243
24266
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
@@ -24253,8 +24276,8 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
24253
24276
|
});
|
|
24254
24277
|
return /*#__PURE__*/React.createElement(SelectContainer, {
|
|
24255
24278
|
ref: dropdownRef,
|
|
24279
|
+
"aria-role": "group",
|
|
24256
24280
|
disabled: disabled,
|
|
24257
|
-
"aria-disabled": disabled,
|
|
24258
24281
|
"data-qa": dataQa
|
|
24259
24282
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
24260
24283
|
padding: "0",
|
|
@@ -24268,10 +24291,10 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
24268
24291
|
color: themeValues.labelColor,
|
|
24269
24292
|
weight: themeValues.fontWeight,
|
|
24270
24293
|
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
24271
|
-
id:
|
|
24294
|
+
id: labelId(labelTextWhenNoError)
|
|
24272
24295
|
}, labelTextWhenNoError))), /*#__PURE__*/React.createElement(Dropdown$1, {
|
|
24273
|
-
ariaLabelledby:
|
|
24274
|
-
ariaDescribedby:
|
|
24296
|
+
ariaLabelledby: labelId(labelTextWhenNoError),
|
|
24297
|
+
ariaDescribedby: descriptionId(field, labelTextWhenNoError),
|
|
24275
24298
|
maxHeight: dropdownMaxHeight,
|
|
24276
24299
|
widthFitOptions: widthFitOptions,
|
|
24277
24300
|
hasTitles: hasTitles,
|
|
@@ -24292,7 +24315,8 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
24292
24315
|
},
|
|
24293
24316
|
disabled: disabled,
|
|
24294
24317
|
autocompleteValue: autocompleteValue,
|
|
24295
|
-
smoothScroll: smoothScroll
|
|
24318
|
+
smoothScroll: smoothScroll,
|
|
24319
|
+
isRequired: required
|
|
24296
24320
|
}), /*#__PURE__*/React.createElement(Stack, {
|
|
24297
24321
|
direction: "row",
|
|
24298
24322
|
justify: "space-between"
|
|
@@ -25062,7 +25086,9 @@ var CountryDropdown = function CountryDropdown(_ref) {
|
|
|
25062
25086
|
showErrors = _ref.showErrors,
|
|
25063
25087
|
onChange = _ref.onChange,
|
|
25064
25088
|
_ref$dataQa = _ref.dataQa,
|
|
25065
|
-
dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa
|
|
25089
|
+
dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa,
|
|
25090
|
+
_ref$isRequired = _ref.isRequired,
|
|
25091
|
+
isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired;
|
|
25066
25092
|
return /*#__PURE__*/React.createElement(FormSelect$1, {
|
|
25067
25093
|
options: options,
|
|
25068
25094
|
field: field,
|
|
@@ -25072,7 +25098,8 @@ var CountryDropdown = function CountryDropdown(_ref) {
|
|
|
25072
25098
|
errorMessages: errorMessages,
|
|
25073
25099
|
showErrors: showErrors,
|
|
25074
25100
|
onChange: onChange,
|
|
25075
|
-
autocompleteValue: "country-name"
|
|
25101
|
+
autocompleteValue: "country-name",
|
|
25102
|
+
isRequired: isRequired
|
|
25076
25103
|
});
|
|
25077
25104
|
};
|
|
25078
25105
|
|
|
@@ -25919,7 +25946,7 @@ var fallbackValues$k = {
|
|
|
25919
25946
|
};
|
|
25920
25947
|
|
|
25921
25948
|
var _excluded$p = ["showErrors", "themeValues"],
|
|
25922
|
-
_excluded2 = ["type", "labelTextWhenNoError", "errorMessages", "isNum", "isEmail", "helperModal", "field", "fieldActions", "showErrors", "formatter", "decorator", "themeValues", "background", "customHeight", "autocompleteValue", "extraStyles", "removeFromValue", "dataQa"];
|
|
25949
|
+
_excluded2 = ["type", "labelTextWhenNoError", "errorMessages", "isNum", "isEmail", "helperModal", "field", "fieldActions", "showErrors", "formatter", "decorator", "themeValues", "background", "customHeight", "autocompleteValue", "extraStyles", "removeFromValue", "dataQa", "isRequired"];
|
|
25923
25950
|
var InputField = styled.input.withConfig({
|
|
25924
25951
|
displayName: "FormInput__InputField",
|
|
25925
25952
|
componentId: "sc-l094r1-0"
|
|
@@ -26006,6 +26033,8 @@ var FormInput = function FormInput(_ref15) {
|
|
|
26006
26033
|
removeFromValue = _ref15.removeFromValue,
|
|
26007
26034
|
_ref15$dataQa = _ref15.dataQa,
|
|
26008
26035
|
dataQa = _ref15$dataQa === void 0 ? null : _ref15$dataQa,
|
|
26036
|
+
_ref15$isRequired = _ref15.isRequired,
|
|
26037
|
+
isRequired = _ref15$isRequired === void 0 ? false : _ref15$isRequired,
|
|
26009
26038
|
props = _objectWithoutProperties(_ref15, _excluded2);
|
|
26010
26039
|
|
|
26011
26040
|
var _useState = useState(false),
|
|
@@ -26092,7 +26121,8 @@ var FormInput = function FormInput(_ref15) {
|
|
|
26092
26121
|
$customHeight: customHeight,
|
|
26093
26122
|
$extraStyles: extraStyles,
|
|
26094
26123
|
"data-qa": dataQa || labelTextWhenNoError,
|
|
26095
|
-
autoComplete: autocompleteValue
|
|
26124
|
+
autoComplete: autocompleteValue,
|
|
26125
|
+
required: isRequired
|
|
26096
26126
|
}, props)) : /*#__PURE__*/React.createElement(InputField, _extends({
|
|
26097
26127
|
"aria-labelledby": createIdFromString(labelTextWhenNoError),
|
|
26098
26128
|
"aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
|
|
@@ -26111,7 +26141,8 @@ var FormInput = function FormInput(_ref15) {
|
|
|
26111
26141
|
$customHeight: customHeight,
|
|
26112
26142
|
$extraStyles: extraStyles,
|
|
26113
26143
|
"data-qa": dataQa || labelTextWhenNoError,
|
|
26114
|
-
autoComplete: autocompleteValue
|
|
26144
|
+
autoComplete: autocompleteValue,
|
|
26145
|
+
required: isRequired
|
|
26115
26146
|
}, props))), /*#__PURE__*/React.createElement(Stack, {
|
|
26116
26147
|
direction: "row",
|
|
26117
26148
|
justify: "space-between",
|
|
@@ -27244,7 +27275,7 @@ var HiddenRadioInput = styled.input.withConfig({
|
|
|
27244
27275
|
var Circle = styled.div.withConfig({
|
|
27245
27276
|
displayName: "RadioButtonWithLabel__Circle",
|
|
27246
27277
|
componentId: "sc-1m9whwg-1"
|
|
27247
|
-
})(["flex-shrink:0;margin-right:8px;width:1.5rem;height
|
|
27278
|
+
})(["flex-shrink:0;margin-right:8px;width:1.5rem;height:1.5rem;border:", ";border-radius:50%;box-sizing:border-box;padding:2px;:after{content:\"\";width:100%;height:100%;display:block;background:", ";border-radius:50%;transform:scale(0);}"], function (_ref) {
|
|
27248
27279
|
var inactiveBorderColor = _ref.inactiveBorderColor;
|
|
27249
27280
|
return "1px solid ".concat(inactiveBorderColor);
|
|
27250
27281
|
}, function (_ref2) {
|
|
@@ -27254,12 +27285,12 @@ var Circle = styled.div.withConfig({
|
|
|
27254
27285
|
var InputAndLabelContainer = styled(Cluster).withConfig({
|
|
27255
27286
|
displayName: "RadioButtonWithLabel__InputAndLabelContainer",
|
|
27256
27287
|
componentId: "sc-1m9whwg-2"
|
|
27257
|
-
})(["overflow:visible;", ":checked + label ", ":after{transform:scale(0.85);transition:transform 0.15s;}", ":checked + label ", "{border:", "}", ":focus + label ", "{
|
|
27288
|
+
})(["overflow:visible;", ":checked + label ", ":after{transform:scale(0.85);transition:transform 0.15s;}", ":checked + label ", "{border:", ";}", ":focus + label ", "{box-shadow:", ";}"], HiddenRadioInput, Circle, HiddenRadioInput, Circle, function (_ref3) {
|
|
27258
27289
|
var activeColor = _ref3.activeColor;
|
|
27259
|
-
return "1px solid "
|
|
27290
|
+
return "1px solid " + activeColor;
|
|
27260
27291
|
}, HiddenRadioInput, Circle, function (_ref4) {
|
|
27261
27292
|
var activeColor = _ref4.activeColor;
|
|
27262
|
-
return "0px 0px 2px 1px "
|
|
27293
|
+
return "0px 0px 2px 1px " + activeColor;
|
|
27263
27294
|
});
|
|
27264
27295
|
|
|
27265
27296
|
var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
|
|
@@ -27353,7 +27384,9 @@ var RadioButton$1 = function RadioButton(_ref2) {
|
|
|
27353
27384
|
_ref2$ariaLabelledBy = _ref2.ariaLabelledBy,
|
|
27354
27385
|
ariaLabelledBy = _ref2$ariaLabelledBy === void 0 ? "" : _ref2$ariaLabelledBy,
|
|
27355
27386
|
_ref2$ariaLabel = _ref2.ariaLabel,
|
|
27356
|
-
ariaLabel = _ref2$ariaLabel === void 0 ? null : _ref2$ariaLabel
|
|
27387
|
+
ariaLabel = _ref2$ariaLabel === void 0 ? null : _ref2$ariaLabel,
|
|
27388
|
+
_ref2$required = _ref2.required,
|
|
27389
|
+
required = _ref2$required === void 0 ? false : _ref2$required;
|
|
27357
27390
|
var buttonBorder = {
|
|
27358
27391
|
onFocused: {
|
|
27359
27392
|
borderColor: themeValues.activeColor,
|
|
@@ -27413,6 +27446,8 @@ var RadioButton$1 = function RadioButton(_ref2) {
|
|
|
27413
27446
|
type: "radio",
|
|
27414
27447
|
id: "radio-".concat(name),
|
|
27415
27448
|
disabled: disabled,
|
|
27449
|
+
required: required,
|
|
27450
|
+
"aria-required": required,
|
|
27416
27451
|
onClick: toggleRadio,
|
|
27417
27452
|
"aria-describedby": ariaDescribedBy,
|
|
27418
27453
|
tabIndex: "-1"
|
|
@@ -38105,7 +38140,9 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
|
|
|
38105
38140
|
field = _ref.field,
|
|
38106
38141
|
fieldActions = _ref.fieldActions,
|
|
38107
38142
|
showErrors = _ref.showErrors,
|
|
38108
|
-
countryCode = _ref.countryCode
|
|
38143
|
+
countryCode = _ref.countryCode,
|
|
38144
|
+
_ref$isRequired = _ref.isRequired,
|
|
38145
|
+
isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired;
|
|
38109
38146
|
var placeholder = countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
|
|
38110
38147
|
var options = [placeholder].concat(_toConsumableArray(getOptions(countryCode)));
|
|
38111
38148
|
return /*#__PURE__*/React.createElement(FormSelect$1, {
|
|
@@ -38115,7 +38152,8 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
|
|
|
38115
38152
|
labelTextWhenNoError: labelTextWhenNoError,
|
|
38116
38153
|
errorMessages: errorMessages,
|
|
38117
38154
|
showErrors: showErrors,
|
|
38118
|
-
autocompleteValue: "address-level1"
|
|
38155
|
+
autocompleteValue: "address-level1",
|
|
38156
|
+
isRequired: isRequired
|
|
38119
38157
|
});
|
|
38120
38158
|
};
|
|
38121
38159
|
|
|
@@ -38739,44 +38777,52 @@ var TableHeading_styled = styled.th.withConfig({
|
|
|
38739
38777
|
return extraStyles;
|
|
38740
38778
|
});
|
|
38741
38779
|
|
|
38742
|
-
const validatorToPredicate =
|
|
38743
|
-
|
|
38744
|
-
...rest
|
|
38745
|
-
|
|
38780
|
+
const validatorToPredicate =
|
|
38781
|
+
(validatorFn, emptyCase) =>
|
|
38782
|
+
(value, ...rest) =>
|
|
38783
|
+
value === '' ? emptyCase : validatorFn(value, ...rest);
|
|
38746
38784
|
|
|
38747
38785
|
var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
38748
38786
|
|
|
38787
|
+
function getDefaultExportFromCjs (x) {
|
|
38788
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
38789
|
+
}
|
|
38790
|
+
|
|
38749
38791
|
var dayjs_min = {exports: {}};
|
|
38750
38792
|
|
|
38751
38793
|
(function (module, exports) {
|
|
38752
|
-
!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"
|
|
38753
|
-
}(dayjs_min));
|
|
38794
|
+
!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}));
|
|
38795
|
+
} (dayjs_min));
|
|
38754
38796
|
|
|
38755
|
-
var
|
|
38797
|
+
var dayjs_minExports = dayjs_min.exports;
|
|
38798
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
38756
38799
|
|
|
38757
38800
|
var customParseFormat$1 = {exports: {}};
|
|
38758
38801
|
|
|
38759
38802
|
(function (module, exports) {
|
|
38760
|
-
!function(t
|
|
38761
|
-
}(customParseFormat$1));
|
|
38803
|
+
!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);};}}));
|
|
38804
|
+
} (customParseFormat$1));
|
|
38762
38805
|
|
|
38763
|
-
var
|
|
38806
|
+
var customParseFormatExports = customParseFormat$1.exports;
|
|
38807
|
+
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
38764
38808
|
|
|
38765
38809
|
var isSameOrBefore$1 = {exports: {}};
|
|
38766
38810
|
|
|
38767
38811
|
(function (module, exports) {
|
|
38768
|
-
!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)};}}));
|
|
38769
|
-
}(isSameOrBefore$1));
|
|
38812
|
+
!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)};}}));
|
|
38813
|
+
} (isSameOrBefore$1));
|
|
38770
38814
|
|
|
38771
|
-
var
|
|
38815
|
+
var isSameOrBeforeExports = isSameOrBefore$1.exports;
|
|
38816
|
+
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);
|
|
38772
38817
|
|
|
38773
38818
|
var isSameOrAfter$1 = {exports: {}};
|
|
38774
38819
|
|
|
38775
38820
|
(function (module, exports) {
|
|
38776
|
-
!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)};}}));
|
|
38777
|
-
}(isSameOrAfter$1));
|
|
38821
|
+
!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)};}}));
|
|
38822
|
+
} (isSameOrAfter$1));
|
|
38778
38823
|
|
|
38779
|
-
var
|
|
38824
|
+
var isSameOrAfterExports = isSameOrAfter$1.exports;
|
|
38825
|
+
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);
|
|
38780
38826
|
|
|
38781
38827
|
/* eslint-disable no-unused-vars */
|
|
38782
38828
|
|
|
@@ -38792,24 +38838,24 @@ dayjs.extend(isSameOrAfter);
|
|
|
38792
38838
|
|
|
38793
38839
|
let validatorFns = {};
|
|
38794
38840
|
|
|
38795
|
-
const INCLUDED_IN =
|
|
38796
|
-
const INCLUDED_IN_ERROR =
|
|
38841
|
+
const INCLUDED_IN = 'validator/INCLUDED_IN';
|
|
38842
|
+
const INCLUDED_IN_ERROR = 'error/INCLUDED_IN';
|
|
38797
38843
|
const includedIn = createValidator(INCLUDED_IN, INCLUDED_IN_ERROR);
|
|
38798
38844
|
validatorFns[INCLUDED_IN] = (value, args, form) =>
|
|
38799
38845
|
Array.isArray(args[0]) ? args[0].includes(value) : args[0] === value;
|
|
38800
38846
|
|
|
38801
|
-
const REQUIRED =
|
|
38802
|
-
const REQUIRED_ERROR =
|
|
38847
|
+
const REQUIRED = 'validator/REQUIRED';
|
|
38848
|
+
const REQUIRED_ERROR = 'error/REQUIRED';
|
|
38803
38849
|
const required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
38804
|
-
validatorFns[REQUIRED] = (value, args, form) => value !==
|
|
38850
|
+
validatorFns[REQUIRED] = (value, args, form) => value !== '';
|
|
38805
38851
|
|
|
38806
|
-
const ONLY_INTEGERS =
|
|
38807
|
-
const ONLY_INTEGERS_ERROR =
|
|
38852
|
+
const ONLY_INTEGERS = 'validator/ONLY_INTEGERS';
|
|
38853
|
+
const ONLY_INTEGERS_ERROR = 'error/ONLY_INTEGERS';
|
|
38808
38854
|
const onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
38809
38855
|
validatorFns[ONLY_INTEGERS] = (value, args, form) => /^(-?\d+)?$/.test(value);
|
|
38810
38856
|
|
|
38811
|
-
const ONLY_NATURALS =
|
|
38812
|
-
const ONLY_NATURALS_ERROR =
|
|
38857
|
+
const ONLY_NATURALS = 'validator/ONLY_NATURALS';
|
|
38858
|
+
const ONLY_NATURALS_ERROR = 'error/ONLY_NATURALS';
|
|
38813
38859
|
const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
38814
38860
|
validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
|
|
38815
38861
|
|
|
@@ -38822,8 +38868,8 @@ not tested as validation function
|
|
|
38822
38868
|
to validate exp date instead use combo of:
|
|
38823
38869
|
required(), hasLength(), isValidMonth(), dateAfterToday()
|
|
38824
38870
|
*/
|
|
38825
|
-
const ONLY_EXPIRATION_DATE =
|
|
38826
|
-
const ONLY_EXPIRATION_DATE_ERROR =
|
|
38871
|
+
const ONLY_EXPIRATION_DATE = 'validator/ONLY_EXPIRATION_DATE';
|
|
38872
|
+
const ONLY_EXPIRATION_DATE_ERROR = 'error/ONLY_EXPIRATION_DATE';
|
|
38827
38873
|
const onlyExpirationDate = createValidator(
|
|
38828
38874
|
ONLY_EXPIRATION_DATE,
|
|
38829
38875
|
ONLY_EXPIRATION_DATE_ERROR
|
|
@@ -38831,64 +38877,63 @@ const onlyExpirationDate = createValidator(
|
|
|
38831
38877
|
validatorFns[ONLY_EXPIRATION_DATE] = (value, args, form) =>
|
|
38832
38878
|
/^(\d?\d?\/?\d?\d?)?$/.test(value);
|
|
38833
38879
|
|
|
38834
|
-
const NUMBER_LESS_THAN =
|
|
38835
|
-
const NUMBER_LESS_THAN_ERROR =
|
|
38880
|
+
const NUMBER_LESS_THAN = 'validator/NUMBER_LESS_THAN';
|
|
38881
|
+
const NUMBER_LESS_THAN_ERROR = 'error/NUMBER_LESS_THAN';
|
|
38836
38882
|
const numberLessThan = createValidator(
|
|
38837
38883
|
NUMBER_LESS_THAN,
|
|
38838
38884
|
NUMBER_LESS_THAN_ERROR
|
|
38839
38885
|
);
|
|
38840
38886
|
validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
38841
|
-
if (value ===
|
|
38887
|
+
if (value === '') {
|
|
38842
38888
|
return true;
|
|
38843
38889
|
}
|
|
38844
38890
|
return Number(value) < args[0];
|
|
38845
38891
|
};
|
|
38846
38892
|
|
|
38847
|
-
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
38848
|
-
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
38893
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO = 'validator/NUMBER_LESS_THAN_OR_EQUAL_TO';
|
|
38849
38894
|
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
38850
|
-
|
|
38895
|
+
'error/NUMBER_LESS_THAN_OR_EQUAL_TO';
|
|
38851
38896
|
const numberLessThanOrEqualTo = createValidator(
|
|
38852
38897
|
NUMBER_LESS_THAN_OR_EQUAL_TO,
|
|
38853
38898
|
NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR
|
|
38854
38899
|
);
|
|
38855
38900
|
validatorFns[NUMBER_LESS_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38856
|
-
if (value ===
|
|
38901
|
+
if (value === '') {
|
|
38857
38902
|
return true;
|
|
38858
38903
|
}
|
|
38859
38904
|
return Number(value) <= args[0];
|
|
38860
38905
|
};
|
|
38861
38906
|
|
|
38862
|
-
const NUMBER_GREATER_THAN =
|
|
38863
|
-
const NUMBER_GREATER_THAN_ERROR =
|
|
38907
|
+
const NUMBER_GREATER_THAN = 'validator/NUMBER_GREATER_THAN';
|
|
38908
|
+
const NUMBER_GREATER_THAN_ERROR = 'error/NUMBER_GREATER_THAN';
|
|
38864
38909
|
const numberGreaterThan = createValidator(
|
|
38865
38910
|
NUMBER_GREATER_THAN,
|
|
38866
38911
|
NUMBER_GREATER_THAN_ERROR
|
|
38867
38912
|
);
|
|
38868
38913
|
validatorFns[NUMBER_GREATER_THAN] = (value, args, form) => {
|
|
38869
|
-
if (value ===
|
|
38914
|
+
if (value === '') {
|
|
38870
38915
|
return true;
|
|
38871
38916
|
}
|
|
38872
38917
|
return Number(value) > args[0];
|
|
38873
38918
|
};
|
|
38874
38919
|
|
|
38875
38920
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO =
|
|
38876
|
-
|
|
38921
|
+
'validator/NUMBER_GREATER_THAN_OR_EQUAL_TO';
|
|
38877
38922
|
const NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR =
|
|
38878
|
-
|
|
38923
|
+
'error/NUMBER_GREATER_THAN_OR_EQUAL_TO';
|
|
38879
38924
|
const numberGreaterThanOrEqualTo = createValidator(
|
|
38880
38925
|
NUMBER_GREATER_THAN_OR_EQUAL_TO,
|
|
38881
38926
|
NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR
|
|
38882
38927
|
);
|
|
38883
38928
|
validatorFns[NUMBER_GREATER_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
38884
|
-
if (value ===
|
|
38929
|
+
if (value === '') {
|
|
38885
38930
|
return true;
|
|
38886
38931
|
}
|
|
38887
38932
|
return Number(value) >= args[0];
|
|
38888
38933
|
};
|
|
38889
38934
|
|
|
38890
|
-
const MATCHES_FIELD =
|
|
38891
|
-
const MATCHES_FIELD_ERROR$1 =
|
|
38935
|
+
const MATCHES_FIELD = 'validator/MATCHES_FIELD';
|
|
38936
|
+
const MATCHES_FIELD_ERROR$1 = 'error/MATCHES_FIELD';
|
|
38892
38937
|
const matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
|
|
38893
38938
|
validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
38894
38939
|
const dependentField = form[args[0]];
|
|
@@ -38901,7 +38946,7 @@ validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
|
38901
38946
|
return value === dependentFieldValue;
|
|
38902
38947
|
};
|
|
38903
38948
|
|
|
38904
|
-
const validateWhenErrorMessage = type =>
|
|
38949
|
+
const validateWhenErrorMessage = (type) =>
|
|
38905
38950
|
`${type} was passed to validateWhen, but that validator type does not exist.
|
|
38906
38951
|
Please check that you are only calling validator creator functions exported from
|
|
38907
38952
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -38909,25 +38954,21 @@ const validateWhenErrorMessage = type =>
|
|
|
38909
38954
|
createFormState). Also make sure you aren't passing validateWhen() to validateWhen
|
|
38910
38955
|
as the primary validator.`;
|
|
38911
38956
|
|
|
38912
|
-
const VALIDATE_WHEN =
|
|
38913
|
-
const VALIDATE_WHEN_ERROR =
|
|
38914
|
-
const validateWhen = (
|
|
38915
|
-
dependentValidator,
|
|
38916
|
-
primaryValidator,
|
|
38917
|
-
optionalFieldName
|
|
38918
|
-
) => ({
|
|
38957
|
+
const VALIDATE_WHEN = 'validator/VALIDATE_WHEN';
|
|
38958
|
+
const VALIDATE_WHEN_ERROR = 'error/VALIDATE_WHEN';
|
|
38959
|
+
const validateWhen = (dependentValidator, primaryValidator, optionalFieldName) => ({
|
|
38919
38960
|
type: VALIDATE_WHEN,
|
|
38920
38961
|
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
38921
|
-
error: dependentValidator.error
|
|
38962
|
+
error: dependentValidator.error,
|
|
38922
38963
|
});
|
|
38923
38964
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
38924
38965
|
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
38925
38966
|
const [dependentValidator, primaryValidator, optionalFieldName] = args;
|
|
38926
|
-
const dependsOnOtherField = typeof optionalFieldName ===
|
|
38967
|
+
const dependsOnOtherField = typeof optionalFieldName === 'string';
|
|
38927
38968
|
|
|
38928
38969
|
if (
|
|
38929
38970
|
primaryValidator.type === undefined ||
|
|
38930
|
-
typeof validatorFns[primaryValidator.type] !==
|
|
38971
|
+
typeof validatorFns[primaryValidator.type] !== 'function'
|
|
38931
38972
|
) {
|
|
38932
38973
|
throw new Error(validateWhenErrorMessage(primaryValidator.type));
|
|
38933
38974
|
}
|
|
@@ -38951,26 +38992,22 @@ validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
|
38951
38992
|
);
|
|
38952
38993
|
|
|
38953
38994
|
return primaryPredicatePassed
|
|
38954
|
-
? validatorFns[dependentValidator.type](
|
|
38955
|
-
value,
|
|
38956
|
-
dependentValidator.args,
|
|
38957
|
-
form
|
|
38958
|
-
)
|
|
38995
|
+
? validatorFns[dependentValidator.type](value, dependentValidator.args, form)
|
|
38959
38996
|
: true;
|
|
38960
38997
|
};
|
|
38961
38998
|
|
|
38962
|
-
const validateSumErrorMessage = type =>
|
|
38999
|
+
const validateSumErrorMessage = (type) =>
|
|
38963
39000
|
`${type} was passed to validateSum, but that validator type does not exist.
|
|
38964
39001
|
Please check that you are only calling validator creator functions exported from
|
|
38965
39002
|
redux-freeform in your form config and that you didn't forget to
|
|
38966
39003
|
invoke the validator creator (you cannot pass the functions themselves to
|
|
38967
39004
|
createFormState).`;
|
|
38968
|
-
const VALIDATE_SUM =
|
|
38969
|
-
const VALIDATE_SUM_ERROR =
|
|
39005
|
+
const VALIDATE_SUM = 'validator/VALIDATE_SUM';
|
|
39006
|
+
const VALIDATE_SUM_ERROR = 'error/VALIDATE_SUM';
|
|
38970
39007
|
const validateSum = (validator, fieldNamesArray) => ({
|
|
38971
39008
|
type: VALIDATE_SUM,
|
|
38972
39009
|
args: [validator, fieldNamesArray],
|
|
38973
|
-
error: validator.error
|
|
39010
|
+
error: validator.error,
|
|
38974
39011
|
});
|
|
38975
39012
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
38976
39013
|
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
@@ -38978,7 +39015,7 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38978
39015
|
|
|
38979
39016
|
if (
|
|
38980
39017
|
validator.type === undefined ||
|
|
38981
|
-
typeof validatorFns[validator.type] !==
|
|
39018
|
+
typeof validatorFns[validator.type] !== 'function'
|
|
38982
39019
|
) {
|
|
38983
39020
|
throw new Error(validateSumErrorMessage(validator.type));
|
|
38984
39021
|
}
|
|
@@ -38999,37 +39036,35 @@ validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
|
38999
39036
|
return validatorFns[validator.type](sum, validator.args, form);
|
|
39000
39037
|
};
|
|
39001
39038
|
|
|
39002
|
-
const HAS_LENGTH =
|
|
39003
|
-
const HAS_LENGTH_ERROR =
|
|
39039
|
+
const HAS_LENGTH = 'validator/HAS_LENGTH';
|
|
39040
|
+
const HAS_LENGTH_ERROR = 'error/HAS_LENGTH';
|
|
39004
39041
|
const hasLength = createValidator(HAS_LENGTH, HAS_LENGTH_ERROR);
|
|
39005
39042
|
validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
39006
|
-
if (value ===
|
|
39043
|
+
if (value === '') {
|
|
39007
39044
|
return true;
|
|
39008
39045
|
}
|
|
39009
39046
|
const min = args[0];
|
|
39010
39047
|
const max = args[1];
|
|
39011
39048
|
if (max == undefined || min == undefined) {
|
|
39012
39049
|
throw new Error(
|
|
39013
|
-
|
|
39050
|
+
'Max and min need to be defined for hasLength, both or one of them is undefined'
|
|
39014
39051
|
);
|
|
39015
39052
|
}
|
|
39016
39053
|
if (max < min) {
|
|
39017
|
-
throw new Error(
|
|
39018
|
-
"hasLength validator was passed a min greater than the max"
|
|
39019
|
-
);
|
|
39054
|
+
throw new Error('hasLength validator was passed a min greater than the max');
|
|
39020
39055
|
}
|
|
39021
39056
|
const valueLength = value.length;
|
|
39022
39057
|
return max >= valueLength && valueLength >= min;
|
|
39023
39058
|
};
|
|
39024
39059
|
|
|
39025
|
-
const DATE_BEFORE_TODAY =
|
|
39026
|
-
const DATE_BEFORE_TODAY_ERROR =
|
|
39060
|
+
const DATE_BEFORE_TODAY = 'validator/DATE_BEFORE_TODAY';
|
|
39061
|
+
const DATE_BEFORE_TODAY_ERROR = 'error/DATE_BEFORE_TODAY';
|
|
39027
39062
|
const dateBeforeToday = createValidator(
|
|
39028
39063
|
DATE_BEFORE_TODAY,
|
|
39029
39064
|
DATE_BEFORE_TODAY_ERROR
|
|
39030
39065
|
);
|
|
39031
39066
|
validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
39032
|
-
if (value ===
|
|
39067
|
+
if (value === '') {
|
|
39033
39068
|
return true;
|
|
39034
39069
|
}
|
|
39035
39070
|
const dateFormat = args[0];
|
|
@@ -39038,7 +39073,7 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
39038
39073
|
|
|
39039
39074
|
if (dateFormat == undefined || unit == undefined) {
|
|
39040
39075
|
throw new Error(
|
|
39041
|
-
|
|
39076
|
+
'Date format and unit need to be defined for dateBeforeToday, one or both are undefined'
|
|
39042
39077
|
);
|
|
39043
39078
|
}
|
|
39044
39079
|
const now = dayjs();
|
|
@@ -39050,14 +39085,14 @@ validatorFns[DATE_BEFORE_TODAY] = (value, args, form) => {
|
|
|
39050
39085
|
return dateValue.isBefore(now, unit);
|
|
39051
39086
|
};
|
|
39052
39087
|
|
|
39053
|
-
const DATE_AFTER_TODAY =
|
|
39054
|
-
const DATE_AFTER_TODAY_ERROR =
|
|
39088
|
+
const DATE_AFTER_TODAY = 'validator/DATE_AFTER_TODAY';
|
|
39089
|
+
const DATE_AFTER_TODAY_ERROR = 'error/DATE_AFTER_TODAY';
|
|
39055
39090
|
const dateAfterToday = createValidator(
|
|
39056
39091
|
DATE_AFTER_TODAY,
|
|
39057
39092
|
DATE_AFTER_TODAY_ERROR
|
|
39058
39093
|
);
|
|
39059
39094
|
validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
39060
|
-
if (value ===
|
|
39095
|
+
if (value === '') {
|
|
39061
39096
|
return true;
|
|
39062
39097
|
}
|
|
39063
39098
|
const dateFormat = args[0];
|
|
@@ -39066,7 +39101,7 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
39066
39101
|
|
|
39067
39102
|
if (dateFormat == undefined || unit == undefined) {
|
|
39068
39103
|
throw new Error(
|
|
39069
|
-
|
|
39104
|
+
'Date format and unit need to be defined for dateAfterToday, one or both are undefined'
|
|
39070
39105
|
);
|
|
39071
39106
|
}
|
|
39072
39107
|
const now = dayjs();
|
|
@@ -39078,14 +39113,11 @@ validatorFns[DATE_AFTER_TODAY] = (value, args, form) => {
|
|
|
39078
39113
|
return dateValue.isAfter(now, unit);
|
|
39079
39114
|
};
|
|
39080
39115
|
|
|
39081
|
-
const IS_VALID_MONTH =
|
|
39082
|
-
const IS_VALID_MONTH_ERROR =
|
|
39083
|
-
const isValidMonth = createValidator(
|
|
39084
|
-
IS_VALID_MONTH,
|
|
39085
|
-
IS_VALID_MONTH_ERROR
|
|
39086
|
-
);
|
|
39116
|
+
const IS_VALID_MONTH = 'validator/IS_VALID_MONTH';
|
|
39117
|
+
const IS_VALID_MONTH_ERROR = 'error/IS_VALID_MONTH';
|
|
39118
|
+
const isValidMonth = createValidator(IS_VALID_MONTH, IS_VALID_MONTH_ERROR);
|
|
39087
39119
|
validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
39088
|
-
if (value ===
|
|
39120
|
+
if (value === '') {
|
|
39089
39121
|
return true;
|
|
39090
39122
|
}
|
|
39091
39123
|
// Function takes one argument representing the character position
|
|
@@ -39095,43 +39127,43 @@ validatorFns[IS_VALID_MONTH] = (value, args, form) => {
|
|
|
39095
39127
|
// Only works with two digit months (01, 02, 03, etc)
|
|
39096
39128
|
const monthStartPosition = parseInt(args[0]);
|
|
39097
39129
|
const monthEndPosition = monthStartPosition + 2;
|
|
39098
|
-
if (monthStartPosition
|
|
39099
|
-
throw new Error(
|
|
39130
|
+
if (isNaN(monthStartPosition)) {
|
|
39131
|
+
throw new Error('Month start position has to be a valid integer string');
|
|
39100
39132
|
}
|
|
39101
39133
|
const month = parseInt(value.slice(monthStartPosition, monthEndPosition));
|
|
39102
|
-
if (month
|
|
39134
|
+
if (isNaN(month)) {
|
|
39103
39135
|
return false;
|
|
39104
39136
|
}
|
|
39105
39137
|
return month >= 1 && month <= 12;
|
|
39106
39138
|
};
|
|
39107
39139
|
|
|
39108
|
-
const MATCHES_REGEX =
|
|
39109
|
-
const MATCHES_REGEX_ERROR =
|
|
39140
|
+
const MATCHES_REGEX = 'validator/MATCHES_REGEX';
|
|
39141
|
+
const MATCHES_REGEX_ERROR = 'error/MATCHES_REGEX';
|
|
39110
39142
|
const matchesRegex = createValidator(MATCHES_REGEX, MATCHES_REGEX_ERROR);
|
|
39111
39143
|
validatorFns[MATCHES_REGEX] = (value, args, form) => {
|
|
39112
|
-
if (value ===
|
|
39144
|
+
if (value === '') {
|
|
39113
39145
|
return true;
|
|
39114
39146
|
}
|
|
39115
39147
|
return new RegExp(args[0]).test(value); // new RexExp never throws an error, no matter the input
|
|
39116
39148
|
};
|
|
39117
39149
|
|
|
39118
39150
|
// based on http://www.brainjar.com/js/validation/
|
|
39119
|
-
const IS_ROUTING_NUMBER =
|
|
39120
|
-
const IS_ROUTING_NUMBER_ERROR =
|
|
39151
|
+
const IS_ROUTING_NUMBER = 'validator/IS_ROUTING_NUMBER';
|
|
39152
|
+
const IS_ROUTING_NUMBER_ERROR = 'error/IS_ROUTING_NUMBER';
|
|
39121
39153
|
const isRoutingNumber = createValidator(
|
|
39122
39154
|
IS_ROUTING_NUMBER,
|
|
39123
39155
|
IS_ROUTING_NUMBER_ERROR
|
|
39124
39156
|
);
|
|
39125
39157
|
validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
39126
|
-
if (value ===
|
|
39158
|
+
if (value === '') {
|
|
39127
39159
|
return true;
|
|
39128
39160
|
}
|
|
39129
39161
|
if (value.length != 9) {
|
|
39130
39162
|
return false;
|
|
39131
39163
|
}
|
|
39132
39164
|
const sum = value
|
|
39133
|
-
.split(
|
|
39134
|
-
.map(ch => parseInt(ch))
|
|
39165
|
+
.split('')
|
|
39166
|
+
.map((ch) => parseInt(ch))
|
|
39135
39167
|
.reduce((acc, cur, idx) => {
|
|
39136
39168
|
switch (idx % 3) {
|
|
39137
39169
|
case 0:
|
|
@@ -39145,69 +39177,69 @@ validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
|
39145
39177
|
return sum != 0 && sum % 10 == 0;
|
|
39146
39178
|
};
|
|
39147
39179
|
|
|
39148
|
-
const HAS_NUMBER =
|
|
39149
|
-
const HAS_NUMBER_ERROR$1 =
|
|
39180
|
+
const HAS_NUMBER = 'validator/HAS_NUMBER';
|
|
39181
|
+
const HAS_NUMBER_ERROR$1 = 'error/HAS_NUMBER';
|
|
39150
39182
|
const hasNumber = createValidator(HAS_NUMBER, HAS_NUMBER_ERROR$1);
|
|
39151
39183
|
validatorFns[HAS_NUMBER] = (value, args, form) => {
|
|
39152
|
-
if (value ===
|
|
39184
|
+
if (value === '') {
|
|
39153
39185
|
return true;
|
|
39154
39186
|
}
|
|
39155
39187
|
return new RegExp(/[0-9]/).test(value);
|
|
39156
39188
|
};
|
|
39157
39189
|
|
|
39158
|
-
const HAS_LOWERCASE_LETTER =
|
|
39159
|
-
const HAS_LOWERCASE_LETTER_ERROR$1 =
|
|
39190
|
+
const HAS_LOWERCASE_LETTER = 'validator/HAS_LOWERCASE_LETTER';
|
|
39191
|
+
const HAS_LOWERCASE_LETTER_ERROR$1 = 'error/HAS_LOWERCASE_LETTER';
|
|
39160
39192
|
const hasLowercaseLetter = createValidator(
|
|
39161
39193
|
HAS_LOWERCASE_LETTER,
|
|
39162
39194
|
HAS_LOWERCASE_LETTER_ERROR$1
|
|
39163
39195
|
);
|
|
39164
39196
|
validatorFns[HAS_LOWERCASE_LETTER] = (value, args, form) => {
|
|
39165
|
-
if (value ===
|
|
39197
|
+
if (value === '') {
|
|
39166
39198
|
return true;
|
|
39167
39199
|
}
|
|
39168
39200
|
return new RegExp(/[a-z]/).test(value);
|
|
39169
39201
|
};
|
|
39170
39202
|
|
|
39171
|
-
const HAS_UPPERCASE_LETTER =
|
|
39172
|
-
const HAS_UPPERCASE_LETTER_ERROR$1 =
|
|
39203
|
+
const HAS_UPPERCASE_LETTER = 'validator/HAS_UPPERCASE_LETTER';
|
|
39204
|
+
const HAS_UPPERCASE_LETTER_ERROR$1 = 'error/HAS_UPPERCASE_LETTER';
|
|
39173
39205
|
const hasUppercaseLetter = createValidator(
|
|
39174
39206
|
HAS_UPPERCASE_LETTER,
|
|
39175
39207
|
HAS_UPPERCASE_LETTER_ERROR$1
|
|
39176
39208
|
);
|
|
39177
39209
|
validatorFns[HAS_UPPERCASE_LETTER] = (value, args, form) => {
|
|
39178
|
-
if (value ===
|
|
39210
|
+
if (value === '') {
|
|
39179
39211
|
return true;
|
|
39180
39212
|
}
|
|
39181
39213
|
return new RegExp(/[A-Z]/).test(value);
|
|
39182
39214
|
};
|
|
39183
39215
|
|
|
39184
|
-
const HAS_SPECIAL_CHARACTER =
|
|
39185
|
-
const HAS_SPECIAL_CHARACTER_ERROR$1 =
|
|
39216
|
+
const HAS_SPECIAL_CHARACTER = 'validator/HAS_SPECIAL_CHARACTER';
|
|
39217
|
+
const HAS_SPECIAL_CHARACTER_ERROR$1 = 'error/HAS_SPECIAL_CHARACTER';
|
|
39186
39218
|
const hasSpecialCharacter = createValidator(
|
|
39187
39219
|
HAS_SPECIAL_CHARACTER,
|
|
39188
39220
|
HAS_SPECIAL_CHARACTER_ERROR$1
|
|
39189
39221
|
);
|
|
39190
39222
|
validatorFns[HAS_SPECIAL_CHARACTER] = (value, args, form) => {
|
|
39191
|
-
if (value ===
|
|
39223
|
+
if (value === '') {
|
|
39192
39224
|
return true;
|
|
39193
39225
|
}
|
|
39194
39226
|
return new RegExp(/[!@#$%^&*.?]/).test(value);
|
|
39195
39227
|
};
|
|
39196
39228
|
|
|
39197
|
-
const IS_PROBABLY_EMAIL =
|
|
39198
|
-
const IS_PROBABLY_EMAIL_ERROR =
|
|
39229
|
+
const IS_PROBABLY_EMAIL = 'validator/IS_PROBABLY_EMAIL';
|
|
39230
|
+
const IS_PROBABLY_EMAIL_ERROR = 'error/IS_PROBABLY_EMAIL';
|
|
39199
39231
|
const isProbablyEmail = createValidator(
|
|
39200
39232
|
IS_PROBABLY_EMAIL,
|
|
39201
39233
|
IS_PROBABLY_EMAIL_ERROR
|
|
39202
39234
|
);
|
|
39203
39235
|
validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
39204
|
-
if (value ===
|
|
39236
|
+
if (value === '') {
|
|
39205
39237
|
return true;
|
|
39206
39238
|
}
|
|
39207
39239
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
39208
39240
|
};
|
|
39209
39241
|
|
|
39210
|
-
const runValidatorErrorMessage = type =>
|
|
39242
|
+
const runValidatorErrorMessage = (type) =>
|
|
39211
39243
|
`${type} was passed to runValidator, but that validator type does not exist.
|
|
39212
39244
|
Please check that you are only calling validator creator functions exported from
|
|
39213
39245
|
redux-freeform in your form config and that you didn't forget to
|
|
@@ -39222,1165 +39254,53 @@ const runValidator = (validator, value, form) => {
|
|
|
39222
39254
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
39223
39255
|
};
|
|
39224
39256
|
|
|
39225
|
-
const
|
|
39257
|
+
const runFormValidators = (fieldName, form, validators) => {
|
|
39226
39258
|
return validators
|
|
39227
|
-
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
39228
|
-
.filter(x => x !== null);
|
|
39259
|
+
.map((v) => runValidator(v, form[fieldName].rawValue, form))
|
|
39260
|
+
.filter((x) => x !== null);
|
|
39229
39261
|
};
|
|
39230
39262
|
|
|
39231
39263
|
const computeConstraints = (fieldName, form) => {
|
|
39232
39264
|
const constraints = form[fieldName].constraints;
|
|
39233
|
-
return
|
|
39265
|
+
return runFormValidators(fieldName, form, constraints);
|
|
39234
39266
|
};
|
|
39235
39267
|
|
|
39236
39268
|
const computeErrors = (fieldName, form) => {
|
|
39237
39269
|
const validators = form[fieldName].validators;
|
|
39238
|
-
return
|
|
39239
|
-
};
|
|
39240
|
-
|
|
39241
|
-
var obj;
|
|
39242
|
-
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : ( obj = {}, obj["immer-nothing"] = true, obj );
|
|
39243
|
-
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
39244
|
-
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-state") : "__$immer_state";
|
|
39245
|
-
function isDraft(value) {
|
|
39246
|
-
return !!value && !!value[DRAFT_STATE];
|
|
39247
|
-
}
|
|
39248
|
-
function isDraftable(value) {
|
|
39249
|
-
if (!value) { return false; }
|
|
39250
|
-
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
39251
|
-
}
|
|
39252
|
-
function isPlainObject(value) {
|
|
39253
|
-
if (!value || typeof value !== "object") { return false; }
|
|
39254
|
-
if (Array.isArray(value)) { return true; }
|
|
39255
|
-
var proto = Object.getPrototypeOf(value);
|
|
39256
|
-
return !proto || proto === Object.prototype;
|
|
39257
|
-
}
|
|
39258
|
-
var assign = Object.assign || function assign(target, value) {
|
|
39259
|
-
for (var key in value) {
|
|
39260
|
-
if (has$1(value, key)) {
|
|
39261
|
-
target[key] = value[key];
|
|
39262
|
-
}
|
|
39263
|
-
}
|
|
39264
|
-
|
|
39265
|
-
return target;
|
|
39266
|
-
};
|
|
39267
|
-
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;
|
|
39268
|
-
function shallowCopy(base, invokeGetters) {
|
|
39269
|
-
if ( invokeGetters === void 0 ) invokeGetters = false;
|
|
39270
|
-
|
|
39271
|
-
if (Array.isArray(base)) { return base.slice(); }
|
|
39272
|
-
var clone = Object.create(Object.getPrototypeOf(base));
|
|
39273
|
-
ownKeys$2(base).forEach(function (key) {
|
|
39274
|
-
if (key === DRAFT_STATE) {
|
|
39275
|
-
return; // Never copy over draft state.
|
|
39276
|
-
}
|
|
39277
|
-
|
|
39278
|
-
var desc = Object.getOwnPropertyDescriptor(base, key);
|
|
39279
|
-
var value = desc.value;
|
|
39280
|
-
|
|
39281
|
-
if (desc.get) {
|
|
39282
|
-
if (!invokeGetters) {
|
|
39283
|
-
throw new Error("Immer drafts cannot have computed properties");
|
|
39284
|
-
}
|
|
39285
|
-
|
|
39286
|
-
value = desc.get.call(base);
|
|
39287
|
-
}
|
|
39288
|
-
|
|
39289
|
-
if (desc.enumerable) {
|
|
39290
|
-
clone[key] = value;
|
|
39291
|
-
} else {
|
|
39292
|
-
Object.defineProperty(clone, key, {
|
|
39293
|
-
value: value,
|
|
39294
|
-
writable: true,
|
|
39295
|
-
configurable: true
|
|
39296
|
-
});
|
|
39297
|
-
}
|
|
39298
|
-
});
|
|
39299
|
-
return clone;
|
|
39300
|
-
}
|
|
39301
|
-
function each(value, cb) {
|
|
39302
|
-
if (Array.isArray(value)) {
|
|
39303
|
-
for (var i = 0; i < value.length; i++) { cb(i, value[i], value); }
|
|
39304
|
-
} else {
|
|
39305
|
-
ownKeys$2(value).forEach(function (key) { return cb(key, value[key], value); });
|
|
39306
|
-
}
|
|
39307
|
-
}
|
|
39308
|
-
function isEnumerable(base, prop) {
|
|
39309
|
-
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
39310
|
-
return !!desc && desc.enumerable;
|
|
39311
|
-
}
|
|
39312
|
-
function has$1(thing, prop) {
|
|
39313
|
-
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
39314
|
-
}
|
|
39315
|
-
function is(x, y) {
|
|
39316
|
-
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
39317
|
-
if (x === y) {
|
|
39318
|
-
return x !== 0 || 1 / x === 1 / y;
|
|
39319
|
-
} else {
|
|
39320
|
-
return x !== x && y !== y;
|
|
39321
|
-
}
|
|
39322
|
-
}
|
|
39323
|
-
function clone(obj) {
|
|
39324
|
-
if (!isDraftable(obj)) { return obj; }
|
|
39325
|
-
if (Array.isArray(obj)) { return obj.map(clone); }
|
|
39326
|
-
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
39327
|
-
|
|
39328
|
-
for (var key in obj) { cloned[key] = clone(obj[key]); }
|
|
39329
|
-
|
|
39330
|
-
return cloned;
|
|
39331
|
-
}
|
|
39332
|
-
|
|
39333
|
-
/** Each scope represents a `produce` call. */
|
|
39334
|
-
|
|
39335
|
-
var ImmerScope = function ImmerScope(parent) {
|
|
39336
|
-
this.drafts = [];
|
|
39337
|
-
this.parent = parent; // Whenever the modified draft contains a draft from another scope, we
|
|
39338
|
-
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
39339
|
-
|
|
39340
|
-
this.canAutoFreeze = true; // To avoid prototype lookups:
|
|
39341
|
-
|
|
39342
|
-
this.patches = null;
|
|
39343
|
-
};
|
|
39344
|
-
|
|
39345
|
-
ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
39346
|
-
if (patchListener) {
|
|
39347
|
-
this.patches = [];
|
|
39348
|
-
this.inversePatches = [];
|
|
39349
|
-
this.patchListener = patchListener;
|
|
39350
|
-
}
|
|
39351
|
-
};
|
|
39352
|
-
|
|
39353
|
-
ImmerScope.prototype.revoke = function revoke$1 () {
|
|
39354
|
-
this.leave();
|
|
39355
|
-
this.drafts.forEach(revoke);
|
|
39356
|
-
this.drafts = null; // Make draft-related methods throw.
|
|
39357
|
-
};
|
|
39358
|
-
|
|
39359
|
-
ImmerScope.prototype.leave = function leave () {
|
|
39360
|
-
if (this === ImmerScope.current) {
|
|
39361
|
-
ImmerScope.current = this.parent;
|
|
39362
|
-
}
|
|
39363
|
-
};
|
|
39364
|
-
ImmerScope.current = null;
|
|
39365
|
-
|
|
39366
|
-
ImmerScope.enter = function () {
|
|
39367
|
-
return this.current = new ImmerScope(this.current);
|
|
39368
|
-
};
|
|
39369
|
-
|
|
39370
|
-
function revoke(draft) {
|
|
39371
|
-
draft[DRAFT_STATE].revoke();
|
|
39372
|
-
}
|
|
39373
|
-
|
|
39374
|
-
// but share them all instead
|
|
39375
|
-
|
|
39376
|
-
var descriptors$1 = {};
|
|
39377
|
-
function willFinalize(scope, result, isReplaced) {
|
|
39378
|
-
scope.drafts.forEach(function (draft) {
|
|
39379
|
-
draft[DRAFT_STATE].finalizing = true;
|
|
39380
|
-
});
|
|
39381
|
-
|
|
39382
|
-
if (!isReplaced) {
|
|
39383
|
-
if (scope.patches) {
|
|
39384
|
-
markChangesRecursively(scope.drafts[0]);
|
|
39385
|
-
} // This is faster when we don't care about which attributes changed.
|
|
39386
|
-
|
|
39387
|
-
|
|
39388
|
-
markChangesSweep(scope.drafts);
|
|
39389
|
-
} // When a child draft is returned, look for changes.
|
|
39390
|
-
else if (isDraft(result) && result[DRAFT_STATE].scope === scope) {
|
|
39391
|
-
markChangesSweep(scope.drafts);
|
|
39392
|
-
}
|
|
39393
|
-
}
|
|
39394
|
-
function createProxy(base, parent) {
|
|
39395
|
-
var isArray = Array.isArray(base);
|
|
39396
|
-
var draft = clonePotentialDraft(base);
|
|
39397
|
-
each(draft, function (prop) {
|
|
39398
|
-
proxyProperty(draft, prop, isArray || isEnumerable(base, prop));
|
|
39399
|
-
}); // See "proxy.js" for property documentation.
|
|
39400
|
-
|
|
39401
|
-
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39402
|
-
var state = {
|
|
39403
|
-
scope: scope,
|
|
39404
|
-
modified: false,
|
|
39405
|
-
finalizing: false,
|
|
39406
|
-
// es5 only
|
|
39407
|
-
finalized: false,
|
|
39408
|
-
assigned: {},
|
|
39409
|
-
parent: parent,
|
|
39410
|
-
base: base,
|
|
39411
|
-
draft: draft,
|
|
39412
|
-
copy: null,
|
|
39413
|
-
revoke: revoke$1,
|
|
39414
|
-
revoked: false // es5 only
|
|
39415
|
-
|
|
39416
|
-
};
|
|
39417
|
-
createHiddenProperty(draft, DRAFT_STATE, state);
|
|
39418
|
-
scope.drafts.push(draft);
|
|
39419
|
-
return draft;
|
|
39420
|
-
}
|
|
39421
|
-
|
|
39422
|
-
function revoke$1() {
|
|
39423
|
-
this.revoked = true;
|
|
39424
|
-
}
|
|
39425
|
-
|
|
39426
|
-
function source(state) {
|
|
39427
|
-
return state.copy || state.base;
|
|
39428
|
-
} // Access a property without creating an Immer draft.
|
|
39429
|
-
|
|
39430
|
-
|
|
39431
|
-
function peek(draft, prop) {
|
|
39432
|
-
var state = draft[DRAFT_STATE];
|
|
39433
|
-
|
|
39434
|
-
if (state && !state.finalizing) {
|
|
39435
|
-
state.finalizing = true;
|
|
39436
|
-
var value = draft[prop];
|
|
39437
|
-
state.finalizing = false;
|
|
39438
|
-
return value;
|
|
39439
|
-
}
|
|
39440
|
-
|
|
39441
|
-
return draft[prop];
|
|
39442
|
-
}
|
|
39443
|
-
|
|
39444
|
-
function get$1(state, prop) {
|
|
39445
|
-
assertUnrevoked(state);
|
|
39446
|
-
var value = peek(source(state), prop);
|
|
39447
|
-
if (state.finalizing) { return value; } // Create a draft if the value is unmodified.
|
|
39448
|
-
|
|
39449
|
-
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
39450
|
-
prepareCopy(state);
|
|
39451
|
-
return state.copy[prop] = createProxy(value, state);
|
|
39452
|
-
}
|
|
39453
|
-
|
|
39454
|
-
return value;
|
|
39455
|
-
}
|
|
39456
|
-
|
|
39457
|
-
function set$1(state, prop, value) {
|
|
39458
|
-
assertUnrevoked(state);
|
|
39459
|
-
state.assigned[prop] = true;
|
|
39460
|
-
|
|
39461
|
-
if (!state.modified) {
|
|
39462
|
-
if (is(value, peek(source(state), prop))) { return; }
|
|
39463
|
-
markChanged(state);
|
|
39464
|
-
prepareCopy(state);
|
|
39465
|
-
}
|
|
39466
|
-
|
|
39467
|
-
state.copy[prop] = value;
|
|
39468
|
-
}
|
|
39469
|
-
|
|
39470
|
-
function markChanged(state) {
|
|
39471
|
-
if (!state.modified) {
|
|
39472
|
-
state.modified = true;
|
|
39473
|
-
if (state.parent) { markChanged(state.parent); }
|
|
39474
|
-
}
|
|
39475
|
-
}
|
|
39476
|
-
|
|
39477
|
-
function prepareCopy(state) {
|
|
39478
|
-
if (!state.copy) { state.copy = clonePotentialDraft(state.base); }
|
|
39479
|
-
}
|
|
39480
|
-
|
|
39481
|
-
function clonePotentialDraft(base) {
|
|
39482
|
-
var state = base && base[DRAFT_STATE];
|
|
39483
|
-
|
|
39484
|
-
if (state) {
|
|
39485
|
-
state.finalizing = true;
|
|
39486
|
-
var draft = shallowCopy(state.draft, true);
|
|
39487
|
-
state.finalizing = false;
|
|
39488
|
-
return draft;
|
|
39489
|
-
}
|
|
39490
|
-
|
|
39491
|
-
return shallowCopy(base);
|
|
39492
|
-
}
|
|
39493
|
-
|
|
39494
|
-
function proxyProperty(draft, prop, enumerable) {
|
|
39495
|
-
var desc = descriptors$1[prop];
|
|
39496
|
-
|
|
39497
|
-
if (desc) {
|
|
39498
|
-
desc.enumerable = enumerable;
|
|
39499
|
-
} else {
|
|
39500
|
-
descriptors$1[prop] = desc = {
|
|
39501
|
-
configurable: true,
|
|
39502
|
-
enumerable: enumerable,
|
|
39503
|
-
|
|
39504
|
-
get: function get$1$1() {
|
|
39505
|
-
return get$1(this[DRAFT_STATE], prop);
|
|
39506
|
-
},
|
|
39507
|
-
|
|
39508
|
-
set: function set$1$1(value) {
|
|
39509
|
-
set$1(this[DRAFT_STATE], prop, value);
|
|
39510
|
-
}
|
|
39511
|
-
|
|
39512
|
-
};
|
|
39513
|
-
}
|
|
39514
|
-
|
|
39515
|
-
Object.defineProperty(draft, prop, desc);
|
|
39516
|
-
}
|
|
39517
|
-
|
|
39518
|
-
function assertUnrevoked(state) {
|
|
39519
|
-
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))); }
|
|
39520
|
-
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
39521
|
-
|
|
39522
|
-
|
|
39523
|
-
function markChangesSweep(drafts) {
|
|
39524
|
-
// The natural order of drafts in the `scope` array is based on when they
|
|
39525
|
-
// were accessed. By processing drafts in reverse natural order, we have a
|
|
39526
|
-
// better chance of processing leaf nodes first. When a leaf node is known to
|
|
39527
|
-
// have changed, we can avoid any traversal of its ancestor nodes.
|
|
39528
|
-
for (var i = drafts.length - 1; i >= 0; i--) {
|
|
39529
|
-
var state = drafts[i][DRAFT_STATE];
|
|
39530
|
-
|
|
39531
|
-
if (!state.modified) {
|
|
39532
|
-
if (Array.isArray(state.base)) {
|
|
39533
|
-
if (hasArrayChanges(state)) { markChanged(state); }
|
|
39534
|
-
} else if (hasObjectChanges(state)) { markChanged(state); }
|
|
39535
|
-
}
|
|
39536
|
-
}
|
|
39537
|
-
}
|
|
39538
|
-
|
|
39539
|
-
function markChangesRecursively(object) {
|
|
39540
|
-
if (!object || typeof object !== "object") { return; }
|
|
39541
|
-
var state = object[DRAFT_STATE];
|
|
39542
|
-
if (!state) { return; }
|
|
39543
|
-
var base = state.base;
|
|
39544
|
-
var draft = state.draft;
|
|
39545
|
-
var assigned = state.assigned;
|
|
39546
|
-
|
|
39547
|
-
if (!Array.isArray(object)) {
|
|
39548
|
-
// Look for added keys.
|
|
39549
|
-
Object.keys(draft).forEach(function (key) {
|
|
39550
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39551
|
-
if (base[key] === undefined && !has$1(base, key)) {
|
|
39552
|
-
assigned[key] = true;
|
|
39553
|
-
markChanged(state);
|
|
39554
|
-
} else if (!assigned[key]) {
|
|
39555
|
-
// Only untouched properties trigger recursion.
|
|
39556
|
-
markChangesRecursively(draft[key]);
|
|
39557
|
-
}
|
|
39558
|
-
}); // Look for removed keys.
|
|
39559
|
-
|
|
39560
|
-
Object.keys(base).forEach(function (key) {
|
|
39561
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39562
|
-
if (draft[key] === undefined && !has$1(draft, key)) {
|
|
39563
|
-
assigned[key] = false;
|
|
39564
|
-
markChanged(state);
|
|
39565
|
-
}
|
|
39566
|
-
});
|
|
39567
|
-
} else if (hasArrayChanges(state)) {
|
|
39568
|
-
markChanged(state);
|
|
39569
|
-
assigned.length = true;
|
|
39570
|
-
|
|
39571
|
-
if (draft.length < base.length) {
|
|
39572
|
-
for (var i = draft.length; i < base.length; i++) { assigned[i] = false; }
|
|
39573
|
-
} else {
|
|
39574
|
-
for (var i$1 = base.length; i$1 < draft.length; i$1++) { assigned[i$1] = true; }
|
|
39575
|
-
}
|
|
39576
|
-
|
|
39577
|
-
for (var i$2 = 0; i$2 < draft.length; i$2++) {
|
|
39578
|
-
// Only untouched indices trigger recursion.
|
|
39579
|
-
if (assigned[i$2] === undefined) { markChangesRecursively(draft[i$2]); }
|
|
39580
|
-
}
|
|
39581
|
-
}
|
|
39582
|
-
}
|
|
39583
|
-
|
|
39584
|
-
function hasObjectChanges(state) {
|
|
39585
|
-
var base = state.base;
|
|
39586
|
-
var draft = state.draft; // Search for added keys and changed keys. Start at the back, because
|
|
39587
|
-
// non-numeric keys are ordered by time of definition on the object.
|
|
39588
|
-
|
|
39589
|
-
var keys = Object.keys(draft);
|
|
39590
|
-
|
|
39591
|
-
for (var i = keys.length - 1; i >= 0; i--) {
|
|
39592
|
-
var key = keys[i];
|
|
39593
|
-
var baseValue = base[key]; // The `undefined` check is a fast path for pre-existing keys.
|
|
39594
|
-
|
|
39595
|
-
if (baseValue === undefined && !has$1(base, key)) {
|
|
39596
|
-
return true;
|
|
39597
|
-
} // Once a base key is deleted, future changes go undetected, because its
|
|
39598
|
-
// descriptor is erased. This branch detects any missed changes.
|
|
39599
|
-
else {
|
|
39600
|
-
var value = draft[key];
|
|
39601
|
-
var state$1 = value && value[DRAFT_STATE];
|
|
39602
|
-
|
|
39603
|
-
if (state$1 ? state$1.base !== baseValue : !is(value, baseValue)) {
|
|
39604
|
-
return true;
|
|
39605
|
-
}
|
|
39606
|
-
}
|
|
39607
|
-
} // At this point, no keys were added or changed.
|
|
39608
|
-
// Compare key count to determine if keys were deleted.
|
|
39609
|
-
|
|
39610
|
-
|
|
39611
|
-
return keys.length !== Object.keys(base).length;
|
|
39612
|
-
}
|
|
39613
|
-
|
|
39614
|
-
function hasArrayChanges(state) {
|
|
39615
|
-
var draft = state.draft;
|
|
39616
|
-
if (draft.length !== state.base.length) { return true; } // See #116
|
|
39617
|
-
// If we first shorten the length, our array interceptors will be removed.
|
|
39618
|
-
// If after that new items are added, result in the same original length,
|
|
39619
|
-
// those last items will have no intercepting property.
|
|
39620
|
-
// So if there is no own descriptor on the last position, we know that items were removed and added
|
|
39621
|
-
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
39622
|
-
// the last one
|
|
39623
|
-
|
|
39624
|
-
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
39625
|
-
|
|
39626
|
-
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
|
|
39627
|
-
|
|
39628
|
-
return false;
|
|
39629
|
-
}
|
|
39630
|
-
|
|
39631
|
-
function createHiddenProperty(target, prop, value) {
|
|
39632
|
-
Object.defineProperty(target, prop, {
|
|
39633
|
-
value: value,
|
|
39634
|
-
enumerable: false,
|
|
39635
|
-
writable: true
|
|
39636
|
-
});
|
|
39637
|
-
}
|
|
39638
|
-
|
|
39639
|
-
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
39640
|
-
willFinalize: willFinalize,
|
|
39641
|
-
createProxy: createProxy
|
|
39642
|
-
});
|
|
39643
|
-
|
|
39644
|
-
function willFinalize$1() {}
|
|
39645
|
-
function createProxy$1(base, parent) {
|
|
39646
|
-
var scope = parent ? parent.scope : ImmerScope.current;
|
|
39647
|
-
var state = {
|
|
39648
|
-
// Track which produce call this is associated with.
|
|
39649
|
-
scope: scope,
|
|
39650
|
-
// True for both shallow and deep changes.
|
|
39651
|
-
modified: false,
|
|
39652
|
-
// Used during finalization.
|
|
39653
|
-
finalized: false,
|
|
39654
|
-
// Track which properties have been assigned (true) or deleted (false).
|
|
39655
|
-
assigned: {},
|
|
39656
|
-
// The parent draft state.
|
|
39657
|
-
parent: parent,
|
|
39658
|
-
// The base state.
|
|
39659
|
-
base: base,
|
|
39660
|
-
// The base proxy.
|
|
39661
|
-
draft: null,
|
|
39662
|
-
// Any property proxies.
|
|
39663
|
-
drafts: {},
|
|
39664
|
-
// The base copy with any updated values.
|
|
39665
|
-
copy: null,
|
|
39666
|
-
// Called by the `produce` function.
|
|
39667
|
-
revoke: null
|
|
39668
|
-
};
|
|
39669
|
-
var ref = Array.isArray(base) ? // [state] is used for arrays, to make sure the proxy is array-ish and not violate invariants,
|
|
39670
|
-
// although state itself is an object
|
|
39671
|
-
Proxy.revocable([state], arrayTraps) : Proxy.revocable(state, objectTraps);
|
|
39672
|
-
var revoke = ref.revoke;
|
|
39673
|
-
var proxy = ref.proxy;
|
|
39674
|
-
state.draft = proxy;
|
|
39675
|
-
state.revoke = revoke;
|
|
39676
|
-
scope.drafts.push(proxy);
|
|
39677
|
-
return proxy;
|
|
39678
|
-
}
|
|
39679
|
-
var objectTraps = {
|
|
39680
|
-
get: get$1$1,
|
|
39681
|
-
|
|
39682
|
-
has: function has(target, prop) {
|
|
39683
|
-
return prop in source$1(target);
|
|
39684
|
-
},
|
|
39685
|
-
|
|
39686
|
-
ownKeys: function ownKeys(target) {
|
|
39687
|
-
return Reflect.ownKeys(source$1(target));
|
|
39688
|
-
},
|
|
39689
|
-
|
|
39690
|
-
set: set$1$1,
|
|
39691
|
-
deleteProperty: deleteProperty,
|
|
39692
|
-
getOwnPropertyDescriptor: getOwnPropertyDescriptor$2,
|
|
39693
|
-
|
|
39694
|
-
defineProperty: function defineProperty() {
|
|
39695
|
-
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
39696
|
-
},
|
|
39697
|
-
|
|
39698
|
-
getPrototypeOf: function getPrototypeOf(target) {
|
|
39699
|
-
return Object.getPrototypeOf(target.base);
|
|
39700
|
-
},
|
|
39701
|
-
|
|
39702
|
-
setPrototypeOf: function setPrototypeOf() {
|
|
39703
|
-
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
39704
|
-
}
|
|
39705
|
-
|
|
39706
|
-
};
|
|
39707
|
-
var arrayTraps = {};
|
|
39708
|
-
each(objectTraps, function (key, fn) {
|
|
39709
|
-
arrayTraps[key] = function () {
|
|
39710
|
-
arguments[0] = arguments[0][0];
|
|
39711
|
-
return fn.apply(this, arguments);
|
|
39712
|
-
};
|
|
39713
|
-
});
|
|
39714
|
-
|
|
39715
|
-
arrayTraps.deleteProperty = function (state, prop) {
|
|
39716
|
-
if (isNaN(parseInt(prop))) {
|
|
39717
|
-
throw new Error("Immer only supports deleting array indices"); // prettier-ignore
|
|
39718
|
-
}
|
|
39719
|
-
|
|
39720
|
-
return objectTraps.deleteProperty.call(this, state[0], prop);
|
|
39721
|
-
};
|
|
39722
|
-
|
|
39723
|
-
arrayTraps.set = function (state, prop, value) {
|
|
39724
|
-
if (prop !== "length" && isNaN(parseInt(prop))) {
|
|
39725
|
-
throw new Error("Immer only supports setting array indices and the 'length' property"); // prettier-ignore
|
|
39726
|
-
}
|
|
39727
|
-
|
|
39728
|
-
return objectTraps.set.call(this, state[0], prop, value);
|
|
39729
|
-
}; // returns the object we should be reading the current value from, which is base, until some change has been made
|
|
39730
|
-
|
|
39731
|
-
|
|
39732
|
-
function source$1(state) {
|
|
39733
|
-
return state.copy || state.base;
|
|
39734
|
-
} // Access a property without creating an Immer draft.
|
|
39735
|
-
|
|
39736
|
-
|
|
39737
|
-
function peek$1(draft, prop) {
|
|
39738
|
-
var state = draft[DRAFT_STATE];
|
|
39739
|
-
var desc = Reflect.getOwnPropertyDescriptor(state ? source$1(state) : draft, prop);
|
|
39740
|
-
return desc && desc.value;
|
|
39741
|
-
}
|
|
39742
|
-
|
|
39743
|
-
function get$1$1(state, prop) {
|
|
39744
|
-
if (prop === DRAFT_STATE) { return state; }
|
|
39745
|
-
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
39746
|
-
|
|
39747
|
-
if (!state.modified && has$1(drafts, prop)) {
|
|
39748
|
-
return drafts[prop];
|
|
39749
|
-
}
|
|
39750
|
-
|
|
39751
|
-
var value = source$1(state)[prop];
|
|
39752
|
-
|
|
39753
|
-
if (state.finalized || !isDraftable(value)) {
|
|
39754
|
-
return value;
|
|
39755
|
-
} // Check for existing draft in modified state.
|
|
39756
|
-
|
|
39757
|
-
|
|
39758
|
-
if (state.modified) {
|
|
39759
|
-
// Assigned values are never drafted. This catches any drafts we created, too.
|
|
39760
|
-
if (value !== peek$1(state.base, prop)) { return value; } // Store drafts on the copy (when one exists).
|
|
39761
|
-
|
|
39762
|
-
drafts = state.copy;
|
|
39763
|
-
}
|
|
39764
|
-
|
|
39765
|
-
return drafts[prop] = createProxy$1(value, state);
|
|
39766
|
-
}
|
|
39767
|
-
|
|
39768
|
-
function set$1$1(state, prop, value) {
|
|
39769
|
-
if (!state.modified) {
|
|
39770
|
-
var baseValue = peek$1(state.base, prop); // Optimize based on value's truthiness. Truthy values are guaranteed to
|
|
39771
|
-
// never be undefined, so we can avoid the `in` operator. Lastly, truthy
|
|
39772
|
-
// values may be drafts, but falsy values are never drafts.
|
|
39773
|
-
|
|
39774
|
-
var isUnchanged = value ? is(baseValue, value) || value === state.drafts[prop] : is(baseValue, value) && prop in state.base;
|
|
39775
|
-
if (isUnchanged) { return true; }
|
|
39776
|
-
markChanged$1(state);
|
|
39777
|
-
}
|
|
39778
|
-
|
|
39779
|
-
state.assigned[prop] = true;
|
|
39780
|
-
state.copy[prop] = value;
|
|
39781
|
-
return true;
|
|
39782
|
-
}
|
|
39783
|
-
|
|
39784
|
-
function deleteProperty(state, prop) {
|
|
39785
|
-
// The `undefined` check is a fast path for pre-existing keys.
|
|
39786
|
-
if (peek$1(state.base, prop) !== undefined || prop in state.base) {
|
|
39787
|
-
state.assigned[prop] = false;
|
|
39788
|
-
markChanged$1(state);
|
|
39789
|
-
} else if (state.assigned[prop]) {
|
|
39790
|
-
// if an originally not assigned property was deleted
|
|
39791
|
-
delete state.assigned[prop];
|
|
39792
|
-
}
|
|
39793
|
-
|
|
39794
|
-
if (state.copy) { delete state.copy[prop]; }
|
|
39795
|
-
return true;
|
|
39796
|
-
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
39797
|
-
// the same guarantee in ES5 mode.
|
|
39798
|
-
|
|
39799
|
-
|
|
39800
|
-
function getOwnPropertyDescriptor$2(state, prop) {
|
|
39801
|
-
var owner = source$1(state);
|
|
39802
|
-
var desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
39803
|
-
|
|
39804
|
-
if (desc) {
|
|
39805
|
-
desc.writable = true;
|
|
39806
|
-
desc.configurable = !Array.isArray(owner) || prop !== "length";
|
|
39807
|
-
}
|
|
39808
|
-
|
|
39809
|
-
return desc;
|
|
39810
|
-
}
|
|
39811
|
-
|
|
39812
|
-
function markChanged$1(state) {
|
|
39813
|
-
if (!state.modified) {
|
|
39814
|
-
state.modified = true;
|
|
39815
|
-
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
39816
|
-
state.drafts = null;
|
|
39817
|
-
if (state.parent) { markChanged$1(state.parent); }
|
|
39818
|
-
}
|
|
39819
|
-
}
|
|
39820
|
-
|
|
39821
|
-
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
39822
|
-
willFinalize: willFinalize$1,
|
|
39823
|
-
createProxy: createProxy$1
|
|
39824
|
-
});
|
|
39825
|
-
|
|
39826
|
-
function generatePatches(state, basePath, patches, inversePatches) {
|
|
39827
|
-
Array.isArray(state.base) ? generateArrayPatches(state, basePath, patches, inversePatches) : generateObjectPatches(state, basePath, patches, inversePatches);
|
|
39828
|
-
}
|
|
39829
|
-
|
|
39830
|
-
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
39831
|
-
var assign, assign$1;
|
|
39832
|
-
|
|
39833
|
-
var base = state.base;
|
|
39834
|
-
var copy = state.copy;
|
|
39835
|
-
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
39836
|
-
|
|
39837
|
-
if (copy.length < base.length) {
|
|
39838
|
-
(assign = [copy, base], base = assign[0], copy = assign[1]);
|
|
39839
|
-
(assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1]);
|
|
39840
|
-
}
|
|
39841
|
-
|
|
39842
|
-
var delta = copy.length - base.length; // Find the first replaced index.
|
|
39843
|
-
|
|
39844
|
-
var start = 0;
|
|
39845
|
-
|
|
39846
|
-
while (base[start] === copy[start] && start < base.length) {
|
|
39847
|
-
++start;
|
|
39848
|
-
} // Find the last replaced index. Search from the end to optimize splice patches.
|
|
39849
|
-
|
|
39850
|
-
|
|
39851
|
-
var end = base.length;
|
|
39852
|
-
|
|
39853
|
-
while (end > start && base[end - 1] === copy[end + delta - 1]) {
|
|
39854
|
-
--end;
|
|
39855
|
-
} // Process replaced indices.
|
|
39856
|
-
|
|
39857
|
-
|
|
39858
|
-
for (var i = start; i < end; ++i) {
|
|
39859
|
-
if (assigned[i] && copy[i] !== base[i]) {
|
|
39860
|
-
var path = basePath.concat([i]);
|
|
39861
|
-
patches.push({
|
|
39862
|
-
op: "replace",
|
|
39863
|
-
path: path,
|
|
39864
|
-
value: copy[i]
|
|
39865
|
-
});
|
|
39866
|
-
inversePatches.push({
|
|
39867
|
-
op: "replace",
|
|
39868
|
-
path: path,
|
|
39869
|
-
value: base[i]
|
|
39870
|
-
});
|
|
39871
|
-
}
|
|
39872
|
-
}
|
|
39873
|
-
|
|
39874
|
-
var replaceCount = patches.length; // Process added indices.
|
|
39875
|
-
|
|
39876
|
-
for (var i$1 = end + delta - 1; i$1 >= end; --i$1) {
|
|
39877
|
-
var path$1 = basePath.concat([i$1]);
|
|
39878
|
-
patches[replaceCount + i$1 - end] = {
|
|
39879
|
-
op: "add",
|
|
39880
|
-
path: path$1,
|
|
39881
|
-
value: copy[i$1]
|
|
39882
|
-
};
|
|
39883
|
-
inversePatches.push({
|
|
39884
|
-
op: "remove",
|
|
39885
|
-
path: path$1
|
|
39886
|
-
});
|
|
39887
|
-
}
|
|
39888
|
-
}
|
|
39889
|
-
|
|
39890
|
-
function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
39891
|
-
var base = state.base;
|
|
39892
|
-
var copy = state.copy;
|
|
39893
|
-
each(state.assigned, function (key, assignedValue) {
|
|
39894
|
-
var origValue = base[key];
|
|
39895
|
-
var value = copy[key];
|
|
39896
|
-
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
39897
|
-
if (origValue === value && op === "replace") { return; }
|
|
39898
|
-
var path = basePath.concat(key);
|
|
39899
|
-
patches.push(op === "remove" ? {
|
|
39900
|
-
op: op,
|
|
39901
|
-
path: path
|
|
39902
|
-
} : {
|
|
39903
|
-
op: op,
|
|
39904
|
-
path: path,
|
|
39905
|
-
value: value
|
|
39906
|
-
});
|
|
39907
|
-
inversePatches.push(op === "add" ? {
|
|
39908
|
-
op: "remove",
|
|
39909
|
-
path: path
|
|
39910
|
-
} : op === "remove" ? {
|
|
39911
|
-
op: "add",
|
|
39912
|
-
path: path,
|
|
39913
|
-
value: origValue
|
|
39914
|
-
} : {
|
|
39915
|
-
op: "replace",
|
|
39916
|
-
path: path,
|
|
39917
|
-
value: origValue
|
|
39918
|
-
});
|
|
39919
|
-
});
|
|
39920
|
-
}
|
|
39921
|
-
|
|
39922
|
-
var applyPatches = function (draft, patches) {
|
|
39923
|
-
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
39924
|
-
var patch = list[i$1];
|
|
39925
|
-
|
|
39926
|
-
var path = patch.path;
|
|
39927
|
-
var op = patch.op;
|
|
39928
|
-
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
39929
|
-
|
|
39930
|
-
if (!path.length) { throw new Error("Illegal state"); }
|
|
39931
|
-
var base = draft;
|
|
39932
|
-
|
|
39933
|
-
for (var i = 0; i < path.length - 1; i++) {
|
|
39934
|
-
base = base[path[i]];
|
|
39935
|
-
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
39936
|
-
}
|
|
39937
|
-
|
|
39938
|
-
var key = path[path.length - 1];
|
|
39939
|
-
|
|
39940
|
-
switch (op) {
|
|
39941
|
-
case "replace":
|
|
39942
|
-
// if value is an object, then it's assigned by reference
|
|
39943
|
-
// in the following add or remove ops, the value field inside the patch will also be modifyed
|
|
39944
|
-
// so we use value from the cloned patch
|
|
39945
|
-
base[key] = value;
|
|
39946
|
-
break;
|
|
39947
|
-
|
|
39948
|
-
case "add":
|
|
39949
|
-
if (Array.isArray(base)) {
|
|
39950
|
-
// TODO: support "foo/-" paths for appending to an array
|
|
39951
|
-
base.splice(key, 0, value);
|
|
39952
|
-
} else {
|
|
39953
|
-
base[key] = value;
|
|
39954
|
-
}
|
|
39955
|
-
|
|
39956
|
-
break;
|
|
39957
|
-
|
|
39958
|
-
case "remove":
|
|
39959
|
-
if (Array.isArray(base)) {
|
|
39960
|
-
base.splice(key, 1);
|
|
39961
|
-
} else {
|
|
39962
|
-
delete base[key];
|
|
39963
|
-
}
|
|
39964
|
-
|
|
39965
|
-
break;
|
|
39966
|
-
|
|
39967
|
-
default:
|
|
39968
|
-
throw new Error("Unsupported patch operation: " + op);
|
|
39969
|
-
}
|
|
39970
|
-
}
|
|
39971
|
-
|
|
39972
|
-
return draft;
|
|
39973
|
-
};
|
|
39974
|
-
|
|
39975
|
-
function verifyMinified() {}
|
|
39976
|
-
|
|
39977
|
-
var configDefaults = {
|
|
39978
|
-
useProxies: typeof Proxy !== "undefined" && typeof Reflect !== "undefined",
|
|
39979
|
-
autoFreeze: typeof process !== "undefined" ? process.env.NODE_ENV !== "production" : verifyMinified.name === "verifyMinified",
|
|
39980
|
-
onAssign: null,
|
|
39981
|
-
onDelete: null,
|
|
39982
|
-
onCopy: null
|
|
39983
|
-
};
|
|
39984
|
-
var Immer = function Immer(config) {
|
|
39985
|
-
assign(this, configDefaults, config);
|
|
39986
|
-
this.setUseProxies(this.useProxies);
|
|
39987
|
-
this.produce = this.produce.bind(this);
|
|
39988
|
-
};
|
|
39989
|
-
|
|
39990
|
-
Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
39991
|
-
var this$1$1 = this;
|
|
39992
|
-
|
|
39993
|
-
// curried invocation
|
|
39994
|
-
if (typeof base === "function" && typeof recipe !== "function") {
|
|
39995
|
-
var defaultBase = recipe;
|
|
39996
|
-
recipe = base;
|
|
39997
|
-
var self = this;
|
|
39998
|
-
return function curriedProduce(base) {
|
|
39999
|
-
var this$1$1 = this;
|
|
40000
|
-
if ( base === void 0 ) base = defaultBase;
|
|
40001
|
-
var args = [], len = arguments.length - 1;
|
|
40002
|
-
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
40003
|
-
|
|
40004
|
-
return self.produce(base, function (draft) { return recipe.call.apply(recipe, [ this$1$1, draft ].concat( args )); }); // prettier-ignore
|
|
40005
|
-
};
|
|
40006
|
-
} // prettier-ignore
|
|
40007
|
-
|
|
40008
|
-
|
|
40009
|
-
{
|
|
40010
|
-
if (typeof recipe !== "function") {
|
|
40011
|
-
throw new Error("The first or second argument to `produce` must be a function");
|
|
40012
|
-
}
|
|
40013
|
-
|
|
40014
|
-
if (patchListener !== undefined && typeof patchListener !== "function") {
|
|
40015
|
-
throw new Error("The third argument to `produce` must be a function or undefined");
|
|
40016
|
-
}
|
|
40017
|
-
}
|
|
40018
|
-
var result; // Only plain objects, arrays, and "immerable classes" are drafted.
|
|
40019
|
-
|
|
40020
|
-
if (isDraftable(base)) {
|
|
40021
|
-
var scope = ImmerScope.enter();
|
|
40022
|
-
var proxy = this.createProxy(base);
|
|
40023
|
-
var hasError = true;
|
|
40024
|
-
|
|
40025
|
-
try {
|
|
40026
|
-
result = recipe(proxy);
|
|
40027
|
-
hasError = false;
|
|
40028
|
-
} finally {
|
|
40029
|
-
// finally instead of catch + rethrow better preserves original stack
|
|
40030
|
-
if (hasError) { scope.revoke(); }else { scope.leave(); }
|
|
40031
|
-
}
|
|
40032
|
-
|
|
40033
|
-
if (result instanceof Promise) {
|
|
40034
|
-
return result.then(function (result) {
|
|
40035
|
-
scope.usePatches(patchListener);
|
|
40036
|
-
return this$1$1.processResult(result, scope);
|
|
40037
|
-
}, function (error) {
|
|
40038
|
-
scope.revoke();
|
|
40039
|
-
throw error;
|
|
40040
|
-
});
|
|
40041
|
-
}
|
|
40042
|
-
|
|
40043
|
-
scope.usePatches(patchListener);
|
|
40044
|
-
return this.processResult(result, scope);
|
|
40045
|
-
} else {
|
|
40046
|
-
result = recipe(base);
|
|
40047
|
-
if (result === undefined) { return base; }
|
|
40048
|
-
return result !== NOTHING ? result : undefined;
|
|
40049
|
-
}
|
|
40050
|
-
};
|
|
40051
|
-
|
|
40052
|
-
Immer.prototype.produceWithPatches = function produceWithPatches (arg1, arg2, arg3) {
|
|
40053
|
-
var this$1$1 = this;
|
|
40054
|
-
|
|
40055
|
-
if (typeof arg1 === "function") {
|
|
40056
|
-
return function (state) {
|
|
40057
|
-
var args = [], len = arguments.length - 1;
|
|
40058
|
-
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
40059
|
-
|
|
40060
|
-
return this$1$1.produceWithPatches(state, function (draft) { return arg1.apply(void 0, [ draft ].concat( args )); });
|
|
40061
|
-
};
|
|
40062
|
-
} // non-curried form
|
|
40063
|
-
|
|
40064
|
-
|
|
40065
|
-
if (arg3) { throw new Error("A patch listener cannot be passed to produceWithPatches"); }
|
|
40066
|
-
var patches, inversePatches;
|
|
40067
|
-
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
40068
|
-
patches = p;
|
|
40069
|
-
inversePatches = ip;
|
|
40070
|
-
});
|
|
40071
|
-
return [nextState, patches, inversePatches];
|
|
40072
|
-
};
|
|
40073
|
-
|
|
40074
|
-
Immer.prototype.createDraft = function createDraft (base) {
|
|
40075
|
-
if (!isDraftable(base)) {
|
|
40076
|
-
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
40077
|
-
}
|
|
40078
|
-
|
|
40079
|
-
var scope = ImmerScope.enter();
|
|
40080
|
-
var proxy = this.createProxy(base);
|
|
40081
|
-
proxy[DRAFT_STATE].isManual = true;
|
|
40082
|
-
scope.leave();
|
|
40083
|
-
return proxy;
|
|
40084
|
-
};
|
|
40085
|
-
|
|
40086
|
-
Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
40087
|
-
var state = draft && draft[DRAFT_STATE];
|
|
40088
|
-
|
|
40089
|
-
if (!state || !state.isManual) {
|
|
40090
|
-
throw new Error("First argument to `finishDraft` must be a draft returned by `createDraft`"); // prettier-ignore
|
|
40091
|
-
}
|
|
40092
|
-
|
|
40093
|
-
if (state.finalized) {
|
|
40094
|
-
throw new Error("The given draft is already finalized"); // prettier-ignore
|
|
40095
|
-
}
|
|
40096
|
-
|
|
40097
|
-
var scope = state.scope;
|
|
40098
|
-
scope.usePatches(patchListener);
|
|
40099
|
-
return this.processResult(undefined, scope);
|
|
40100
|
-
};
|
|
40101
|
-
|
|
40102
|
-
Immer.prototype.setAutoFreeze = function setAutoFreeze (value) {
|
|
40103
|
-
this.autoFreeze = value;
|
|
40104
|
-
};
|
|
40105
|
-
|
|
40106
|
-
Immer.prototype.setUseProxies = function setUseProxies (value) {
|
|
40107
|
-
this.useProxies = value;
|
|
40108
|
-
assign(this, value ? modernProxy : legacyProxy);
|
|
40109
|
-
};
|
|
40110
|
-
|
|
40111
|
-
Immer.prototype.applyPatches = function applyPatches$1 (base, patches) {
|
|
40112
|
-
// If a patch replaces the entire state, take that replacement as base
|
|
40113
|
-
// before applying patches
|
|
40114
|
-
var i;
|
|
40115
|
-
|
|
40116
|
-
for (i = patches.length - 1; i >= 0; i--) {
|
|
40117
|
-
var patch = patches[i];
|
|
40118
|
-
|
|
40119
|
-
if (patch.path.length === 0 && patch.op === "replace") {
|
|
40120
|
-
base = patch.value;
|
|
40121
|
-
break;
|
|
40122
|
-
}
|
|
40123
|
-
}
|
|
40124
|
-
|
|
40125
|
-
if (isDraft(base)) {
|
|
40126
|
-
// N.B: never hits if some patch a replacement, patches are never drafts
|
|
40127
|
-
return applyPatches(base, patches);
|
|
40128
|
-
} // Otherwise, produce a copy of the base state.
|
|
40129
|
-
|
|
40130
|
-
|
|
40131
|
-
return this.produce(base, function (draft) { return applyPatches(draft, patches.slice(i + 1)); });
|
|
40132
|
-
};
|
|
40133
|
-
/** @internal */
|
|
40134
|
-
|
|
40135
|
-
|
|
40136
|
-
Immer.prototype.processResult = function processResult (result, scope) {
|
|
40137
|
-
var baseDraft = scope.drafts[0];
|
|
40138
|
-
var isReplaced = result !== undefined && result !== baseDraft;
|
|
40139
|
-
this.willFinalize(scope, result, isReplaced);
|
|
40140
|
-
|
|
40141
|
-
if (isReplaced) {
|
|
40142
|
-
if (baseDraft[DRAFT_STATE].modified) {
|
|
40143
|
-
scope.revoke();
|
|
40144
|
-
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
|
|
40145
|
-
}
|
|
40146
|
-
|
|
40147
|
-
if (isDraftable(result)) {
|
|
40148
|
-
// Finalize the result in case it contains (or is) a subset of the draft.
|
|
40149
|
-
result = this.finalize(result, null, scope);
|
|
40150
|
-
}
|
|
40151
|
-
|
|
40152
|
-
if (scope.patches) {
|
|
40153
|
-
scope.patches.push({
|
|
40154
|
-
op: "replace",
|
|
40155
|
-
path: [],
|
|
40156
|
-
value: result
|
|
40157
|
-
});
|
|
40158
|
-
scope.inversePatches.push({
|
|
40159
|
-
op: "replace",
|
|
40160
|
-
path: [],
|
|
40161
|
-
value: baseDraft[DRAFT_STATE].base
|
|
40162
|
-
});
|
|
40163
|
-
}
|
|
40164
|
-
} else {
|
|
40165
|
-
// Finalize the base draft.
|
|
40166
|
-
result = this.finalize(baseDraft, [], scope);
|
|
40167
|
-
}
|
|
40168
|
-
|
|
40169
|
-
scope.revoke();
|
|
40170
|
-
|
|
40171
|
-
if (scope.patches) {
|
|
40172
|
-
scope.patchListener(scope.patches, scope.inversePatches);
|
|
40173
|
-
}
|
|
40174
|
-
|
|
40175
|
-
return result !== NOTHING ? result : undefined;
|
|
39270
|
+
return runFormValidators(fieldName, form, validators);
|
|
40176
39271
|
};
|
|
40177
|
-
/**
|
|
40178
|
-
* @internal
|
|
40179
|
-
* Finalize a draft, returning either the unmodified base state or a modified
|
|
40180
|
-
* copy of the base state.
|
|
40181
|
-
*/
|
|
40182
|
-
|
|
40183
|
-
|
|
40184
|
-
Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
40185
|
-
var this$1$1 = this;
|
|
40186
|
-
|
|
40187
|
-
var state = draft[DRAFT_STATE];
|
|
40188
|
-
|
|
40189
|
-
if (!state) {
|
|
40190
|
-
if (Object.isFrozen(draft)) { return draft; }
|
|
40191
|
-
return this.finalizeTree(draft, null, scope);
|
|
40192
|
-
} // Never finalize drafts owned by another scope.
|
|
40193
|
-
|
|
40194
|
-
|
|
40195
|
-
if (state.scope !== scope) {
|
|
40196
|
-
return draft;
|
|
40197
|
-
}
|
|
40198
39272
|
|
|
40199
|
-
|
|
40200
|
-
|
|
39273
|
+
const computeErrorEntries = (formState) => {
|
|
39274
|
+
const fields = Object.entries(formState);
|
|
39275
|
+
for (let entry of fields) {
|
|
39276
|
+
let fieldName = entry[0];
|
|
39277
|
+
let errors = computeErrors(fieldName, formState);
|
|
39278
|
+
formState[fieldName].errors = errors;
|
|
39279
|
+
formState[fieldName].hasErrors = errors.length > 0;
|
|
40201
39280
|
}
|
|
40202
|
-
|
|
40203
|
-
if (!state.finalized) {
|
|
40204
|
-
state.finalized = true;
|
|
40205
|
-
this.finalizeTree(state.draft, path, scope);
|
|
40206
|
-
|
|
40207
|
-
if (this.onDelete) {
|
|
40208
|
-
// The `assigned` object is unreliable with ES5 drafts.
|
|
40209
|
-
if (this.useProxies) {
|
|
40210
|
-
var assigned = state.assigned;
|
|
40211
|
-
|
|
40212
|
-
for (var prop in assigned) {
|
|
40213
|
-
if (!assigned[prop]) { this.onDelete(state, prop); }
|
|
40214
|
-
}
|
|
40215
|
-
} else {
|
|
40216
|
-
var base = state.base;
|
|
40217
|
-
var copy = state.copy;
|
|
40218
|
-
each(base, function (prop) {
|
|
40219
|
-
if (!has$1(copy, prop)) { this$1$1.onDelete(state, prop); }
|
|
40220
|
-
});
|
|
40221
|
-
}
|
|
40222
|
-
}
|
|
40223
|
-
|
|
40224
|
-
if (this.onCopy) {
|
|
40225
|
-
this.onCopy(state);
|
|
40226
|
-
} // At this point, all descendants of `state.copy` have been finalized,
|
|
40227
|
-
// so we can be sure that `scope.canAutoFreeze` is accurate.
|
|
40228
|
-
|
|
40229
|
-
|
|
40230
|
-
if (this.autoFreeze && scope.canAutoFreeze) {
|
|
40231
|
-
Object.freeze(state.copy);
|
|
40232
|
-
}
|
|
40233
|
-
|
|
40234
|
-
if (path && scope.patches) {
|
|
40235
|
-
generatePatches(state, path, scope.patches, scope.inversePatches);
|
|
40236
|
-
}
|
|
40237
|
-
}
|
|
40238
|
-
|
|
40239
|
-
return state.copy;
|
|
40240
39281
|
};
|
|
40241
|
-
/**
|
|
40242
|
-
* @internal
|
|
40243
|
-
* Finalize all drafts in the given state tree.
|
|
40244
|
-
*/
|
|
40245
39282
|
|
|
40246
|
-
|
|
40247
|
-
|
|
40248
|
-
|
|
40249
|
-
|
|
40250
|
-
|
|
40251
|
-
|
|
40252
|
-
|
|
40253
|
-
if (!this.useProxies) {
|
|
40254
|
-
// Create the final copy, with added keys and without deleted keys.
|
|
40255
|
-
state.copy = shallowCopy(state.draft, true);
|
|
40256
|
-
}
|
|
40257
|
-
|
|
40258
|
-
root = state.copy;
|
|
39283
|
+
const computeDirtyEntries = (formState, changedFieldName) => {
|
|
39284
|
+
const fields = Object.entries(formState);
|
|
39285
|
+
for (let entry of fields) {
|
|
39286
|
+
let fieldName = entry[0];
|
|
39287
|
+
let field = entry[1];
|
|
39288
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
39289
|
+
formState[fieldName].dirty = dirty;
|
|
40259
39290
|
}
|
|
40260
|
-
|
|
40261
|
-
var needPatches = !!rootPath && !!scope.patches;
|
|
40262
|
-
|
|
40263
|
-
var finalizeProperty = function (prop, value, parent) {
|
|
40264
|
-
if (value === parent) {
|
|
40265
|
-
throw Error("Immer forbids circular references");
|
|
40266
|
-
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
40267
|
-
|
|
40268
|
-
|
|
40269
|
-
var isDraftProp = !!state && parent === root;
|
|
40270
|
-
|
|
40271
|
-
if (isDraft(value)) {
|
|
40272
|
-
var path = isDraftProp && needPatches && !state.assigned[prop] ? rootPath.concat(prop) : null; // Drafts owned by `scope` are finalized here.
|
|
40273
|
-
|
|
40274
|
-
value = this$1$1.finalize(value, path, scope); // Drafts from another scope must prevent auto-freezing.
|
|
40275
|
-
|
|
40276
|
-
if (isDraft(value)) {
|
|
40277
|
-
scope.canAutoFreeze = false;
|
|
40278
|
-
} // Preserve non-enumerable properties.
|
|
40279
|
-
|
|
40280
|
-
|
|
40281
|
-
if (Array.isArray(parent) || isEnumerable(parent, prop)) {
|
|
40282
|
-
parent[prop] = value;
|
|
40283
|
-
} else {
|
|
40284
|
-
Object.defineProperty(parent, prop, {
|
|
40285
|
-
value: value
|
|
40286
|
-
});
|
|
40287
|
-
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
40288
|
-
|
|
40289
|
-
|
|
40290
|
-
if (isDraftProp && value === state.base[prop]) { return; }
|
|
40291
|
-
} // Unchanged draft properties are ignored.
|
|
40292
|
-
else if (isDraftProp && is(value, state.base[prop])) {
|
|
40293
|
-
return;
|
|
40294
|
-
} // Search new objects for unfinalized drafts. Frozen objects should never contain drafts.
|
|
40295
|
-
else if (isDraftable(value) && !Object.isFrozen(value)) {
|
|
40296
|
-
each(value, finalizeProperty);
|
|
40297
|
-
}
|
|
40298
|
-
|
|
40299
|
-
if (isDraftProp && this$1$1.onAssign) {
|
|
40300
|
-
this$1$1.onAssign(state, prop, value);
|
|
40301
|
-
}
|
|
40302
|
-
};
|
|
40303
|
-
|
|
40304
|
-
each(root, finalizeProperty);
|
|
40305
|
-
return root;
|
|
40306
39291
|
};
|
|
40307
39292
|
|
|
40308
|
-
var immer = new Immer();
|
|
40309
|
-
/**
|
|
40310
|
-
* The `produce` function takes a value and a "recipe function" (whose
|
|
40311
|
-
* return value often depends on the base state). The recipe function is
|
|
40312
|
-
* free to mutate its first argument however it wants. All mutations are
|
|
40313
|
-
* only ever applied to a __copy__ of the base state.
|
|
40314
|
-
*
|
|
40315
|
-
* Pass only a function to create a "curried producer" which relieves you
|
|
40316
|
-
* from passing the recipe function every time.
|
|
40317
|
-
*
|
|
40318
|
-
* Only plain objects and arrays are made mutable. All other objects are
|
|
40319
|
-
* considered uncopyable.
|
|
40320
|
-
*
|
|
40321
|
-
* Note: This function is __bound__ to its `Immer` instance.
|
|
40322
|
-
*
|
|
40323
|
-
* @param {any} base - the initial state
|
|
40324
|
-
* @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified
|
|
40325
|
-
* @param {Function} patchListener - optional function that will be called with all the patches produced here
|
|
40326
|
-
* @returns {any} a new state, or the initial state if nothing was modified
|
|
40327
|
-
*/
|
|
40328
|
-
|
|
40329
|
-
var produce = immer.produce;
|
|
40330
|
-
/**
|
|
40331
|
-
* Like `produce`, but `produceWithPatches` always returns a tuple
|
|
40332
|
-
* [nextState, patches, inversePatches] (instead of just the next state)
|
|
40333
|
-
*/
|
|
40334
|
-
|
|
40335
|
-
immer.produceWithPatches.bind(immer);
|
|
40336
|
-
/**
|
|
40337
|
-
* Pass true to automatically freeze all copies created by Immer.
|
|
40338
|
-
*
|
|
40339
|
-
* By default, auto-freezing is disabled in production.
|
|
40340
|
-
*/
|
|
40341
|
-
|
|
40342
|
-
immer.setAutoFreeze.bind(immer);
|
|
40343
|
-
/**
|
|
40344
|
-
* Pass true to use the ES2015 `Proxy` class when creating drafts, which is
|
|
40345
|
-
* always faster than using ES5 proxies.
|
|
40346
|
-
*
|
|
40347
|
-
* By default, feature detection is used, so calling this is rarely necessary.
|
|
40348
|
-
*/
|
|
40349
|
-
|
|
40350
|
-
immer.setUseProxies.bind(immer);
|
|
40351
|
-
/**
|
|
40352
|
-
* Apply an array of Immer patches to the first argument.
|
|
40353
|
-
*
|
|
40354
|
-
* This function is a producer, which means copy-on-write is in effect.
|
|
40355
|
-
*/
|
|
40356
|
-
|
|
40357
|
-
immer.applyPatches.bind(immer);
|
|
40358
|
-
/**
|
|
40359
|
-
* Create an Immer draft from the given base state, which may be a draft itself.
|
|
40360
|
-
* The draft can be modified until you finalize it with the `finishDraft` function.
|
|
40361
|
-
*/
|
|
39293
|
+
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;
|
|
40362
39294
|
|
|
40363
|
-
|
|
40364
|
-
/**
|
|
40365
|
-
* Finalize an Immer draft from a `createDraft` call, returning the base state
|
|
40366
|
-
* (if no changes were made) or a modified copy. The draft must *not* be
|
|
40367
|
-
* mutated afterwards.
|
|
40368
|
-
*
|
|
40369
|
-
* Pass a function as the 2nd argument to generate Immer patches based on the
|
|
40370
|
-
* changes that were made.
|
|
40371
|
-
*/
|
|
40372
|
-
|
|
40373
|
-
immer.finishDraft.bind(immer);
|
|
40374
|
-
|
|
40375
|
-
const createInitialState = formConfig => {
|
|
39295
|
+
const createInitialState = (formConfig) => {
|
|
40376
39296
|
let initialForm = {};
|
|
40377
39297
|
const formConfigKeys = Object.keys(formConfig);
|
|
40378
39298
|
for (let formKey of formConfigKeys) {
|
|
40379
39299
|
initialForm[formKey] = {
|
|
40380
39300
|
dirty: false,
|
|
40381
|
-
rawValue: formConfig[formKey].defaultValue ||
|
|
39301
|
+
rawValue: formConfig[formKey].defaultValue || '',
|
|
40382
39302
|
validators: formConfig[formKey].validators || [],
|
|
40383
|
-
constraints: formConfig[formKey].constraints || []
|
|
39303
|
+
constraints: formConfig[formKey].constraints || [],
|
|
40384
39304
|
};
|
|
40385
39305
|
}
|
|
40386
39306
|
// Because validators require the entire form we have to do a
|
|
@@ -40391,82 +39311,99 @@ const createInitialState = formConfig => {
|
|
|
40391
39311
|
initialForm[formKey].errors = errors;
|
|
40392
39312
|
initialForm[formKey].hasErrors = errors.length > 0;
|
|
40393
39313
|
}
|
|
39314
|
+
|
|
40394
39315
|
return initialForm;
|
|
40395
39316
|
};
|
|
40396
39317
|
|
|
40397
|
-
const SET =
|
|
40398
|
-
const set$
|
|
39318
|
+
const SET = 'field/SET';
|
|
39319
|
+
const set$1 = (fieldName) => (value) => ({
|
|
40399
39320
|
type: SET,
|
|
40400
|
-
payload: { fieldName, value }
|
|
39321
|
+
payload: { fieldName, value },
|
|
40401
39322
|
});
|
|
40402
39323
|
|
|
40403
|
-
const CLEAR =
|
|
39324
|
+
const CLEAR = 'form/CLEAR';
|
|
40404
39325
|
const clear = () => ({ type: CLEAR });
|
|
40405
39326
|
|
|
40406
|
-
const ADD_VALIDATOR =
|
|
40407
|
-
const addValidator = fieldName => validator => ({
|
|
39327
|
+
const ADD_VALIDATOR = 'field/ADD_VALIDATOR';
|
|
39328
|
+
const addValidator = (fieldName) => (validator) => ({
|
|
40408
39329
|
type: ADD_VALIDATOR,
|
|
40409
|
-
payload: { fieldName, validator }
|
|
39330
|
+
payload: { fieldName, validator },
|
|
40410
39331
|
});
|
|
40411
39332
|
|
|
40412
|
-
const
|
|
40413
|
-
|
|
40414
|
-
|
|
40415
|
-
|
|
40416
|
-
|
|
40417
|
-
case SET:
|
|
40418
|
-
const changedFieldName = action.payload.fieldName;
|
|
40419
|
-
const newRawValue = action.payload.value;
|
|
40420
|
-
|
|
40421
|
-
return produce(state, draftState => {
|
|
40422
|
-
let originalValue = draftState[changedFieldName].rawValue;
|
|
40423
|
-
draftState[changedFieldName].rawValue = newRawValue;
|
|
40424
|
-
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
40425
|
-
// If the change violates constraints, revert the change
|
|
40426
|
-
draftState[changedFieldName].rawValue = originalValue;
|
|
40427
|
-
return draftState;
|
|
40428
|
-
}
|
|
39333
|
+
const REMOVE_VALIDATOR = 'field/REMOVE_VALIDATOR';
|
|
39334
|
+
const removeValidator = (fieldName) => (validator) => ({
|
|
39335
|
+
type: REMOVE_VALIDATOR,
|
|
39336
|
+
payload: { fieldName, validator },
|
|
39337
|
+
});
|
|
40429
39338
|
|
|
40430
|
-
|
|
40431
|
-
|
|
40432
|
-
|
|
40433
|
-
|
|
40434
|
-
|
|
40435
|
-
|
|
40436
|
-
|
|
40437
|
-
|
|
40438
|
-
|
|
40439
|
-
|
|
40440
|
-
|
|
40441
|
-
|
|
40442
|
-
|
|
40443
|
-
|
|
40444
|
-
|
|
40445
|
-
|
|
40446
|
-
|
|
40447
|
-
|
|
40448
|
-
|
|
40449
|
-
|
|
40450
|
-
|
|
40451
|
-
|
|
40452
|
-
let field = entry[1];
|
|
40453
|
-
let errors = computeErrors(fieldName, draftState);
|
|
40454
|
-
let dirty = field.dirty;
|
|
40455
|
-
draftState[fieldName].errors = errors;
|
|
40456
|
-
draftState[fieldName].dirty = dirty;
|
|
40457
|
-
draftState[fieldName].hasErrors = errors.length > 0;
|
|
40458
|
-
}
|
|
40459
|
-
});
|
|
40460
|
-
default:
|
|
40461
|
-
return state;
|
|
40462
|
-
}
|
|
40463
|
-
};
|
|
39339
|
+
const CLEAR_FIELD_VALIDATORS = 'field/CLEAR_FIELD_VALIDATORS';
|
|
39340
|
+
const clearFieldValidators = (fieldName) => () => ({
|
|
39341
|
+
type: CLEAR_FIELD_VALIDATORS,
|
|
39342
|
+
payload: { fieldName },
|
|
39343
|
+
});
|
|
39344
|
+
|
|
39345
|
+
const createFormReducer =
|
|
39346
|
+
(formConfig) =>
|
|
39347
|
+
(state = createInitialState(formConfig), action) => {
|
|
39348
|
+
switch (action.type) {
|
|
39349
|
+
case SET: {
|
|
39350
|
+
const changedFieldName = action.payload.fieldName;
|
|
39351
|
+
const newRawValue = action.payload.value;
|
|
39352
|
+
|
|
39353
|
+
return produce(state, (draftState) => {
|
|
39354
|
+
let originalValue = draftState[changedFieldName].rawValue;
|
|
39355
|
+
draftState[changedFieldName].rawValue = newRawValue;
|
|
39356
|
+
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
39357
|
+
// If the change violates constraints, revert the change
|
|
39358
|
+
draftState[changedFieldName].rawValue = originalValue;
|
|
39359
|
+
return draftState;
|
|
39360
|
+
}
|
|
40464
39361
|
|
|
40465
|
-
|
|
39362
|
+
computeDirtyEntries(draftState, changedFieldName);
|
|
39363
|
+
computeErrorEntries(draftState);
|
|
39364
|
+
});
|
|
39365
|
+
}
|
|
39366
|
+
case CLEAR:
|
|
39367
|
+
return createInitialState(formConfig);
|
|
39368
|
+
case ADD_VALIDATOR: {
|
|
39369
|
+
const fieldWithOverride = action.payload.fieldName;
|
|
39370
|
+
const newValidator = action.payload.validator;
|
|
39371
|
+
|
|
39372
|
+
return produce(state, (draftState) => {
|
|
39373
|
+
draftState[fieldWithOverride].validators.push(newValidator);
|
|
39374
|
+
computeErrorEntries(draftState);
|
|
39375
|
+
});
|
|
39376
|
+
}
|
|
39377
|
+
case REMOVE_VALIDATOR: {
|
|
39378
|
+
const fieldToOverride = action.payload.fieldName;
|
|
39379
|
+
const targetValidator = action.payload.validator;
|
|
39380
|
+
|
|
39381
|
+
return produce(state, (draftState) => {
|
|
39382
|
+
let fieldValidators = draftState[fieldToOverride].validators;
|
|
39383
|
+
draftState[fieldToOverride].validators = fieldValidators.filter(
|
|
39384
|
+
(validator) => validator.type !== targetValidator.type
|
|
39385
|
+
);
|
|
39386
|
+
computeErrorEntries(draftState);
|
|
39387
|
+
});
|
|
39388
|
+
}
|
|
39389
|
+
case CLEAR_FIELD_VALIDATORS: {
|
|
39390
|
+
const fieldToClear = action.payload.fieldName;
|
|
39391
|
+
|
|
39392
|
+
return produce(state, (draftState) => {
|
|
39393
|
+
draftState[fieldToClear].validators = [];
|
|
39394
|
+
computeErrorEntries(draftState);
|
|
39395
|
+
});
|
|
39396
|
+
}
|
|
39397
|
+
default:
|
|
39398
|
+
return state;
|
|
39399
|
+
}
|
|
39400
|
+
};
|
|
39401
|
+
|
|
39402
|
+
const createMapDispatchToProps = (formConfig) => {
|
|
40466
39403
|
// Do memo-ization
|
|
40467
39404
|
let cachedDispatch;
|
|
40468
39405
|
let cacheValue;
|
|
40469
|
-
return dispatch => {
|
|
39406
|
+
return (dispatch) => {
|
|
40470
39407
|
if (dispatch == cachedDispatch) {
|
|
40471
39408
|
return cacheValue;
|
|
40472
39409
|
}
|
|
@@ -40475,8 +39412,11 @@ const createMapDispatchToProps = formConfig => {
|
|
|
40475
39412
|
const keys = Object.keys(formConfig);
|
|
40476
39413
|
for (let fieldName of keys) {
|
|
40477
39414
|
dispatchObj.fields[fieldName] = {
|
|
40478
|
-
set: value => dispatch(set$
|
|
40479
|
-
addValidator: validator => dispatch(addValidator(fieldName)(validator))
|
|
39415
|
+
set: (value) => dispatch(set$1(fieldName)(value)),
|
|
39416
|
+
addValidator: (validator) => dispatch(addValidator(fieldName)(validator)),
|
|
39417
|
+
removeValidator: (validator) =>
|
|
39418
|
+
dispatch(removeValidator(fieldName)(validator)),
|
|
39419
|
+
clear: () => dispatch(clearFieldValidators(fieldName)()),
|
|
40480
39420
|
};
|
|
40481
39421
|
}
|
|
40482
39422
|
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
@@ -40486,12 +39426,12 @@ const createMapDispatchToProps = formConfig => {
|
|
|
40486
39426
|
};
|
|
40487
39427
|
};
|
|
40488
39428
|
|
|
40489
|
-
const mapStateToProps = state => ({ fields: state });
|
|
39429
|
+
const mapStateToProps = (state) => ({ fields: state });
|
|
40490
39430
|
|
|
40491
|
-
const createFormState = formConfig => ({
|
|
39431
|
+
const createFormState = (formConfig) => ({
|
|
40492
39432
|
reducer: createFormReducer(formConfig),
|
|
40493
39433
|
mapDispatchToProps: createMapDispatchToProps(formConfig),
|
|
40494
|
-
mapStateToProps: mapStateToProps
|
|
39434
|
+
mapStateToProps: mapStateToProps,
|
|
40495
39435
|
});
|
|
40496
39436
|
|
|
40497
39437
|
var AddressForm = function AddressForm(_ref) {
|
|
@@ -40539,6 +39479,7 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
40539
39479
|
labelTextWhenNoError: "Country",
|
|
40540
39480
|
errorMessages: countryErrorMessages,
|
|
40541
39481
|
field: fields.country,
|
|
39482
|
+
isRequired: true,
|
|
40542
39483
|
onChange: function onChange(value) {
|
|
40543
39484
|
actions.fields.country.set(value); // temporary measure to not dirty fields until
|
|
40544
39485
|
// we can write a reset function for fields
|
|
@@ -40563,7 +39504,8 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
40563
39504
|
return e.key === "Enter" && handleSubmit(e);
|
|
40564
39505
|
},
|
|
40565
39506
|
autocompleteValue: "address-line1",
|
|
40566
|
-
dataQa: "Address"
|
|
39507
|
+
dataQa: "Address",
|
|
39508
|
+
isRequired: true
|
|
40567
39509
|
}), /*#__PURE__*/React.createElement(FormInput$1, {
|
|
40568
39510
|
labelTextWhenNoError: "Apt, Suite, Unit, Floor, etc. (Optional)",
|
|
40569
39511
|
field: fields.street2,
|
|
@@ -40573,7 +39515,8 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
40573
39515
|
return e.key === "Enter" && handleSubmit(e);
|
|
40574
39516
|
},
|
|
40575
39517
|
autocompleteValue: "address-line2",
|
|
40576
|
-
dataQa: "Address Line 2"
|
|
39518
|
+
dataQa: "Address Line 2",
|
|
39519
|
+
isRequired: false
|
|
40577
39520
|
}), /*#__PURE__*/React.createElement(FormInput$1, {
|
|
40578
39521
|
labelTextWhenNoError: "City",
|
|
40579
39522
|
errorMessages: cityErrorMessages,
|
|
@@ -40584,7 +39527,8 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
40584
39527
|
return e.key === "Enter" && handleSubmit(e);
|
|
40585
39528
|
},
|
|
40586
39529
|
autocompleteValue: "address-level2",
|
|
40587
|
-
dataQa: "City"
|
|
39530
|
+
dataQa: "City",
|
|
39531
|
+
isRequired: true
|
|
40588
39532
|
}), /*#__PURE__*/React.createElement(FormStateDropdown, {
|
|
40589
39533
|
labelTextWhenNoError: isUS ? "State" : "State or Province",
|
|
40590
39534
|
errorMessages: stateProvinceErrorMessages,
|
|
@@ -40595,7 +39539,8 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
40595
39539
|
onKeyDown: function onKeyDown(e) {
|
|
40596
39540
|
return e.key === "Enter" && handleSubmit(e);
|
|
40597
39541
|
},
|
|
40598
|
-
dataQa: "State or Province"
|
|
39542
|
+
dataQa: "State or Province",
|
|
39543
|
+
isRequired: true
|
|
40599
39544
|
}), /*#__PURE__*/React.createElement(FormInput$1, {
|
|
40600
39545
|
isNum: isUS,
|
|
40601
39546
|
formatter: isUS ? zipFormat : null,
|
|
@@ -40608,7 +39553,8 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
40608
39553
|
return e.key === "Enter" && handleSubmit(e);
|
|
40609
39554
|
},
|
|
40610
39555
|
autocompleteValue: "postal-code",
|
|
40611
|
-
dataQa: "Zip code"
|
|
39556
|
+
dataQa: "Zip code",
|
|
39557
|
+
isRequired: true
|
|
40612
39558
|
}), showWalletCheckbox && /*#__PURE__*/React.createElement(Checkbox$1, {
|
|
40613
39559
|
name: "address checkbox",
|
|
40614
39560
|
title: "Save address to wallet",
|
|
@@ -43356,12 +42302,12 @@ LoginForm.mapDispatchToProps = mapDispatchToProps$5;
|
|
|
43356
42302
|
* This source code is licensed under the MIT license found in the
|
|
43357
42303
|
* LICENSE file in the root directory of this source tree.
|
|
43358
42304
|
*/
|
|
43359
|
-
var b$
|
|
43360
|
-
Symbol.for("react.suspense_list"):60120,r=b$
|
|
43361
|
-
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c$
|
|
43362
|
-
var Profiler=g;var StrictMode=f$
|
|
43363
|
-
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$
|
|
43364
|
-
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f$
|
|
42305
|
+
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?
|
|
42306
|
+
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;
|
|
42307
|
+
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;
|
|
42308
|
+
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};
|
|
42309
|
+
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};
|
|
42310
|
+
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;
|
|
43365
42311
|
|
|
43366
42312
|
var reactIs_production_min = {
|
|
43367
42313
|
AsyncMode: AsyncMode,
|
|
@@ -43732,14 +42678,14 @@ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
|
43732
42678
|
|
|
43733
42679
|
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
43734
42680
|
|
|
43735
|
-
var has$
|
|
42681
|
+
var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
43736
42682
|
|
|
43737
42683
|
var printWarning = function() {};
|
|
43738
42684
|
|
|
43739
42685
|
if (process.env.NODE_ENV !== 'production') {
|
|
43740
42686
|
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
43741
42687
|
var loggedTypeFailures = {};
|
|
43742
|
-
var has$
|
|
42688
|
+
var has$2 = has$1;
|
|
43743
42689
|
|
|
43744
42690
|
printWarning = function(text) {
|
|
43745
42691
|
var message = 'Warning: ' + text;
|
|
@@ -43769,7 +42715,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
43769
42715
|
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
43770
42716
|
if (process.env.NODE_ENV !== 'production') {
|
|
43771
42717
|
for (var typeSpecName in typeSpecs) {
|
|
43772
|
-
if (has$
|
|
42718
|
+
if (has$2(typeSpecs, typeSpecName)) {
|
|
43773
42719
|
var error;
|
|
43774
42720
|
// Prop type validation may throw. In case they do, we don't want to
|
|
43775
42721
|
// fail the render phase where it didn't fail before. So we log it.
|
|
@@ -44168,7 +43114,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44168
43114
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
44169
43115
|
}
|
|
44170
43116
|
for (var key in propValue) {
|
|
44171
|
-
if (has$
|
|
43117
|
+
if (has$1(propValue, key)) {
|
|
44172
43118
|
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
44173
43119
|
if (error instanceof Error) {
|
|
44174
43120
|
return error;
|
|
@@ -44205,7 +43151,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44205
43151
|
if (checkerResult == null) {
|
|
44206
43152
|
return null;
|
|
44207
43153
|
}
|
|
44208
|
-
if (checkerResult.data && has$
|
|
43154
|
+
if (checkerResult.data && has$1(checkerResult.data, 'expectedType')) {
|
|
44209
43155
|
expectedTypes.push(checkerResult.data.expectedType);
|
|
44210
43156
|
}
|
|
44211
43157
|
}
|
|
@@ -44265,7 +43211,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
|
44265
43211
|
var allKeys = objectAssign({}, props[propName], shapeTypes);
|
|
44266
43212
|
for (var key in allKeys) {
|
|
44267
43213
|
var checker = shapeTypes[key];
|
|
44268
|
-
if (has$
|
|
43214
|
+
if (has$1(shapeTypes, key) && typeof checker !== 'function') {
|
|
44269
43215
|
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
44270
43216
|
}
|
|
44271
43217
|
if (!checker) {
|
|
@@ -45003,7 +43949,7 @@ var index_esm = /*#__PURE__*/Object.freeze({
|
|
|
45003
43949
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
45004
43950
|
*/
|
|
45005
43951
|
|
|
45006
|
-
function ownKeys$
|
|
43952
|
+
function ownKeys$2(object, enumerableOnly) {
|
|
45007
43953
|
var keys = Object.keys(object);
|
|
45008
43954
|
|
|
45009
43955
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -45019,9 +43965,9 @@ function ownKeys$3(object, enumerableOnly) {
|
|
|
45019
43965
|
function _objectSpread2$1(target) {
|
|
45020
43966
|
for (var i = 1; i < arguments.length; i++) {
|
|
45021
43967
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
45022
|
-
i % 2 ? ownKeys$
|
|
43968
|
+
i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) {
|
|
45023
43969
|
_defineProperty$1(target, key, source[key]);
|
|
45024
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$
|
|
43970
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) {
|
|
45025
43971
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
45026
43972
|
});
|
|
45027
43973
|
}
|
|
@@ -49075,7 +48021,8 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
49075
48021
|
onKeyDown: function onKeyDown(e) {
|
|
49076
48022
|
return e.key === "Enter" && handleSubmit(e);
|
|
49077
48023
|
},
|
|
49078
|
-
autocompleteValue: "name"
|
|
48024
|
+
autocompleteValue: "name",
|
|
48025
|
+
isRequired: true
|
|
49079
48026
|
}), /*#__PURE__*/React.createElement(FormInput$1, {
|
|
49080
48027
|
labelTextWhenNoError: "Routing number",
|
|
49081
48028
|
dataQa: "Routing number",
|
|
@@ -49097,7 +48044,8 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
49097
48044
|
},
|
|
49098
48045
|
onKeyDown: function onKeyDown(e) {
|
|
49099
48046
|
return e.key === "Enter" && handleSubmit(e);
|
|
49100
|
-
}
|
|
48047
|
+
},
|
|
48048
|
+
isRequired: true
|
|
49101
48049
|
}), /*#__PURE__*/React.createElement(FormInput$1, {
|
|
49102
48050
|
labelTextWhenNoError: "Confirm routing number",
|
|
49103
48051
|
dataQa: "Confirm routing number",
|
|
@@ -49108,6 +48056,7 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
49108
48056
|
onKeyDown: function onKeyDown(e) {
|
|
49109
48057
|
return e.key === "Enter" && handleSubmit(e);
|
|
49110
48058
|
},
|
|
48059
|
+
isRequired: true,
|
|
49111
48060
|
isNum: true
|
|
49112
48061
|
}), /*#__PURE__*/React.createElement(FormInput$1, {
|
|
49113
48062
|
labelTextWhenNoError: "Account number",
|
|
@@ -49116,6 +48065,7 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
49116
48065
|
field: fields.accountNumber,
|
|
49117
48066
|
fieldActions: actions.fields.accountNumber,
|
|
49118
48067
|
showErrors: showErrors,
|
|
48068
|
+
isRequired: true,
|
|
49119
48069
|
isNum: true,
|
|
49120
48070
|
helperModal: function helperModal() {
|
|
49121
48071
|
return /*#__PURE__*/React.createElement(AccountAndRoutingModal$1, {
|
|
@@ -49134,6 +48084,7 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
49134
48084
|
}), /*#__PURE__*/React.createElement(FormInput$1, {
|
|
49135
48085
|
labelTextWhenNoError: "Confirm account number",
|
|
49136
48086
|
dataQa: "Confirm account number",
|
|
48087
|
+
isRequired: true,
|
|
49137
48088
|
errorMessages: confirmAccountNumberErrors,
|
|
49138
48089
|
field: fields.confirmAccountNumber,
|
|
49139
48090
|
fieldActions: actions.fields.confirmAccountNumber,
|
|
@@ -49144,6 +48095,7 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
|
|
|
49144
48095
|
isNum: true
|
|
49145
48096
|
}), allowBankAccountType && /*#__PURE__*/React.createElement(FormSelect$1, {
|
|
49146
48097
|
labelTextWhenNoError: "Account type",
|
|
48098
|
+
isRequired: true,
|
|
49147
48099
|
dataQa: "Account type",
|
|
49148
48100
|
options: [{
|
|
49149
48101
|
text: "Select account type",
|
|
@@ -49274,6 +48226,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
49274
48226
|
"aria-label": "Card payment"
|
|
49275
48227
|
}, /*#__PURE__*/React.createElement(FormInputColumn, null, !hideZipCode && /*#__PURE__*/React.createElement(CountryDropdown, {
|
|
49276
48228
|
labelTextWhenNoError: "Country",
|
|
48229
|
+
isRequired: true,
|
|
49277
48230
|
errorMessages: countryErrorMessages,
|
|
49278
48231
|
field: fields.country,
|
|
49279
48232
|
onChange: function onChange(value) {
|
|
@@ -49296,8 +48249,10 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
49296
48249
|
onKeyDown: function onKeyDown(e) {
|
|
49297
48250
|
return e.key === "Enter" && handleSubmit(e);
|
|
49298
48251
|
},
|
|
49299
|
-
autocompleteValue: "cc-name"
|
|
48252
|
+
autocompleteValue: "cc-name",
|
|
48253
|
+
isRequired: true
|
|
49300
48254
|
}), /*#__PURE__*/React.createElement(FormInput$1, {
|
|
48255
|
+
isRequired: true,
|
|
49301
48256
|
labelTextWhenNoError: "Credit card number",
|
|
49302
48257
|
dataQa: "Credit card number",
|
|
49303
48258
|
errorMessages: creditCardNumberErrors,
|
|
@@ -49327,7 +48282,8 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
49327
48282
|
isNum: true,
|
|
49328
48283
|
removeFromValue: /\// // removes "/" from browser autofill
|
|
49329
48284
|
,
|
|
49330
|
-
autocompleteValue: "cc-exp"
|
|
48285
|
+
autocompleteValue: "cc-exp",
|
|
48286
|
+
isRequired: true
|
|
49331
48287
|
}), /*#__PURE__*/React.createElement(FormInput$1, {
|
|
49332
48288
|
labelTextWhenNoError: "CVV",
|
|
49333
48289
|
dataQa: "CVV",
|
|
@@ -49340,7 +48296,8 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
49340
48296
|
onKeyDown: function onKeyDown(e) {
|
|
49341
48297
|
return e.key === "Enter" && handleSubmit(e);
|
|
49342
48298
|
},
|
|
49343
|
-
autocompleteValue: "cc-csc"
|
|
48299
|
+
autocompleteValue: "cc-csc",
|
|
48300
|
+
isRequired: true
|
|
49344
48301
|
})), !hideZipCode && /*#__PURE__*/React.createElement(Box, {
|
|
49345
48302
|
padding: isMobile ? "0" : "0 0.5rem 0 0",
|
|
49346
48303
|
width: isMobile ? "100%" : "50%"
|
|
@@ -49356,7 +48313,8 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
|
|
|
49356
48313
|
onKeyDown: function onKeyDown(e) {
|
|
49357
48314
|
return e.key === "Enter" && handleSubmit(e);
|
|
49358
48315
|
},
|
|
49359
|
-
autocompleteValue: "billing postal-code"
|
|
48316
|
+
autocompleteValue: "billing postal-code",
|
|
48317
|
+
isRequired: true
|
|
49360
48318
|
})), (showWalletCheckbox || showTerms) && /*#__PURE__*/React.createElement(Cluster, {
|
|
49361
48319
|
childGap: "4px",
|
|
49362
48320
|
align: "center"
|
|
@@ -49604,7 +48562,7 @@ PhoneForm.mapDispatchToProps = mapDispatchToProps$8;
|
|
|
49604
48562
|
var DefaultHeading = styled.div.withConfig({
|
|
49605
48563
|
displayName: "RadioGroup__DefaultHeading",
|
|
49606
48564
|
componentId: "sc-7lqrl8-0"
|
|
49607
|
-
})(["font-size:0.875rem;color:", "
|
|
48565
|
+
})(["font-size:0.875rem;color:", ";margin:0;padding:8px 0px;"], CHARADE_GREY);
|
|
49608
48566
|
var StyledFieldset = styled.fieldset.withConfig({
|
|
49609
48567
|
displayName: "RadioGroup__StyledFieldset",
|
|
49610
48568
|
componentId: "sc-7lqrl8-1"
|
|
@@ -49825,7 +48783,8 @@ var RadioSection = function RadioSection(_ref) {
|
|
|
49825
48783
|
toggleRadio: section.disabled ? noop : function () {
|
|
49826
48784
|
return toggleOpenSection(section.id);
|
|
49827
48785
|
},
|
|
49828
|
-
tabIndex: "-1"
|
|
48786
|
+
tabIndex: "-1",
|
|
48787
|
+
required: section === null || section === void 0 ? void 0 : section.required
|
|
49829
48788
|
})), section.titleIcon && /*#__PURE__*/React.createElement(Cluster, {
|
|
49830
48789
|
align: "center"
|
|
49831
48790
|
}, section.titleIcon), /*#__PURE__*/React.createElement(Box, {
|