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