@thecb/components 3.5.2 → 3.5.5-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 +403 -637
- package/package.json +1 -1
- package/src/components/atoms/form-layouts/FormInput.js +0 -1
- package/src/components/atoms/layouts/Cover.styled.js +1 -0
- package/src/components/atoms/layouts/Imposter.styled.js +1 -0
- package/src/components/atoms/loading/Loading.js +1 -1
- package/src/components/molecules/content/Content.js +20 -0
- package/src/components/molecules/content/Content.theme.js +60 -0
- package/src/components/molecules/content/blocks/accordion-block/AccordionBlock.js +108 -0
- package/src/components/molecules/content/blocks/accordion-block/index.js +3 -0
- package/src/components/molecules/content/blocks/article-block/ArticleBlock.js +58 -0
- package/src/components/molecules/content/blocks/article-block/index.js +3 -0
- package/src/components/molecules/content/blocks/attached-file-block/AttachedFileBlock.js +60 -0
- package/src/components/molecules/content/blocks/attached-file-block/index.js +3 -0
- package/src/components/molecules/content/blocks/featured-content-block/FeaturedContentBlock.js +0 -0
- package/src/components/molecules/content/blocks/featured-content-block/index.js +0 -0
- package/src/components/molecules/content/blocks/hero-block/HeroBlock.js +54 -0
- package/src/components/molecules/content/blocks/hero-block/index.js +3 -0
- package/src/components/molecules/content/blocks/highlight-block/HighlightBlock.js +42 -0
- package/src/components/molecules/content/blocks/highlight-block/index.js +3 -0
- package/src/components/molecules/content/blocks/index.js +33 -0
- package/src/components/molecules/content/blocks/info-block/InfoBlock.js +15 -0
- package/src/components/molecules/content/blocks/info-block/index.js +3 -0
- package/src/components/molecules/content/blocks/location-block/LocationBlock.js +228 -0
- package/src/components/molecules/content/blocks/location-block/index.js +3 -0
- package/src/components/molecules/content/blocks/related-links-block/RelatedLinksBlock.js +35 -0
- package/src/components/molecules/content/blocks/related-links-block/index.js +3 -0
- package/src/components/molecules/content/blocks/screendoor-block/ScreendoorBlock.js +57 -0
- package/src/components/molecules/content/blocks/screendoor-block/ScreendoorForm.styled.js +314 -0
- package/src/components/molecules/content/blocks/screendoor-block/index.js +3 -0
- package/src/components/molecules/content/blocks/tagline-block/TaglineBlock.js +45 -0
- package/src/components/molecules/content/blocks/tagline-block/index.js +3 -0
- package/src/components/molecules/content/blocks/task-block/TaskBlock.js +40 -0
- package/src/components/molecules/content/blocks/task-block/index.js +3 -0
- package/src/components/molecules/content/blocks/text-block/TextBlock.js +40 -0
- package/src/components/molecules/content/blocks/text-block/index.js +3 -0
- package/src/components/molecules/content/header/Header.js +283 -0
- package/src/components/molecules/content/header/Header.theme.js +11 -0
- package/src/components/molecules/content/header/index.js +3 -0
- package/src/components/molecules/content/index.js +3 -0
- package/src/components/molecules/payment-button-bar/PaymentButtonBar.js +17 -16
package/dist/index.cjs.js
CHANGED
|
@@ -215,63 +215,6 @@ function _nonIterableRest() {
|
|
|
215
215
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
219
|
-
var it;
|
|
220
|
-
|
|
221
|
-
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
|
222
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
223
|
-
if (it) o = it;
|
|
224
|
-
var i = 0;
|
|
225
|
-
|
|
226
|
-
var F = function () {};
|
|
227
|
-
|
|
228
|
-
return {
|
|
229
|
-
s: F,
|
|
230
|
-
n: function () {
|
|
231
|
-
if (i >= o.length) return {
|
|
232
|
-
done: true
|
|
233
|
-
};
|
|
234
|
-
return {
|
|
235
|
-
done: false,
|
|
236
|
-
value: o[i++]
|
|
237
|
-
};
|
|
238
|
-
},
|
|
239
|
-
e: function (e) {
|
|
240
|
-
throw e;
|
|
241
|
-
},
|
|
242
|
-
f: F
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
var normalCompletion = true,
|
|
250
|
-
didErr = false,
|
|
251
|
-
err;
|
|
252
|
-
return {
|
|
253
|
-
s: function () {
|
|
254
|
-
it = o[Symbol.iterator]();
|
|
255
|
-
},
|
|
256
|
-
n: function () {
|
|
257
|
-
var step = it.next();
|
|
258
|
-
normalCompletion = step.done;
|
|
259
|
-
return step;
|
|
260
|
-
},
|
|
261
|
-
e: function (e) {
|
|
262
|
-
didErr = true;
|
|
263
|
-
err = e;
|
|
264
|
-
},
|
|
265
|
-
f: function () {
|
|
266
|
-
try {
|
|
267
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
268
|
-
} finally {
|
|
269
|
-
if (didErr) throw err;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
|
|
275
218
|
/*! *****************************************************************************
|
|
276
219
|
Copyright (c) Microsoft Corporation.
|
|
277
220
|
|
|
@@ -6787,7 +6730,7 @@ var Stack = function Stack(_ref) {
|
|
|
6787
6730
|
};
|
|
6788
6731
|
|
|
6789
6732
|
function _templateObject$7() {
|
|
6790
|
-
var data = _taggedTemplateLiteral(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n min-height: ", ";\n padding: ", ";\n\n > * {\n margin-top: ", ";\n margin-bottom: ", ";\n }\n\n > :first-child {\n margin-top: 0;\n }\n\n ", "\n\n ", "\n\n > :last-child {\n margin-bottom: 0;\n }\n"]);
|
|
6733
|
+
var data = _taggedTemplateLiteral(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n min-height: ", ";\n padding: ", ";\n min-width: ", ";\n\n > * {\n margin-top: ", ";\n margin-bottom: ", ";\n }\n\n > :first-child {\n margin-top: 0;\n }\n\n ", "\n\n ", "\n\n > :last-child {\n margin-bottom: 0;\n }\n"]);
|
|
6791
6734
|
|
|
6792
6735
|
_templateObject$7 = function _templateObject() {
|
|
6793
6736
|
return data;
|
|
@@ -6802,16 +6745,19 @@ var CoverOuterContainer = styled__default.div(_templateObject$7(), function (_re
|
|
|
6802
6745
|
var padding = _ref2.padding;
|
|
6803
6746
|
return padding;
|
|
6804
6747
|
}, function (_ref3) {
|
|
6805
|
-
var
|
|
6806
|
-
return
|
|
6748
|
+
var fillCenter = _ref3.fillCenter;
|
|
6749
|
+
return fillCenter ? "100%" : "auto";
|
|
6807
6750
|
}, function (_ref4) {
|
|
6808
6751
|
var childGap = _ref4.childGap;
|
|
6809
6752
|
return childGap;
|
|
6810
6753
|
}, function (_ref5) {
|
|
6811
|
-
var
|
|
6812
|
-
return
|
|
6754
|
+
var childGap = _ref5.childGap;
|
|
6755
|
+
return childGap;
|
|
6813
6756
|
}, function (_ref6) {
|
|
6814
|
-
var
|
|
6757
|
+
var fillCenter = _ref6.fillCenter;
|
|
6758
|
+
return fillCenter ? "> :nth-child(2) {flex-grow: 1;}" : "";
|
|
6759
|
+
}, function (_ref7) {
|
|
6760
|
+
var centerOverride = _ref7.centerOverride;
|
|
6815
6761
|
return centerOverride ? "> :nth-child(2) {margin-top: 0; margin-bottom: auto;}" : "> :nth-child(2) {margin-top: auto; margin-bottom: auto;}";
|
|
6816
6762
|
});
|
|
6817
6763
|
|
|
@@ -7009,7 +6955,7 @@ var Switcher = function Switcher(_ref) {
|
|
|
7009
6955
|
};
|
|
7010
6956
|
|
|
7011
6957
|
function _templateObject$a() {
|
|
7012
|
-
var data = _taggedTemplateLiteral(["\n position: ", ";\n top: ", ";\n left: ", ";\n display: ", ";\n\n ", "\n\n ", "\n"]);
|
|
6958
|
+
var data = _taggedTemplateLiteral(["\n position: ", ";\n top: ", ";\n left: ", ";\n display: ", ";\n\n ", "\n\n ", "\n ", ";\n"]);
|
|
7013
6959
|
|
|
7014
6960
|
_templateObject$a = function _templateObject() {
|
|
7015
6961
|
return data;
|
|
@@ -7037,6 +6983,9 @@ var ImposterWrapper = styled__default.div(_templateObject$a(), function (_ref) {
|
|
|
7037
6983
|
verticalMargin = _ref6.verticalMargin,
|
|
7038
6984
|
horizontalMargin = _ref6.horizontalMargin;
|
|
7039
6985
|
return breakout ? "" : "\n overflow: auto;\n max-width: calc(100% - (".concat(horizontalMargin, " * 2));\n max-height: calc(100% - (").concat(verticalMargin, " * 2));\n ");
|
|
6986
|
+
}, function (_ref7) {
|
|
6987
|
+
var extraStyles = _ref7.extraStyles;
|
|
6988
|
+
return extraStyles;
|
|
7040
6989
|
});
|
|
7041
6990
|
|
|
7042
6991
|
/*
|
|
@@ -18613,7 +18562,6 @@ var FormInput = function FormInput(_ref9) {
|
|
|
18613
18562
|
color: themeValues.linkColor,
|
|
18614
18563
|
weight: themeValues.fontWeight,
|
|
18615
18564
|
hoverStyles: themeValues.hoverFocusStyles,
|
|
18616
|
-
focusStyles: themeValues.hoverFocusStyles,
|
|
18617
18565
|
extraStyles: "cursor: pointer;",
|
|
18618
18566
|
onClick: function onClick() {
|
|
18619
18567
|
return setShowPassword(!showPassword);
|
|
@@ -19128,7 +19076,7 @@ var Loading = function Loading() {
|
|
|
19128
19076
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
19129
19077
|
key: "spinner-container"
|
|
19130
19078
|
}, /*#__PURE__*/React__default.createElement(Cover, {
|
|
19131
|
-
minHeight: "
|
|
19079
|
+
minHeight: "100vh",
|
|
19132
19080
|
singleChild: true
|
|
19133
19081
|
}, /*#__PURE__*/React__default.createElement(Center, {
|
|
19134
19082
|
intrinsic: true
|
|
@@ -30572,401 +30520,378 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
|
|
|
30572
30520
|
|
|
30573
30521
|
var ToggleSwitch$1 = themeComponent(ToggleSwitch, "ToggleSwitch", fallbackValues$o);
|
|
30574
30522
|
|
|
30575
|
-
|
|
30576
|
-
|
|
30577
|
-
|
|
30578
|
-
|
|
30579
|
-
}
|
|
30523
|
+
const validatorToPredicate = (validatorFn, emptyCase) => (
|
|
30524
|
+
value,
|
|
30525
|
+
...rest
|
|
30526
|
+
) => (value === "" ? emptyCase : validatorFn(value, ...rest));
|
|
30580
30527
|
|
|
30581
|
-
return value === "" ? emptyCase : validatorFn.apply(void 0, [value].concat(rest));
|
|
30582
|
-
};
|
|
30583
|
-
};
|
|
30584
30528
|
/* eslint-disable no-unused-vars */
|
|
30585
30529
|
|
|
30586
|
-
|
|
30587
|
-
|
|
30588
|
-
var validator = function validator() {
|
|
30589
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
30590
|
-
args[_key2] = arguments[_key2];
|
|
30591
|
-
}
|
|
30592
|
-
|
|
30593
|
-
return {
|
|
30594
|
-
type: type,
|
|
30595
|
-
args: args,
|
|
30596
|
-
error: error
|
|
30597
|
-
};
|
|
30598
|
-
};
|
|
30599
|
-
|
|
30530
|
+
const createValidator = (type, error) => {
|
|
30531
|
+
let validator = (...args) => ({ type, args, error });
|
|
30600
30532
|
validator.error = error;
|
|
30601
30533
|
return validator;
|
|
30602
30534
|
};
|
|
30603
30535
|
|
|
30604
|
-
|
|
30605
|
-
var REQUIRED = "validator/REQUIRED";
|
|
30606
|
-
var REQUIRED_ERROR = "error/REQUIRED";
|
|
30607
|
-
var required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
30608
|
-
|
|
30609
|
-
validatorFns[REQUIRED] = function (value, args, form) {
|
|
30610
|
-
return value !== "";
|
|
30611
|
-
};
|
|
30612
|
-
|
|
30613
|
-
var ONLY_INTEGERS = "validator/ONLY_INTEGERS";
|
|
30614
|
-
var ONLY_INTEGERS_ERROR = "error/ONLY_INTEGERS";
|
|
30615
|
-
var onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
30616
|
-
|
|
30617
|
-
validatorFns[ONLY_INTEGERS] = function (value, args, form) {
|
|
30618
|
-
return /^(-?\d+)?$/.test(value);
|
|
30619
|
-
};
|
|
30536
|
+
let validatorFns = {};
|
|
30620
30537
|
|
|
30621
|
-
|
|
30622
|
-
|
|
30623
|
-
|
|
30538
|
+
const REQUIRED = "validator/REQUIRED";
|
|
30539
|
+
const REQUIRED_ERROR = "error/REQUIRED";
|
|
30540
|
+
const required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
30541
|
+
validatorFns[REQUIRED] = (value, args, form) => value !== "";
|
|
30624
30542
|
|
|
30625
|
-
|
|
30626
|
-
|
|
30627
|
-
|
|
30543
|
+
const ONLY_INTEGERS = "validator/ONLY_INTEGERS";
|
|
30544
|
+
const ONLY_INTEGERS_ERROR = "error/ONLY_INTEGERS";
|
|
30545
|
+
const onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
30546
|
+
validatorFns[ONLY_INTEGERS] = (value, args, form) => /^(-?\d+)?$/.test(value);
|
|
30628
30547
|
|
|
30629
|
-
|
|
30630
|
-
|
|
30631
|
-
|
|
30548
|
+
const ONLY_NATURALS = "validator/ONLY_NATURALS";
|
|
30549
|
+
const ONLY_NATURALS_ERROR = "error/ONLY_NATURALS";
|
|
30550
|
+
const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
30551
|
+
validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
|
|
30632
30552
|
|
|
30633
|
-
|
|
30553
|
+
const NUMBER_LESS_THAN = "validator/NUMBER_LESS_THAN";
|
|
30554
|
+
const NUMBER_LESS_THAN_ERROR = "error/NUMBER_LESS_THAN";
|
|
30555
|
+
const numberLessThan = createValidator(
|
|
30556
|
+
NUMBER_LESS_THAN,
|
|
30557
|
+
NUMBER_LESS_THAN_ERROR
|
|
30558
|
+
);
|
|
30559
|
+
validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
30634
30560
|
if (value === "") {
|
|
30635
30561
|
return true;
|
|
30636
30562
|
}
|
|
30637
|
-
|
|
30638
30563
|
return Number(value) < args[0];
|
|
30639
30564
|
};
|
|
30640
30565
|
|
|
30641
|
-
|
|
30642
|
-
|
|
30643
|
-
|
|
30644
|
-
|
|
30645
|
-
|
|
30566
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
30567
|
+
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
30568
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
30569
|
+
"error/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
30570
|
+
const numberLessThanOrEqualTo = createValidator(
|
|
30571
|
+
NUMBER_LESS_THAN_OR_EQUAL_TO,
|
|
30572
|
+
NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR
|
|
30573
|
+
);
|
|
30574
|
+
validatorFns[NUMBER_LESS_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
30646
30575
|
if (value === "") {
|
|
30647
30576
|
return true;
|
|
30648
30577
|
}
|
|
30649
|
-
|
|
30650
30578
|
return Number(value) <= args[0];
|
|
30651
30579
|
};
|
|
30652
30580
|
|
|
30653
|
-
|
|
30654
|
-
|
|
30655
|
-
|
|
30656
|
-
|
|
30657
|
-
|
|
30581
|
+
const NUMBER_GREATER_THAN = "validator/NUMBER_GREATER_THAN";
|
|
30582
|
+
const NUMBER_GREATER_THAN_ERROR = "error/NUMBER_GREATER_THAN";
|
|
30583
|
+
const numberGreaterThan = createValidator(
|
|
30584
|
+
NUMBER_GREATER_THAN,
|
|
30585
|
+
NUMBER_GREATER_THAN_ERROR
|
|
30586
|
+
);
|
|
30587
|
+
validatorFns[NUMBER_GREATER_THAN] = (value, args, form) => {
|
|
30658
30588
|
if (value === "") {
|
|
30659
30589
|
return true;
|
|
30660
30590
|
}
|
|
30661
|
-
|
|
30662
30591
|
return Number(value) > args[0];
|
|
30663
30592
|
};
|
|
30664
30593
|
|
|
30665
|
-
|
|
30666
|
-
|
|
30667
|
-
|
|
30668
|
-
|
|
30669
|
-
|
|
30594
|
+
const NUMBER_GREATER_THAN_OR_EQUAL_TO =
|
|
30595
|
+
"validator/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
30596
|
+
const NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR =
|
|
30597
|
+
"error/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
30598
|
+
const numberGreaterThanOrEqualTo = createValidator(
|
|
30599
|
+
NUMBER_GREATER_THAN_OR_EQUAL_TO,
|
|
30600
|
+
NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR
|
|
30601
|
+
);
|
|
30602
|
+
validatorFns[NUMBER_GREATER_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
30670
30603
|
if (value === "") {
|
|
30671
30604
|
return true;
|
|
30672
30605
|
}
|
|
30673
|
-
|
|
30674
30606
|
return Number(value) >= args[0];
|
|
30675
30607
|
};
|
|
30676
30608
|
|
|
30677
|
-
|
|
30678
|
-
|
|
30679
|
-
|
|
30680
|
-
|
|
30681
|
-
validatorFns[MATCHES_FIELD] = function (value, args, form) {
|
|
30609
|
+
const MATCHES_FIELD = "validator/MATCHES_FIELD";
|
|
30610
|
+
const MATCHES_FIELD_ERROR$1 = "error/MATCHES_FIELD";
|
|
30611
|
+
const matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
|
|
30612
|
+
validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
30682
30613
|
if (value === "") {
|
|
30683
30614
|
return true;
|
|
30684
30615
|
}
|
|
30685
|
-
|
|
30686
30616
|
if (form[args[0]] === undefined) {
|
|
30687
|
-
throw new Error(
|
|
30617
|
+
throw new Error(
|
|
30618
|
+
`${args[0]} was passed to matchesField, but that field does not exist in the form`
|
|
30619
|
+
);
|
|
30688
30620
|
}
|
|
30689
|
-
|
|
30690
30621
|
return value === form[args[0]].rawValue;
|
|
30691
30622
|
};
|
|
30692
30623
|
|
|
30693
|
-
|
|
30694
|
-
|
|
30695
|
-
|
|
30696
|
-
|
|
30697
|
-
|
|
30698
|
-
|
|
30699
|
-
|
|
30700
|
-
|
|
30701
|
-
|
|
30702
|
-
|
|
30703
|
-
|
|
30704
|
-
|
|
30705
|
-
|
|
30706
|
-
|
|
30707
|
-
|
|
30624
|
+
const validateWhenErrorMessage = type =>
|
|
30625
|
+
`${type} was passed to validateWhen, but that validator type does not exist.
|
|
30626
|
+
Please check that you are only calling validator creator functions exported from
|
|
30627
|
+
redux-freeform in your form config and that you didn't forget to
|
|
30628
|
+
invoke the validator creator (you cannot pass the functions themselves to
|
|
30629
|
+
createFormState). Also make sure you aren't passing validateWhen() to validateWhen
|
|
30630
|
+
as the primary validator.`;
|
|
30631
|
+
|
|
30632
|
+
const VALIDATE_WHEN = "validator/VALIDATE_WHEN";
|
|
30633
|
+
const VALIDATE_WHEN_ERROR = "error/VALIDATE_WHEN";
|
|
30634
|
+
const validateWhen = (
|
|
30635
|
+
dependentValidator,
|
|
30636
|
+
primaryValidator,
|
|
30637
|
+
optionalFieldName
|
|
30638
|
+
) => ({
|
|
30639
|
+
type: VALIDATE_WHEN,
|
|
30640
|
+
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
30641
|
+
error: dependentValidator.error
|
|
30642
|
+
});
|
|
30708
30643
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
30644
|
+
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
30645
|
+
const [dependentValidator, primaryValidator, optionalFieldName] = args;
|
|
30646
|
+
const dependsOnOtherField = typeof optionalFieldName === "string";
|
|
30709
30647
|
|
|
30710
|
-
|
|
30711
|
-
|
|
30712
|
-
|
|
30713
|
-
|
|
30714
|
-
optionalFieldName = _args[2];
|
|
30715
|
-
|
|
30716
|
-
var dependsOnOtherField = typeof optionalFieldName === "string";
|
|
30717
|
-
|
|
30718
|
-
if (primaryValidator.type === undefined || typeof validatorFns[primaryValidator.type] !== "function") {
|
|
30648
|
+
if (
|
|
30649
|
+
primaryValidator.type === undefined ||
|
|
30650
|
+
typeof validatorFns[primaryValidator.type] !== "function"
|
|
30651
|
+
) {
|
|
30719
30652
|
throw new Error(validateWhenErrorMessage(primaryValidator.type));
|
|
30720
30653
|
}
|
|
30721
|
-
|
|
30722
30654
|
if (dependsOnOtherField && form[optionalFieldName] === undefined) {
|
|
30723
|
-
throw new Error(
|
|
30655
|
+
throw new Error(
|
|
30656
|
+
`${args[2]} was passed to matchesField, but that field does not exist in the form`
|
|
30657
|
+
);
|
|
30724
30658
|
}
|
|
30725
30659
|
|
|
30726
|
-
|
|
30727
|
-
|
|
30728
|
-
|
|
30729
|
-
|
|
30730
|
-
|
|
30731
|
-
|
|
30732
|
-
|
|
30733
|
-
|
|
30734
|
-
|
|
30735
|
-
|
|
30736
|
-
|
|
30737
|
-
|
|
30738
|
-
|
|
30739
|
-
var validateSum = function validateSum(validator, fieldNamesArray) {
|
|
30740
|
-
return {
|
|
30741
|
-
type: VALIDATE_SUM,
|
|
30742
|
-
args: [validator, fieldNamesArray],
|
|
30743
|
-
error: validator.error
|
|
30744
|
-
};
|
|
30745
|
-
};
|
|
30660
|
+
const primaryPredicate = validatorToPredicate(
|
|
30661
|
+
validatorFns[primaryValidator.type],
|
|
30662
|
+
false
|
|
30663
|
+
);
|
|
30664
|
+
const primaryValue = dependsOnOtherField
|
|
30665
|
+
? form[optionalFieldName].rawValue
|
|
30666
|
+
: value;
|
|
30667
|
+
const primaryPredicatePassed = primaryPredicate(
|
|
30668
|
+
primaryValue,
|
|
30669
|
+
primaryValidator.args,
|
|
30670
|
+
form
|
|
30671
|
+
);
|
|
30746
30672
|
|
|
30673
|
+
return primaryPredicatePassed
|
|
30674
|
+
? validatorFns[dependentValidator.type](
|
|
30675
|
+
value,
|
|
30676
|
+
dependentValidator.args,
|
|
30677
|
+
form
|
|
30678
|
+
)
|
|
30679
|
+
: true;
|
|
30680
|
+
};
|
|
30681
|
+
|
|
30682
|
+
const validateSumErrorMessage = type =>
|
|
30683
|
+
`${type} was passed to validateSum, but that validator type does not exist.
|
|
30684
|
+
Please check that you are only calling validator creator functions exported from
|
|
30685
|
+
redux-freeform in your form config and that you didn't forget to
|
|
30686
|
+
invoke the validator creator (you cannot pass the functions themselves to
|
|
30687
|
+
createFormState).`;
|
|
30688
|
+
const VALIDATE_SUM = "validator/VALIDATE_SUM";
|
|
30689
|
+
const VALIDATE_SUM_ERROR = "error/VALIDATE_SUM";
|
|
30690
|
+
const validateSum = (validator, fieldNamesArray) => ({
|
|
30691
|
+
type: VALIDATE_SUM,
|
|
30692
|
+
args: [validator, fieldNamesArray],
|
|
30693
|
+
error: validator.error
|
|
30694
|
+
});
|
|
30747
30695
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
30696
|
+
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
30697
|
+
const [validator, fieldNamesArray] = args;
|
|
30748
30698
|
|
|
30749
|
-
|
|
30750
|
-
|
|
30751
|
-
|
|
30752
|
-
|
|
30753
|
-
|
|
30754
|
-
if (validator.type === undefined || typeof validatorFns[validator.type] !== "function") {
|
|
30699
|
+
if (
|
|
30700
|
+
validator.type === undefined ||
|
|
30701
|
+
typeof validatorFns[validator.type] !== "function"
|
|
30702
|
+
) {
|
|
30755
30703
|
throw new Error(validateSumErrorMessage(validator.type));
|
|
30756
30704
|
}
|
|
30757
30705
|
|
|
30758
|
-
|
|
30759
|
-
|
|
30760
|
-
|
|
30761
|
-
|
|
30762
|
-
|
|
30763
|
-
var fieldName = _step.value;
|
|
30764
|
-
|
|
30765
|
-
if (form[fieldName] === undefined) {
|
|
30766
|
-
throw new Error("".concat(fieldName, " was passed to matchesField, but that field does not exist in the form"));
|
|
30767
|
-
}
|
|
30706
|
+
for (const fieldName of fieldNamesArray) {
|
|
30707
|
+
if (form[fieldName] === undefined) {
|
|
30708
|
+
throw new Error(
|
|
30709
|
+
`${fieldName} was passed to matchesField, but that field does not exist in the form`
|
|
30710
|
+
);
|
|
30768
30711
|
}
|
|
30769
|
-
} catch (err) {
|
|
30770
|
-
_iterator.e(err);
|
|
30771
|
-
} finally {
|
|
30772
|
-
_iterator.f();
|
|
30773
30712
|
}
|
|
30774
30713
|
|
|
30775
|
-
|
|
30776
|
-
|
|
30777
|
-
|
|
30714
|
+
const sum = fieldNamesArray.reduce(
|
|
30715
|
+
(acc, curr) => acc + Number(form[curr].rawValue),
|
|
30716
|
+
Number(value)
|
|
30717
|
+
);
|
|
30718
|
+
|
|
30778
30719
|
return validatorFns[validator.type](sum, validator.args, form);
|
|
30779
30720
|
};
|
|
30780
30721
|
|
|
30781
|
-
|
|
30782
|
-
|
|
30783
|
-
|
|
30784
|
-
|
|
30785
|
-
validatorFns[HAS_LENGTH] = function (value, args, form) {
|
|
30722
|
+
const HAS_LENGTH = "validator/HAS_LENGTH";
|
|
30723
|
+
const HAS_LENGTH_ERROR = "error/HAS_LENGTH";
|
|
30724
|
+
const hasLength = createValidator(HAS_LENGTH, HAS_LENGTH_ERROR);
|
|
30725
|
+
validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
30786
30726
|
if (value === "") {
|
|
30787
30727
|
return true;
|
|
30788
30728
|
}
|
|
30789
|
-
|
|
30790
|
-
|
|
30791
|
-
var max = args[1];
|
|
30792
|
-
|
|
30729
|
+
const min = args[0];
|
|
30730
|
+
const max = args[1];
|
|
30793
30731
|
if (max == undefined || min == undefined) {
|
|
30794
|
-
throw new Error(
|
|
30732
|
+
throw new Error(
|
|
30733
|
+
"Max and min need to be defined for hasLength, both or one of them is undefined"
|
|
30734
|
+
);
|
|
30795
30735
|
}
|
|
30796
|
-
|
|
30797
30736
|
if (max < min) {
|
|
30798
|
-
throw new Error(
|
|
30737
|
+
throw new Error(
|
|
30738
|
+
"hasLength validator was passed a min greater than the max"
|
|
30739
|
+
);
|
|
30799
30740
|
}
|
|
30800
|
-
|
|
30801
|
-
var valueLength = value.length;
|
|
30741
|
+
const valueLength = value.length;
|
|
30802
30742
|
return max >= valueLength && valueLength >= min;
|
|
30803
30743
|
};
|
|
30804
30744
|
|
|
30805
|
-
|
|
30806
|
-
|
|
30807
|
-
|
|
30808
|
-
|
|
30809
|
-
validatorFns[MATCHES_REGEX] = function (value, args, form) {
|
|
30745
|
+
const MATCHES_REGEX = "validator/MATCHES_REGEX";
|
|
30746
|
+
const MATCHES_REGEX_ERROR = "error/MATCHES_REGEX";
|
|
30747
|
+
const matchesRegex = createValidator(MATCHES_REGEX, MATCHES_REGEX_ERROR);
|
|
30748
|
+
validatorFns[MATCHES_REGEX] = (value, args, form) => {
|
|
30810
30749
|
if (value === "") {
|
|
30811
30750
|
return true;
|
|
30812
30751
|
}
|
|
30813
|
-
|
|
30814
30752
|
return new RegExp(args[0]).test(value); // new RexExp never throws an error, no matter the input
|
|
30815
|
-
};
|
|
30816
|
-
|
|
30817
|
-
|
|
30818
|
-
var IS_ROUTING_NUMBER = "validator/IS_ROUTING_NUMBER";
|
|
30819
|
-
var IS_ROUTING_NUMBER_ERROR = "error/IS_ROUTING_NUMBER";
|
|
30820
|
-
var isRoutingNumber = createValidator(IS_ROUTING_NUMBER, IS_ROUTING_NUMBER_ERROR);
|
|
30753
|
+
};
|
|
30821
30754
|
|
|
30822
|
-
|
|
30755
|
+
// based on http://www.brainjar.com/js/validation/
|
|
30756
|
+
const IS_ROUTING_NUMBER = "validator/IS_ROUTING_NUMBER";
|
|
30757
|
+
const IS_ROUTING_NUMBER_ERROR = "error/IS_ROUTING_NUMBER";
|
|
30758
|
+
const isRoutingNumber = createValidator(
|
|
30759
|
+
IS_ROUTING_NUMBER,
|
|
30760
|
+
IS_ROUTING_NUMBER_ERROR
|
|
30761
|
+
);
|
|
30762
|
+
validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
30823
30763
|
if (value === "") {
|
|
30824
30764
|
return true;
|
|
30825
30765
|
}
|
|
30826
|
-
|
|
30827
30766
|
if (value.length != 9) {
|
|
30828
30767
|
return false;
|
|
30829
30768
|
}
|
|
30830
|
-
|
|
30831
|
-
|
|
30832
|
-
|
|
30833
|
-
|
|
30834
|
-
|
|
30835
|
-
|
|
30836
|
-
|
|
30837
|
-
|
|
30838
|
-
|
|
30839
|
-
|
|
30840
|
-
|
|
30841
|
-
|
|
30842
|
-
|
|
30843
|
-
}
|
|
30844
|
-
}, 0);
|
|
30769
|
+
const sum = value
|
|
30770
|
+
.split("")
|
|
30771
|
+
.map(ch => parseInt(ch))
|
|
30772
|
+
.reduce((acc, cur, idx) => {
|
|
30773
|
+
switch (idx % 3) {
|
|
30774
|
+
case 0:
|
|
30775
|
+
return acc + 3 * cur;
|
|
30776
|
+
case 1:
|
|
30777
|
+
return acc + 7 * cur;
|
|
30778
|
+
case 2:
|
|
30779
|
+
return acc + 1 * cur;
|
|
30780
|
+
}
|
|
30781
|
+
}, 0);
|
|
30845
30782
|
return sum != 0 && sum % 10 == 0;
|
|
30846
30783
|
};
|
|
30847
30784
|
|
|
30848
|
-
|
|
30849
|
-
|
|
30850
|
-
|
|
30851
|
-
|
|
30852
|
-
validatorFns[HAS_NUMBER] = function (value, args, form) {
|
|
30785
|
+
const HAS_NUMBER = "validator/HAS_NUMBER";
|
|
30786
|
+
const HAS_NUMBER_ERROR$1 = "error/HAS_NUMBER";
|
|
30787
|
+
const hasNumber = createValidator(HAS_NUMBER, HAS_NUMBER_ERROR$1);
|
|
30788
|
+
validatorFns[HAS_NUMBER] = (value, args, form) => {
|
|
30853
30789
|
if (value === "") {
|
|
30854
30790
|
return true;
|
|
30855
30791
|
}
|
|
30856
|
-
|
|
30857
30792
|
return new RegExp(/[0-9]/).test(value);
|
|
30858
30793
|
};
|
|
30859
30794
|
|
|
30860
|
-
|
|
30861
|
-
|
|
30862
|
-
|
|
30863
|
-
|
|
30864
|
-
|
|
30795
|
+
const HAS_LOWERCASE_LETTER = "validator/HAS_LOWERCASE_LETTER";
|
|
30796
|
+
const HAS_LOWERCASE_LETTER_ERROR$1 = "error/HAS_LOWERCASE_LETTER";
|
|
30797
|
+
const hasLowercaseLetter = createValidator(
|
|
30798
|
+
HAS_LOWERCASE_LETTER,
|
|
30799
|
+
HAS_LOWERCASE_LETTER_ERROR$1
|
|
30800
|
+
);
|
|
30801
|
+
validatorFns[HAS_LOWERCASE_LETTER] = (value, args, form) => {
|
|
30865
30802
|
if (value === "") {
|
|
30866
30803
|
return true;
|
|
30867
30804
|
}
|
|
30868
|
-
|
|
30869
30805
|
return new RegExp(/[a-z]/).test(value);
|
|
30870
30806
|
};
|
|
30871
30807
|
|
|
30872
|
-
|
|
30873
|
-
|
|
30874
|
-
|
|
30875
|
-
|
|
30876
|
-
|
|
30808
|
+
const HAS_UPPERCASE_LETTER = "validator/HAS_UPPERCASE_LETTER";
|
|
30809
|
+
const HAS_UPPERCASE_LETTER_ERROR$1 = "error/HAS_UPPERCASE_LETTER";
|
|
30810
|
+
const hasUppercaseLetter = createValidator(
|
|
30811
|
+
HAS_UPPERCASE_LETTER,
|
|
30812
|
+
HAS_UPPERCASE_LETTER_ERROR$1
|
|
30813
|
+
);
|
|
30814
|
+
validatorFns[HAS_UPPERCASE_LETTER] = (value, args, form) => {
|
|
30877
30815
|
if (value === "") {
|
|
30878
30816
|
return true;
|
|
30879
30817
|
}
|
|
30880
|
-
|
|
30881
30818
|
return new RegExp(/[A-Z]/).test(value);
|
|
30882
30819
|
};
|
|
30883
30820
|
|
|
30884
|
-
|
|
30885
|
-
|
|
30886
|
-
|
|
30887
|
-
|
|
30888
|
-
|
|
30821
|
+
const HAS_SPECIAL_CHARACTER = "validator/HAS_SPECIAL_CHARACTER";
|
|
30822
|
+
const HAS_SPECIAL_CHARACTER_ERROR$1 = "error/HAS_SPECIAL_CHARACTER";
|
|
30823
|
+
const hasSpecialCharacter = createValidator(
|
|
30824
|
+
HAS_SPECIAL_CHARACTER,
|
|
30825
|
+
HAS_SPECIAL_CHARACTER_ERROR$1
|
|
30826
|
+
);
|
|
30827
|
+
validatorFns[HAS_SPECIAL_CHARACTER] = (value, args, form) => {
|
|
30889
30828
|
if (value === "") {
|
|
30890
30829
|
return true;
|
|
30891
30830
|
}
|
|
30892
|
-
|
|
30893
30831
|
return new RegExp(/[!@#$%^&*.?]/).test(value);
|
|
30894
30832
|
};
|
|
30895
30833
|
|
|
30896
|
-
|
|
30897
|
-
|
|
30898
|
-
|
|
30899
|
-
|
|
30900
|
-
|
|
30834
|
+
const IS_PROBABLY_EMAIL = "validator/IS_PROBABLY_EMAIL";
|
|
30835
|
+
const IS_PROBABLY_EMAIL_ERROR = "error/IS_PROBABLY_EMAIL";
|
|
30836
|
+
const isProbablyEmail = createValidator(
|
|
30837
|
+
IS_PROBABLY_EMAIL,
|
|
30838
|
+
IS_PROBABLY_EMAIL_ERROR
|
|
30839
|
+
);
|
|
30840
|
+
validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
30901
30841
|
if (value === "") {
|
|
30902
30842
|
return true;
|
|
30903
30843
|
}
|
|
30904
|
-
|
|
30905
30844
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
30906
30845
|
};
|
|
30907
30846
|
|
|
30908
|
-
|
|
30909
|
-
|
|
30910
|
-
|
|
30911
|
-
|
|
30912
|
-
|
|
30913
|
-
|
|
30847
|
+
const runValidatorErrorMessage = type =>
|
|
30848
|
+
`${type} was passed to runValidator, but that validator type does not exist.
|
|
30849
|
+
Please check that you are only calling validator creator functions exported from
|
|
30850
|
+
redux-freeform in your form config and that you didn't forget to
|
|
30851
|
+
invoke the validator creator (you cannot pass the functions themselves to
|
|
30852
|
+
createFormState)`;
|
|
30914
30853
|
|
|
30854
|
+
const runValidator = (validator, value, form) => {
|
|
30855
|
+
const validatorFn = validatorFns[validator.type];
|
|
30915
30856
|
if (validatorFn === undefined) {
|
|
30916
30857
|
throw new Error(runValidatorErrorMessage(validator.type));
|
|
30917
30858
|
}
|
|
30918
|
-
|
|
30919
30859
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
30920
30860
|
};
|
|
30921
30861
|
|
|
30922
|
-
|
|
30923
|
-
return validators
|
|
30924
|
-
|
|
30925
|
-
|
|
30926
|
-
return x !== null;
|
|
30927
|
-
});
|
|
30862
|
+
const _computeErrors = (fieldName, form, validators) => {
|
|
30863
|
+
return validators
|
|
30864
|
+
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
30865
|
+
.filter(x => x !== null);
|
|
30928
30866
|
};
|
|
30929
30867
|
|
|
30930
|
-
|
|
30931
|
-
|
|
30868
|
+
const computeConstraints = (fieldName, form) => {
|
|
30869
|
+
const constraints = form[fieldName].constraints;
|
|
30932
30870
|
return _computeErrors(fieldName, form, constraints);
|
|
30933
30871
|
};
|
|
30934
30872
|
|
|
30935
|
-
|
|
30936
|
-
|
|
30873
|
+
const computeErrors = (fieldName, form) => {
|
|
30874
|
+
const validators = form[fieldName].validators;
|
|
30937
30875
|
return _computeErrors(fieldName, form, validators);
|
|
30938
30876
|
};
|
|
30939
30877
|
|
|
30940
30878
|
var obj;
|
|
30941
|
-
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : (obj = {}, obj["immer-nothing"] = true, obj);
|
|
30942
|
-
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol
|
|
30943
|
-
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol
|
|
30944
|
-
|
|
30879
|
+
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : ( obj = {}, obj["immer-nothing"] = true, obj );
|
|
30880
|
+
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
30881
|
+
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-state") : "__$immer_state";
|
|
30945
30882
|
function isDraft(value) {
|
|
30946
30883
|
return !!value && !!value[DRAFT_STATE];
|
|
30947
30884
|
}
|
|
30948
|
-
|
|
30949
30885
|
function isDraftable(value) {
|
|
30950
|
-
if (!value) {
|
|
30951
|
-
return false;
|
|
30952
|
-
}
|
|
30953
|
-
|
|
30886
|
+
if (!value) { return false; }
|
|
30954
30887
|
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
30955
30888
|
}
|
|
30956
|
-
|
|
30957
30889
|
function isPlainObject(value) {
|
|
30958
|
-
if (!value ||
|
|
30959
|
-
|
|
30960
|
-
}
|
|
30961
|
-
|
|
30962
|
-
if (Array.isArray(value)) {
|
|
30963
|
-
return true;
|
|
30964
|
-
}
|
|
30965
|
-
|
|
30890
|
+
if (!value || typeof value !== "object") { return false; }
|
|
30891
|
+
if (Array.isArray(value)) { return true; }
|
|
30966
30892
|
var proto = Object.getPrototypeOf(value);
|
|
30967
30893
|
return !proto || proto === Object.prototype;
|
|
30968
30894
|
}
|
|
30969
|
-
|
|
30970
30895
|
var assign = Object.assign || function assign(target, value) {
|
|
30971
30896
|
for (var key in value) {
|
|
30972
30897
|
if (has(value, key)) {
|
|
@@ -30976,18 +30901,11 @@ var assign = Object.assign || function assign(target, value) {
|
|
|
30976
30901
|
|
|
30977
30902
|
return target;
|
|
30978
30903
|
};
|
|
30979
|
-
|
|
30980
|
-
var ownKeys$1 = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKeys : typeof Object.getOwnPropertySymbols !== "undefined" ? function (obj) {
|
|
30981
|
-
return Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj));
|
|
30982
|
-
} : Object.getOwnPropertyNames;
|
|
30983
|
-
|
|
30904
|
+
var ownKeys$1 = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKeys : typeof Object.getOwnPropertySymbols !== "undefined" ? function (obj) { return Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj)); } : Object.getOwnPropertyNames;
|
|
30984
30905
|
function shallowCopy(base, invokeGetters) {
|
|
30985
|
-
if (invokeGetters === void 0) invokeGetters = false;
|
|
30986
|
-
|
|
30987
|
-
if (Array.isArray(base)) {
|
|
30988
|
-
return base.slice();
|
|
30989
|
-
}
|
|
30906
|
+
if ( invokeGetters === void 0 ) invokeGetters = false;
|
|
30990
30907
|
|
|
30908
|
+
if (Array.isArray(base)) { return base.slice(); }
|
|
30991
30909
|
var clone = Object.create(Object.getPrototypeOf(base));
|
|
30992
30910
|
ownKeys$1(base).forEach(function (key) {
|
|
30993
30911
|
if (key === DRAFT_STATE) {
|
|
@@ -31017,28 +30935,20 @@ function shallowCopy(base, invokeGetters) {
|
|
|
31017
30935
|
});
|
|
31018
30936
|
return clone;
|
|
31019
30937
|
}
|
|
31020
|
-
|
|
31021
30938
|
function each(value, cb) {
|
|
31022
30939
|
if (Array.isArray(value)) {
|
|
31023
|
-
for (var i = 0; i < value.length; i++) {
|
|
31024
|
-
cb(i, value[i], value);
|
|
31025
|
-
}
|
|
30940
|
+
for (var i = 0; i < value.length; i++) { cb(i, value[i], value); }
|
|
31026
30941
|
} else {
|
|
31027
|
-
ownKeys$1(value).forEach(function (key) {
|
|
31028
|
-
return cb(key, value[key], value);
|
|
31029
|
-
});
|
|
30942
|
+
ownKeys$1(value).forEach(function (key) { return cb(key, value[key], value); });
|
|
31030
30943
|
}
|
|
31031
30944
|
}
|
|
31032
|
-
|
|
31033
30945
|
function isEnumerable(base, prop) {
|
|
31034
30946
|
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
31035
30947
|
return !!desc && desc.enumerable;
|
|
31036
30948
|
}
|
|
31037
|
-
|
|
31038
30949
|
function has(thing, prop) {
|
|
31039
30950
|
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
31040
30951
|
}
|
|
31041
|
-
|
|
31042
30952
|
function is(x, y) {
|
|
31043
30953
|
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
31044
30954
|
if (x === y) {
|
|
@@ -31047,26 +30957,17 @@ function is(x, y) {
|
|
|
31047
30957
|
return x !== x && y !== y;
|
|
31048
30958
|
}
|
|
31049
30959
|
}
|
|
31050
|
-
|
|
31051
30960
|
function clone(obj) {
|
|
31052
|
-
if (!isDraftable(obj)) {
|
|
31053
|
-
|
|
31054
|
-
}
|
|
31055
|
-
|
|
31056
|
-
if (Array.isArray(obj)) {
|
|
31057
|
-
return obj.map(clone);
|
|
31058
|
-
}
|
|
31059
|
-
|
|
30961
|
+
if (!isDraftable(obj)) { return obj; }
|
|
30962
|
+
if (Array.isArray(obj)) { return obj.map(clone); }
|
|
31060
30963
|
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
31061
30964
|
|
|
31062
|
-
for (var key in obj) {
|
|
31063
|
-
cloned[key] = clone(obj[key]);
|
|
31064
|
-
}
|
|
30965
|
+
for (var key in obj) { cloned[key] = clone(obj[key]); }
|
|
31065
30966
|
|
|
31066
30967
|
return cloned;
|
|
31067
30968
|
}
|
|
31068
|
-
/** Each scope represents a `produce` call. */
|
|
31069
30969
|
|
|
30970
|
+
/** Each scope represents a `produce` call. */
|
|
31070
30971
|
|
|
31071
30972
|
var ImmerScope = function ImmerScope(parent) {
|
|
31072
30973
|
this.drafts = [];
|
|
@@ -31078,7 +30979,7 @@ var ImmerScope = function ImmerScope(parent) {
|
|
|
31078
30979
|
this.patches = null;
|
|
31079
30980
|
};
|
|
31080
30981
|
|
|
31081
|
-
ImmerScope.prototype.usePatches = function usePatches(patchListener) {
|
|
30982
|
+
ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
31082
30983
|
if (patchListener) {
|
|
31083
30984
|
this.patches = [];
|
|
31084
30985
|
this.inversePatches = [];
|
|
@@ -31086,18 +30987,17 @@ ImmerScope.prototype.usePatches = function usePatches(patchListener) {
|
|
|
31086
30987
|
}
|
|
31087
30988
|
};
|
|
31088
30989
|
|
|
31089
|
-
ImmerScope.prototype.revoke = function revoke$1() {
|
|
30990
|
+
ImmerScope.prototype.revoke = function revoke$1 () {
|
|
31090
30991
|
this.leave();
|
|
31091
30992
|
this.drafts.forEach(revoke);
|
|
31092
30993
|
this.drafts = null; // Make draft-related methods throw.
|
|
31093
30994
|
};
|
|
31094
30995
|
|
|
31095
|
-
ImmerScope.prototype.leave = function leave() {
|
|
30996
|
+
ImmerScope.prototype.leave = function leave () {
|
|
31096
30997
|
if (this === ImmerScope.current) {
|
|
31097
30998
|
ImmerScope.current = this.parent;
|
|
31098
30999
|
}
|
|
31099
31000
|
};
|
|
31100
|
-
|
|
31101
31001
|
ImmerScope.current = null;
|
|
31102
31002
|
|
|
31103
31003
|
ImmerScope.enter = function () {
|
|
@@ -31106,11 +31006,11 @@ ImmerScope.enter = function () {
|
|
|
31106
31006
|
|
|
31107
31007
|
function revoke(draft) {
|
|
31108
31008
|
draft[DRAFT_STATE].revoke();
|
|
31109
|
-
}
|
|
31009
|
+
}
|
|
31110
31010
|
|
|
31011
|
+
// but share them all instead
|
|
31111
31012
|
|
|
31112
31013
|
var descriptors = {};
|
|
31113
|
-
|
|
31114
31014
|
function willFinalize(scope, result, isReplaced) {
|
|
31115
31015
|
scope.drafts.forEach(function (draft) {
|
|
31116
31016
|
draft[DRAFT_STATE].finalizing = true;
|
|
@@ -31128,7 +31028,6 @@ function willFinalize(scope, result, isReplaced) {
|
|
|
31128
31028
|
markChangesSweep(scope.drafts);
|
|
31129
31029
|
}
|
|
31130
31030
|
}
|
|
31131
|
-
|
|
31132
31031
|
function createProxy(base, parent) {
|
|
31133
31032
|
var isArray = Array.isArray(base);
|
|
31134
31033
|
var draft = clonePotentialDraft(base);
|
|
@@ -31182,11 +31081,7 @@ function peek(draft, prop) {
|
|
|
31182
31081
|
function get(state, prop) {
|
|
31183
31082
|
assertUnrevoked(state);
|
|
31184
31083
|
var value = peek(source(state), prop);
|
|
31185
|
-
|
|
31186
|
-
if (state.finalizing) {
|
|
31187
|
-
return value;
|
|
31188
|
-
} // Create a draft if the value is unmodified.
|
|
31189
|
-
|
|
31084
|
+
if (state.finalizing) { return value; } // Create a draft if the value is unmodified.
|
|
31190
31085
|
|
|
31191
31086
|
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
31192
31087
|
prepareCopy(state);
|
|
@@ -31201,10 +31096,7 @@ function set(state, prop, value) {
|
|
|
31201
31096
|
state.assigned[prop] = true;
|
|
31202
31097
|
|
|
31203
31098
|
if (!state.modified) {
|
|
31204
|
-
if (is(value, peek(source(state), prop))) {
|
|
31205
|
-
return;
|
|
31206
|
-
}
|
|
31207
|
-
|
|
31099
|
+
if (is(value, peek(source(state), prop))) { return; }
|
|
31208
31100
|
markChanged(state);
|
|
31209
31101
|
prepareCopy(state);
|
|
31210
31102
|
}
|
|
@@ -31215,17 +31107,12 @@ function set(state, prop, value) {
|
|
|
31215
31107
|
function markChanged(state) {
|
|
31216
31108
|
if (!state.modified) {
|
|
31217
31109
|
state.modified = true;
|
|
31218
|
-
|
|
31219
|
-
if (state.parent) {
|
|
31220
|
-
markChanged(state.parent);
|
|
31221
|
-
}
|
|
31110
|
+
if (state.parent) { markChanged(state.parent); }
|
|
31222
31111
|
}
|
|
31223
31112
|
}
|
|
31224
31113
|
|
|
31225
31114
|
function prepareCopy(state) {
|
|
31226
|
-
if (!state.copy) {
|
|
31227
|
-
state.copy = clonePotentialDraft(state.base);
|
|
31228
|
-
}
|
|
31115
|
+
if (!state.copy) { state.copy = clonePotentialDraft(state.base); }
|
|
31229
31116
|
}
|
|
31230
31117
|
|
|
31231
31118
|
function clonePotentialDraft(base) {
|
|
@@ -31250,12 +31137,15 @@ function proxyProperty(draft, prop, enumerable) {
|
|
|
31250
31137
|
descriptors[prop] = desc = {
|
|
31251
31138
|
configurable: true,
|
|
31252
31139
|
enumerable: enumerable,
|
|
31140
|
+
|
|
31253
31141
|
get: function get$1() {
|
|
31254
31142
|
return get(this[DRAFT_STATE], prop);
|
|
31255
31143
|
},
|
|
31144
|
+
|
|
31256
31145
|
set: function set$1(value) {
|
|
31257
31146
|
set(this[DRAFT_STATE], prop, value);
|
|
31258
31147
|
}
|
|
31148
|
+
|
|
31259
31149
|
};
|
|
31260
31150
|
}
|
|
31261
31151
|
|
|
@@ -31263,9 +31153,7 @@ function proxyProperty(draft, prop, enumerable) {
|
|
|
31263
31153
|
}
|
|
31264
31154
|
|
|
31265
31155
|
function assertUnrevoked(state) {
|
|
31266
|
-
if (state.revoked === true) {
|
|
31267
|
-
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)));
|
|
31268
|
-
}
|
|
31156
|
+
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))); }
|
|
31269
31157
|
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
31270
31158
|
|
|
31271
31159
|
|
|
@@ -31279,27 +31167,16 @@ function markChangesSweep(drafts) {
|
|
|
31279
31167
|
|
|
31280
31168
|
if (!state.modified) {
|
|
31281
31169
|
if (Array.isArray(state.base)) {
|
|
31282
|
-
if (hasArrayChanges(state)) {
|
|
31283
|
-
|
|
31284
|
-
}
|
|
31285
|
-
} else if (hasObjectChanges(state)) {
|
|
31286
|
-
markChanged(state);
|
|
31287
|
-
}
|
|
31170
|
+
if (hasArrayChanges(state)) { markChanged(state); }
|
|
31171
|
+
} else if (hasObjectChanges(state)) { markChanged(state); }
|
|
31288
31172
|
}
|
|
31289
31173
|
}
|
|
31290
31174
|
}
|
|
31291
31175
|
|
|
31292
31176
|
function markChangesRecursively(object) {
|
|
31293
|
-
if (!object ||
|
|
31294
|
-
return;
|
|
31295
|
-
}
|
|
31296
|
-
|
|
31177
|
+
if (!object || typeof object !== "object") { return; }
|
|
31297
31178
|
var state = object[DRAFT_STATE];
|
|
31298
|
-
|
|
31299
|
-
if (!state) {
|
|
31300
|
-
return;
|
|
31301
|
-
}
|
|
31302
|
-
|
|
31179
|
+
if (!state) { return; }
|
|
31303
31180
|
var base = state.base;
|
|
31304
31181
|
var draft = state.draft;
|
|
31305
31182
|
var assigned = state.assigned;
|
|
@@ -31329,20 +31206,14 @@ function markChangesRecursively(object) {
|
|
|
31329
31206
|
assigned.length = true;
|
|
31330
31207
|
|
|
31331
31208
|
if (draft.length < base.length) {
|
|
31332
|
-
for (var i = draft.length; i < base.length; i++) {
|
|
31333
|
-
assigned[i] = false;
|
|
31334
|
-
}
|
|
31209
|
+
for (var i = draft.length; i < base.length; i++) { assigned[i] = false; }
|
|
31335
31210
|
} else {
|
|
31336
|
-
for (var i$1 = base.length; i$1 < draft.length; i$1++) {
|
|
31337
|
-
assigned[i$1] = true;
|
|
31338
|
-
}
|
|
31211
|
+
for (var i$1 = base.length; i$1 < draft.length; i$1++) { assigned[i$1] = true; }
|
|
31339
31212
|
}
|
|
31340
31213
|
|
|
31341
31214
|
for (var i$2 = 0; i$2 < draft.length; i$2++) {
|
|
31342
31215
|
// Only untouched indices trigger recursion.
|
|
31343
|
-
if (assigned[i$2] === undefined) {
|
|
31344
|
-
markChangesRecursively(draft[i$2]);
|
|
31345
|
-
}
|
|
31216
|
+
if (assigned[i$2] === undefined) { markChangesRecursively(draft[i$2]); }
|
|
31346
31217
|
}
|
|
31347
31218
|
}
|
|
31348
31219
|
}
|
|
@@ -31379,10 +31250,7 @@ function hasObjectChanges(state) {
|
|
|
31379
31250
|
|
|
31380
31251
|
function hasArrayChanges(state) {
|
|
31381
31252
|
var draft = state.draft;
|
|
31382
|
-
|
|
31383
|
-
if (draft.length !== state.base.length) {
|
|
31384
|
-
return true;
|
|
31385
|
-
} // See #116
|
|
31253
|
+
if (draft.length !== state.base.length) { return true; } // See #116
|
|
31386
31254
|
// If we first shorten the length, our array interceptors will be removed.
|
|
31387
31255
|
// If after that new items are added, result in the same original length,
|
|
31388
31256
|
// those last items will have no intercepting property.
|
|
@@ -31390,13 +31258,9 @@ function hasArrayChanges(state) {
|
|
|
31390
31258
|
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
31391
31259
|
// the last one
|
|
31392
31260
|
|
|
31393
|
-
|
|
31394
31261
|
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
31395
31262
|
|
|
31396
|
-
if (descriptor && !descriptor.get) {
|
|
31397
|
-
return true;
|
|
31398
|
-
} // For all other cases, we don't have to compare, as they would have been picked up by the index setters
|
|
31399
|
-
|
|
31263
|
+
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
|
|
31400
31264
|
|
|
31401
31265
|
return false;
|
|
31402
31266
|
}
|
|
@@ -31410,12 +31274,11 @@ function createHiddenProperty(target, prop, value) {
|
|
|
31410
31274
|
}
|
|
31411
31275
|
|
|
31412
31276
|
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
31413
|
-
|
|
31414
|
-
|
|
31277
|
+
willFinalize: willFinalize,
|
|
31278
|
+
createProxy: createProxy
|
|
31415
31279
|
});
|
|
31416
31280
|
|
|
31417
31281
|
function willFinalize$1() {}
|
|
31418
|
-
|
|
31419
31282
|
function createProxy$1(base, parent) {
|
|
31420
31283
|
var scope = parent ? parent.scope : ImmerScope.current;
|
|
31421
31284
|
var state = {
|
|
@@ -31450,27 +31313,33 @@ function createProxy$1(base, parent) {
|
|
|
31450
31313
|
scope.drafts.push(proxy);
|
|
31451
31314
|
return proxy;
|
|
31452
31315
|
}
|
|
31453
|
-
|
|
31454
31316
|
var objectTraps = {
|
|
31455
31317
|
get: get$1,
|
|
31318
|
+
|
|
31456
31319
|
has: function has(target, prop) {
|
|
31457
31320
|
return prop in source$1(target);
|
|
31458
31321
|
},
|
|
31322
|
+
|
|
31459
31323
|
ownKeys: function ownKeys(target) {
|
|
31460
31324
|
return Reflect.ownKeys(source$1(target));
|
|
31461
31325
|
},
|
|
31326
|
+
|
|
31462
31327
|
set: set$1,
|
|
31463
31328
|
deleteProperty: deleteProperty,
|
|
31464
31329
|
getOwnPropertyDescriptor: getOwnPropertyDescriptor,
|
|
31330
|
+
|
|
31465
31331
|
defineProperty: function defineProperty() {
|
|
31466
31332
|
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
31467
31333
|
},
|
|
31334
|
+
|
|
31468
31335
|
getPrototypeOf: function getPrototypeOf(target) {
|
|
31469
31336
|
return Object.getPrototypeOf(target.base);
|
|
31470
31337
|
},
|
|
31338
|
+
|
|
31471
31339
|
setPrototypeOf: function setPrototypeOf() {
|
|
31472
31340
|
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
31473
31341
|
}
|
|
31342
|
+
|
|
31474
31343
|
};
|
|
31475
31344
|
var arrayTraps = {};
|
|
31476
31345
|
each(objectTraps, function (key, fn) {
|
|
@@ -31509,10 +31378,7 @@ function peek$1(draft, prop) {
|
|
|
31509
31378
|
}
|
|
31510
31379
|
|
|
31511
31380
|
function get$1(state, prop) {
|
|
31512
|
-
if (prop === DRAFT_STATE) {
|
|
31513
|
-
return state;
|
|
31514
|
-
}
|
|
31515
|
-
|
|
31381
|
+
if (prop === DRAFT_STATE) { return state; }
|
|
31516
31382
|
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
31517
31383
|
|
|
31518
31384
|
if (!state.modified && has(drafts, prop)) {
|
|
@@ -31528,10 +31394,7 @@ function get$1(state, prop) {
|
|
|
31528
31394
|
|
|
31529
31395
|
if (state.modified) {
|
|
31530
31396
|
// Assigned values are never drafted. This catches any drafts we created, too.
|
|
31531
|
-
if (value !== peek$1(state.base, prop)) {
|
|
31532
|
-
return value;
|
|
31533
|
-
} // Store drafts on the copy (when one exists).
|
|
31534
|
-
|
|
31397
|
+
if (value !== peek$1(state.base, prop)) { return value; } // Store drafts on the copy (when one exists).
|
|
31535
31398
|
|
|
31536
31399
|
drafts = state.copy;
|
|
31537
31400
|
}
|
|
@@ -31546,11 +31409,7 @@ function set$1(state, prop, value) {
|
|
|
31546
31409
|
// values may be drafts, but falsy values are never drafts.
|
|
31547
31410
|
|
|
31548
31411
|
var isUnchanged = value ? is(baseValue, value) || value === state.drafts[prop] : is(baseValue, value) && prop in state.base;
|
|
31549
|
-
|
|
31550
|
-
if (isUnchanged) {
|
|
31551
|
-
return true;
|
|
31552
|
-
}
|
|
31553
|
-
|
|
31412
|
+
if (isUnchanged) { return true; }
|
|
31554
31413
|
markChanged$1(state);
|
|
31555
31414
|
}
|
|
31556
31415
|
|
|
@@ -31569,10 +31428,7 @@ function deleteProperty(state, prop) {
|
|
|
31569
31428
|
delete state.assigned[prop];
|
|
31570
31429
|
}
|
|
31571
31430
|
|
|
31572
|
-
if (state.copy) {
|
|
31573
|
-
delete state.copy[prop];
|
|
31574
|
-
}
|
|
31575
|
-
|
|
31431
|
+
if (state.copy) { delete state.copy[prop]; }
|
|
31576
31432
|
return true;
|
|
31577
31433
|
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
31578
31434
|
// the same guarantee in ES5 mode.
|
|
@@ -31595,16 +31451,13 @@ function markChanged$1(state) {
|
|
|
31595
31451
|
state.modified = true;
|
|
31596
31452
|
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
31597
31453
|
state.drafts = null;
|
|
31598
|
-
|
|
31599
|
-
if (state.parent) {
|
|
31600
|
-
markChanged$1(state.parent);
|
|
31601
|
-
}
|
|
31454
|
+
if (state.parent) { markChanged$1(state.parent); }
|
|
31602
31455
|
}
|
|
31603
31456
|
}
|
|
31604
31457
|
|
|
31605
31458
|
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
31606
|
-
|
|
31607
|
-
|
|
31459
|
+
willFinalize: willFinalize$1,
|
|
31460
|
+
createProxy: createProxy$1
|
|
31608
31461
|
});
|
|
31609
31462
|
|
|
31610
31463
|
function generatePatches(state, basePath, patches, inversePatches) {
|
|
@@ -31613,13 +31466,14 @@ function generatePatches(state, basePath, patches, inversePatches) {
|
|
|
31613
31466
|
|
|
31614
31467
|
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
31615
31468
|
var assign, assign$1;
|
|
31469
|
+
|
|
31616
31470
|
var base = state.base;
|
|
31617
31471
|
var copy = state.copy;
|
|
31618
31472
|
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
31619
31473
|
|
|
31620
31474
|
if (copy.length < base.length) {
|
|
31621
|
-
assign = [copy, base], base = assign[0], copy = assign[1];
|
|
31622
|
-
assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1];
|
|
31475
|
+
(assign = [copy, base], base = assign[0], copy = assign[1]);
|
|
31476
|
+
(assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1]);
|
|
31623
31477
|
}
|
|
31624
31478
|
|
|
31625
31479
|
var delta = copy.length - base.length; // Find the first replaced index.
|
|
@@ -31677,11 +31531,7 @@ function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
|
31677
31531
|
var origValue = base[key];
|
|
31678
31532
|
var value = copy[key];
|
|
31679
31533
|
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
31680
|
-
|
|
31681
|
-
if (origValue === value && op === "replace") {
|
|
31682
|
-
return;
|
|
31683
|
-
}
|
|
31684
|
-
|
|
31534
|
+
if (origValue === value && op === "replace") { return; }
|
|
31685
31535
|
var path = basePath.concat(key);
|
|
31686
31536
|
patches.push(op === "remove" ? {
|
|
31687
31537
|
op: op,
|
|
@@ -31706,26 +31556,20 @@ function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
|
31706
31556
|
});
|
|
31707
31557
|
}
|
|
31708
31558
|
|
|
31709
|
-
var applyPatches = function
|
|
31559
|
+
var applyPatches = function (draft, patches) {
|
|
31710
31560
|
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
31711
31561
|
var patch = list[i$1];
|
|
31562
|
+
|
|
31712
31563
|
var path = patch.path;
|
|
31713
31564
|
var op = patch.op;
|
|
31714
31565
|
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
31715
31566
|
|
|
31716
|
-
if (!path.length) {
|
|
31717
|
-
throw new Error("Illegal state");
|
|
31718
|
-
}
|
|
31719
|
-
|
|
31567
|
+
if (!path.length) { throw new Error("Illegal state"); }
|
|
31720
31568
|
var base = draft;
|
|
31721
31569
|
|
|
31722
31570
|
for (var i = 0; i < path.length - 1; i++) {
|
|
31723
31571
|
base = base[path[i]];
|
|
31724
|
-
|
|
31725
|
-
if (!base || _typeof(base) !== "object") {
|
|
31726
|
-
throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/"));
|
|
31727
|
-
} // prettier-ignore
|
|
31728
|
-
|
|
31572
|
+
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
31729
31573
|
}
|
|
31730
31574
|
|
|
31731
31575
|
var key = path[path.length - 1];
|
|
@@ -31774,33 +31618,27 @@ var configDefaults = {
|
|
|
31774
31618
|
onDelete: null,
|
|
31775
31619
|
onCopy: null
|
|
31776
31620
|
};
|
|
31777
|
-
|
|
31778
31621
|
var Immer = function Immer(config) {
|
|
31779
31622
|
assign(this, configDefaults, config);
|
|
31780
31623
|
this.setUseProxies(this.useProxies);
|
|
31781
31624
|
this.produce = this.produce.bind(this);
|
|
31782
31625
|
};
|
|
31783
31626
|
|
|
31784
|
-
Immer.prototype.produce = function produce(base, recipe, patchListener) {
|
|
31785
|
-
|
|
31627
|
+
Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
31628
|
+
var this$1 = this;
|
|
31786
31629
|
|
|
31630
|
+
// curried invocation
|
|
31787
31631
|
if (typeof base === "function" && typeof recipe !== "function") {
|
|
31788
31632
|
var defaultBase = recipe;
|
|
31789
31633
|
recipe = base;
|
|
31790
31634
|
var self = this;
|
|
31791
31635
|
return function curriedProduce(base) {
|
|
31792
|
-
|
|
31793
|
-
|
|
31794
|
-
|
|
31795
|
-
|
|
31796
|
-
|
|
31797
|
-
while (len-- > 0) {
|
|
31798
|
-
args[len] = arguments[len + 1];
|
|
31799
|
-
}
|
|
31636
|
+
var this$1 = this;
|
|
31637
|
+
if ( base === void 0 ) base = defaultBase;
|
|
31638
|
+
var args = [], len = arguments.length - 1;
|
|
31639
|
+
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
31800
31640
|
|
|
31801
|
-
return self.produce(base, function (draft) {
|
|
31802
|
-
return recipe.call.apply(recipe, [this$1, draft].concat(args));
|
|
31803
|
-
}); // prettier-ignore
|
|
31641
|
+
return self.produce(base, function (draft) { return recipe.call.apply(recipe, [ this$1, draft ].concat( args )); }); // prettier-ignore
|
|
31804
31642
|
};
|
|
31805
31643
|
} // prettier-ignore
|
|
31806
31644
|
|
|
@@ -31826,11 +31664,7 @@ Immer.prototype.produce = function produce(base, recipe, patchListener) {
|
|
|
31826
31664
|
hasError = false;
|
|
31827
31665
|
} finally {
|
|
31828
31666
|
// finally instead of catch + rethrow better preserves original stack
|
|
31829
|
-
if (hasError) {
|
|
31830
|
-
scope.revoke();
|
|
31831
|
-
} else {
|
|
31832
|
-
scope.leave();
|
|
31833
|
-
}
|
|
31667
|
+
if (hasError) { scope.revoke(); }else { scope.leave(); }
|
|
31834
31668
|
}
|
|
31835
31669
|
|
|
31836
31670
|
if (result instanceof Promise) {
|
|
@@ -31847,38 +31681,25 @@ Immer.prototype.produce = function produce(base, recipe, patchListener) {
|
|
|
31847
31681
|
return this.processResult(result, scope);
|
|
31848
31682
|
} else {
|
|
31849
31683
|
result = recipe(base);
|
|
31850
|
-
|
|
31851
|
-
if (result === undefined) {
|
|
31852
|
-
return base;
|
|
31853
|
-
}
|
|
31854
|
-
|
|
31684
|
+
if (result === undefined) { return base; }
|
|
31855
31685
|
return result !== NOTHING ? result : undefined;
|
|
31856
31686
|
}
|
|
31857
31687
|
};
|
|
31858
31688
|
|
|
31859
|
-
Immer.prototype.produceWithPatches = function produceWithPatches(arg1, arg2, arg3) {
|
|
31860
|
-
|
|
31689
|
+
Immer.prototype.produceWithPatches = function produceWithPatches (arg1, arg2, arg3) {
|
|
31690
|
+
var this$1 = this;
|
|
31861
31691
|
|
|
31862
31692
|
if (typeof arg1 === "function") {
|
|
31863
31693
|
return function (state) {
|
|
31864
|
-
|
|
31865
|
-
|
|
31694
|
+
var args = [], len = arguments.length - 1;
|
|
31695
|
+
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
31866
31696
|
|
|
31867
|
-
|
|
31868
|
-
|
|
31869
|
-
}
|
|
31870
|
-
|
|
31871
|
-
return this$1.produceWithPatches(state, function (draft) {
|
|
31872
|
-
return arg1.apply(void 0, [draft].concat(args));
|
|
31873
|
-
});
|
|
31874
|
-
};
|
|
31697
|
+
return this$1.produceWithPatches(state, function (draft) { return arg1.apply(void 0, [ draft ].concat( args )); });
|
|
31698
|
+
};
|
|
31875
31699
|
} // non-curried form
|
|
31876
31700
|
|
|
31877
31701
|
|
|
31878
|
-
if (arg3) {
|
|
31879
|
-
throw new Error("A patch listener cannot be passed to produceWithPatches");
|
|
31880
|
-
}
|
|
31881
|
-
|
|
31702
|
+
if (arg3) { throw new Error("A patch listener cannot be passed to produceWithPatches"); }
|
|
31882
31703
|
var patches, inversePatches;
|
|
31883
31704
|
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
31884
31705
|
patches = p;
|
|
@@ -31887,7 +31708,7 @@ Immer.prototype.produceWithPatches = function produceWithPatches(arg1, arg2, arg
|
|
|
31887
31708
|
return [nextState, patches, inversePatches];
|
|
31888
31709
|
};
|
|
31889
31710
|
|
|
31890
|
-
Immer.prototype.createDraft = function createDraft(base) {
|
|
31711
|
+
Immer.prototype.createDraft = function createDraft (base) {
|
|
31891
31712
|
if (!isDraftable(base)) {
|
|
31892
31713
|
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
31893
31714
|
}
|
|
@@ -31899,7 +31720,7 @@ Immer.prototype.createDraft = function createDraft(base) {
|
|
|
31899
31720
|
return proxy;
|
|
31900
31721
|
};
|
|
31901
31722
|
|
|
31902
|
-
Immer.prototype.finishDraft = function finishDraft(draft, patchListener) {
|
|
31723
|
+
Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
31903
31724
|
var state = draft && draft[DRAFT_STATE];
|
|
31904
31725
|
|
|
31905
31726
|
if (!state || !state.isManual) {
|
|
@@ -31915,16 +31736,16 @@ Immer.prototype.finishDraft = function finishDraft(draft, patchListener) {
|
|
|
31915
31736
|
return this.processResult(undefined, scope);
|
|
31916
31737
|
};
|
|
31917
31738
|
|
|
31918
|
-
Immer.prototype.setAutoFreeze = function setAutoFreeze(value) {
|
|
31739
|
+
Immer.prototype.setAutoFreeze = function setAutoFreeze (value) {
|
|
31919
31740
|
this.autoFreeze = value;
|
|
31920
31741
|
};
|
|
31921
31742
|
|
|
31922
|
-
Immer.prototype.setUseProxies = function setUseProxies(value) {
|
|
31743
|
+
Immer.prototype.setUseProxies = function setUseProxies (value) {
|
|
31923
31744
|
this.useProxies = value;
|
|
31924
31745
|
assign(this, value ? modernProxy : legacyProxy);
|
|
31925
31746
|
};
|
|
31926
31747
|
|
|
31927
|
-
Immer.prototype.applyPatches = function applyPatches$1(base, patches) {
|
|
31748
|
+
Immer.prototype.applyPatches = function applyPatches$1 (base, patches) {
|
|
31928
31749
|
// If a patch replaces the entire state, take that replacement as base
|
|
31929
31750
|
// before applying patches
|
|
31930
31751
|
var i;
|
|
@@ -31944,14 +31765,12 @@ Immer.prototype.applyPatches = function applyPatches$1(base, patches) {
|
|
|
31944
31765
|
} // Otherwise, produce a copy of the base state.
|
|
31945
31766
|
|
|
31946
31767
|
|
|
31947
|
-
return this.produce(base, function (draft) {
|
|
31948
|
-
return applyPatches(draft, patches.slice(i + 1));
|
|
31949
|
-
});
|
|
31768
|
+
return this.produce(base, function (draft) { return applyPatches(draft, patches.slice(i + 1)); });
|
|
31950
31769
|
};
|
|
31951
31770
|
/** @internal */
|
|
31952
31771
|
|
|
31953
31772
|
|
|
31954
|
-
Immer.prototype.processResult = function processResult(result, scope) {
|
|
31773
|
+
Immer.prototype.processResult = function processResult (result, scope) {
|
|
31955
31774
|
var baseDraft = scope.drafts[0];
|
|
31956
31775
|
var isReplaced = result !== undefined && result !== baseDraft;
|
|
31957
31776
|
this.willFinalize(scope, result, isReplaced);
|
|
@@ -31999,15 +31818,13 @@ Immer.prototype.processResult = function processResult(result, scope) {
|
|
|
31999
31818
|
*/
|
|
32000
31819
|
|
|
32001
31820
|
|
|
32002
|
-
Immer.prototype.finalize = function finalize(draft, path, scope) {
|
|
32003
|
-
|
|
31821
|
+
Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
31822
|
+
var this$1 = this;
|
|
31823
|
+
|
|
32004
31824
|
var state = draft[DRAFT_STATE];
|
|
32005
31825
|
|
|
32006
31826
|
if (!state) {
|
|
32007
|
-
if (Object.isFrozen(draft)) {
|
|
32008
|
-
return draft;
|
|
32009
|
-
}
|
|
32010
|
-
|
|
31827
|
+
if (Object.isFrozen(draft)) { return draft; }
|
|
32011
31828
|
return this.finalizeTree(draft, null, scope);
|
|
32012
31829
|
} // Never finalize drafts owned by another scope.
|
|
32013
31830
|
|
|
@@ -32030,17 +31847,13 @@ Immer.prototype.finalize = function finalize(draft, path, scope) {
|
|
|
32030
31847
|
var assigned = state.assigned;
|
|
32031
31848
|
|
|
32032
31849
|
for (var prop in assigned) {
|
|
32033
|
-
if (!assigned[prop]) {
|
|
32034
|
-
this.onDelete(state, prop);
|
|
32035
|
-
}
|
|
31850
|
+
if (!assigned[prop]) { this.onDelete(state, prop); }
|
|
32036
31851
|
}
|
|
32037
31852
|
} else {
|
|
32038
31853
|
var base = state.base;
|
|
32039
|
-
|
|
31854
|
+
var copy = state.copy;
|
|
32040
31855
|
each(base, function (prop) {
|
|
32041
|
-
if (!has(copy, prop)) {
|
|
32042
|
-
this$1.onDelete(state, prop);
|
|
32043
|
-
}
|
|
31856
|
+
if (!has(copy, prop)) { this$1.onDelete(state, prop); }
|
|
32044
31857
|
});
|
|
32045
31858
|
}
|
|
32046
31859
|
}
|
|
@@ -32068,8 +31881,9 @@ Immer.prototype.finalize = function finalize(draft, path, scope) {
|
|
|
32068
31881
|
*/
|
|
32069
31882
|
|
|
32070
31883
|
|
|
32071
|
-
Immer.prototype.finalizeTree = function finalizeTree(root, rootPath, scope) {
|
|
32072
|
-
|
|
31884
|
+
Immer.prototype.finalizeTree = function finalizeTree (root, rootPath, scope) {
|
|
31885
|
+
var this$1 = this;
|
|
31886
|
+
|
|
32073
31887
|
var state = root[DRAFT_STATE];
|
|
32074
31888
|
|
|
32075
31889
|
if (state) {
|
|
@@ -32083,7 +31897,7 @@ Immer.prototype.finalizeTree = function finalizeTree(root, rootPath, scope) {
|
|
|
32083
31897
|
|
|
32084
31898
|
var needPatches = !!rootPath && !!scope.patches;
|
|
32085
31899
|
|
|
32086
|
-
var finalizeProperty = function
|
|
31900
|
+
var finalizeProperty = function (prop, value, parent) {
|
|
32087
31901
|
if (value === parent) {
|
|
32088
31902
|
throw Error("Immer forbids circular references");
|
|
32089
31903
|
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
@@ -32110,9 +31924,7 @@ Immer.prototype.finalizeTree = function finalizeTree(root, rootPath, scope) {
|
|
|
32110
31924
|
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
32111
31925
|
|
|
32112
31926
|
|
|
32113
|
-
if (isDraftProp && value === state.base[prop]) {
|
|
32114
|
-
return;
|
|
32115
|
-
}
|
|
31927
|
+
if (isDraftProp && value === state.base[prop]) { return; }
|
|
32116
31928
|
} // Unchanged draft properties are ignored.
|
|
32117
31929
|
else if (isDraftProp && is(value, state.base[prop])) {
|
|
32118
31930
|
return;
|
|
@@ -32197,149 +32009,103 @@ var createDraft = immer.createDraft.bind(immer);
|
|
|
32197
32009
|
|
|
32198
32010
|
var finishDraft = immer.finishDraft.bind(immer);
|
|
32199
32011
|
|
|
32200
|
-
|
|
32201
|
-
|
|
32202
|
-
|
|
32203
|
-
|
|
32204
|
-
for (var _i = 0, _formConfigKeys = formConfigKeys; _i < _formConfigKeys.length; _i++) {
|
|
32205
|
-
var formKey = _formConfigKeys[_i];
|
|
32012
|
+
const createInitialState = formConfig => {
|
|
32013
|
+
let initialForm = {};
|
|
32014
|
+
const formConfigKeys = Object.keys(formConfig);
|
|
32015
|
+
for (let formKey of formConfigKeys) {
|
|
32206
32016
|
initialForm[formKey] = {
|
|
32207
32017
|
dirty: false,
|
|
32208
32018
|
rawValue: formConfig[formKey].defaultValue || "",
|
|
32209
32019
|
validators: formConfig[formKey].validators || [],
|
|
32210
32020
|
constraints: formConfig[formKey].constraints || []
|
|
32211
32021
|
};
|
|
32212
|
-
}
|
|
32022
|
+
}
|
|
32023
|
+
// Because validators require the entire form we have to do a
|
|
32213
32024
|
// second pass to add errors once the initial form has been
|
|
32214
32025
|
// constructed
|
|
32215
|
-
|
|
32216
|
-
|
|
32217
|
-
|
|
32218
|
-
|
|
32219
|
-
var errors = computeErrors(_formKey, initialForm);
|
|
32220
|
-
initialForm[_formKey].errors = errors;
|
|
32221
|
-
initialForm[_formKey].hasErrors = errors.length > 0;
|
|
32026
|
+
for (let formKey of formConfigKeys) {
|
|
32027
|
+
let errors = computeErrors(formKey, initialForm);
|
|
32028
|
+
initialForm[formKey].errors = errors;
|
|
32029
|
+
initialForm[formKey].hasErrors = errors.length > 0;
|
|
32222
32030
|
}
|
|
32223
|
-
|
|
32224
32031
|
return initialForm;
|
|
32225
32032
|
};
|
|
32226
32033
|
|
|
32227
|
-
|
|
32228
|
-
|
|
32229
|
-
|
|
32230
|
-
|
|
32231
|
-
|
|
32232
|
-
type: SET,
|
|
32233
|
-
payload: {
|
|
32234
|
-
fieldName: fieldName,
|
|
32235
|
-
value: value
|
|
32236
|
-
}
|
|
32237
|
-
};
|
|
32238
|
-
};
|
|
32239
|
-
};
|
|
32240
|
-
|
|
32241
|
-
var CLEAR = "form/CLEAR";
|
|
32242
|
-
|
|
32243
|
-
var _clear = function clear() {
|
|
32244
|
-
return {
|
|
32245
|
-
type: CLEAR
|
|
32246
|
-
};
|
|
32247
|
-
};
|
|
32248
|
-
|
|
32249
|
-
var createFormReducer = function createFormReducer(formConfig) {
|
|
32250
|
-
return function () {
|
|
32251
|
-
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : createInitialState(formConfig);
|
|
32252
|
-
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
32253
|
-
|
|
32254
|
-
switch (action.type) {
|
|
32255
|
-
case SET:
|
|
32256
|
-
var changedFieldName = action.payload.fieldName;
|
|
32257
|
-
var newRawValue = action.payload.value;
|
|
32258
|
-
return produce(state, function (draftState) {
|
|
32259
|
-
var originalValue = draftState[changedFieldName].rawValue;
|
|
32260
|
-
draftState[changedFieldName].rawValue = newRawValue;
|
|
32261
|
-
|
|
32262
|
-
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
32263
|
-
// If the change violates constraints, revert the change
|
|
32264
|
-
draftState[changedFieldName].rawValue = originalValue;
|
|
32265
|
-
return draftState;
|
|
32266
|
-
}
|
|
32267
|
-
|
|
32268
|
-
var fields = Object.entries(draftState);
|
|
32269
|
-
|
|
32270
|
-
for (var _i3 = 0, _fields = fields; _i3 < _fields.length; _i3++) {
|
|
32271
|
-
var entry = _fields[_i3];
|
|
32272
|
-
var fieldName = entry[0];
|
|
32273
|
-
var field = entry[1];
|
|
32274
|
-
var errors = computeErrors(fieldName, draftState);
|
|
32275
|
-
var dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
32276
|
-
draftState[fieldName].errors = errors;
|
|
32277
|
-
draftState[fieldName].dirty = dirty;
|
|
32278
|
-
draftState[fieldName].hasErrors = errors.length > 0;
|
|
32279
|
-
}
|
|
32280
|
-
});
|
|
32034
|
+
const SET = "field/SET";
|
|
32035
|
+
const set$2 = fieldName => value => ({
|
|
32036
|
+
type: SET,
|
|
32037
|
+
payload: { fieldName, value }
|
|
32038
|
+
});
|
|
32281
32039
|
|
|
32282
|
-
|
|
32283
|
-
|
|
32040
|
+
const CLEAR = "form/CLEAR";
|
|
32041
|
+
const clear = () => ({ type: CLEAR });
|
|
32042
|
+
|
|
32043
|
+
const createFormReducer = formConfig => (
|
|
32044
|
+
state = createInitialState(formConfig),
|
|
32045
|
+
action
|
|
32046
|
+
) => {
|
|
32047
|
+
switch (action.type) {
|
|
32048
|
+
case SET:
|
|
32049
|
+
const changedFieldName = action.payload.fieldName;
|
|
32050
|
+
const newRawValue = action.payload.value;
|
|
32051
|
+
|
|
32052
|
+
return produce(state, draftState => {
|
|
32053
|
+
let originalValue = draftState[changedFieldName].rawValue;
|
|
32054
|
+
draftState[changedFieldName].rawValue = newRawValue;
|
|
32055
|
+
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
32056
|
+
// If the change violates constraints, revert the change
|
|
32057
|
+
draftState[changedFieldName].rawValue = originalValue;
|
|
32058
|
+
return draftState;
|
|
32059
|
+
}
|
|
32284
32060
|
|
|
32285
|
-
|
|
32286
|
-
|
|
32287
|
-
|
|
32288
|
-
|
|
32061
|
+
const fields = Object.entries(draftState);
|
|
32062
|
+
for (let entry of fields) {
|
|
32063
|
+
let fieldName = entry[0];
|
|
32064
|
+
let field = entry[1];
|
|
32065
|
+
let errors = computeErrors(fieldName, draftState);
|
|
32066
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
32067
|
+
draftState[fieldName].errors = errors;
|
|
32068
|
+
draftState[fieldName].dirty = dirty;
|
|
32069
|
+
draftState[fieldName].hasErrors = errors.length > 0;
|
|
32070
|
+
}
|
|
32071
|
+
});
|
|
32072
|
+
case CLEAR:
|
|
32073
|
+
return createInitialState(formConfig);
|
|
32074
|
+
default:
|
|
32075
|
+
return state;
|
|
32076
|
+
}
|
|
32289
32077
|
};
|
|
32290
32078
|
|
|
32291
|
-
|
|
32079
|
+
const createMapDispatchToProps = formConfig => {
|
|
32292
32080
|
// Do memo-ization
|
|
32293
|
-
|
|
32294
|
-
|
|
32295
|
-
return
|
|
32081
|
+
let cachedDispatch;
|
|
32082
|
+
let cacheValue;
|
|
32083
|
+
return dispatch => {
|
|
32296
32084
|
if (dispatch == cachedDispatch) {
|
|
32297
32085
|
return cacheValue;
|
|
32298
32086
|
}
|
|
32299
|
-
|
|
32300
|
-
var dispatchObj = {};
|
|
32087
|
+
let dispatchObj = {};
|
|
32301
32088
|
dispatchObj.fields = {};
|
|
32302
|
-
|
|
32303
|
-
|
|
32304
|
-
var _loop = function _loop() {
|
|
32305
|
-
var fieldName = _keys[_i4];
|
|
32089
|
+
const keys = Object.keys(formConfig);
|
|
32090
|
+
for (let fieldName of keys) {
|
|
32306
32091
|
dispatchObj.fields[fieldName] = {
|
|
32307
|
-
set:
|
|
32308
|
-
return dispatch(set$2(fieldName)(value));
|
|
32309
|
-
}
|
|
32092
|
+
set: value => dispatch(set$2(fieldName)(value))
|
|
32310
32093
|
};
|
|
32311
|
-
};
|
|
32312
|
-
|
|
32313
|
-
for (var _i4 = 0, _keys = keys; _i4 < _keys.length; _i4++) {
|
|
32314
|
-
_loop();
|
|
32315
32094
|
}
|
|
32316
|
-
|
|
32317
|
-
dispatchObj.form = {
|
|
32318
|
-
clear: function clear() {
|
|
32319
|
-
return dispatch(_clear());
|
|
32320
|
-
}
|
|
32321
|
-
};
|
|
32095
|
+
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
32322
32096
|
cachedDispatch = dispatch;
|
|
32323
|
-
cacheValue = {
|
|
32324
|
-
actions: dispatchObj
|
|
32325
|
-
};
|
|
32097
|
+
cacheValue = { actions: dispatchObj };
|
|
32326
32098
|
return cacheValue;
|
|
32327
32099
|
};
|
|
32328
32100
|
};
|
|
32329
32101
|
|
|
32330
|
-
|
|
32331
|
-
return {
|
|
32332
|
-
fields: state
|
|
32333
|
-
};
|
|
32334
|
-
};
|
|
32102
|
+
const mapStateToProps = state => ({ fields: state });
|
|
32335
32103
|
|
|
32336
|
-
|
|
32337
|
-
|
|
32338
|
-
|
|
32339
|
-
|
|
32340
|
-
|
|
32341
|
-
};
|
|
32342
|
-
};
|
|
32104
|
+
const createFormState = formConfig => ({
|
|
32105
|
+
reducer: createFormReducer(formConfig),
|
|
32106
|
+
mapDispatchToProps: createMapDispatchToProps(formConfig),
|
|
32107
|
+
mapStateToProps: mapStateToProps
|
|
32108
|
+
});
|
|
32343
32109
|
|
|
32344
32110
|
var formatDelimiter = "_";
|
|
32345
32111
|
var phoneFormats = ["", "_", "__", "(___) ", "(___) _", "(___) __", "(___) ___-", "(___) ___-_", "(___) ___-__", "(___) ___-___", "(___) ___-____"];
|
|
@@ -36650,7 +36416,7 @@ var PaymentButtonBar = function PaymentButtonBar(_ref) {
|
|
|
36650
36416
|
var _useContext = React.useContext(styled.ThemeContext),
|
|
36651
36417
|
isMobile = _useContext.isMobile;
|
|
36652
36418
|
|
|
36653
|
-
var backButton = !!cancelURL ? /*#__PURE__*/React__default.createElement(ButtonWithLink, {
|
|
36419
|
+
var backButton = !!cancelURL && !!cancelText ? /*#__PURE__*/React__default.createElement(ButtonWithLink, {
|
|
36654
36420
|
text: cancelText,
|
|
36655
36421
|
url: cancelURL,
|
|
36656
36422
|
variant: "secondary",
|