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