@thecb/components 3.4.0 → 3.4.1
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,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
|
|
|
@@ -30373,345 +30430,401 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
|
|
|
30373
30430
|
|
|
30374
30431
|
var ToggleSwitch$1 = themeComponent(ToggleSwitch, "ToggleSwitch", fallbackValues$o);
|
|
30375
30432
|
|
|
30376
|
-
|
|
30377
|
-
value
|
|
30378
|
-
|
|
30379
|
-
|
|
30433
|
+
var validatorToPredicate = function validatorToPredicate(validatorFn, emptyCase) {
|
|
30434
|
+
return function (value) {
|
|
30435
|
+
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
30436
|
+
rest[_key - 1] = arguments[_key];
|
|
30437
|
+
}
|
|
30380
30438
|
|
|
30439
|
+
return value === "" ? emptyCase : validatorFn.apply(void 0, [value].concat(rest));
|
|
30440
|
+
};
|
|
30441
|
+
};
|
|
30381
30442
|
/* eslint-disable no-unused-vars */
|
|
30382
30443
|
|
|
30383
|
-
|
|
30384
|
-
|
|
30444
|
+
|
|
30445
|
+
var createValidator = function createValidator(type, error) {
|
|
30446
|
+
var validator = function validator() {
|
|
30447
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
30448
|
+
args[_key2] = arguments[_key2];
|
|
30449
|
+
}
|
|
30450
|
+
|
|
30451
|
+
return {
|
|
30452
|
+
type: type,
|
|
30453
|
+
args: args,
|
|
30454
|
+
error: error
|
|
30455
|
+
};
|
|
30456
|
+
};
|
|
30457
|
+
|
|
30385
30458
|
validator.error = error;
|
|
30386
30459
|
return validator;
|
|
30387
30460
|
};
|
|
30388
30461
|
|
|
30389
|
-
|
|
30462
|
+
var validatorFns = {};
|
|
30463
|
+
var REQUIRED = "validator/REQUIRED";
|
|
30464
|
+
var REQUIRED_ERROR = "error/REQUIRED";
|
|
30465
|
+
var required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
30390
30466
|
|
|
30391
|
-
|
|
30392
|
-
|
|
30393
|
-
|
|
30394
|
-
validatorFns[REQUIRED] = (value, args, form) => value !== "";
|
|
30467
|
+
validatorFns[REQUIRED] = function (value, args, form) {
|
|
30468
|
+
return value !== "";
|
|
30469
|
+
};
|
|
30395
30470
|
|
|
30396
|
-
|
|
30397
|
-
|
|
30398
|
-
|
|
30399
|
-
validatorFns[ONLY_INTEGERS] = (value, args, form) => /^(-?\d+)?$/.test(value);
|
|
30471
|
+
var ONLY_INTEGERS = "validator/ONLY_INTEGERS";
|
|
30472
|
+
var ONLY_INTEGERS_ERROR = "error/ONLY_INTEGERS";
|
|
30473
|
+
var onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
30400
30474
|
|
|
30401
|
-
|
|
30402
|
-
|
|
30403
|
-
|
|
30404
|
-
validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
|
|
30475
|
+
validatorFns[ONLY_INTEGERS] = function (value, args, form) {
|
|
30476
|
+
return /^(-?\d+)?$/.test(value);
|
|
30477
|
+
};
|
|
30405
30478
|
|
|
30406
|
-
|
|
30407
|
-
|
|
30408
|
-
|
|
30409
|
-
|
|
30410
|
-
|
|
30411
|
-
);
|
|
30412
|
-
|
|
30479
|
+
var ONLY_NATURALS = "validator/ONLY_NATURALS";
|
|
30480
|
+
var ONLY_NATURALS_ERROR = "error/ONLY_NATURALS";
|
|
30481
|
+
var onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
30482
|
+
|
|
30483
|
+
validatorFns[ONLY_NATURALS] = function (value, args, form) {
|
|
30484
|
+
return /^(\d+)?$/.test(value);
|
|
30485
|
+
};
|
|
30486
|
+
|
|
30487
|
+
var NUMBER_LESS_THAN = "validator/NUMBER_LESS_THAN";
|
|
30488
|
+
var NUMBER_LESS_THAN_ERROR = "error/NUMBER_LESS_THAN";
|
|
30489
|
+
var numberLessThan = createValidator(NUMBER_LESS_THAN, NUMBER_LESS_THAN_ERROR);
|
|
30490
|
+
|
|
30491
|
+
validatorFns[NUMBER_LESS_THAN] = function (value, args, form) {
|
|
30413
30492
|
if (value === "") {
|
|
30414
30493
|
return true;
|
|
30415
30494
|
}
|
|
30495
|
+
|
|
30416
30496
|
return Number(value) < args[0];
|
|
30417
30497
|
};
|
|
30418
30498
|
|
|
30419
|
-
|
|
30420
|
-
|
|
30421
|
-
|
|
30422
|
-
|
|
30423
|
-
|
|
30424
|
-
)
|
|
30425
|
-
|
|
30499
|
+
var NUMBER_LESS_THAN_OR_EQUAL_TO = "validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
30500
|
+
var NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR = "error/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
30501
|
+
var numberLessThanOrEqualTo = createValidator(NUMBER_LESS_THAN_OR_EQUAL_TO, NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR);
|
|
30502
|
+
|
|
30503
|
+
validatorFns[NUMBER_LESS_THAN_OR_EQUAL_TO] = function (value, args, form) {
|
|
30504
|
+
if (value === "") {
|
|
30505
|
+
return true;
|
|
30506
|
+
}
|
|
30507
|
+
|
|
30508
|
+
return Number(value) <= args[0];
|
|
30509
|
+
};
|
|
30510
|
+
|
|
30511
|
+
var NUMBER_GREATER_THAN = "validator/NUMBER_GREATER_THAN";
|
|
30512
|
+
var NUMBER_GREATER_THAN_ERROR = "error/NUMBER_GREATER_THAN";
|
|
30513
|
+
var numberGreaterThan = createValidator(NUMBER_GREATER_THAN, NUMBER_GREATER_THAN_ERROR);
|
|
30514
|
+
|
|
30515
|
+
validatorFns[NUMBER_GREATER_THAN] = function (value, args, form) {
|
|
30426
30516
|
if (value === "") {
|
|
30427
30517
|
return true;
|
|
30428
30518
|
}
|
|
30519
|
+
|
|
30429
30520
|
return Number(value) > args[0];
|
|
30430
30521
|
};
|
|
30431
30522
|
|
|
30432
|
-
|
|
30433
|
-
|
|
30434
|
-
|
|
30435
|
-
|
|
30523
|
+
var NUMBER_GREATER_THAN_OR_EQUAL_TO = "validator/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
30524
|
+
var NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR = "error/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
30525
|
+
var numberGreaterThanOrEqualTo = createValidator(NUMBER_GREATER_THAN_OR_EQUAL_TO, NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR);
|
|
30526
|
+
|
|
30527
|
+
validatorFns[NUMBER_GREATER_THAN_OR_EQUAL_TO] = function (value, args, form) {
|
|
30528
|
+
if (value === "") {
|
|
30529
|
+
return true;
|
|
30530
|
+
}
|
|
30531
|
+
|
|
30532
|
+
return Number(value) >= args[0];
|
|
30533
|
+
};
|
|
30534
|
+
|
|
30535
|
+
var MATCHES_FIELD = "validator/MATCHES_FIELD";
|
|
30536
|
+
var MATCHES_FIELD_ERROR$1 = "error/MATCHES_FIELD";
|
|
30537
|
+
var matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
|
|
30538
|
+
|
|
30539
|
+
validatorFns[MATCHES_FIELD] = function (value, args, form) {
|
|
30436
30540
|
if (value === "") {
|
|
30437
30541
|
return true;
|
|
30438
30542
|
}
|
|
30543
|
+
|
|
30439
30544
|
if (form[args[0]] === undefined) {
|
|
30440
|
-
throw new Error(
|
|
30441
|
-
`${args[0]} was passed to matchesField, but that field does not exist in the form`
|
|
30442
|
-
);
|
|
30545
|
+
throw new Error("".concat(args[0], " was passed to matchesField, but that field does not exist in the form"));
|
|
30443
30546
|
}
|
|
30547
|
+
|
|
30444
30548
|
return value === form[args[0]].rawValue;
|
|
30445
30549
|
};
|
|
30446
30550
|
|
|
30447
|
-
|
|
30448
|
-
|
|
30449
|
-
|
|
30450
|
-
|
|
30451
|
-
|
|
30452
|
-
|
|
30453
|
-
|
|
30454
|
-
|
|
30455
|
-
|
|
30456
|
-
|
|
30457
|
-
|
|
30458
|
-
|
|
30459
|
-
|
|
30460
|
-
|
|
30461
|
-
|
|
30462
|
-
type: VALIDATE_WHEN,
|
|
30463
|
-
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
30464
|
-
error: dependentValidator.error
|
|
30465
|
-
});
|
|
30551
|
+
var validateWhenErrorMessage = function validateWhenErrorMessage(type) {
|
|
30552
|
+
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.");
|
|
30553
|
+
};
|
|
30554
|
+
|
|
30555
|
+
var VALIDATE_WHEN = "validator/VALIDATE_WHEN";
|
|
30556
|
+
var VALIDATE_WHEN_ERROR = "error/VALIDATE_WHEN";
|
|
30557
|
+
|
|
30558
|
+
var validateWhen = function validateWhen(dependentValidator, primaryValidator, optionalFieldName) {
|
|
30559
|
+
return {
|
|
30560
|
+
type: VALIDATE_WHEN,
|
|
30561
|
+
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
30562
|
+
error: dependentValidator.error
|
|
30563
|
+
};
|
|
30564
|
+
};
|
|
30565
|
+
|
|
30466
30566
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
30467
|
-
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
30468
|
-
const [dependentValidator, primaryValidator, optionalFieldName] = args;
|
|
30469
|
-
const dependsOnOtherField = typeof optionalFieldName === "string";
|
|
30470
30567
|
|
|
30471
|
-
|
|
30472
|
-
|
|
30473
|
-
|
|
30474
|
-
|
|
30568
|
+
validatorFns[VALIDATE_WHEN] = function (value, args, form) {
|
|
30569
|
+
var _args = _slicedToArray(args, 3),
|
|
30570
|
+
dependentValidator = _args[0],
|
|
30571
|
+
primaryValidator = _args[1],
|
|
30572
|
+
optionalFieldName = _args[2];
|
|
30573
|
+
|
|
30574
|
+
var dependsOnOtherField = typeof optionalFieldName === "string";
|
|
30575
|
+
|
|
30576
|
+
if (primaryValidator.type === undefined || typeof validatorFns[primaryValidator.type] !== "function") {
|
|
30475
30577
|
throw new Error(validateWhenErrorMessage(primaryValidator.type));
|
|
30476
30578
|
}
|
|
30579
|
+
|
|
30477
30580
|
if (dependsOnOtherField && form[optionalFieldName] === undefined) {
|
|
30478
|
-
throw new Error(
|
|
30479
|
-
`${args[2]} was passed to matchesField, but that field does not exist in the form`
|
|
30480
|
-
);
|
|
30581
|
+
throw new Error("".concat(args[2], " was passed to matchesField, but that field does not exist in the form"));
|
|
30481
30582
|
}
|
|
30482
30583
|
|
|
30483
|
-
|
|
30484
|
-
|
|
30485
|
-
|
|
30486
|
-
);
|
|
30487
|
-
|
|
30488
|
-
|
|
30489
|
-
|
|
30490
|
-
|
|
30491
|
-
|
|
30492
|
-
|
|
30493
|
-
|
|
30494
|
-
|
|
30584
|
+
var primaryPredicate = validatorToPredicate(validatorFns[primaryValidator.type], false);
|
|
30585
|
+
var primaryValue = dependsOnOtherField ? form[optionalFieldName].rawValue : value;
|
|
30586
|
+
var primaryPredicatePassed = primaryPredicate(primaryValue, primaryValidator.args, form);
|
|
30587
|
+
return primaryPredicatePassed ? validatorFns[dependentValidator.type](value, dependentValidator.args, form) : true;
|
|
30588
|
+
};
|
|
30589
|
+
|
|
30590
|
+
var validateSumErrorMessage = function validateSumErrorMessage(type) {
|
|
30591
|
+
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).");
|
|
30592
|
+
};
|
|
30593
|
+
|
|
30594
|
+
var VALIDATE_SUM = "validator/VALIDATE_SUM";
|
|
30595
|
+
var VALIDATE_SUM_ERROR = "error/VALIDATE_SUM";
|
|
30596
|
+
|
|
30597
|
+
var validateSum = function validateSum(validator, fieldNamesArray) {
|
|
30598
|
+
return {
|
|
30599
|
+
type: VALIDATE_SUM,
|
|
30600
|
+
args: [validator, fieldNamesArray],
|
|
30601
|
+
error: validator.error
|
|
30602
|
+
};
|
|
30603
|
+
};
|
|
30495
30604
|
|
|
30496
|
-
return primaryPredicatePassed
|
|
30497
|
-
? validatorFns[dependentValidator.type](
|
|
30498
|
-
value,
|
|
30499
|
-
dependentValidator.args,
|
|
30500
|
-
form
|
|
30501
|
-
)
|
|
30502
|
-
: true;
|
|
30503
|
-
};
|
|
30504
|
-
|
|
30505
|
-
const validateSumErrorMessage = type =>
|
|
30506
|
-
`${type} was passed to validateSum, but that validator type does not exist.
|
|
30507
|
-
Please check that you are only calling validator creator functions exported from
|
|
30508
|
-
redux-freeform in your form config and that you didn't forget to
|
|
30509
|
-
invoke the validator creator (you cannot pass the functions themselves to
|
|
30510
|
-
createFormState).`;
|
|
30511
|
-
const VALIDATE_SUM = "validator/VALIDATE_SUM";
|
|
30512
|
-
const VALIDATE_SUM_ERROR = "error/VALIDATE_SUM";
|
|
30513
|
-
const validateSum = (validator, fieldNamesArray) => ({
|
|
30514
|
-
type: VALIDATE_SUM,
|
|
30515
|
-
args: [validator, fieldNamesArray],
|
|
30516
|
-
error: validator.error
|
|
30517
|
-
});
|
|
30518
30605
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
30519
|
-
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
30520
|
-
const [validator, fieldNamesArray] = args;
|
|
30521
30606
|
|
|
30522
|
-
|
|
30523
|
-
|
|
30524
|
-
|
|
30525
|
-
|
|
30607
|
+
validatorFns[VALIDATE_SUM] = function (value, args, form) {
|
|
30608
|
+
var _args2 = _slicedToArray(args, 2),
|
|
30609
|
+
validator = _args2[0],
|
|
30610
|
+
fieldNamesArray = _args2[1];
|
|
30611
|
+
|
|
30612
|
+
if (validator.type === undefined || typeof validatorFns[validator.type] !== "function") {
|
|
30526
30613
|
throw new Error(validateSumErrorMessage(validator.type));
|
|
30527
30614
|
}
|
|
30528
30615
|
|
|
30529
|
-
|
|
30530
|
-
|
|
30531
|
-
|
|
30532
|
-
|
|
30533
|
-
|
|
30616
|
+
var _iterator = _createForOfIteratorHelper(fieldNamesArray),
|
|
30617
|
+
_step;
|
|
30618
|
+
|
|
30619
|
+
try {
|
|
30620
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
30621
|
+
var fieldName = _step.value;
|
|
30622
|
+
|
|
30623
|
+
if (form[fieldName] === undefined) {
|
|
30624
|
+
throw new Error("".concat(fieldName, " was passed to matchesField, but that field does not exist in the form"));
|
|
30625
|
+
}
|
|
30534
30626
|
}
|
|
30627
|
+
} catch (err) {
|
|
30628
|
+
_iterator.e(err);
|
|
30629
|
+
} finally {
|
|
30630
|
+
_iterator.f();
|
|
30535
30631
|
}
|
|
30536
30632
|
|
|
30537
|
-
|
|
30538
|
-
|
|
30539
|
-
|
|
30540
|
-
);
|
|
30541
|
-
|
|
30633
|
+
var sum = fieldNamesArray.reduce(function (acc, curr) {
|
|
30634
|
+
return acc + Number(form[curr].rawValue);
|
|
30635
|
+
}, Number(value));
|
|
30542
30636
|
return validatorFns[validator.type](sum, validator.args, form);
|
|
30543
30637
|
};
|
|
30544
30638
|
|
|
30545
|
-
|
|
30546
|
-
|
|
30547
|
-
|
|
30548
|
-
|
|
30639
|
+
var HAS_LENGTH = "validator/HAS_LENGTH";
|
|
30640
|
+
var HAS_LENGTH_ERROR = "error/HAS_LENGTH";
|
|
30641
|
+
var hasLength = createValidator(HAS_LENGTH, HAS_LENGTH_ERROR);
|
|
30642
|
+
|
|
30643
|
+
validatorFns[HAS_LENGTH] = function (value, args, form) {
|
|
30549
30644
|
if (value === "") {
|
|
30550
30645
|
return true;
|
|
30551
30646
|
}
|
|
30552
|
-
|
|
30553
|
-
|
|
30647
|
+
|
|
30648
|
+
var min = args[0];
|
|
30649
|
+
var max = args[1];
|
|
30650
|
+
|
|
30554
30651
|
if (max == undefined || min == undefined) {
|
|
30555
|
-
throw new Error(
|
|
30556
|
-
"Max and min need to be defined for hasLength, both or one of them is undefined"
|
|
30557
|
-
);
|
|
30652
|
+
throw new Error("Max and min need to be defined for hasLength, both or one of them is undefined");
|
|
30558
30653
|
}
|
|
30654
|
+
|
|
30559
30655
|
if (max < min) {
|
|
30560
|
-
throw new Error(
|
|
30561
|
-
"hasLength validator was passed a min greater than the max"
|
|
30562
|
-
);
|
|
30656
|
+
throw new Error("hasLength validator was passed a min greater than the max");
|
|
30563
30657
|
}
|
|
30564
|
-
|
|
30658
|
+
|
|
30659
|
+
var valueLength = value.length;
|
|
30565
30660
|
return max >= valueLength && valueLength >= min;
|
|
30566
30661
|
};
|
|
30567
30662
|
|
|
30568
|
-
|
|
30569
|
-
|
|
30570
|
-
|
|
30571
|
-
|
|
30663
|
+
var MATCHES_REGEX = "validator/MATCHES_REGEX";
|
|
30664
|
+
var MATCHES_REGEX_ERROR = "error/MATCHES_REGEX";
|
|
30665
|
+
var matchesRegex = createValidator(MATCHES_REGEX, MATCHES_REGEX_ERROR);
|
|
30666
|
+
|
|
30667
|
+
validatorFns[MATCHES_REGEX] = function (value, args, form) {
|
|
30572
30668
|
if (value === "") {
|
|
30573
30669
|
return true;
|
|
30574
30670
|
}
|
|
30671
|
+
|
|
30575
30672
|
return new RegExp(args[0]).test(value); // new RexExp never throws an error, no matter the input
|
|
30576
|
-
};
|
|
30673
|
+
}; // based on http://www.brainjar.com/js/validation/
|
|
30577
30674
|
|
|
30578
|
-
|
|
30579
|
-
|
|
30580
|
-
|
|
30581
|
-
|
|
30582
|
-
|
|
30583
|
-
|
|
30584
|
-
);
|
|
30585
|
-
validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
30675
|
+
|
|
30676
|
+
var IS_ROUTING_NUMBER = "validator/IS_ROUTING_NUMBER";
|
|
30677
|
+
var IS_ROUTING_NUMBER_ERROR = "error/IS_ROUTING_NUMBER";
|
|
30678
|
+
var isRoutingNumber = createValidator(IS_ROUTING_NUMBER, IS_ROUTING_NUMBER_ERROR);
|
|
30679
|
+
|
|
30680
|
+
validatorFns[IS_ROUTING_NUMBER] = function (value, args, form) {
|
|
30586
30681
|
if (value === "") {
|
|
30587
30682
|
return true;
|
|
30588
30683
|
}
|
|
30684
|
+
|
|
30589
30685
|
if (value.length != 9) {
|
|
30590
30686
|
return false;
|
|
30591
30687
|
}
|
|
30592
|
-
|
|
30593
|
-
|
|
30594
|
-
|
|
30595
|
-
|
|
30596
|
-
|
|
30597
|
-
|
|
30598
|
-
|
|
30599
|
-
|
|
30600
|
-
|
|
30601
|
-
|
|
30602
|
-
|
|
30603
|
-
|
|
30604
|
-
|
|
30688
|
+
|
|
30689
|
+
var sum = value.split("").map(function (ch) {
|
|
30690
|
+
return parseInt(ch);
|
|
30691
|
+
}).reduce(function (acc, cur, idx) {
|
|
30692
|
+
switch (idx % 3) {
|
|
30693
|
+
case 0:
|
|
30694
|
+
return acc + 3 * cur;
|
|
30695
|
+
|
|
30696
|
+
case 1:
|
|
30697
|
+
return acc + 7 * cur;
|
|
30698
|
+
|
|
30699
|
+
case 2:
|
|
30700
|
+
return acc + 1 * cur;
|
|
30701
|
+
}
|
|
30702
|
+
}, 0);
|
|
30605
30703
|
return sum != 0 && sum % 10 == 0;
|
|
30606
30704
|
};
|
|
30607
30705
|
|
|
30608
|
-
|
|
30609
|
-
|
|
30610
|
-
|
|
30611
|
-
|
|
30706
|
+
var HAS_NUMBER = "validator/HAS_NUMBER";
|
|
30707
|
+
var HAS_NUMBER_ERROR$1 = "error/HAS_NUMBER";
|
|
30708
|
+
var hasNumber = createValidator(HAS_NUMBER, HAS_NUMBER_ERROR$1);
|
|
30709
|
+
|
|
30710
|
+
validatorFns[HAS_NUMBER] = function (value, args, form) {
|
|
30612
30711
|
if (value === "") {
|
|
30613
30712
|
return true;
|
|
30614
30713
|
}
|
|
30714
|
+
|
|
30615
30715
|
return new RegExp(/[0-9]/).test(value);
|
|
30616
30716
|
};
|
|
30617
30717
|
|
|
30618
|
-
|
|
30619
|
-
|
|
30620
|
-
|
|
30621
|
-
|
|
30622
|
-
|
|
30623
|
-
);
|
|
30624
|
-
validatorFns[HAS_LOWERCASE_LETTER] = (value, args, form) => {
|
|
30718
|
+
var HAS_LOWERCASE_LETTER = "validator/HAS_LOWERCASE_LETTER";
|
|
30719
|
+
var HAS_LOWERCASE_LETTER_ERROR$1 = "error/HAS_LOWERCASE_LETTER";
|
|
30720
|
+
var hasLowercaseLetter = createValidator(HAS_LOWERCASE_LETTER, HAS_LOWERCASE_LETTER_ERROR$1);
|
|
30721
|
+
|
|
30722
|
+
validatorFns[HAS_LOWERCASE_LETTER] = function (value, args, form) {
|
|
30625
30723
|
if (value === "") {
|
|
30626
30724
|
return true;
|
|
30627
30725
|
}
|
|
30726
|
+
|
|
30628
30727
|
return new RegExp(/[a-z]/).test(value);
|
|
30629
30728
|
};
|
|
30630
30729
|
|
|
30631
|
-
|
|
30632
|
-
|
|
30633
|
-
|
|
30634
|
-
|
|
30635
|
-
|
|
30636
|
-
);
|
|
30637
|
-
validatorFns[HAS_UPPERCASE_LETTER] = (value, args, form) => {
|
|
30730
|
+
var HAS_UPPERCASE_LETTER = "validator/HAS_UPPERCASE_LETTER";
|
|
30731
|
+
var HAS_UPPERCASE_LETTER_ERROR$1 = "error/HAS_UPPERCASE_LETTER";
|
|
30732
|
+
var hasUppercaseLetter = createValidator(HAS_UPPERCASE_LETTER, HAS_UPPERCASE_LETTER_ERROR$1);
|
|
30733
|
+
|
|
30734
|
+
validatorFns[HAS_UPPERCASE_LETTER] = function (value, args, form) {
|
|
30638
30735
|
if (value === "") {
|
|
30639
30736
|
return true;
|
|
30640
30737
|
}
|
|
30738
|
+
|
|
30641
30739
|
return new RegExp(/[A-Z]/).test(value);
|
|
30642
30740
|
};
|
|
30643
30741
|
|
|
30644
|
-
|
|
30645
|
-
|
|
30646
|
-
|
|
30647
|
-
|
|
30648
|
-
|
|
30649
|
-
);
|
|
30650
|
-
validatorFns[HAS_SPECIAL_CHARACTER] = (value, args, form) => {
|
|
30742
|
+
var HAS_SPECIAL_CHARACTER = "validator/HAS_SPECIAL_CHARACTER";
|
|
30743
|
+
var HAS_SPECIAL_CHARACTER_ERROR$1 = "error/HAS_SPECIAL_CHARACTER";
|
|
30744
|
+
var hasSpecialCharacter = createValidator(HAS_SPECIAL_CHARACTER, HAS_SPECIAL_CHARACTER_ERROR$1);
|
|
30745
|
+
|
|
30746
|
+
validatorFns[HAS_SPECIAL_CHARACTER] = function (value, args, form) {
|
|
30651
30747
|
if (value === "") {
|
|
30652
30748
|
return true;
|
|
30653
30749
|
}
|
|
30750
|
+
|
|
30654
30751
|
return new RegExp(/[!@#$%^&*.?]/).test(value);
|
|
30655
30752
|
};
|
|
30656
30753
|
|
|
30657
|
-
|
|
30658
|
-
|
|
30659
|
-
|
|
30660
|
-
|
|
30661
|
-
|
|
30662
|
-
);
|
|
30663
|
-
validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
30754
|
+
var IS_PROBABLY_EMAIL = "validator/IS_PROBABLY_EMAIL";
|
|
30755
|
+
var IS_PROBABLY_EMAIL_ERROR = "error/IS_PROBABLY_EMAIL";
|
|
30756
|
+
var isProbablyEmail = createValidator(IS_PROBABLY_EMAIL, IS_PROBABLY_EMAIL_ERROR);
|
|
30757
|
+
|
|
30758
|
+
validatorFns[IS_PROBABLY_EMAIL] = function (value, args, form) {
|
|
30664
30759
|
if (value === "") {
|
|
30665
30760
|
return true;
|
|
30666
30761
|
}
|
|
30762
|
+
|
|
30667
30763
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
30668
30764
|
};
|
|
30669
30765
|
|
|
30670
|
-
|
|
30671
|
-
|
|
30672
|
-
|
|
30673
|
-
|
|
30674
|
-
|
|
30675
|
-
|
|
30766
|
+
var runValidatorErrorMessage = function runValidatorErrorMessage(type) {
|
|
30767
|
+
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)");
|
|
30768
|
+
};
|
|
30769
|
+
|
|
30770
|
+
var runValidator = function runValidator(validator, value, form) {
|
|
30771
|
+
var validatorFn = validatorFns[validator.type];
|
|
30676
30772
|
|
|
30677
|
-
const runValidator = (validator, value, form) => {
|
|
30678
|
-
const validatorFn = validatorFns[validator.type];
|
|
30679
30773
|
if (validatorFn === undefined) {
|
|
30680
30774
|
throw new Error(runValidatorErrorMessage(validator.type));
|
|
30681
30775
|
}
|
|
30776
|
+
|
|
30682
30777
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
30683
30778
|
};
|
|
30684
30779
|
|
|
30685
|
-
|
|
30686
|
-
return validators
|
|
30687
|
-
|
|
30688
|
-
|
|
30780
|
+
var _computeErrors = function _computeErrors(fieldName, form, validators) {
|
|
30781
|
+
return validators.map(function (v) {
|
|
30782
|
+
return runValidator(v, form[fieldName].rawValue, form);
|
|
30783
|
+
}).filter(function (x) {
|
|
30784
|
+
return x !== null;
|
|
30785
|
+
});
|
|
30689
30786
|
};
|
|
30690
30787
|
|
|
30691
|
-
|
|
30692
|
-
|
|
30788
|
+
var computeConstraints = function computeConstraints(fieldName, form) {
|
|
30789
|
+
var constraints = form[fieldName].constraints;
|
|
30693
30790
|
return _computeErrors(fieldName, form, constraints);
|
|
30694
30791
|
};
|
|
30695
30792
|
|
|
30696
|
-
|
|
30697
|
-
|
|
30793
|
+
var computeErrors = function computeErrors(fieldName, form) {
|
|
30794
|
+
var validators = form[fieldName].validators;
|
|
30698
30795
|
return _computeErrors(fieldName, form, validators);
|
|
30699
30796
|
};
|
|
30700
30797
|
|
|
30701
30798
|
var obj;
|
|
30702
|
-
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : (
|
|
30703
|
-
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol
|
|
30704
|
-
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol
|
|
30799
|
+
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : (obj = {}, obj["immer-nothing"] = true, obj);
|
|
30800
|
+
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol["for"] ? Symbol["for"]("immer-draftable") : "__$immer_draftable";
|
|
30801
|
+
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol["for"] ? Symbol["for"]("immer-state") : "__$immer_state";
|
|
30802
|
+
|
|
30705
30803
|
function isDraft(value) {
|
|
30706
30804
|
return !!value && !!value[DRAFT_STATE];
|
|
30707
30805
|
}
|
|
30806
|
+
|
|
30708
30807
|
function isDraftable(value) {
|
|
30709
|
-
if (!value
|
|
30710
|
-
|
|
30808
|
+
if (!value) {
|
|
30809
|
+
return false;
|
|
30810
|
+
}
|
|
30811
|
+
|
|
30812
|
+
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
30813
|
+
}
|
|
30814
|
+
|
|
30815
|
+
function isPlainObject(value) {
|
|
30816
|
+
if (!value || _typeof(value) !== "object") {
|
|
30817
|
+
return false;
|
|
30818
|
+
}
|
|
30819
|
+
|
|
30820
|
+
if (Array.isArray(value)) {
|
|
30821
|
+
return true;
|
|
30822
|
+
}
|
|
30823
|
+
|
|
30711
30824
|
var proto = Object.getPrototypeOf(value);
|
|
30712
|
-
|
|
30713
|
-
return !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
30825
|
+
return !proto || proto === Object.prototype;
|
|
30714
30826
|
}
|
|
30827
|
+
|
|
30715
30828
|
var assign = Object.assign || function assign(target, value) {
|
|
30716
30829
|
for (var key in value) {
|
|
30717
30830
|
if (has(value, key)) {
|
|
@@ -30721,11 +30834,18 @@ var assign = Object.assign || function assign(target, value) {
|
|
|
30721
30834
|
|
|
30722
30835
|
return target;
|
|
30723
30836
|
};
|
|
30724
|
-
|
|
30837
|
+
|
|
30838
|
+
var ownKeys$1 = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKeys : typeof Object.getOwnPropertySymbols !== "undefined" ? function (obj) {
|
|
30839
|
+
return Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj));
|
|
30840
|
+
} : Object.getOwnPropertyNames;
|
|
30841
|
+
|
|
30725
30842
|
function shallowCopy(base, invokeGetters) {
|
|
30726
|
-
if (
|
|
30843
|
+
if (invokeGetters === void 0) invokeGetters = false;
|
|
30844
|
+
|
|
30845
|
+
if (Array.isArray(base)) {
|
|
30846
|
+
return base.slice();
|
|
30847
|
+
}
|
|
30727
30848
|
|
|
30728
|
-
if (Array.isArray(base)) { return base.slice(); }
|
|
30729
30849
|
var clone = Object.create(Object.getPrototypeOf(base));
|
|
30730
30850
|
ownKeys$1(base).forEach(function (key) {
|
|
30731
30851
|
if (key === DRAFT_STATE) {
|
|
@@ -30755,20 +30875,28 @@ function shallowCopy(base, invokeGetters) {
|
|
|
30755
30875
|
});
|
|
30756
30876
|
return clone;
|
|
30757
30877
|
}
|
|
30878
|
+
|
|
30758
30879
|
function each(value, cb) {
|
|
30759
30880
|
if (Array.isArray(value)) {
|
|
30760
|
-
for (var i = 0; i < value.length; i++) {
|
|
30881
|
+
for (var i = 0; i < value.length; i++) {
|
|
30882
|
+
cb(i, value[i], value);
|
|
30883
|
+
}
|
|
30761
30884
|
} else {
|
|
30762
|
-
ownKeys$1(value).forEach(function (key) {
|
|
30885
|
+
ownKeys$1(value).forEach(function (key) {
|
|
30886
|
+
return cb(key, value[key], value);
|
|
30887
|
+
});
|
|
30763
30888
|
}
|
|
30764
30889
|
}
|
|
30890
|
+
|
|
30765
30891
|
function isEnumerable(base, prop) {
|
|
30766
30892
|
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
30767
30893
|
return !!desc && desc.enumerable;
|
|
30768
30894
|
}
|
|
30895
|
+
|
|
30769
30896
|
function has(thing, prop) {
|
|
30770
30897
|
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
30771
30898
|
}
|
|
30899
|
+
|
|
30772
30900
|
function is(x, y) {
|
|
30773
30901
|
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
30774
30902
|
if (x === y) {
|
|
@@ -30778,8 +30906,26 @@ function is(x, y) {
|
|
|
30778
30906
|
}
|
|
30779
30907
|
}
|
|
30780
30908
|
|
|
30909
|
+
function clone(obj) {
|
|
30910
|
+
if (!isDraftable(obj)) {
|
|
30911
|
+
return obj;
|
|
30912
|
+
}
|
|
30913
|
+
|
|
30914
|
+
if (Array.isArray(obj)) {
|
|
30915
|
+
return obj.map(clone);
|
|
30916
|
+
}
|
|
30917
|
+
|
|
30918
|
+
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
30919
|
+
|
|
30920
|
+
for (var key in obj) {
|
|
30921
|
+
cloned[key] = clone(obj[key]);
|
|
30922
|
+
}
|
|
30923
|
+
|
|
30924
|
+
return cloned;
|
|
30925
|
+
}
|
|
30781
30926
|
/** Each scope represents a `produce` call. */
|
|
30782
30927
|
|
|
30928
|
+
|
|
30783
30929
|
var ImmerScope = function ImmerScope(parent) {
|
|
30784
30930
|
this.drafts = [];
|
|
30785
30931
|
this.parent = parent; // Whenever the modified draft contains a draft from another scope, we
|
|
@@ -30790,7 +30936,7 @@ var ImmerScope = function ImmerScope(parent) {
|
|
|
30790
30936
|
this.patches = null;
|
|
30791
30937
|
};
|
|
30792
30938
|
|
|
30793
|
-
ImmerScope.prototype.usePatches = function usePatches
|
|
30939
|
+
ImmerScope.prototype.usePatches = function usePatches(patchListener) {
|
|
30794
30940
|
if (patchListener) {
|
|
30795
30941
|
this.patches = [];
|
|
30796
30942
|
this.inversePatches = [];
|
|
@@ -30798,17 +30944,18 @@ ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
|
30798
30944
|
}
|
|
30799
30945
|
};
|
|
30800
30946
|
|
|
30801
|
-
ImmerScope.prototype.revoke = function revoke$1
|
|
30947
|
+
ImmerScope.prototype.revoke = function revoke$1() {
|
|
30802
30948
|
this.leave();
|
|
30803
30949
|
this.drafts.forEach(revoke);
|
|
30804
30950
|
this.drafts = null; // Make draft-related methods throw.
|
|
30805
30951
|
};
|
|
30806
30952
|
|
|
30807
|
-
ImmerScope.prototype.leave = function leave
|
|
30953
|
+
ImmerScope.prototype.leave = function leave() {
|
|
30808
30954
|
if (this === ImmerScope.current) {
|
|
30809
30955
|
ImmerScope.current = this.parent;
|
|
30810
30956
|
}
|
|
30811
30957
|
};
|
|
30958
|
+
|
|
30812
30959
|
ImmerScope.current = null;
|
|
30813
30960
|
|
|
30814
30961
|
ImmerScope.enter = function () {
|
|
@@ -30817,11 +30964,11 @@ ImmerScope.enter = function () {
|
|
|
30817
30964
|
|
|
30818
30965
|
function revoke(draft) {
|
|
30819
30966
|
draft[DRAFT_STATE].revoke();
|
|
30820
|
-
}
|
|
30967
|
+
} // but share them all instead
|
|
30821
30968
|
|
|
30822
|
-
// but share them all instead
|
|
30823
30969
|
|
|
30824
30970
|
var descriptors = {};
|
|
30971
|
+
|
|
30825
30972
|
function willFinalize(scope, result, isReplaced) {
|
|
30826
30973
|
scope.drafts.forEach(function (draft) {
|
|
30827
30974
|
draft[DRAFT_STATE].finalizing = true;
|
|
@@ -30839,6 +30986,7 @@ function willFinalize(scope, result, isReplaced) {
|
|
|
30839
30986
|
markChangesSweep(scope.drafts);
|
|
30840
30987
|
}
|
|
30841
30988
|
}
|
|
30989
|
+
|
|
30842
30990
|
function createProxy(base, parent) {
|
|
30843
30991
|
var isArray = Array.isArray(base);
|
|
30844
30992
|
var draft = clonePotentialDraft(base);
|
|
@@ -30892,7 +31040,11 @@ function peek(draft, prop) {
|
|
|
30892
31040
|
function get(state, prop) {
|
|
30893
31041
|
assertUnrevoked(state);
|
|
30894
31042
|
var value = peek(source(state), prop);
|
|
30895
|
-
|
|
31043
|
+
|
|
31044
|
+
if (state.finalizing) {
|
|
31045
|
+
return value;
|
|
31046
|
+
} // Create a draft if the value is unmodified.
|
|
31047
|
+
|
|
30896
31048
|
|
|
30897
31049
|
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
30898
31050
|
prepareCopy(state);
|
|
@@ -30907,7 +31059,10 @@ function set(state, prop, value) {
|
|
|
30907
31059
|
state.assigned[prop] = true;
|
|
30908
31060
|
|
|
30909
31061
|
if (!state.modified) {
|
|
30910
|
-
if (is(value, peek(source(state), prop))) {
|
|
31062
|
+
if (is(value, peek(source(state), prop))) {
|
|
31063
|
+
return;
|
|
31064
|
+
}
|
|
31065
|
+
|
|
30911
31066
|
markChanged(state);
|
|
30912
31067
|
prepareCopy(state);
|
|
30913
31068
|
}
|
|
@@ -30918,12 +31073,17 @@ function set(state, prop, value) {
|
|
|
30918
31073
|
function markChanged(state) {
|
|
30919
31074
|
if (!state.modified) {
|
|
30920
31075
|
state.modified = true;
|
|
30921
|
-
|
|
31076
|
+
|
|
31077
|
+
if (state.parent) {
|
|
31078
|
+
markChanged(state.parent);
|
|
31079
|
+
}
|
|
30922
31080
|
}
|
|
30923
31081
|
}
|
|
30924
31082
|
|
|
30925
31083
|
function prepareCopy(state) {
|
|
30926
|
-
if (!state.copy) {
|
|
31084
|
+
if (!state.copy) {
|
|
31085
|
+
state.copy = clonePotentialDraft(state.base);
|
|
31086
|
+
}
|
|
30927
31087
|
}
|
|
30928
31088
|
|
|
30929
31089
|
function clonePotentialDraft(base) {
|
|
@@ -30948,15 +31108,12 @@ function proxyProperty(draft, prop, enumerable) {
|
|
|
30948
31108
|
descriptors[prop] = desc = {
|
|
30949
31109
|
configurable: true,
|
|
30950
31110
|
enumerable: enumerable,
|
|
30951
|
-
|
|
30952
31111
|
get: function get$1() {
|
|
30953
31112
|
return get(this[DRAFT_STATE], prop);
|
|
30954
31113
|
},
|
|
30955
|
-
|
|
30956
31114
|
set: function set$1(value) {
|
|
30957
31115
|
set(this[DRAFT_STATE], prop, value);
|
|
30958
31116
|
}
|
|
30959
|
-
|
|
30960
31117
|
};
|
|
30961
31118
|
}
|
|
30962
31119
|
|
|
@@ -30964,7 +31121,9 @@ function proxyProperty(draft, prop, enumerable) {
|
|
|
30964
31121
|
}
|
|
30965
31122
|
|
|
30966
31123
|
function assertUnrevoked(state) {
|
|
30967
|
-
if (state.revoked === true) {
|
|
31124
|
+
if (state.revoked === true) {
|
|
31125
|
+
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)));
|
|
31126
|
+
}
|
|
30968
31127
|
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
30969
31128
|
|
|
30970
31129
|
|
|
@@ -30978,16 +31137,27 @@ function markChangesSweep(drafts) {
|
|
|
30978
31137
|
|
|
30979
31138
|
if (!state.modified) {
|
|
30980
31139
|
if (Array.isArray(state.base)) {
|
|
30981
|
-
if (hasArrayChanges(state)) {
|
|
30982
|
-
|
|
31140
|
+
if (hasArrayChanges(state)) {
|
|
31141
|
+
markChanged(state);
|
|
31142
|
+
}
|
|
31143
|
+
} else if (hasObjectChanges(state)) {
|
|
31144
|
+
markChanged(state);
|
|
31145
|
+
}
|
|
30983
31146
|
}
|
|
30984
31147
|
}
|
|
30985
31148
|
}
|
|
30986
31149
|
|
|
30987
31150
|
function markChangesRecursively(object) {
|
|
30988
|
-
if (!object ||
|
|
31151
|
+
if (!object || _typeof(object) !== "object") {
|
|
31152
|
+
return;
|
|
31153
|
+
}
|
|
31154
|
+
|
|
30989
31155
|
var state = object[DRAFT_STATE];
|
|
30990
|
-
|
|
31156
|
+
|
|
31157
|
+
if (!state) {
|
|
31158
|
+
return;
|
|
31159
|
+
}
|
|
31160
|
+
|
|
30991
31161
|
var base = state.base;
|
|
30992
31162
|
var draft = state.draft;
|
|
30993
31163
|
var assigned = state.assigned;
|
|
@@ -31017,14 +31187,20 @@ function markChangesRecursively(object) {
|
|
|
31017
31187
|
assigned.length = true;
|
|
31018
31188
|
|
|
31019
31189
|
if (draft.length < base.length) {
|
|
31020
|
-
for (var i = draft.length; i < base.length; i++) {
|
|
31190
|
+
for (var i = draft.length; i < base.length; i++) {
|
|
31191
|
+
assigned[i] = false;
|
|
31192
|
+
}
|
|
31021
31193
|
} else {
|
|
31022
|
-
for (var i$1 = base.length; i$1 < draft.length; i$1++) {
|
|
31194
|
+
for (var i$1 = base.length; i$1 < draft.length; i$1++) {
|
|
31195
|
+
assigned[i$1] = true;
|
|
31196
|
+
}
|
|
31023
31197
|
}
|
|
31024
31198
|
|
|
31025
31199
|
for (var i$2 = 0; i$2 < draft.length; i$2++) {
|
|
31026
31200
|
// Only untouched indices trigger recursion.
|
|
31027
|
-
if (assigned[i$2] === undefined) {
|
|
31201
|
+
if (assigned[i$2] === undefined) {
|
|
31202
|
+
markChangesRecursively(draft[i$2]);
|
|
31203
|
+
}
|
|
31028
31204
|
}
|
|
31029
31205
|
}
|
|
31030
31206
|
}
|
|
@@ -31061,7 +31237,10 @@ function hasObjectChanges(state) {
|
|
|
31061
31237
|
|
|
31062
31238
|
function hasArrayChanges(state) {
|
|
31063
31239
|
var draft = state.draft;
|
|
31064
|
-
|
|
31240
|
+
|
|
31241
|
+
if (draft.length !== state.base.length) {
|
|
31242
|
+
return true;
|
|
31243
|
+
} // See #116
|
|
31065
31244
|
// If we first shorten the length, our array interceptors will be removed.
|
|
31066
31245
|
// If after that new items are added, result in the same original length,
|
|
31067
31246
|
// those last items will have no intercepting property.
|
|
@@ -31069,9 +31248,13 @@ function hasArrayChanges(state) {
|
|
|
31069
31248
|
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
31070
31249
|
// the last one
|
|
31071
31250
|
|
|
31251
|
+
|
|
31072
31252
|
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
31073
31253
|
|
|
31074
|
-
if (descriptor && !descriptor.get) {
|
|
31254
|
+
if (descriptor && !descriptor.get) {
|
|
31255
|
+
return true;
|
|
31256
|
+
} // For all other cases, we don't have to compare, as they would have been picked up by the index setters
|
|
31257
|
+
|
|
31075
31258
|
|
|
31076
31259
|
return false;
|
|
31077
31260
|
}
|
|
@@ -31085,11 +31268,12 @@ function createHiddenProperty(target, prop, value) {
|
|
|
31085
31268
|
}
|
|
31086
31269
|
|
|
31087
31270
|
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
31088
|
-
|
|
31089
|
-
|
|
31271
|
+
willFinalize: willFinalize,
|
|
31272
|
+
createProxy: createProxy
|
|
31090
31273
|
});
|
|
31091
31274
|
|
|
31092
31275
|
function willFinalize$1() {}
|
|
31276
|
+
|
|
31093
31277
|
function createProxy$1(base, parent) {
|
|
31094
31278
|
var scope = parent ? parent.scope : ImmerScope.current;
|
|
31095
31279
|
var state = {
|
|
@@ -31124,33 +31308,27 @@ function createProxy$1(base, parent) {
|
|
|
31124
31308
|
scope.drafts.push(proxy);
|
|
31125
31309
|
return proxy;
|
|
31126
31310
|
}
|
|
31311
|
+
|
|
31127
31312
|
var objectTraps = {
|
|
31128
31313
|
get: get$1,
|
|
31129
|
-
|
|
31130
31314
|
has: function has(target, prop) {
|
|
31131
31315
|
return prop in source$1(target);
|
|
31132
31316
|
},
|
|
31133
|
-
|
|
31134
31317
|
ownKeys: function ownKeys(target) {
|
|
31135
31318
|
return Reflect.ownKeys(source$1(target));
|
|
31136
31319
|
},
|
|
31137
|
-
|
|
31138
31320
|
set: set$1,
|
|
31139
31321
|
deleteProperty: deleteProperty,
|
|
31140
31322
|
getOwnPropertyDescriptor: getOwnPropertyDescriptor,
|
|
31141
|
-
|
|
31142
31323
|
defineProperty: function defineProperty() {
|
|
31143
31324
|
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
31144
31325
|
},
|
|
31145
|
-
|
|
31146
31326
|
getPrototypeOf: function getPrototypeOf(target) {
|
|
31147
31327
|
return Object.getPrototypeOf(target.base);
|
|
31148
31328
|
},
|
|
31149
|
-
|
|
31150
31329
|
setPrototypeOf: function setPrototypeOf() {
|
|
31151
31330
|
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
31152
31331
|
}
|
|
31153
|
-
|
|
31154
31332
|
};
|
|
31155
31333
|
var arrayTraps = {};
|
|
31156
31334
|
each(objectTraps, function (key, fn) {
|
|
@@ -31189,7 +31367,10 @@ function peek$1(draft, prop) {
|
|
|
31189
31367
|
}
|
|
31190
31368
|
|
|
31191
31369
|
function get$1(state, prop) {
|
|
31192
|
-
if (prop === DRAFT_STATE) {
|
|
31370
|
+
if (prop === DRAFT_STATE) {
|
|
31371
|
+
return state;
|
|
31372
|
+
}
|
|
31373
|
+
|
|
31193
31374
|
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
31194
31375
|
|
|
31195
31376
|
if (!state.modified && has(drafts, prop)) {
|
|
@@ -31205,7 +31386,10 @@ function get$1(state, prop) {
|
|
|
31205
31386
|
|
|
31206
31387
|
if (state.modified) {
|
|
31207
31388
|
// Assigned values are never drafted. This catches any drafts we created, too.
|
|
31208
|
-
if (value !== peek$1(state.base, prop)) {
|
|
31389
|
+
if (value !== peek$1(state.base, prop)) {
|
|
31390
|
+
return value;
|
|
31391
|
+
} // Store drafts on the copy (when one exists).
|
|
31392
|
+
|
|
31209
31393
|
|
|
31210
31394
|
drafts = state.copy;
|
|
31211
31395
|
}
|
|
@@ -31220,7 +31404,11 @@ function set$1(state, prop, value) {
|
|
|
31220
31404
|
// values may be drafts, but falsy values are never drafts.
|
|
31221
31405
|
|
|
31222
31406
|
var isUnchanged = value ? is(baseValue, value) || value === state.drafts[prop] : is(baseValue, value) && prop in state.base;
|
|
31223
|
-
|
|
31407
|
+
|
|
31408
|
+
if (isUnchanged) {
|
|
31409
|
+
return true;
|
|
31410
|
+
}
|
|
31411
|
+
|
|
31224
31412
|
markChanged$1(state);
|
|
31225
31413
|
}
|
|
31226
31414
|
|
|
@@ -31234,9 +31422,15 @@ function deleteProperty(state, prop) {
|
|
|
31234
31422
|
if (peek$1(state.base, prop) !== undefined || prop in state.base) {
|
|
31235
31423
|
state.assigned[prop] = false;
|
|
31236
31424
|
markChanged$1(state);
|
|
31425
|
+
} else if (state.assigned[prop]) {
|
|
31426
|
+
// if an originally not assigned property was deleted
|
|
31427
|
+
delete state.assigned[prop];
|
|
31428
|
+
}
|
|
31429
|
+
|
|
31430
|
+
if (state.copy) {
|
|
31431
|
+
delete state.copy[prop];
|
|
31237
31432
|
}
|
|
31238
31433
|
|
|
31239
|
-
if (state.copy) { delete state.copy[prop]; }
|
|
31240
31434
|
return true;
|
|
31241
31435
|
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
31242
31436
|
// the same guarantee in ES5 mode.
|
|
@@ -31259,13 +31453,16 @@ function markChanged$1(state) {
|
|
|
31259
31453
|
state.modified = true;
|
|
31260
31454
|
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
31261
31455
|
state.drafts = null;
|
|
31262
|
-
|
|
31456
|
+
|
|
31457
|
+
if (state.parent) {
|
|
31458
|
+
markChanged$1(state.parent);
|
|
31459
|
+
}
|
|
31263
31460
|
}
|
|
31264
31461
|
}
|
|
31265
31462
|
|
|
31266
31463
|
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
31267
|
-
|
|
31268
|
-
|
|
31464
|
+
willFinalize: willFinalize$1,
|
|
31465
|
+
createProxy: createProxy$1
|
|
31269
31466
|
});
|
|
31270
31467
|
|
|
31271
31468
|
function generatePatches(state, basePath, patches, inversePatches) {
|
|
@@ -31274,14 +31471,13 @@ function generatePatches(state, basePath, patches, inversePatches) {
|
|
|
31274
31471
|
|
|
31275
31472
|
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
31276
31473
|
var assign, assign$1;
|
|
31277
|
-
|
|
31278
31474
|
var base = state.base;
|
|
31279
31475
|
var copy = state.copy;
|
|
31280
31476
|
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
31281
31477
|
|
|
31282
31478
|
if (copy.length < base.length) {
|
|
31283
|
-
|
|
31284
|
-
|
|
31479
|
+
assign = [copy, base], base = assign[0], copy = assign[1];
|
|
31480
|
+
assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1];
|
|
31285
31481
|
}
|
|
31286
31482
|
|
|
31287
31483
|
var delta = copy.length - base.length; // Find the first replaced index.
|
|
@@ -31316,7 +31512,6 @@ function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
|
31316
31512
|
}
|
|
31317
31513
|
}
|
|
31318
31514
|
|
|
31319
|
-
var useRemove = end != base.length;
|
|
31320
31515
|
var replaceCount = patches.length; // Process added indices.
|
|
31321
31516
|
|
|
31322
31517
|
for (var i$1 = end + delta - 1; i$1 >= end; --i$1) {
|
|
@@ -31326,21 +31521,9 @@ function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
|
31326
31521
|
path: path$1,
|
|
31327
31522
|
value: copy[i$1]
|
|
31328
31523
|
};
|
|
31329
|
-
|
|
31330
|
-
if (useRemove) {
|
|
31331
|
-
inversePatches.push({
|
|
31332
|
-
op: "remove",
|
|
31333
|
-
path: path$1
|
|
31334
|
-
});
|
|
31335
|
-
}
|
|
31336
|
-
} // One "replace" patch reverses all non-splicing "add" patches.
|
|
31337
|
-
|
|
31338
|
-
|
|
31339
|
-
if (!useRemove) {
|
|
31340
31524
|
inversePatches.push({
|
|
31341
|
-
op: "
|
|
31342
|
-
path:
|
|
31343
|
-
value: base.length
|
|
31525
|
+
op: "remove",
|
|
31526
|
+
path: path$1
|
|
31344
31527
|
});
|
|
31345
31528
|
}
|
|
31346
31529
|
}
|
|
@@ -31352,7 +31535,11 @@ function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
|
31352
31535
|
var origValue = base[key];
|
|
31353
31536
|
var value = copy[key];
|
|
31354
31537
|
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
31355
|
-
|
|
31538
|
+
|
|
31539
|
+
if (origValue === value && op === "replace") {
|
|
31540
|
+
return;
|
|
31541
|
+
}
|
|
31542
|
+
|
|
31356
31543
|
var path = basePath.concat(key);
|
|
31357
31544
|
patches.push(op === "remove" ? {
|
|
31358
31545
|
op: op,
|
|
@@ -31377,55 +31564,64 @@ function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
|
31377
31564
|
});
|
|
31378
31565
|
}
|
|
31379
31566
|
|
|
31380
|
-
function applyPatches(draft, patches) {
|
|
31381
|
-
for (var i = 0; i <
|
|
31382
|
-
var patch =
|
|
31567
|
+
var applyPatches = function applyPatches(draft, patches) {
|
|
31568
|
+
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
31569
|
+
var patch = list[i$1];
|
|
31383
31570
|
var path = patch.path;
|
|
31571
|
+
var op = patch.op;
|
|
31572
|
+
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
31384
31573
|
|
|
31385
|
-
if (path.length
|
|
31386
|
-
|
|
31387
|
-
}
|
|
31388
|
-
var base = draft;
|
|
31574
|
+
if (!path.length) {
|
|
31575
|
+
throw new Error("Illegal state");
|
|
31576
|
+
}
|
|
31389
31577
|
|
|
31390
|
-
|
|
31391
|
-
base = base[path[i$1]];
|
|
31392
|
-
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
31393
|
-
}
|
|
31578
|
+
var base = draft;
|
|
31394
31579
|
|
|
31395
|
-
|
|
31580
|
+
for (var i = 0; i < path.length - 1; i++) {
|
|
31581
|
+
base = base[path[i]];
|
|
31396
31582
|
|
|
31397
|
-
|
|
31398
|
-
|
|
31399
|
-
|
|
31400
|
-
break;
|
|
31583
|
+
if (!base || _typeof(base) !== "object") {
|
|
31584
|
+
throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/"));
|
|
31585
|
+
} // prettier-ignore
|
|
31401
31586
|
|
|
31402
|
-
|
|
31403
|
-
if (Array.isArray(base)) {
|
|
31404
|
-
// TODO: support "foo/-" paths for appending to an array
|
|
31405
|
-
base.splice(key, 0, patch.value);
|
|
31406
|
-
} else {
|
|
31407
|
-
base[key] = patch.value;
|
|
31408
|
-
}
|
|
31587
|
+
}
|
|
31409
31588
|
|
|
31410
|
-
|
|
31589
|
+
var key = path[path.length - 1];
|
|
31411
31590
|
|
|
31412
|
-
|
|
31413
|
-
|
|
31414
|
-
|
|
31415
|
-
|
|
31416
|
-
|
|
31417
|
-
|
|
31591
|
+
switch (op) {
|
|
31592
|
+
case "replace":
|
|
31593
|
+
// if value is an object, then it's assigned by reference
|
|
31594
|
+
// in the following add or remove ops, the value field inside the patch will also be modifyed
|
|
31595
|
+
// so we use value from the cloned patch
|
|
31596
|
+
base[key] = value;
|
|
31597
|
+
break;
|
|
31418
31598
|
|
|
31419
|
-
|
|
31599
|
+
case "add":
|
|
31600
|
+
if (Array.isArray(base)) {
|
|
31601
|
+
// TODO: support "foo/-" paths for appending to an array
|
|
31602
|
+
base.splice(key, 0, value);
|
|
31603
|
+
} else {
|
|
31604
|
+
base[key] = value;
|
|
31605
|
+
}
|
|
31420
31606
|
|
|
31421
|
-
|
|
31422
|
-
|
|
31423
|
-
|
|
31607
|
+
break;
|
|
31608
|
+
|
|
31609
|
+
case "remove":
|
|
31610
|
+
if (Array.isArray(base)) {
|
|
31611
|
+
base.splice(key, 1);
|
|
31612
|
+
} else {
|
|
31613
|
+
delete base[key];
|
|
31614
|
+
}
|
|
31615
|
+
|
|
31616
|
+
break;
|
|
31617
|
+
|
|
31618
|
+
default:
|
|
31619
|
+
throw new Error("Unsupported patch operation: " + op);
|
|
31424
31620
|
}
|
|
31425
31621
|
}
|
|
31426
31622
|
|
|
31427
31623
|
return draft;
|
|
31428
|
-
}
|
|
31624
|
+
};
|
|
31429
31625
|
|
|
31430
31626
|
function verifyMinified() {}
|
|
31431
31627
|
|
|
@@ -31436,27 +31632,33 @@ var configDefaults = {
|
|
|
31436
31632
|
onDelete: null,
|
|
31437
31633
|
onCopy: null
|
|
31438
31634
|
};
|
|
31635
|
+
|
|
31439
31636
|
var Immer = function Immer(config) {
|
|
31440
31637
|
assign(this, configDefaults, config);
|
|
31441
31638
|
this.setUseProxies(this.useProxies);
|
|
31442
31639
|
this.produce = this.produce.bind(this);
|
|
31443
31640
|
};
|
|
31444
31641
|
|
|
31445
|
-
Immer.prototype.produce = function produce
|
|
31446
|
-
|
|
31642
|
+
Immer.prototype.produce = function produce(base, recipe, patchListener) {
|
|
31643
|
+
var this$1 = this; // curried invocation
|
|
31447
31644
|
|
|
31448
|
-
// curried invocation
|
|
31449
31645
|
if (typeof base === "function" && typeof recipe !== "function") {
|
|
31450
31646
|
var defaultBase = recipe;
|
|
31451
31647
|
recipe = base;
|
|
31452
31648
|
var self = this;
|
|
31453
31649
|
return function curriedProduce(base) {
|
|
31454
|
-
|
|
31455
|
-
|
|
31456
|
-
|
|
31457
|
-
|
|
31650
|
+
var this$1 = this;
|
|
31651
|
+
if (base === void 0) base = defaultBase;
|
|
31652
|
+
var args = [],
|
|
31653
|
+
len = arguments.length - 1;
|
|
31654
|
+
|
|
31655
|
+
while (len-- > 0) {
|
|
31656
|
+
args[len] = arguments[len + 1];
|
|
31657
|
+
}
|
|
31458
31658
|
|
|
31459
|
-
return self.produce(base, function (draft) {
|
|
31659
|
+
return self.produce(base, function (draft) {
|
|
31660
|
+
return recipe.call.apply(recipe, [this$1, draft].concat(args));
|
|
31661
|
+
}); // prettier-ignore
|
|
31460
31662
|
};
|
|
31461
31663
|
} // prettier-ignore
|
|
31462
31664
|
|
|
@@ -31482,7 +31684,11 @@ Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
|
31482
31684
|
hasError = false;
|
|
31483
31685
|
} finally {
|
|
31484
31686
|
// finally instead of catch + rethrow better preserves original stack
|
|
31485
|
-
if (hasError) {
|
|
31687
|
+
if (hasError) {
|
|
31688
|
+
scope.revoke();
|
|
31689
|
+
} else {
|
|
31690
|
+
scope.leave();
|
|
31691
|
+
}
|
|
31486
31692
|
}
|
|
31487
31693
|
|
|
31488
31694
|
if (result instanceof Promise) {
|
|
@@ -31499,12 +31705,47 @@ Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
|
31499
31705
|
return this.processResult(result, scope);
|
|
31500
31706
|
} else {
|
|
31501
31707
|
result = recipe(base);
|
|
31502
|
-
|
|
31708
|
+
|
|
31709
|
+
if (result === undefined) {
|
|
31710
|
+
return base;
|
|
31711
|
+
}
|
|
31712
|
+
|
|
31503
31713
|
return result !== NOTHING ? result : undefined;
|
|
31504
31714
|
}
|
|
31505
31715
|
};
|
|
31506
31716
|
|
|
31507
|
-
Immer.prototype.
|
|
31717
|
+
Immer.prototype.produceWithPatches = function produceWithPatches(arg1, arg2, arg3) {
|
|
31718
|
+
var this$1 = this;
|
|
31719
|
+
|
|
31720
|
+
if (typeof arg1 === "function") {
|
|
31721
|
+
return function (state) {
|
|
31722
|
+
var args = [],
|
|
31723
|
+
len = arguments.length - 1;
|
|
31724
|
+
|
|
31725
|
+
while (len-- > 0) {
|
|
31726
|
+
args[len] = arguments[len + 1];
|
|
31727
|
+
}
|
|
31728
|
+
|
|
31729
|
+
return this$1.produceWithPatches(state, function (draft) {
|
|
31730
|
+
return arg1.apply(void 0, [draft].concat(args));
|
|
31731
|
+
});
|
|
31732
|
+
};
|
|
31733
|
+
} // non-curried form
|
|
31734
|
+
|
|
31735
|
+
|
|
31736
|
+
if (arg3) {
|
|
31737
|
+
throw new Error("A patch listener cannot be passed to produceWithPatches");
|
|
31738
|
+
}
|
|
31739
|
+
|
|
31740
|
+
var patches, inversePatches;
|
|
31741
|
+
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
31742
|
+
patches = p;
|
|
31743
|
+
inversePatches = ip;
|
|
31744
|
+
});
|
|
31745
|
+
return [nextState, patches, inversePatches];
|
|
31746
|
+
};
|
|
31747
|
+
|
|
31748
|
+
Immer.prototype.createDraft = function createDraft(base) {
|
|
31508
31749
|
if (!isDraftable(base)) {
|
|
31509
31750
|
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
31510
31751
|
}
|
|
@@ -31516,7 +31757,7 @@ Immer.prototype.createDraft = function createDraft (base) {
|
|
|
31516
31757
|
return proxy;
|
|
31517
31758
|
};
|
|
31518
31759
|
|
|
31519
|
-
Immer.prototype.finishDraft = function finishDraft
|
|
31760
|
+
Immer.prototype.finishDraft = function finishDraft(draft, patchListener) {
|
|
31520
31761
|
var state = draft && draft[DRAFT_STATE];
|
|
31521
31762
|
|
|
31522
31763
|
if (!state || !state.isManual) {
|
|
@@ -31532,28 +31773,43 @@ Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
|
31532
31773
|
return this.processResult(undefined, scope);
|
|
31533
31774
|
};
|
|
31534
31775
|
|
|
31535
|
-
Immer.prototype.setAutoFreeze = function setAutoFreeze
|
|
31776
|
+
Immer.prototype.setAutoFreeze = function setAutoFreeze(value) {
|
|
31536
31777
|
this.autoFreeze = value;
|
|
31537
31778
|
};
|
|
31538
31779
|
|
|
31539
|
-
Immer.prototype.setUseProxies = function setUseProxies
|
|
31780
|
+
Immer.prototype.setUseProxies = function setUseProxies(value) {
|
|
31540
31781
|
this.useProxies = value;
|
|
31541
31782
|
assign(this, value ? modernProxy : legacyProxy);
|
|
31542
31783
|
};
|
|
31543
31784
|
|
|
31544
|
-
Immer.prototype.applyPatches = function applyPatches$1
|
|
31545
|
-
//
|
|
31785
|
+
Immer.prototype.applyPatches = function applyPatches$1(base, patches) {
|
|
31786
|
+
// If a patch replaces the entire state, take that replacement as base
|
|
31787
|
+
// before applying patches
|
|
31788
|
+
var i;
|
|
31789
|
+
|
|
31790
|
+
for (i = patches.length - 1; i >= 0; i--) {
|
|
31791
|
+
var patch = patches[i];
|
|
31792
|
+
|
|
31793
|
+
if (patch.path.length === 0 && patch.op === "replace") {
|
|
31794
|
+
base = patch.value;
|
|
31795
|
+
break;
|
|
31796
|
+
}
|
|
31797
|
+
}
|
|
31798
|
+
|
|
31546
31799
|
if (isDraft(base)) {
|
|
31800
|
+
// N.B: never hits if some patch a replacement, patches are never drafts
|
|
31547
31801
|
return applyPatches(base, patches);
|
|
31548
31802
|
} // Otherwise, produce a copy of the base state.
|
|
31549
31803
|
|
|
31550
31804
|
|
|
31551
|
-
return this.produce(base, function (draft) {
|
|
31805
|
+
return this.produce(base, function (draft) {
|
|
31806
|
+
return applyPatches(draft, patches.slice(i + 1));
|
|
31807
|
+
});
|
|
31552
31808
|
};
|
|
31553
31809
|
/** @internal */
|
|
31554
31810
|
|
|
31555
31811
|
|
|
31556
|
-
Immer.prototype.processResult = function processResult
|
|
31812
|
+
Immer.prototype.processResult = function processResult(result, scope) {
|
|
31557
31813
|
var baseDraft = scope.drafts[0];
|
|
31558
31814
|
var isReplaced = result !== undefined && result !== baseDraft;
|
|
31559
31815
|
this.willFinalize(scope, result, isReplaced);
|
|
@@ -31601,13 +31857,15 @@ Immer.prototype.processResult = function processResult (result, scope) {
|
|
|
31601
31857
|
*/
|
|
31602
31858
|
|
|
31603
31859
|
|
|
31604
|
-
Immer.prototype.finalize = function finalize
|
|
31605
|
-
|
|
31606
|
-
|
|
31860
|
+
Immer.prototype.finalize = function finalize(draft, path, scope) {
|
|
31861
|
+
var this$1 = this;
|
|
31607
31862
|
var state = draft[DRAFT_STATE];
|
|
31608
31863
|
|
|
31609
31864
|
if (!state) {
|
|
31610
|
-
if (Object.isFrozen(draft)) {
|
|
31865
|
+
if (Object.isFrozen(draft)) {
|
|
31866
|
+
return draft;
|
|
31867
|
+
}
|
|
31868
|
+
|
|
31611
31869
|
return this.finalizeTree(draft, null, scope);
|
|
31612
31870
|
} // Never finalize drafts owned by another scope.
|
|
31613
31871
|
|
|
@@ -31630,13 +31888,17 @@ Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
|
31630
31888
|
var assigned = state.assigned;
|
|
31631
31889
|
|
|
31632
31890
|
for (var prop in assigned) {
|
|
31633
|
-
if (!assigned[prop]) {
|
|
31891
|
+
if (!assigned[prop]) {
|
|
31892
|
+
this.onDelete(state, prop);
|
|
31893
|
+
}
|
|
31634
31894
|
}
|
|
31635
31895
|
} else {
|
|
31636
31896
|
var base = state.base;
|
|
31637
|
-
|
|
31897
|
+
var copy = state.copy;
|
|
31638
31898
|
each(base, function (prop) {
|
|
31639
|
-
if (!has(copy, prop)) {
|
|
31899
|
+
if (!has(copy, prop)) {
|
|
31900
|
+
this$1.onDelete(state, prop);
|
|
31901
|
+
}
|
|
31640
31902
|
});
|
|
31641
31903
|
}
|
|
31642
31904
|
}
|
|
@@ -31664,9 +31926,8 @@ Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
|
31664
31926
|
*/
|
|
31665
31927
|
|
|
31666
31928
|
|
|
31667
|
-
Immer.prototype.finalizeTree = function finalizeTree
|
|
31668
|
-
|
|
31669
|
-
|
|
31929
|
+
Immer.prototype.finalizeTree = function finalizeTree(root, rootPath, scope) {
|
|
31930
|
+
var this$1 = this;
|
|
31670
31931
|
var state = root[DRAFT_STATE];
|
|
31671
31932
|
|
|
31672
31933
|
if (state) {
|
|
@@ -31680,7 +31941,7 @@ Immer.prototype.finalizeTree = function finalizeTree (root, rootPath, scope) {
|
|
|
31680
31941
|
|
|
31681
31942
|
var needPatches = !!rootPath && !!scope.patches;
|
|
31682
31943
|
|
|
31683
|
-
var finalizeProperty = function (prop, value, parent) {
|
|
31944
|
+
var finalizeProperty = function finalizeProperty(prop, value, parent) {
|
|
31684
31945
|
if (value === parent) {
|
|
31685
31946
|
throw Error("Immer forbids circular references");
|
|
31686
31947
|
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
@@ -31707,7 +31968,9 @@ Immer.prototype.finalizeTree = function finalizeTree (root, rootPath, scope) {
|
|
|
31707
31968
|
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
31708
31969
|
|
|
31709
31970
|
|
|
31710
|
-
if (isDraftProp && value === state.base[prop]) {
|
|
31971
|
+
if (isDraftProp && value === state.base[prop]) {
|
|
31972
|
+
return;
|
|
31973
|
+
}
|
|
31711
31974
|
} // Unchanged draft properties are ignored.
|
|
31712
31975
|
else if (isDraftProp && is(value, state.base[prop])) {
|
|
31713
31976
|
return;
|
|
@@ -31747,6 +32010,12 @@ var immer = new Immer();
|
|
|
31747
32010
|
*/
|
|
31748
32011
|
|
|
31749
32012
|
var produce = immer.produce;
|
|
32013
|
+
/**
|
|
32014
|
+
* Like `produce`, but `produceWithPatches` always returns a tuple
|
|
32015
|
+
* [nextState, patches, inversePatches] (instead of just the next state)
|
|
32016
|
+
*/
|
|
32017
|
+
|
|
32018
|
+
var produceWithPatches = immer.produceWithPatches.bind(immer);
|
|
31750
32019
|
/**
|
|
31751
32020
|
* Pass true to automatically freeze all copies created by Immer.
|
|
31752
32021
|
*
|
|
@@ -31786,103 +32055,149 @@ var createDraft = immer.createDraft.bind(immer);
|
|
|
31786
32055
|
|
|
31787
32056
|
var finishDraft = immer.finishDraft.bind(immer);
|
|
31788
32057
|
|
|
31789
|
-
|
|
31790
|
-
|
|
31791
|
-
|
|
31792
|
-
|
|
32058
|
+
var createInitialState = function createInitialState(formConfig) {
|
|
32059
|
+
var initialForm = {};
|
|
32060
|
+
var formConfigKeys = Object.keys(formConfig);
|
|
32061
|
+
|
|
32062
|
+
for (var _i = 0, _formConfigKeys = formConfigKeys; _i < _formConfigKeys.length; _i++) {
|
|
32063
|
+
var formKey = _formConfigKeys[_i];
|
|
31793
32064
|
initialForm[formKey] = {
|
|
31794
32065
|
dirty: false,
|
|
31795
32066
|
rawValue: formConfig[formKey].defaultValue || "",
|
|
31796
32067
|
validators: formConfig[formKey].validators || [],
|
|
31797
32068
|
constraints: formConfig[formKey].constraints || []
|
|
31798
32069
|
};
|
|
31799
|
-
}
|
|
31800
|
-
// Because validators require the entire form we have to do a
|
|
32070
|
+
} // Because validators require the entire form we have to do a
|
|
31801
32071
|
// second pass to add errors once the initial form has been
|
|
31802
32072
|
// constructed
|
|
31803
|
-
|
|
31804
|
-
|
|
31805
|
-
|
|
31806
|
-
|
|
32073
|
+
|
|
32074
|
+
|
|
32075
|
+
for (var _i2 = 0, _formConfigKeys2 = formConfigKeys; _i2 < _formConfigKeys2.length; _i2++) {
|
|
32076
|
+
var _formKey = _formConfigKeys2[_i2];
|
|
32077
|
+
var errors = computeErrors(_formKey, initialForm);
|
|
32078
|
+
initialForm[_formKey].errors = errors;
|
|
32079
|
+
initialForm[_formKey].hasErrors = errors.length > 0;
|
|
31807
32080
|
}
|
|
32081
|
+
|
|
31808
32082
|
return initialForm;
|
|
31809
32083
|
};
|
|
31810
32084
|
|
|
31811
|
-
|
|
31812
|
-
const set$2 = fieldName => value => ({
|
|
31813
|
-
type: SET,
|
|
31814
|
-
payload: { fieldName, value }
|
|
31815
|
-
});
|
|
32085
|
+
var SET = "field/SET";
|
|
31816
32086
|
|
|
31817
|
-
|
|
31818
|
-
|
|
31819
|
-
|
|
31820
|
-
|
|
31821
|
-
|
|
31822
|
-
|
|
31823
|
-
|
|
31824
|
-
|
|
31825
|
-
|
|
31826
|
-
|
|
31827
|
-
|
|
31828
|
-
|
|
31829
|
-
return produce(state, draftState => {
|
|
31830
|
-
let originalValue = draftState[changedFieldName].rawValue;
|
|
31831
|
-
draftState[changedFieldName].rawValue = newRawValue;
|
|
31832
|
-
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
31833
|
-
// If the change violates constraints, revert the change
|
|
31834
|
-
draftState[changedFieldName].rawValue = originalValue;
|
|
31835
|
-
return draftState;
|
|
31836
|
-
}
|
|
32087
|
+
var set$2 = function set$2(fieldName) {
|
|
32088
|
+
return function (value) {
|
|
32089
|
+
return {
|
|
32090
|
+
type: SET,
|
|
32091
|
+
payload: {
|
|
32092
|
+
fieldName: fieldName,
|
|
32093
|
+
value: value
|
|
32094
|
+
}
|
|
32095
|
+
};
|
|
32096
|
+
};
|
|
32097
|
+
};
|
|
31837
32098
|
|
|
31838
|
-
|
|
31839
|
-
|
|
31840
|
-
|
|
31841
|
-
|
|
31842
|
-
|
|
31843
|
-
|
|
31844
|
-
draftState[fieldName].errors = errors;
|
|
31845
|
-
draftState[fieldName].dirty = dirty;
|
|
31846
|
-
draftState[fieldName].hasErrors = errors.length > 0;
|
|
31847
|
-
}
|
|
31848
|
-
});
|
|
31849
|
-
case CLEAR:
|
|
31850
|
-
return createInitialState(formConfig);
|
|
31851
|
-
default:
|
|
31852
|
-
return state;
|
|
31853
|
-
}
|
|
32099
|
+
var CLEAR = "form/CLEAR";
|
|
32100
|
+
|
|
32101
|
+
var _clear = function clear() {
|
|
32102
|
+
return {
|
|
32103
|
+
type: CLEAR
|
|
32104
|
+
};
|
|
31854
32105
|
};
|
|
31855
32106
|
|
|
31856
|
-
|
|
32107
|
+
var createFormReducer = function createFormReducer(formConfig) {
|
|
32108
|
+
return function () {
|
|
32109
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : createInitialState(formConfig);
|
|
32110
|
+
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
32111
|
+
|
|
32112
|
+
switch (action.type) {
|
|
32113
|
+
case SET:
|
|
32114
|
+
var changedFieldName = action.payload.fieldName;
|
|
32115
|
+
var newRawValue = action.payload.value;
|
|
32116
|
+
return produce(state, function (draftState) {
|
|
32117
|
+
var originalValue = draftState[changedFieldName].rawValue;
|
|
32118
|
+
draftState[changedFieldName].rawValue = newRawValue;
|
|
32119
|
+
|
|
32120
|
+
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
32121
|
+
// If the change violates constraints, revert the change
|
|
32122
|
+
draftState[changedFieldName].rawValue = originalValue;
|
|
32123
|
+
return draftState;
|
|
32124
|
+
}
|
|
32125
|
+
|
|
32126
|
+
var fields = Object.entries(draftState);
|
|
32127
|
+
|
|
32128
|
+
for (var _i3 = 0, _fields = fields; _i3 < _fields.length; _i3++) {
|
|
32129
|
+
var entry = _fields[_i3];
|
|
32130
|
+
var fieldName = entry[0];
|
|
32131
|
+
var field = entry[1];
|
|
32132
|
+
var errors = computeErrors(fieldName, draftState);
|
|
32133
|
+
var dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
32134
|
+
draftState[fieldName].errors = errors;
|
|
32135
|
+
draftState[fieldName].dirty = dirty;
|
|
32136
|
+
draftState[fieldName].hasErrors = errors.length > 0;
|
|
32137
|
+
}
|
|
32138
|
+
});
|
|
32139
|
+
|
|
32140
|
+
case CLEAR:
|
|
32141
|
+
return createInitialState(formConfig);
|
|
32142
|
+
|
|
32143
|
+
default:
|
|
32144
|
+
return state;
|
|
32145
|
+
}
|
|
32146
|
+
};
|
|
32147
|
+
};
|
|
32148
|
+
|
|
32149
|
+
var createMapDispatchToProps = function createMapDispatchToProps(formConfig) {
|
|
31857
32150
|
// Do memo-ization
|
|
31858
|
-
|
|
31859
|
-
|
|
31860
|
-
return dispatch
|
|
32151
|
+
var cachedDispatch;
|
|
32152
|
+
var cacheValue;
|
|
32153
|
+
return function (dispatch) {
|
|
31861
32154
|
if (dispatch == cachedDispatch) {
|
|
31862
32155
|
return cacheValue;
|
|
31863
32156
|
}
|
|
31864
|
-
|
|
32157
|
+
|
|
32158
|
+
var dispatchObj = {};
|
|
31865
32159
|
dispatchObj.fields = {};
|
|
31866
|
-
|
|
31867
|
-
|
|
32160
|
+
var keys = Object.keys(formConfig);
|
|
32161
|
+
|
|
32162
|
+
var _loop = function _loop() {
|
|
32163
|
+
var fieldName = _keys[_i4];
|
|
31868
32164
|
dispatchObj.fields[fieldName] = {
|
|
31869
|
-
set:
|
|
32165
|
+
set: function set(value) {
|
|
32166
|
+
return dispatch(set$2(fieldName)(value));
|
|
32167
|
+
}
|
|
31870
32168
|
};
|
|
32169
|
+
};
|
|
32170
|
+
|
|
32171
|
+
for (var _i4 = 0, _keys = keys; _i4 < _keys.length; _i4++) {
|
|
32172
|
+
_loop();
|
|
31871
32173
|
}
|
|
31872
|
-
|
|
32174
|
+
|
|
32175
|
+
dispatchObj.form = {
|
|
32176
|
+
clear: function clear() {
|
|
32177
|
+
return dispatch(_clear());
|
|
32178
|
+
}
|
|
32179
|
+
};
|
|
31873
32180
|
cachedDispatch = dispatch;
|
|
31874
|
-
cacheValue = {
|
|
32181
|
+
cacheValue = {
|
|
32182
|
+
actions: dispatchObj
|
|
32183
|
+
};
|
|
31875
32184
|
return cacheValue;
|
|
31876
32185
|
};
|
|
31877
32186
|
};
|
|
31878
32187
|
|
|
31879
|
-
|
|
32188
|
+
var mapStateToProps = function mapStateToProps(state) {
|
|
32189
|
+
return {
|
|
32190
|
+
fields: state
|
|
32191
|
+
};
|
|
32192
|
+
};
|
|
31880
32193
|
|
|
31881
|
-
|
|
31882
|
-
|
|
31883
|
-
|
|
31884
|
-
|
|
31885
|
-
|
|
32194
|
+
var createFormState = function createFormState(formConfig) {
|
|
32195
|
+
return {
|
|
32196
|
+
reducer: createFormReducer(formConfig),
|
|
32197
|
+
mapDispatchToProps: createMapDispatchToProps(formConfig),
|
|
32198
|
+
mapStateToProps: mapStateToProps
|
|
32199
|
+
};
|
|
32200
|
+
};
|
|
31886
32201
|
|
|
31887
32202
|
var formatDelimiter = "_";
|
|
31888
32203
|
var phoneFormats = ["", "_", "__", "(___) ", "(___) _", "(___) __", "(___) ___-", "(___) ___-_", "(___) ___-__", "(___) ___-___", "(___) ___-____"];
|
|
@@ -35930,7 +36245,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
35930
36245
|
}, []);
|
|
35931
36246
|
}
|
|
35932
36247
|
|
|
35933
|
-
var amountErrors = (_amountErrors = {}, _defineProperty(_amountErrors, required.error, "Amount is required"), _defineProperty(_amountErrors, numberGreaterThan.error, "Your total payment must be greater than ".concat(displayCurrency(minimum))), _defineProperty(_amountErrors,
|
|
36248
|
+
var amountErrors = (_amountErrors = {}, _defineProperty(_amountErrors, required.error, "Amount is required"), _defineProperty(_amountErrors, numberGreaterThan.error, "Your total payment must be greater than ".concat(displayCurrency(minimum))), _defineProperty(_amountErrors, numberLessThanOrEqualTo.error, "Your total payment must be less than ".concat(displayCurrency(maximum))), _amountErrors);
|
|
35934
36249
|
var lineItemsNew = Array.isArray(lineItems) ? lineItems : [];
|
|
35935
36250
|
return /*#__PURE__*/React__default.createElement(FormContainer$1, {
|
|
35936
36251
|
variant: variant,
|
|
@@ -35975,7 +36290,7 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
|
|
|
35975
36290
|
}, []))];
|
|
35976
36291
|
|
|
35977
36292
|
if (!!maximum) {
|
|
35978
|
-
validators.push(validateSum(
|
|
36293
|
+
validators.push(validateSum(numberLessThanOrEqualTo(maximum), lineItems.filter(function (lineItem) {
|
|
35979
36294
|
return lineItem != item;
|
|
35980
36295
|
}).reduce(function (acc, curr) {
|
|
35981
36296
|
return [].concat(_toConsumableArray(acc), [curr.id]);
|