@thecb/components 3.5.4 → 3.5.6
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
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
|
|
|
@@ -19126,9 +19069,10 @@ var Spinner$2 = themeComponent(Spinner$1, "Spinner", fallbackValues$j);
|
|
|
19126
19069
|
|
|
19127
19070
|
var Loading = function Loading() {
|
|
19128
19071
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
19129
|
-
key: "spinner-container"
|
|
19072
|
+
key: "spinner-container",
|
|
19073
|
+
extraStyles: "position: fixed; top: 0; bottom: 0; left: 0; right: 0;"
|
|
19130
19074
|
}, /*#__PURE__*/React__default.createElement(Cover, {
|
|
19131
|
-
minHeight: "
|
|
19075
|
+
minHeight: "100%",
|
|
19132
19076
|
singleChild: true
|
|
19133
19077
|
}, /*#__PURE__*/React__default.createElement(Center, {
|
|
19134
19078
|
intrinsic: true
|
|
@@ -30572,401 +30516,378 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
|
|
|
30572
30516
|
|
|
30573
30517
|
var ToggleSwitch$1 = themeComponent(ToggleSwitch, "ToggleSwitch", fallbackValues$o);
|
|
30574
30518
|
|
|
30575
|
-
|
|
30576
|
-
|
|
30577
|
-
|
|
30578
|
-
|
|
30579
|
-
}
|
|
30519
|
+
const validatorToPredicate = (validatorFn, emptyCase) => (
|
|
30520
|
+
value,
|
|
30521
|
+
...rest
|
|
30522
|
+
) => (value === "" ? emptyCase : validatorFn(value, ...rest));
|
|
30580
30523
|
|
|
30581
|
-
return value === "" ? emptyCase : validatorFn.apply(void 0, [value].concat(rest));
|
|
30582
|
-
};
|
|
30583
|
-
};
|
|
30584
30524
|
/* eslint-disable no-unused-vars */
|
|
30585
30525
|
|
|
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
|
-
|
|
30526
|
+
const createValidator = (type, error) => {
|
|
30527
|
+
let validator = (...args) => ({ type, args, error });
|
|
30600
30528
|
validator.error = error;
|
|
30601
30529
|
return validator;
|
|
30602
30530
|
};
|
|
30603
30531
|
|
|
30604
|
-
|
|
30605
|
-
var REQUIRED = "validator/REQUIRED";
|
|
30606
|
-
var REQUIRED_ERROR = "error/REQUIRED";
|
|
30607
|
-
var required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
30532
|
+
let validatorFns = {};
|
|
30608
30533
|
|
|
30609
|
-
|
|
30610
|
-
|
|
30611
|
-
|
|
30534
|
+
const REQUIRED = "validator/REQUIRED";
|
|
30535
|
+
const REQUIRED_ERROR = "error/REQUIRED";
|
|
30536
|
+
const required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
30537
|
+
validatorFns[REQUIRED] = (value, args, form) => value !== "";
|
|
30612
30538
|
|
|
30613
|
-
|
|
30614
|
-
|
|
30615
|
-
|
|
30539
|
+
const ONLY_INTEGERS = "validator/ONLY_INTEGERS";
|
|
30540
|
+
const ONLY_INTEGERS_ERROR = "error/ONLY_INTEGERS";
|
|
30541
|
+
const onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
30542
|
+
validatorFns[ONLY_INTEGERS] = (value, args, form) => /^(-?\d+)?$/.test(value);
|
|
30616
30543
|
|
|
30617
|
-
|
|
30618
|
-
|
|
30619
|
-
|
|
30544
|
+
const ONLY_NATURALS = "validator/ONLY_NATURALS";
|
|
30545
|
+
const ONLY_NATURALS_ERROR = "error/ONLY_NATURALS";
|
|
30546
|
+
const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
30547
|
+
validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
|
|
30620
30548
|
|
|
30621
|
-
|
|
30622
|
-
|
|
30623
|
-
|
|
30624
|
-
|
|
30625
|
-
|
|
30626
|
-
|
|
30627
|
-
|
|
30628
|
-
|
|
30629
|
-
var NUMBER_LESS_THAN = "validator/NUMBER_LESS_THAN";
|
|
30630
|
-
var NUMBER_LESS_THAN_ERROR = "error/NUMBER_LESS_THAN";
|
|
30631
|
-
var numberLessThan = createValidator(NUMBER_LESS_THAN, NUMBER_LESS_THAN_ERROR);
|
|
30632
|
-
|
|
30633
|
-
validatorFns[NUMBER_LESS_THAN] = function (value, args, form) {
|
|
30549
|
+
const NUMBER_LESS_THAN = "validator/NUMBER_LESS_THAN";
|
|
30550
|
+
const NUMBER_LESS_THAN_ERROR = "error/NUMBER_LESS_THAN";
|
|
30551
|
+
const numberLessThan = createValidator(
|
|
30552
|
+
NUMBER_LESS_THAN,
|
|
30553
|
+
NUMBER_LESS_THAN_ERROR
|
|
30554
|
+
);
|
|
30555
|
+
validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
30634
30556
|
if (value === "") {
|
|
30635
30557
|
return true;
|
|
30636
30558
|
}
|
|
30637
|
-
|
|
30638
30559
|
return Number(value) < args[0];
|
|
30639
30560
|
};
|
|
30640
30561
|
|
|
30641
|
-
|
|
30642
|
-
|
|
30643
|
-
|
|
30644
|
-
|
|
30645
|
-
|
|
30562
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
30563
|
+
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
30564
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
30565
|
+
"error/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
30566
|
+
const numberLessThanOrEqualTo = createValidator(
|
|
30567
|
+
NUMBER_LESS_THAN_OR_EQUAL_TO,
|
|
30568
|
+
NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR
|
|
30569
|
+
);
|
|
30570
|
+
validatorFns[NUMBER_LESS_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
30646
30571
|
if (value === "") {
|
|
30647
30572
|
return true;
|
|
30648
30573
|
}
|
|
30649
|
-
|
|
30650
30574
|
return Number(value) <= args[0];
|
|
30651
30575
|
};
|
|
30652
30576
|
|
|
30653
|
-
|
|
30654
|
-
|
|
30655
|
-
|
|
30656
|
-
|
|
30657
|
-
|
|
30577
|
+
const NUMBER_GREATER_THAN = "validator/NUMBER_GREATER_THAN";
|
|
30578
|
+
const NUMBER_GREATER_THAN_ERROR = "error/NUMBER_GREATER_THAN";
|
|
30579
|
+
const numberGreaterThan = createValidator(
|
|
30580
|
+
NUMBER_GREATER_THAN,
|
|
30581
|
+
NUMBER_GREATER_THAN_ERROR
|
|
30582
|
+
);
|
|
30583
|
+
validatorFns[NUMBER_GREATER_THAN] = (value, args, form) => {
|
|
30658
30584
|
if (value === "") {
|
|
30659
30585
|
return true;
|
|
30660
30586
|
}
|
|
30661
|
-
|
|
30662
30587
|
return Number(value) > args[0];
|
|
30663
30588
|
};
|
|
30664
30589
|
|
|
30665
|
-
|
|
30666
|
-
|
|
30667
|
-
|
|
30668
|
-
|
|
30669
|
-
|
|
30590
|
+
const NUMBER_GREATER_THAN_OR_EQUAL_TO =
|
|
30591
|
+
"validator/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
30592
|
+
const NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR =
|
|
30593
|
+
"error/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
30594
|
+
const numberGreaterThanOrEqualTo = createValidator(
|
|
30595
|
+
NUMBER_GREATER_THAN_OR_EQUAL_TO,
|
|
30596
|
+
NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR
|
|
30597
|
+
);
|
|
30598
|
+
validatorFns[NUMBER_GREATER_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
30670
30599
|
if (value === "") {
|
|
30671
30600
|
return true;
|
|
30672
30601
|
}
|
|
30673
|
-
|
|
30674
30602
|
return Number(value) >= args[0];
|
|
30675
30603
|
};
|
|
30676
30604
|
|
|
30677
|
-
|
|
30678
|
-
|
|
30679
|
-
|
|
30680
|
-
|
|
30681
|
-
validatorFns[MATCHES_FIELD] = function (value, args, form) {
|
|
30605
|
+
const MATCHES_FIELD = "validator/MATCHES_FIELD";
|
|
30606
|
+
const MATCHES_FIELD_ERROR$1 = "error/MATCHES_FIELD";
|
|
30607
|
+
const matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
|
|
30608
|
+
validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
30682
30609
|
if (value === "") {
|
|
30683
30610
|
return true;
|
|
30684
30611
|
}
|
|
30685
|
-
|
|
30686
30612
|
if (form[args[0]] === undefined) {
|
|
30687
|
-
throw new Error(
|
|
30613
|
+
throw new Error(
|
|
30614
|
+
`${args[0]} was passed to matchesField, but that field does not exist in the form`
|
|
30615
|
+
);
|
|
30688
30616
|
}
|
|
30689
|
-
|
|
30690
30617
|
return value === form[args[0]].rawValue;
|
|
30691
30618
|
};
|
|
30692
30619
|
|
|
30693
|
-
|
|
30694
|
-
|
|
30695
|
-
|
|
30696
|
-
|
|
30697
|
-
|
|
30698
|
-
|
|
30699
|
-
|
|
30700
|
-
|
|
30701
|
-
|
|
30702
|
-
|
|
30703
|
-
|
|
30704
|
-
|
|
30705
|
-
|
|
30706
|
-
|
|
30707
|
-
|
|
30620
|
+
const validateWhenErrorMessage = type =>
|
|
30621
|
+
`${type} was passed to validateWhen, but that validator type does not exist.
|
|
30622
|
+
Please check that you are only calling validator creator functions exported from
|
|
30623
|
+
redux-freeform in your form config and that you didn't forget to
|
|
30624
|
+
invoke the validator creator (you cannot pass the functions themselves to
|
|
30625
|
+
createFormState). Also make sure you aren't passing validateWhen() to validateWhen
|
|
30626
|
+
as the primary validator.`;
|
|
30627
|
+
|
|
30628
|
+
const VALIDATE_WHEN = "validator/VALIDATE_WHEN";
|
|
30629
|
+
const VALIDATE_WHEN_ERROR = "error/VALIDATE_WHEN";
|
|
30630
|
+
const validateWhen = (
|
|
30631
|
+
dependentValidator,
|
|
30632
|
+
primaryValidator,
|
|
30633
|
+
optionalFieldName
|
|
30634
|
+
) => ({
|
|
30635
|
+
type: VALIDATE_WHEN,
|
|
30636
|
+
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
30637
|
+
error: dependentValidator.error
|
|
30638
|
+
});
|
|
30708
30639
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
30640
|
+
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
30641
|
+
const [dependentValidator, primaryValidator, optionalFieldName] = args;
|
|
30642
|
+
const dependsOnOtherField = typeof optionalFieldName === "string";
|
|
30709
30643
|
|
|
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") {
|
|
30644
|
+
if (
|
|
30645
|
+
primaryValidator.type === undefined ||
|
|
30646
|
+
typeof validatorFns[primaryValidator.type] !== "function"
|
|
30647
|
+
) {
|
|
30719
30648
|
throw new Error(validateWhenErrorMessage(primaryValidator.type));
|
|
30720
30649
|
}
|
|
30721
|
-
|
|
30722
30650
|
if (dependsOnOtherField && form[optionalFieldName] === undefined) {
|
|
30723
|
-
throw new Error(
|
|
30651
|
+
throw new Error(
|
|
30652
|
+
`${args[2]} was passed to matchesField, but that field does not exist in the form`
|
|
30653
|
+
);
|
|
30724
30654
|
}
|
|
30725
30655
|
|
|
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
|
-
};
|
|
30656
|
+
const primaryPredicate = validatorToPredicate(
|
|
30657
|
+
validatorFns[primaryValidator.type],
|
|
30658
|
+
false
|
|
30659
|
+
);
|
|
30660
|
+
const primaryValue = dependsOnOtherField
|
|
30661
|
+
? form[optionalFieldName].rawValue
|
|
30662
|
+
: value;
|
|
30663
|
+
const primaryPredicatePassed = primaryPredicate(
|
|
30664
|
+
primaryValue,
|
|
30665
|
+
primaryValidator.args,
|
|
30666
|
+
form
|
|
30667
|
+
);
|
|
30746
30668
|
|
|
30669
|
+
return primaryPredicatePassed
|
|
30670
|
+
? validatorFns[dependentValidator.type](
|
|
30671
|
+
value,
|
|
30672
|
+
dependentValidator.args,
|
|
30673
|
+
form
|
|
30674
|
+
)
|
|
30675
|
+
: true;
|
|
30676
|
+
};
|
|
30677
|
+
|
|
30678
|
+
const validateSumErrorMessage = type =>
|
|
30679
|
+
`${type} was passed to validateSum, but that validator type does not exist.
|
|
30680
|
+
Please check that you are only calling validator creator functions exported from
|
|
30681
|
+
redux-freeform in your form config and that you didn't forget to
|
|
30682
|
+
invoke the validator creator (you cannot pass the functions themselves to
|
|
30683
|
+
createFormState).`;
|
|
30684
|
+
const VALIDATE_SUM = "validator/VALIDATE_SUM";
|
|
30685
|
+
const VALIDATE_SUM_ERROR = "error/VALIDATE_SUM";
|
|
30686
|
+
const validateSum = (validator, fieldNamesArray) => ({
|
|
30687
|
+
type: VALIDATE_SUM,
|
|
30688
|
+
args: [validator, fieldNamesArray],
|
|
30689
|
+
error: validator.error
|
|
30690
|
+
});
|
|
30747
30691
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
30692
|
+
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
30693
|
+
const [validator, fieldNamesArray] = args;
|
|
30748
30694
|
|
|
30749
|
-
|
|
30750
|
-
|
|
30751
|
-
|
|
30752
|
-
|
|
30753
|
-
|
|
30754
|
-
if (validator.type === undefined || typeof validatorFns[validator.type] !== "function") {
|
|
30695
|
+
if (
|
|
30696
|
+
validator.type === undefined ||
|
|
30697
|
+
typeof validatorFns[validator.type] !== "function"
|
|
30698
|
+
) {
|
|
30755
30699
|
throw new Error(validateSumErrorMessage(validator.type));
|
|
30756
30700
|
}
|
|
30757
30701
|
|
|
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
|
-
}
|
|
30702
|
+
for (const fieldName of fieldNamesArray) {
|
|
30703
|
+
if (form[fieldName] === undefined) {
|
|
30704
|
+
throw new Error(
|
|
30705
|
+
`${fieldName} was passed to matchesField, but that field does not exist in the form`
|
|
30706
|
+
);
|
|
30768
30707
|
}
|
|
30769
|
-
} catch (err) {
|
|
30770
|
-
_iterator.e(err);
|
|
30771
|
-
} finally {
|
|
30772
|
-
_iterator.f();
|
|
30773
30708
|
}
|
|
30774
30709
|
|
|
30775
|
-
|
|
30776
|
-
|
|
30777
|
-
|
|
30710
|
+
const sum = fieldNamesArray.reduce(
|
|
30711
|
+
(acc, curr) => acc + Number(form[curr].rawValue),
|
|
30712
|
+
Number(value)
|
|
30713
|
+
);
|
|
30714
|
+
|
|
30778
30715
|
return validatorFns[validator.type](sum, validator.args, form);
|
|
30779
30716
|
};
|
|
30780
30717
|
|
|
30781
|
-
|
|
30782
|
-
|
|
30783
|
-
|
|
30784
|
-
|
|
30785
|
-
validatorFns[HAS_LENGTH] = function (value, args, form) {
|
|
30718
|
+
const HAS_LENGTH = "validator/HAS_LENGTH";
|
|
30719
|
+
const HAS_LENGTH_ERROR = "error/HAS_LENGTH";
|
|
30720
|
+
const hasLength = createValidator(HAS_LENGTH, HAS_LENGTH_ERROR);
|
|
30721
|
+
validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
30786
30722
|
if (value === "") {
|
|
30787
30723
|
return true;
|
|
30788
30724
|
}
|
|
30789
|
-
|
|
30790
|
-
|
|
30791
|
-
var max = args[1];
|
|
30792
|
-
|
|
30725
|
+
const min = args[0];
|
|
30726
|
+
const max = args[1];
|
|
30793
30727
|
if (max == undefined || min == undefined) {
|
|
30794
|
-
throw new Error(
|
|
30728
|
+
throw new Error(
|
|
30729
|
+
"Max and min need to be defined for hasLength, both or one of them is undefined"
|
|
30730
|
+
);
|
|
30795
30731
|
}
|
|
30796
|
-
|
|
30797
30732
|
if (max < min) {
|
|
30798
|
-
throw new Error(
|
|
30733
|
+
throw new Error(
|
|
30734
|
+
"hasLength validator was passed a min greater than the max"
|
|
30735
|
+
);
|
|
30799
30736
|
}
|
|
30800
|
-
|
|
30801
|
-
var valueLength = value.length;
|
|
30737
|
+
const valueLength = value.length;
|
|
30802
30738
|
return max >= valueLength && valueLength >= min;
|
|
30803
30739
|
};
|
|
30804
30740
|
|
|
30805
|
-
|
|
30806
|
-
|
|
30807
|
-
|
|
30808
|
-
|
|
30809
|
-
validatorFns[MATCHES_REGEX] = function (value, args, form) {
|
|
30741
|
+
const MATCHES_REGEX = "validator/MATCHES_REGEX";
|
|
30742
|
+
const MATCHES_REGEX_ERROR = "error/MATCHES_REGEX";
|
|
30743
|
+
const matchesRegex = createValidator(MATCHES_REGEX, MATCHES_REGEX_ERROR);
|
|
30744
|
+
validatorFns[MATCHES_REGEX] = (value, args, form) => {
|
|
30810
30745
|
if (value === "") {
|
|
30811
30746
|
return true;
|
|
30812
30747
|
}
|
|
30813
|
-
|
|
30814
30748
|
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);
|
|
30749
|
+
};
|
|
30821
30750
|
|
|
30822
|
-
|
|
30751
|
+
// based on http://www.brainjar.com/js/validation/
|
|
30752
|
+
const IS_ROUTING_NUMBER = "validator/IS_ROUTING_NUMBER";
|
|
30753
|
+
const IS_ROUTING_NUMBER_ERROR = "error/IS_ROUTING_NUMBER";
|
|
30754
|
+
const isRoutingNumber = createValidator(
|
|
30755
|
+
IS_ROUTING_NUMBER,
|
|
30756
|
+
IS_ROUTING_NUMBER_ERROR
|
|
30757
|
+
);
|
|
30758
|
+
validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
30823
30759
|
if (value === "") {
|
|
30824
30760
|
return true;
|
|
30825
30761
|
}
|
|
30826
|
-
|
|
30827
30762
|
if (value.length != 9) {
|
|
30828
30763
|
return false;
|
|
30829
30764
|
}
|
|
30830
|
-
|
|
30831
|
-
|
|
30832
|
-
|
|
30833
|
-
|
|
30834
|
-
|
|
30835
|
-
|
|
30836
|
-
|
|
30837
|
-
|
|
30838
|
-
|
|
30839
|
-
|
|
30840
|
-
|
|
30841
|
-
|
|
30842
|
-
|
|
30843
|
-
}
|
|
30844
|
-
}, 0);
|
|
30765
|
+
const sum = value
|
|
30766
|
+
.split("")
|
|
30767
|
+
.map(ch => parseInt(ch))
|
|
30768
|
+
.reduce((acc, cur, idx) => {
|
|
30769
|
+
switch (idx % 3) {
|
|
30770
|
+
case 0:
|
|
30771
|
+
return acc + 3 * cur;
|
|
30772
|
+
case 1:
|
|
30773
|
+
return acc + 7 * cur;
|
|
30774
|
+
case 2:
|
|
30775
|
+
return acc + 1 * cur;
|
|
30776
|
+
}
|
|
30777
|
+
}, 0);
|
|
30845
30778
|
return sum != 0 && sum % 10 == 0;
|
|
30846
30779
|
};
|
|
30847
30780
|
|
|
30848
|
-
|
|
30849
|
-
|
|
30850
|
-
|
|
30851
|
-
|
|
30852
|
-
validatorFns[HAS_NUMBER] = function (value, args, form) {
|
|
30781
|
+
const HAS_NUMBER = "validator/HAS_NUMBER";
|
|
30782
|
+
const HAS_NUMBER_ERROR$1 = "error/HAS_NUMBER";
|
|
30783
|
+
const hasNumber = createValidator(HAS_NUMBER, HAS_NUMBER_ERROR$1);
|
|
30784
|
+
validatorFns[HAS_NUMBER] = (value, args, form) => {
|
|
30853
30785
|
if (value === "") {
|
|
30854
30786
|
return true;
|
|
30855
30787
|
}
|
|
30856
|
-
|
|
30857
30788
|
return new RegExp(/[0-9]/).test(value);
|
|
30858
30789
|
};
|
|
30859
30790
|
|
|
30860
|
-
|
|
30861
|
-
|
|
30862
|
-
|
|
30863
|
-
|
|
30864
|
-
|
|
30791
|
+
const HAS_LOWERCASE_LETTER = "validator/HAS_LOWERCASE_LETTER";
|
|
30792
|
+
const HAS_LOWERCASE_LETTER_ERROR$1 = "error/HAS_LOWERCASE_LETTER";
|
|
30793
|
+
const hasLowercaseLetter = createValidator(
|
|
30794
|
+
HAS_LOWERCASE_LETTER,
|
|
30795
|
+
HAS_LOWERCASE_LETTER_ERROR$1
|
|
30796
|
+
);
|
|
30797
|
+
validatorFns[HAS_LOWERCASE_LETTER] = (value, args, form) => {
|
|
30865
30798
|
if (value === "") {
|
|
30866
30799
|
return true;
|
|
30867
30800
|
}
|
|
30868
|
-
|
|
30869
30801
|
return new RegExp(/[a-z]/).test(value);
|
|
30870
30802
|
};
|
|
30871
30803
|
|
|
30872
|
-
|
|
30873
|
-
|
|
30874
|
-
|
|
30875
|
-
|
|
30876
|
-
|
|
30804
|
+
const HAS_UPPERCASE_LETTER = "validator/HAS_UPPERCASE_LETTER";
|
|
30805
|
+
const HAS_UPPERCASE_LETTER_ERROR$1 = "error/HAS_UPPERCASE_LETTER";
|
|
30806
|
+
const hasUppercaseLetter = createValidator(
|
|
30807
|
+
HAS_UPPERCASE_LETTER,
|
|
30808
|
+
HAS_UPPERCASE_LETTER_ERROR$1
|
|
30809
|
+
);
|
|
30810
|
+
validatorFns[HAS_UPPERCASE_LETTER] = (value, args, form) => {
|
|
30877
30811
|
if (value === "") {
|
|
30878
30812
|
return true;
|
|
30879
30813
|
}
|
|
30880
|
-
|
|
30881
30814
|
return new RegExp(/[A-Z]/).test(value);
|
|
30882
30815
|
};
|
|
30883
30816
|
|
|
30884
|
-
|
|
30885
|
-
|
|
30886
|
-
|
|
30887
|
-
|
|
30888
|
-
|
|
30817
|
+
const HAS_SPECIAL_CHARACTER = "validator/HAS_SPECIAL_CHARACTER";
|
|
30818
|
+
const HAS_SPECIAL_CHARACTER_ERROR$1 = "error/HAS_SPECIAL_CHARACTER";
|
|
30819
|
+
const hasSpecialCharacter = createValidator(
|
|
30820
|
+
HAS_SPECIAL_CHARACTER,
|
|
30821
|
+
HAS_SPECIAL_CHARACTER_ERROR$1
|
|
30822
|
+
);
|
|
30823
|
+
validatorFns[HAS_SPECIAL_CHARACTER] = (value, args, form) => {
|
|
30889
30824
|
if (value === "") {
|
|
30890
30825
|
return true;
|
|
30891
30826
|
}
|
|
30892
|
-
|
|
30893
30827
|
return new RegExp(/[!@#$%^&*.?]/).test(value);
|
|
30894
30828
|
};
|
|
30895
30829
|
|
|
30896
|
-
|
|
30897
|
-
|
|
30898
|
-
|
|
30899
|
-
|
|
30900
|
-
|
|
30830
|
+
const IS_PROBABLY_EMAIL = "validator/IS_PROBABLY_EMAIL";
|
|
30831
|
+
const IS_PROBABLY_EMAIL_ERROR = "error/IS_PROBABLY_EMAIL";
|
|
30832
|
+
const isProbablyEmail = createValidator(
|
|
30833
|
+
IS_PROBABLY_EMAIL,
|
|
30834
|
+
IS_PROBABLY_EMAIL_ERROR
|
|
30835
|
+
);
|
|
30836
|
+
validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
30901
30837
|
if (value === "") {
|
|
30902
30838
|
return true;
|
|
30903
30839
|
}
|
|
30904
|
-
|
|
30905
30840
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
30906
30841
|
};
|
|
30907
30842
|
|
|
30908
|
-
|
|
30909
|
-
|
|
30910
|
-
|
|
30911
|
-
|
|
30912
|
-
|
|
30913
|
-
|
|
30843
|
+
const runValidatorErrorMessage = type =>
|
|
30844
|
+
`${type} was passed to runValidator, but that validator type does not exist.
|
|
30845
|
+
Please check that you are only calling validator creator functions exported from
|
|
30846
|
+
redux-freeform in your form config and that you didn't forget to
|
|
30847
|
+
invoke the validator creator (you cannot pass the functions themselves to
|
|
30848
|
+
createFormState)`;
|
|
30914
30849
|
|
|
30850
|
+
const runValidator = (validator, value, form) => {
|
|
30851
|
+
const validatorFn = validatorFns[validator.type];
|
|
30915
30852
|
if (validatorFn === undefined) {
|
|
30916
30853
|
throw new Error(runValidatorErrorMessage(validator.type));
|
|
30917
30854
|
}
|
|
30918
|
-
|
|
30919
30855
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
30920
30856
|
};
|
|
30921
30857
|
|
|
30922
|
-
|
|
30923
|
-
return validators
|
|
30924
|
-
|
|
30925
|
-
|
|
30926
|
-
return x !== null;
|
|
30927
|
-
});
|
|
30858
|
+
const _computeErrors = (fieldName, form, validators) => {
|
|
30859
|
+
return validators
|
|
30860
|
+
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
30861
|
+
.filter(x => x !== null);
|
|
30928
30862
|
};
|
|
30929
30863
|
|
|
30930
|
-
|
|
30931
|
-
|
|
30864
|
+
const computeConstraints = (fieldName, form) => {
|
|
30865
|
+
const constraints = form[fieldName].constraints;
|
|
30932
30866
|
return _computeErrors(fieldName, form, constraints);
|
|
30933
30867
|
};
|
|
30934
30868
|
|
|
30935
|
-
|
|
30936
|
-
|
|
30869
|
+
const computeErrors = (fieldName, form) => {
|
|
30870
|
+
const validators = form[fieldName].validators;
|
|
30937
30871
|
return _computeErrors(fieldName, form, validators);
|
|
30938
30872
|
};
|
|
30939
30873
|
|
|
30940
30874
|
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
|
-
|
|
30875
|
+
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : ( obj = {}, obj["immer-nothing"] = true, obj );
|
|
30876
|
+
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
30877
|
+
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-state") : "__$immer_state";
|
|
30945
30878
|
function isDraft(value) {
|
|
30946
30879
|
return !!value && !!value[DRAFT_STATE];
|
|
30947
30880
|
}
|
|
30948
|
-
|
|
30949
30881
|
function isDraftable(value) {
|
|
30950
|
-
if (!value) {
|
|
30951
|
-
return false;
|
|
30952
|
-
}
|
|
30953
|
-
|
|
30882
|
+
if (!value) { return false; }
|
|
30954
30883
|
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
30955
30884
|
}
|
|
30956
|
-
|
|
30957
30885
|
function isPlainObject(value) {
|
|
30958
|
-
if (!value ||
|
|
30959
|
-
|
|
30960
|
-
}
|
|
30961
|
-
|
|
30962
|
-
if (Array.isArray(value)) {
|
|
30963
|
-
return true;
|
|
30964
|
-
}
|
|
30965
|
-
|
|
30886
|
+
if (!value || typeof value !== "object") { return false; }
|
|
30887
|
+
if (Array.isArray(value)) { return true; }
|
|
30966
30888
|
var proto = Object.getPrototypeOf(value);
|
|
30967
30889
|
return !proto || proto === Object.prototype;
|
|
30968
30890
|
}
|
|
30969
|
-
|
|
30970
30891
|
var assign = Object.assign || function assign(target, value) {
|
|
30971
30892
|
for (var key in value) {
|
|
30972
30893
|
if (has(value, key)) {
|
|
@@ -30976,18 +30897,11 @@ var assign = Object.assign || function assign(target, value) {
|
|
|
30976
30897
|
|
|
30977
30898
|
return target;
|
|
30978
30899
|
};
|
|
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
|
-
|
|
30900
|
+
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
30901
|
function shallowCopy(base, invokeGetters) {
|
|
30985
|
-
if (invokeGetters === void 0) invokeGetters = false;
|
|
30986
|
-
|
|
30987
|
-
if (Array.isArray(base)) {
|
|
30988
|
-
return base.slice();
|
|
30989
|
-
}
|
|
30902
|
+
if ( invokeGetters === void 0 ) invokeGetters = false;
|
|
30990
30903
|
|
|
30904
|
+
if (Array.isArray(base)) { return base.slice(); }
|
|
30991
30905
|
var clone = Object.create(Object.getPrototypeOf(base));
|
|
30992
30906
|
ownKeys$1(base).forEach(function (key) {
|
|
30993
30907
|
if (key === DRAFT_STATE) {
|
|
@@ -31017,28 +30931,20 @@ function shallowCopy(base, invokeGetters) {
|
|
|
31017
30931
|
});
|
|
31018
30932
|
return clone;
|
|
31019
30933
|
}
|
|
31020
|
-
|
|
31021
30934
|
function each(value, cb) {
|
|
31022
30935
|
if (Array.isArray(value)) {
|
|
31023
|
-
for (var i = 0; i < value.length; i++) {
|
|
31024
|
-
cb(i, value[i], value);
|
|
31025
|
-
}
|
|
30936
|
+
for (var i = 0; i < value.length; i++) { cb(i, value[i], value); }
|
|
31026
30937
|
} else {
|
|
31027
|
-
ownKeys$1(value).forEach(function (key) {
|
|
31028
|
-
return cb(key, value[key], value);
|
|
31029
|
-
});
|
|
30938
|
+
ownKeys$1(value).forEach(function (key) { return cb(key, value[key], value); });
|
|
31030
30939
|
}
|
|
31031
30940
|
}
|
|
31032
|
-
|
|
31033
30941
|
function isEnumerable(base, prop) {
|
|
31034
30942
|
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
31035
30943
|
return !!desc && desc.enumerable;
|
|
31036
30944
|
}
|
|
31037
|
-
|
|
31038
30945
|
function has(thing, prop) {
|
|
31039
30946
|
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
31040
30947
|
}
|
|
31041
|
-
|
|
31042
30948
|
function is(x, y) {
|
|
31043
30949
|
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
31044
30950
|
if (x === y) {
|
|
@@ -31047,26 +30953,17 @@ function is(x, y) {
|
|
|
31047
30953
|
return x !== x && y !== y;
|
|
31048
30954
|
}
|
|
31049
30955
|
}
|
|
31050
|
-
|
|
31051
30956
|
function clone(obj) {
|
|
31052
|
-
if (!isDraftable(obj)) {
|
|
31053
|
-
|
|
31054
|
-
}
|
|
31055
|
-
|
|
31056
|
-
if (Array.isArray(obj)) {
|
|
31057
|
-
return obj.map(clone);
|
|
31058
|
-
}
|
|
31059
|
-
|
|
30957
|
+
if (!isDraftable(obj)) { return obj; }
|
|
30958
|
+
if (Array.isArray(obj)) { return obj.map(clone); }
|
|
31060
30959
|
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
31061
30960
|
|
|
31062
|
-
for (var key in obj) {
|
|
31063
|
-
cloned[key] = clone(obj[key]);
|
|
31064
|
-
}
|
|
30961
|
+
for (var key in obj) { cloned[key] = clone(obj[key]); }
|
|
31065
30962
|
|
|
31066
30963
|
return cloned;
|
|
31067
30964
|
}
|
|
31068
|
-
/** Each scope represents a `produce` call. */
|
|
31069
30965
|
|
|
30966
|
+
/** Each scope represents a `produce` call. */
|
|
31070
30967
|
|
|
31071
30968
|
var ImmerScope = function ImmerScope(parent) {
|
|
31072
30969
|
this.drafts = [];
|
|
@@ -31078,7 +30975,7 @@ var ImmerScope = function ImmerScope(parent) {
|
|
|
31078
30975
|
this.patches = null;
|
|
31079
30976
|
};
|
|
31080
30977
|
|
|
31081
|
-
ImmerScope.prototype.usePatches = function usePatches(patchListener) {
|
|
30978
|
+
ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
31082
30979
|
if (patchListener) {
|
|
31083
30980
|
this.patches = [];
|
|
31084
30981
|
this.inversePatches = [];
|
|
@@ -31086,18 +30983,17 @@ ImmerScope.prototype.usePatches = function usePatches(patchListener) {
|
|
|
31086
30983
|
}
|
|
31087
30984
|
};
|
|
31088
30985
|
|
|
31089
|
-
ImmerScope.prototype.revoke = function revoke$1() {
|
|
30986
|
+
ImmerScope.prototype.revoke = function revoke$1 () {
|
|
31090
30987
|
this.leave();
|
|
31091
30988
|
this.drafts.forEach(revoke);
|
|
31092
30989
|
this.drafts = null; // Make draft-related methods throw.
|
|
31093
30990
|
};
|
|
31094
30991
|
|
|
31095
|
-
ImmerScope.prototype.leave = function leave() {
|
|
30992
|
+
ImmerScope.prototype.leave = function leave () {
|
|
31096
30993
|
if (this === ImmerScope.current) {
|
|
31097
30994
|
ImmerScope.current = this.parent;
|
|
31098
30995
|
}
|
|
31099
30996
|
};
|
|
31100
|
-
|
|
31101
30997
|
ImmerScope.current = null;
|
|
31102
30998
|
|
|
31103
30999
|
ImmerScope.enter = function () {
|
|
@@ -31106,11 +31002,11 @@ ImmerScope.enter = function () {
|
|
|
31106
31002
|
|
|
31107
31003
|
function revoke(draft) {
|
|
31108
31004
|
draft[DRAFT_STATE].revoke();
|
|
31109
|
-
}
|
|
31005
|
+
}
|
|
31110
31006
|
|
|
31007
|
+
// but share them all instead
|
|
31111
31008
|
|
|
31112
31009
|
var descriptors = {};
|
|
31113
|
-
|
|
31114
31010
|
function willFinalize(scope, result, isReplaced) {
|
|
31115
31011
|
scope.drafts.forEach(function (draft) {
|
|
31116
31012
|
draft[DRAFT_STATE].finalizing = true;
|
|
@@ -31128,7 +31024,6 @@ function willFinalize(scope, result, isReplaced) {
|
|
|
31128
31024
|
markChangesSweep(scope.drafts);
|
|
31129
31025
|
}
|
|
31130
31026
|
}
|
|
31131
|
-
|
|
31132
31027
|
function createProxy(base, parent) {
|
|
31133
31028
|
var isArray = Array.isArray(base);
|
|
31134
31029
|
var draft = clonePotentialDraft(base);
|
|
@@ -31182,11 +31077,7 @@ function peek(draft, prop) {
|
|
|
31182
31077
|
function get(state, prop) {
|
|
31183
31078
|
assertUnrevoked(state);
|
|
31184
31079
|
var value = peek(source(state), prop);
|
|
31185
|
-
|
|
31186
|
-
if (state.finalizing) {
|
|
31187
|
-
return value;
|
|
31188
|
-
} // Create a draft if the value is unmodified.
|
|
31189
|
-
|
|
31080
|
+
if (state.finalizing) { return value; } // Create a draft if the value is unmodified.
|
|
31190
31081
|
|
|
31191
31082
|
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
31192
31083
|
prepareCopy(state);
|
|
@@ -31201,10 +31092,7 @@ function set(state, prop, value) {
|
|
|
31201
31092
|
state.assigned[prop] = true;
|
|
31202
31093
|
|
|
31203
31094
|
if (!state.modified) {
|
|
31204
|
-
if (is(value, peek(source(state), prop))) {
|
|
31205
|
-
return;
|
|
31206
|
-
}
|
|
31207
|
-
|
|
31095
|
+
if (is(value, peek(source(state), prop))) { return; }
|
|
31208
31096
|
markChanged(state);
|
|
31209
31097
|
prepareCopy(state);
|
|
31210
31098
|
}
|
|
@@ -31215,17 +31103,12 @@ function set(state, prop, value) {
|
|
|
31215
31103
|
function markChanged(state) {
|
|
31216
31104
|
if (!state.modified) {
|
|
31217
31105
|
state.modified = true;
|
|
31218
|
-
|
|
31219
|
-
if (state.parent) {
|
|
31220
|
-
markChanged(state.parent);
|
|
31221
|
-
}
|
|
31106
|
+
if (state.parent) { markChanged(state.parent); }
|
|
31222
31107
|
}
|
|
31223
31108
|
}
|
|
31224
31109
|
|
|
31225
31110
|
function prepareCopy(state) {
|
|
31226
|
-
if (!state.copy) {
|
|
31227
|
-
state.copy = clonePotentialDraft(state.base);
|
|
31228
|
-
}
|
|
31111
|
+
if (!state.copy) { state.copy = clonePotentialDraft(state.base); }
|
|
31229
31112
|
}
|
|
31230
31113
|
|
|
31231
31114
|
function clonePotentialDraft(base) {
|
|
@@ -31250,12 +31133,15 @@ function proxyProperty(draft, prop, enumerable) {
|
|
|
31250
31133
|
descriptors[prop] = desc = {
|
|
31251
31134
|
configurable: true,
|
|
31252
31135
|
enumerable: enumerable,
|
|
31136
|
+
|
|
31253
31137
|
get: function get$1() {
|
|
31254
31138
|
return get(this[DRAFT_STATE], prop);
|
|
31255
31139
|
},
|
|
31140
|
+
|
|
31256
31141
|
set: function set$1(value) {
|
|
31257
31142
|
set(this[DRAFT_STATE], prop, value);
|
|
31258
31143
|
}
|
|
31144
|
+
|
|
31259
31145
|
};
|
|
31260
31146
|
}
|
|
31261
31147
|
|
|
@@ -31263,9 +31149,7 @@ function proxyProperty(draft, prop, enumerable) {
|
|
|
31263
31149
|
}
|
|
31264
31150
|
|
|
31265
31151
|
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
|
-
}
|
|
31152
|
+
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
31153
|
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
31270
31154
|
|
|
31271
31155
|
|
|
@@ -31279,27 +31163,16 @@ function markChangesSweep(drafts) {
|
|
|
31279
31163
|
|
|
31280
31164
|
if (!state.modified) {
|
|
31281
31165
|
if (Array.isArray(state.base)) {
|
|
31282
|
-
if (hasArrayChanges(state)) {
|
|
31283
|
-
|
|
31284
|
-
}
|
|
31285
|
-
} else if (hasObjectChanges(state)) {
|
|
31286
|
-
markChanged(state);
|
|
31287
|
-
}
|
|
31166
|
+
if (hasArrayChanges(state)) { markChanged(state); }
|
|
31167
|
+
} else if (hasObjectChanges(state)) { markChanged(state); }
|
|
31288
31168
|
}
|
|
31289
31169
|
}
|
|
31290
31170
|
}
|
|
31291
31171
|
|
|
31292
31172
|
function markChangesRecursively(object) {
|
|
31293
|
-
if (!object ||
|
|
31294
|
-
return;
|
|
31295
|
-
}
|
|
31296
|
-
|
|
31173
|
+
if (!object || typeof object !== "object") { return; }
|
|
31297
31174
|
var state = object[DRAFT_STATE];
|
|
31298
|
-
|
|
31299
|
-
if (!state) {
|
|
31300
|
-
return;
|
|
31301
|
-
}
|
|
31302
|
-
|
|
31175
|
+
if (!state) { return; }
|
|
31303
31176
|
var base = state.base;
|
|
31304
31177
|
var draft = state.draft;
|
|
31305
31178
|
var assigned = state.assigned;
|
|
@@ -31329,20 +31202,14 @@ function markChangesRecursively(object) {
|
|
|
31329
31202
|
assigned.length = true;
|
|
31330
31203
|
|
|
31331
31204
|
if (draft.length < base.length) {
|
|
31332
|
-
for (var i = draft.length; i < base.length; i++) {
|
|
31333
|
-
assigned[i] = false;
|
|
31334
|
-
}
|
|
31205
|
+
for (var i = draft.length; i < base.length; i++) { assigned[i] = false; }
|
|
31335
31206
|
} else {
|
|
31336
|
-
for (var i$1 = base.length; i$1 < draft.length; i$1++) {
|
|
31337
|
-
assigned[i$1] = true;
|
|
31338
|
-
}
|
|
31207
|
+
for (var i$1 = base.length; i$1 < draft.length; i$1++) { assigned[i$1] = true; }
|
|
31339
31208
|
}
|
|
31340
31209
|
|
|
31341
31210
|
for (var i$2 = 0; i$2 < draft.length; i$2++) {
|
|
31342
31211
|
// Only untouched indices trigger recursion.
|
|
31343
|
-
if (assigned[i$2] === undefined) {
|
|
31344
|
-
markChangesRecursively(draft[i$2]);
|
|
31345
|
-
}
|
|
31212
|
+
if (assigned[i$2] === undefined) { markChangesRecursively(draft[i$2]); }
|
|
31346
31213
|
}
|
|
31347
31214
|
}
|
|
31348
31215
|
}
|
|
@@ -31379,10 +31246,7 @@ function hasObjectChanges(state) {
|
|
|
31379
31246
|
|
|
31380
31247
|
function hasArrayChanges(state) {
|
|
31381
31248
|
var draft = state.draft;
|
|
31382
|
-
|
|
31383
|
-
if (draft.length !== state.base.length) {
|
|
31384
|
-
return true;
|
|
31385
|
-
} // See #116
|
|
31249
|
+
if (draft.length !== state.base.length) { return true; } // See #116
|
|
31386
31250
|
// If we first shorten the length, our array interceptors will be removed.
|
|
31387
31251
|
// If after that new items are added, result in the same original length,
|
|
31388
31252
|
// those last items will have no intercepting property.
|
|
@@ -31390,13 +31254,9 @@ function hasArrayChanges(state) {
|
|
|
31390
31254
|
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
31391
31255
|
// the last one
|
|
31392
31256
|
|
|
31393
|
-
|
|
31394
31257
|
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
31395
31258
|
|
|
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
|
-
|
|
31259
|
+
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
31260
|
|
|
31401
31261
|
return false;
|
|
31402
31262
|
}
|
|
@@ -31410,12 +31270,11 @@ function createHiddenProperty(target, prop, value) {
|
|
|
31410
31270
|
}
|
|
31411
31271
|
|
|
31412
31272
|
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
31413
|
-
|
|
31414
|
-
|
|
31273
|
+
willFinalize: willFinalize,
|
|
31274
|
+
createProxy: createProxy
|
|
31415
31275
|
});
|
|
31416
31276
|
|
|
31417
31277
|
function willFinalize$1() {}
|
|
31418
|
-
|
|
31419
31278
|
function createProxy$1(base, parent) {
|
|
31420
31279
|
var scope = parent ? parent.scope : ImmerScope.current;
|
|
31421
31280
|
var state = {
|
|
@@ -31450,27 +31309,33 @@ function createProxy$1(base, parent) {
|
|
|
31450
31309
|
scope.drafts.push(proxy);
|
|
31451
31310
|
return proxy;
|
|
31452
31311
|
}
|
|
31453
|
-
|
|
31454
31312
|
var objectTraps = {
|
|
31455
31313
|
get: get$1,
|
|
31314
|
+
|
|
31456
31315
|
has: function has(target, prop) {
|
|
31457
31316
|
return prop in source$1(target);
|
|
31458
31317
|
},
|
|
31318
|
+
|
|
31459
31319
|
ownKeys: function ownKeys(target) {
|
|
31460
31320
|
return Reflect.ownKeys(source$1(target));
|
|
31461
31321
|
},
|
|
31322
|
+
|
|
31462
31323
|
set: set$1,
|
|
31463
31324
|
deleteProperty: deleteProperty,
|
|
31464
31325
|
getOwnPropertyDescriptor: getOwnPropertyDescriptor,
|
|
31326
|
+
|
|
31465
31327
|
defineProperty: function defineProperty() {
|
|
31466
31328
|
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
31467
31329
|
},
|
|
31330
|
+
|
|
31468
31331
|
getPrototypeOf: function getPrototypeOf(target) {
|
|
31469
31332
|
return Object.getPrototypeOf(target.base);
|
|
31470
31333
|
},
|
|
31334
|
+
|
|
31471
31335
|
setPrototypeOf: function setPrototypeOf() {
|
|
31472
31336
|
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
31473
31337
|
}
|
|
31338
|
+
|
|
31474
31339
|
};
|
|
31475
31340
|
var arrayTraps = {};
|
|
31476
31341
|
each(objectTraps, function (key, fn) {
|
|
@@ -31509,10 +31374,7 @@ function peek$1(draft, prop) {
|
|
|
31509
31374
|
}
|
|
31510
31375
|
|
|
31511
31376
|
function get$1(state, prop) {
|
|
31512
|
-
if (prop === DRAFT_STATE) {
|
|
31513
|
-
return state;
|
|
31514
|
-
}
|
|
31515
|
-
|
|
31377
|
+
if (prop === DRAFT_STATE) { return state; }
|
|
31516
31378
|
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
31517
31379
|
|
|
31518
31380
|
if (!state.modified && has(drafts, prop)) {
|
|
@@ -31528,10 +31390,7 @@ function get$1(state, prop) {
|
|
|
31528
31390
|
|
|
31529
31391
|
if (state.modified) {
|
|
31530
31392
|
// 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
|
-
|
|
31393
|
+
if (value !== peek$1(state.base, prop)) { return value; } // Store drafts on the copy (when one exists).
|
|
31535
31394
|
|
|
31536
31395
|
drafts = state.copy;
|
|
31537
31396
|
}
|
|
@@ -31546,11 +31405,7 @@ function set$1(state, prop, value) {
|
|
|
31546
31405
|
// values may be drafts, but falsy values are never drafts.
|
|
31547
31406
|
|
|
31548
31407
|
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
|
-
|
|
31408
|
+
if (isUnchanged) { return true; }
|
|
31554
31409
|
markChanged$1(state);
|
|
31555
31410
|
}
|
|
31556
31411
|
|
|
@@ -31569,10 +31424,7 @@ function deleteProperty(state, prop) {
|
|
|
31569
31424
|
delete state.assigned[prop];
|
|
31570
31425
|
}
|
|
31571
31426
|
|
|
31572
|
-
if (state.copy) {
|
|
31573
|
-
delete state.copy[prop];
|
|
31574
|
-
}
|
|
31575
|
-
|
|
31427
|
+
if (state.copy) { delete state.copy[prop]; }
|
|
31576
31428
|
return true;
|
|
31577
31429
|
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
31578
31430
|
// the same guarantee in ES5 mode.
|
|
@@ -31595,16 +31447,13 @@ function markChanged$1(state) {
|
|
|
31595
31447
|
state.modified = true;
|
|
31596
31448
|
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
31597
31449
|
state.drafts = null;
|
|
31598
|
-
|
|
31599
|
-
if (state.parent) {
|
|
31600
|
-
markChanged$1(state.parent);
|
|
31601
|
-
}
|
|
31450
|
+
if (state.parent) { markChanged$1(state.parent); }
|
|
31602
31451
|
}
|
|
31603
31452
|
}
|
|
31604
31453
|
|
|
31605
31454
|
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
31606
|
-
|
|
31607
|
-
|
|
31455
|
+
willFinalize: willFinalize$1,
|
|
31456
|
+
createProxy: createProxy$1
|
|
31608
31457
|
});
|
|
31609
31458
|
|
|
31610
31459
|
function generatePatches(state, basePath, patches, inversePatches) {
|
|
@@ -31613,13 +31462,14 @@ function generatePatches(state, basePath, patches, inversePatches) {
|
|
|
31613
31462
|
|
|
31614
31463
|
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
31615
31464
|
var assign, assign$1;
|
|
31465
|
+
|
|
31616
31466
|
var base = state.base;
|
|
31617
31467
|
var copy = state.copy;
|
|
31618
31468
|
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
31619
31469
|
|
|
31620
31470
|
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];
|
|
31471
|
+
(assign = [copy, base], base = assign[0], copy = assign[1]);
|
|
31472
|
+
(assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1]);
|
|
31623
31473
|
}
|
|
31624
31474
|
|
|
31625
31475
|
var delta = copy.length - base.length; // Find the first replaced index.
|
|
@@ -31677,11 +31527,7 @@ function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
|
31677
31527
|
var origValue = base[key];
|
|
31678
31528
|
var value = copy[key];
|
|
31679
31529
|
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
31680
|
-
|
|
31681
|
-
if (origValue === value && op === "replace") {
|
|
31682
|
-
return;
|
|
31683
|
-
}
|
|
31684
|
-
|
|
31530
|
+
if (origValue === value && op === "replace") { return; }
|
|
31685
31531
|
var path = basePath.concat(key);
|
|
31686
31532
|
patches.push(op === "remove" ? {
|
|
31687
31533
|
op: op,
|
|
@@ -31706,26 +31552,20 @@ function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
|
31706
31552
|
});
|
|
31707
31553
|
}
|
|
31708
31554
|
|
|
31709
|
-
var applyPatches = function
|
|
31555
|
+
var applyPatches = function (draft, patches) {
|
|
31710
31556
|
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
31711
31557
|
var patch = list[i$1];
|
|
31558
|
+
|
|
31712
31559
|
var path = patch.path;
|
|
31713
31560
|
var op = patch.op;
|
|
31714
31561
|
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
31715
31562
|
|
|
31716
|
-
if (!path.length) {
|
|
31717
|
-
throw new Error("Illegal state");
|
|
31718
|
-
}
|
|
31719
|
-
|
|
31563
|
+
if (!path.length) { throw new Error("Illegal state"); }
|
|
31720
31564
|
var base = draft;
|
|
31721
31565
|
|
|
31722
31566
|
for (var i = 0; i < path.length - 1; i++) {
|
|
31723
31567
|
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
|
-
|
|
31568
|
+
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
31729
31569
|
}
|
|
31730
31570
|
|
|
31731
31571
|
var key = path[path.length - 1];
|
|
@@ -31774,33 +31614,27 @@ var configDefaults = {
|
|
|
31774
31614
|
onDelete: null,
|
|
31775
31615
|
onCopy: null
|
|
31776
31616
|
};
|
|
31777
|
-
|
|
31778
31617
|
var Immer = function Immer(config) {
|
|
31779
31618
|
assign(this, configDefaults, config);
|
|
31780
31619
|
this.setUseProxies(this.useProxies);
|
|
31781
31620
|
this.produce = this.produce.bind(this);
|
|
31782
31621
|
};
|
|
31783
31622
|
|
|
31784
|
-
Immer.prototype.produce = function produce(base, recipe, patchListener) {
|
|
31785
|
-
|
|
31623
|
+
Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
31624
|
+
var this$1 = this;
|
|
31786
31625
|
|
|
31626
|
+
// curried invocation
|
|
31787
31627
|
if (typeof base === "function" && typeof recipe !== "function") {
|
|
31788
31628
|
var defaultBase = recipe;
|
|
31789
31629
|
recipe = base;
|
|
31790
31630
|
var self = this;
|
|
31791
31631
|
return function curriedProduce(base) {
|
|
31792
|
-
|
|
31793
|
-
|
|
31794
|
-
|
|
31795
|
-
|
|
31632
|
+
var this$1 = this;
|
|
31633
|
+
if ( base === void 0 ) base = defaultBase;
|
|
31634
|
+
var args = [], len = arguments.length - 1;
|
|
31635
|
+
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
31796
31636
|
|
|
31797
|
-
|
|
31798
|
-
args[len] = arguments[len + 1];
|
|
31799
|
-
}
|
|
31800
|
-
|
|
31801
|
-
return self.produce(base, function (draft) {
|
|
31802
|
-
return recipe.call.apply(recipe, [this$1, draft].concat(args));
|
|
31803
|
-
}); // prettier-ignore
|
|
31637
|
+
return self.produce(base, function (draft) { return recipe.call.apply(recipe, [ this$1, draft ].concat( args )); }); // prettier-ignore
|
|
31804
31638
|
};
|
|
31805
31639
|
} // prettier-ignore
|
|
31806
31640
|
|
|
@@ -31826,11 +31660,7 @@ Immer.prototype.produce = function produce(base, recipe, patchListener) {
|
|
|
31826
31660
|
hasError = false;
|
|
31827
31661
|
} finally {
|
|
31828
31662
|
// finally instead of catch + rethrow better preserves original stack
|
|
31829
|
-
if (hasError) {
|
|
31830
|
-
scope.revoke();
|
|
31831
|
-
} else {
|
|
31832
|
-
scope.leave();
|
|
31833
|
-
}
|
|
31663
|
+
if (hasError) { scope.revoke(); }else { scope.leave(); }
|
|
31834
31664
|
}
|
|
31835
31665
|
|
|
31836
31666
|
if (result instanceof Promise) {
|
|
@@ -31847,38 +31677,25 @@ Immer.prototype.produce = function produce(base, recipe, patchListener) {
|
|
|
31847
31677
|
return this.processResult(result, scope);
|
|
31848
31678
|
} else {
|
|
31849
31679
|
result = recipe(base);
|
|
31850
|
-
|
|
31851
|
-
if (result === undefined) {
|
|
31852
|
-
return base;
|
|
31853
|
-
}
|
|
31854
|
-
|
|
31680
|
+
if (result === undefined) { return base; }
|
|
31855
31681
|
return result !== NOTHING ? result : undefined;
|
|
31856
31682
|
}
|
|
31857
31683
|
};
|
|
31858
31684
|
|
|
31859
|
-
Immer.prototype.produceWithPatches = function produceWithPatches(arg1, arg2, arg3) {
|
|
31860
|
-
|
|
31685
|
+
Immer.prototype.produceWithPatches = function produceWithPatches (arg1, arg2, arg3) {
|
|
31686
|
+
var this$1 = this;
|
|
31861
31687
|
|
|
31862
31688
|
if (typeof arg1 === "function") {
|
|
31863
31689
|
return function (state) {
|
|
31864
|
-
|
|
31865
|
-
|
|
31866
|
-
|
|
31867
|
-
while (len-- > 0) {
|
|
31868
|
-
args[len] = arguments[len + 1];
|
|
31869
|
-
}
|
|
31690
|
+
var args = [], len = arguments.length - 1;
|
|
31691
|
+
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
31870
31692
|
|
|
31871
|
-
|
|
31872
|
-
|
|
31873
|
-
});
|
|
31874
|
-
};
|
|
31693
|
+
return this$1.produceWithPatches(state, function (draft) { return arg1.apply(void 0, [ draft ].concat( args )); });
|
|
31694
|
+
};
|
|
31875
31695
|
} // non-curried form
|
|
31876
31696
|
|
|
31877
31697
|
|
|
31878
|
-
if (arg3) {
|
|
31879
|
-
throw new Error("A patch listener cannot be passed to produceWithPatches");
|
|
31880
|
-
}
|
|
31881
|
-
|
|
31698
|
+
if (arg3) { throw new Error("A patch listener cannot be passed to produceWithPatches"); }
|
|
31882
31699
|
var patches, inversePatches;
|
|
31883
31700
|
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
31884
31701
|
patches = p;
|
|
@@ -31887,7 +31704,7 @@ Immer.prototype.produceWithPatches = function produceWithPatches(arg1, arg2, arg
|
|
|
31887
31704
|
return [nextState, patches, inversePatches];
|
|
31888
31705
|
};
|
|
31889
31706
|
|
|
31890
|
-
Immer.prototype.createDraft = function createDraft(base) {
|
|
31707
|
+
Immer.prototype.createDraft = function createDraft (base) {
|
|
31891
31708
|
if (!isDraftable(base)) {
|
|
31892
31709
|
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
31893
31710
|
}
|
|
@@ -31899,7 +31716,7 @@ Immer.prototype.createDraft = function createDraft(base) {
|
|
|
31899
31716
|
return proxy;
|
|
31900
31717
|
};
|
|
31901
31718
|
|
|
31902
|
-
Immer.prototype.finishDraft = function finishDraft(draft, patchListener) {
|
|
31719
|
+
Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
31903
31720
|
var state = draft && draft[DRAFT_STATE];
|
|
31904
31721
|
|
|
31905
31722
|
if (!state || !state.isManual) {
|
|
@@ -31915,16 +31732,16 @@ Immer.prototype.finishDraft = function finishDraft(draft, patchListener) {
|
|
|
31915
31732
|
return this.processResult(undefined, scope);
|
|
31916
31733
|
};
|
|
31917
31734
|
|
|
31918
|
-
Immer.prototype.setAutoFreeze = function setAutoFreeze(value) {
|
|
31735
|
+
Immer.prototype.setAutoFreeze = function setAutoFreeze (value) {
|
|
31919
31736
|
this.autoFreeze = value;
|
|
31920
31737
|
};
|
|
31921
31738
|
|
|
31922
|
-
Immer.prototype.setUseProxies = function setUseProxies(value) {
|
|
31739
|
+
Immer.prototype.setUseProxies = function setUseProxies (value) {
|
|
31923
31740
|
this.useProxies = value;
|
|
31924
31741
|
assign(this, value ? modernProxy : legacyProxy);
|
|
31925
31742
|
};
|
|
31926
31743
|
|
|
31927
|
-
Immer.prototype.applyPatches = function applyPatches$1(base, patches) {
|
|
31744
|
+
Immer.prototype.applyPatches = function applyPatches$1 (base, patches) {
|
|
31928
31745
|
// If a patch replaces the entire state, take that replacement as base
|
|
31929
31746
|
// before applying patches
|
|
31930
31747
|
var i;
|
|
@@ -31944,14 +31761,12 @@ Immer.prototype.applyPatches = function applyPatches$1(base, patches) {
|
|
|
31944
31761
|
} // Otherwise, produce a copy of the base state.
|
|
31945
31762
|
|
|
31946
31763
|
|
|
31947
|
-
return this.produce(base, function (draft) {
|
|
31948
|
-
return applyPatches(draft, patches.slice(i + 1));
|
|
31949
|
-
});
|
|
31764
|
+
return this.produce(base, function (draft) { return applyPatches(draft, patches.slice(i + 1)); });
|
|
31950
31765
|
};
|
|
31951
31766
|
/** @internal */
|
|
31952
31767
|
|
|
31953
31768
|
|
|
31954
|
-
Immer.prototype.processResult = function processResult(result, scope) {
|
|
31769
|
+
Immer.prototype.processResult = function processResult (result, scope) {
|
|
31955
31770
|
var baseDraft = scope.drafts[0];
|
|
31956
31771
|
var isReplaced = result !== undefined && result !== baseDraft;
|
|
31957
31772
|
this.willFinalize(scope, result, isReplaced);
|
|
@@ -31999,15 +31814,13 @@ Immer.prototype.processResult = function processResult(result, scope) {
|
|
|
31999
31814
|
*/
|
|
32000
31815
|
|
|
32001
31816
|
|
|
32002
|
-
Immer.prototype.finalize = function finalize(draft, path, scope) {
|
|
32003
|
-
|
|
31817
|
+
Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
31818
|
+
var this$1 = this;
|
|
31819
|
+
|
|
32004
31820
|
var state = draft[DRAFT_STATE];
|
|
32005
31821
|
|
|
32006
31822
|
if (!state) {
|
|
32007
|
-
if (Object.isFrozen(draft)) {
|
|
32008
|
-
return draft;
|
|
32009
|
-
}
|
|
32010
|
-
|
|
31823
|
+
if (Object.isFrozen(draft)) { return draft; }
|
|
32011
31824
|
return this.finalizeTree(draft, null, scope);
|
|
32012
31825
|
} // Never finalize drafts owned by another scope.
|
|
32013
31826
|
|
|
@@ -32030,17 +31843,13 @@ Immer.prototype.finalize = function finalize(draft, path, scope) {
|
|
|
32030
31843
|
var assigned = state.assigned;
|
|
32031
31844
|
|
|
32032
31845
|
for (var prop in assigned) {
|
|
32033
|
-
if (!assigned[prop]) {
|
|
32034
|
-
this.onDelete(state, prop);
|
|
32035
|
-
}
|
|
31846
|
+
if (!assigned[prop]) { this.onDelete(state, prop); }
|
|
32036
31847
|
}
|
|
32037
31848
|
} else {
|
|
32038
31849
|
var base = state.base;
|
|
32039
|
-
|
|
31850
|
+
var copy = state.copy;
|
|
32040
31851
|
each(base, function (prop) {
|
|
32041
|
-
if (!has(copy, prop)) {
|
|
32042
|
-
this$1.onDelete(state, prop);
|
|
32043
|
-
}
|
|
31852
|
+
if (!has(copy, prop)) { this$1.onDelete(state, prop); }
|
|
32044
31853
|
});
|
|
32045
31854
|
}
|
|
32046
31855
|
}
|
|
@@ -32068,8 +31877,9 @@ Immer.prototype.finalize = function finalize(draft, path, scope) {
|
|
|
32068
31877
|
*/
|
|
32069
31878
|
|
|
32070
31879
|
|
|
32071
|
-
Immer.prototype.finalizeTree = function finalizeTree(root, rootPath, scope) {
|
|
32072
|
-
|
|
31880
|
+
Immer.prototype.finalizeTree = function finalizeTree (root, rootPath, scope) {
|
|
31881
|
+
var this$1 = this;
|
|
31882
|
+
|
|
32073
31883
|
var state = root[DRAFT_STATE];
|
|
32074
31884
|
|
|
32075
31885
|
if (state) {
|
|
@@ -32083,7 +31893,7 @@ Immer.prototype.finalizeTree = function finalizeTree(root, rootPath, scope) {
|
|
|
32083
31893
|
|
|
32084
31894
|
var needPatches = !!rootPath && !!scope.patches;
|
|
32085
31895
|
|
|
32086
|
-
var finalizeProperty = function
|
|
31896
|
+
var finalizeProperty = function (prop, value, parent) {
|
|
32087
31897
|
if (value === parent) {
|
|
32088
31898
|
throw Error("Immer forbids circular references");
|
|
32089
31899
|
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
@@ -32110,9 +31920,7 @@ Immer.prototype.finalizeTree = function finalizeTree(root, rootPath, scope) {
|
|
|
32110
31920
|
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
32111
31921
|
|
|
32112
31922
|
|
|
32113
|
-
if (isDraftProp && value === state.base[prop]) {
|
|
32114
|
-
return;
|
|
32115
|
-
}
|
|
31923
|
+
if (isDraftProp && value === state.base[prop]) { return; }
|
|
32116
31924
|
} // Unchanged draft properties are ignored.
|
|
32117
31925
|
else if (isDraftProp && is(value, state.base[prop])) {
|
|
32118
31926
|
return;
|
|
@@ -32197,149 +32005,103 @@ var createDraft = immer.createDraft.bind(immer);
|
|
|
32197
32005
|
|
|
32198
32006
|
var finishDraft = immer.finishDraft.bind(immer);
|
|
32199
32007
|
|
|
32200
|
-
|
|
32201
|
-
|
|
32202
|
-
|
|
32203
|
-
|
|
32204
|
-
for (var _i = 0, _formConfigKeys = formConfigKeys; _i < _formConfigKeys.length; _i++) {
|
|
32205
|
-
var formKey = _formConfigKeys[_i];
|
|
32008
|
+
const createInitialState = formConfig => {
|
|
32009
|
+
let initialForm = {};
|
|
32010
|
+
const formConfigKeys = Object.keys(formConfig);
|
|
32011
|
+
for (let formKey of formConfigKeys) {
|
|
32206
32012
|
initialForm[formKey] = {
|
|
32207
32013
|
dirty: false,
|
|
32208
32014
|
rawValue: formConfig[formKey].defaultValue || "",
|
|
32209
32015
|
validators: formConfig[formKey].validators || [],
|
|
32210
32016
|
constraints: formConfig[formKey].constraints || []
|
|
32211
32017
|
};
|
|
32212
|
-
}
|
|
32018
|
+
}
|
|
32019
|
+
// Because validators require the entire form we have to do a
|
|
32213
32020
|
// second pass to add errors once the initial form has been
|
|
32214
32021
|
// constructed
|
|
32215
|
-
|
|
32216
|
-
|
|
32217
|
-
|
|
32218
|
-
|
|
32219
|
-
var errors = computeErrors(_formKey, initialForm);
|
|
32220
|
-
initialForm[_formKey].errors = errors;
|
|
32221
|
-
initialForm[_formKey].hasErrors = errors.length > 0;
|
|
32022
|
+
for (let formKey of formConfigKeys) {
|
|
32023
|
+
let errors = computeErrors(formKey, initialForm);
|
|
32024
|
+
initialForm[formKey].errors = errors;
|
|
32025
|
+
initialForm[formKey].hasErrors = errors.length > 0;
|
|
32222
32026
|
}
|
|
32223
|
-
|
|
32224
32027
|
return initialForm;
|
|
32225
32028
|
};
|
|
32226
32029
|
|
|
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
|
-
});
|
|
32030
|
+
const SET = "field/SET";
|
|
32031
|
+
const set$2 = fieldName => value => ({
|
|
32032
|
+
type: SET,
|
|
32033
|
+
payload: { fieldName, value }
|
|
32034
|
+
});
|
|
32281
32035
|
|
|
32282
|
-
|
|
32283
|
-
|
|
32036
|
+
const CLEAR = "form/CLEAR";
|
|
32037
|
+
const clear = () => ({ type: CLEAR });
|
|
32038
|
+
|
|
32039
|
+
const createFormReducer = formConfig => (
|
|
32040
|
+
state = createInitialState(formConfig),
|
|
32041
|
+
action
|
|
32042
|
+
) => {
|
|
32043
|
+
switch (action.type) {
|
|
32044
|
+
case SET:
|
|
32045
|
+
const changedFieldName = action.payload.fieldName;
|
|
32046
|
+
const newRawValue = action.payload.value;
|
|
32047
|
+
|
|
32048
|
+
return produce(state, draftState => {
|
|
32049
|
+
let originalValue = draftState[changedFieldName].rawValue;
|
|
32050
|
+
draftState[changedFieldName].rawValue = newRawValue;
|
|
32051
|
+
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
32052
|
+
// If the change violates constraints, revert the change
|
|
32053
|
+
draftState[changedFieldName].rawValue = originalValue;
|
|
32054
|
+
return draftState;
|
|
32055
|
+
}
|
|
32284
32056
|
|
|
32285
|
-
|
|
32286
|
-
|
|
32287
|
-
|
|
32288
|
-
|
|
32057
|
+
const fields = Object.entries(draftState);
|
|
32058
|
+
for (let entry of fields) {
|
|
32059
|
+
let fieldName = entry[0];
|
|
32060
|
+
let field = entry[1];
|
|
32061
|
+
let errors = computeErrors(fieldName, draftState);
|
|
32062
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
32063
|
+
draftState[fieldName].errors = errors;
|
|
32064
|
+
draftState[fieldName].dirty = dirty;
|
|
32065
|
+
draftState[fieldName].hasErrors = errors.length > 0;
|
|
32066
|
+
}
|
|
32067
|
+
});
|
|
32068
|
+
case CLEAR:
|
|
32069
|
+
return createInitialState(formConfig);
|
|
32070
|
+
default:
|
|
32071
|
+
return state;
|
|
32072
|
+
}
|
|
32289
32073
|
};
|
|
32290
32074
|
|
|
32291
|
-
|
|
32075
|
+
const createMapDispatchToProps = formConfig => {
|
|
32292
32076
|
// Do memo-ization
|
|
32293
|
-
|
|
32294
|
-
|
|
32295
|
-
return
|
|
32077
|
+
let cachedDispatch;
|
|
32078
|
+
let cacheValue;
|
|
32079
|
+
return dispatch => {
|
|
32296
32080
|
if (dispatch == cachedDispatch) {
|
|
32297
32081
|
return cacheValue;
|
|
32298
32082
|
}
|
|
32299
|
-
|
|
32300
|
-
var dispatchObj = {};
|
|
32083
|
+
let dispatchObj = {};
|
|
32301
32084
|
dispatchObj.fields = {};
|
|
32302
|
-
|
|
32303
|
-
|
|
32304
|
-
var _loop = function _loop() {
|
|
32305
|
-
var fieldName = _keys[_i4];
|
|
32085
|
+
const keys = Object.keys(formConfig);
|
|
32086
|
+
for (let fieldName of keys) {
|
|
32306
32087
|
dispatchObj.fields[fieldName] = {
|
|
32307
|
-
set:
|
|
32308
|
-
return dispatch(set$2(fieldName)(value));
|
|
32309
|
-
}
|
|
32088
|
+
set: value => dispatch(set$2(fieldName)(value))
|
|
32310
32089
|
};
|
|
32311
|
-
};
|
|
32312
|
-
|
|
32313
|
-
for (var _i4 = 0, _keys = keys; _i4 < _keys.length; _i4++) {
|
|
32314
|
-
_loop();
|
|
32315
32090
|
}
|
|
32316
|
-
|
|
32317
|
-
dispatchObj.form = {
|
|
32318
|
-
clear: function clear() {
|
|
32319
|
-
return dispatch(_clear());
|
|
32320
|
-
}
|
|
32321
|
-
};
|
|
32091
|
+
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
32322
32092
|
cachedDispatch = dispatch;
|
|
32323
|
-
cacheValue = {
|
|
32324
|
-
actions: dispatchObj
|
|
32325
|
-
};
|
|
32093
|
+
cacheValue = { actions: dispatchObj };
|
|
32326
32094
|
return cacheValue;
|
|
32327
32095
|
};
|
|
32328
32096
|
};
|
|
32329
32097
|
|
|
32330
|
-
|
|
32331
|
-
return {
|
|
32332
|
-
fields: state
|
|
32333
|
-
};
|
|
32334
|
-
};
|
|
32098
|
+
const mapStateToProps = state => ({ fields: state });
|
|
32335
32099
|
|
|
32336
|
-
|
|
32337
|
-
|
|
32338
|
-
|
|
32339
|
-
|
|
32340
|
-
|
|
32341
|
-
};
|
|
32342
|
-
};
|
|
32100
|
+
const createFormState = formConfig => ({
|
|
32101
|
+
reducer: createFormReducer(formConfig),
|
|
32102
|
+
mapDispatchToProps: createMapDispatchToProps(formConfig),
|
|
32103
|
+
mapStateToProps: mapStateToProps
|
|
32104
|
+
});
|
|
32343
32105
|
|
|
32344
32106
|
var formatDelimiter = "_";
|
|
32345
32107
|
var phoneFormats = ["", "_", "__", "(___) ", "(___) _", "(___) __", "(___) ___-", "(___) ___-_", "(___) ___-__", "(___) ___-___", "(___) ___-____"];
|
|
@@ -36360,7 +36122,8 @@ var PaymentDetailsActions = function PaymentDetailsActions(_ref) {
|
|
|
36360
36122
|
|
|
36361
36123
|
var obligationSlug = config.obligationSlug;
|
|
36362
36124
|
var createPaymentFromProfile = actions.createPaymentFromProfile,
|
|
36363
|
-
setDetailedObligation = actions.setDetailedObligation
|
|
36125
|
+
setDetailedObligation = actions.setDetailedObligation,
|
|
36126
|
+
navigateToDetailedObligation = actions.navigateToDetailedObligation;
|
|
36364
36127
|
var detailsSlug = config.type === "ACCOUNT" ? "/profile/accounts/details/".concat(obligationSlug) : "/profile/properties/details/".concat(obligationSlug);
|
|
36365
36128
|
|
|
36366
36129
|
var handleClick = function handleClick(obligations) {
|
|
@@ -36369,7 +36132,8 @@ var PaymentDetailsActions = function PaymentDetailsActions(_ref) {
|
|
|
36369
36132
|
};
|
|
36370
36133
|
|
|
36371
36134
|
var handleDetailsClick = function handleDetailsClick() {
|
|
36372
|
-
setDetailedObligation(obligations, config
|
|
36135
|
+
setDetailedObligation(obligations, config);
|
|
36136
|
+
navigateToDetailedObligation(detailsSlug);
|
|
36373
36137
|
};
|
|
36374
36138
|
|
|
36375
36139
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
@@ -36433,7 +36197,10 @@ var PaymentDetailsActions = function PaymentDetailsActions(_ref) {
|
|
|
36433
36197
|
}, autoPayAvailable && !autoPayEnabled ? /*#__PURE__*/React__default.createElement(ButtonWithAction, {
|
|
36434
36198
|
variant: "tertiary",
|
|
36435
36199
|
text: "Set Up Autopay",
|
|
36436
|
-
action:
|
|
36200
|
+
action: function action() {
|
|
36201
|
+
setDetailedObligation(obligations, config);
|
|
36202
|
+
handleAutopayAction();
|
|
36203
|
+
},
|
|
36437
36204
|
dataQa: "Set Up Autopay",
|
|
36438
36205
|
extraStyles: isMobile && "flex-grow: 1; width: 100%;"
|
|
36439
36206
|
}) : /*#__PURE__*/React__default.createElement(AutopayModalModule, {
|