@thecb/components 3.5.12-beta.0 → 3.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js
CHANGED
|
@@ -215,63 +215,6 @@ function _nonIterableRest() {
|
|
|
215
215
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
219
|
-
var it;
|
|
220
|
-
|
|
221
|
-
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
|
222
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
223
|
-
if (it) o = it;
|
|
224
|
-
var i = 0;
|
|
225
|
-
|
|
226
|
-
var F = function () {};
|
|
227
|
-
|
|
228
|
-
return {
|
|
229
|
-
s: F,
|
|
230
|
-
n: function () {
|
|
231
|
-
if (i >= o.length) return {
|
|
232
|
-
done: true
|
|
233
|
-
};
|
|
234
|
-
return {
|
|
235
|
-
done: false,
|
|
236
|
-
value: o[i++]
|
|
237
|
-
};
|
|
238
|
-
},
|
|
239
|
-
e: function (e) {
|
|
240
|
-
throw e;
|
|
241
|
-
},
|
|
242
|
-
f: F
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
var normalCompletion = true,
|
|
250
|
-
didErr = false,
|
|
251
|
-
err;
|
|
252
|
-
return {
|
|
253
|
-
s: function () {
|
|
254
|
-
it = o[Symbol.iterator]();
|
|
255
|
-
},
|
|
256
|
-
n: function () {
|
|
257
|
-
var step = it.next();
|
|
258
|
-
normalCompletion = step.done;
|
|
259
|
-
return step;
|
|
260
|
-
},
|
|
261
|
-
e: function (e) {
|
|
262
|
-
didErr = true;
|
|
263
|
-
err = e;
|
|
264
|
-
},
|
|
265
|
-
f: function () {
|
|
266
|
-
try {
|
|
267
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
268
|
-
} finally {
|
|
269
|
-
if (didErr) throw err;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
|
|
275
218
|
/*! *****************************************************************************
|
|
276
219
|
Copyright (c) Microsoft Corporation.
|
|
277
220
|
|
|
@@ -10095,9 +10038,11 @@ function usePanGesture(_a, ref) {
|
|
|
10095
10038
|
onPanEnd && onPanEnd(event, info);
|
|
10096
10039
|
},
|
|
10097
10040
|
};
|
|
10098
|
-
|
|
10099
|
-
panSession.current
|
|
10100
|
-
|
|
10041
|
+
React.useEffect(function () {
|
|
10042
|
+
if (panSession.current !== null) {
|
|
10043
|
+
panSession.current.updateHandlers(handlers);
|
|
10044
|
+
}
|
|
10045
|
+
});
|
|
10101
10046
|
function onPointerDown(event) {
|
|
10102
10047
|
panSession.current = new PanSession(event, handlers, {
|
|
10103
10048
|
transformPagePoint: transformPagePoint,
|
|
@@ -14294,21 +14239,18 @@ var fallbackValues$4 = {
|
|
|
14294
14239
|
var Alert = function Alert(_ref) {
|
|
14295
14240
|
var heading = _ref.heading,
|
|
14296
14241
|
text = _ref.text,
|
|
14297
|
-
textOverride = _ref.textOverride,
|
|
14298
14242
|
variant = _ref.variant,
|
|
14299
14243
|
children = _ref.children,
|
|
14300
14244
|
height = _ref.height,
|
|
14301
14245
|
onLinkClick = _ref.onLinkClick,
|
|
14302
|
-
_ref$padding = _ref.padding,
|
|
14303
|
-
padding = _ref$padding === void 0 ? "0.5rem" : _ref$padding,
|
|
14304
14246
|
_ref$showQuitLink = _ref.showQuitLink,
|
|
14305
14247
|
showQuitLink = _ref$showQuitLink === void 0 ? true : _ref$showQuitLink,
|
|
14306
14248
|
themeValues = _ref.themeValues;
|
|
14307
14249
|
var Icon = AlertIcons[variant];
|
|
14308
14250
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
14309
|
-
padding:
|
|
14251
|
+
padding: "0.5rem",
|
|
14310
14252
|
width: "100%",
|
|
14311
|
-
minHeight:
|
|
14253
|
+
minHeight: "100px",
|
|
14312
14254
|
height: height ? height : "auto",
|
|
14313
14255
|
background: themeValues.background,
|
|
14314
14256
|
borderRadius: "4px",
|
|
@@ -14334,11 +14276,11 @@ var Alert = function Alert(_ref) {
|
|
|
14334
14276
|
width: "24px",
|
|
14335
14277
|
childGap: "0rem"
|
|
14336
14278
|
}, /*#__PURE__*/React__default.createElement(Box, {
|
|
14337
|
-
padding: "
|
|
14279
|
+
padding: "1rem"
|
|
14338
14280
|
}, /*#__PURE__*/React__default.createElement(Cluster, {
|
|
14339
14281
|
justify: "flex-start",
|
|
14340
14282
|
align: "center"
|
|
14341
|
-
},
|
|
14283
|
+
}, /*#__PURE__*/React__default.createElement(Stack, {
|
|
14342
14284
|
fullHeight: true,
|
|
14343
14285
|
childGap: "0.25rem"
|
|
14344
14286
|
}, /*#__PURE__*/React__default.createElement(Text$1, {
|
|
@@ -15403,7 +15345,7 @@ _curry2(function nth(offset, list) {
|
|
|
15403
15345
|
*
|
|
15404
15346
|
* @func
|
|
15405
15347
|
* @memberOf R
|
|
15406
|
-
* @since v0.27.
|
|
15348
|
+
* @since v0.27.1
|
|
15407
15349
|
* @category Object
|
|
15408
15350
|
* @typedefn Idx = [String | Int]
|
|
15409
15351
|
* @sig [Idx] -> {a} -> [a | Undefined]
|
|
@@ -18502,8 +18444,28 @@ var fallbackValues$e = {
|
|
|
18502
18444
|
hoverFocusStyles: hoverFocusStyles
|
|
18503
18445
|
};
|
|
18504
18446
|
|
|
18447
|
+
function _templateObject4$4() {
|
|
18448
|
+
var data = _taggedTemplateLiteral(["\n ", "\n "]);
|
|
18449
|
+
|
|
18450
|
+
_templateObject4$4 = function _templateObject4() {
|
|
18451
|
+
return data;
|
|
18452
|
+
};
|
|
18453
|
+
|
|
18454
|
+
return data;
|
|
18455
|
+
}
|
|
18456
|
+
|
|
18457
|
+
function _templateObject3$7() {
|
|
18458
|
+
var data = _taggedTemplateLiteral(["\n border: 1px solid\n ", ";\n border-radius: 2px;\n height: ", ";\n width: 100%;\n padding: 1rem;\n min-width: 100px;\n margin: 0;\n box-sizing: border-box;\n position: relative;\n font-size: 1.1rem;\n line-height: 2rem;\n font-weight: ", ";\n background-color: ", ";\n color: ", ";\n box-shadow: none;\n\n &:focus {\n border: 1px solid ", ";\n }\n\n ", "\n"]);
|
|
18459
|
+
|
|
18460
|
+
_templateObject3$7 = function _templateObject3() {
|
|
18461
|
+
return data;
|
|
18462
|
+
};
|
|
18463
|
+
|
|
18464
|
+
return data;
|
|
18465
|
+
}
|
|
18466
|
+
|
|
18505
18467
|
function _templateObject2$d() {
|
|
18506
|
-
var data = _taggedTemplateLiteral(["\n
|
|
18468
|
+
var data = _taggedTemplateLiteral(["\n ", "\n "]);
|
|
18507
18469
|
|
|
18508
18470
|
_templateObject2$d = function _templateObject2() {
|
|
18509
18471
|
return data;
|
|
@@ -18513,7 +18475,7 @@ function _templateObject2$d() {
|
|
|
18513
18475
|
}
|
|
18514
18476
|
|
|
18515
18477
|
function _templateObject$p() {
|
|
18516
|
-
var data = _taggedTemplateLiteral(["\n border: 1px solid\n ", ";\n border-radius: 2px;\n height:
|
|
18478
|
+
var data = _taggedTemplateLiteral(["\n border: 1px solid\n ", ";\n border-radius: 2px;\n height: ", ";\n width: 100%;\n padding: 1rem;\n min-width: 100px;\n margin: 0;\n box-sizing: border-box;\n position: relative;\n font-size: 1.1rem;\n font-family: Public Sans;\n line-height: 2rem;\n font-weight: ", ";\n background-color: ", ";\n color: ", ";\n box-shadow: none;\n ", "\n transition: background 0.3s ease;\n\n &:focus {\n border: 1px solid ", ";\n }\n\n ", "\n"]);
|
|
18517
18479
|
|
|
18518
18480
|
_templateObject$p = function _templateObject() {
|
|
18519
18481
|
return data;
|
|
@@ -18526,54 +18488,68 @@ var InputField = styled__default.input(_templateObject$p(), function (_ref) {
|
|
|
18526
18488
|
showErrors = _ref.showErrors,
|
|
18527
18489
|
themeValues = _ref.themeValues;
|
|
18528
18490
|
return field.dirty && field.hasErrors || field.hasErrors && showErrors ? ERROR_COLOR : themeValues.borderColor;
|
|
18529
|
-
},
|
|
18530
|
-
var
|
|
18531
|
-
return
|
|
18532
|
-
}, function (_ref3) {
|
|
18491
|
+
}, function (_ref2) {
|
|
18492
|
+
var customHeight = _ref2.customHeight;
|
|
18493
|
+
return customHeight ? customHeight : "48px";
|
|
18494
|
+
}, FONT_WEIGHT_REGULAR, function (_ref3) {
|
|
18533
18495
|
var themeValues = _ref3.themeValues;
|
|
18534
|
-
return themeValues.
|
|
18496
|
+
return themeValues.inputBackgroundColor && themeValues.inputBackgroundColor;
|
|
18535
18497
|
}, function (_ref4) {
|
|
18536
|
-
var
|
|
18537
|
-
|
|
18498
|
+
var themeValues = _ref4.themeValues;
|
|
18499
|
+
return themeValues.color && themeValues.color;
|
|
18500
|
+
}, function (_ref5) {
|
|
18501
|
+
var background = _ref5.background,
|
|
18502
|
+
themeValues = _ref5.themeValues;
|
|
18538
18503
|
return background && "background: ".concat(themeValues.inputBackgroundColor, " url(").concat(background, ") no-repeat right 0.5rem center;");
|
|
18539
|
-
}, MATISSE_BLUE
|
|
18504
|
+
}, MATISSE_BLUE, function (_ref6) {
|
|
18505
|
+
var extraStyles = _ref6.extraStyles;
|
|
18506
|
+
return styled.css(_templateObject2$d(), extraStyles);
|
|
18507
|
+
}); // eslint-disable-next-line no-unused-vars
|
|
18540
18508
|
|
|
18541
|
-
var FormattedInputField = styled__default(function (
|
|
18542
|
-
var showErrors =
|
|
18543
|
-
props = _objectWithoutProperties(
|
|
18509
|
+
var FormattedInputField = styled__default(function (_ref7) {
|
|
18510
|
+
var showErrors = _ref7.showErrors,
|
|
18511
|
+
props = _objectWithoutProperties(_ref7, ["showErrors"]);
|
|
18544
18512
|
|
|
18545
18513
|
return /*#__PURE__*/React__default.createElement(src_1, props);
|
|
18546
|
-
})(
|
|
18547
|
-
var field =
|
|
18548
|
-
showErrors =
|
|
18549
|
-
themeValues =
|
|
18514
|
+
})(_templateObject3$7(), function (_ref8) {
|
|
18515
|
+
var field = _ref8.field,
|
|
18516
|
+
showErrors = _ref8.showErrors,
|
|
18517
|
+
themeValues = _ref8.themeValues;
|
|
18550
18518
|
return field.dirty && field.hasErrors || field.hasErrors && showErrors ? ERROR_COLOR : themeValues.borderColor;
|
|
18551
|
-
},
|
|
18552
|
-
var
|
|
18519
|
+
}, function (_ref9) {
|
|
18520
|
+
var customHeight = _ref9.customHeight;
|
|
18521
|
+
return customHeight ? customHeight : "48px";
|
|
18522
|
+
}, FONT_WEIGHT_REGULAR, function (_ref10) {
|
|
18523
|
+
var themeValues = _ref10.themeValues;
|
|
18553
18524
|
return themeValues.inputBackgroundColor && themeValues.inputBackgroundColor;
|
|
18554
|
-
}, function (
|
|
18555
|
-
var themeValues =
|
|
18525
|
+
}, function (_ref11) {
|
|
18526
|
+
var themeValues = _ref11.themeValues;
|
|
18556
18527
|
return themeValues.color && themeValues.color;
|
|
18557
|
-
}, MATISSE_BLUE)
|
|
18528
|
+
}, MATISSE_BLUE, function (_ref12) {
|
|
18529
|
+
var extraStyles = _ref12.extraStyles;
|
|
18530
|
+
return styled.css(_templateObject4$4(), extraStyles);
|
|
18531
|
+
});
|
|
18558
18532
|
|
|
18559
|
-
var FormInput = function FormInput(
|
|
18560
|
-
var
|
|
18561
|
-
type =
|
|
18562
|
-
labelTextWhenNoError =
|
|
18563
|
-
errorMessages =
|
|
18564
|
-
|
|
18565
|
-
isNum =
|
|
18566
|
-
|
|
18567
|
-
helperModal =
|
|
18568
|
-
field =
|
|
18569
|
-
fieldActions =
|
|
18570
|
-
showErrors =
|
|
18571
|
-
|
|
18572
|
-
formatter =
|
|
18573
|
-
decorator =
|
|
18574
|
-
themeValues =
|
|
18575
|
-
background =
|
|
18576
|
-
|
|
18533
|
+
var FormInput = function FormInput(_ref13) {
|
|
18534
|
+
var _ref13$type = _ref13.type,
|
|
18535
|
+
type = _ref13$type === void 0 ? "text" : _ref13$type,
|
|
18536
|
+
labelTextWhenNoError = _ref13.labelTextWhenNoError,
|
|
18537
|
+
errorMessages = _ref13.errorMessages,
|
|
18538
|
+
_ref13$isNum = _ref13.isNum,
|
|
18539
|
+
isNum = _ref13$isNum === void 0 ? false : _ref13$isNum,
|
|
18540
|
+
_ref13$helperModal = _ref13.helperModal,
|
|
18541
|
+
helperModal = _ref13$helperModal === void 0 ? false : _ref13$helperModal,
|
|
18542
|
+
field = _ref13.field,
|
|
18543
|
+
fieldActions = _ref13.fieldActions,
|
|
18544
|
+
showErrors = _ref13.showErrors,
|
|
18545
|
+
_ref13$formatter = _ref13.formatter,
|
|
18546
|
+
formatter = _ref13$formatter === void 0 ? null : _ref13$formatter,
|
|
18547
|
+
decorator = _ref13.decorator,
|
|
18548
|
+
themeValues = _ref13.themeValues,
|
|
18549
|
+
background = _ref13.background,
|
|
18550
|
+
customHeight = _ref13.customHeight,
|
|
18551
|
+
extraStyles = _ref13.extraStyles,
|
|
18552
|
+
props = _objectWithoutProperties(_ref13, ["type", "labelTextWhenNoError", "errorMessages", "isNum", "helperModal", "field", "fieldActions", "showErrors", "formatter", "decorator", "themeValues", "background", "customHeight", "extraStyles"]);
|
|
18577
18553
|
|
|
18578
18554
|
var _useState = React.useState(false),
|
|
18579
18555
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -18643,7 +18619,9 @@ var FormInput = function FormInput(_ref9) {
|
|
|
18643
18619
|
formatter: formatter,
|
|
18644
18620
|
showErrors: showErrors,
|
|
18645
18621
|
"data-qa": labelTextWhenNoError,
|
|
18646
|
-
themeValues: themeValues
|
|
18622
|
+
themeValues: themeValues,
|
|
18623
|
+
customHeight: customHeight,
|
|
18624
|
+
extraStyles: extraStyles
|
|
18647
18625
|
}, props)) : /*#__PURE__*/React__default.createElement(InputField, _extends({
|
|
18648
18626
|
"aria-labelledby": labelTextWhenNoError,
|
|
18649
18627
|
onChange: function onChange(e) {
|
|
@@ -18657,7 +18635,9 @@ var FormInput = function FormInput(_ref9) {
|
|
|
18657
18635
|
showErrors: showErrors,
|
|
18658
18636
|
"data-qa": labelTextWhenNoError,
|
|
18659
18637
|
themeValues: themeValues,
|
|
18660
|
-
background: background
|
|
18638
|
+
background: background,
|
|
18639
|
+
customHeight: customHeight,
|
|
18640
|
+
extraStyles: extraStyles
|
|
18661
18641
|
}, props))), /*#__PURE__*/React__default.createElement(Stack, {
|
|
18662
18642
|
direction: "row",
|
|
18663
18643
|
justify: "space-between"
|
|
@@ -18887,10 +18867,10 @@ var FormattedCreditCard = function FormattedCreditCard(_ref) {
|
|
|
18887
18867
|
|
|
18888
18868
|
var FormattedCreditCard$1 = themeComponent(FormattedCreditCard, "FormattedCreditCard", fallbackValues$g, "default");
|
|
18889
18869
|
|
|
18890
|
-
function _templateObject3$
|
|
18870
|
+
function _templateObject3$8() {
|
|
18891
18871
|
var data = _taggedTemplateLiteral(["\n display: block;\n top: auto;\n bottom: 6px;\n left: 2px;\n transition-duration: 0.13s;\n transition-delay: 0.13s;\n transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);\n margin-top: 12px;\n background-color: ", ";\n\n &, &::before, &::after {\n background-color: ", ";\n width: 30px;\n height: 3px;\n position: absolute;\n transition-property: transform;\n transition-duration: 0.15s;\n transition-timing-function: ease;\n }\n\n &::before, &::after {\n content: \"\";\n display: block;\n }\n\n &::before {\n top: -10px;\n transition: top 0.12s 0.2s cubic-bezier(0.33333, 0.66667, 0.66667, 1), \n transform 0.13s cubic-bezier(0.55, 0.055, 0.675, 0.19);\n }\n\n &::after {\n bottom: -10px;\n top: -20px;\n transition: top 0.2s 0.2s cubic-bezier(0.33333, 0.66667, 0.66667, 1), \n opacity 0.1s linear;\n }\n\n &.active, &.active::before, &.active::after {\n background-color: ", ";\n }\n\n &.active {\n transform: translate3d(0, -10px, 0) rotate(-45deg);\n transition-delay: 0.22s;\n transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);\n }\n\n &.active::after {\n top: 0;\n opacity: 0;\n transition: top 0.2s cubic-bezier(0.33333, 0, 0.66667, 0.33333), \n opacity: 0.1s 0.22s linear;\n }\n\n &.active::before {\n top: 0;\n transform: rotate(-90deg);\n transition: top 0.1s 0.16s cubic-bezier(0.33333, 0, 0.66667, 0.33333), \n transform 0.13s 0.25s cubic-bezier(0.215, 0.61, 0.355, 1);\n }\n"]);
|
|
18892
18872
|
|
|
18893
|
-
_templateObject3$
|
|
18873
|
+
_templateObject3$8 = function _templateObject3() {
|
|
18894
18874
|
return data;
|
|
18895
18875
|
};
|
|
18896
18876
|
|
|
@@ -18918,7 +18898,7 @@ function _templateObject$r() {
|
|
|
18918
18898
|
}
|
|
18919
18899
|
var Hamburger = styled__default.button(_templateObject$r());
|
|
18920
18900
|
var HamburgerBox = styled__default.span(_templateObject2$f());
|
|
18921
|
-
var HamburgerInner = styled__default.span(_templateObject3$
|
|
18901
|
+
var HamburgerInner = styled__default.span(_templateObject3$8(), function (_ref) {
|
|
18922
18902
|
var inactiveColor = _ref.inactiveColor;
|
|
18923
18903
|
return inactiveColor;
|
|
18924
18904
|
}, function (_ref2) {
|
|
@@ -19341,20 +19321,20 @@ function _templateObject5$2() {
|
|
|
19341
19321
|
return data;
|
|
19342
19322
|
}
|
|
19343
19323
|
|
|
19344
|
-
function _templateObject4$
|
|
19324
|
+
function _templateObject4$5() {
|
|
19345
19325
|
var data = _taggedTemplateLiteral(["", " is not a valid length"]);
|
|
19346
19326
|
|
|
19347
|
-
_templateObject4$
|
|
19327
|
+
_templateObject4$5 = function _templateObject4() {
|
|
19348
19328
|
return data;
|
|
19349
19329
|
};
|
|
19350
19330
|
|
|
19351
19331
|
return data;
|
|
19352
19332
|
}
|
|
19353
19333
|
|
|
19354
|
-
function _templateObject3$
|
|
19334
|
+
function _templateObject3$9() {
|
|
19355
19335
|
var data = _taggedTemplateLiteral(["", " is not the right length"]);
|
|
19356
19336
|
|
|
19357
|
-
_templateObject3$
|
|
19337
|
+
_templateObject3$9 = function _templateObject3() {
|
|
19358
19338
|
return data;
|
|
19359
19339
|
};
|
|
19360
19340
|
|
|
@@ -19420,7 +19400,7 @@ with interpolation.
|
|
|
19420
19400
|
*/
|
|
19421
19401
|
|
|
19422
19402
|
|
|
19423
|
-
var DEFAULT_ERROR_MESSAGES = (_DEFAULT_ERROR_MESSAG = {}, _defineProperty(_DEFAULT_ERROR_MESSAG, MIN_LENGTH_ERROR, genErrorMessage(_templateObject$t(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, MAX_LENGTH_ERROR, genErrorMessage(_templateObject2$h(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, EXACT_LENGTH_ERROR, genErrorMessage(_templateObject3$
|
|
19403
|
+
var DEFAULT_ERROR_MESSAGES = (_DEFAULT_ERROR_MESSAG = {}, _defineProperty(_DEFAULT_ERROR_MESSAG, MIN_LENGTH_ERROR, genErrorMessage(_templateObject$t(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, MAX_LENGTH_ERROR, genErrorMessage(_templateObject2$h(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, EXACT_LENGTH_ERROR, genErrorMessage(_templateObject3$9(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, MULTIPLE_LENGTHS_ERROR, genErrorMessage(_templateObject4$5(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, EMAIL_ERROR, genErrorMessage(_templateObject5$2(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, HAS_NUMBER_ERROR, genErrorMessage(_templateObject6$2(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, HAS_UPPERCASE_LETTER_ERROR, genErrorMessage(_templateObject7$2(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, HAS_LOWERCASE_LETTER_ERROR, genErrorMessage(_templateObject8$1(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, HAS_SPECIAL_CHARACTER_ERROR, genErrorMessage(_templateObject9$1(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, ONLY_NUMBERS_ERROR, genErrorMessage(_templateObject10$1(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, ONLY_LETTERS_ERROR, genErrorMessage(_templateObject11$1(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, REQUIRED_FIELD_ERROR, genErrorMessage(_templateObject12(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, NUM_GREATER_THAN_ERROR, genErrorMessage(_templateObject13(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, NUM_LESS_THAN_ERROR, genErrorMessage(_templateObject14(), "fieldLabel")), _defineProperty(_DEFAULT_ERROR_MESSAG, MATCHES_FIELD_ERROR, genErrorMessage(_templateObject15(), "fieldLabel", "matchField")), _defineProperty(_DEFAULT_ERROR_MESSAG, VALID_SELECT_OPTION_ERROR, genErrorMessage(_templateObject16(), "fieldLabel")), _DEFAULT_ERROR_MESSAG); // Constants to represent an input's state
|
|
19424
19404
|
// Neutral - has not been validated
|
|
19425
19405
|
// Invalid - has been validated and has an error
|
|
19426
19406
|
// Valid - has been validated and has no error
|
|
@@ -30382,20 +30362,20 @@ var fallbackValues$o = {
|
|
|
30382
30362
|
leftLabelStyles: leftLabelStyles
|
|
30383
30363
|
};
|
|
30384
30364
|
|
|
30385
|
-
function _templateObject4$
|
|
30365
|
+
function _templateObject4$6() {
|
|
30386
30366
|
var data = _taggedTemplateLiteral(["\n position: absolute;\n width: 14px;\n height: 14px;\n top: 3px;\n left: 3px;\n right: 3px;\n bottom: 3px;\n border-radius: 50%;\n box-sizing: border-box;\n"]);
|
|
30387
30367
|
|
|
30388
|
-
_templateObject4$
|
|
30368
|
+
_templateObject4$6 = function _templateObject4() {
|
|
30389
30369
|
return data;
|
|
30390
30370
|
};
|
|
30391
30371
|
|
|
30392
30372
|
return data;
|
|
30393
30373
|
}
|
|
30394
30374
|
|
|
30395
|
-
function _templateObject3$
|
|
30375
|
+
function _templateObject3$a() {
|
|
30396
30376
|
var data = _taggedTemplateLiteral(["\n position: absolute;\n width: 20px;\n height: 20px;\n border: none;\n border-radius: 50%;\n box-sizing: border-box;\n"]);
|
|
30397
30377
|
|
|
30398
|
-
_templateObject3$
|
|
30378
|
+
_templateObject3$a = function _templateObject3() {
|
|
30399
30379
|
return data;
|
|
30400
30380
|
};
|
|
30401
30381
|
|
|
@@ -30438,8 +30418,8 @@ var VisibleSwitchComponent = styled__default.label(_templateObject2$i(), functio
|
|
|
30438
30418
|
var isMobile = _ref5.isMobile;
|
|
30439
30419
|
return isMobile ? "transform: scale(0.75)" : "";
|
|
30440
30420
|
});
|
|
30441
|
-
var ToggleSwitchMiddleRingComponent = styled__default.div(_templateObject3$
|
|
30442
|
-
var ToggleSwitchInnerRingComponent = styled__default.div(_templateObject4$
|
|
30421
|
+
var ToggleSwitchMiddleRingComponent = styled__default.div(_templateObject3$a());
|
|
30422
|
+
var ToggleSwitchInnerRingComponent = styled__default.div(_templateObject4$6());
|
|
30443
30423
|
|
|
30444
30424
|
var ToggleSwitch = function ToggleSwitch(_ref6) {
|
|
30445
30425
|
var _ref6$isOn = _ref6.isOn,
|
|
@@ -30576,401 +30556,378 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
|
|
|
30576
30556
|
|
|
30577
30557
|
var ToggleSwitch$1 = themeComponent(ToggleSwitch, "ToggleSwitch", fallbackValues$o);
|
|
30578
30558
|
|
|
30579
|
-
|
|
30580
|
-
|
|
30581
|
-
|
|
30582
|
-
|
|
30583
|
-
}
|
|
30559
|
+
const validatorToPredicate = (validatorFn, emptyCase) => (
|
|
30560
|
+
value,
|
|
30561
|
+
...rest
|
|
30562
|
+
) => (value === "" ? emptyCase : validatorFn(value, ...rest));
|
|
30584
30563
|
|
|
30585
|
-
return value === "" ? emptyCase : validatorFn.apply(void 0, [value].concat(rest));
|
|
30586
|
-
};
|
|
30587
|
-
};
|
|
30588
30564
|
/* eslint-disable no-unused-vars */
|
|
30589
30565
|
|
|
30590
|
-
|
|
30591
|
-
|
|
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
|
-
|
|
30566
|
+
const createValidator = (type, error) => {
|
|
30567
|
+
let validator = (...args) => ({ type, args, error });
|
|
30604
30568
|
validator.error = error;
|
|
30605
30569
|
return validator;
|
|
30606
30570
|
};
|
|
30607
30571
|
|
|
30608
|
-
|
|
30609
|
-
var REQUIRED = "validator/REQUIRED";
|
|
30610
|
-
var REQUIRED_ERROR = "error/REQUIRED";
|
|
30611
|
-
var required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
30572
|
+
let validatorFns = {};
|
|
30612
30573
|
|
|
30613
|
-
|
|
30614
|
-
|
|
30615
|
-
|
|
30616
|
-
|
|
30617
|
-
var ONLY_INTEGERS = "validator/ONLY_INTEGERS";
|
|
30618
|
-
var ONLY_INTEGERS_ERROR = "error/ONLY_INTEGERS";
|
|
30619
|
-
var onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
30620
|
-
|
|
30621
|
-
validatorFns[ONLY_INTEGERS] = function (value, args, form) {
|
|
30622
|
-
return /^(-?\d+)?$/.test(value);
|
|
30623
|
-
};
|
|
30624
|
-
|
|
30625
|
-
var ONLY_NATURALS = "validator/ONLY_NATURALS";
|
|
30626
|
-
var ONLY_NATURALS_ERROR = "error/ONLY_NATURALS";
|
|
30627
|
-
var onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
30574
|
+
const REQUIRED = "validator/REQUIRED";
|
|
30575
|
+
const REQUIRED_ERROR = "error/REQUIRED";
|
|
30576
|
+
const required = createValidator(REQUIRED, REQUIRED_ERROR);
|
|
30577
|
+
validatorFns[REQUIRED] = (value, args, form) => value !== "";
|
|
30628
30578
|
|
|
30629
|
-
|
|
30630
|
-
|
|
30631
|
-
|
|
30579
|
+
const ONLY_INTEGERS = "validator/ONLY_INTEGERS";
|
|
30580
|
+
const ONLY_INTEGERS_ERROR = "error/ONLY_INTEGERS";
|
|
30581
|
+
const onlyIntegers = createValidator(ONLY_INTEGERS, ONLY_INTEGERS_ERROR);
|
|
30582
|
+
validatorFns[ONLY_INTEGERS] = (value, args, form) => /^(-?\d+)?$/.test(value);
|
|
30632
30583
|
|
|
30633
|
-
|
|
30634
|
-
|
|
30635
|
-
|
|
30584
|
+
const ONLY_NATURALS = "validator/ONLY_NATURALS";
|
|
30585
|
+
const ONLY_NATURALS_ERROR = "error/ONLY_NATURALS";
|
|
30586
|
+
const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
|
|
30587
|
+
validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
|
|
30636
30588
|
|
|
30637
|
-
|
|
30589
|
+
const NUMBER_LESS_THAN = "validator/NUMBER_LESS_THAN";
|
|
30590
|
+
const NUMBER_LESS_THAN_ERROR = "error/NUMBER_LESS_THAN";
|
|
30591
|
+
const numberLessThan = createValidator(
|
|
30592
|
+
NUMBER_LESS_THAN,
|
|
30593
|
+
NUMBER_LESS_THAN_ERROR
|
|
30594
|
+
);
|
|
30595
|
+
validatorFns[NUMBER_LESS_THAN] = (value, args, form) => {
|
|
30638
30596
|
if (value === "") {
|
|
30639
30597
|
return true;
|
|
30640
30598
|
}
|
|
30641
|
-
|
|
30642
30599
|
return Number(value) < args[0];
|
|
30643
30600
|
};
|
|
30644
30601
|
|
|
30645
|
-
|
|
30646
|
-
|
|
30647
|
-
|
|
30648
|
-
|
|
30649
|
-
|
|
30602
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO =
|
|
30603
|
+
"validator/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
30604
|
+
const NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR =
|
|
30605
|
+
"error/NUMBER_LESS_THAN_OR_EQUAL_TO";
|
|
30606
|
+
const numberLessThanOrEqualTo = createValidator(
|
|
30607
|
+
NUMBER_LESS_THAN_OR_EQUAL_TO,
|
|
30608
|
+
NUMBER_LESS_THAN_OR_EQUAL_TO_ERROR
|
|
30609
|
+
);
|
|
30610
|
+
validatorFns[NUMBER_LESS_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
30650
30611
|
if (value === "") {
|
|
30651
30612
|
return true;
|
|
30652
30613
|
}
|
|
30653
|
-
|
|
30654
30614
|
return Number(value) <= args[0];
|
|
30655
30615
|
};
|
|
30656
30616
|
|
|
30657
|
-
|
|
30658
|
-
|
|
30659
|
-
|
|
30660
|
-
|
|
30661
|
-
|
|
30617
|
+
const NUMBER_GREATER_THAN = "validator/NUMBER_GREATER_THAN";
|
|
30618
|
+
const NUMBER_GREATER_THAN_ERROR = "error/NUMBER_GREATER_THAN";
|
|
30619
|
+
const numberGreaterThan = createValidator(
|
|
30620
|
+
NUMBER_GREATER_THAN,
|
|
30621
|
+
NUMBER_GREATER_THAN_ERROR
|
|
30622
|
+
);
|
|
30623
|
+
validatorFns[NUMBER_GREATER_THAN] = (value, args, form) => {
|
|
30662
30624
|
if (value === "") {
|
|
30663
30625
|
return true;
|
|
30664
30626
|
}
|
|
30665
|
-
|
|
30666
30627
|
return Number(value) > args[0];
|
|
30667
30628
|
};
|
|
30668
30629
|
|
|
30669
|
-
|
|
30670
|
-
|
|
30671
|
-
|
|
30672
|
-
|
|
30673
|
-
|
|
30630
|
+
const NUMBER_GREATER_THAN_OR_EQUAL_TO =
|
|
30631
|
+
"validator/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
30632
|
+
const NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR =
|
|
30633
|
+
"error/NUMBER_GREATER_THAN_OR_EQUAL_TO";
|
|
30634
|
+
const numberGreaterThanOrEqualTo = createValidator(
|
|
30635
|
+
NUMBER_GREATER_THAN_OR_EQUAL_TO,
|
|
30636
|
+
NUMBER_GREATER_THAN_OR_EQUAL_TO_ERROR
|
|
30637
|
+
);
|
|
30638
|
+
validatorFns[NUMBER_GREATER_THAN_OR_EQUAL_TO] = (value, args, form) => {
|
|
30674
30639
|
if (value === "") {
|
|
30675
30640
|
return true;
|
|
30676
30641
|
}
|
|
30677
|
-
|
|
30678
30642
|
return Number(value) >= args[0];
|
|
30679
30643
|
};
|
|
30680
30644
|
|
|
30681
|
-
|
|
30682
|
-
|
|
30683
|
-
|
|
30684
|
-
|
|
30685
|
-
validatorFns[MATCHES_FIELD] = function (value, args, form) {
|
|
30645
|
+
const MATCHES_FIELD = "validator/MATCHES_FIELD";
|
|
30646
|
+
const MATCHES_FIELD_ERROR$1 = "error/MATCHES_FIELD";
|
|
30647
|
+
const matchesField = createValidator(MATCHES_FIELD, MATCHES_FIELD_ERROR$1);
|
|
30648
|
+
validatorFns[MATCHES_FIELD] = (value, args, form) => {
|
|
30686
30649
|
if (value === "") {
|
|
30687
30650
|
return true;
|
|
30688
30651
|
}
|
|
30689
|
-
|
|
30690
30652
|
if (form[args[0]] === undefined) {
|
|
30691
|
-
throw new Error(
|
|
30653
|
+
throw new Error(
|
|
30654
|
+
`${args[0]} was passed to matchesField, but that field does not exist in the form`
|
|
30655
|
+
);
|
|
30692
30656
|
}
|
|
30693
|
-
|
|
30694
30657
|
return value === form[args[0]].rawValue;
|
|
30695
30658
|
};
|
|
30696
30659
|
|
|
30697
|
-
|
|
30698
|
-
|
|
30699
|
-
|
|
30700
|
-
|
|
30701
|
-
|
|
30702
|
-
|
|
30703
|
-
|
|
30704
|
-
|
|
30705
|
-
|
|
30706
|
-
|
|
30707
|
-
|
|
30708
|
-
|
|
30709
|
-
|
|
30710
|
-
|
|
30711
|
-
|
|
30660
|
+
const validateWhenErrorMessage = type =>
|
|
30661
|
+
`${type} was passed to validateWhen, but that validator type does not exist.
|
|
30662
|
+
Please check that you are only calling validator creator functions exported from
|
|
30663
|
+
redux-freeform in your form config and that you didn't forget to
|
|
30664
|
+
invoke the validator creator (you cannot pass the functions themselves to
|
|
30665
|
+
createFormState). Also make sure you aren't passing validateWhen() to validateWhen
|
|
30666
|
+
as the primary validator.`;
|
|
30667
|
+
|
|
30668
|
+
const VALIDATE_WHEN = "validator/VALIDATE_WHEN";
|
|
30669
|
+
const VALIDATE_WHEN_ERROR = "error/VALIDATE_WHEN";
|
|
30670
|
+
const validateWhen = (
|
|
30671
|
+
dependentValidator,
|
|
30672
|
+
primaryValidator,
|
|
30673
|
+
optionalFieldName
|
|
30674
|
+
) => ({
|
|
30675
|
+
type: VALIDATE_WHEN,
|
|
30676
|
+
args: [dependentValidator, primaryValidator, optionalFieldName],
|
|
30677
|
+
error: dependentValidator.error
|
|
30678
|
+
});
|
|
30712
30679
|
validateWhen.error = VALIDATE_WHEN_ERROR;
|
|
30680
|
+
validatorFns[VALIDATE_WHEN] = (value, args, form) => {
|
|
30681
|
+
const [dependentValidator, primaryValidator, optionalFieldName] = args;
|
|
30682
|
+
const dependsOnOtherField = typeof optionalFieldName === "string";
|
|
30713
30683
|
|
|
30714
|
-
|
|
30715
|
-
|
|
30716
|
-
|
|
30717
|
-
|
|
30718
|
-
optionalFieldName = _args[2];
|
|
30719
|
-
|
|
30720
|
-
var dependsOnOtherField = typeof optionalFieldName === "string";
|
|
30721
|
-
|
|
30722
|
-
if (primaryValidator.type === undefined || typeof validatorFns[primaryValidator.type] !== "function") {
|
|
30684
|
+
if (
|
|
30685
|
+
primaryValidator.type === undefined ||
|
|
30686
|
+
typeof validatorFns[primaryValidator.type] !== "function"
|
|
30687
|
+
) {
|
|
30723
30688
|
throw new Error(validateWhenErrorMessage(primaryValidator.type));
|
|
30724
30689
|
}
|
|
30725
|
-
|
|
30726
30690
|
if (dependsOnOtherField && form[optionalFieldName] === undefined) {
|
|
30727
|
-
throw new Error(
|
|
30691
|
+
throw new Error(
|
|
30692
|
+
`${args[2]} was passed to matchesField, but that field does not exist in the form`
|
|
30693
|
+
);
|
|
30728
30694
|
}
|
|
30729
30695
|
|
|
30730
|
-
|
|
30731
|
-
|
|
30732
|
-
|
|
30733
|
-
|
|
30734
|
-
|
|
30735
|
-
|
|
30736
|
-
|
|
30737
|
-
|
|
30738
|
-
|
|
30739
|
-
|
|
30740
|
-
|
|
30741
|
-
|
|
30742
|
-
|
|
30743
|
-
var validateSum = function validateSum(validator, fieldNamesArray) {
|
|
30744
|
-
return {
|
|
30745
|
-
type: VALIDATE_SUM,
|
|
30746
|
-
args: [validator, fieldNamesArray],
|
|
30747
|
-
error: validator.error
|
|
30748
|
-
};
|
|
30749
|
-
};
|
|
30696
|
+
const primaryPredicate = validatorToPredicate(
|
|
30697
|
+
validatorFns[primaryValidator.type],
|
|
30698
|
+
false
|
|
30699
|
+
);
|
|
30700
|
+
const primaryValue = dependsOnOtherField
|
|
30701
|
+
? form[optionalFieldName].rawValue
|
|
30702
|
+
: value;
|
|
30703
|
+
const primaryPredicatePassed = primaryPredicate(
|
|
30704
|
+
primaryValue,
|
|
30705
|
+
primaryValidator.args,
|
|
30706
|
+
form
|
|
30707
|
+
);
|
|
30750
30708
|
|
|
30709
|
+
return primaryPredicatePassed
|
|
30710
|
+
? validatorFns[dependentValidator.type](
|
|
30711
|
+
value,
|
|
30712
|
+
dependentValidator.args,
|
|
30713
|
+
form
|
|
30714
|
+
)
|
|
30715
|
+
: true;
|
|
30716
|
+
};
|
|
30717
|
+
|
|
30718
|
+
const validateSumErrorMessage = type =>
|
|
30719
|
+
`${type} was passed to validateSum, but that validator type does not exist.
|
|
30720
|
+
Please check that you are only calling validator creator functions exported from
|
|
30721
|
+
redux-freeform in your form config and that you didn't forget to
|
|
30722
|
+
invoke the validator creator (you cannot pass the functions themselves to
|
|
30723
|
+
createFormState).`;
|
|
30724
|
+
const VALIDATE_SUM = "validator/VALIDATE_SUM";
|
|
30725
|
+
const VALIDATE_SUM_ERROR = "error/VALIDATE_SUM";
|
|
30726
|
+
const validateSum = (validator, fieldNamesArray) => ({
|
|
30727
|
+
type: VALIDATE_SUM,
|
|
30728
|
+
args: [validator, fieldNamesArray],
|
|
30729
|
+
error: validator.error
|
|
30730
|
+
});
|
|
30751
30731
|
validateSum.error = VALIDATE_SUM_ERROR;
|
|
30732
|
+
validatorFns[VALIDATE_SUM] = (value, args, form) => {
|
|
30733
|
+
const [validator, fieldNamesArray] = args;
|
|
30752
30734
|
|
|
30753
|
-
|
|
30754
|
-
|
|
30755
|
-
|
|
30756
|
-
|
|
30757
|
-
|
|
30758
|
-
if (validator.type === undefined || typeof validatorFns[validator.type] !== "function") {
|
|
30735
|
+
if (
|
|
30736
|
+
validator.type === undefined ||
|
|
30737
|
+
typeof validatorFns[validator.type] !== "function"
|
|
30738
|
+
) {
|
|
30759
30739
|
throw new Error(validateSumErrorMessage(validator.type));
|
|
30760
30740
|
}
|
|
30761
30741
|
|
|
30762
|
-
|
|
30763
|
-
|
|
30764
|
-
|
|
30765
|
-
|
|
30766
|
-
|
|
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
|
-
}
|
|
30742
|
+
for (const fieldName of fieldNamesArray) {
|
|
30743
|
+
if (form[fieldName] === undefined) {
|
|
30744
|
+
throw new Error(
|
|
30745
|
+
`${fieldName} was passed to matchesField, but that field does not exist in the form`
|
|
30746
|
+
);
|
|
30772
30747
|
}
|
|
30773
|
-
} catch (err) {
|
|
30774
|
-
_iterator.e(err);
|
|
30775
|
-
} finally {
|
|
30776
|
-
_iterator.f();
|
|
30777
30748
|
}
|
|
30778
30749
|
|
|
30779
|
-
|
|
30780
|
-
|
|
30781
|
-
|
|
30750
|
+
const sum = fieldNamesArray.reduce(
|
|
30751
|
+
(acc, curr) => acc + Number(form[curr].rawValue),
|
|
30752
|
+
Number(value)
|
|
30753
|
+
);
|
|
30754
|
+
|
|
30782
30755
|
return validatorFns[validator.type](sum, validator.args, form);
|
|
30783
30756
|
};
|
|
30784
30757
|
|
|
30785
|
-
|
|
30786
|
-
|
|
30787
|
-
|
|
30788
|
-
|
|
30789
|
-
validatorFns[HAS_LENGTH] = function (value, args, form) {
|
|
30758
|
+
const HAS_LENGTH = "validator/HAS_LENGTH";
|
|
30759
|
+
const HAS_LENGTH_ERROR = "error/HAS_LENGTH";
|
|
30760
|
+
const hasLength = createValidator(HAS_LENGTH, HAS_LENGTH_ERROR);
|
|
30761
|
+
validatorFns[HAS_LENGTH] = (value, args, form) => {
|
|
30790
30762
|
if (value === "") {
|
|
30791
30763
|
return true;
|
|
30792
30764
|
}
|
|
30793
|
-
|
|
30794
|
-
|
|
30795
|
-
var max = args[1];
|
|
30796
|
-
|
|
30765
|
+
const min = args[0];
|
|
30766
|
+
const max = args[1];
|
|
30797
30767
|
if (max == undefined || min == undefined) {
|
|
30798
|
-
throw new Error(
|
|
30768
|
+
throw new Error(
|
|
30769
|
+
"Max and min need to be defined for hasLength, both or one of them is undefined"
|
|
30770
|
+
);
|
|
30799
30771
|
}
|
|
30800
|
-
|
|
30801
30772
|
if (max < min) {
|
|
30802
|
-
throw new Error(
|
|
30773
|
+
throw new Error(
|
|
30774
|
+
"hasLength validator was passed a min greater than the max"
|
|
30775
|
+
);
|
|
30803
30776
|
}
|
|
30804
|
-
|
|
30805
|
-
var valueLength = value.length;
|
|
30777
|
+
const valueLength = value.length;
|
|
30806
30778
|
return max >= valueLength && valueLength >= min;
|
|
30807
30779
|
};
|
|
30808
30780
|
|
|
30809
|
-
|
|
30810
|
-
|
|
30811
|
-
|
|
30812
|
-
|
|
30813
|
-
validatorFns[MATCHES_REGEX] = function (value, args, form) {
|
|
30781
|
+
const MATCHES_REGEX = "validator/MATCHES_REGEX";
|
|
30782
|
+
const MATCHES_REGEX_ERROR = "error/MATCHES_REGEX";
|
|
30783
|
+
const matchesRegex = createValidator(MATCHES_REGEX, MATCHES_REGEX_ERROR);
|
|
30784
|
+
validatorFns[MATCHES_REGEX] = (value, args, form) => {
|
|
30814
30785
|
if (value === "") {
|
|
30815
30786
|
return true;
|
|
30816
30787
|
}
|
|
30817
|
-
|
|
30818
30788
|
return new RegExp(args[0]).test(value); // new RexExp never throws an error, no matter the input
|
|
30819
|
-
};
|
|
30820
|
-
|
|
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);
|
|
30789
|
+
};
|
|
30825
30790
|
|
|
30826
|
-
|
|
30791
|
+
// based on http://www.brainjar.com/js/validation/
|
|
30792
|
+
const IS_ROUTING_NUMBER = "validator/IS_ROUTING_NUMBER";
|
|
30793
|
+
const IS_ROUTING_NUMBER_ERROR = "error/IS_ROUTING_NUMBER";
|
|
30794
|
+
const isRoutingNumber = createValidator(
|
|
30795
|
+
IS_ROUTING_NUMBER,
|
|
30796
|
+
IS_ROUTING_NUMBER_ERROR
|
|
30797
|
+
);
|
|
30798
|
+
validatorFns[IS_ROUTING_NUMBER] = (value, args, form) => {
|
|
30827
30799
|
if (value === "") {
|
|
30828
30800
|
return true;
|
|
30829
30801
|
}
|
|
30830
|
-
|
|
30831
30802
|
if (value.length != 9) {
|
|
30832
30803
|
return false;
|
|
30833
30804
|
}
|
|
30834
|
-
|
|
30835
|
-
|
|
30836
|
-
|
|
30837
|
-
|
|
30838
|
-
|
|
30839
|
-
|
|
30840
|
-
|
|
30841
|
-
|
|
30842
|
-
|
|
30843
|
-
|
|
30844
|
-
|
|
30845
|
-
|
|
30846
|
-
|
|
30847
|
-
}
|
|
30848
|
-
}, 0);
|
|
30805
|
+
const sum = value
|
|
30806
|
+
.split("")
|
|
30807
|
+
.map(ch => parseInt(ch))
|
|
30808
|
+
.reduce((acc, cur, idx) => {
|
|
30809
|
+
switch (idx % 3) {
|
|
30810
|
+
case 0:
|
|
30811
|
+
return acc + 3 * cur;
|
|
30812
|
+
case 1:
|
|
30813
|
+
return acc + 7 * cur;
|
|
30814
|
+
case 2:
|
|
30815
|
+
return acc + 1 * cur;
|
|
30816
|
+
}
|
|
30817
|
+
}, 0);
|
|
30849
30818
|
return sum != 0 && sum % 10 == 0;
|
|
30850
30819
|
};
|
|
30851
30820
|
|
|
30852
|
-
|
|
30853
|
-
|
|
30854
|
-
|
|
30855
|
-
|
|
30856
|
-
validatorFns[HAS_NUMBER] = function (value, args, form) {
|
|
30821
|
+
const HAS_NUMBER = "validator/HAS_NUMBER";
|
|
30822
|
+
const HAS_NUMBER_ERROR$1 = "error/HAS_NUMBER";
|
|
30823
|
+
const hasNumber = createValidator(HAS_NUMBER, HAS_NUMBER_ERROR$1);
|
|
30824
|
+
validatorFns[HAS_NUMBER] = (value, args, form) => {
|
|
30857
30825
|
if (value === "") {
|
|
30858
30826
|
return true;
|
|
30859
30827
|
}
|
|
30860
|
-
|
|
30861
30828
|
return new RegExp(/[0-9]/).test(value);
|
|
30862
30829
|
};
|
|
30863
30830
|
|
|
30864
|
-
|
|
30865
|
-
|
|
30866
|
-
|
|
30867
|
-
|
|
30868
|
-
|
|
30831
|
+
const HAS_LOWERCASE_LETTER = "validator/HAS_LOWERCASE_LETTER";
|
|
30832
|
+
const HAS_LOWERCASE_LETTER_ERROR$1 = "error/HAS_LOWERCASE_LETTER";
|
|
30833
|
+
const hasLowercaseLetter = createValidator(
|
|
30834
|
+
HAS_LOWERCASE_LETTER,
|
|
30835
|
+
HAS_LOWERCASE_LETTER_ERROR$1
|
|
30836
|
+
);
|
|
30837
|
+
validatorFns[HAS_LOWERCASE_LETTER] = (value, args, form) => {
|
|
30869
30838
|
if (value === "") {
|
|
30870
30839
|
return true;
|
|
30871
30840
|
}
|
|
30872
|
-
|
|
30873
30841
|
return new RegExp(/[a-z]/).test(value);
|
|
30874
30842
|
};
|
|
30875
30843
|
|
|
30876
|
-
|
|
30877
|
-
|
|
30878
|
-
|
|
30879
|
-
|
|
30880
|
-
|
|
30844
|
+
const HAS_UPPERCASE_LETTER = "validator/HAS_UPPERCASE_LETTER";
|
|
30845
|
+
const HAS_UPPERCASE_LETTER_ERROR$1 = "error/HAS_UPPERCASE_LETTER";
|
|
30846
|
+
const hasUppercaseLetter = createValidator(
|
|
30847
|
+
HAS_UPPERCASE_LETTER,
|
|
30848
|
+
HAS_UPPERCASE_LETTER_ERROR$1
|
|
30849
|
+
);
|
|
30850
|
+
validatorFns[HAS_UPPERCASE_LETTER] = (value, args, form) => {
|
|
30881
30851
|
if (value === "") {
|
|
30882
30852
|
return true;
|
|
30883
30853
|
}
|
|
30884
|
-
|
|
30885
30854
|
return new RegExp(/[A-Z]/).test(value);
|
|
30886
30855
|
};
|
|
30887
30856
|
|
|
30888
|
-
|
|
30889
|
-
|
|
30890
|
-
|
|
30891
|
-
|
|
30892
|
-
|
|
30857
|
+
const HAS_SPECIAL_CHARACTER = "validator/HAS_SPECIAL_CHARACTER";
|
|
30858
|
+
const HAS_SPECIAL_CHARACTER_ERROR$1 = "error/HAS_SPECIAL_CHARACTER";
|
|
30859
|
+
const hasSpecialCharacter = createValidator(
|
|
30860
|
+
HAS_SPECIAL_CHARACTER,
|
|
30861
|
+
HAS_SPECIAL_CHARACTER_ERROR$1
|
|
30862
|
+
);
|
|
30863
|
+
validatorFns[HAS_SPECIAL_CHARACTER] = (value, args, form) => {
|
|
30893
30864
|
if (value === "") {
|
|
30894
30865
|
return true;
|
|
30895
30866
|
}
|
|
30896
|
-
|
|
30897
30867
|
return new RegExp(/[!@#$%^&*.?]/).test(value);
|
|
30898
30868
|
};
|
|
30899
30869
|
|
|
30900
|
-
|
|
30901
|
-
|
|
30902
|
-
|
|
30903
|
-
|
|
30904
|
-
|
|
30870
|
+
const IS_PROBABLY_EMAIL = "validator/IS_PROBABLY_EMAIL";
|
|
30871
|
+
const IS_PROBABLY_EMAIL_ERROR = "error/IS_PROBABLY_EMAIL";
|
|
30872
|
+
const isProbablyEmail = createValidator(
|
|
30873
|
+
IS_PROBABLY_EMAIL,
|
|
30874
|
+
IS_PROBABLY_EMAIL_ERROR
|
|
30875
|
+
);
|
|
30876
|
+
validatorFns[IS_PROBABLY_EMAIL] = (value, args, form) => {
|
|
30905
30877
|
if (value === "") {
|
|
30906
30878
|
return true;
|
|
30907
30879
|
}
|
|
30908
|
-
|
|
30909
30880
|
return new RegExp(/^\S+@\S+\.\S+$/).test(value);
|
|
30910
30881
|
};
|
|
30911
30882
|
|
|
30912
|
-
|
|
30913
|
-
|
|
30914
|
-
|
|
30915
|
-
|
|
30916
|
-
|
|
30917
|
-
|
|
30883
|
+
const runValidatorErrorMessage = type =>
|
|
30884
|
+
`${type} was passed to runValidator, but that validator type does not exist.
|
|
30885
|
+
Please check that you are only calling validator creator functions exported from
|
|
30886
|
+
redux-freeform in your form config and that you didn't forget to
|
|
30887
|
+
invoke the validator creator (you cannot pass the functions themselves to
|
|
30888
|
+
createFormState)`;
|
|
30918
30889
|
|
|
30890
|
+
const runValidator = (validator, value, form) => {
|
|
30891
|
+
const validatorFn = validatorFns[validator.type];
|
|
30919
30892
|
if (validatorFn === undefined) {
|
|
30920
30893
|
throw new Error(runValidatorErrorMessage(validator.type));
|
|
30921
30894
|
}
|
|
30922
|
-
|
|
30923
30895
|
return validatorFn(value, validator.args, form) ? null : validator.error;
|
|
30924
30896
|
};
|
|
30925
30897
|
|
|
30926
|
-
|
|
30927
|
-
return validators
|
|
30928
|
-
|
|
30929
|
-
|
|
30930
|
-
return x !== null;
|
|
30931
|
-
});
|
|
30898
|
+
const _computeErrors = (fieldName, form, validators) => {
|
|
30899
|
+
return validators
|
|
30900
|
+
.map(v => runValidator(v, form[fieldName].rawValue, form))
|
|
30901
|
+
.filter(x => x !== null);
|
|
30932
30902
|
};
|
|
30933
30903
|
|
|
30934
|
-
|
|
30935
|
-
|
|
30904
|
+
const computeConstraints = (fieldName, form) => {
|
|
30905
|
+
const constraints = form[fieldName].constraints;
|
|
30936
30906
|
return _computeErrors(fieldName, form, constraints);
|
|
30937
30907
|
};
|
|
30938
30908
|
|
|
30939
|
-
|
|
30940
|
-
|
|
30909
|
+
const computeErrors = (fieldName, form) => {
|
|
30910
|
+
const validators = form[fieldName].validators;
|
|
30941
30911
|
return _computeErrors(fieldName, form, validators);
|
|
30942
30912
|
};
|
|
30943
30913
|
|
|
30944
30914
|
var obj;
|
|
30945
|
-
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : (obj = {}, obj["immer-nothing"] = true, obj);
|
|
30946
|
-
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol
|
|
30947
|
-
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol
|
|
30948
|
-
|
|
30915
|
+
var NOTHING = typeof Symbol !== "undefined" ? Symbol("immer-nothing") : ( obj = {}, obj["immer-nothing"] = true, obj );
|
|
30916
|
+
var DRAFTABLE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
30917
|
+
var DRAFT_STATE = typeof Symbol !== "undefined" && Symbol.for ? Symbol.for("immer-state") : "__$immer_state";
|
|
30949
30918
|
function isDraft(value) {
|
|
30950
30919
|
return !!value && !!value[DRAFT_STATE];
|
|
30951
30920
|
}
|
|
30952
|
-
|
|
30953
30921
|
function isDraftable(value) {
|
|
30954
|
-
if (!value) {
|
|
30955
|
-
return false;
|
|
30956
|
-
}
|
|
30957
|
-
|
|
30922
|
+
if (!value) { return false; }
|
|
30958
30923
|
return isPlainObject(value) || !!value[DRAFTABLE] || !!value.constructor[DRAFTABLE];
|
|
30959
30924
|
}
|
|
30960
|
-
|
|
30961
30925
|
function isPlainObject(value) {
|
|
30962
|
-
if (!value ||
|
|
30963
|
-
|
|
30964
|
-
}
|
|
30965
|
-
|
|
30966
|
-
if (Array.isArray(value)) {
|
|
30967
|
-
return true;
|
|
30968
|
-
}
|
|
30969
|
-
|
|
30926
|
+
if (!value || typeof value !== "object") { return false; }
|
|
30927
|
+
if (Array.isArray(value)) { return true; }
|
|
30970
30928
|
var proto = Object.getPrototypeOf(value);
|
|
30971
30929
|
return !proto || proto === Object.prototype;
|
|
30972
30930
|
}
|
|
30973
|
-
|
|
30974
30931
|
var assign = Object.assign || function assign(target, value) {
|
|
30975
30932
|
for (var key in value) {
|
|
30976
30933
|
if (has(value, key)) {
|
|
@@ -30980,18 +30937,11 @@ var assign = Object.assign || function assign(target, value) {
|
|
|
30980
30937
|
|
|
30981
30938
|
return target;
|
|
30982
30939
|
};
|
|
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
|
-
|
|
30940
|
+
var ownKeys$1 = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKeys : typeof Object.getOwnPropertySymbols !== "undefined" ? function (obj) { return Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj)); } : Object.getOwnPropertyNames;
|
|
30988
30941
|
function shallowCopy(base, invokeGetters) {
|
|
30989
|
-
if (invokeGetters === void 0) invokeGetters = false;
|
|
30990
|
-
|
|
30991
|
-
if (Array.isArray(base)) {
|
|
30992
|
-
return base.slice();
|
|
30993
|
-
}
|
|
30942
|
+
if ( invokeGetters === void 0 ) invokeGetters = false;
|
|
30994
30943
|
|
|
30944
|
+
if (Array.isArray(base)) { return base.slice(); }
|
|
30995
30945
|
var clone = Object.create(Object.getPrototypeOf(base));
|
|
30996
30946
|
ownKeys$1(base).forEach(function (key) {
|
|
30997
30947
|
if (key === DRAFT_STATE) {
|
|
@@ -31021,28 +30971,20 @@ function shallowCopy(base, invokeGetters) {
|
|
|
31021
30971
|
});
|
|
31022
30972
|
return clone;
|
|
31023
30973
|
}
|
|
31024
|
-
|
|
31025
30974
|
function each(value, cb) {
|
|
31026
30975
|
if (Array.isArray(value)) {
|
|
31027
|
-
for (var i = 0; i < value.length; i++) {
|
|
31028
|
-
cb(i, value[i], value);
|
|
31029
|
-
}
|
|
30976
|
+
for (var i = 0; i < value.length; i++) { cb(i, value[i], value); }
|
|
31030
30977
|
} else {
|
|
31031
|
-
ownKeys$1(value).forEach(function (key) {
|
|
31032
|
-
return cb(key, value[key], value);
|
|
31033
|
-
});
|
|
30978
|
+
ownKeys$1(value).forEach(function (key) { return cb(key, value[key], value); });
|
|
31034
30979
|
}
|
|
31035
30980
|
}
|
|
31036
|
-
|
|
31037
30981
|
function isEnumerable(base, prop) {
|
|
31038
30982
|
var desc = Object.getOwnPropertyDescriptor(base, prop);
|
|
31039
30983
|
return !!desc && desc.enumerable;
|
|
31040
30984
|
}
|
|
31041
|
-
|
|
31042
30985
|
function has(thing, prop) {
|
|
31043
30986
|
return Object.prototype.hasOwnProperty.call(thing, prop);
|
|
31044
30987
|
}
|
|
31045
|
-
|
|
31046
30988
|
function is(x, y) {
|
|
31047
30989
|
// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js
|
|
31048
30990
|
if (x === y) {
|
|
@@ -31051,26 +30993,17 @@ function is(x, y) {
|
|
|
31051
30993
|
return x !== x && y !== y;
|
|
31052
30994
|
}
|
|
31053
30995
|
}
|
|
31054
|
-
|
|
31055
30996
|
function clone(obj) {
|
|
31056
|
-
if (!isDraftable(obj)) {
|
|
31057
|
-
|
|
31058
|
-
}
|
|
31059
|
-
|
|
31060
|
-
if (Array.isArray(obj)) {
|
|
31061
|
-
return obj.map(clone);
|
|
31062
|
-
}
|
|
31063
|
-
|
|
30997
|
+
if (!isDraftable(obj)) { return obj; }
|
|
30998
|
+
if (Array.isArray(obj)) { return obj.map(clone); }
|
|
31064
30999
|
var cloned = Object.create(Object.getPrototypeOf(obj));
|
|
31065
31000
|
|
|
31066
|
-
for (var key in obj) {
|
|
31067
|
-
cloned[key] = clone(obj[key]);
|
|
31068
|
-
}
|
|
31001
|
+
for (var key in obj) { cloned[key] = clone(obj[key]); }
|
|
31069
31002
|
|
|
31070
31003
|
return cloned;
|
|
31071
31004
|
}
|
|
31072
|
-
/** Each scope represents a `produce` call. */
|
|
31073
31005
|
|
|
31006
|
+
/** Each scope represents a `produce` call. */
|
|
31074
31007
|
|
|
31075
31008
|
var ImmerScope = function ImmerScope(parent) {
|
|
31076
31009
|
this.drafts = [];
|
|
@@ -31082,7 +31015,7 @@ var ImmerScope = function ImmerScope(parent) {
|
|
|
31082
31015
|
this.patches = null;
|
|
31083
31016
|
};
|
|
31084
31017
|
|
|
31085
|
-
ImmerScope.prototype.usePatches = function usePatches(patchListener) {
|
|
31018
|
+
ImmerScope.prototype.usePatches = function usePatches (patchListener) {
|
|
31086
31019
|
if (patchListener) {
|
|
31087
31020
|
this.patches = [];
|
|
31088
31021
|
this.inversePatches = [];
|
|
@@ -31090,18 +31023,17 @@ ImmerScope.prototype.usePatches = function usePatches(patchListener) {
|
|
|
31090
31023
|
}
|
|
31091
31024
|
};
|
|
31092
31025
|
|
|
31093
|
-
ImmerScope.prototype.revoke = function revoke$1() {
|
|
31026
|
+
ImmerScope.prototype.revoke = function revoke$1 () {
|
|
31094
31027
|
this.leave();
|
|
31095
31028
|
this.drafts.forEach(revoke);
|
|
31096
31029
|
this.drafts = null; // Make draft-related methods throw.
|
|
31097
31030
|
};
|
|
31098
31031
|
|
|
31099
|
-
ImmerScope.prototype.leave = function leave() {
|
|
31032
|
+
ImmerScope.prototype.leave = function leave () {
|
|
31100
31033
|
if (this === ImmerScope.current) {
|
|
31101
31034
|
ImmerScope.current = this.parent;
|
|
31102
31035
|
}
|
|
31103
31036
|
};
|
|
31104
|
-
|
|
31105
31037
|
ImmerScope.current = null;
|
|
31106
31038
|
|
|
31107
31039
|
ImmerScope.enter = function () {
|
|
@@ -31110,11 +31042,11 @@ ImmerScope.enter = function () {
|
|
|
31110
31042
|
|
|
31111
31043
|
function revoke(draft) {
|
|
31112
31044
|
draft[DRAFT_STATE].revoke();
|
|
31113
|
-
}
|
|
31045
|
+
}
|
|
31114
31046
|
|
|
31047
|
+
// but share them all instead
|
|
31115
31048
|
|
|
31116
31049
|
var descriptors = {};
|
|
31117
|
-
|
|
31118
31050
|
function willFinalize(scope, result, isReplaced) {
|
|
31119
31051
|
scope.drafts.forEach(function (draft) {
|
|
31120
31052
|
draft[DRAFT_STATE].finalizing = true;
|
|
@@ -31132,7 +31064,6 @@ function willFinalize(scope, result, isReplaced) {
|
|
|
31132
31064
|
markChangesSweep(scope.drafts);
|
|
31133
31065
|
}
|
|
31134
31066
|
}
|
|
31135
|
-
|
|
31136
31067
|
function createProxy(base, parent) {
|
|
31137
31068
|
var isArray = Array.isArray(base);
|
|
31138
31069
|
var draft = clonePotentialDraft(base);
|
|
@@ -31186,11 +31117,7 @@ function peek(draft, prop) {
|
|
|
31186
31117
|
function get(state, prop) {
|
|
31187
31118
|
assertUnrevoked(state);
|
|
31188
31119
|
var value = peek(source(state), prop);
|
|
31189
|
-
|
|
31190
|
-
if (state.finalizing) {
|
|
31191
|
-
return value;
|
|
31192
|
-
} // Create a draft if the value is unmodified.
|
|
31193
|
-
|
|
31120
|
+
if (state.finalizing) { return value; } // Create a draft if the value is unmodified.
|
|
31194
31121
|
|
|
31195
31122
|
if (value === peek(state.base, prop) && isDraftable(value)) {
|
|
31196
31123
|
prepareCopy(state);
|
|
@@ -31205,10 +31132,7 @@ function set(state, prop, value) {
|
|
|
31205
31132
|
state.assigned[prop] = true;
|
|
31206
31133
|
|
|
31207
31134
|
if (!state.modified) {
|
|
31208
|
-
if (is(value, peek(source(state), prop))) {
|
|
31209
|
-
return;
|
|
31210
|
-
}
|
|
31211
|
-
|
|
31135
|
+
if (is(value, peek(source(state), prop))) { return; }
|
|
31212
31136
|
markChanged(state);
|
|
31213
31137
|
prepareCopy(state);
|
|
31214
31138
|
}
|
|
@@ -31219,17 +31143,12 @@ function set(state, prop, value) {
|
|
|
31219
31143
|
function markChanged(state) {
|
|
31220
31144
|
if (!state.modified) {
|
|
31221
31145
|
state.modified = true;
|
|
31222
|
-
|
|
31223
|
-
if (state.parent) {
|
|
31224
|
-
markChanged(state.parent);
|
|
31225
|
-
}
|
|
31146
|
+
if (state.parent) { markChanged(state.parent); }
|
|
31226
31147
|
}
|
|
31227
31148
|
}
|
|
31228
31149
|
|
|
31229
31150
|
function prepareCopy(state) {
|
|
31230
|
-
if (!state.copy) {
|
|
31231
|
-
state.copy = clonePotentialDraft(state.base);
|
|
31232
|
-
}
|
|
31151
|
+
if (!state.copy) { state.copy = clonePotentialDraft(state.base); }
|
|
31233
31152
|
}
|
|
31234
31153
|
|
|
31235
31154
|
function clonePotentialDraft(base) {
|
|
@@ -31254,12 +31173,15 @@ function proxyProperty(draft, prop, enumerable) {
|
|
|
31254
31173
|
descriptors[prop] = desc = {
|
|
31255
31174
|
configurable: true,
|
|
31256
31175
|
enumerable: enumerable,
|
|
31176
|
+
|
|
31257
31177
|
get: function get$1() {
|
|
31258
31178
|
return get(this[DRAFT_STATE], prop);
|
|
31259
31179
|
},
|
|
31180
|
+
|
|
31260
31181
|
set: function set$1(value) {
|
|
31261
31182
|
set(this[DRAFT_STATE], prop, value);
|
|
31262
31183
|
}
|
|
31184
|
+
|
|
31263
31185
|
};
|
|
31264
31186
|
}
|
|
31265
31187
|
|
|
@@ -31267,9 +31189,7 @@ function proxyProperty(draft, prop, enumerable) {
|
|
|
31267
31189
|
}
|
|
31268
31190
|
|
|
31269
31191
|
function assertUnrevoked(state) {
|
|
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
|
-
}
|
|
31192
|
+
if (state.revoked === true) { throw new Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + JSON.stringify(source(state))); }
|
|
31273
31193
|
} // This looks expensive, but only proxies are visited, and only objects without known changes are scanned.
|
|
31274
31194
|
|
|
31275
31195
|
|
|
@@ -31283,27 +31203,16 @@ function markChangesSweep(drafts) {
|
|
|
31283
31203
|
|
|
31284
31204
|
if (!state.modified) {
|
|
31285
31205
|
if (Array.isArray(state.base)) {
|
|
31286
|
-
if (hasArrayChanges(state)) {
|
|
31287
|
-
|
|
31288
|
-
}
|
|
31289
|
-
} else if (hasObjectChanges(state)) {
|
|
31290
|
-
markChanged(state);
|
|
31291
|
-
}
|
|
31206
|
+
if (hasArrayChanges(state)) { markChanged(state); }
|
|
31207
|
+
} else if (hasObjectChanges(state)) { markChanged(state); }
|
|
31292
31208
|
}
|
|
31293
31209
|
}
|
|
31294
31210
|
}
|
|
31295
31211
|
|
|
31296
31212
|
function markChangesRecursively(object) {
|
|
31297
|
-
if (!object ||
|
|
31298
|
-
return;
|
|
31299
|
-
}
|
|
31300
|
-
|
|
31213
|
+
if (!object || typeof object !== "object") { return; }
|
|
31301
31214
|
var state = object[DRAFT_STATE];
|
|
31302
|
-
|
|
31303
|
-
if (!state) {
|
|
31304
|
-
return;
|
|
31305
|
-
}
|
|
31306
|
-
|
|
31215
|
+
if (!state) { return; }
|
|
31307
31216
|
var base = state.base;
|
|
31308
31217
|
var draft = state.draft;
|
|
31309
31218
|
var assigned = state.assigned;
|
|
@@ -31333,20 +31242,14 @@ function markChangesRecursively(object) {
|
|
|
31333
31242
|
assigned.length = true;
|
|
31334
31243
|
|
|
31335
31244
|
if (draft.length < base.length) {
|
|
31336
|
-
for (var i = draft.length; i < base.length; i++) {
|
|
31337
|
-
assigned[i] = false;
|
|
31338
|
-
}
|
|
31245
|
+
for (var i = draft.length; i < base.length; i++) { assigned[i] = false; }
|
|
31339
31246
|
} else {
|
|
31340
|
-
for (var i$1 = base.length; i$1 < draft.length; i$1++) {
|
|
31341
|
-
assigned[i$1] = true;
|
|
31342
|
-
}
|
|
31247
|
+
for (var i$1 = base.length; i$1 < draft.length; i$1++) { assigned[i$1] = true; }
|
|
31343
31248
|
}
|
|
31344
31249
|
|
|
31345
31250
|
for (var i$2 = 0; i$2 < draft.length; i$2++) {
|
|
31346
31251
|
// Only untouched indices trigger recursion.
|
|
31347
|
-
if (assigned[i$2] === undefined) {
|
|
31348
|
-
markChangesRecursively(draft[i$2]);
|
|
31349
|
-
}
|
|
31252
|
+
if (assigned[i$2] === undefined) { markChangesRecursively(draft[i$2]); }
|
|
31350
31253
|
}
|
|
31351
31254
|
}
|
|
31352
31255
|
}
|
|
@@ -31383,10 +31286,7 @@ function hasObjectChanges(state) {
|
|
|
31383
31286
|
|
|
31384
31287
|
function hasArrayChanges(state) {
|
|
31385
31288
|
var draft = state.draft;
|
|
31386
|
-
|
|
31387
|
-
if (draft.length !== state.base.length) {
|
|
31388
|
-
return true;
|
|
31389
|
-
} // See #116
|
|
31289
|
+
if (draft.length !== state.base.length) { return true; } // See #116
|
|
31390
31290
|
// If we first shorten the length, our array interceptors will be removed.
|
|
31391
31291
|
// If after that new items are added, result in the same original length,
|
|
31392
31292
|
// those last items will have no intercepting property.
|
|
@@ -31394,13 +31294,9 @@ function hasArrayChanges(state) {
|
|
|
31394
31294
|
// N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check
|
|
31395
31295
|
// the last one
|
|
31396
31296
|
|
|
31397
|
-
|
|
31398
31297
|
var descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1); // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)
|
|
31399
31298
|
|
|
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
|
-
|
|
31299
|
+
if (descriptor && !descriptor.get) { return true; } // For all other cases, we don't have to compare, as they would have been picked up by the index setters
|
|
31404
31300
|
|
|
31405
31301
|
return false;
|
|
31406
31302
|
}
|
|
@@ -31414,12 +31310,11 @@ function createHiddenProperty(target, prop, value) {
|
|
|
31414
31310
|
}
|
|
31415
31311
|
|
|
31416
31312
|
var legacyProxy = /*#__PURE__*/Object.freeze({
|
|
31417
|
-
|
|
31418
|
-
|
|
31313
|
+
willFinalize: willFinalize,
|
|
31314
|
+
createProxy: createProxy
|
|
31419
31315
|
});
|
|
31420
31316
|
|
|
31421
31317
|
function willFinalize$1() {}
|
|
31422
|
-
|
|
31423
31318
|
function createProxy$1(base, parent) {
|
|
31424
31319
|
var scope = parent ? parent.scope : ImmerScope.current;
|
|
31425
31320
|
var state = {
|
|
@@ -31454,27 +31349,33 @@ function createProxy$1(base, parent) {
|
|
|
31454
31349
|
scope.drafts.push(proxy);
|
|
31455
31350
|
return proxy;
|
|
31456
31351
|
}
|
|
31457
|
-
|
|
31458
31352
|
var objectTraps = {
|
|
31459
31353
|
get: get$1,
|
|
31354
|
+
|
|
31460
31355
|
has: function has(target, prop) {
|
|
31461
31356
|
return prop in source$1(target);
|
|
31462
31357
|
},
|
|
31358
|
+
|
|
31463
31359
|
ownKeys: function ownKeys(target) {
|
|
31464
31360
|
return Reflect.ownKeys(source$1(target));
|
|
31465
31361
|
},
|
|
31362
|
+
|
|
31466
31363
|
set: set$1,
|
|
31467
31364
|
deleteProperty: deleteProperty,
|
|
31468
31365
|
getOwnPropertyDescriptor: getOwnPropertyDescriptor,
|
|
31366
|
+
|
|
31469
31367
|
defineProperty: function defineProperty() {
|
|
31470
31368
|
throw new Error("Object.defineProperty() cannot be used on an Immer draft"); // prettier-ignore
|
|
31471
31369
|
},
|
|
31370
|
+
|
|
31472
31371
|
getPrototypeOf: function getPrototypeOf(target) {
|
|
31473
31372
|
return Object.getPrototypeOf(target.base);
|
|
31474
31373
|
},
|
|
31374
|
+
|
|
31475
31375
|
setPrototypeOf: function setPrototypeOf() {
|
|
31476
31376
|
throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft"); // prettier-ignore
|
|
31477
31377
|
}
|
|
31378
|
+
|
|
31478
31379
|
};
|
|
31479
31380
|
var arrayTraps = {};
|
|
31480
31381
|
each(objectTraps, function (key, fn) {
|
|
@@ -31513,10 +31414,7 @@ function peek$1(draft, prop) {
|
|
|
31513
31414
|
}
|
|
31514
31415
|
|
|
31515
31416
|
function get$1(state, prop) {
|
|
31516
|
-
if (prop === DRAFT_STATE) {
|
|
31517
|
-
return state;
|
|
31518
|
-
}
|
|
31519
|
-
|
|
31417
|
+
if (prop === DRAFT_STATE) { return state; }
|
|
31520
31418
|
var drafts = state.drafts; // Check for existing draft in unmodified state.
|
|
31521
31419
|
|
|
31522
31420
|
if (!state.modified && has(drafts, prop)) {
|
|
@@ -31532,10 +31430,7 @@ function get$1(state, prop) {
|
|
|
31532
31430
|
|
|
31533
31431
|
if (state.modified) {
|
|
31534
31432
|
// Assigned values are never drafted. This catches any drafts we created, too.
|
|
31535
|
-
if (value !== peek$1(state.base, prop)) {
|
|
31536
|
-
return value;
|
|
31537
|
-
} // Store drafts on the copy (when one exists).
|
|
31538
|
-
|
|
31433
|
+
if (value !== peek$1(state.base, prop)) { return value; } // Store drafts on the copy (when one exists).
|
|
31539
31434
|
|
|
31540
31435
|
drafts = state.copy;
|
|
31541
31436
|
}
|
|
@@ -31550,11 +31445,7 @@ function set$1(state, prop, value) {
|
|
|
31550
31445
|
// values may be drafts, but falsy values are never drafts.
|
|
31551
31446
|
|
|
31552
31447
|
var isUnchanged = value ? is(baseValue, value) || value === state.drafts[prop] : is(baseValue, value) && prop in state.base;
|
|
31553
|
-
|
|
31554
|
-
if (isUnchanged) {
|
|
31555
|
-
return true;
|
|
31556
|
-
}
|
|
31557
|
-
|
|
31448
|
+
if (isUnchanged) { return true; }
|
|
31558
31449
|
markChanged$1(state);
|
|
31559
31450
|
}
|
|
31560
31451
|
|
|
@@ -31573,10 +31464,7 @@ function deleteProperty(state, prop) {
|
|
|
31573
31464
|
delete state.assigned[prop];
|
|
31574
31465
|
}
|
|
31575
31466
|
|
|
31576
|
-
if (state.copy) {
|
|
31577
|
-
delete state.copy[prop];
|
|
31578
|
-
}
|
|
31579
|
-
|
|
31467
|
+
if (state.copy) { delete state.copy[prop]; }
|
|
31580
31468
|
return true;
|
|
31581
31469
|
} // Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
31582
31470
|
// the same guarantee in ES5 mode.
|
|
@@ -31599,16 +31487,13 @@ function markChanged$1(state) {
|
|
|
31599
31487
|
state.modified = true;
|
|
31600
31488
|
state.copy = assign(shallowCopy(state.base), state.drafts);
|
|
31601
31489
|
state.drafts = null;
|
|
31602
|
-
|
|
31603
|
-
if (state.parent) {
|
|
31604
|
-
markChanged$1(state.parent);
|
|
31605
|
-
}
|
|
31490
|
+
if (state.parent) { markChanged$1(state.parent); }
|
|
31606
31491
|
}
|
|
31607
31492
|
}
|
|
31608
31493
|
|
|
31609
31494
|
var modernProxy = /*#__PURE__*/Object.freeze({
|
|
31610
|
-
|
|
31611
|
-
|
|
31495
|
+
willFinalize: willFinalize$1,
|
|
31496
|
+
createProxy: createProxy$1
|
|
31612
31497
|
});
|
|
31613
31498
|
|
|
31614
31499
|
function generatePatches(state, basePath, patches, inversePatches) {
|
|
@@ -31617,13 +31502,14 @@ function generatePatches(state, basePath, patches, inversePatches) {
|
|
|
31617
31502
|
|
|
31618
31503
|
function generateArrayPatches(state, basePath, patches, inversePatches) {
|
|
31619
31504
|
var assign, assign$1;
|
|
31505
|
+
|
|
31620
31506
|
var base = state.base;
|
|
31621
31507
|
var copy = state.copy;
|
|
31622
31508
|
var assigned = state.assigned; // Reduce complexity by ensuring `base` is never longer.
|
|
31623
31509
|
|
|
31624
31510
|
if (copy.length < base.length) {
|
|
31625
|
-
assign = [copy, base], base = assign[0], copy = assign[1];
|
|
31626
|
-
assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1];
|
|
31511
|
+
(assign = [copy, base], base = assign[0], copy = assign[1]);
|
|
31512
|
+
(assign$1 = [inversePatches, patches], patches = assign$1[0], inversePatches = assign$1[1]);
|
|
31627
31513
|
}
|
|
31628
31514
|
|
|
31629
31515
|
var delta = copy.length - base.length; // Find the first replaced index.
|
|
@@ -31681,11 +31567,7 @@ function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
|
31681
31567
|
var origValue = base[key];
|
|
31682
31568
|
var value = copy[key];
|
|
31683
31569
|
var op = !assignedValue ? "remove" : key in base ? "replace" : "add";
|
|
31684
|
-
|
|
31685
|
-
if (origValue === value && op === "replace") {
|
|
31686
|
-
return;
|
|
31687
|
-
}
|
|
31688
|
-
|
|
31570
|
+
if (origValue === value && op === "replace") { return; }
|
|
31689
31571
|
var path = basePath.concat(key);
|
|
31690
31572
|
patches.push(op === "remove" ? {
|
|
31691
31573
|
op: op,
|
|
@@ -31710,26 +31592,20 @@ function generateObjectPatches(state, basePath, patches, inversePatches) {
|
|
|
31710
31592
|
});
|
|
31711
31593
|
}
|
|
31712
31594
|
|
|
31713
|
-
var applyPatches = function
|
|
31595
|
+
var applyPatches = function (draft, patches) {
|
|
31714
31596
|
for (var i$1 = 0, list = patches; i$1 < list.length; i$1 += 1) {
|
|
31715
31597
|
var patch = list[i$1];
|
|
31598
|
+
|
|
31716
31599
|
var path = patch.path;
|
|
31717
31600
|
var op = patch.op;
|
|
31718
31601
|
var value = clone(patch.value); // used to clone patch to ensure original patch is not modified, see #411
|
|
31719
31602
|
|
|
31720
|
-
if (!path.length) {
|
|
31721
|
-
throw new Error("Illegal state");
|
|
31722
|
-
}
|
|
31723
|
-
|
|
31603
|
+
if (!path.length) { throw new Error("Illegal state"); }
|
|
31724
31604
|
var base = draft;
|
|
31725
31605
|
|
|
31726
31606
|
for (var i = 0; i < path.length - 1; i++) {
|
|
31727
31607
|
base = base[path[i]];
|
|
31728
|
-
|
|
31729
|
-
if (!base || _typeof(base) !== "object") {
|
|
31730
|
-
throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/"));
|
|
31731
|
-
} // prettier-ignore
|
|
31732
|
-
|
|
31608
|
+
if (!base || typeof base !== "object") { throw new Error("Cannot apply patch, path doesn't resolve: " + path.join("/")); } // prettier-ignore
|
|
31733
31609
|
}
|
|
31734
31610
|
|
|
31735
31611
|
var key = path[path.length - 1];
|
|
@@ -31778,33 +31654,27 @@ var configDefaults = {
|
|
|
31778
31654
|
onDelete: null,
|
|
31779
31655
|
onCopy: null
|
|
31780
31656
|
};
|
|
31781
|
-
|
|
31782
31657
|
var Immer = function Immer(config) {
|
|
31783
31658
|
assign(this, configDefaults, config);
|
|
31784
31659
|
this.setUseProxies(this.useProxies);
|
|
31785
31660
|
this.produce = this.produce.bind(this);
|
|
31786
31661
|
};
|
|
31787
31662
|
|
|
31788
|
-
Immer.prototype.produce = function produce(base, recipe, patchListener) {
|
|
31789
|
-
|
|
31663
|
+
Immer.prototype.produce = function produce (base, recipe, patchListener) {
|
|
31664
|
+
var this$1 = this;
|
|
31790
31665
|
|
|
31666
|
+
// curried invocation
|
|
31791
31667
|
if (typeof base === "function" && typeof recipe !== "function") {
|
|
31792
31668
|
var defaultBase = recipe;
|
|
31793
31669
|
recipe = base;
|
|
31794
31670
|
var self = this;
|
|
31795
31671
|
return function curriedProduce(base) {
|
|
31796
|
-
|
|
31797
|
-
|
|
31798
|
-
|
|
31799
|
-
|
|
31800
|
-
|
|
31801
|
-
while (len-- > 0) {
|
|
31802
|
-
args[len] = arguments[len + 1];
|
|
31803
|
-
}
|
|
31672
|
+
var this$1 = this;
|
|
31673
|
+
if ( base === void 0 ) base = defaultBase;
|
|
31674
|
+
var args = [], len = arguments.length - 1;
|
|
31675
|
+
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
31804
31676
|
|
|
31805
|
-
return self.produce(base, function (draft) {
|
|
31806
|
-
return recipe.call.apply(recipe, [this$1, draft].concat(args));
|
|
31807
|
-
}); // prettier-ignore
|
|
31677
|
+
return self.produce(base, function (draft) { return recipe.call.apply(recipe, [ this$1, draft ].concat( args )); }); // prettier-ignore
|
|
31808
31678
|
};
|
|
31809
31679
|
} // prettier-ignore
|
|
31810
31680
|
|
|
@@ -31830,11 +31700,7 @@ Immer.prototype.produce = function produce(base, recipe, patchListener) {
|
|
|
31830
31700
|
hasError = false;
|
|
31831
31701
|
} finally {
|
|
31832
31702
|
// finally instead of catch + rethrow better preserves original stack
|
|
31833
|
-
if (hasError) {
|
|
31834
|
-
scope.revoke();
|
|
31835
|
-
} else {
|
|
31836
|
-
scope.leave();
|
|
31837
|
-
}
|
|
31703
|
+
if (hasError) { scope.revoke(); }else { scope.leave(); }
|
|
31838
31704
|
}
|
|
31839
31705
|
|
|
31840
31706
|
if (result instanceof Promise) {
|
|
@@ -31851,38 +31717,25 @@ Immer.prototype.produce = function produce(base, recipe, patchListener) {
|
|
|
31851
31717
|
return this.processResult(result, scope);
|
|
31852
31718
|
} else {
|
|
31853
31719
|
result = recipe(base);
|
|
31854
|
-
|
|
31855
|
-
if (result === undefined) {
|
|
31856
|
-
return base;
|
|
31857
|
-
}
|
|
31858
|
-
|
|
31720
|
+
if (result === undefined) { return base; }
|
|
31859
31721
|
return result !== NOTHING ? result : undefined;
|
|
31860
31722
|
}
|
|
31861
31723
|
};
|
|
31862
31724
|
|
|
31863
|
-
Immer.prototype.produceWithPatches = function produceWithPatches(arg1, arg2, arg3) {
|
|
31864
|
-
|
|
31725
|
+
Immer.prototype.produceWithPatches = function produceWithPatches (arg1, arg2, arg3) {
|
|
31726
|
+
var this$1 = this;
|
|
31865
31727
|
|
|
31866
31728
|
if (typeof arg1 === "function") {
|
|
31867
31729
|
return function (state) {
|
|
31868
|
-
|
|
31869
|
-
|
|
31870
|
-
|
|
31871
|
-
while (len-- > 0) {
|
|
31872
|
-
args[len] = arguments[len + 1];
|
|
31873
|
-
}
|
|
31730
|
+
var args = [], len = arguments.length - 1;
|
|
31731
|
+
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
|
|
31874
31732
|
|
|
31875
|
-
|
|
31876
|
-
|
|
31877
|
-
});
|
|
31878
|
-
};
|
|
31733
|
+
return this$1.produceWithPatches(state, function (draft) { return arg1.apply(void 0, [ draft ].concat( args )); });
|
|
31734
|
+
};
|
|
31879
31735
|
} // non-curried form
|
|
31880
31736
|
|
|
31881
31737
|
|
|
31882
|
-
if (arg3) {
|
|
31883
|
-
throw new Error("A patch listener cannot be passed to produceWithPatches");
|
|
31884
|
-
}
|
|
31885
|
-
|
|
31738
|
+
if (arg3) { throw new Error("A patch listener cannot be passed to produceWithPatches"); }
|
|
31886
31739
|
var patches, inversePatches;
|
|
31887
31740
|
var nextState = this.produce(arg1, arg2, function (p, ip) {
|
|
31888
31741
|
patches = p;
|
|
@@ -31891,7 +31744,7 @@ Immer.prototype.produceWithPatches = function produceWithPatches(arg1, arg2, arg
|
|
|
31891
31744
|
return [nextState, patches, inversePatches];
|
|
31892
31745
|
};
|
|
31893
31746
|
|
|
31894
|
-
Immer.prototype.createDraft = function createDraft(base) {
|
|
31747
|
+
Immer.prototype.createDraft = function createDraft (base) {
|
|
31895
31748
|
if (!isDraftable(base)) {
|
|
31896
31749
|
throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object"); // prettier-ignore
|
|
31897
31750
|
}
|
|
@@ -31903,7 +31756,7 @@ Immer.prototype.createDraft = function createDraft(base) {
|
|
|
31903
31756
|
return proxy;
|
|
31904
31757
|
};
|
|
31905
31758
|
|
|
31906
|
-
Immer.prototype.finishDraft = function finishDraft(draft, patchListener) {
|
|
31759
|
+
Immer.prototype.finishDraft = function finishDraft (draft, patchListener) {
|
|
31907
31760
|
var state = draft && draft[DRAFT_STATE];
|
|
31908
31761
|
|
|
31909
31762
|
if (!state || !state.isManual) {
|
|
@@ -31919,16 +31772,16 @@ Immer.prototype.finishDraft = function finishDraft(draft, patchListener) {
|
|
|
31919
31772
|
return this.processResult(undefined, scope);
|
|
31920
31773
|
};
|
|
31921
31774
|
|
|
31922
|
-
Immer.prototype.setAutoFreeze = function setAutoFreeze(value) {
|
|
31775
|
+
Immer.prototype.setAutoFreeze = function setAutoFreeze (value) {
|
|
31923
31776
|
this.autoFreeze = value;
|
|
31924
31777
|
};
|
|
31925
31778
|
|
|
31926
|
-
Immer.prototype.setUseProxies = function setUseProxies(value) {
|
|
31779
|
+
Immer.prototype.setUseProxies = function setUseProxies (value) {
|
|
31927
31780
|
this.useProxies = value;
|
|
31928
31781
|
assign(this, value ? modernProxy : legacyProxy);
|
|
31929
31782
|
};
|
|
31930
31783
|
|
|
31931
|
-
Immer.prototype.applyPatches = function applyPatches$1(base, patches) {
|
|
31784
|
+
Immer.prototype.applyPatches = function applyPatches$1 (base, patches) {
|
|
31932
31785
|
// If a patch replaces the entire state, take that replacement as base
|
|
31933
31786
|
// before applying patches
|
|
31934
31787
|
var i;
|
|
@@ -31948,14 +31801,12 @@ Immer.prototype.applyPatches = function applyPatches$1(base, patches) {
|
|
|
31948
31801
|
} // Otherwise, produce a copy of the base state.
|
|
31949
31802
|
|
|
31950
31803
|
|
|
31951
|
-
return this.produce(base, function (draft) {
|
|
31952
|
-
return applyPatches(draft, patches.slice(i + 1));
|
|
31953
|
-
});
|
|
31804
|
+
return this.produce(base, function (draft) { return applyPatches(draft, patches.slice(i + 1)); });
|
|
31954
31805
|
};
|
|
31955
31806
|
/** @internal */
|
|
31956
31807
|
|
|
31957
31808
|
|
|
31958
|
-
Immer.prototype.processResult = function processResult(result, scope) {
|
|
31809
|
+
Immer.prototype.processResult = function processResult (result, scope) {
|
|
31959
31810
|
var baseDraft = scope.drafts[0];
|
|
31960
31811
|
var isReplaced = result !== undefined && result !== baseDraft;
|
|
31961
31812
|
this.willFinalize(scope, result, isReplaced);
|
|
@@ -32003,15 +31854,13 @@ Immer.prototype.processResult = function processResult(result, scope) {
|
|
|
32003
31854
|
*/
|
|
32004
31855
|
|
|
32005
31856
|
|
|
32006
|
-
Immer.prototype.finalize = function finalize(draft, path, scope) {
|
|
32007
|
-
|
|
31857
|
+
Immer.prototype.finalize = function finalize (draft, path, scope) {
|
|
31858
|
+
var this$1 = this;
|
|
31859
|
+
|
|
32008
31860
|
var state = draft[DRAFT_STATE];
|
|
32009
31861
|
|
|
32010
31862
|
if (!state) {
|
|
32011
|
-
if (Object.isFrozen(draft)) {
|
|
32012
|
-
return draft;
|
|
32013
|
-
}
|
|
32014
|
-
|
|
31863
|
+
if (Object.isFrozen(draft)) { return draft; }
|
|
32015
31864
|
return this.finalizeTree(draft, null, scope);
|
|
32016
31865
|
} // Never finalize drafts owned by another scope.
|
|
32017
31866
|
|
|
@@ -32034,17 +31883,13 @@ Immer.prototype.finalize = function finalize(draft, path, scope) {
|
|
|
32034
31883
|
var assigned = state.assigned;
|
|
32035
31884
|
|
|
32036
31885
|
for (var prop in assigned) {
|
|
32037
|
-
if (!assigned[prop]) {
|
|
32038
|
-
this.onDelete(state, prop);
|
|
32039
|
-
}
|
|
31886
|
+
if (!assigned[prop]) { this.onDelete(state, prop); }
|
|
32040
31887
|
}
|
|
32041
31888
|
} else {
|
|
32042
31889
|
var base = state.base;
|
|
32043
|
-
|
|
31890
|
+
var copy = state.copy;
|
|
32044
31891
|
each(base, function (prop) {
|
|
32045
|
-
if (!has(copy, prop)) {
|
|
32046
|
-
this$1.onDelete(state, prop);
|
|
32047
|
-
}
|
|
31892
|
+
if (!has(copy, prop)) { this$1.onDelete(state, prop); }
|
|
32048
31893
|
});
|
|
32049
31894
|
}
|
|
32050
31895
|
}
|
|
@@ -32072,8 +31917,9 @@ Immer.prototype.finalize = function finalize(draft, path, scope) {
|
|
|
32072
31917
|
*/
|
|
32073
31918
|
|
|
32074
31919
|
|
|
32075
|
-
Immer.prototype.finalizeTree = function finalizeTree(root, rootPath, scope) {
|
|
32076
|
-
|
|
31920
|
+
Immer.prototype.finalizeTree = function finalizeTree (root, rootPath, scope) {
|
|
31921
|
+
var this$1 = this;
|
|
31922
|
+
|
|
32077
31923
|
var state = root[DRAFT_STATE];
|
|
32078
31924
|
|
|
32079
31925
|
if (state) {
|
|
@@ -32087,7 +31933,7 @@ Immer.prototype.finalizeTree = function finalizeTree(root, rootPath, scope) {
|
|
|
32087
31933
|
|
|
32088
31934
|
var needPatches = !!rootPath && !!scope.patches;
|
|
32089
31935
|
|
|
32090
|
-
var finalizeProperty = function
|
|
31936
|
+
var finalizeProperty = function (prop, value, parent) {
|
|
32091
31937
|
if (value === parent) {
|
|
32092
31938
|
throw Error("Immer forbids circular references");
|
|
32093
31939
|
} // In the `finalizeTree` method, only the `root` object may be a draft.
|
|
@@ -32114,9 +31960,7 @@ Immer.prototype.finalizeTree = function finalizeTree(root, rootPath, scope) {
|
|
|
32114
31960
|
} // Unchanged drafts are never passed to the `onAssign` hook.
|
|
32115
31961
|
|
|
32116
31962
|
|
|
32117
|
-
if (isDraftProp && value === state.base[prop]) {
|
|
32118
|
-
return;
|
|
32119
|
-
}
|
|
31963
|
+
if (isDraftProp && value === state.base[prop]) { return; }
|
|
32120
31964
|
} // Unchanged draft properties are ignored.
|
|
32121
31965
|
else if (isDraftProp && is(value, state.base[prop])) {
|
|
32122
31966
|
return;
|
|
@@ -32201,149 +32045,103 @@ var createDraft = immer.createDraft.bind(immer);
|
|
|
32201
32045
|
|
|
32202
32046
|
var finishDraft = immer.finishDraft.bind(immer);
|
|
32203
32047
|
|
|
32204
|
-
|
|
32205
|
-
|
|
32206
|
-
|
|
32207
|
-
|
|
32208
|
-
for (var _i = 0, _formConfigKeys = formConfigKeys; _i < _formConfigKeys.length; _i++) {
|
|
32209
|
-
var formKey = _formConfigKeys[_i];
|
|
32048
|
+
const createInitialState = formConfig => {
|
|
32049
|
+
let initialForm = {};
|
|
32050
|
+
const formConfigKeys = Object.keys(formConfig);
|
|
32051
|
+
for (let formKey of formConfigKeys) {
|
|
32210
32052
|
initialForm[formKey] = {
|
|
32211
32053
|
dirty: false,
|
|
32212
32054
|
rawValue: formConfig[formKey].defaultValue || "",
|
|
32213
32055
|
validators: formConfig[formKey].validators || [],
|
|
32214
32056
|
constraints: formConfig[formKey].constraints || []
|
|
32215
32057
|
};
|
|
32216
|
-
}
|
|
32058
|
+
}
|
|
32059
|
+
// Because validators require the entire form we have to do a
|
|
32217
32060
|
// second pass to add errors once the initial form has been
|
|
32218
32061
|
// constructed
|
|
32219
|
-
|
|
32220
|
-
|
|
32221
|
-
|
|
32222
|
-
|
|
32223
|
-
var errors = computeErrors(_formKey, initialForm);
|
|
32224
|
-
initialForm[_formKey].errors = errors;
|
|
32225
|
-
initialForm[_formKey].hasErrors = errors.length > 0;
|
|
32062
|
+
for (let formKey of formConfigKeys) {
|
|
32063
|
+
let errors = computeErrors(formKey, initialForm);
|
|
32064
|
+
initialForm[formKey].errors = errors;
|
|
32065
|
+
initialForm[formKey].hasErrors = errors.length > 0;
|
|
32226
32066
|
}
|
|
32227
|
-
|
|
32228
32067
|
return initialForm;
|
|
32229
32068
|
};
|
|
32230
32069
|
|
|
32231
|
-
|
|
32232
|
-
|
|
32233
|
-
|
|
32234
|
-
|
|
32235
|
-
|
|
32236
|
-
type: SET,
|
|
32237
|
-
payload: {
|
|
32238
|
-
fieldName: fieldName,
|
|
32239
|
-
value: value
|
|
32240
|
-
}
|
|
32241
|
-
};
|
|
32242
|
-
};
|
|
32243
|
-
};
|
|
32244
|
-
|
|
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
|
-
});
|
|
32070
|
+
const SET = "field/SET";
|
|
32071
|
+
const set$2 = fieldName => value => ({
|
|
32072
|
+
type: SET,
|
|
32073
|
+
payload: { fieldName, value }
|
|
32074
|
+
});
|
|
32285
32075
|
|
|
32286
|
-
|
|
32287
|
-
|
|
32076
|
+
const CLEAR = "form/CLEAR";
|
|
32077
|
+
const clear = () => ({ type: CLEAR });
|
|
32078
|
+
|
|
32079
|
+
const createFormReducer = formConfig => (
|
|
32080
|
+
state = createInitialState(formConfig),
|
|
32081
|
+
action
|
|
32082
|
+
) => {
|
|
32083
|
+
switch (action.type) {
|
|
32084
|
+
case SET:
|
|
32085
|
+
const changedFieldName = action.payload.fieldName;
|
|
32086
|
+
const newRawValue = action.payload.value;
|
|
32087
|
+
|
|
32088
|
+
return produce(state, draftState => {
|
|
32089
|
+
let originalValue = draftState[changedFieldName].rawValue;
|
|
32090
|
+
draftState[changedFieldName].rawValue = newRawValue;
|
|
32091
|
+
if (computeConstraints(changedFieldName, draftState).length > 0) {
|
|
32092
|
+
// If the change violates constraints, revert the change
|
|
32093
|
+
draftState[changedFieldName].rawValue = originalValue;
|
|
32094
|
+
return draftState;
|
|
32095
|
+
}
|
|
32288
32096
|
|
|
32289
|
-
|
|
32290
|
-
|
|
32291
|
-
|
|
32292
|
-
|
|
32097
|
+
const fields = Object.entries(draftState);
|
|
32098
|
+
for (let entry of fields) {
|
|
32099
|
+
let fieldName = entry[0];
|
|
32100
|
+
let field = entry[1];
|
|
32101
|
+
let errors = computeErrors(fieldName, draftState);
|
|
32102
|
+
let dirty = fieldName === changedFieldName ? true : field.dirty;
|
|
32103
|
+
draftState[fieldName].errors = errors;
|
|
32104
|
+
draftState[fieldName].dirty = dirty;
|
|
32105
|
+
draftState[fieldName].hasErrors = errors.length > 0;
|
|
32106
|
+
}
|
|
32107
|
+
});
|
|
32108
|
+
case CLEAR:
|
|
32109
|
+
return createInitialState(formConfig);
|
|
32110
|
+
default:
|
|
32111
|
+
return state;
|
|
32112
|
+
}
|
|
32293
32113
|
};
|
|
32294
32114
|
|
|
32295
|
-
|
|
32115
|
+
const createMapDispatchToProps = formConfig => {
|
|
32296
32116
|
// Do memo-ization
|
|
32297
|
-
|
|
32298
|
-
|
|
32299
|
-
return
|
|
32117
|
+
let cachedDispatch;
|
|
32118
|
+
let cacheValue;
|
|
32119
|
+
return dispatch => {
|
|
32300
32120
|
if (dispatch == cachedDispatch) {
|
|
32301
32121
|
return cacheValue;
|
|
32302
32122
|
}
|
|
32303
|
-
|
|
32304
|
-
var dispatchObj = {};
|
|
32123
|
+
let dispatchObj = {};
|
|
32305
32124
|
dispatchObj.fields = {};
|
|
32306
|
-
|
|
32307
|
-
|
|
32308
|
-
var _loop = function _loop() {
|
|
32309
|
-
var fieldName = _keys[_i4];
|
|
32125
|
+
const keys = Object.keys(formConfig);
|
|
32126
|
+
for (let fieldName of keys) {
|
|
32310
32127
|
dispatchObj.fields[fieldName] = {
|
|
32311
|
-
set:
|
|
32312
|
-
return dispatch(set$2(fieldName)(value));
|
|
32313
|
-
}
|
|
32128
|
+
set: value => dispatch(set$2(fieldName)(value))
|
|
32314
32129
|
};
|
|
32315
|
-
};
|
|
32316
|
-
|
|
32317
|
-
for (var _i4 = 0, _keys = keys; _i4 < _keys.length; _i4++) {
|
|
32318
|
-
_loop();
|
|
32319
32130
|
}
|
|
32320
|
-
|
|
32321
|
-
dispatchObj.form = {
|
|
32322
|
-
clear: function clear() {
|
|
32323
|
-
return dispatch(_clear());
|
|
32324
|
-
}
|
|
32325
|
-
};
|
|
32131
|
+
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
32326
32132
|
cachedDispatch = dispatch;
|
|
32327
|
-
cacheValue = {
|
|
32328
|
-
actions: dispatchObj
|
|
32329
|
-
};
|
|
32133
|
+
cacheValue = { actions: dispatchObj };
|
|
32330
32134
|
return cacheValue;
|
|
32331
32135
|
};
|
|
32332
32136
|
};
|
|
32333
32137
|
|
|
32334
|
-
|
|
32335
|
-
return {
|
|
32336
|
-
fields: state
|
|
32337
|
-
};
|
|
32338
|
-
};
|
|
32138
|
+
const mapStateToProps = state => ({ fields: state });
|
|
32339
32139
|
|
|
32340
|
-
|
|
32341
|
-
|
|
32342
|
-
|
|
32343
|
-
|
|
32344
|
-
|
|
32345
|
-
};
|
|
32346
|
-
};
|
|
32140
|
+
const createFormState = formConfig => ({
|
|
32141
|
+
reducer: createFormReducer(formConfig),
|
|
32142
|
+
mapDispatchToProps: createMapDispatchToProps(formConfig),
|
|
32143
|
+
mapStateToProps: mapStateToProps
|
|
32144
|
+
});
|
|
32347
32145
|
|
|
32348
32146
|
var formatDelimiter = "_";
|
|
32349
32147
|
var phoneFormats = ["", "_", "__", "(___) ", "(___) _", "(___) __", "(___) ___-", "(___) ___-_", "(___) ___-__", "(___) ___-___", "(___) ___-____"];
|
|
@@ -32920,20 +32718,20 @@ function _templateObject5$3() {
|
|
|
32920
32718
|
return data;
|
|
32921
32719
|
}
|
|
32922
32720
|
|
|
32923
|
-
function _templateObject4$
|
|
32721
|
+
function _templateObject4$7() {
|
|
32924
32722
|
var data = _taggedTemplateLiteral(["\n color: ", ";\n align-items: center;\n font-size: 1rem;\n padding-right: 1rem;\n cursor: pointer;\n display: ", ";\n"]);
|
|
32925
32723
|
|
|
32926
|
-
_templateObject4$
|
|
32724
|
+
_templateObject4$7 = function _templateObject4() {
|
|
32927
32725
|
return data;
|
|
32928
32726
|
};
|
|
32929
32727
|
|
|
32930
32728
|
return data;
|
|
32931
32729
|
}
|
|
32932
32730
|
|
|
32933
|
-
function _templateObject3$
|
|
32731
|
+
function _templateObject3$b() {
|
|
32934
32732
|
var data = _taggedTemplateLiteral(["\n display: flex;\n justify-content: space-evenly;\n align-items: center;\n"]);
|
|
32935
32733
|
|
|
32936
|
-
_templateObject3$
|
|
32734
|
+
_templateObject3$b = function _templateObject3() {
|
|
32937
32735
|
return data;
|
|
32938
32736
|
};
|
|
32939
32737
|
|
|
@@ -32976,8 +32774,8 @@ var EditableTableListItem = styled__default.div(_templateObject2$k(), function (
|
|
|
32976
32774
|
var isMobile = _ref5.isMobile;
|
|
32977
32775
|
return isMobile ? "padding: 1rem 0.5rem" : "padding: 0 0.5rem";
|
|
32978
32776
|
});
|
|
32979
|
-
var EditableListItemControls$1 = styled__default.div(_templateObject3$
|
|
32980
|
-
var EditableListAction = styled__default.div(_templateObject4$
|
|
32777
|
+
var EditableListItemControls$1 = styled__default.div(_templateObject3$b());
|
|
32778
|
+
var EditableListAction = styled__default.div(_templateObject4$7(), MATISSE_BLUE, function (_ref6) {
|
|
32981
32779
|
var hide = _ref6.hide;
|
|
32982
32780
|
return hide ? "none" : "flex";
|
|
32983
32781
|
});
|
|
@@ -37478,10 +37276,10 @@ var RadioSection = function RadioSection(_ref) {
|
|
|
37478
37276
|
}, /*#__PURE__*/React__default.createElement(Box, {
|
|
37479
37277
|
padding: section.hideRadioButton ? "1.5rem" : "1.25rem 1.5rem 1.25rem 1.25rem",
|
|
37480
37278
|
background: section.disabled ? themeValues.headingDisabledColor : themeValues.headingBackgroundColor,
|
|
37481
|
-
onClick: isMobile && supportsTouch ? noop : function () {
|
|
37279
|
+
onClick: isMobile && supportsTouch || section.disabled ? noop : function () {
|
|
37482
37280
|
return toggleOpenSection(section.id);
|
|
37483
37281
|
},
|
|
37484
|
-
onTouchEnd: isMobile && supportsTouch ? function () {
|
|
37282
|
+
onTouchEnd: isMobile && supportsTouch || !section.disabled ? function () {
|
|
37485
37283
|
return toggleOpenSection(section.id);
|
|
37486
37284
|
} : noop,
|
|
37487
37285
|
key: "header-".concat(section.id),
|
|
@@ -37505,7 +37303,7 @@ var RadioSection = function RadioSection(_ref) {
|
|
|
37505
37303
|
name: section.id,
|
|
37506
37304
|
radioOn: openSection === section.id,
|
|
37507
37305
|
radioFocused: focused === section.id,
|
|
37508
|
-
toggleRadio: function
|
|
37306
|
+
toggleRadio: section.disabled ? noop : function () {
|
|
37509
37307
|
return toggleOpenSection(section.id);
|
|
37510
37308
|
},
|
|
37511
37309
|
tabIndex: "-1"
|