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