@dartcom/ui-kit 3.8.0 → 3.8.2
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/components/form/form.stories.d.ts.map +1 -1
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/index.cjs +4247 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +14 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/pages/auth/auth.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5448,7 +5448,7 @@ const createClassNameGenerator = () => {
|
|
|
5448
5448
|
};
|
|
5449
5449
|
const ClassNameGenerator = createClassNameGenerator();
|
|
5450
5450
|
|
|
5451
|
-
function r$
|
|
5451
|
+
function r$2(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r$2(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx$1(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r$2(e))&&(n&&(n+=" "),n+=t);return n}
|
|
5452
5452
|
|
|
5453
5453
|
function createBox(options = {}) {
|
|
5454
5454
|
const {
|
|
@@ -14361,7 +14361,7 @@ function isElement(node) {
|
|
|
14361
14361
|
return node instanceof OwnElement || node instanceof Element;
|
|
14362
14362
|
}
|
|
14363
14363
|
|
|
14364
|
-
function isHTMLElement$
|
|
14364
|
+
function isHTMLElement$3(node) {
|
|
14365
14365
|
var OwnElement = getWindow$1(node).HTMLElement;
|
|
14366
14366
|
return node instanceof OwnElement || node instanceof HTMLElement;
|
|
14367
14367
|
}
|
|
@@ -14385,7 +14385,7 @@ function applyStyles(_ref) {
|
|
|
14385
14385
|
var attributes = state.attributes[name] || {};
|
|
14386
14386
|
var element = state.elements[name]; // arrow is optional + virtual elements
|
|
14387
14387
|
|
|
14388
|
-
if (!isHTMLElement$
|
|
14388
|
+
if (!isHTMLElement$3(element) || !getNodeName(element)) {
|
|
14389
14389
|
return;
|
|
14390
14390
|
} // Flow doesn't support to extend this property, but it's the most
|
|
14391
14391
|
// effective way to apply styles to an HTMLElement
|
|
@@ -14437,7 +14437,7 @@ function effect$2(_ref2) {
|
|
|
14437
14437
|
return style;
|
|
14438
14438
|
}, {}); // arrow is optional + virtual elements
|
|
14439
14439
|
|
|
14440
|
-
if (!isHTMLElement$
|
|
14440
|
+
if (!isHTMLElement$3(element) || !getNodeName(element)) {
|
|
14441
14441
|
return;
|
|
14442
14442
|
}
|
|
14443
14443
|
|
|
@@ -14496,7 +14496,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
|
14496
14496
|
var scaleX = 1;
|
|
14497
14497
|
var scaleY = 1;
|
|
14498
14498
|
|
|
14499
|
-
if (includeScale && isHTMLElement$
|
|
14499
|
+
if (includeScale && isHTMLElement$3(element)) {
|
|
14500
14500
|
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
14501
14501
|
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
14502
14502
|
}
|
|
@@ -14601,7 +14601,7 @@ function getParentNode(element) {
|
|
|
14601
14601
|
}
|
|
14602
14602
|
|
|
14603
14603
|
function getTrueOffsetParent(element) {
|
|
14604
|
-
if (!isHTMLElement$
|
|
14604
|
+
if (!isHTMLElement$3(element) || // https://github.com/popperjs/popper-core/issues/837
|
|
14605
14605
|
getComputedStyle(element).position === 'fixed') {
|
|
14606
14606
|
return null;
|
|
14607
14607
|
}
|
|
@@ -14615,7 +14615,7 @@ function getContainingBlock(element) {
|
|
|
14615
14615
|
var isFirefox = /firefox/i.test(getUAString());
|
|
14616
14616
|
var isIE = /Trident/i.test(getUAString());
|
|
14617
14617
|
|
|
14618
|
-
if (isIE && isHTMLElement$
|
|
14618
|
+
if (isIE && isHTMLElement$3(element)) {
|
|
14619
14619
|
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
|
|
14620
14620
|
var elementCss = getComputedStyle(element);
|
|
14621
14621
|
|
|
@@ -14630,7 +14630,7 @@ function getContainingBlock(element) {
|
|
|
14630
14630
|
currentNode = currentNode.host;
|
|
14631
14631
|
}
|
|
14632
14632
|
|
|
14633
|
-
while (isHTMLElement$
|
|
14633
|
+
while (isHTMLElement$3(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
|
|
14634
14634
|
var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
|
|
14635
14635
|
// create a containing block.
|
|
14636
14636
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
@@ -15100,7 +15100,7 @@ function getScrollParent(node) {
|
|
|
15100
15100
|
return node.ownerDocument.body;
|
|
15101
15101
|
}
|
|
15102
15102
|
|
|
15103
|
-
if (isHTMLElement$
|
|
15103
|
+
if (isHTMLElement$3(node) && isScrollParent(node)) {
|
|
15104
15104
|
return node;
|
|
15105
15105
|
}
|
|
15106
15106
|
|
|
@@ -15162,7 +15162,7 @@ function getClientRectFromMixedType(element, clippingParent, strategy) {
|
|
|
15162
15162
|
function getClippingParents(element) {
|
|
15163
15163
|
var clippingParents = listScrollParents(getParentNode(element));
|
|
15164
15164
|
var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
|
|
15165
|
-
var clipperElement = canEscapeClipping && isHTMLElement$
|
|
15165
|
+
var clipperElement = canEscapeClipping && isHTMLElement$3(element) ? getOffsetParent(element) : element;
|
|
15166
15166
|
|
|
15167
15167
|
if (!isElement(clipperElement)) {
|
|
15168
15168
|
return [];
|
|
@@ -15772,7 +15772,7 @@ function getHTMLElementScroll(element) {
|
|
|
15772
15772
|
}
|
|
15773
15773
|
|
|
15774
15774
|
function getNodeScroll(node) {
|
|
15775
|
-
if (node === getWindow$1(node) || !isHTMLElement$
|
|
15775
|
+
if (node === getWindow$1(node) || !isHTMLElement$3(node)) {
|
|
15776
15776
|
return getWindowScroll(node);
|
|
15777
15777
|
} else {
|
|
15778
15778
|
return getHTMLElementScroll(node);
|
|
@@ -15793,8 +15793,8 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
|
15793
15793
|
isFixed = false;
|
|
15794
15794
|
}
|
|
15795
15795
|
|
|
15796
|
-
var isOffsetParentAnElement = isHTMLElement$
|
|
15797
|
-
var offsetParentIsScaled = isHTMLElement$
|
|
15796
|
+
var isOffsetParentAnElement = isHTMLElement$3(offsetParent);
|
|
15797
|
+
var offsetParentIsScaled = isHTMLElement$3(offsetParent) && isElementScaled(offsetParent);
|
|
15798
15798
|
var documentElement = getDocumentElement(offsetParent);
|
|
15799
15799
|
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
|
15800
15800
|
var scroll = {
|
|
@@ -15812,7 +15812,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
|
15812
15812
|
scroll = getNodeScroll(offsetParent);
|
|
15813
15813
|
}
|
|
15814
15814
|
|
|
15815
|
-
if (isHTMLElement$
|
|
15815
|
+
if (isHTMLElement$3(offsetParent)) {
|
|
15816
15816
|
offsets = getBoundingClientRect(offsetParent, true);
|
|
15817
15817
|
offsets.x += offsetParent.clientLeft;
|
|
15818
15818
|
offsets.y += offsetParent.clientTop;
|
|
@@ -16250,11 +16250,11 @@ function flipPlacement(placement, direction) {
|
|
|
16250
16250
|
function resolveAnchorEl$1(anchorEl) {
|
|
16251
16251
|
return typeof anchorEl === 'function' ? anchorEl() : anchorEl;
|
|
16252
16252
|
}
|
|
16253
|
-
function isHTMLElement$
|
|
16253
|
+
function isHTMLElement$2(element) {
|
|
16254
16254
|
return element.nodeType !== undefined;
|
|
16255
16255
|
}
|
|
16256
16256
|
function isVirtualElement(element) {
|
|
16257
|
-
return !isHTMLElement$
|
|
16257
|
+
return !isHTMLElement$2(element);
|
|
16258
16258
|
}
|
|
16259
16259
|
const useUtilityClasses$v = ownerState => {
|
|
16260
16260
|
const {
|
|
@@ -16319,7 +16319,7 @@ const PopperTooltip = /*#__PURE__*/React__namespace.forwardRef(function PopperTo
|
|
|
16319
16319
|
setPlacement(data.placement);
|
|
16320
16320
|
};
|
|
16321
16321
|
if (process.env.NODE_ENV !== 'production') {
|
|
16322
|
-
if (resolvedAnchorElement && isHTMLElement$
|
|
16322
|
+
if (resolvedAnchorElement && isHTMLElement$2(resolvedAnchorElement) && resolvedAnchorElement.nodeType === 1) {
|
|
16323
16323
|
const box = resolvedAnchorElement.getBoundingClientRect();
|
|
16324
16324
|
if (process.env.NODE_ENV !== 'test' && box.top === 0 && box.left === 0 && box.right === 0 && box.bottom === 0) {
|
|
16325
16325
|
console.warn(['MUI: The `anchorEl` prop provided to the component is invalid.', 'The anchor element should be part of the document layout.', "Make sure the element is present in the document or that it's not display none."].join('\n'));
|
|
@@ -16429,7 +16429,7 @@ const Popper$1 = /*#__PURE__*/React__namespace.forwardRef(function Popper(props,
|
|
|
16429
16429
|
container = containerProp;
|
|
16430
16430
|
} else if (anchorEl) {
|
|
16431
16431
|
const resolvedAnchorEl = resolveAnchorEl$1(anchorEl);
|
|
16432
|
-
container = resolvedAnchorEl && isHTMLElement$
|
|
16432
|
+
container = resolvedAnchorEl && isHTMLElement$2(resolvedAnchorEl) ? ownerDocument$1(resolvedAnchorEl).body : ownerDocument$1(null).body;
|
|
16433
16433
|
}
|
|
16434
16434
|
const display = !open && keepMounted && (!transition || exited) ? 'none' : undefined;
|
|
16435
16435
|
const transitionProps = transition ? {
|
|
@@ -16481,7 +16481,7 @@ process.env.NODE_ENV !== "production" ? Popper$1.propTypes /* remove-proptypes *
|
|
|
16481
16481
|
anchorEl: chainPropTypes(PropTypes.oneOfType([HTMLElementType, PropTypes.object, PropTypes.func]), props => {
|
|
16482
16482
|
if (props.open) {
|
|
16483
16483
|
const resolvedAnchorEl = resolveAnchorEl$1(props.anchorEl);
|
|
16484
|
-
if (resolvedAnchorEl && isHTMLElement$
|
|
16484
|
+
if (resolvedAnchorEl && isHTMLElement$2(resolvedAnchorEl) && resolvedAnchorEl.nodeType === 1) {
|
|
16485
16485
|
const box = resolvedAnchorEl.getBoundingClientRect();
|
|
16486
16486
|
if (process.env.NODE_ENV !== 'test' && box.top === 0 && box.left === 0 && box.right === 0 && box.bottom === 0) {
|
|
16487
16487
|
return new Error(['MUI: The `anchorEl` prop provided to the component is invalid.', 'The anchor element should be part of the document layout.', "Make sure the element is present in the document or that it's not display none."].join('\n'));
|
|
@@ -20746,7 +20746,7 @@ const ButtonLoadingIconPlaceholder = styled('span', {
|
|
|
20746
20746
|
width: '1em',
|
|
20747
20747
|
height: '1em'
|
|
20748
20748
|
});
|
|
20749
|
-
const Button$
|
|
20749
|
+
const Button$2 = /*#__PURE__*/React__namespace.forwardRef(function Button(inProps, ref) {
|
|
20750
20750
|
// props priority: `inProps` > `contextProps` > `themeDefaultProps`
|
|
20751
20751
|
const contextProps = React__namespace.useContext(ButtonGroupContext);
|
|
20752
20752
|
const buttonGroupButtonContextPositionClassName = React__namespace.useContext(ButtonGroupButtonContext);
|
|
@@ -20844,7 +20844,7 @@ const Button$1 = /*#__PURE__*/React__namespace.forwardRef(function Button(inProp
|
|
|
20844
20844
|
children: [startIcon, loadingPosition !== 'end' && loader, children, loadingPosition === 'end' && loader, endIcon]
|
|
20845
20845
|
});
|
|
20846
20846
|
});
|
|
20847
|
-
process.env.NODE_ENV !== "production" ? Button$
|
|
20847
|
+
process.env.NODE_ENV !== "production" ? Button$2.propTypes /* remove-proptypes */ = {
|
|
20848
20848
|
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
20849
20849
|
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
20850
20850
|
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
@@ -30167,9 +30167,9 @@ const DeleteButton = ({ notification, onDelete, }) => {
|
|
|
30167
30167
|
}
|
|
30168
30168
|
}, children: jsxRuntime.jsx(DeleteIcon, { fontSize: "small", color: "error" }) }), notification ? (jsxRuntime.jsxs(Dialog, { slots: {
|
|
30169
30169
|
transition: Transition$1,
|
|
30170
|
-
}, open: openNotification, onClose: handleCloseNotification, children: [jsxRuntime.jsx(DialogTitle, { id: `${id}-dialog-title`, children: notification.title }), jsxRuntime.jsx(DialogContent, { children: jsxRuntime.jsx(DialogContentText, { id: `${id}-dialog-text`, children: notification.description }) }), jsxRuntime.jsxs(DialogActions, { children: [jsxRuntime.jsx(Button$
|
|
30170
|
+
}, open: openNotification, onClose: handleCloseNotification, children: [jsxRuntime.jsx(DialogTitle, { id: `${id}-dialog-title`, children: notification.title }), jsxRuntime.jsx(DialogContent, { children: jsxRuntime.jsx(DialogContentText, { id: `${id}-dialog-text`, children: notification.description }) }), jsxRuntime.jsxs(DialogActions, { children: [jsxRuntime.jsx(Button$2, { variant: "contained", color: "error", sx: {
|
|
30171
30171
|
textTransform: 'none',
|
|
30172
|
-
}, onClick: handleCloseNotification, children: "\u041E\u0442\u043C\u0435\u043D\u0430" }), jsxRuntime.jsx(Button$
|
|
30172
|
+
}, onClick: handleCloseNotification, children: "\u041E\u0442\u043C\u0435\u043D\u0430" }), jsxRuntime.jsx(Button$2, { variant: "contained", sx: {
|
|
30173
30173
|
textTransform: 'none',
|
|
30174
30174
|
}, onClick: () => {
|
|
30175
30175
|
onDelete();
|
|
@@ -30199,7 +30199,7 @@ const warn = () => {
|
|
|
30199
30199
|
*/
|
|
30200
30200
|
var LoadingButton = /*#__PURE__*/React__namespace.forwardRef(function DeprecatedLoadingButton(props, ref) {
|
|
30201
30201
|
warn();
|
|
30202
|
-
return /*#__PURE__*/jsxRuntime.jsx(Button$
|
|
30202
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button$2, {
|
|
30203
30203
|
ref: ref,
|
|
30204
30204
|
...props
|
|
30205
30205
|
});
|
|
@@ -30349,7 +30349,7 @@ function once(func) {
|
|
|
30349
30349
|
};
|
|
30350
30350
|
}
|
|
30351
30351
|
var noop$4 = function noop() {};
|
|
30352
|
-
function isFunction$
|
|
30352
|
+
function isFunction$3(fn) {
|
|
30353
30353
|
return typeof fn === "function";
|
|
30354
30354
|
}
|
|
30355
30355
|
function isStringish(value) {
|
|
@@ -30362,11 +30362,11 @@ function isStringish(value) {
|
|
|
30362
30362
|
}
|
|
30363
30363
|
return false;
|
|
30364
30364
|
}
|
|
30365
|
-
function isObject$
|
|
30365
|
+
function isObject$3(value) {
|
|
30366
30366
|
return value !== null && typeof value === "object";
|
|
30367
30367
|
}
|
|
30368
30368
|
function isPlainObject$3(value) {
|
|
30369
|
-
if (!isObject$
|
|
30369
|
+
if (!isObject$3(value)) {
|
|
30370
30370
|
return false;
|
|
30371
30371
|
}
|
|
30372
30372
|
var proto = Object.getPrototypeOf(value);
|
|
@@ -30407,7 +30407,7 @@ function createInstanceofPredicate(name, theClass) {
|
|
|
30407
30407
|
var propName = "isMobX" + name;
|
|
30408
30408
|
theClass.prototype[propName] = true;
|
|
30409
30409
|
return function (x) {
|
|
30410
|
-
return isObject$
|
|
30410
|
+
return isObject$3(x) && x[propName] === true;
|
|
30411
30411
|
};
|
|
30412
30412
|
}
|
|
30413
30413
|
/**
|
|
@@ -30914,7 +30914,7 @@ function decorate_20223_$1(mthd, context) {
|
|
|
30914
30914
|
function assertActionDescriptor(adm, _ref, key, _ref2) {
|
|
30915
30915
|
var annotationType_ = _ref.annotationType_;
|
|
30916
30916
|
var value = _ref2.value;
|
|
30917
|
-
if (process.env.NODE_ENV !== "production" && !isFunction$
|
|
30917
|
+
if (process.env.NODE_ENV !== "production" && !isFunction$3(value)) {
|
|
30918
30918
|
die("Cannot apply '" + annotationType_ + "' to '" + adm.name_ + "." + key.toString() + "':" + ("\n'" + annotationType_ + "' can only be used on properties with a function value."));
|
|
30919
30919
|
}
|
|
30920
30920
|
}
|
|
@@ -31005,7 +31005,7 @@ function decorate_20223_$2(mthd, context) {
|
|
|
31005
31005
|
function assertFlowDescriptor(adm, _ref, key, _ref2) {
|
|
31006
31006
|
var annotationType_ = _ref.annotationType_;
|
|
31007
31007
|
var value = _ref2.value;
|
|
31008
|
-
if (process.env.NODE_ENV !== "production" && !isFunction$
|
|
31008
|
+
if (process.env.NODE_ENV !== "production" && !isFunction$3(value)) {
|
|
31009
31009
|
die("Cannot apply '" + annotationType_ + "' to '" + adm.name_ + "." + key.toString() + "':" + ("\n'" + annotationType_ + "' can only be used on properties with a generator function value."));
|
|
31010
31010
|
}
|
|
31011
31011
|
}
|
|
@@ -31381,10 +31381,10 @@ var computed = function computed(arg1, arg2) {
|
|
|
31381
31381
|
}
|
|
31382
31382
|
// computed(expr, options?)
|
|
31383
31383
|
if (process.env.NODE_ENV !== "production") {
|
|
31384
|
-
if (!isFunction$
|
|
31384
|
+
if (!isFunction$3(arg1)) {
|
|
31385
31385
|
die("First argument to `computed` should be an expression.");
|
|
31386
31386
|
}
|
|
31387
|
-
if (isFunction$
|
|
31387
|
+
if (isFunction$3(arg2)) {
|
|
31388
31388
|
die("A setter as second argument is no longer supported, use `{ set: fn }` option instead");
|
|
31389
31389
|
}
|
|
31390
31390
|
}
|
|
@@ -31414,7 +31414,7 @@ function createAction(actionName, fn, autoAction, ref) {
|
|
|
31414
31414
|
autoAction = false;
|
|
31415
31415
|
}
|
|
31416
31416
|
if (process.env.NODE_ENV !== "production") {
|
|
31417
|
-
if (!isFunction$
|
|
31417
|
+
if (!isFunction$3(fn)) {
|
|
31418
31418
|
die("`action` can only be invoked on functions");
|
|
31419
31419
|
}
|
|
31420
31420
|
if (typeof actionName !== "string" || !actionName) {
|
|
@@ -32871,11 +32871,11 @@ var autoActionBoundAnnotation = /*#__PURE__*/createActionAnnotation(AUTOACTION_B
|
|
|
32871
32871
|
function createActionFactory(autoAction) {
|
|
32872
32872
|
var res = function action(arg1, arg2) {
|
|
32873
32873
|
// action(fn() {})
|
|
32874
|
-
if (isFunction$
|
|
32874
|
+
if (isFunction$3(arg1)) {
|
|
32875
32875
|
return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction);
|
|
32876
32876
|
}
|
|
32877
32877
|
// action("name", fn() {})
|
|
32878
|
-
if (isFunction$
|
|
32878
|
+
if (isFunction$3(arg2)) {
|
|
32879
32879
|
return createAction(arg1, arg2, autoAction);
|
|
32880
32880
|
}
|
|
32881
32881
|
// @action (2022.3 Decorators)
|
|
@@ -32906,7 +32906,7 @@ Object.assign(autoAction, autoActionAnnotation);
|
|
|
32906
32906
|
action.bound = /*#__PURE__*/createDecoratorAnnotation(actionBoundAnnotation);
|
|
32907
32907
|
autoAction.bound = /*#__PURE__*/createDecoratorAnnotation(autoActionBoundAnnotation);
|
|
32908
32908
|
function isAction(thing) {
|
|
32909
|
-
return isFunction$
|
|
32909
|
+
return isFunction$3(thing) && thing.isMobxAction === true;
|
|
32910
32910
|
}
|
|
32911
32911
|
|
|
32912
32912
|
/**
|
|
@@ -32921,7 +32921,7 @@ function autorun(view, opts) {
|
|
|
32921
32921
|
opts = EMPTY_OBJECT;
|
|
32922
32922
|
}
|
|
32923
32923
|
if (process.env.NODE_ENV !== "production") {
|
|
32924
|
-
if (!isFunction$
|
|
32924
|
+
if (!isFunction$3(view)) {
|
|
32925
32925
|
die("Autorun expects a function as first argument");
|
|
32926
32926
|
}
|
|
32927
32927
|
if (isAction(view)) {
|
|
@@ -32979,7 +32979,7 @@ function onBecomeUnobserved(thing, arg2, arg3) {
|
|
|
32979
32979
|
}
|
|
32980
32980
|
function interceptHook(hook, thing, arg2, arg3) {
|
|
32981
32981
|
var atom = getAtom(thing);
|
|
32982
|
-
var cb = isFunction$
|
|
32982
|
+
var cb = isFunction$3(arg3) ? arg3 : arg2;
|
|
32983
32983
|
var listenersKey = hook + "L";
|
|
32984
32984
|
if (atom[listenersKey]) {
|
|
32985
32985
|
atom[listenersKey].add(cb);
|
|
@@ -33135,7 +33135,7 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
33135
33135
|
next(ret);
|
|
33136
33136
|
}
|
|
33137
33137
|
function next(ret) {
|
|
33138
|
-
if (isFunction$
|
|
33138
|
+
if (isFunction$3(ret == null ? void 0 : ret.then)) {
|
|
33139
33139
|
// an async iterator
|
|
33140
33140
|
ret.then(next, reject);
|
|
33141
33141
|
return;
|
|
@@ -33172,7 +33172,7 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
33172
33172
|
}, flowAnnotation);
|
|
33173
33173
|
flow.bound = /*#__PURE__*/createDecoratorAnnotation(flowBoundAnnotation);
|
|
33174
33174
|
function cancelPromise(promise) {
|
|
33175
|
-
if (isFunction$
|
|
33175
|
+
if (isFunction$3(promise.cancel)) {
|
|
33176
33176
|
promise.cancel();
|
|
33177
33177
|
}
|
|
33178
33178
|
}
|
|
@@ -33896,7 +33896,7 @@ function reduceLikeFunc(funcName) {
|
|
|
33896
33896
|
}
|
|
33897
33897
|
var isObservableArrayAdministration = /*#__PURE__*/createInstanceofPredicate("ObservableArrayAdministration", ObservableArrayAdministration);
|
|
33898
33898
|
function isObservableArray(thing) {
|
|
33899
|
-
return isObject$
|
|
33899
|
+
return isObject$3(thing) && isObservableArrayAdministration(thing[$mobx]);
|
|
33900
33900
|
}
|
|
33901
33901
|
|
|
33902
33902
|
var ObservableMapMarker = {};
|
|
@@ -33925,7 +33925,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
33925
33925
|
this.dehancer = void 0;
|
|
33926
33926
|
this.enhancer_ = enhancer_;
|
|
33927
33927
|
this.name_ = name_;
|
|
33928
|
-
if (!isFunction$
|
|
33928
|
+
if (!isFunction$3(Map)) {
|
|
33929
33929
|
die(18);
|
|
33930
33930
|
}
|
|
33931
33931
|
initObservable(function () {
|
|
@@ -34334,7 +34334,7 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
34334
34334
|
this.dehancer = void 0;
|
|
34335
34335
|
this.enhancer_ = void 0;
|
|
34336
34336
|
this.name_ = name_;
|
|
34337
|
-
if (!isFunction$
|
|
34337
|
+
if (!isFunction$3(Set)) {
|
|
34338
34338
|
die(22);
|
|
34339
34339
|
}
|
|
34340
34340
|
this.enhancer_ = function (newV, oldV) {
|
|
@@ -35143,7 +35143,7 @@ function getCachedObservablePropDescriptor(key) {
|
|
|
35143
35143
|
});
|
|
35144
35144
|
}
|
|
35145
35145
|
function isObservableObject(thing) {
|
|
35146
|
-
if (isObject$
|
|
35146
|
+
if (isObject$3(thing)) {
|
|
35147
35147
|
return isObservableObjectAdministration(thing[$mobx]);
|
|
35148
35148
|
}
|
|
35149
35149
|
return false;
|
|
@@ -35372,7 +35372,7 @@ function getAtom(thing, property) {
|
|
|
35372
35372
|
if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) {
|
|
35373
35373
|
return thing;
|
|
35374
35374
|
}
|
|
35375
|
-
} else if (isFunction$
|
|
35375
|
+
} else if (isFunction$3(thing)) {
|
|
35376
35376
|
if (isReaction(thing[$mobx])) {
|
|
35377
35377
|
// disposer function
|
|
35378
35378
|
return thing[$mobx];
|
|
@@ -35428,7 +35428,7 @@ function initObservable(cb) {
|
|
|
35428
35428
|
}
|
|
35429
35429
|
}
|
|
35430
35430
|
|
|
35431
|
-
var toString$
|
|
35431
|
+
var toString$2 = objectPrototype.toString;
|
|
35432
35432
|
function deepEqual$1(a, b, depth) {
|
|
35433
35433
|
if (depth === void 0) {
|
|
35434
35434
|
depth = -1;
|
|
@@ -35459,8 +35459,8 @@ function eq(a, b, depth, aStack, bStack) {
|
|
|
35459
35459
|
return false;
|
|
35460
35460
|
}
|
|
35461
35461
|
// Compare `[[Class]]` names.
|
|
35462
|
-
var className = toString$
|
|
35463
|
-
if (className !== toString$
|
|
35462
|
+
var className = toString$2.call(a);
|
|
35463
|
+
if (className !== toString$2.call(b)) {
|
|
35464
35464
|
return false;
|
|
35465
35465
|
}
|
|
35466
35466
|
switch (className) {
|
|
@@ -35508,7 +35508,7 @@ function eq(a, b, depth, aStack, bStack) {
|
|
|
35508
35508
|
// from different frames are.
|
|
35509
35509
|
var aCtor = a.constructor,
|
|
35510
35510
|
bCtor = b.constructor;
|
|
35511
|
-
if (aCtor !== bCtor && !(isFunction$
|
|
35511
|
+
if (aCtor !== bCtor && !(isFunction$3(aCtor) && aCtor instanceof aCtor && isFunction$3(bCtor) && bCtor instanceof bCtor) && "constructor" in a && "constructor" in b) {
|
|
35512
35512
|
return false;
|
|
35513
35513
|
}
|
|
35514
35514
|
}
|
|
@@ -35595,7 +35595,7 @@ function getSelf() {
|
|
|
35595
35595
|
function isAnnotation(thing) {
|
|
35596
35596
|
return (
|
|
35597
35597
|
// Can be function
|
|
35598
|
-
thing instanceof Object && typeof thing.annotationType_ === "string" && isFunction$
|
|
35598
|
+
thing instanceof Object && typeof thing.annotationType_ === "string" && isFunction$3(thing.make_) && isFunction$3(thing.extend_)
|
|
35599
35599
|
);
|
|
35600
35600
|
}
|
|
35601
35601
|
|
|
@@ -36143,14 +36143,14 @@ const Button = (props) => {
|
|
|
36143
36143
|
if (icon) {
|
|
36144
36144
|
return jsxRuntime.jsx(IconButton, { ...restProps, children: icon });
|
|
36145
36145
|
}
|
|
36146
|
-
return (jsxRuntime.jsx(Button$
|
|
36146
|
+
return (jsxRuntime.jsx(Button$2, { sx: {
|
|
36147
36147
|
whiteSpace: 'nowrap',
|
|
36148
36148
|
padding: '5px 15px',
|
|
36149
36149
|
textTransform: 'none',
|
|
36150
36150
|
...sx,
|
|
36151
36151
|
}, variant: variant, ...restProps, children: jsxRuntime.jsx(Typography, { variant: textVariant, children: children }) }));
|
|
36152
36152
|
};
|
|
36153
|
-
var
|
|
36153
|
+
var Button$1 = observer(Button);
|
|
36154
36154
|
|
|
36155
36155
|
var isCheckBoxInput = (element) => element.type === 'checkbox';
|
|
36156
36156
|
|
|
@@ -36159,12 +36159,12 @@ var isDateObject = (value) => value instanceof Date;
|
|
|
36159
36159
|
var isNullOrUndefined = (value) => value == null;
|
|
36160
36160
|
|
|
36161
36161
|
const isObjectType = (value) => typeof value === 'object';
|
|
36162
|
-
var isObject$
|
|
36162
|
+
var isObject$2 = (value) => !isNullOrUndefined(value) &&
|
|
36163
36163
|
!Array.isArray(value) &&
|
|
36164
36164
|
isObjectType(value) &&
|
|
36165
36165
|
!isDateObject(value);
|
|
36166
36166
|
|
|
36167
|
-
var getEventValue = (event) => isObject$
|
|
36167
|
+
var getEventValue = (event) => isObject$2(event) && event.target
|
|
36168
36168
|
? isCheckBoxInput(event.target)
|
|
36169
36169
|
? event.target.checked
|
|
36170
36170
|
: event.target.value
|
|
@@ -36176,7 +36176,7 @@ var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
|
|
|
36176
36176
|
|
|
36177
36177
|
var isPlainObject$2 = (tempObject) => {
|
|
36178
36178
|
const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
|
|
36179
|
-
return (isObject$
|
|
36179
|
+
return (isObject$2(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
|
|
36180
36180
|
};
|
|
36181
36181
|
|
|
36182
36182
|
var isWeb = typeof window !== 'undefined' &&
|
|
@@ -36191,7 +36191,7 @@ function cloneObject(data) {
|
|
|
36191
36191
|
copy = new Date(data);
|
|
36192
36192
|
}
|
|
36193
36193
|
else if (!(isWeb && (data instanceof Blob || isFileListInstance)) &&
|
|
36194
|
-
(isArray || isObject$
|
|
36194
|
+
(isArray || isObject$2(data))) {
|
|
36195
36195
|
copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
|
|
36196
36196
|
if (!isArray && !isPlainObject$2(data)) {
|
|
36197
36197
|
copy = data;
|
|
@@ -36219,7 +36219,7 @@ var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
|
|
|
36219
36219
|
var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
|
|
36220
36220
|
|
|
36221
36221
|
var get = (object, path, defaultValue) => {
|
|
36222
|
-
if (!path || !isObject$
|
|
36222
|
+
if (!path || !isObject$2(object)) {
|
|
36223
36223
|
return defaultValue;
|
|
36224
36224
|
}
|
|
36225
36225
|
const result = (isKey(path) ? [path] : stringToPath(path)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
|
|
@@ -36243,7 +36243,7 @@ var set = (object, path, value) => {
|
|
|
36243
36243
|
if (index !== lastIndex) {
|
|
36244
36244
|
const objValue = object[key];
|
|
36245
36245
|
newValue =
|
|
36246
|
-
isObject$
|
|
36246
|
+
isObject$2(objValue) || Array.isArray(objValue)
|
|
36247
36247
|
? objValue
|
|
36248
36248
|
: !isNaN(+tempPath[index + 1])
|
|
36249
36249
|
? []
|
|
@@ -36259,11 +36259,25 @@ var set = (object, path, value) => {
|
|
|
36259
36259
|
|
|
36260
36260
|
const EVENTS = {
|
|
36261
36261
|
BLUR: 'blur',
|
|
36262
|
+
FOCUS_OUT: 'focusout',
|
|
36262
36263
|
CHANGE: 'change',
|
|
36263
36264
|
};
|
|
36264
36265
|
const VALIDATION_MODE = {
|
|
36266
|
+
onBlur: 'onBlur',
|
|
36267
|
+
onChange: 'onChange',
|
|
36268
|
+
onSubmit: 'onSubmit',
|
|
36269
|
+
onTouched: 'onTouched',
|
|
36265
36270
|
all: 'all',
|
|
36266
36271
|
};
|
|
36272
|
+
const INPUT_VALIDATION_RULES = {
|
|
36273
|
+
max: 'max',
|
|
36274
|
+
min: 'min',
|
|
36275
|
+
maxLength: 'maxLength',
|
|
36276
|
+
minLength: 'minLength',
|
|
36277
|
+
pattern: 'pattern',
|
|
36278
|
+
required: 'required',
|
|
36279
|
+
validate: 'validate',
|
|
36280
|
+
};
|
|
36267
36281
|
|
|
36268
36282
|
const HookFormContext = React.createContext(null);
|
|
36269
36283
|
HookFormContext.displayName = 'HookFormContext';
|
|
@@ -36420,11 +36434,14 @@ var isString$1 = (value) => typeof value === 'string';
|
|
|
36420
36434
|
|
|
36421
36435
|
var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
|
|
36422
36436
|
if (isString$1(names)) {
|
|
36437
|
+
isGlobal && _names.watch.add(names);
|
|
36423
36438
|
return get(formValues, names, defaultValue);
|
|
36424
36439
|
}
|
|
36425
36440
|
if (Array.isArray(names)) {
|
|
36426
|
-
return names.map((fieldName) => (
|
|
36441
|
+
return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName),
|
|
36442
|
+
get(formValues, fieldName)));
|
|
36427
36443
|
}
|
|
36444
|
+
isGlobal && (_names.watchAll = true);
|
|
36428
36445
|
return formValues;
|
|
36429
36446
|
};
|
|
36430
36447
|
|
|
@@ -36455,7 +36472,7 @@ function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
|
|
|
36455
36472
|
if (key !== 'ref') {
|
|
36456
36473
|
const val2 = object2[key];
|
|
36457
36474
|
if ((isDateObject(val1) && isDateObject(val2)) ||
|
|
36458
|
-
(isObject$
|
|
36475
|
+
(isObject$2(val1) && isObject$2(val2)) ||
|
|
36459
36476
|
(Array.isArray(val1) && Array.isArray(val2))
|
|
36460
36477
|
? !deepEqual(val1, val2, _internal_visited)
|
|
36461
36478
|
: val1 !== val2) {
|
|
@@ -36750,6 +36767,1802 @@ function useController(props) {
|
|
|
36750
36767
|
*/
|
|
36751
36768
|
const Controller = (props) => props.render(useController(props));
|
|
36752
36769
|
|
|
36770
|
+
var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
|
|
36771
|
+
? {
|
|
36772
|
+
...errors[name],
|
|
36773
|
+
types: {
|
|
36774
|
+
...(errors[name] && errors[name].types ? errors[name].types : {}),
|
|
36775
|
+
[type]: message || true,
|
|
36776
|
+
},
|
|
36777
|
+
}
|
|
36778
|
+
: {};
|
|
36779
|
+
|
|
36780
|
+
var convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);
|
|
36781
|
+
|
|
36782
|
+
var createSubject = () => {
|
|
36783
|
+
let _observers = [];
|
|
36784
|
+
const next = (value) => {
|
|
36785
|
+
for (const observer of _observers) {
|
|
36786
|
+
observer.next && observer.next(value);
|
|
36787
|
+
}
|
|
36788
|
+
};
|
|
36789
|
+
const subscribe = (observer) => {
|
|
36790
|
+
_observers.push(observer);
|
|
36791
|
+
return {
|
|
36792
|
+
unsubscribe: () => {
|
|
36793
|
+
_observers = _observers.filter((o) => o !== observer);
|
|
36794
|
+
},
|
|
36795
|
+
};
|
|
36796
|
+
};
|
|
36797
|
+
const unsubscribe = () => {
|
|
36798
|
+
_observers = [];
|
|
36799
|
+
};
|
|
36800
|
+
return {
|
|
36801
|
+
get observers() {
|
|
36802
|
+
return _observers;
|
|
36803
|
+
},
|
|
36804
|
+
next,
|
|
36805
|
+
subscribe,
|
|
36806
|
+
unsubscribe,
|
|
36807
|
+
};
|
|
36808
|
+
};
|
|
36809
|
+
|
|
36810
|
+
function extractFormValues(fieldsState, formValues) {
|
|
36811
|
+
const values = {};
|
|
36812
|
+
for (const key in fieldsState) {
|
|
36813
|
+
if (fieldsState.hasOwnProperty(key)) {
|
|
36814
|
+
const fieldState = fieldsState[key];
|
|
36815
|
+
const fieldValue = formValues[key];
|
|
36816
|
+
if (fieldState && isObject$2(fieldState) && fieldValue) {
|
|
36817
|
+
const nestedFieldsState = extractFormValues(fieldState, fieldValue);
|
|
36818
|
+
if (isObject$2(nestedFieldsState)) {
|
|
36819
|
+
values[key] = nestedFieldsState;
|
|
36820
|
+
}
|
|
36821
|
+
}
|
|
36822
|
+
else if (fieldsState[key]) {
|
|
36823
|
+
values[key] = fieldValue;
|
|
36824
|
+
}
|
|
36825
|
+
}
|
|
36826
|
+
}
|
|
36827
|
+
return values;
|
|
36828
|
+
}
|
|
36829
|
+
|
|
36830
|
+
var isEmptyObject$1 = (value) => isObject$2(value) && !Object.keys(value).length;
|
|
36831
|
+
|
|
36832
|
+
var isFileInput = (element) => element.type === 'file';
|
|
36833
|
+
|
|
36834
|
+
var isFunction$2 = (value) => typeof value === 'function';
|
|
36835
|
+
|
|
36836
|
+
var isHTMLElement$1 = (value) => {
|
|
36837
|
+
if (!isWeb) {
|
|
36838
|
+
return false;
|
|
36839
|
+
}
|
|
36840
|
+
const owner = value ? value.ownerDocument : 0;
|
|
36841
|
+
return (value instanceof
|
|
36842
|
+
(owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement));
|
|
36843
|
+
};
|
|
36844
|
+
|
|
36845
|
+
var isMultipleSelect = (element) => element.type === `select-multiple`;
|
|
36846
|
+
|
|
36847
|
+
var isRadioInput = (element) => element.type === 'radio';
|
|
36848
|
+
|
|
36849
|
+
var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
|
|
36850
|
+
|
|
36851
|
+
var live = (ref) => isHTMLElement$1(ref) && ref.isConnected;
|
|
36852
|
+
|
|
36853
|
+
function baseGet(object, updatePath) {
|
|
36854
|
+
const length = updatePath.slice(0, -1).length;
|
|
36855
|
+
let index = 0;
|
|
36856
|
+
while (index < length) {
|
|
36857
|
+
object = isUndefined$1(object) ? index++ : object[updatePath[index++]];
|
|
36858
|
+
}
|
|
36859
|
+
return object;
|
|
36860
|
+
}
|
|
36861
|
+
function isEmptyArray(obj) {
|
|
36862
|
+
for (const key in obj) {
|
|
36863
|
+
if (obj.hasOwnProperty(key) && !isUndefined$1(obj[key])) {
|
|
36864
|
+
return false;
|
|
36865
|
+
}
|
|
36866
|
+
}
|
|
36867
|
+
return true;
|
|
36868
|
+
}
|
|
36869
|
+
function unset(object, path) {
|
|
36870
|
+
const paths = Array.isArray(path)
|
|
36871
|
+
? path
|
|
36872
|
+
: isKey(path)
|
|
36873
|
+
? [path]
|
|
36874
|
+
: stringToPath(path);
|
|
36875
|
+
const childObject = paths.length === 1 ? object : baseGet(object, paths);
|
|
36876
|
+
const index = paths.length - 1;
|
|
36877
|
+
const key = paths[index];
|
|
36878
|
+
if (childObject) {
|
|
36879
|
+
delete childObject[key];
|
|
36880
|
+
}
|
|
36881
|
+
if (index !== 0 &&
|
|
36882
|
+
((isObject$2(childObject) && isEmptyObject$1(childObject)) ||
|
|
36883
|
+
(Array.isArray(childObject) && isEmptyArray(childObject)))) {
|
|
36884
|
+
unset(object, paths.slice(0, -1));
|
|
36885
|
+
}
|
|
36886
|
+
return object;
|
|
36887
|
+
}
|
|
36888
|
+
|
|
36889
|
+
var objectHasFunction = (data) => {
|
|
36890
|
+
for (const key in data) {
|
|
36891
|
+
if (isFunction$2(data[key])) {
|
|
36892
|
+
return true;
|
|
36893
|
+
}
|
|
36894
|
+
}
|
|
36895
|
+
return false;
|
|
36896
|
+
};
|
|
36897
|
+
|
|
36898
|
+
function isTraversable(value) {
|
|
36899
|
+
return Array.isArray(value) || (isObject$2(value) && !objectHasFunction(value));
|
|
36900
|
+
}
|
|
36901
|
+
function markFieldsDirty(data, fields = {}) {
|
|
36902
|
+
for (const key in data) {
|
|
36903
|
+
if (isTraversable(data[key])) {
|
|
36904
|
+
fields[key] = Array.isArray(data[key]) ? [] : {};
|
|
36905
|
+
markFieldsDirty(data[key], fields[key]);
|
|
36906
|
+
}
|
|
36907
|
+
else if (!isUndefined$1(data[key])) {
|
|
36908
|
+
fields[key] = true;
|
|
36909
|
+
}
|
|
36910
|
+
}
|
|
36911
|
+
return fields;
|
|
36912
|
+
}
|
|
36913
|
+
function getDirtyFields(data, formValues, dirtyFieldsFromValues) {
|
|
36914
|
+
if (!dirtyFieldsFromValues) {
|
|
36915
|
+
dirtyFieldsFromValues = markFieldsDirty(formValues);
|
|
36916
|
+
}
|
|
36917
|
+
for (const key in data) {
|
|
36918
|
+
if (isTraversable(data[key])) {
|
|
36919
|
+
if (isUndefined$1(formValues) || isPrimitive(dirtyFieldsFromValues[key])) {
|
|
36920
|
+
dirtyFieldsFromValues[key] = markFieldsDirty(data[key], Array.isArray(data[key]) ? [] : {});
|
|
36921
|
+
}
|
|
36922
|
+
else {
|
|
36923
|
+
getDirtyFields(data[key], isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
|
|
36924
|
+
}
|
|
36925
|
+
}
|
|
36926
|
+
else {
|
|
36927
|
+
dirtyFieldsFromValues[key] = !deepEqual(data[key], formValues[key]);
|
|
36928
|
+
}
|
|
36929
|
+
}
|
|
36930
|
+
return dirtyFieldsFromValues;
|
|
36931
|
+
}
|
|
36932
|
+
|
|
36933
|
+
const defaultResult = {
|
|
36934
|
+
value: false,
|
|
36935
|
+
isValid: false,
|
|
36936
|
+
};
|
|
36937
|
+
const validResult = { value: true, isValid: true };
|
|
36938
|
+
var getCheckboxValue = (options) => {
|
|
36939
|
+
if (Array.isArray(options)) {
|
|
36940
|
+
if (options.length > 1) {
|
|
36941
|
+
const values = options
|
|
36942
|
+
.filter((option) => option && option.checked && !option.disabled)
|
|
36943
|
+
.map((option) => option.value);
|
|
36944
|
+
return { value: values, isValid: !!values.length };
|
|
36945
|
+
}
|
|
36946
|
+
return options[0].checked && !options[0].disabled
|
|
36947
|
+
? // @ts-expect-error expected to work in the browser
|
|
36948
|
+
options[0].attributes && !isUndefined$1(options[0].attributes.value)
|
|
36949
|
+
? isUndefined$1(options[0].value) || options[0].value === ''
|
|
36950
|
+
? validResult
|
|
36951
|
+
: { value: options[0].value, isValid: true }
|
|
36952
|
+
: validResult
|
|
36953
|
+
: defaultResult;
|
|
36954
|
+
}
|
|
36955
|
+
return defaultResult;
|
|
36956
|
+
};
|
|
36957
|
+
|
|
36958
|
+
var getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined$1(value)
|
|
36959
|
+
? value
|
|
36960
|
+
: valueAsNumber
|
|
36961
|
+
? value === ''
|
|
36962
|
+
? NaN
|
|
36963
|
+
: value
|
|
36964
|
+
? +value
|
|
36965
|
+
: value
|
|
36966
|
+
: valueAsDate && isString$1(value)
|
|
36967
|
+
? new Date(value)
|
|
36968
|
+
: setValueAs
|
|
36969
|
+
? setValueAs(value)
|
|
36970
|
+
: value;
|
|
36971
|
+
|
|
36972
|
+
const defaultReturn = {
|
|
36973
|
+
isValid: false,
|
|
36974
|
+
value: null,
|
|
36975
|
+
};
|
|
36976
|
+
var getRadioValue = (options) => Array.isArray(options)
|
|
36977
|
+
? options.reduce((previous, option) => option && option.checked && !option.disabled
|
|
36978
|
+
? {
|
|
36979
|
+
isValid: true,
|
|
36980
|
+
value: option.value,
|
|
36981
|
+
}
|
|
36982
|
+
: previous, defaultReturn)
|
|
36983
|
+
: defaultReturn;
|
|
36984
|
+
|
|
36985
|
+
function getFieldValue(_f) {
|
|
36986
|
+
const ref = _f.ref;
|
|
36987
|
+
if (isFileInput(ref)) {
|
|
36988
|
+
return ref.files;
|
|
36989
|
+
}
|
|
36990
|
+
if (isRadioInput(ref)) {
|
|
36991
|
+
return getRadioValue(_f.refs).value;
|
|
36992
|
+
}
|
|
36993
|
+
if (isMultipleSelect(ref)) {
|
|
36994
|
+
return [...ref.selectedOptions].map(({ value }) => value);
|
|
36995
|
+
}
|
|
36996
|
+
if (isCheckBoxInput(ref)) {
|
|
36997
|
+
return getCheckboxValue(_f.refs).value;
|
|
36998
|
+
}
|
|
36999
|
+
return getFieldValueAs(isUndefined$1(ref.value) ? _f.ref.value : ref.value, _f);
|
|
37000
|
+
}
|
|
37001
|
+
|
|
37002
|
+
var getResolverOptions = (fieldsNames, _fields, criteriaMode, shouldUseNativeValidation) => {
|
|
37003
|
+
const fields = {};
|
|
37004
|
+
for (const name of fieldsNames) {
|
|
37005
|
+
const field = get(_fields, name);
|
|
37006
|
+
field && set(fields, name, field._f);
|
|
37007
|
+
}
|
|
37008
|
+
return {
|
|
37009
|
+
criteriaMode,
|
|
37010
|
+
names: [...fieldsNames],
|
|
37011
|
+
fields,
|
|
37012
|
+
shouldUseNativeValidation,
|
|
37013
|
+
};
|
|
37014
|
+
};
|
|
37015
|
+
|
|
37016
|
+
var isRegex = (value) => value instanceof RegExp;
|
|
37017
|
+
|
|
37018
|
+
var getRuleValue = (rule) => isUndefined$1(rule)
|
|
37019
|
+
? rule
|
|
37020
|
+
: isRegex(rule)
|
|
37021
|
+
? rule.source
|
|
37022
|
+
: isObject$2(rule)
|
|
37023
|
+
? isRegex(rule.value)
|
|
37024
|
+
? rule.value.source
|
|
37025
|
+
: rule.value
|
|
37026
|
+
: rule;
|
|
37027
|
+
|
|
37028
|
+
var getValidationModes = (mode) => ({
|
|
37029
|
+
isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,
|
|
37030
|
+
isOnBlur: mode === VALIDATION_MODE.onBlur,
|
|
37031
|
+
isOnChange: mode === VALIDATION_MODE.onChange,
|
|
37032
|
+
isOnAll: mode === VALIDATION_MODE.all,
|
|
37033
|
+
isOnTouch: mode === VALIDATION_MODE.onTouched,
|
|
37034
|
+
});
|
|
37035
|
+
|
|
37036
|
+
const ASYNC_FUNCTION = 'AsyncFunction';
|
|
37037
|
+
var hasPromiseValidation = (fieldReference) => !!fieldReference &&
|
|
37038
|
+
!!fieldReference.validate &&
|
|
37039
|
+
!!((isFunction$2(fieldReference.validate) &&
|
|
37040
|
+
fieldReference.validate.constructor.name === ASYNC_FUNCTION) ||
|
|
37041
|
+
(isObject$2(fieldReference.validate) &&
|
|
37042
|
+
Object.values(fieldReference.validate).find((validateFunction) => validateFunction.constructor.name === ASYNC_FUNCTION)));
|
|
37043
|
+
|
|
37044
|
+
var hasValidation = (options) => options.mount &&
|
|
37045
|
+
(options.required ||
|
|
37046
|
+
options.min ||
|
|
37047
|
+
options.max ||
|
|
37048
|
+
options.maxLength ||
|
|
37049
|
+
options.minLength ||
|
|
37050
|
+
options.pattern ||
|
|
37051
|
+
options.validate);
|
|
37052
|
+
|
|
37053
|
+
var isWatched = (name, _names, isBlurEvent) => !isBlurEvent &&
|
|
37054
|
+
(_names.watchAll ||
|
|
37055
|
+
_names.watch.has(name) ||
|
|
37056
|
+
[..._names.watch].some((watchName) => name.startsWith(watchName) &&
|
|
37057
|
+
/^\.\w+/.test(name.slice(watchName.length))));
|
|
37058
|
+
|
|
37059
|
+
const iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {
|
|
37060
|
+
for (const key of fieldsNames || Object.keys(fields)) {
|
|
37061
|
+
const field = get(fields, key);
|
|
37062
|
+
if (field) {
|
|
37063
|
+
const { _f, ...currentField } = field;
|
|
37064
|
+
if (_f) {
|
|
37065
|
+
if (_f.refs && _f.refs[0] && action(_f.refs[0], key) && !abortEarly) {
|
|
37066
|
+
return true;
|
|
37067
|
+
}
|
|
37068
|
+
else if (_f.ref && action(_f.ref, _f.name) && !abortEarly) {
|
|
37069
|
+
return true;
|
|
37070
|
+
}
|
|
37071
|
+
else {
|
|
37072
|
+
if (iterateFieldsByAction(currentField, action)) {
|
|
37073
|
+
break;
|
|
37074
|
+
}
|
|
37075
|
+
}
|
|
37076
|
+
}
|
|
37077
|
+
else if (isObject$2(currentField)) {
|
|
37078
|
+
if (iterateFieldsByAction(currentField, action)) {
|
|
37079
|
+
break;
|
|
37080
|
+
}
|
|
37081
|
+
}
|
|
37082
|
+
}
|
|
37083
|
+
}
|
|
37084
|
+
return;
|
|
37085
|
+
};
|
|
37086
|
+
|
|
37087
|
+
function schemaErrorLookup(errors, _fields, name) {
|
|
37088
|
+
const error = get(errors, name);
|
|
37089
|
+
if (error || isKey(name)) {
|
|
37090
|
+
return {
|
|
37091
|
+
error,
|
|
37092
|
+
name,
|
|
37093
|
+
};
|
|
37094
|
+
}
|
|
37095
|
+
const names = name.split('.');
|
|
37096
|
+
while (names.length) {
|
|
37097
|
+
const fieldName = names.join('.');
|
|
37098
|
+
const field = get(_fields, fieldName);
|
|
37099
|
+
const foundError = get(errors, fieldName);
|
|
37100
|
+
if (field && !Array.isArray(field) && name !== fieldName) {
|
|
37101
|
+
return { name };
|
|
37102
|
+
}
|
|
37103
|
+
if (foundError && foundError.type) {
|
|
37104
|
+
return {
|
|
37105
|
+
name: fieldName,
|
|
37106
|
+
error: foundError,
|
|
37107
|
+
};
|
|
37108
|
+
}
|
|
37109
|
+
if (foundError && foundError.root && foundError.root.type) {
|
|
37110
|
+
return {
|
|
37111
|
+
name: `${fieldName}.root`,
|
|
37112
|
+
error: foundError.root,
|
|
37113
|
+
};
|
|
37114
|
+
}
|
|
37115
|
+
names.pop();
|
|
37116
|
+
}
|
|
37117
|
+
return {
|
|
37118
|
+
name,
|
|
37119
|
+
};
|
|
37120
|
+
}
|
|
37121
|
+
|
|
37122
|
+
var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
|
|
37123
|
+
updateFormState(formStateData);
|
|
37124
|
+
const { name, ...formState } = formStateData;
|
|
37125
|
+
return (isEmptyObject$1(formState) ||
|
|
37126
|
+
Object.keys(formState).length >= Object.keys(_proxyFormState).length ||
|
|
37127
|
+
Object.keys(formState).find((key) => _proxyFormState[key] ===
|
|
37128
|
+
(!isRoot || VALIDATION_MODE.all)));
|
|
37129
|
+
};
|
|
37130
|
+
|
|
37131
|
+
var shouldSubscribeByName = (name, signalName, exact) => !name ||
|
|
37132
|
+
!signalName ||
|
|
37133
|
+
name === signalName ||
|
|
37134
|
+
convertToArrayPayload(name).some((currentName) => currentName &&
|
|
37135
|
+
(exact
|
|
37136
|
+
? currentName === signalName
|
|
37137
|
+
: currentName.startsWith(signalName) ||
|
|
37138
|
+
signalName.startsWith(currentName)));
|
|
37139
|
+
|
|
37140
|
+
var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode) => {
|
|
37141
|
+
if (mode.isOnAll) {
|
|
37142
|
+
return false;
|
|
37143
|
+
}
|
|
37144
|
+
else if (!isSubmitted && mode.isOnTouch) {
|
|
37145
|
+
return !(isTouched || isBlurEvent);
|
|
37146
|
+
}
|
|
37147
|
+
else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {
|
|
37148
|
+
return !isBlurEvent;
|
|
37149
|
+
}
|
|
37150
|
+
else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {
|
|
37151
|
+
return isBlurEvent;
|
|
37152
|
+
}
|
|
37153
|
+
return true;
|
|
37154
|
+
};
|
|
37155
|
+
|
|
37156
|
+
var unsetEmptyArray = (ref, name) => !compact(get(ref, name)).length && unset(ref, name);
|
|
37157
|
+
|
|
37158
|
+
var updateFieldArrayRootError = (errors, error, name) => {
|
|
37159
|
+
const fieldArrayErrors = convertToArrayPayload(get(errors, name));
|
|
37160
|
+
set(fieldArrayErrors, 'root', error[name]);
|
|
37161
|
+
set(errors, name, fieldArrayErrors);
|
|
37162
|
+
return errors;
|
|
37163
|
+
};
|
|
37164
|
+
|
|
37165
|
+
function getValidateError(result, ref, type = 'validate') {
|
|
37166
|
+
if (isString$1(result) ||
|
|
37167
|
+
(Array.isArray(result) && result.every(isString$1)) ||
|
|
37168
|
+
(isBoolean$1(result) && !result)) {
|
|
37169
|
+
return {
|
|
37170
|
+
type,
|
|
37171
|
+
message: isString$1(result) ? result : '',
|
|
37172
|
+
ref,
|
|
37173
|
+
};
|
|
37174
|
+
}
|
|
37175
|
+
}
|
|
37176
|
+
|
|
37177
|
+
var getValueAndMessage = (validationData) => isObject$2(validationData) && !isRegex(validationData)
|
|
37178
|
+
? validationData
|
|
37179
|
+
: {
|
|
37180
|
+
value: validationData,
|
|
37181
|
+
message: '',
|
|
37182
|
+
};
|
|
37183
|
+
|
|
37184
|
+
var validateField = async (field, disabledFieldNames, formValues, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {
|
|
37185
|
+
const { ref, refs, required, maxLength, minLength, min, max, pattern, validate, name, valueAsNumber, mount, } = field._f;
|
|
37186
|
+
const inputValue = get(formValues, name);
|
|
37187
|
+
if (!mount || disabledFieldNames.has(name)) {
|
|
37188
|
+
return {};
|
|
37189
|
+
}
|
|
37190
|
+
const inputRef = refs ? refs[0] : ref;
|
|
37191
|
+
const setCustomValidity = (message) => {
|
|
37192
|
+
if (shouldUseNativeValidation && inputRef.reportValidity) {
|
|
37193
|
+
inputRef.setCustomValidity(isBoolean$1(message) ? '' : message || '');
|
|
37194
|
+
inputRef.reportValidity();
|
|
37195
|
+
}
|
|
37196
|
+
};
|
|
37197
|
+
const error = {};
|
|
37198
|
+
const isRadio = isRadioInput(ref);
|
|
37199
|
+
const isCheckBox = isCheckBoxInput(ref);
|
|
37200
|
+
const isRadioOrCheckbox = isRadio || isCheckBox;
|
|
37201
|
+
const isEmpty = ((valueAsNumber || isFileInput(ref)) &&
|
|
37202
|
+
isUndefined$1(ref.value) &&
|
|
37203
|
+
isUndefined$1(inputValue)) ||
|
|
37204
|
+
(isHTMLElement$1(ref) && ref.value === '') ||
|
|
37205
|
+
inputValue === '' ||
|
|
37206
|
+
(Array.isArray(inputValue) && !inputValue.length);
|
|
37207
|
+
const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
|
|
37208
|
+
const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {
|
|
37209
|
+
const message = exceedMax ? maxLengthMessage : minLengthMessage;
|
|
37210
|
+
error[name] = {
|
|
37211
|
+
type: exceedMax ? maxType : minType,
|
|
37212
|
+
message,
|
|
37213
|
+
ref,
|
|
37214
|
+
...appendErrorsCurry(exceedMax ? maxType : minType, message),
|
|
37215
|
+
};
|
|
37216
|
+
};
|
|
37217
|
+
if (isFieldArray
|
|
37218
|
+
? !Array.isArray(inputValue) || !inputValue.length
|
|
37219
|
+
: required &&
|
|
37220
|
+
((!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue))) ||
|
|
37221
|
+
(isBoolean$1(inputValue) && !inputValue) ||
|
|
37222
|
+
(isCheckBox && !getCheckboxValue(refs).isValid) ||
|
|
37223
|
+
(isRadio && !getRadioValue(refs).isValid))) {
|
|
37224
|
+
const { value, message } = isString$1(required)
|
|
37225
|
+
? { value: !!required, message: required }
|
|
37226
|
+
: getValueAndMessage(required);
|
|
37227
|
+
if (value) {
|
|
37228
|
+
error[name] = {
|
|
37229
|
+
type: INPUT_VALIDATION_RULES.required,
|
|
37230
|
+
message,
|
|
37231
|
+
ref: inputRef,
|
|
37232
|
+
...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message),
|
|
37233
|
+
};
|
|
37234
|
+
if (!validateAllFieldCriteria) {
|
|
37235
|
+
setCustomValidity(message);
|
|
37236
|
+
return error;
|
|
37237
|
+
}
|
|
37238
|
+
}
|
|
37239
|
+
}
|
|
37240
|
+
if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {
|
|
37241
|
+
let exceedMax;
|
|
37242
|
+
let exceedMin;
|
|
37243
|
+
const maxOutput = getValueAndMessage(max);
|
|
37244
|
+
const minOutput = getValueAndMessage(min);
|
|
37245
|
+
if (!isNullOrUndefined(inputValue) && !isNaN(inputValue)) {
|
|
37246
|
+
const valueNumber = ref.valueAsNumber ||
|
|
37247
|
+
(inputValue ? +inputValue : inputValue);
|
|
37248
|
+
if (!isNullOrUndefined(maxOutput.value)) {
|
|
37249
|
+
exceedMax = valueNumber > maxOutput.value;
|
|
37250
|
+
}
|
|
37251
|
+
if (!isNullOrUndefined(minOutput.value)) {
|
|
37252
|
+
exceedMin = valueNumber < minOutput.value;
|
|
37253
|
+
}
|
|
37254
|
+
}
|
|
37255
|
+
else {
|
|
37256
|
+
const valueDate = ref.valueAsDate || new Date(inputValue);
|
|
37257
|
+
const convertTimeToDate = (time) => new Date(new Date().toDateString() + ' ' + time);
|
|
37258
|
+
const isTime = ref.type == 'time';
|
|
37259
|
+
const isWeek = ref.type == 'week';
|
|
37260
|
+
if (isString$1(maxOutput.value) && inputValue) {
|
|
37261
|
+
exceedMax = isTime
|
|
37262
|
+
? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value)
|
|
37263
|
+
: isWeek
|
|
37264
|
+
? inputValue > maxOutput.value
|
|
37265
|
+
: valueDate > new Date(maxOutput.value);
|
|
37266
|
+
}
|
|
37267
|
+
if (isString$1(minOutput.value) && inputValue) {
|
|
37268
|
+
exceedMin = isTime
|
|
37269
|
+
? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value)
|
|
37270
|
+
: isWeek
|
|
37271
|
+
? inputValue < minOutput.value
|
|
37272
|
+
: valueDate < new Date(minOutput.value);
|
|
37273
|
+
}
|
|
37274
|
+
}
|
|
37275
|
+
if (exceedMax || exceedMin) {
|
|
37276
|
+
getMinMaxMessage(!!exceedMax, maxOutput.message, minOutput.message, INPUT_VALIDATION_RULES.max, INPUT_VALIDATION_RULES.min);
|
|
37277
|
+
if (!validateAllFieldCriteria) {
|
|
37278
|
+
setCustomValidity(error[name].message);
|
|
37279
|
+
return error;
|
|
37280
|
+
}
|
|
37281
|
+
}
|
|
37282
|
+
}
|
|
37283
|
+
if ((maxLength || minLength) &&
|
|
37284
|
+
!isEmpty &&
|
|
37285
|
+
(isString$1(inputValue) || (isFieldArray && Array.isArray(inputValue)))) {
|
|
37286
|
+
const maxLengthOutput = getValueAndMessage(maxLength);
|
|
37287
|
+
const minLengthOutput = getValueAndMessage(minLength);
|
|
37288
|
+
const exceedMax = !isNullOrUndefined(maxLengthOutput.value) &&
|
|
37289
|
+
inputValue.length > +maxLengthOutput.value;
|
|
37290
|
+
const exceedMin = !isNullOrUndefined(minLengthOutput.value) &&
|
|
37291
|
+
inputValue.length < +minLengthOutput.value;
|
|
37292
|
+
if (exceedMax || exceedMin) {
|
|
37293
|
+
getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);
|
|
37294
|
+
if (!validateAllFieldCriteria) {
|
|
37295
|
+
setCustomValidity(error[name].message);
|
|
37296
|
+
return error;
|
|
37297
|
+
}
|
|
37298
|
+
}
|
|
37299
|
+
}
|
|
37300
|
+
if (pattern && !isEmpty && isString$1(inputValue)) {
|
|
37301
|
+
const { value: patternValue, message } = getValueAndMessage(pattern);
|
|
37302
|
+
if (isRegex(patternValue) && !inputValue.match(patternValue)) {
|
|
37303
|
+
error[name] = {
|
|
37304
|
+
type: INPUT_VALIDATION_RULES.pattern,
|
|
37305
|
+
message,
|
|
37306
|
+
ref,
|
|
37307
|
+
...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message),
|
|
37308
|
+
};
|
|
37309
|
+
if (!validateAllFieldCriteria) {
|
|
37310
|
+
setCustomValidity(message);
|
|
37311
|
+
return error;
|
|
37312
|
+
}
|
|
37313
|
+
}
|
|
37314
|
+
}
|
|
37315
|
+
if (validate) {
|
|
37316
|
+
if (isFunction$2(validate)) {
|
|
37317
|
+
const result = await validate(inputValue, formValues);
|
|
37318
|
+
const validateError = getValidateError(result, inputRef);
|
|
37319
|
+
if (validateError) {
|
|
37320
|
+
error[name] = {
|
|
37321
|
+
...validateError,
|
|
37322
|
+
...appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message),
|
|
37323
|
+
};
|
|
37324
|
+
if (!validateAllFieldCriteria) {
|
|
37325
|
+
setCustomValidity(validateError.message);
|
|
37326
|
+
return error;
|
|
37327
|
+
}
|
|
37328
|
+
}
|
|
37329
|
+
}
|
|
37330
|
+
else if (isObject$2(validate)) {
|
|
37331
|
+
let validationResult = {};
|
|
37332
|
+
for (const key in validate) {
|
|
37333
|
+
if (!isEmptyObject$1(validationResult) && !validateAllFieldCriteria) {
|
|
37334
|
+
break;
|
|
37335
|
+
}
|
|
37336
|
+
const validateError = getValidateError(await validate[key](inputValue, formValues), inputRef, key);
|
|
37337
|
+
if (validateError) {
|
|
37338
|
+
validationResult = {
|
|
37339
|
+
...validateError,
|
|
37340
|
+
...appendErrorsCurry(key, validateError.message),
|
|
37341
|
+
};
|
|
37342
|
+
setCustomValidity(validateError.message);
|
|
37343
|
+
if (validateAllFieldCriteria) {
|
|
37344
|
+
error[name] = validationResult;
|
|
37345
|
+
}
|
|
37346
|
+
}
|
|
37347
|
+
}
|
|
37348
|
+
if (!isEmptyObject$1(validationResult)) {
|
|
37349
|
+
error[name] = {
|
|
37350
|
+
ref: inputRef,
|
|
37351
|
+
...validationResult,
|
|
37352
|
+
};
|
|
37353
|
+
if (!validateAllFieldCriteria) {
|
|
37354
|
+
return error;
|
|
37355
|
+
}
|
|
37356
|
+
}
|
|
37357
|
+
}
|
|
37358
|
+
}
|
|
37359
|
+
setCustomValidity(true);
|
|
37360
|
+
return error;
|
|
37361
|
+
};
|
|
37362
|
+
|
|
37363
|
+
const defaultOptions$2 = {
|
|
37364
|
+
mode: VALIDATION_MODE.onSubmit,
|
|
37365
|
+
reValidateMode: VALIDATION_MODE.onChange,
|
|
37366
|
+
shouldFocusError: true,
|
|
37367
|
+
};
|
|
37368
|
+
function createFormControl(props = {}) {
|
|
37369
|
+
let _options = {
|
|
37370
|
+
...defaultOptions$2,
|
|
37371
|
+
...props,
|
|
37372
|
+
};
|
|
37373
|
+
let _formState = {
|
|
37374
|
+
submitCount: 0,
|
|
37375
|
+
isDirty: false,
|
|
37376
|
+
isReady: false,
|
|
37377
|
+
isLoading: isFunction$2(_options.defaultValues),
|
|
37378
|
+
isValidating: false,
|
|
37379
|
+
isSubmitted: false,
|
|
37380
|
+
isSubmitting: false,
|
|
37381
|
+
isSubmitSuccessful: false,
|
|
37382
|
+
isValid: false,
|
|
37383
|
+
touchedFields: {},
|
|
37384
|
+
dirtyFields: {},
|
|
37385
|
+
validatingFields: {},
|
|
37386
|
+
errors: _options.errors || {},
|
|
37387
|
+
disabled: _options.disabled || false,
|
|
37388
|
+
};
|
|
37389
|
+
let _fields = {};
|
|
37390
|
+
let _defaultValues = isObject$2(_options.defaultValues) || isObject$2(_options.values)
|
|
37391
|
+
? cloneObject(_options.defaultValues || _options.values) || {}
|
|
37392
|
+
: {};
|
|
37393
|
+
let _formValues = _options.shouldUnregister
|
|
37394
|
+
? {}
|
|
37395
|
+
: cloneObject(_defaultValues);
|
|
37396
|
+
let _state = {
|
|
37397
|
+
action: false,
|
|
37398
|
+
mount: false,
|
|
37399
|
+
watch: false,
|
|
37400
|
+
};
|
|
37401
|
+
let _names = {
|
|
37402
|
+
mount: new Set(),
|
|
37403
|
+
disabled: new Set(),
|
|
37404
|
+
unMount: new Set(),
|
|
37405
|
+
array: new Set(),
|
|
37406
|
+
watch: new Set(),
|
|
37407
|
+
};
|
|
37408
|
+
let delayErrorCallback;
|
|
37409
|
+
let timer = 0;
|
|
37410
|
+
const _proxyFormState = {
|
|
37411
|
+
isDirty: false,
|
|
37412
|
+
dirtyFields: false,
|
|
37413
|
+
validatingFields: false,
|
|
37414
|
+
touchedFields: false,
|
|
37415
|
+
isValidating: false,
|
|
37416
|
+
isValid: false,
|
|
37417
|
+
errors: false,
|
|
37418
|
+
};
|
|
37419
|
+
let _proxySubscribeFormState = {
|
|
37420
|
+
..._proxyFormState,
|
|
37421
|
+
};
|
|
37422
|
+
const _subjects = {
|
|
37423
|
+
array: createSubject(),
|
|
37424
|
+
state: createSubject(),
|
|
37425
|
+
};
|
|
37426
|
+
const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
|
|
37427
|
+
const debounce = (callback) => (wait) => {
|
|
37428
|
+
clearTimeout(timer);
|
|
37429
|
+
timer = setTimeout(callback, wait);
|
|
37430
|
+
};
|
|
37431
|
+
const _setValid = async (shouldUpdateValid) => {
|
|
37432
|
+
if (!_options.disabled &&
|
|
37433
|
+
(_proxyFormState.isValid ||
|
|
37434
|
+
_proxySubscribeFormState.isValid ||
|
|
37435
|
+
shouldUpdateValid)) {
|
|
37436
|
+
const isValid = _options.resolver
|
|
37437
|
+
? isEmptyObject$1((await _runSchema()).errors)
|
|
37438
|
+
: await executeBuiltInValidation(_fields, true);
|
|
37439
|
+
if (isValid !== _formState.isValid) {
|
|
37440
|
+
_subjects.state.next({
|
|
37441
|
+
isValid,
|
|
37442
|
+
});
|
|
37443
|
+
}
|
|
37444
|
+
}
|
|
37445
|
+
};
|
|
37446
|
+
const _updateIsValidating = (names, isValidating) => {
|
|
37447
|
+
if (!_options.disabled &&
|
|
37448
|
+
(_proxyFormState.isValidating ||
|
|
37449
|
+
_proxyFormState.validatingFields ||
|
|
37450
|
+
_proxySubscribeFormState.isValidating ||
|
|
37451
|
+
_proxySubscribeFormState.validatingFields)) {
|
|
37452
|
+
(names || Array.from(_names.mount)).forEach((name) => {
|
|
37453
|
+
if (name) {
|
|
37454
|
+
isValidating
|
|
37455
|
+
? set(_formState.validatingFields, name, isValidating)
|
|
37456
|
+
: unset(_formState.validatingFields, name);
|
|
37457
|
+
}
|
|
37458
|
+
});
|
|
37459
|
+
_subjects.state.next({
|
|
37460
|
+
validatingFields: _formState.validatingFields,
|
|
37461
|
+
isValidating: !isEmptyObject$1(_formState.validatingFields),
|
|
37462
|
+
});
|
|
37463
|
+
}
|
|
37464
|
+
};
|
|
37465
|
+
const _setFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
|
|
37466
|
+
if (args && method && !_options.disabled) {
|
|
37467
|
+
_state.action = true;
|
|
37468
|
+
if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {
|
|
37469
|
+
const fieldValues = method(get(_fields, name), args.argA, args.argB);
|
|
37470
|
+
shouldSetValues && set(_fields, name, fieldValues);
|
|
37471
|
+
}
|
|
37472
|
+
if (shouldUpdateFieldsAndState &&
|
|
37473
|
+
Array.isArray(get(_formState.errors, name))) {
|
|
37474
|
+
const errors = method(get(_formState.errors, name), args.argA, args.argB);
|
|
37475
|
+
shouldSetValues && set(_formState.errors, name, errors);
|
|
37476
|
+
unsetEmptyArray(_formState.errors, name);
|
|
37477
|
+
}
|
|
37478
|
+
if ((_proxyFormState.touchedFields ||
|
|
37479
|
+
_proxySubscribeFormState.touchedFields) &&
|
|
37480
|
+
shouldUpdateFieldsAndState &&
|
|
37481
|
+
Array.isArray(get(_formState.touchedFields, name))) {
|
|
37482
|
+
const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);
|
|
37483
|
+
shouldSetValues && set(_formState.touchedFields, name, touchedFields);
|
|
37484
|
+
}
|
|
37485
|
+
if (_proxyFormState.dirtyFields || _proxySubscribeFormState.dirtyFields) {
|
|
37486
|
+
_formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);
|
|
37487
|
+
}
|
|
37488
|
+
_subjects.state.next({
|
|
37489
|
+
name,
|
|
37490
|
+
isDirty: _getDirty(name, values),
|
|
37491
|
+
dirtyFields: _formState.dirtyFields,
|
|
37492
|
+
errors: _formState.errors,
|
|
37493
|
+
isValid: _formState.isValid,
|
|
37494
|
+
});
|
|
37495
|
+
}
|
|
37496
|
+
else {
|
|
37497
|
+
set(_formValues, name, values);
|
|
37498
|
+
}
|
|
37499
|
+
};
|
|
37500
|
+
const updateErrors = (name, error) => {
|
|
37501
|
+
set(_formState.errors, name, error);
|
|
37502
|
+
_subjects.state.next({
|
|
37503
|
+
errors: _formState.errors,
|
|
37504
|
+
});
|
|
37505
|
+
};
|
|
37506
|
+
const _setErrors = (errors) => {
|
|
37507
|
+
_formState.errors = errors;
|
|
37508
|
+
_subjects.state.next({
|
|
37509
|
+
errors: _formState.errors,
|
|
37510
|
+
isValid: false,
|
|
37511
|
+
});
|
|
37512
|
+
};
|
|
37513
|
+
const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {
|
|
37514
|
+
const field = get(_fields, name);
|
|
37515
|
+
if (field) {
|
|
37516
|
+
const defaultValue = get(_formValues, name, isUndefined$1(value) ? get(_defaultValues, name) : value);
|
|
37517
|
+
isUndefined$1(defaultValue) ||
|
|
37518
|
+
(ref && ref.defaultChecked) ||
|
|
37519
|
+
shouldSkipSetValueAs
|
|
37520
|
+
? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f))
|
|
37521
|
+
: setFieldValue(name, defaultValue);
|
|
37522
|
+
_state.mount && _setValid();
|
|
37523
|
+
}
|
|
37524
|
+
};
|
|
37525
|
+
const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {
|
|
37526
|
+
let shouldUpdateField = false;
|
|
37527
|
+
let isPreviousDirty = false;
|
|
37528
|
+
const output = {
|
|
37529
|
+
name,
|
|
37530
|
+
};
|
|
37531
|
+
if (!_options.disabled) {
|
|
37532
|
+
if (!isBlurEvent || shouldDirty) {
|
|
37533
|
+
if (_proxyFormState.isDirty || _proxySubscribeFormState.isDirty) {
|
|
37534
|
+
isPreviousDirty = _formState.isDirty;
|
|
37535
|
+
_formState.isDirty = output.isDirty = _getDirty();
|
|
37536
|
+
shouldUpdateField = isPreviousDirty !== output.isDirty;
|
|
37537
|
+
}
|
|
37538
|
+
const isCurrentFieldPristine = deepEqual(get(_defaultValues, name), fieldValue);
|
|
37539
|
+
isPreviousDirty = !!get(_formState.dirtyFields, name);
|
|
37540
|
+
isCurrentFieldPristine
|
|
37541
|
+
? unset(_formState.dirtyFields, name)
|
|
37542
|
+
: set(_formState.dirtyFields, name, true);
|
|
37543
|
+
output.dirtyFields = _formState.dirtyFields;
|
|
37544
|
+
shouldUpdateField =
|
|
37545
|
+
shouldUpdateField ||
|
|
37546
|
+
((_proxyFormState.dirtyFields ||
|
|
37547
|
+
_proxySubscribeFormState.dirtyFields) &&
|
|
37548
|
+
isPreviousDirty !== !isCurrentFieldPristine);
|
|
37549
|
+
}
|
|
37550
|
+
if (isBlurEvent) {
|
|
37551
|
+
const isPreviousFieldTouched = get(_formState.touchedFields, name);
|
|
37552
|
+
if (!isPreviousFieldTouched) {
|
|
37553
|
+
set(_formState.touchedFields, name, isBlurEvent);
|
|
37554
|
+
output.touchedFields = _formState.touchedFields;
|
|
37555
|
+
shouldUpdateField =
|
|
37556
|
+
shouldUpdateField ||
|
|
37557
|
+
((_proxyFormState.touchedFields ||
|
|
37558
|
+
_proxySubscribeFormState.touchedFields) &&
|
|
37559
|
+
isPreviousFieldTouched !== isBlurEvent);
|
|
37560
|
+
}
|
|
37561
|
+
}
|
|
37562
|
+
shouldUpdateField && shouldRender && _subjects.state.next(output);
|
|
37563
|
+
}
|
|
37564
|
+
return shouldUpdateField ? output : {};
|
|
37565
|
+
};
|
|
37566
|
+
const shouldRenderByError = (name, isValid, error, fieldState) => {
|
|
37567
|
+
const previousFieldError = get(_formState.errors, name);
|
|
37568
|
+
const shouldUpdateValid = (_proxyFormState.isValid || _proxySubscribeFormState.isValid) &&
|
|
37569
|
+
isBoolean$1(isValid) &&
|
|
37570
|
+
_formState.isValid !== isValid;
|
|
37571
|
+
if (_options.delayError && error) {
|
|
37572
|
+
delayErrorCallback = debounce(() => updateErrors(name, error));
|
|
37573
|
+
delayErrorCallback(_options.delayError);
|
|
37574
|
+
}
|
|
37575
|
+
else {
|
|
37576
|
+
clearTimeout(timer);
|
|
37577
|
+
delayErrorCallback = null;
|
|
37578
|
+
error
|
|
37579
|
+
? set(_formState.errors, name, error)
|
|
37580
|
+
: unset(_formState.errors, name);
|
|
37581
|
+
}
|
|
37582
|
+
if ((error ? !deepEqual(previousFieldError, error) : previousFieldError) ||
|
|
37583
|
+
!isEmptyObject$1(fieldState) ||
|
|
37584
|
+
shouldUpdateValid) {
|
|
37585
|
+
const updatedFormState = {
|
|
37586
|
+
...fieldState,
|
|
37587
|
+
...(shouldUpdateValid && isBoolean$1(isValid) ? { isValid } : {}),
|
|
37588
|
+
errors: _formState.errors,
|
|
37589
|
+
name,
|
|
37590
|
+
};
|
|
37591
|
+
_formState = {
|
|
37592
|
+
..._formState,
|
|
37593
|
+
...updatedFormState,
|
|
37594
|
+
};
|
|
37595
|
+
_subjects.state.next(updatedFormState);
|
|
37596
|
+
}
|
|
37597
|
+
};
|
|
37598
|
+
const _runSchema = async (name) => {
|
|
37599
|
+
_updateIsValidating(name, true);
|
|
37600
|
+
const result = await _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
|
|
37601
|
+
_updateIsValidating(name);
|
|
37602
|
+
return result;
|
|
37603
|
+
};
|
|
37604
|
+
const executeSchemaAndUpdateState = async (names) => {
|
|
37605
|
+
const { errors } = await _runSchema(names);
|
|
37606
|
+
if (names) {
|
|
37607
|
+
for (const name of names) {
|
|
37608
|
+
const error = get(errors, name);
|
|
37609
|
+
error
|
|
37610
|
+
? set(_formState.errors, name, error)
|
|
37611
|
+
: unset(_formState.errors, name);
|
|
37612
|
+
}
|
|
37613
|
+
}
|
|
37614
|
+
else {
|
|
37615
|
+
_formState.errors = errors;
|
|
37616
|
+
}
|
|
37617
|
+
return errors;
|
|
37618
|
+
};
|
|
37619
|
+
const executeBuiltInValidation = async (fields, shouldOnlyCheckValid, context = {
|
|
37620
|
+
valid: true,
|
|
37621
|
+
}) => {
|
|
37622
|
+
for (const name in fields) {
|
|
37623
|
+
const field = fields[name];
|
|
37624
|
+
if (field) {
|
|
37625
|
+
const { _f, ...fieldValue } = field;
|
|
37626
|
+
if (_f) {
|
|
37627
|
+
const isFieldArrayRoot = _names.array.has(_f.name);
|
|
37628
|
+
const isPromiseFunction = field._f && hasPromiseValidation(field._f);
|
|
37629
|
+
if (isPromiseFunction && _proxyFormState.validatingFields) {
|
|
37630
|
+
_updateIsValidating([_f.name], true);
|
|
37631
|
+
}
|
|
37632
|
+
const fieldError = await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);
|
|
37633
|
+
if (isPromiseFunction && _proxyFormState.validatingFields) {
|
|
37634
|
+
_updateIsValidating([_f.name]);
|
|
37635
|
+
}
|
|
37636
|
+
if (fieldError[_f.name]) {
|
|
37637
|
+
context.valid = false;
|
|
37638
|
+
if (shouldOnlyCheckValid) {
|
|
37639
|
+
break;
|
|
37640
|
+
}
|
|
37641
|
+
}
|
|
37642
|
+
!shouldOnlyCheckValid &&
|
|
37643
|
+
(get(fieldError, _f.name)
|
|
37644
|
+
? isFieldArrayRoot
|
|
37645
|
+
? updateFieldArrayRootError(_formState.errors, fieldError, _f.name)
|
|
37646
|
+
: set(_formState.errors, _f.name, fieldError[_f.name])
|
|
37647
|
+
: unset(_formState.errors, _f.name));
|
|
37648
|
+
}
|
|
37649
|
+
!isEmptyObject$1(fieldValue) &&
|
|
37650
|
+
(await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));
|
|
37651
|
+
}
|
|
37652
|
+
}
|
|
37653
|
+
return context.valid;
|
|
37654
|
+
};
|
|
37655
|
+
const _removeUnmounted = () => {
|
|
37656
|
+
for (const name of _names.unMount) {
|
|
37657
|
+
const field = get(_fields, name);
|
|
37658
|
+
field &&
|
|
37659
|
+
(field._f.refs
|
|
37660
|
+
? field._f.refs.every((ref) => !live(ref))
|
|
37661
|
+
: !live(field._f.ref)) &&
|
|
37662
|
+
unregister(name);
|
|
37663
|
+
}
|
|
37664
|
+
_names.unMount = new Set();
|
|
37665
|
+
};
|
|
37666
|
+
const _getDirty = (name, data) => !_options.disabled &&
|
|
37667
|
+
(name && data && set(_formValues, name, data),
|
|
37668
|
+
!deepEqual(getValues(), _defaultValues));
|
|
37669
|
+
const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {
|
|
37670
|
+
...(_state.mount
|
|
37671
|
+
? _formValues
|
|
37672
|
+
: isUndefined$1(defaultValue)
|
|
37673
|
+
? _defaultValues
|
|
37674
|
+
: isString$1(names)
|
|
37675
|
+
? { [names]: defaultValue }
|
|
37676
|
+
: defaultValue),
|
|
37677
|
+
}, isGlobal, defaultValue);
|
|
37678
|
+
const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, _options.shouldUnregister ? get(_defaultValues, name, []) : []));
|
|
37679
|
+
const setFieldValue = (name, value, options = {}) => {
|
|
37680
|
+
const field = get(_fields, name);
|
|
37681
|
+
let fieldValue = value;
|
|
37682
|
+
if (field) {
|
|
37683
|
+
const fieldReference = field._f;
|
|
37684
|
+
if (fieldReference) {
|
|
37685
|
+
!fieldReference.disabled &&
|
|
37686
|
+
set(_formValues, name, getFieldValueAs(value, fieldReference));
|
|
37687
|
+
fieldValue =
|
|
37688
|
+
isHTMLElement$1(fieldReference.ref) && isNullOrUndefined(value)
|
|
37689
|
+
? ''
|
|
37690
|
+
: value;
|
|
37691
|
+
if (isMultipleSelect(fieldReference.ref)) {
|
|
37692
|
+
[...fieldReference.ref.options].forEach((optionRef) => (optionRef.selected = fieldValue.includes(optionRef.value)));
|
|
37693
|
+
}
|
|
37694
|
+
else if (fieldReference.refs) {
|
|
37695
|
+
if (isCheckBoxInput(fieldReference.ref)) {
|
|
37696
|
+
fieldReference.refs.forEach((checkboxRef) => {
|
|
37697
|
+
if (!checkboxRef.defaultChecked || !checkboxRef.disabled) {
|
|
37698
|
+
if (Array.isArray(fieldValue)) {
|
|
37699
|
+
checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
|
|
37700
|
+
}
|
|
37701
|
+
else {
|
|
37702
|
+
checkboxRef.checked =
|
|
37703
|
+
fieldValue === checkboxRef.value || !!fieldValue;
|
|
37704
|
+
}
|
|
37705
|
+
}
|
|
37706
|
+
});
|
|
37707
|
+
}
|
|
37708
|
+
else {
|
|
37709
|
+
fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
|
|
37710
|
+
}
|
|
37711
|
+
}
|
|
37712
|
+
else if (isFileInput(fieldReference.ref)) {
|
|
37713
|
+
fieldReference.ref.value = '';
|
|
37714
|
+
}
|
|
37715
|
+
else {
|
|
37716
|
+
fieldReference.ref.value = fieldValue;
|
|
37717
|
+
if (!fieldReference.ref.type) {
|
|
37718
|
+
_subjects.state.next({
|
|
37719
|
+
name,
|
|
37720
|
+
values: cloneObject(_formValues),
|
|
37721
|
+
});
|
|
37722
|
+
}
|
|
37723
|
+
}
|
|
37724
|
+
}
|
|
37725
|
+
}
|
|
37726
|
+
(options.shouldDirty || options.shouldTouch) &&
|
|
37727
|
+
updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);
|
|
37728
|
+
options.shouldValidate && trigger(name);
|
|
37729
|
+
};
|
|
37730
|
+
const setValues = (name, value, options) => {
|
|
37731
|
+
for (const fieldKey in value) {
|
|
37732
|
+
if (!value.hasOwnProperty(fieldKey)) {
|
|
37733
|
+
return;
|
|
37734
|
+
}
|
|
37735
|
+
const fieldValue = value[fieldKey];
|
|
37736
|
+
const fieldName = name + '.' + fieldKey;
|
|
37737
|
+
const field = get(_fields, fieldName);
|
|
37738
|
+
(_names.array.has(name) ||
|
|
37739
|
+
isObject$2(fieldValue) ||
|
|
37740
|
+
(field && !field._f)) &&
|
|
37741
|
+
!isDateObject(fieldValue)
|
|
37742
|
+
? setValues(fieldName, fieldValue, options)
|
|
37743
|
+
: setFieldValue(fieldName, fieldValue, options);
|
|
37744
|
+
}
|
|
37745
|
+
};
|
|
37746
|
+
const setValue = (name, value, options = {}) => {
|
|
37747
|
+
const field = get(_fields, name);
|
|
37748
|
+
const isFieldArray = _names.array.has(name);
|
|
37749
|
+
const cloneValue = cloneObject(value);
|
|
37750
|
+
set(_formValues, name, cloneValue);
|
|
37751
|
+
if (isFieldArray) {
|
|
37752
|
+
_subjects.array.next({
|
|
37753
|
+
name,
|
|
37754
|
+
values: cloneObject(_formValues),
|
|
37755
|
+
});
|
|
37756
|
+
if ((_proxyFormState.isDirty ||
|
|
37757
|
+
_proxyFormState.dirtyFields ||
|
|
37758
|
+
_proxySubscribeFormState.isDirty ||
|
|
37759
|
+
_proxySubscribeFormState.dirtyFields) &&
|
|
37760
|
+
options.shouldDirty) {
|
|
37761
|
+
_subjects.state.next({
|
|
37762
|
+
name,
|
|
37763
|
+
dirtyFields: getDirtyFields(_defaultValues, _formValues),
|
|
37764
|
+
isDirty: _getDirty(name, cloneValue),
|
|
37765
|
+
});
|
|
37766
|
+
}
|
|
37767
|
+
}
|
|
37768
|
+
else {
|
|
37769
|
+
field && !field._f && !isNullOrUndefined(cloneValue)
|
|
37770
|
+
? setValues(name, cloneValue, options)
|
|
37771
|
+
: setFieldValue(name, cloneValue, options);
|
|
37772
|
+
}
|
|
37773
|
+
isWatched(name, _names) && _subjects.state.next({ ..._formState, name });
|
|
37774
|
+
_subjects.state.next({
|
|
37775
|
+
name: _state.mount ? name : undefined,
|
|
37776
|
+
values: cloneObject(_formValues),
|
|
37777
|
+
});
|
|
37778
|
+
};
|
|
37779
|
+
const onChange = async (event) => {
|
|
37780
|
+
_state.mount = true;
|
|
37781
|
+
const target = event.target;
|
|
37782
|
+
let name = target.name;
|
|
37783
|
+
let isFieldValueUpdated = true;
|
|
37784
|
+
const field = get(_fields, name);
|
|
37785
|
+
const _updateIsFieldValueUpdated = (fieldValue) => {
|
|
37786
|
+
isFieldValueUpdated =
|
|
37787
|
+
Number.isNaN(fieldValue) ||
|
|
37788
|
+
(isDateObject(fieldValue) && isNaN(fieldValue.getTime())) ||
|
|
37789
|
+
deepEqual(fieldValue, get(_formValues, name, fieldValue));
|
|
37790
|
+
};
|
|
37791
|
+
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
37792
|
+
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
37793
|
+
if (field) {
|
|
37794
|
+
let error;
|
|
37795
|
+
let isValid;
|
|
37796
|
+
const fieldValue = target.type
|
|
37797
|
+
? getFieldValue(field._f)
|
|
37798
|
+
: getEventValue(event);
|
|
37799
|
+
const isBlurEvent = event.type === EVENTS.BLUR || event.type === EVENTS.FOCUS_OUT;
|
|
37800
|
+
const shouldSkipValidation = (!hasValidation(field._f) &&
|
|
37801
|
+
!_options.resolver &&
|
|
37802
|
+
!get(_formState.errors, name) &&
|
|
37803
|
+
!field._f.deps) ||
|
|
37804
|
+
skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit);
|
|
37805
|
+
const watched = isWatched(name, _names, isBlurEvent);
|
|
37806
|
+
set(_formValues, name, fieldValue);
|
|
37807
|
+
if (isBlurEvent) {
|
|
37808
|
+
if (!target || !target.readOnly) {
|
|
37809
|
+
field._f.onBlur && field._f.onBlur(event);
|
|
37810
|
+
delayErrorCallback && delayErrorCallback(0);
|
|
37811
|
+
}
|
|
37812
|
+
}
|
|
37813
|
+
else if (field._f.onChange) {
|
|
37814
|
+
field._f.onChange(event);
|
|
37815
|
+
}
|
|
37816
|
+
const fieldState = updateTouchAndDirty(name, fieldValue, isBlurEvent);
|
|
37817
|
+
const shouldRender = !isEmptyObject$1(fieldState) || watched;
|
|
37818
|
+
!isBlurEvent &&
|
|
37819
|
+
_subjects.state.next({
|
|
37820
|
+
name,
|
|
37821
|
+
type: event.type,
|
|
37822
|
+
values: cloneObject(_formValues),
|
|
37823
|
+
});
|
|
37824
|
+
if (shouldSkipValidation) {
|
|
37825
|
+
if (_proxyFormState.isValid || _proxySubscribeFormState.isValid) {
|
|
37826
|
+
if (_options.mode === 'onBlur') {
|
|
37827
|
+
if (isBlurEvent) {
|
|
37828
|
+
_setValid();
|
|
37829
|
+
}
|
|
37830
|
+
}
|
|
37831
|
+
else if (!isBlurEvent) {
|
|
37832
|
+
_setValid();
|
|
37833
|
+
}
|
|
37834
|
+
}
|
|
37835
|
+
return (shouldRender &&
|
|
37836
|
+
_subjects.state.next({ name, ...(watched ? {} : fieldState) }));
|
|
37837
|
+
}
|
|
37838
|
+
!isBlurEvent && watched && _subjects.state.next({ ..._formState });
|
|
37839
|
+
if (_options.resolver) {
|
|
37840
|
+
const { errors } = await _runSchema([name]);
|
|
37841
|
+
_updateIsFieldValueUpdated(fieldValue);
|
|
37842
|
+
if (isFieldValueUpdated) {
|
|
37843
|
+
const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
|
|
37844
|
+
const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);
|
|
37845
|
+
error = errorLookupResult.error;
|
|
37846
|
+
name = errorLookupResult.name;
|
|
37847
|
+
isValid = isEmptyObject$1(errors);
|
|
37848
|
+
}
|
|
37849
|
+
}
|
|
37850
|
+
else {
|
|
37851
|
+
_updateIsValidating([name], true);
|
|
37852
|
+
error = (await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
|
|
37853
|
+
_updateIsValidating([name]);
|
|
37854
|
+
_updateIsFieldValueUpdated(fieldValue);
|
|
37855
|
+
if (isFieldValueUpdated) {
|
|
37856
|
+
if (error) {
|
|
37857
|
+
isValid = false;
|
|
37858
|
+
}
|
|
37859
|
+
else if (_proxyFormState.isValid ||
|
|
37860
|
+
_proxySubscribeFormState.isValid) {
|
|
37861
|
+
isValid = await executeBuiltInValidation(_fields, true);
|
|
37862
|
+
}
|
|
37863
|
+
}
|
|
37864
|
+
}
|
|
37865
|
+
if (isFieldValueUpdated) {
|
|
37866
|
+
field._f.deps &&
|
|
37867
|
+
(!Array.isArray(field._f.deps) || field._f.deps.length > 0) &&
|
|
37868
|
+
trigger(field._f.deps);
|
|
37869
|
+
shouldRenderByError(name, isValid, error, fieldState);
|
|
37870
|
+
}
|
|
37871
|
+
}
|
|
37872
|
+
};
|
|
37873
|
+
const _focusInput = (ref, key) => {
|
|
37874
|
+
if (get(_formState.errors, key) && ref.focus) {
|
|
37875
|
+
ref.focus();
|
|
37876
|
+
return 1;
|
|
37877
|
+
}
|
|
37878
|
+
return;
|
|
37879
|
+
};
|
|
37880
|
+
const trigger = async (name, options = {}) => {
|
|
37881
|
+
let isValid;
|
|
37882
|
+
let validationResult;
|
|
37883
|
+
const fieldNames = convertToArrayPayload(name);
|
|
37884
|
+
if (_options.resolver) {
|
|
37885
|
+
const errors = await executeSchemaAndUpdateState(isUndefined$1(name) ? name : fieldNames);
|
|
37886
|
+
isValid = isEmptyObject$1(errors);
|
|
37887
|
+
validationResult = name
|
|
37888
|
+
? !fieldNames.some((name) => get(errors, name))
|
|
37889
|
+
: isValid;
|
|
37890
|
+
}
|
|
37891
|
+
else if (name) {
|
|
37892
|
+
validationResult = (await Promise.all(fieldNames.map(async (fieldName) => {
|
|
37893
|
+
const field = get(_fields, fieldName);
|
|
37894
|
+
return await executeBuiltInValidation(field && field._f ? { [fieldName]: field } : field);
|
|
37895
|
+
}))).every(Boolean);
|
|
37896
|
+
!(!validationResult && !_formState.isValid) && _setValid();
|
|
37897
|
+
}
|
|
37898
|
+
else {
|
|
37899
|
+
validationResult = isValid = await executeBuiltInValidation(_fields);
|
|
37900
|
+
}
|
|
37901
|
+
_subjects.state.next({
|
|
37902
|
+
...(!isString$1(name) ||
|
|
37903
|
+
((_proxyFormState.isValid || _proxySubscribeFormState.isValid) &&
|
|
37904
|
+
isValid !== _formState.isValid)
|
|
37905
|
+
? {}
|
|
37906
|
+
: { name }),
|
|
37907
|
+
...(_options.resolver || !name ? { isValid } : {}),
|
|
37908
|
+
errors: _formState.errors,
|
|
37909
|
+
});
|
|
37910
|
+
options.shouldFocus &&
|
|
37911
|
+
!validationResult &&
|
|
37912
|
+
iterateFieldsByAction(_fields, _focusInput, name ? fieldNames : _names.mount);
|
|
37913
|
+
return validationResult;
|
|
37914
|
+
};
|
|
37915
|
+
const getValues = (fieldNames, config) => {
|
|
37916
|
+
let values = {
|
|
37917
|
+
...(_state.mount ? _formValues : _defaultValues),
|
|
37918
|
+
};
|
|
37919
|
+
if (config) {
|
|
37920
|
+
values = extractFormValues(config.dirtyFields ? _formState.dirtyFields : _formState.touchedFields, values);
|
|
37921
|
+
}
|
|
37922
|
+
return isUndefined$1(fieldNames)
|
|
37923
|
+
? values
|
|
37924
|
+
: isString$1(fieldNames)
|
|
37925
|
+
? get(values, fieldNames)
|
|
37926
|
+
: fieldNames.map((name) => get(values, name));
|
|
37927
|
+
};
|
|
37928
|
+
const getFieldState = (name, formState) => ({
|
|
37929
|
+
invalid: !!get((formState || _formState).errors, name),
|
|
37930
|
+
isDirty: !!get((formState || _formState).dirtyFields, name),
|
|
37931
|
+
error: get((formState || _formState).errors, name),
|
|
37932
|
+
isValidating: !!get(_formState.validatingFields, name),
|
|
37933
|
+
isTouched: !!get((formState || _formState).touchedFields, name),
|
|
37934
|
+
});
|
|
37935
|
+
const clearErrors = (name) => {
|
|
37936
|
+
name &&
|
|
37937
|
+
convertToArrayPayload(name).forEach((inputName) => unset(_formState.errors, inputName));
|
|
37938
|
+
_subjects.state.next({
|
|
37939
|
+
errors: name ? _formState.errors : {},
|
|
37940
|
+
});
|
|
37941
|
+
};
|
|
37942
|
+
const setError = (name, error, options) => {
|
|
37943
|
+
const ref = (get(_fields, name, { _f: {} })._f || {}).ref;
|
|
37944
|
+
const currentError = get(_formState.errors, name) || {};
|
|
37945
|
+
// Don't override existing error messages elsewhere in the object tree.
|
|
37946
|
+
const { ref: currentRef, message, type, ...restOfErrorTree } = currentError;
|
|
37947
|
+
set(_formState.errors, name, {
|
|
37948
|
+
...restOfErrorTree,
|
|
37949
|
+
...error,
|
|
37950
|
+
ref,
|
|
37951
|
+
});
|
|
37952
|
+
_subjects.state.next({
|
|
37953
|
+
name,
|
|
37954
|
+
errors: _formState.errors,
|
|
37955
|
+
isValid: false,
|
|
37956
|
+
});
|
|
37957
|
+
options && options.shouldFocus && ref && ref.focus && ref.focus();
|
|
37958
|
+
};
|
|
37959
|
+
const watch = (name, defaultValue) => isFunction$2(name)
|
|
37960
|
+
? _subjects.state.subscribe({
|
|
37961
|
+
next: (payload) => 'values' in payload &&
|
|
37962
|
+
name(_getWatch(undefined, defaultValue), payload),
|
|
37963
|
+
})
|
|
37964
|
+
: _getWatch(name, defaultValue, true);
|
|
37965
|
+
const _subscribe = (props) => _subjects.state.subscribe({
|
|
37966
|
+
next: (formState) => {
|
|
37967
|
+
if (shouldSubscribeByName(props.name, formState.name, props.exact) &&
|
|
37968
|
+
shouldRenderFormState(formState, props.formState || _proxyFormState, _setFormState, props.reRenderRoot)) {
|
|
37969
|
+
props.callback({
|
|
37970
|
+
values: { ..._formValues },
|
|
37971
|
+
..._formState,
|
|
37972
|
+
...formState,
|
|
37973
|
+
defaultValues: _defaultValues,
|
|
37974
|
+
});
|
|
37975
|
+
}
|
|
37976
|
+
},
|
|
37977
|
+
}).unsubscribe;
|
|
37978
|
+
const subscribe = (props) => {
|
|
37979
|
+
_state.mount = true;
|
|
37980
|
+
_proxySubscribeFormState = {
|
|
37981
|
+
..._proxySubscribeFormState,
|
|
37982
|
+
...props.formState,
|
|
37983
|
+
};
|
|
37984
|
+
return _subscribe({
|
|
37985
|
+
...props,
|
|
37986
|
+
formState: _proxySubscribeFormState,
|
|
37987
|
+
});
|
|
37988
|
+
};
|
|
37989
|
+
const unregister = (name, options = {}) => {
|
|
37990
|
+
for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {
|
|
37991
|
+
_names.mount.delete(fieldName);
|
|
37992
|
+
_names.array.delete(fieldName);
|
|
37993
|
+
if (!options.keepValue) {
|
|
37994
|
+
unset(_fields, fieldName);
|
|
37995
|
+
unset(_formValues, fieldName);
|
|
37996
|
+
}
|
|
37997
|
+
!options.keepError && unset(_formState.errors, fieldName);
|
|
37998
|
+
!options.keepDirty && unset(_formState.dirtyFields, fieldName);
|
|
37999
|
+
!options.keepTouched && unset(_formState.touchedFields, fieldName);
|
|
38000
|
+
!options.keepIsValidating &&
|
|
38001
|
+
unset(_formState.validatingFields, fieldName);
|
|
38002
|
+
!_options.shouldUnregister &&
|
|
38003
|
+
!options.keepDefaultValue &&
|
|
38004
|
+
unset(_defaultValues, fieldName);
|
|
38005
|
+
}
|
|
38006
|
+
_subjects.state.next({
|
|
38007
|
+
values: cloneObject(_formValues),
|
|
38008
|
+
});
|
|
38009
|
+
_subjects.state.next({
|
|
38010
|
+
..._formState,
|
|
38011
|
+
...(!options.keepDirty ? {} : { isDirty: _getDirty() }),
|
|
38012
|
+
});
|
|
38013
|
+
!options.keepIsValid && _setValid();
|
|
38014
|
+
};
|
|
38015
|
+
const _setDisabledField = ({ disabled, name, }) => {
|
|
38016
|
+
if ((isBoolean$1(disabled) && _state.mount) ||
|
|
38017
|
+
!!disabled ||
|
|
38018
|
+
_names.disabled.has(name)) {
|
|
38019
|
+
disabled ? _names.disabled.add(name) : _names.disabled.delete(name);
|
|
38020
|
+
}
|
|
38021
|
+
};
|
|
38022
|
+
const register = (name, options = {}) => {
|
|
38023
|
+
let field = get(_fields, name);
|
|
38024
|
+
const disabledIsDefined = isBoolean$1(options.disabled) || isBoolean$1(_options.disabled);
|
|
38025
|
+
set(_fields, name, {
|
|
38026
|
+
...(field || {}),
|
|
38027
|
+
_f: {
|
|
38028
|
+
...(field && field._f ? field._f : { ref: { name } }),
|
|
38029
|
+
name,
|
|
38030
|
+
mount: true,
|
|
38031
|
+
...options,
|
|
38032
|
+
},
|
|
38033
|
+
});
|
|
38034
|
+
_names.mount.add(name);
|
|
38035
|
+
if (field) {
|
|
38036
|
+
_setDisabledField({
|
|
38037
|
+
disabled: isBoolean$1(options.disabled)
|
|
38038
|
+
? options.disabled
|
|
38039
|
+
: _options.disabled,
|
|
38040
|
+
name,
|
|
38041
|
+
});
|
|
38042
|
+
}
|
|
38043
|
+
else {
|
|
38044
|
+
updateValidAndValue(name, true, options.value);
|
|
38045
|
+
}
|
|
38046
|
+
return {
|
|
38047
|
+
...(disabledIsDefined
|
|
38048
|
+
? { disabled: options.disabled || _options.disabled }
|
|
38049
|
+
: {}),
|
|
38050
|
+
...(_options.progressive
|
|
38051
|
+
? {
|
|
38052
|
+
required: !!options.required,
|
|
38053
|
+
min: getRuleValue(options.min),
|
|
38054
|
+
max: getRuleValue(options.max),
|
|
38055
|
+
minLength: getRuleValue(options.minLength),
|
|
38056
|
+
maxLength: getRuleValue(options.maxLength),
|
|
38057
|
+
pattern: getRuleValue(options.pattern),
|
|
38058
|
+
}
|
|
38059
|
+
: {}),
|
|
38060
|
+
name,
|
|
38061
|
+
onChange,
|
|
38062
|
+
onBlur: onChange,
|
|
38063
|
+
ref: (ref) => {
|
|
38064
|
+
if (ref) {
|
|
38065
|
+
register(name, options);
|
|
38066
|
+
field = get(_fields, name);
|
|
38067
|
+
const fieldRef = isUndefined$1(ref.value)
|
|
38068
|
+
? ref.querySelectorAll
|
|
38069
|
+
? ref.querySelectorAll('input,select,textarea')[0] || ref
|
|
38070
|
+
: ref
|
|
38071
|
+
: ref;
|
|
38072
|
+
const radioOrCheckbox = isRadioOrCheckbox(fieldRef);
|
|
38073
|
+
const refs = field._f.refs || [];
|
|
38074
|
+
if (radioOrCheckbox
|
|
38075
|
+
? refs.find((option) => option === fieldRef)
|
|
38076
|
+
: fieldRef === field._f.ref) {
|
|
38077
|
+
return;
|
|
38078
|
+
}
|
|
38079
|
+
set(_fields, name, {
|
|
38080
|
+
_f: {
|
|
38081
|
+
...field._f,
|
|
38082
|
+
...(radioOrCheckbox
|
|
38083
|
+
? {
|
|
38084
|
+
refs: [
|
|
38085
|
+
...refs.filter(live),
|
|
38086
|
+
fieldRef,
|
|
38087
|
+
...(Array.isArray(get(_defaultValues, name)) ? [{}] : []),
|
|
38088
|
+
],
|
|
38089
|
+
ref: { type: fieldRef.type, name },
|
|
38090
|
+
}
|
|
38091
|
+
: { ref: fieldRef }),
|
|
38092
|
+
},
|
|
38093
|
+
});
|
|
38094
|
+
updateValidAndValue(name, false, undefined, fieldRef);
|
|
38095
|
+
}
|
|
38096
|
+
else {
|
|
38097
|
+
field = get(_fields, name, {});
|
|
38098
|
+
if (field._f) {
|
|
38099
|
+
field._f.mount = false;
|
|
38100
|
+
}
|
|
38101
|
+
(_options.shouldUnregister || options.shouldUnregister) &&
|
|
38102
|
+
!(isNameInFieldArray(_names.array, name) && _state.action) &&
|
|
38103
|
+
_names.unMount.add(name);
|
|
38104
|
+
}
|
|
38105
|
+
},
|
|
38106
|
+
};
|
|
38107
|
+
};
|
|
38108
|
+
const _focusError = () => _options.shouldFocusError &&
|
|
38109
|
+
iterateFieldsByAction(_fields, _focusInput, _names.mount);
|
|
38110
|
+
const _disableForm = (disabled) => {
|
|
38111
|
+
if (isBoolean$1(disabled)) {
|
|
38112
|
+
_subjects.state.next({ disabled });
|
|
38113
|
+
iterateFieldsByAction(_fields, (ref, name) => {
|
|
38114
|
+
const currentField = get(_fields, name);
|
|
38115
|
+
if (currentField) {
|
|
38116
|
+
ref.disabled = currentField._f.disabled || disabled;
|
|
38117
|
+
if (Array.isArray(currentField._f.refs)) {
|
|
38118
|
+
currentField._f.refs.forEach((inputRef) => {
|
|
38119
|
+
inputRef.disabled = currentField._f.disabled || disabled;
|
|
38120
|
+
});
|
|
38121
|
+
}
|
|
38122
|
+
}
|
|
38123
|
+
}, 0, false);
|
|
38124
|
+
}
|
|
38125
|
+
};
|
|
38126
|
+
const handleSubmit = (onValid, onInvalid) => async (e) => {
|
|
38127
|
+
let onValidError = undefined;
|
|
38128
|
+
if (e) {
|
|
38129
|
+
e.preventDefault && e.preventDefault();
|
|
38130
|
+
e.persist &&
|
|
38131
|
+
e.persist();
|
|
38132
|
+
}
|
|
38133
|
+
let fieldValues = cloneObject(_formValues);
|
|
38134
|
+
_subjects.state.next({
|
|
38135
|
+
isSubmitting: true,
|
|
38136
|
+
});
|
|
38137
|
+
if (_options.resolver) {
|
|
38138
|
+
const { errors, values } = await _runSchema();
|
|
38139
|
+
_formState.errors = errors;
|
|
38140
|
+
fieldValues = cloneObject(values);
|
|
38141
|
+
}
|
|
38142
|
+
else {
|
|
38143
|
+
await executeBuiltInValidation(_fields);
|
|
38144
|
+
}
|
|
38145
|
+
if (_names.disabled.size) {
|
|
38146
|
+
for (const name of _names.disabled) {
|
|
38147
|
+
unset(fieldValues, name);
|
|
38148
|
+
}
|
|
38149
|
+
}
|
|
38150
|
+
unset(_formState.errors, 'root');
|
|
38151
|
+
if (isEmptyObject$1(_formState.errors)) {
|
|
38152
|
+
_subjects.state.next({
|
|
38153
|
+
errors: {},
|
|
38154
|
+
});
|
|
38155
|
+
try {
|
|
38156
|
+
await onValid(fieldValues, e);
|
|
38157
|
+
}
|
|
38158
|
+
catch (error) {
|
|
38159
|
+
onValidError = error;
|
|
38160
|
+
}
|
|
38161
|
+
}
|
|
38162
|
+
else {
|
|
38163
|
+
if (onInvalid) {
|
|
38164
|
+
await onInvalid({ ..._formState.errors }, e);
|
|
38165
|
+
}
|
|
38166
|
+
_focusError();
|
|
38167
|
+
setTimeout(_focusError);
|
|
38168
|
+
}
|
|
38169
|
+
_subjects.state.next({
|
|
38170
|
+
isSubmitted: true,
|
|
38171
|
+
isSubmitting: false,
|
|
38172
|
+
isSubmitSuccessful: isEmptyObject$1(_formState.errors) && !onValidError,
|
|
38173
|
+
submitCount: _formState.submitCount + 1,
|
|
38174
|
+
errors: _formState.errors,
|
|
38175
|
+
});
|
|
38176
|
+
if (onValidError) {
|
|
38177
|
+
throw onValidError;
|
|
38178
|
+
}
|
|
38179
|
+
};
|
|
38180
|
+
const resetField = (name, options = {}) => {
|
|
38181
|
+
if (get(_fields, name)) {
|
|
38182
|
+
if (isUndefined$1(options.defaultValue)) {
|
|
38183
|
+
setValue(name, cloneObject(get(_defaultValues, name)));
|
|
38184
|
+
}
|
|
38185
|
+
else {
|
|
38186
|
+
setValue(name, options.defaultValue);
|
|
38187
|
+
set(_defaultValues, name, cloneObject(options.defaultValue));
|
|
38188
|
+
}
|
|
38189
|
+
if (!options.keepTouched) {
|
|
38190
|
+
unset(_formState.touchedFields, name);
|
|
38191
|
+
}
|
|
38192
|
+
if (!options.keepDirty) {
|
|
38193
|
+
unset(_formState.dirtyFields, name);
|
|
38194
|
+
_formState.isDirty = options.defaultValue
|
|
38195
|
+
? _getDirty(name, cloneObject(get(_defaultValues, name)))
|
|
38196
|
+
: _getDirty();
|
|
38197
|
+
}
|
|
38198
|
+
if (!options.keepError) {
|
|
38199
|
+
unset(_formState.errors, name);
|
|
38200
|
+
_proxyFormState.isValid && _setValid();
|
|
38201
|
+
}
|
|
38202
|
+
_subjects.state.next({ ..._formState });
|
|
38203
|
+
}
|
|
38204
|
+
};
|
|
38205
|
+
const _reset = (formValues, keepStateOptions = {}) => {
|
|
38206
|
+
const updatedValues = formValues ? cloneObject(formValues) : _defaultValues;
|
|
38207
|
+
const cloneUpdatedValues = cloneObject(updatedValues);
|
|
38208
|
+
const isEmptyResetValues = isEmptyObject$1(formValues);
|
|
38209
|
+
const values = isEmptyResetValues ? _defaultValues : cloneUpdatedValues;
|
|
38210
|
+
if (!keepStateOptions.keepDefaultValues) {
|
|
38211
|
+
_defaultValues = updatedValues;
|
|
38212
|
+
}
|
|
38213
|
+
if (!keepStateOptions.keepValues) {
|
|
38214
|
+
if (keepStateOptions.keepDirtyValues) {
|
|
38215
|
+
const fieldsToCheck = new Set([
|
|
38216
|
+
..._names.mount,
|
|
38217
|
+
...Object.keys(getDirtyFields(_defaultValues, _formValues)),
|
|
38218
|
+
]);
|
|
38219
|
+
for (const fieldName of Array.from(fieldsToCheck)) {
|
|
38220
|
+
get(_formState.dirtyFields, fieldName)
|
|
38221
|
+
? set(values, fieldName, get(_formValues, fieldName))
|
|
38222
|
+
: setValue(fieldName, get(values, fieldName));
|
|
38223
|
+
}
|
|
38224
|
+
}
|
|
38225
|
+
else {
|
|
38226
|
+
if (isWeb && isUndefined$1(formValues)) {
|
|
38227
|
+
for (const name of _names.mount) {
|
|
38228
|
+
const field = get(_fields, name);
|
|
38229
|
+
if (field && field._f) {
|
|
38230
|
+
const fieldReference = Array.isArray(field._f.refs)
|
|
38231
|
+
? field._f.refs[0]
|
|
38232
|
+
: field._f.ref;
|
|
38233
|
+
if (isHTMLElement$1(fieldReference)) {
|
|
38234
|
+
const form = fieldReference.closest('form');
|
|
38235
|
+
if (form) {
|
|
38236
|
+
form.reset();
|
|
38237
|
+
break;
|
|
38238
|
+
}
|
|
38239
|
+
}
|
|
38240
|
+
}
|
|
38241
|
+
}
|
|
38242
|
+
}
|
|
38243
|
+
if (keepStateOptions.keepFieldsRef) {
|
|
38244
|
+
for (const fieldName of _names.mount) {
|
|
38245
|
+
setValue(fieldName, get(values, fieldName));
|
|
38246
|
+
}
|
|
38247
|
+
}
|
|
38248
|
+
else {
|
|
38249
|
+
_fields = {};
|
|
38250
|
+
}
|
|
38251
|
+
}
|
|
38252
|
+
_formValues = _options.shouldUnregister
|
|
38253
|
+
? keepStateOptions.keepDefaultValues
|
|
38254
|
+
? cloneObject(_defaultValues)
|
|
38255
|
+
: {}
|
|
38256
|
+
: cloneObject(values);
|
|
38257
|
+
_subjects.array.next({
|
|
38258
|
+
values: { ...values },
|
|
38259
|
+
});
|
|
38260
|
+
_subjects.state.next({
|
|
38261
|
+
values: { ...values },
|
|
38262
|
+
});
|
|
38263
|
+
}
|
|
38264
|
+
_names = {
|
|
38265
|
+
mount: keepStateOptions.keepDirtyValues ? _names.mount : new Set(),
|
|
38266
|
+
unMount: new Set(),
|
|
38267
|
+
array: new Set(),
|
|
38268
|
+
disabled: new Set(),
|
|
38269
|
+
watch: new Set(),
|
|
38270
|
+
watchAll: false,
|
|
38271
|
+
focus: '',
|
|
38272
|
+
};
|
|
38273
|
+
_state.mount =
|
|
38274
|
+
!_proxyFormState.isValid ||
|
|
38275
|
+
!!keepStateOptions.keepIsValid ||
|
|
38276
|
+
!!keepStateOptions.keepDirtyValues ||
|
|
38277
|
+
(!_options.shouldUnregister && !isEmptyObject$1(values));
|
|
38278
|
+
_state.watch = !!_options.shouldUnregister;
|
|
38279
|
+
_subjects.state.next({
|
|
38280
|
+
submitCount: keepStateOptions.keepSubmitCount
|
|
38281
|
+
? _formState.submitCount
|
|
38282
|
+
: 0,
|
|
38283
|
+
isDirty: isEmptyResetValues
|
|
38284
|
+
? false
|
|
38285
|
+
: keepStateOptions.keepDirty
|
|
38286
|
+
? _formState.isDirty
|
|
38287
|
+
: !!(keepStateOptions.keepDefaultValues &&
|
|
38288
|
+
!deepEqual(formValues, _defaultValues)),
|
|
38289
|
+
isSubmitted: keepStateOptions.keepIsSubmitted
|
|
38290
|
+
? _formState.isSubmitted
|
|
38291
|
+
: false,
|
|
38292
|
+
dirtyFields: isEmptyResetValues
|
|
38293
|
+
? {}
|
|
38294
|
+
: keepStateOptions.keepDirtyValues
|
|
38295
|
+
? keepStateOptions.keepDefaultValues && _formValues
|
|
38296
|
+
? getDirtyFields(_defaultValues, _formValues)
|
|
38297
|
+
: _formState.dirtyFields
|
|
38298
|
+
: keepStateOptions.keepDefaultValues && formValues
|
|
38299
|
+
? getDirtyFields(_defaultValues, formValues)
|
|
38300
|
+
: keepStateOptions.keepDirty
|
|
38301
|
+
? _formState.dirtyFields
|
|
38302
|
+
: {},
|
|
38303
|
+
touchedFields: keepStateOptions.keepTouched
|
|
38304
|
+
? _formState.touchedFields
|
|
38305
|
+
: {},
|
|
38306
|
+
errors: keepStateOptions.keepErrors ? _formState.errors : {},
|
|
38307
|
+
isSubmitSuccessful: keepStateOptions.keepIsSubmitSuccessful
|
|
38308
|
+
? _formState.isSubmitSuccessful
|
|
38309
|
+
: false,
|
|
38310
|
+
isSubmitting: false,
|
|
38311
|
+
defaultValues: _defaultValues,
|
|
38312
|
+
});
|
|
38313
|
+
};
|
|
38314
|
+
const reset = (formValues, keepStateOptions) => _reset(isFunction$2(formValues)
|
|
38315
|
+
? formValues(_formValues)
|
|
38316
|
+
: formValues, keepStateOptions);
|
|
38317
|
+
const setFocus = (name, options = {}) => {
|
|
38318
|
+
const field = get(_fields, name);
|
|
38319
|
+
const fieldReference = field && field._f;
|
|
38320
|
+
if (fieldReference) {
|
|
38321
|
+
const fieldRef = fieldReference.refs
|
|
38322
|
+
? fieldReference.refs[0]
|
|
38323
|
+
: fieldReference.ref;
|
|
38324
|
+
if (fieldRef.focus) {
|
|
38325
|
+
fieldRef.focus();
|
|
38326
|
+
options.shouldSelect &&
|
|
38327
|
+
isFunction$2(fieldRef.select) &&
|
|
38328
|
+
fieldRef.select();
|
|
38329
|
+
}
|
|
38330
|
+
}
|
|
38331
|
+
};
|
|
38332
|
+
const _setFormState = (updatedFormState) => {
|
|
38333
|
+
_formState = {
|
|
38334
|
+
..._formState,
|
|
38335
|
+
...updatedFormState,
|
|
38336
|
+
};
|
|
38337
|
+
};
|
|
38338
|
+
const _resetDefaultValues = () => isFunction$2(_options.defaultValues) &&
|
|
38339
|
+
_options.defaultValues().then((values) => {
|
|
38340
|
+
reset(values, _options.resetOptions);
|
|
38341
|
+
_subjects.state.next({
|
|
38342
|
+
isLoading: false,
|
|
38343
|
+
});
|
|
38344
|
+
});
|
|
38345
|
+
const methods = {
|
|
38346
|
+
control: {
|
|
38347
|
+
register,
|
|
38348
|
+
unregister,
|
|
38349
|
+
getFieldState,
|
|
38350
|
+
handleSubmit,
|
|
38351
|
+
setError,
|
|
38352
|
+
_subscribe,
|
|
38353
|
+
_runSchema,
|
|
38354
|
+
_focusError,
|
|
38355
|
+
_getWatch,
|
|
38356
|
+
_getDirty,
|
|
38357
|
+
_setValid,
|
|
38358
|
+
_setFieldArray,
|
|
38359
|
+
_setDisabledField,
|
|
38360
|
+
_setErrors,
|
|
38361
|
+
_getFieldArray,
|
|
38362
|
+
_reset,
|
|
38363
|
+
_resetDefaultValues,
|
|
38364
|
+
_removeUnmounted,
|
|
38365
|
+
_disableForm,
|
|
38366
|
+
_subjects,
|
|
38367
|
+
_proxyFormState,
|
|
38368
|
+
get _fields() {
|
|
38369
|
+
return _fields;
|
|
38370
|
+
},
|
|
38371
|
+
get _formValues() {
|
|
38372
|
+
return _formValues;
|
|
38373
|
+
},
|
|
38374
|
+
get _state() {
|
|
38375
|
+
return _state;
|
|
38376
|
+
},
|
|
38377
|
+
set _state(value) {
|
|
38378
|
+
_state = value;
|
|
38379
|
+
},
|
|
38380
|
+
get _defaultValues() {
|
|
38381
|
+
return _defaultValues;
|
|
38382
|
+
},
|
|
38383
|
+
get _names() {
|
|
38384
|
+
return _names;
|
|
38385
|
+
},
|
|
38386
|
+
set _names(value) {
|
|
38387
|
+
_names = value;
|
|
38388
|
+
},
|
|
38389
|
+
get _formState() {
|
|
38390
|
+
return _formState;
|
|
38391
|
+
},
|
|
38392
|
+
get _options() {
|
|
38393
|
+
return _options;
|
|
38394
|
+
},
|
|
38395
|
+
set _options(value) {
|
|
38396
|
+
_options = {
|
|
38397
|
+
..._options,
|
|
38398
|
+
...value,
|
|
38399
|
+
};
|
|
38400
|
+
},
|
|
38401
|
+
},
|
|
38402
|
+
subscribe,
|
|
38403
|
+
trigger,
|
|
38404
|
+
register,
|
|
38405
|
+
handleSubmit,
|
|
38406
|
+
watch,
|
|
38407
|
+
setValue,
|
|
38408
|
+
getValues,
|
|
38409
|
+
reset,
|
|
38410
|
+
resetField,
|
|
38411
|
+
clearErrors,
|
|
38412
|
+
unregister,
|
|
38413
|
+
setError,
|
|
38414
|
+
setFocus,
|
|
38415
|
+
getFieldState,
|
|
38416
|
+
};
|
|
38417
|
+
return {
|
|
38418
|
+
...methods,
|
|
38419
|
+
formControl: methods,
|
|
38420
|
+
};
|
|
38421
|
+
}
|
|
38422
|
+
|
|
38423
|
+
/**
|
|
38424
|
+
* Custom hook to manage the entire form.
|
|
38425
|
+
*
|
|
38426
|
+
* @remarks
|
|
38427
|
+
* [API](https://react-hook-form.com/docs/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)
|
|
38428
|
+
*
|
|
38429
|
+
* @param props - form configuration and validation parameters.
|
|
38430
|
+
*
|
|
38431
|
+
* @returns methods - individual functions to manage the form state. {@link UseFormReturn}
|
|
38432
|
+
*
|
|
38433
|
+
* @example
|
|
38434
|
+
* ```tsx
|
|
38435
|
+
* function App() {
|
|
38436
|
+
* const { register, handleSubmit, watch, formState: { errors } } = useForm();
|
|
38437
|
+
* const onSubmit = data => console.log(data);
|
|
38438
|
+
*
|
|
38439
|
+
* console.log(watch("example"));
|
|
38440
|
+
*
|
|
38441
|
+
* return (
|
|
38442
|
+
* <form onSubmit={handleSubmit(onSubmit)}>
|
|
38443
|
+
* <input defaultValue="test" {...register("example")} />
|
|
38444
|
+
* <input {...register("exampleRequired", { required: true })} />
|
|
38445
|
+
* {errors.exampleRequired && <span>This field is required</span>}
|
|
38446
|
+
* <button>Submit</button>
|
|
38447
|
+
* </form>
|
|
38448
|
+
* );
|
|
38449
|
+
* }
|
|
38450
|
+
* ```
|
|
38451
|
+
*/
|
|
38452
|
+
function useForm(props = {}) {
|
|
38453
|
+
const _formControl = React.useRef(undefined);
|
|
38454
|
+
const _values = React.useRef(undefined);
|
|
38455
|
+
const [formState, updateFormState] = React.useState({
|
|
38456
|
+
isDirty: false,
|
|
38457
|
+
isValidating: false,
|
|
38458
|
+
isLoading: isFunction$2(props.defaultValues),
|
|
38459
|
+
isSubmitted: false,
|
|
38460
|
+
isSubmitting: false,
|
|
38461
|
+
isSubmitSuccessful: false,
|
|
38462
|
+
isValid: false,
|
|
38463
|
+
submitCount: 0,
|
|
38464
|
+
dirtyFields: {},
|
|
38465
|
+
touchedFields: {},
|
|
38466
|
+
validatingFields: {},
|
|
38467
|
+
errors: props.errors || {},
|
|
38468
|
+
disabled: props.disabled || false,
|
|
38469
|
+
isReady: false,
|
|
38470
|
+
defaultValues: isFunction$2(props.defaultValues)
|
|
38471
|
+
? undefined
|
|
38472
|
+
: props.defaultValues,
|
|
38473
|
+
});
|
|
38474
|
+
if (!_formControl.current) {
|
|
38475
|
+
if (props.formControl) {
|
|
38476
|
+
_formControl.current = {
|
|
38477
|
+
...props.formControl,
|
|
38478
|
+
formState,
|
|
38479
|
+
};
|
|
38480
|
+
if (props.defaultValues && !isFunction$2(props.defaultValues)) {
|
|
38481
|
+
props.formControl.reset(props.defaultValues, props.resetOptions);
|
|
38482
|
+
}
|
|
38483
|
+
}
|
|
38484
|
+
else {
|
|
38485
|
+
const { formControl, ...rest } = createFormControl(props);
|
|
38486
|
+
_formControl.current = {
|
|
38487
|
+
...rest,
|
|
38488
|
+
formState,
|
|
38489
|
+
};
|
|
38490
|
+
}
|
|
38491
|
+
}
|
|
38492
|
+
const control = _formControl.current.control;
|
|
38493
|
+
control._options = props;
|
|
38494
|
+
useIsomorphicLayoutEffect$1(() => {
|
|
38495
|
+
const sub = control._subscribe({
|
|
38496
|
+
formState: control._proxyFormState,
|
|
38497
|
+
callback: () => updateFormState({ ...control._formState }),
|
|
38498
|
+
reRenderRoot: true,
|
|
38499
|
+
});
|
|
38500
|
+
updateFormState((data) => ({
|
|
38501
|
+
...data,
|
|
38502
|
+
isReady: true,
|
|
38503
|
+
}));
|
|
38504
|
+
control._formState.isReady = true;
|
|
38505
|
+
return sub;
|
|
38506
|
+
}, [control]);
|
|
38507
|
+
React.useEffect(() => control._disableForm(props.disabled), [control, props.disabled]);
|
|
38508
|
+
React.useEffect(() => {
|
|
38509
|
+
if (props.mode) {
|
|
38510
|
+
control._options.mode = props.mode;
|
|
38511
|
+
}
|
|
38512
|
+
if (props.reValidateMode) {
|
|
38513
|
+
control._options.reValidateMode = props.reValidateMode;
|
|
38514
|
+
}
|
|
38515
|
+
}, [control, props.mode, props.reValidateMode]);
|
|
38516
|
+
React.useEffect(() => {
|
|
38517
|
+
if (props.errors) {
|
|
38518
|
+
control._setErrors(props.errors);
|
|
38519
|
+
control._focusError();
|
|
38520
|
+
}
|
|
38521
|
+
}, [control, props.errors]);
|
|
38522
|
+
React.useEffect(() => {
|
|
38523
|
+
props.shouldUnregister &&
|
|
38524
|
+
control._subjects.state.next({
|
|
38525
|
+
values: control._getWatch(),
|
|
38526
|
+
});
|
|
38527
|
+
}, [control, props.shouldUnregister]);
|
|
38528
|
+
React.useEffect(() => {
|
|
38529
|
+
if (control._proxyFormState.isDirty) {
|
|
38530
|
+
const isDirty = control._getDirty();
|
|
38531
|
+
if (isDirty !== formState.isDirty) {
|
|
38532
|
+
control._subjects.state.next({
|
|
38533
|
+
isDirty,
|
|
38534
|
+
});
|
|
38535
|
+
}
|
|
38536
|
+
}
|
|
38537
|
+
}, [control, formState.isDirty]);
|
|
38538
|
+
React.useEffect(() => {
|
|
38539
|
+
if (props.values && !deepEqual(props.values, _values.current)) {
|
|
38540
|
+
control._reset(props.values, {
|
|
38541
|
+
keepFieldsRef: true,
|
|
38542
|
+
...control._options.resetOptions,
|
|
38543
|
+
});
|
|
38544
|
+
_values.current = props.values;
|
|
38545
|
+
updateFormState((state) => ({ ...state }));
|
|
38546
|
+
}
|
|
38547
|
+
else {
|
|
38548
|
+
control._resetDefaultValues();
|
|
38549
|
+
}
|
|
38550
|
+
}, [control, props.values]);
|
|
38551
|
+
React.useEffect(() => {
|
|
38552
|
+
if (!control._state.mount) {
|
|
38553
|
+
control._setValid();
|
|
38554
|
+
control._state.mount = true;
|
|
38555
|
+
}
|
|
38556
|
+
if (control._state.watch) {
|
|
38557
|
+
control._state.watch = false;
|
|
38558
|
+
control._subjects.state.next({ ...control._formState });
|
|
38559
|
+
}
|
|
38560
|
+
control._removeUnmounted();
|
|
38561
|
+
});
|
|
38562
|
+
_formControl.current.formState = getProxyFormState(formState, control);
|
|
38563
|
+
return _formControl.current;
|
|
38564
|
+
}
|
|
38565
|
+
|
|
36753
38566
|
const Paragraph = ({ sx, ...props }) => {
|
|
36754
38567
|
return (jsxRuntime.jsx(Typography, { variant: "body1", sx: {
|
|
36755
38568
|
color: 'var(--color-white)',
|
|
@@ -36843,7 +38656,7 @@ function CustomInput(props) {
|
|
|
36843
38656
|
const { name, type } = props;
|
|
36844
38657
|
const textFieldId = React__namespace.useId();
|
|
36845
38658
|
const { control } = useFormContext$1();
|
|
36846
|
-
return (jsxRuntime.jsx(Controller, { name: name, control: control, render: ({ field }) => (jsxRuntime.jsx(CustomTextField, { id: textFieldId, ...props, ...field, onChange: (event) => {
|
|
38659
|
+
return (jsxRuntime.jsx(Controller, { name: name, control: control, render: ({ field }) => (jsxRuntime.jsx(CustomTextField, { id: textFieldId, size: "small", ...props, ...field, onChange: (event) => {
|
|
36847
38660
|
const { target } = event;
|
|
36848
38661
|
const { value } = target;
|
|
36849
38662
|
switch (type) {
|
|
@@ -41270,12 +43083,12 @@ function bind(fn, thisArg) {
|
|
|
41270
43083
|
|
|
41271
43084
|
// utils is a library of generic helper functions non-specific to axios
|
|
41272
43085
|
|
|
41273
|
-
const {toString} = Object.prototype;
|
|
43086
|
+
const {toString: toString$1} = Object.prototype;
|
|
41274
43087
|
const {getPrototypeOf} = Object;
|
|
41275
43088
|
const {iterator, toStringTag} = Symbol;
|
|
41276
43089
|
|
|
41277
43090
|
const kindOf = (cache => thing => {
|
|
41278
|
-
const str = toString.call(thing);
|
|
43091
|
+
const str = toString$1.call(thing);
|
|
41279
43092
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
41280
43093
|
})(Object.create(null));
|
|
41281
43094
|
|
|
@@ -41376,7 +43189,7 @@ const isNumber = typeOfTest('number');
|
|
|
41376
43189
|
*
|
|
41377
43190
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
41378
43191
|
*/
|
|
41379
|
-
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
43192
|
+
const isObject$1 = (thing) => thing !== null && typeof thing === 'object';
|
|
41380
43193
|
|
|
41381
43194
|
/**
|
|
41382
43195
|
* Determine if a value is a Boolean
|
|
@@ -41411,7 +43224,7 @@ const isPlainObject$1 = (val) => {
|
|
|
41411
43224
|
*/
|
|
41412
43225
|
const isEmptyObject = (val) => {
|
|
41413
43226
|
// Early return for non-objects or Buffers to prevent RangeError
|
|
41414
|
-
if (!isObject(val) || isBuffer(val)) {
|
|
43227
|
+
if (!isObject$1(val) || isBuffer(val)) {
|
|
41415
43228
|
return false;
|
|
41416
43229
|
}
|
|
41417
43230
|
|
|
@@ -41430,7 +43243,7 @@ const isEmptyObject = (val) => {
|
|
|
41430
43243
|
*
|
|
41431
43244
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
41432
43245
|
*/
|
|
41433
|
-
const isDate$
|
|
43246
|
+
const isDate$2 = kindOfTest('Date');
|
|
41434
43247
|
|
|
41435
43248
|
/**
|
|
41436
43249
|
* Determine if a value is a File
|
|
@@ -41466,7 +43279,7 @@ const isFileList = kindOfTest('FileList');
|
|
|
41466
43279
|
*
|
|
41467
43280
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
41468
43281
|
*/
|
|
41469
|
-
const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
43282
|
+
const isStream = (val) => isObject$1(val) && isFunction$1(val.pipe);
|
|
41470
43283
|
|
|
41471
43284
|
/**
|
|
41472
43285
|
* Determine if a value is a FormData
|
|
@@ -41743,7 +43556,7 @@ const endsWith = (str, searchString, position) => {
|
|
|
41743
43556
|
*
|
|
41744
43557
|
* @returns {?Array}
|
|
41745
43558
|
*/
|
|
41746
|
-
const toArray = (thing) => {
|
|
43559
|
+
const toArray$1 = (thing) => {
|
|
41747
43560
|
if (!thing) return null;
|
|
41748
43561
|
if (isArray(thing)) return thing;
|
|
41749
43562
|
let i = thing.length;
|
|
@@ -41917,7 +43730,7 @@ const toJSONObject = (obj) => {
|
|
|
41917
43730
|
|
|
41918
43731
|
const visit = (source, i) => {
|
|
41919
43732
|
|
|
41920
|
-
if (isObject(source)) {
|
|
43733
|
+
if (isObject$1(source)) {
|
|
41921
43734
|
if (stack.indexOf(source) >= 0) {
|
|
41922
43735
|
return;
|
|
41923
43736
|
}
|
|
@@ -41951,7 +43764,7 @@ const toJSONObject = (obj) => {
|
|
|
41951
43764
|
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
41952
43765
|
|
|
41953
43766
|
const isThenable = (thing) =>
|
|
41954
|
-
thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
43767
|
+
thing && (isObject$1(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
41955
43768
|
|
|
41956
43769
|
// original code
|
|
41957
43770
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -41996,7 +43809,7 @@ var utils$1 = {
|
|
|
41996
43809
|
isString,
|
|
41997
43810
|
isNumber,
|
|
41998
43811
|
isBoolean,
|
|
41999
|
-
isObject,
|
|
43812
|
+
isObject: isObject$1,
|
|
42000
43813
|
isPlainObject: isPlainObject$1,
|
|
42001
43814
|
isEmptyObject,
|
|
42002
43815
|
isReadableStream,
|
|
@@ -42004,7 +43817,7 @@ var utils$1 = {
|
|
|
42004
43817
|
isResponse,
|
|
42005
43818
|
isHeaders,
|
|
42006
43819
|
isUndefined,
|
|
42007
|
-
isDate: isDate$
|
|
43820
|
+
isDate: isDate$2,
|
|
42008
43821
|
isFile,
|
|
42009
43822
|
isBlob,
|
|
42010
43823
|
isRegExp,
|
|
@@ -42023,7 +43836,7 @@ var utils$1 = {
|
|
|
42023
43836
|
kindOf,
|
|
42024
43837
|
kindOfTest,
|
|
42025
43838
|
endsWith,
|
|
42026
|
-
toArray,
|
|
43839
|
+
toArray: toArray$1,
|
|
42027
43840
|
forEachEntry,
|
|
42028
43841
|
matchAll,
|
|
42029
43842
|
isHTMLForm,
|
|
@@ -45189,7 +47002,7 @@ const AuthProvider = ({ onUnauthorized, children, }) => {
|
|
|
45189
47002
|
}, [authStore.isUnauthorized]);
|
|
45190
47003
|
return jsxRuntime.jsx(React__namespace.Fragment, { children: children });
|
|
45191
47004
|
};
|
|
45192
|
-
var auth = observer(AuthProvider);
|
|
47005
|
+
var auth$1 = observer(AuthProvider);
|
|
45193
47006
|
|
|
45194
47007
|
class RootStore {
|
|
45195
47008
|
authStore = new AuthStore();
|
|
@@ -50872,7 +52685,7 @@ function buildMatchFn(args) {
|
|
|
50872
52685
|
args.parsePatterns[args.defaultParseWidth];
|
|
50873
52686
|
|
|
50874
52687
|
const key = Array.isArray(parsePatterns)
|
|
50875
|
-
? findIndex(parsePatterns, (pattern) => pattern.test(matchedString))
|
|
52688
|
+
? findIndex$1(parsePatterns, (pattern) => pattern.test(matchedString))
|
|
50876
52689
|
: // [TODO] -- I challenge you to fix the type
|
|
50877
52690
|
findKey(parsePatterns, (pattern) => pattern.test(matchedString));
|
|
50878
52691
|
|
|
@@ -50902,7 +52715,7 @@ function findKey(object, predicate) {
|
|
|
50902
52715
|
return undefined;
|
|
50903
52716
|
}
|
|
50904
52717
|
|
|
50905
|
-
function findIndex(array, predicate) {
|
|
52718
|
+
function findIndex$1(array, predicate) {
|
|
50906
52719
|
for (let key = 0; key < array.length; key++) {
|
|
50907
52720
|
if (predicate(array[key])) {
|
|
50908
52721
|
return key;
|
|
@@ -52627,7 +54440,7 @@ function message(token, format, input) {
|
|
|
52627
54440
|
* const result = isDate({})
|
|
52628
54441
|
* //=> false
|
|
52629
54442
|
*/
|
|
52630
|
-
function isDate(value) {
|
|
54443
|
+
function isDate$1(value) {
|
|
52631
54444
|
return (
|
|
52632
54445
|
value instanceof Date ||
|
|
52633
54446
|
(typeof value === "object" &&
|
|
@@ -52667,7 +54480,7 @@ function isDate(value) {
|
|
|
52667
54480
|
* //=> false
|
|
52668
54481
|
*/
|
|
52669
54482
|
function isValid(date) {
|
|
52670
|
-
return !((!isDate(date) && typeof date !== "number") || isNaN(+toDate(date)));
|
|
54483
|
+
return !((!isDate$1(date) && typeof date !== "number") || isNaN(+toDate(date)));
|
|
52671
54484
|
}
|
|
52672
54485
|
|
|
52673
54486
|
// This RegExp consists of three parts separated by `|`:
|
|
@@ -57840,9 +59653,9 @@ const Provider = (props) => {
|
|
|
57840
59653
|
return (jsxRuntime.jsx(LocalizationProvider, { ...props, dateAdapter: AdapterDateFns, adapterLocale: ru }));
|
|
57841
59654
|
};
|
|
57842
59655
|
|
|
57843
|
-
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
59656
|
+
function r$1(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r$1(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r$1(e))&&(n&&(n+=" "),n+=t);return n}
|
|
57844
59657
|
|
|
57845
|
-
let e={data:""},t=t=>{if("object"==typeof window){let e=(t?t.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return e.nonce=window.__nonce__,e.parentNode||(t||document.head).appendChild(e),e.firstChild}return t||e},l=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,a=/\/\*[^]*?\*\/| +/g,n=/\n+/g,o=(e,t)=>{let r="",l="",a="";for(let n in e){let c=e[n];"@"==n[0]?"i"==n[1]?r=n+" "+c+";":l+="f"==n[1]?o(c,n):n+"{"+o(c,"k"==n[1]?"":t)+"}":"object"==typeof c?l+=o(c,t?t.replace(/([^,])+/g,e=>n.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+" "+t:t)):n):null!=c&&(n=/^--/.test(n)?n:n.replace(/[A-Z]/g,"-$&").toLowerCase(),a+=o.p?o.p(n,c):n+":"+c+";");}return r+(t&&a?t+"{"+a+"}":a)+l},c={},s=e=>{if("object"==typeof e){let t="";for(let r in e)t+=r+s(e[r]);return t}return e},i=(e,t,r,i,p)=>{let u=s(e),d=c[u]||(c[u]=(e=>{let t=0,r=11;for(;t<e.length;)r=101*r+e.charCodeAt(t++)>>>0;return "go"+r})(u));if(!c[d]){let t=u!==e?e:(e=>{let t,r,o=[{}];for(;t=l.exec(e.replace(a,""));)t[4]?o.shift():t[3]?(r=t[3].replace(n," ").trim(),o.unshift(o[0][r]=o[0][r]||{})):o[0][t[1]]=t[2].replace(n," ").trim();return o[0]})(e);c[d]=o(p?{["@keyframes "+d]:t}:t,r?"":"."+d);}let f=r&&c.g?c.g:null;return r&&(c.g=c[d]),((e,t,r,l)=>{l?t.data=t.data.replace(l,e):-1===t.data.indexOf(e)&&(t.data=r?e+t.data:t.data+e);})(c[d],t,i,f),d},p=(e,t,r)=>e.reduce((e,l,a)=>{let n=t[a];if(n&&n.call){let e=n(r),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;n=t?"."+t:e&&"object"==typeof e?e.props?"":o(e,""):false===e?"":e;}return e+l+(null==n?"":n)},"");function u(e){let r=this||{},l=e.call?e(r.p):e;return i(l.unshift?l.raw?p(l,[].slice.call(arguments,1),r.p):l.reduce((e,t)=>Object.assign(e,t&&t.call?t(r.p):t),{}):l,t(r.target),r.g,r.o,r.k)}u.bind({g:1});u.bind({k:1});
|
|
59658
|
+
let e={data:""},t=t=>{if("object"==typeof window){let e=(t?t.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return e.nonce=window.__nonce__,e.parentNode||(t||document.head).appendChild(e),e.firstChild}return t||e},l=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,a=/\/\*[^]*?\*\/| +/g,n$1=/\n+/g,o$2=(e,t)=>{let r="",l="",a="";for(let n in e){let c=e[n];"@"==n[0]?"i"==n[1]?r=n+" "+c+";":l+="f"==n[1]?o$2(c,n):n+"{"+o$2(c,"k"==n[1]?"":t)+"}":"object"==typeof c?l+=o$2(c,t?t.replace(/([^,])+/g,e=>n.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+" "+t:t)):n):null!=c&&(n=/^--/.test(n)?n:n.replace(/[A-Z]/g,"-$&").toLowerCase(),a+=o$2.p?o$2.p(n,c):n+":"+c+";");}return r+(t&&a?t+"{"+a+"}":a)+l},c={},s$1=e=>{if("object"==typeof e){let t="";for(let r in e)t+=r+s$1(e[r]);return t}return e},i$1=(e,t,r,i,p)=>{let u=s$1(e),d=c[u]||(c[u]=(e=>{let t=0,r=11;for(;t<e.length;)r=101*r+e.charCodeAt(t++)>>>0;return "go"+r})(u));if(!c[d]){let t=u!==e?e:(e=>{let t,r,o=[{}];for(;t=l.exec(e.replace(a,""));)t[4]?o.shift():t[3]?(r=t[3].replace(n$1," ").trim(),o.unshift(o[0][r]=o[0][r]||{})):o[0][t[1]]=t[2].replace(n$1," ").trim();return o[0]})(e);c[d]=o$2(p?{["@keyframes "+d]:t}:t,r?"":"."+d);}let f=r&&c.g?c.g:null;return r&&(c.g=c[d]),((e,t,r,l)=>{l?t.data=t.data.replace(l,e):-1===t.data.indexOf(e)&&(t.data=r?e+t.data:t.data+e);})(c[d],t,i,f),d},p=(e,t,r)=>e.reduce((e,l,a)=>{let n=t[a];if(n&&n.call){let e=n(r),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;n=t?"."+t:e&&"object"==typeof e?e.props?"":o$2(e,""):false===e?"":e;}return e+l+(null==n?"":n)},"");function u(e){let r=this||{},l=e.call?e(r.p):e;return i$1(l.unshift?l.raw?p(l,[].slice.call(arguments,1),r.p):l.reduce((e,t)=>Object.assign(e,t&&t.call?t(r.p):t),{}):l,t(r.target),r.g,r.o,r.k)}u.bind({g:1});u.bind({k:1});
|
|
57846
59659
|
|
|
57847
59660
|
function _defineProperties(target, props) {
|
|
57848
59661
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -59771,6 +61584,2357 @@ const useLogout = () => {
|
|
|
59771
61584
|
});
|
|
59772
61585
|
};
|
|
59773
61586
|
|
|
61587
|
+
const r=(t,r,o)=>{if(t&&"reportValidity"in t){const s=get(o,r);t.setCustomValidity(s&&s.message||""),t.reportValidity();}},o$1=(e,t)=>{for(const o in t.fields){const s=t.fields[o];s&&s.ref&&"reportValidity"in s.ref?r(s.ref,o,e):s&&s.refs&&s.refs.forEach(t=>r(t,o,e));}},s=(r,s)=>{s.shouldUseNativeValidation&&o$1(r,s);const n={};for(const o in r){const f=get(s.fields,o),c=Object.assign(r[o]||{},{ref:f&&f.ref});if(i(s.names||Object.keys(r),o)){const r=Object.assign({},get(n,o));set(r,"root",c),set(n,o,r);}else set(n,o,c);}return n},i=(e,t)=>{const r=n(t);return e.some(e=>n(e).match(`^${r}\\.\\d+`))};function n(e){return e.replace(/\]|\[/g,"")}
|
|
61588
|
+
|
|
61589
|
+
function o(o,n,s$1){return void 0===s$1&&(s$1={}),function(a,i,c){try{return Promise.resolve(function(t,r){try{var u=(null!=n&&n.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(o["sync"===s$1.mode?"validateSync":"validate"](a,Object.assign({abortEarly:!1},n,{context:i}))).then(function(t){return c.shouldUseNativeValidation&&o$1({},c),{values:s$1.raw?Object.assign({},a):t,errors:{}}}));}catch(e){return r(e)}return u&&u.then?u.then(void 0,r):u}(0,function(e){if(!e.inner)throw e;return {values:{},errors:s((o=e,n=!c.shouldUseNativeValidation&&"all"===c.criteriaMode,(o.inner||[]).reduce(function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var o=e[t.path].types,s=o&&o[t.type];e[t.path]=appendErrors(t.path,n,e,t.type,s?[].concat(s,t.message):t.message);}return e},{})),c)};var o,n;}))}catch(e){return Promise.reject(e)}}}
|
|
61590
|
+
|
|
61591
|
+
const AuthLayout = ({ children }) => {
|
|
61592
|
+
return (jsxRuntime.jsx(Box, { sx: {
|
|
61593
|
+
display: 'flex',
|
|
61594
|
+
alignItems: 'center',
|
|
61595
|
+
height: '100vh',
|
|
61596
|
+
width: '100vw',
|
|
61597
|
+
overflow: 'hidden',
|
|
61598
|
+
}, children: jsxRuntime.jsx(Box, { sx: {
|
|
61599
|
+
margin: 'auto',
|
|
61600
|
+
maxWidth: '400px',
|
|
61601
|
+
width: '100%',
|
|
61602
|
+
}, children: jsxRuntime.jsx(CustomCard, { children: children }) }) }));
|
|
61603
|
+
};
|
|
61604
|
+
var AuthLayout$1 = observer(AuthLayout);
|
|
61605
|
+
|
|
61606
|
+
/**
|
|
61607
|
+
* Based on Kendo UI Core expression code <https://github.com/telerik/kendo-ui-core#license-information>
|
|
61608
|
+
*/
|
|
61609
|
+
|
|
61610
|
+
var propertyExpr;
|
|
61611
|
+
var hasRequiredPropertyExpr;
|
|
61612
|
+
|
|
61613
|
+
function requirePropertyExpr () {
|
|
61614
|
+
if (hasRequiredPropertyExpr) return propertyExpr;
|
|
61615
|
+
hasRequiredPropertyExpr = 1;
|
|
61616
|
+
|
|
61617
|
+
function Cache(maxSize) {
|
|
61618
|
+
this._maxSize = maxSize;
|
|
61619
|
+
this.clear();
|
|
61620
|
+
}
|
|
61621
|
+
Cache.prototype.clear = function () {
|
|
61622
|
+
this._size = 0;
|
|
61623
|
+
this._values = Object.create(null);
|
|
61624
|
+
};
|
|
61625
|
+
Cache.prototype.get = function (key) {
|
|
61626
|
+
return this._values[key]
|
|
61627
|
+
};
|
|
61628
|
+
Cache.prototype.set = function (key, value) {
|
|
61629
|
+
this._size >= this._maxSize && this.clear();
|
|
61630
|
+
if (!(key in this._values)) this._size++;
|
|
61631
|
+
|
|
61632
|
+
return (this._values[key] = value)
|
|
61633
|
+
};
|
|
61634
|
+
|
|
61635
|
+
var SPLIT_REGEX = /[^.^\]^[]+|(?=\[\]|\.\.)/g,
|
|
61636
|
+
DIGIT_REGEX = /^\d+$/,
|
|
61637
|
+
LEAD_DIGIT_REGEX = /^\d/,
|
|
61638
|
+
SPEC_CHAR_REGEX = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,
|
|
61639
|
+
CLEAN_QUOTES_REGEX = /^\s*(['"]?)(.*?)(\1)\s*$/,
|
|
61640
|
+
MAX_CACHE_SIZE = 512;
|
|
61641
|
+
|
|
61642
|
+
var pathCache = new Cache(MAX_CACHE_SIZE),
|
|
61643
|
+
setCache = new Cache(MAX_CACHE_SIZE),
|
|
61644
|
+
getCache = new Cache(MAX_CACHE_SIZE);
|
|
61645
|
+
|
|
61646
|
+
propertyExpr = {
|
|
61647
|
+
Cache: Cache,
|
|
61648
|
+
|
|
61649
|
+
split: split,
|
|
61650
|
+
|
|
61651
|
+
normalizePath: normalizePath,
|
|
61652
|
+
|
|
61653
|
+
setter: function (path) {
|
|
61654
|
+
var parts = normalizePath(path);
|
|
61655
|
+
|
|
61656
|
+
return (
|
|
61657
|
+
setCache.get(path) ||
|
|
61658
|
+
setCache.set(path, function setter(obj, value) {
|
|
61659
|
+
var index = 0;
|
|
61660
|
+
var len = parts.length;
|
|
61661
|
+
var data = obj;
|
|
61662
|
+
|
|
61663
|
+
while (index < len - 1) {
|
|
61664
|
+
var part = parts[index];
|
|
61665
|
+
if (
|
|
61666
|
+
part === '__proto__' ||
|
|
61667
|
+
part === 'constructor' ||
|
|
61668
|
+
part === 'prototype'
|
|
61669
|
+
) {
|
|
61670
|
+
return obj
|
|
61671
|
+
}
|
|
61672
|
+
|
|
61673
|
+
data = data[parts[index++]];
|
|
61674
|
+
}
|
|
61675
|
+
data[parts[index]] = value;
|
|
61676
|
+
})
|
|
61677
|
+
)
|
|
61678
|
+
},
|
|
61679
|
+
|
|
61680
|
+
getter: function (path, safe) {
|
|
61681
|
+
var parts = normalizePath(path);
|
|
61682
|
+
return (
|
|
61683
|
+
getCache.get(path) ||
|
|
61684
|
+
getCache.set(path, function getter(data) {
|
|
61685
|
+
var index = 0,
|
|
61686
|
+
len = parts.length;
|
|
61687
|
+
while (index < len) {
|
|
61688
|
+
if (data != null || !safe) data = data[parts[index++]];
|
|
61689
|
+
else return
|
|
61690
|
+
}
|
|
61691
|
+
return data
|
|
61692
|
+
})
|
|
61693
|
+
)
|
|
61694
|
+
},
|
|
61695
|
+
|
|
61696
|
+
join: function (segments) {
|
|
61697
|
+
return segments.reduce(function (path, part) {
|
|
61698
|
+
return (
|
|
61699
|
+
path +
|
|
61700
|
+
(isQuoted(part) || DIGIT_REGEX.test(part)
|
|
61701
|
+
? '[' + part + ']'
|
|
61702
|
+
: (path ? '.' : '') + part)
|
|
61703
|
+
)
|
|
61704
|
+
}, '')
|
|
61705
|
+
},
|
|
61706
|
+
|
|
61707
|
+
forEach: function (path, cb, thisArg) {
|
|
61708
|
+
forEach(Array.isArray(path) ? path : split(path), cb, thisArg);
|
|
61709
|
+
},
|
|
61710
|
+
};
|
|
61711
|
+
|
|
61712
|
+
function normalizePath(path) {
|
|
61713
|
+
return (
|
|
61714
|
+
pathCache.get(path) ||
|
|
61715
|
+
pathCache.set(
|
|
61716
|
+
path,
|
|
61717
|
+
split(path).map(function (part) {
|
|
61718
|
+
return part.replace(CLEAN_QUOTES_REGEX, '$2')
|
|
61719
|
+
})
|
|
61720
|
+
)
|
|
61721
|
+
)
|
|
61722
|
+
}
|
|
61723
|
+
|
|
61724
|
+
function split(path) {
|
|
61725
|
+
return path.match(SPLIT_REGEX) || ['']
|
|
61726
|
+
}
|
|
61727
|
+
|
|
61728
|
+
function forEach(parts, iter, thisArg) {
|
|
61729
|
+
var len = parts.length,
|
|
61730
|
+
part,
|
|
61731
|
+
idx,
|
|
61732
|
+
isArray,
|
|
61733
|
+
isBracket;
|
|
61734
|
+
|
|
61735
|
+
for (idx = 0; idx < len; idx++) {
|
|
61736
|
+
part = parts[idx];
|
|
61737
|
+
|
|
61738
|
+
if (part) {
|
|
61739
|
+
if (shouldBeQuoted(part)) {
|
|
61740
|
+
part = '"' + part + '"';
|
|
61741
|
+
}
|
|
61742
|
+
|
|
61743
|
+
isBracket = isQuoted(part);
|
|
61744
|
+
isArray = !isBracket && /^\d+$/.test(part);
|
|
61745
|
+
|
|
61746
|
+
iter.call(thisArg, part, isBracket, isArray, idx, parts);
|
|
61747
|
+
}
|
|
61748
|
+
}
|
|
61749
|
+
}
|
|
61750
|
+
|
|
61751
|
+
function isQuoted(str) {
|
|
61752
|
+
return (
|
|
61753
|
+
typeof str === 'string' && str && ["'", '"'].indexOf(str.charAt(0)) !== -1
|
|
61754
|
+
)
|
|
61755
|
+
}
|
|
61756
|
+
|
|
61757
|
+
function hasLeadingNumber(part) {
|
|
61758
|
+
return part.match(LEAD_DIGIT_REGEX) && !part.match(DIGIT_REGEX)
|
|
61759
|
+
}
|
|
61760
|
+
|
|
61761
|
+
function hasSpecialChars(part) {
|
|
61762
|
+
return SPEC_CHAR_REGEX.test(part)
|
|
61763
|
+
}
|
|
61764
|
+
|
|
61765
|
+
function shouldBeQuoted(part) {
|
|
61766
|
+
return !isQuoted(part) && (hasLeadingNumber(part) || hasSpecialChars(part))
|
|
61767
|
+
}
|
|
61768
|
+
return propertyExpr;
|
|
61769
|
+
}
|
|
61770
|
+
|
|
61771
|
+
var propertyExprExports = requirePropertyExpr();
|
|
61772
|
+
|
|
61773
|
+
var tinyCase;
|
|
61774
|
+
var hasRequiredTinyCase;
|
|
61775
|
+
|
|
61776
|
+
function requireTinyCase () {
|
|
61777
|
+
if (hasRequiredTinyCase) return tinyCase;
|
|
61778
|
+
hasRequiredTinyCase = 1;
|
|
61779
|
+
const reWords = /[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g;
|
|
61780
|
+
|
|
61781
|
+
const words = (str) => str.match(reWords) || [];
|
|
61782
|
+
|
|
61783
|
+
const upperFirst = (str) => str[0].toUpperCase() + str.slice(1);
|
|
61784
|
+
|
|
61785
|
+
const join = (str, d) => words(str).join(d).toLowerCase();
|
|
61786
|
+
|
|
61787
|
+
const camelCase = (str) =>
|
|
61788
|
+
words(str).reduce(
|
|
61789
|
+
(acc, next) =>
|
|
61790
|
+
`${acc}${
|
|
61791
|
+
!acc
|
|
61792
|
+
? next.toLowerCase()
|
|
61793
|
+
: next[0].toUpperCase() + next.slice(1).toLowerCase()
|
|
61794
|
+
}`,
|
|
61795
|
+
'',
|
|
61796
|
+
);
|
|
61797
|
+
|
|
61798
|
+
const pascalCase = (str) => upperFirst(camelCase(str));
|
|
61799
|
+
|
|
61800
|
+
const snakeCase = (str) => join(str, '_');
|
|
61801
|
+
|
|
61802
|
+
const kebabCase = (str) => join(str, '-');
|
|
61803
|
+
|
|
61804
|
+
const sentenceCase = (str) => upperFirst(join(str, ' '));
|
|
61805
|
+
|
|
61806
|
+
const titleCase = (str) => words(str).map(upperFirst).join(' ');
|
|
61807
|
+
|
|
61808
|
+
tinyCase = {
|
|
61809
|
+
words,
|
|
61810
|
+
upperFirst,
|
|
61811
|
+
camelCase,
|
|
61812
|
+
pascalCase,
|
|
61813
|
+
snakeCase,
|
|
61814
|
+
kebabCase,
|
|
61815
|
+
sentenceCase,
|
|
61816
|
+
titleCase,
|
|
61817
|
+
};
|
|
61818
|
+
return tinyCase;
|
|
61819
|
+
}
|
|
61820
|
+
|
|
61821
|
+
var tinyCaseExports = requireTinyCase();
|
|
61822
|
+
|
|
61823
|
+
var toposort$1 = {exports: {}};
|
|
61824
|
+
|
|
61825
|
+
var hasRequiredToposort;
|
|
61826
|
+
|
|
61827
|
+
function requireToposort () {
|
|
61828
|
+
if (hasRequiredToposort) return toposort$1.exports;
|
|
61829
|
+
hasRequiredToposort = 1;
|
|
61830
|
+
/**
|
|
61831
|
+
* Topological sorting function
|
|
61832
|
+
*
|
|
61833
|
+
* @param {Array} edges
|
|
61834
|
+
* @returns {Array}
|
|
61835
|
+
*/
|
|
61836
|
+
|
|
61837
|
+
toposort$1.exports = function(edges) {
|
|
61838
|
+
return toposort(uniqueNodes(edges), edges)
|
|
61839
|
+
};
|
|
61840
|
+
|
|
61841
|
+
toposort$1.exports.array = toposort;
|
|
61842
|
+
|
|
61843
|
+
function toposort(nodes, edges) {
|
|
61844
|
+
var cursor = nodes.length
|
|
61845
|
+
, sorted = new Array(cursor)
|
|
61846
|
+
, visited = {}
|
|
61847
|
+
, i = cursor
|
|
61848
|
+
// Better data structures make algorithm much faster.
|
|
61849
|
+
, outgoingEdges = makeOutgoingEdges(edges)
|
|
61850
|
+
, nodesHash = makeNodesHash(nodes);
|
|
61851
|
+
|
|
61852
|
+
// check for unknown nodes
|
|
61853
|
+
edges.forEach(function(edge) {
|
|
61854
|
+
if (!nodesHash.has(edge[0]) || !nodesHash.has(edge[1])) {
|
|
61855
|
+
throw new Error('Unknown node. There is an unknown node in the supplied edges.')
|
|
61856
|
+
}
|
|
61857
|
+
});
|
|
61858
|
+
|
|
61859
|
+
while (i--) {
|
|
61860
|
+
if (!visited[i]) visit(nodes[i], i, new Set());
|
|
61861
|
+
}
|
|
61862
|
+
|
|
61863
|
+
return sorted
|
|
61864
|
+
|
|
61865
|
+
function visit(node, i, predecessors) {
|
|
61866
|
+
if(predecessors.has(node)) {
|
|
61867
|
+
var nodeRep;
|
|
61868
|
+
try {
|
|
61869
|
+
nodeRep = ", node was:" + JSON.stringify(node);
|
|
61870
|
+
} catch(e) {
|
|
61871
|
+
nodeRep = "";
|
|
61872
|
+
}
|
|
61873
|
+
throw new Error('Cyclic dependency' + nodeRep)
|
|
61874
|
+
}
|
|
61875
|
+
|
|
61876
|
+
if (!nodesHash.has(node)) {
|
|
61877
|
+
throw new Error('Found unknown node. Make sure to provided all involved nodes. Unknown node: '+JSON.stringify(node))
|
|
61878
|
+
}
|
|
61879
|
+
|
|
61880
|
+
if (visited[i]) return;
|
|
61881
|
+
visited[i] = true;
|
|
61882
|
+
|
|
61883
|
+
var outgoing = outgoingEdges.get(node) || new Set();
|
|
61884
|
+
outgoing = Array.from(outgoing);
|
|
61885
|
+
|
|
61886
|
+
if (i = outgoing.length) {
|
|
61887
|
+
predecessors.add(node);
|
|
61888
|
+
do {
|
|
61889
|
+
var child = outgoing[--i];
|
|
61890
|
+
visit(child, nodesHash.get(child), predecessors);
|
|
61891
|
+
} while (i)
|
|
61892
|
+
predecessors.delete(node);
|
|
61893
|
+
}
|
|
61894
|
+
|
|
61895
|
+
sorted[--cursor] = node;
|
|
61896
|
+
}
|
|
61897
|
+
}
|
|
61898
|
+
|
|
61899
|
+
function uniqueNodes(arr){
|
|
61900
|
+
var res = new Set();
|
|
61901
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
61902
|
+
var edge = arr[i];
|
|
61903
|
+
res.add(edge[0]);
|
|
61904
|
+
res.add(edge[1]);
|
|
61905
|
+
}
|
|
61906
|
+
return Array.from(res)
|
|
61907
|
+
}
|
|
61908
|
+
|
|
61909
|
+
function makeOutgoingEdges(arr){
|
|
61910
|
+
var edges = new Map();
|
|
61911
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
61912
|
+
var edge = arr[i];
|
|
61913
|
+
if (!edges.has(edge[0])) edges.set(edge[0], new Set());
|
|
61914
|
+
if (!edges.has(edge[1])) edges.set(edge[1], new Set());
|
|
61915
|
+
edges.get(edge[0]).add(edge[1]);
|
|
61916
|
+
}
|
|
61917
|
+
return edges
|
|
61918
|
+
}
|
|
61919
|
+
|
|
61920
|
+
function makeNodesHash(arr){
|
|
61921
|
+
var res = new Map();
|
|
61922
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
61923
|
+
res.set(arr[i], i);
|
|
61924
|
+
}
|
|
61925
|
+
return res
|
|
61926
|
+
}
|
|
61927
|
+
return toposort$1.exports;
|
|
61928
|
+
}
|
|
61929
|
+
|
|
61930
|
+
var toposortExports = requireToposort();
|
|
61931
|
+
var toposort = /*@__PURE__*/getDefaultExportFromCjs(toposortExports);
|
|
61932
|
+
|
|
61933
|
+
const toString = Object.prototype.toString;
|
|
61934
|
+
const errorToString = Error.prototype.toString;
|
|
61935
|
+
const regExpToString = RegExp.prototype.toString;
|
|
61936
|
+
const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString : () => '';
|
|
61937
|
+
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
|
61938
|
+
function printNumber(val) {
|
|
61939
|
+
if (val != +val) return 'NaN';
|
|
61940
|
+
const isNegativeZero = val === 0 && 1 / val < 0;
|
|
61941
|
+
return isNegativeZero ? '-0' : '' + val;
|
|
61942
|
+
}
|
|
61943
|
+
function printSimpleValue(val, quoteStrings = false) {
|
|
61944
|
+
if (val == null || val === true || val === false) return '' + val;
|
|
61945
|
+
const typeOf = typeof val;
|
|
61946
|
+
if (typeOf === 'number') return printNumber(val);
|
|
61947
|
+
if (typeOf === 'string') return quoteStrings ? `"${val}"` : val;
|
|
61948
|
+
if (typeOf === 'function') return '[Function ' + (val.name || 'anonymous') + ']';
|
|
61949
|
+
if (typeOf === 'symbol') return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
|
|
61950
|
+
const tag = toString.call(val).slice(8, -1);
|
|
61951
|
+
if (tag === 'Date') return isNaN(val.getTime()) ? '' + val : val.toISOString(val);
|
|
61952
|
+
if (tag === 'Error' || val instanceof Error) return '[' + errorToString.call(val) + ']';
|
|
61953
|
+
if (tag === 'RegExp') return regExpToString.call(val);
|
|
61954
|
+
return null;
|
|
61955
|
+
}
|
|
61956
|
+
function printValue(value, quoteStrings) {
|
|
61957
|
+
let result = printSimpleValue(value, quoteStrings);
|
|
61958
|
+
if (result !== null) return result;
|
|
61959
|
+
return JSON.stringify(value, function (key, value) {
|
|
61960
|
+
let result = printSimpleValue(this[key], quoteStrings);
|
|
61961
|
+
if (result !== null) return result;
|
|
61962
|
+
return value;
|
|
61963
|
+
}, 2);
|
|
61964
|
+
}
|
|
61965
|
+
|
|
61966
|
+
function toArray(value) {
|
|
61967
|
+
return value == null ? [] : [].concat(value);
|
|
61968
|
+
}
|
|
61969
|
+
|
|
61970
|
+
let _Symbol$toStringTag, _Symbol$hasInstance, _Symbol$toStringTag2;
|
|
61971
|
+
let strReg = /\$\{\s*(\w+)\s*\}/g;
|
|
61972
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
61973
|
+
class ValidationErrorNoStack {
|
|
61974
|
+
constructor(errorOrErrors, value, field, type) {
|
|
61975
|
+
this.name = void 0;
|
|
61976
|
+
this.message = void 0;
|
|
61977
|
+
this.value = void 0;
|
|
61978
|
+
this.path = void 0;
|
|
61979
|
+
this.type = void 0;
|
|
61980
|
+
this.params = void 0;
|
|
61981
|
+
this.errors = void 0;
|
|
61982
|
+
this.inner = void 0;
|
|
61983
|
+
this[_Symbol$toStringTag] = 'Error';
|
|
61984
|
+
this.name = 'ValidationError';
|
|
61985
|
+
this.value = value;
|
|
61986
|
+
this.path = field;
|
|
61987
|
+
this.type = type;
|
|
61988
|
+
this.errors = [];
|
|
61989
|
+
this.inner = [];
|
|
61990
|
+
toArray(errorOrErrors).forEach(err => {
|
|
61991
|
+
if (ValidationError.isError(err)) {
|
|
61992
|
+
this.errors.push(...err.errors);
|
|
61993
|
+
const innerErrors = err.inner.length ? err.inner : [err];
|
|
61994
|
+
this.inner.push(...innerErrors);
|
|
61995
|
+
} else {
|
|
61996
|
+
this.errors.push(err);
|
|
61997
|
+
}
|
|
61998
|
+
});
|
|
61999
|
+
this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
|
|
62000
|
+
}
|
|
62001
|
+
}
|
|
62002
|
+
_Symbol$hasInstance = Symbol.hasInstance;
|
|
62003
|
+
_Symbol$toStringTag2 = Symbol.toStringTag;
|
|
62004
|
+
class ValidationError extends Error {
|
|
62005
|
+
static formatError(message, params) {
|
|
62006
|
+
// Attempt to make the path more friendly for error message interpolation.
|
|
62007
|
+
const path = params.label || params.path || 'this';
|
|
62008
|
+
// Store the original path under `originalPath` so it isn't lost to custom
|
|
62009
|
+
// message functions; e.g., ones provided in `setLocale()` calls.
|
|
62010
|
+
params = Object.assign({}, params, {
|
|
62011
|
+
path,
|
|
62012
|
+
originalPath: params.path
|
|
62013
|
+
});
|
|
62014
|
+
if (typeof message === 'string') return message.replace(strReg, (_, key) => printValue(params[key]));
|
|
62015
|
+
if (typeof message === 'function') return message(params);
|
|
62016
|
+
return message;
|
|
62017
|
+
}
|
|
62018
|
+
static isError(err) {
|
|
62019
|
+
return err && err.name === 'ValidationError';
|
|
62020
|
+
}
|
|
62021
|
+
constructor(errorOrErrors, value, field, type, disableStack) {
|
|
62022
|
+
const errorNoStack = new ValidationErrorNoStack(errorOrErrors, value, field, type);
|
|
62023
|
+
if (disableStack) {
|
|
62024
|
+
return errorNoStack;
|
|
62025
|
+
}
|
|
62026
|
+
super();
|
|
62027
|
+
this.value = void 0;
|
|
62028
|
+
this.path = void 0;
|
|
62029
|
+
this.type = void 0;
|
|
62030
|
+
this.params = void 0;
|
|
62031
|
+
this.errors = [];
|
|
62032
|
+
this.inner = [];
|
|
62033
|
+
this[_Symbol$toStringTag2] = 'Error';
|
|
62034
|
+
this.name = errorNoStack.name;
|
|
62035
|
+
this.message = errorNoStack.message;
|
|
62036
|
+
this.type = errorNoStack.type;
|
|
62037
|
+
this.value = errorNoStack.value;
|
|
62038
|
+
this.path = errorNoStack.path;
|
|
62039
|
+
this.errors = errorNoStack.errors;
|
|
62040
|
+
this.inner = errorNoStack.inner;
|
|
62041
|
+
if (Error.captureStackTrace) {
|
|
62042
|
+
Error.captureStackTrace(this, ValidationError);
|
|
62043
|
+
}
|
|
62044
|
+
}
|
|
62045
|
+
static [_Symbol$hasInstance](inst) {
|
|
62046
|
+
return ValidationErrorNoStack[Symbol.hasInstance](inst) || super[Symbol.hasInstance](inst);
|
|
62047
|
+
}
|
|
62048
|
+
}
|
|
62049
|
+
|
|
62050
|
+
let mixed = {
|
|
62051
|
+
default: '${path} is invalid',
|
|
62052
|
+
required: '${path} is a required field',
|
|
62053
|
+
defined: '${path} must be defined',
|
|
62054
|
+
notNull: '${path} cannot be null',
|
|
62055
|
+
oneOf: '${path} must be one of the following values: ${values}',
|
|
62056
|
+
notOneOf: '${path} must not be one of the following values: ${values}',
|
|
62057
|
+
notType: ({
|
|
62058
|
+
path,
|
|
62059
|
+
type,
|
|
62060
|
+
value,
|
|
62061
|
+
originalValue
|
|
62062
|
+
}) => {
|
|
62063
|
+
const castMsg = originalValue != null && originalValue !== value ? ` (cast from the value \`${printValue(originalValue, true)}\`).` : '.';
|
|
62064
|
+
return type !== 'mixed' ? `${path} must be a \`${type}\` type, ` + `but the final value was: \`${printValue(value, true)}\`` + castMsg : `${path} must match the configured type. ` + `The validated value was: \`${printValue(value, true)}\`` + castMsg;
|
|
62065
|
+
}
|
|
62066
|
+
};
|
|
62067
|
+
let string = {
|
|
62068
|
+
length: '${path} must be exactly ${length} characters',
|
|
62069
|
+
min: '${path} must be at least ${min} characters',
|
|
62070
|
+
max: '${path} must be at most ${max} characters',
|
|
62071
|
+
matches: '${path} must match the following: "${regex}"',
|
|
62072
|
+
email: '${path} must be a valid email',
|
|
62073
|
+
url: '${path} must be a valid URL',
|
|
62074
|
+
uuid: '${path} must be a valid UUID',
|
|
62075
|
+
datetime: '${path} must be a valid ISO date-time',
|
|
62076
|
+
datetime_precision: '${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits',
|
|
62077
|
+
datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone',
|
|
62078
|
+
trim: '${path} must be a trimmed string',
|
|
62079
|
+
lowercase: '${path} must be a lowercase string',
|
|
62080
|
+
uppercase: '${path} must be a upper case string'
|
|
62081
|
+
};
|
|
62082
|
+
let number = {
|
|
62083
|
+
min: '${path} must be greater than or equal to ${min}',
|
|
62084
|
+
max: '${path} must be less than or equal to ${max}',
|
|
62085
|
+
lessThan: '${path} must be less than ${less}',
|
|
62086
|
+
moreThan: '${path} must be greater than ${more}',
|
|
62087
|
+
positive: '${path} must be a positive number',
|
|
62088
|
+
negative: '${path} must be a negative number',
|
|
62089
|
+
integer: '${path} must be an integer'
|
|
62090
|
+
};
|
|
62091
|
+
let date = {
|
|
62092
|
+
min: '${path} field must be later than ${min}',
|
|
62093
|
+
max: '${path} field must be at earlier than ${max}'
|
|
62094
|
+
};
|
|
62095
|
+
let boolean = {
|
|
62096
|
+
isValue: '${path} field must be ${value}'
|
|
62097
|
+
};
|
|
62098
|
+
let object = {
|
|
62099
|
+
noUnknown: '${path} field has unspecified keys: ${unknown}',
|
|
62100
|
+
exact: '${path} object contains unknown properties: ${properties}'
|
|
62101
|
+
};
|
|
62102
|
+
let array = {
|
|
62103
|
+
min: '${path} field must have at least ${min} items',
|
|
62104
|
+
max: '${path} field must have less than or equal to ${max} items',
|
|
62105
|
+
length: '${path} must have ${length} items'
|
|
62106
|
+
};
|
|
62107
|
+
let tuple = {
|
|
62108
|
+
notType: params => {
|
|
62109
|
+
const {
|
|
62110
|
+
path,
|
|
62111
|
+
value,
|
|
62112
|
+
spec
|
|
62113
|
+
} = params;
|
|
62114
|
+
const typeLen = spec.types.length;
|
|
62115
|
+
if (Array.isArray(value)) {
|
|
62116
|
+
if (value.length < typeLen) return `${path} tuple value has too few items, expected a length of ${typeLen} but got ${value.length} for value: \`${printValue(value, true)}\``;
|
|
62117
|
+
if (value.length > typeLen) return `${path} tuple value has too many items, expected a length of ${typeLen} but got ${value.length} for value: \`${printValue(value, true)}\``;
|
|
62118
|
+
}
|
|
62119
|
+
return ValidationError.formatError(mixed.notType, params);
|
|
62120
|
+
}
|
|
62121
|
+
};
|
|
62122
|
+
Object.assign(Object.create(null), {
|
|
62123
|
+
mixed,
|
|
62124
|
+
string,
|
|
62125
|
+
number,
|
|
62126
|
+
date,
|
|
62127
|
+
object,
|
|
62128
|
+
array,
|
|
62129
|
+
boolean,
|
|
62130
|
+
tuple
|
|
62131
|
+
});
|
|
62132
|
+
|
|
62133
|
+
const isSchema = obj => obj && obj.__isYupSchema__;
|
|
62134
|
+
|
|
62135
|
+
class Condition {
|
|
62136
|
+
static fromOptions(refs, config) {
|
|
62137
|
+
if (!config.then && !config.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions');
|
|
62138
|
+
let {
|
|
62139
|
+
is,
|
|
62140
|
+
then,
|
|
62141
|
+
otherwise
|
|
62142
|
+
} = config;
|
|
62143
|
+
let check = typeof is === 'function' ? is : (...values) => values.every(value => value === is);
|
|
62144
|
+
return new Condition(refs, (values, schema) => {
|
|
62145
|
+
var _branch;
|
|
62146
|
+
let branch = check(...values) ? then : otherwise;
|
|
62147
|
+
return (_branch = branch == null ? void 0 : branch(schema)) != null ? _branch : schema;
|
|
62148
|
+
});
|
|
62149
|
+
}
|
|
62150
|
+
constructor(refs, builder) {
|
|
62151
|
+
this.fn = void 0;
|
|
62152
|
+
this.refs = refs;
|
|
62153
|
+
this.refs = refs;
|
|
62154
|
+
this.fn = builder;
|
|
62155
|
+
}
|
|
62156
|
+
resolve(base, options) {
|
|
62157
|
+
let values = this.refs.map(ref =>
|
|
62158
|
+
// TODO: ? operator here?
|
|
62159
|
+
ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
|
|
62160
|
+
let schema = this.fn(values, base, options);
|
|
62161
|
+
if (schema === undefined ||
|
|
62162
|
+
// @ts-ignore this can be base
|
|
62163
|
+
schema === base) {
|
|
62164
|
+
return base;
|
|
62165
|
+
}
|
|
62166
|
+
if (!isSchema(schema)) throw new TypeError('conditions must return a schema object');
|
|
62167
|
+
return schema.resolve(options);
|
|
62168
|
+
}
|
|
62169
|
+
}
|
|
62170
|
+
|
|
62171
|
+
const prefixes = {
|
|
62172
|
+
context: '$',
|
|
62173
|
+
value: '.'
|
|
62174
|
+
};
|
|
62175
|
+
class Reference {
|
|
62176
|
+
constructor(key, options = {}) {
|
|
62177
|
+
this.key = void 0;
|
|
62178
|
+
this.isContext = void 0;
|
|
62179
|
+
this.isValue = void 0;
|
|
62180
|
+
this.isSibling = void 0;
|
|
62181
|
+
this.path = void 0;
|
|
62182
|
+
this.getter = void 0;
|
|
62183
|
+
this.map = void 0;
|
|
62184
|
+
if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key);
|
|
62185
|
+
this.key = key.trim();
|
|
62186
|
+
if (key === '') throw new TypeError('ref must be a non-empty string');
|
|
62187
|
+
this.isContext = this.key[0] === prefixes.context;
|
|
62188
|
+
this.isValue = this.key[0] === prefixes.value;
|
|
62189
|
+
this.isSibling = !this.isContext && !this.isValue;
|
|
62190
|
+
let prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : '';
|
|
62191
|
+
this.path = this.key.slice(prefix.length);
|
|
62192
|
+
this.getter = this.path && propertyExprExports.getter(this.path, true);
|
|
62193
|
+
this.map = options.map;
|
|
62194
|
+
}
|
|
62195
|
+
getValue(value, parent, context) {
|
|
62196
|
+
let result = this.isContext ? context : this.isValue ? value : parent;
|
|
62197
|
+
if (this.getter) result = this.getter(result || {});
|
|
62198
|
+
if (this.map) result = this.map(result);
|
|
62199
|
+
return result;
|
|
62200
|
+
}
|
|
62201
|
+
|
|
62202
|
+
/**
|
|
62203
|
+
*
|
|
62204
|
+
* @param {*} value
|
|
62205
|
+
* @param {Object} options
|
|
62206
|
+
* @param {Object=} options.context
|
|
62207
|
+
* @param {Object=} options.parent
|
|
62208
|
+
*/
|
|
62209
|
+
cast(value, options) {
|
|
62210
|
+
return this.getValue(value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context);
|
|
62211
|
+
}
|
|
62212
|
+
resolve() {
|
|
62213
|
+
return this;
|
|
62214
|
+
}
|
|
62215
|
+
describe() {
|
|
62216
|
+
return {
|
|
62217
|
+
type: 'ref',
|
|
62218
|
+
key: this.key
|
|
62219
|
+
};
|
|
62220
|
+
}
|
|
62221
|
+
toString() {
|
|
62222
|
+
return `Ref(${this.key})`;
|
|
62223
|
+
}
|
|
62224
|
+
static isRef(value) {
|
|
62225
|
+
return value && value.__isYupRef;
|
|
62226
|
+
}
|
|
62227
|
+
}
|
|
62228
|
+
|
|
62229
|
+
// @ts-ignore
|
|
62230
|
+
Reference.prototype.__isYupRef = true;
|
|
62231
|
+
|
|
62232
|
+
const isAbsent = value => value == null;
|
|
62233
|
+
|
|
62234
|
+
function createValidation(config) {
|
|
62235
|
+
function validate({
|
|
62236
|
+
value,
|
|
62237
|
+
path = '',
|
|
62238
|
+
options,
|
|
62239
|
+
originalValue,
|
|
62240
|
+
schema
|
|
62241
|
+
}, panic, next) {
|
|
62242
|
+
const {
|
|
62243
|
+
name,
|
|
62244
|
+
test,
|
|
62245
|
+
params,
|
|
62246
|
+
message,
|
|
62247
|
+
skipAbsent
|
|
62248
|
+
} = config;
|
|
62249
|
+
let {
|
|
62250
|
+
parent,
|
|
62251
|
+
context,
|
|
62252
|
+
abortEarly = schema.spec.abortEarly,
|
|
62253
|
+
disableStackTrace = schema.spec.disableStackTrace
|
|
62254
|
+
} = options;
|
|
62255
|
+
const resolveOptions = {
|
|
62256
|
+
value,
|
|
62257
|
+
parent,
|
|
62258
|
+
context
|
|
62259
|
+
};
|
|
62260
|
+
function createError(overrides = {}) {
|
|
62261
|
+
const nextParams = resolveParams(Object.assign({
|
|
62262
|
+
value,
|
|
62263
|
+
originalValue,
|
|
62264
|
+
label: schema.spec.label,
|
|
62265
|
+
path: overrides.path || path,
|
|
62266
|
+
spec: schema.spec,
|
|
62267
|
+
disableStackTrace: overrides.disableStackTrace || disableStackTrace
|
|
62268
|
+
}, params, overrides.params), resolveOptions);
|
|
62269
|
+
const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name, nextParams.disableStackTrace);
|
|
62270
|
+
error.params = nextParams;
|
|
62271
|
+
return error;
|
|
62272
|
+
}
|
|
62273
|
+
const invalid = abortEarly ? panic : next;
|
|
62274
|
+
let ctx = {
|
|
62275
|
+
path,
|
|
62276
|
+
parent,
|
|
62277
|
+
type: name,
|
|
62278
|
+
from: options.from,
|
|
62279
|
+
createError,
|
|
62280
|
+
resolve(item) {
|
|
62281
|
+
return resolveMaybeRef(item, resolveOptions);
|
|
62282
|
+
},
|
|
62283
|
+
options,
|
|
62284
|
+
originalValue,
|
|
62285
|
+
schema
|
|
62286
|
+
};
|
|
62287
|
+
const handleResult = validOrError => {
|
|
62288
|
+
if (ValidationError.isError(validOrError)) invalid(validOrError);else if (!validOrError) invalid(createError());else next(null);
|
|
62289
|
+
};
|
|
62290
|
+
const handleError = err => {
|
|
62291
|
+
if (ValidationError.isError(err)) invalid(err);else panic(err);
|
|
62292
|
+
};
|
|
62293
|
+
const shouldSkip = skipAbsent && isAbsent(value);
|
|
62294
|
+
if (shouldSkip) {
|
|
62295
|
+
return handleResult(true);
|
|
62296
|
+
}
|
|
62297
|
+
let result;
|
|
62298
|
+
try {
|
|
62299
|
+
var _result;
|
|
62300
|
+
result = test.call(ctx, value, ctx);
|
|
62301
|
+
if (typeof ((_result = result) == null ? void 0 : _result.then) === 'function') {
|
|
62302
|
+
if (options.sync) {
|
|
62303
|
+
throw new Error(`Validation test of type: "${ctx.type}" returned a Promise during a synchronous validate. ` + `This test will finish after the validate call has returned`);
|
|
62304
|
+
}
|
|
62305
|
+
return Promise.resolve(result).then(handleResult, handleError);
|
|
62306
|
+
}
|
|
62307
|
+
} catch (err) {
|
|
62308
|
+
handleError(err);
|
|
62309
|
+
return;
|
|
62310
|
+
}
|
|
62311
|
+
handleResult(result);
|
|
62312
|
+
}
|
|
62313
|
+
validate.OPTIONS = config;
|
|
62314
|
+
return validate;
|
|
62315
|
+
}
|
|
62316
|
+
|
|
62317
|
+
// Warning: mutates the input
|
|
62318
|
+
function resolveParams(params, options) {
|
|
62319
|
+
if (!params) return params;
|
|
62320
|
+
for (const key of Object.keys(params)) {
|
|
62321
|
+
params[key] = resolveMaybeRef(params[key], options);
|
|
62322
|
+
}
|
|
62323
|
+
return params;
|
|
62324
|
+
}
|
|
62325
|
+
function resolveMaybeRef(item, options) {
|
|
62326
|
+
return Reference.isRef(item) ? item.getValue(options.value, options.parent, options.context) : item;
|
|
62327
|
+
}
|
|
62328
|
+
|
|
62329
|
+
function getIn(schema, path, value, context = value) {
|
|
62330
|
+
let parent, lastPart, lastPartDebug;
|
|
62331
|
+
|
|
62332
|
+
// root path: ''
|
|
62333
|
+
if (!path) return {
|
|
62334
|
+
parent,
|
|
62335
|
+
parentPath: path,
|
|
62336
|
+
schema
|
|
62337
|
+
};
|
|
62338
|
+
propertyExprExports.forEach(path, (_part, isBracket, isArray) => {
|
|
62339
|
+
let part = isBracket ? _part.slice(1, _part.length - 1) : _part;
|
|
62340
|
+
schema = schema.resolve({
|
|
62341
|
+
context,
|
|
62342
|
+
parent,
|
|
62343
|
+
value
|
|
62344
|
+
});
|
|
62345
|
+
let isTuple = schema.type === 'tuple';
|
|
62346
|
+
let idx = isArray ? parseInt(part, 10) : 0;
|
|
62347
|
+
if (schema.innerType || isTuple) {
|
|
62348
|
+
if (isTuple && !isArray) throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${lastPartDebug}" must contain an index to the tuple element, e.g. "${lastPartDebug}[0]"`);
|
|
62349
|
+
if (value && idx >= value.length) {
|
|
62350
|
+
throw new Error(`Yup.reach cannot resolve an array item at index: ${_part}, in the path: ${path}. ` + `because there is no value at that index. `);
|
|
62351
|
+
}
|
|
62352
|
+
parent = value;
|
|
62353
|
+
value = value && value[idx];
|
|
62354
|
+
schema = isTuple ? schema.spec.types[idx] : schema.innerType;
|
|
62355
|
+
}
|
|
62356
|
+
|
|
62357
|
+
// sometimes the array index part of a path doesn't exist: "nested.arr.child"
|
|
62358
|
+
// in these cases the current part is the next schema and should be processed
|
|
62359
|
+
// in this iteration. For cases where the index signature is included this
|
|
62360
|
+
// check will fail and we'll handle the `child` part on the next iteration like normal
|
|
62361
|
+
if (!isArray) {
|
|
62362
|
+
if (!schema.fields || !schema.fields[part]) throw new Error(`The schema does not contain the path: ${path}. ` + `(failed at: ${lastPartDebug} which is a type: "${schema.type}")`);
|
|
62363
|
+
parent = value;
|
|
62364
|
+
value = value && value[part];
|
|
62365
|
+
schema = schema.fields[part];
|
|
62366
|
+
}
|
|
62367
|
+
lastPart = part;
|
|
62368
|
+
lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
|
|
62369
|
+
});
|
|
62370
|
+
return {
|
|
62371
|
+
schema,
|
|
62372
|
+
parent,
|
|
62373
|
+
parentPath: lastPart
|
|
62374
|
+
};
|
|
62375
|
+
}
|
|
62376
|
+
|
|
62377
|
+
class ReferenceSet extends Set {
|
|
62378
|
+
describe() {
|
|
62379
|
+
const description = [];
|
|
62380
|
+
for (const item of this.values()) {
|
|
62381
|
+
description.push(Reference.isRef(item) ? item.describe() : item);
|
|
62382
|
+
}
|
|
62383
|
+
return description;
|
|
62384
|
+
}
|
|
62385
|
+
resolveAll(resolve) {
|
|
62386
|
+
let result = [];
|
|
62387
|
+
for (const item of this.values()) {
|
|
62388
|
+
result.push(resolve(item));
|
|
62389
|
+
}
|
|
62390
|
+
return result;
|
|
62391
|
+
}
|
|
62392
|
+
clone() {
|
|
62393
|
+
return new ReferenceSet(this.values());
|
|
62394
|
+
}
|
|
62395
|
+
merge(newItems, removeItems) {
|
|
62396
|
+
const next = this.clone();
|
|
62397
|
+
newItems.forEach(value => next.add(value));
|
|
62398
|
+
removeItems.forEach(value => next.delete(value));
|
|
62399
|
+
return next;
|
|
62400
|
+
}
|
|
62401
|
+
}
|
|
62402
|
+
|
|
62403
|
+
// tweaked from https://github.com/Kelin2025/nanoclone/blob/0abeb7635bda9b68ef2277093f76dbe3bf3948e1/src/index.js
|
|
62404
|
+
function clone(src, seen = new Map()) {
|
|
62405
|
+
if (isSchema(src) || !src || typeof src !== 'object') return src;
|
|
62406
|
+
if (seen.has(src)) return seen.get(src);
|
|
62407
|
+
let copy;
|
|
62408
|
+
if (src instanceof Date) {
|
|
62409
|
+
// Date
|
|
62410
|
+
copy = new Date(src.getTime());
|
|
62411
|
+
seen.set(src, copy);
|
|
62412
|
+
} else if (src instanceof RegExp) {
|
|
62413
|
+
// RegExp
|
|
62414
|
+
copy = new RegExp(src);
|
|
62415
|
+
seen.set(src, copy);
|
|
62416
|
+
} else if (Array.isArray(src)) {
|
|
62417
|
+
// Array
|
|
62418
|
+
copy = new Array(src.length);
|
|
62419
|
+
seen.set(src, copy);
|
|
62420
|
+
for (let i = 0; i < src.length; i++) copy[i] = clone(src[i], seen);
|
|
62421
|
+
} else if (src instanceof Map) {
|
|
62422
|
+
// Map
|
|
62423
|
+
copy = new Map();
|
|
62424
|
+
seen.set(src, copy);
|
|
62425
|
+
for (const [k, v] of src.entries()) copy.set(k, clone(v, seen));
|
|
62426
|
+
} else if (src instanceof Set) {
|
|
62427
|
+
// Set
|
|
62428
|
+
copy = new Set();
|
|
62429
|
+
seen.set(src, copy);
|
|
62430
|
+
for (const v of src) copy.add(clone(v, seen));
|
|
62431
|
+
} else if (src instanceof Object) {
|
|
62432
|
+
// Object
|
|
62433
|
+
copy = {};
|
|
62434
|
+
seen.set(src, copy);
|
|
62435
|
+
for (const [k, v] of Object.entries(src)) copy[k] = clone(v, seen);
|
|
62436
|
+
} else {
|
|
62437
|
+
throw Error(`Unable to clone ${src}`);
|
|
62438
|
+
}
|
|
62439
|
+
return copy;
|
|
62440
|
+
}
|
|
62441
|
+
|
|
62442
|
+
/**
|
|
62443
|
+
* Copied from @standard-schema/spec to avoid having a dependency on it.
|
|
62444
|
+
* https://github.com/standard-schema/standard-schema/blob/main/packages/spec/src/index.ts
|
|
62445
|
+
*/
|
|
62446
|
+
|
|
62447
|
+
function createStandardPath(path) {
|
|
62448
|
+
if (!(path != null && path.length)) {
|
|
62449
|
+
return undefined;
|
|
62450
|
+
}
|
|
62451
|
+
|
|
62452
|
+
// Array to store the final path segments
|
|
62453
|
+
const segments = [];
|
|
62454
|
+
// Buffer for building the current segment
|
|
62455
|
+
let currentSegment = '';
|
|
62456
|
+
// Track if we're inside square brackets (array/property access)
|
|
62457
|
+
let inBrackets = false;
|
|
62458
|
+
// Track if we're inside quotes (for property names with special chars)
|
|
62459
|
+
let inQuotes = false;
|
|
62460
|
+
for (let i = 0; i < path.length; i++) {
|
|
62461
|
+
const char = path[i];
|
|
62462
|
+
if (char === '[' && !inQuotes) {
|
|
62463
|
+
// When entering brackets, push any accumulated segment after splitting on dots
|
|
62464
|
+
if (currentSegment) {
|
|
62465
|
+
segments.push(...currentSegment.split('.').filter(Boolean));
|
|
62466
|
+
currentSegment = '';
|
|
62467
|
+
}
|
|
62468
|
+
inBrackets = true;
|
|
62469
|
+
continue;
|
|
62470
|
+
}
|
|
62471
|
+
if (char === ']' && !inQuotes) {
|
|
62472
|
+
if (currentSegment) {
|
|
62473
|
+
// Handle numeric indices (e.g. arr[0])
|
|
62474
|
+
if (/^\d+$/.test(currentSegment)) {
|
|
62475
|
+
segments.push(currentSegment);
|
|
62476
|
+
} else {
|
|
62477
|
+
// Handle quoted property names (e.g. obj["foo.bar"])
|
|
62478
|
+
segments.push(currentSegment.replace(/^"|"$/g, ''));
|
|
62479
|
+
}
|
|
62480
|
+
currentSegment = '';
|
|
62481
|
+
}
|
|
62482
|
+
inBrackets = false;
|
|
62483
|
+
continue;
|
|
62484
|
+
}
|
|
62485
|
+
if (char === '"') {
|
|
62486
|
+
// Toggle quote state for handling quoted property names
|
|
62487
|
+
inQuotes = !inQuotes;
|
|
62488
|
+
continue;
|
|
62489
|
+
}
|
|
62490
|
+
if (char === '.' && !inBrackets && !inQuotes) {
|
|
62491
|
+
// On dots outside brackets/quotes, push current segment
|
|
62492
|
+
if (currentSegment) {
|
|
62493
|
+
segments.push(currentSegment);
|
|
62494
|
+
currentSegment = '';
|
|
62495
|
+
}
|
|
62496
|
+
continue;
|
|
62497
|
+
}
|
|
62498
|
+
currentSegment += char;
|
|
62499
|
+
}
|
|
62500
|
+
|
|
62501
|
+
// Push any remaining segment after splitting on dots
|
|
62502
|
+
if (currentSegment) {
|
|
62503
|
+
segments.push(...currentSegment.split('.').filter(Boolean));
|
|
62504
|
+
}
|
|
62505
|
+
return segments;
|
|
62506
|
+
}
|
|
62507
|
+
function createStandardIssues(error, parentPath) {
|
|
62508
|
+
const path = parentPath ? `${parentPath}.${error.path}` : error.path;
|
|
62509
|
+
return error.errors.map(err => ({
|
|
62510
|
+
message: err,
|
|
62511
|
+
path: createStandardPath(path)
|
|
62512
|
+
}));
|
|
62513
|
+
}
|
|
62514
|
+
function issuesFromValidationError(error, parentPath) {
|
|
62515
|
+
var _error$inner;
|
|
62516
|
+
if (!((_error$inner = error.inner) != null && _error$inner.length) && error.errors.length) {
|
|
62517
|
+
return createStandardIssues(error, parentPath);
|
|
62518
|
+
}
|
|
62519
|
+
const path = parentPath ? `${parentPath}.${error.path}` : error.path;
|
|
62520
|
+
return error.inner.flatMap(err => issuesFromValidationError(err, path));
|
|
62521
|
+
}
|
|
62522
|
+
|
|
62523
|
+
// If `CustomSchemaMeta` isn't extended with any keys, we'll fall back to a
|
|
62524
|
+
// loose Record definition allowing free form usage.
|
|
62525
|
+
class Schema {
|
|
62526
|
+
constructor(options) {
|
|
62527
|
+
this.type = void 0;
|
|
62528
|
+
this.deps = [];
|
|
62529
|
+
this.tests = void 0;
|
|
62530
|
+
this.transforms = void 0;
|
|
62531
|
+
this.conditions = [];
|
|
62532
|
+
this._mutate = void 0;
|
|
62533
|
+
this.internalTests = {};
|
|
62534
|
+
this._whitelist = new ReferenceSet();
|
|
62535
|
+
this._blacklist = new ReferenceSet();
|
|
62536
|
+
this.exclusiveTests = Object.create(null);
|
|
62537
|
+
this._typeCheck = void 0;
|
|
62538
|
+
this.spec = void 0;
|
|
62539
|
+
this.tests = [];
|
|
62540
|
+
this.transforms = [];
|
|
62541
|
+
this.withMutation(() => {
|
|
62542
|
+
this.typeError(mixed.notType);
|
|
62543
|
+
});
|
|
62544
|
+
this.type = options.type;
|
|
62545
|
+
this._typeCheck = options.check;
|
|
62546
|
+
this.spec = Object.assign({
|
|
62547
|
+
strip: false,
|
|
62548
|
+
strict: false,
|
|
62549
|
+
abortEarly: true,
|
|
62550
|
+
recursive: true,
|
|
62551
|
+
disableStackTrace: false,
|
|
62552
|
+
nullable: false,
|
|
62553
|
+
optional: true,
|
|
62554
|
+
coerce: true
|
|
62555
|
+
}, options == null ? void 0 : options.spec);
|
|
62556
|
+
this.withMutation(s => {
|
|
62557
|
+
s.nonNullable();
|
|
62558
|
+
});
|
|
62559
|
+
}
|
|
62560
|
+
|
|
62561
|
+
// TODO: remove
|
|
62562
|
+
get _type() {
|
|
62563
|
+
return this.type;
|
|
62564
|
+
}
|
|
62565
|
+
clone(spec) {
|
|
62566
|
+
if (this._mutate) {
|
|
62567
|
+
if (spec) Object.assign(this.spec, spec);
|
|
62568
|
+
return this;
|
|
62569
|
+
}
|
|
62570
|
+
|
|
62571
|
+
// if the nested value is a schema we can skip cloning, since
|
|
62572
|
+
// they are already immutable
|
|
62573
|
+
const next = Object.create(Object.getPrototypeOf(this));
|
|
62574
|
+
|
|
62575
|
+
// @ts-expect-error this is readonly
|
|
62576
|
+
next.type = this.type;
|
|
62577
|
+
next._typeCheck = this._typeCheck;
|
|
62578
|
+
next._whitelist = this._whitelist.clone();
|
|
62579
|
+
next._blacklist = this._blacklist.clone();
|
|
62580
|
+
next.internalTests = Object.assign({}, this.internalTests);
|
|
62581
|
+
next.exclusiveTests = Object.assign({}, this.exclusiveTests);
|
|
62582
|
+
|
|
62583
|
+
// @ts-expect-error this is readonly
|
|
62584
|
+
next.deps = [...this.deps];
|
|
62585
|
+
next.conditions = [...this.conditions];
|
|
62586
|
+
next.tests = [...this.tests];
|
|
62587
|
+
next.transforms = [...this.transforms];
|
|
62588
|
+
next.spec = clone(Object.assign({}, this.spec, spec));
|
|
62589
|
+
return next;
|
|
62590
|
+
}
|
|
62591
|
+
label(label) {
|
|
62592
|
+
let next = this.clone();
|
|
62593
|
+
next.spec.label = label;
|
|
62594
|
+
return next;
|
|
62595
|
+
}
|
|
62596
|
+
meta(...args) {
|
|
62597
|
+
if (args.length === 0) return this.spec.meta;
|
|
62598
|
+
let next = this.clone();
|
|
62599
|
+
next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
|
|
62600
|
+
return next;
|
|
62601
|
+
}
|
|
62602
|
+
withMutation(fn) {
|
|
62603
|
+
let before = this._mutate;
|
|
62604
|
+
this._mutate = true;
|
|
62605
|
+
let result = fn(this);
|
|
62606
|
+
this._mutate = before;
|
|
62607
|
+
return result;
|
|
62608
|
+
}
|
|
62609
|
+
concat(schema) {
|
|
62610
|
+
if (!schema || schema === this) return this;
|
|
62611
|
+
if (schema.type !== this.type && this.type !== 'mixed') throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
|
|
62612
|
+
let base = this;
|
|
62613
|
+
let combined = schema.clone();
|
|
62614
|
+
const mergedSpec = Object.assign({}, base.spec, combined.spec);
|
|
62615
|
+
combined.spec = mergedSpec;
|
|
62616
|
+
combined.internalTests = Object.assign({}, base.internalTests, combined.internalTests);
|
|
62617
|
+
|
|
62618
|
+
// manually merge the blacklist/whitelist (the other `schema` takes
|
|
62619
|
+
// precedence in case of conflicts)
|
|
62620
|
+
combined._whitelist = base._whitelist.merge(schema._whitelist, schema._blacklist);
|
|
62621
|
+
combined._blacklist = base._blacklist.merge(schema._blacklist, schema._whitelist);
|
|
62622
|
+
|
|
62623
|
+
// start with the current tests
|
|
62624
|
+
combined.tests = base.tests;
|
|
62625
|
+
combined.exclusiveTests = base.exclusiveTests;
|
|
62626
|
+
|
|
62627
|
+
// manually add the new tests to ensure
|
|
62628
|
+
// the deduping logic is consistent
|
|
62629
|
+
combined.withMutation(next => {
|
|
62630
|
+
schema.tests.forEach(fn => {
|
|
62631
|
+
next.test(fn.OPTIONS);
|
|
62632
|
+
});
|
|
62633
|
+
});
|
|
62634
|
+
combined.transforms = [...base.transforms, ...combined.transforms];
|
|
62635
|
+
return combined;
|
|
62636
|
+
}
|
|
62637
|
+
isType(v) {
|
|
62638
|
+
if (v == null) {
|
|
62639
|
+
if (this.spec.nullable && v === null) return true;
|
|
62640
|
+
if (this.spec.optional && v === undefined) return true;
|
|
62641
|
+
return false;
|
|
62642
|
+
}
|
|
62643
|
+
return this._typeCheck(v);
|
|
62644
|
+
}
|
|
62645
|
+
resolve(options) {
|
|
62646
|
+
let schema = this;
|
|
62647
|
+
if (schema.conditions.length) {
|
|
62648
|
+
let conditions = schema.conditions;
|
|
62649
|
+
schema = schema.clone();
|
|
62650
|
+
schema.conditions = [];
|
|
62651
|
+
schema = conditions.reduce((prevSchema, condition) => condition.resolve(prevSchema, options), schema);
|
|
62652
|
+
schema = schema.resolve(options);
|
|
62653
|
+
}
|
|
62654
|
+
return schema;
|
|
62655
|
+
}
|
|
62656
|
+
resolveOptions(options) {
|
|
62657
|
+
var _options$strict, _options$abortEarly, _options$recursive, _options$disableStack;
|
|
62658
|
+
return Object.assign({}, options, {
|
|
62659
|
+
from: options.from || [],
|
|
62660
|
+
strict: (_options$strict = options.strict) != null ? _options$strict : this.spec.strict,
|
|
62661
|
+
abortEarly: (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly,
|
|
62662
|
+
recursive: (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive,
|
|
62663
|
+
disableStackTrace: (_options$disableStack = options.disableStackTrace) != null ? _options$disableStack : this.spec.disableStackTrace
|
|
62664
|
+
});
|
|
62665
|
+
}
|
|
62666
|
+
|
|
62667
|
+
/**
|
|
62668
|
+
* Run the configured transform pipeline over an input value.
|
|
62669
|
+
*/
|
|
62670
|
+
|
|
62671
|
+
cast(value, options = {}) {
|
|
62672
|
+
let resolvedSchema = this.resolve(Object.assign({}, options, {
|
|
62673
|
+
value
|
|
62674
|
+
// parent: options.parent,
|
|
62675
|
+
// context: options.context,
|
|
62676
|
+
}));
|
|
62677
|
+
|
|
62678
|
+
let allowOptionality = options.assert === 'ignore-optionality';
|
|
62679
|
+
let result = resolvedSchema._cast(value, options);
|
|
62680
|
+
if (options.assert !== false && !resolvedSchema.isType(result)) {
|
|
62681
|
+
if (allowOptionality && isAbsent(result)) {
|
|
62682
|
+
return result;
|
|
62683
|
+
}
|
|
62684
|
+
let formattedValue = printValue(value);
|
|
62685
|
+
let formattedResult = printValue(result);
|
|
62686
|
+
throw new TypeError(`The value of ${options.path || 'field'} could not be cast to a value ` + `that satisfies the schema type: "${resolvedSchema.type}". \n\n` + `attempted value: ${formattedValue} \n` + (formattedResult !== formattedValue ? `result of cast: ${formattedResult}` : ''));
|
|
62687
|
+
}
|
|
62688
|
+
return result;
|
|
62689
|
+
}
|
|
62690
|
+
_cast(rawValue, options) {
|
|
62691
|
+
let value = rawValue === undefined ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this, options), rawValue);
|
|
62692
|
+
if (value === undefined) {
|
|
62693
|
+
value = this.getDefault(options);
|
|
62694
|
+
}
|
|
62695
|
+
return value;
|
|
62696
|
+
}
|
|
62697
|
+
_validate(_value, options = {}, panic, next) {
|
|
62698
|
+
let {
|
|
62699
|
+
path,
|
|
62700
|
+
originalValue = _value,
|
|
62701
|
+
strict = this.spec.strict
|
|
62702
|
+
} = options;
|
|
62703
|
+
let value = _value;
|
|
62704
|
+
if (!strict) {
|
|
62705
|
+
value = this._cast(value, Object.assign({
|
|
62706
|
+
assert: false
|
|
62707
|
+
}, options));
|
|
62708
|
+
}
|
|
62709
|
+
let initialTests = [];
|
|
62710
|
+
for (let test of Object.values(this.internalTests)) {
|
|
62711
|
+
if (test) initialTests.push(test);
|
|
62712
|
+
}
|
|
62713
|
+
this.runTests({
|
|
62714
|
+
path,
|
|
62715
|
+
value,
|
|
62716
|
+
originalValue,
|
|
62717
|
+
options,
|
|
62718
|
+
tests: initialTests
|
|
62719
|
+
}, panic, initialErrors => {
|
|
62720
|
+
// even if we aren't ending early we can't proceed further if the types aren't correct
|
|
62721
|
+
if (initialErrors.length) {
|
|
62722
|
+
return next(initialErrors, value);
|
|
62723
|
+
}
|
|
62724
|
+
this.runTests({
|
|
62725
|
+
path,
|
|
62726
|
+
value,
|
|
62727
|
+
originalValue,
|
|
62728
|
+
options,
|
|
62729
|
+
tests: this.tests
|
|
62730
|
+
}, panic, next);
|
|
62731
|
+
});
|
|
62732
|
+
}
|
|
62733
|
+
|
|
62734
|
+
/**
|
|
62735
|
+
* Executes a set of validations, either schema, produced Tests or a nested
|
|
62736
|
+
* schema validate result.
|
|
62737
|
+
*/
|
|
62738
|
+
runTests(runOptions, panic, next) {
|
|
62739
|
+
let fired = false;
|
|
62740
|
+
let {
|
|
62741
|
+
tests,
|
|
62742
|
+
value,
|
|
62743
|
+
originalValue,
|
|
62744
|
+
path,
|
|
62745
|
+
options
|
|
62746
|
+
} = runOptions;
|
|
62747
|
+
let panicOnce = arg => {
|
|
62748
|
+
if (fired) return;
|
|
62749
|
+
fired = true;
|
|
62750
|
+
panic(arg, value);
|
|
62751
|
+
};
|
|
62752
|
+
let nextOnce = arg => {
|
|
62753
|
+
if (fired) return;
|
|
62754
|
+
fired = true;
|
|
62755
|
+
next(arg, value);
|
|
62756
|
+
};
|
|
62757
|
+
let count = tests.length;
|
|
62758
|
+
let nestedErrors = [];
|
|
62759
|
+
if (!count) return nextOnce([]);
|
|
62760
|
+
let args = {
|
|
62761
|
+
value,
|
|
62762
|
+
originalValue,
|
|
62763
|
+
path,
|
|
62764
|
+
options,
|
|
62765
|
+
schema: this
|
|
62766
|
+
};
|
|
62767
|
+
for (let i = 0; i < tests.length; i++) {
|
|
62768
|
+
const test = tests[i];
|
|
62769
|
+
test(args, panicOnce, function finishTestRun(err) {
|
|
62770
|
+
if (err) {
|
|
62771
|
+
Array.isArray(err) ? nestedErrors.push(...err) : nestedErrors.push(err);
|
|
62772
|
+
}
|
|
62773
|
+
if (--count <= 0) {
|
|
62774
|
+
nextOnce(nestedErrors);
|
|
62775
|
+
}
|
|
62776
|
+
});
|
|
62777
|
+
}
|
|
62778
|
+
}
|
|
62779
|
+
asNestedTest({
|
|
62780
|
+
key,
|
|
62781
|
+
index,
|
|
62782
|
+
parent,
|
|
62783
|
+
parentPath,
|
|
62784
|
+
originalParent,
|
|
62785
|
+
options
|
|
62786
|
+
}) {
|
|
62787
|
+
const k = key != null ? key : index;
|
|
62788
|
+
if (k == null) {
|
|
62789
|
+
throw TypeError('Must include `key` or `index` for nested validations');
|
|
62790
|
+
}
|
|
62791
|
+
const isIndex = typeof k === 'number';
|
|
62792
|
+
let value = parent[k];
|
|
62793
|
+
const testOptions = Object.assign({}, options, {
|
|
62794
|
+
// Nested validations fields are always strict:
|
|
62795
|
+
// 1. parent isn't strict so the casting will also have cast inner values
|
|
62796
|
+
// 2. parent is strict in which case the nested values weren't cast either
|
|
62797
|
+
strict: true,
|
|
62798
|
+
parent,
|
|
62799
|
+
value,
|
|
62800
|
+
originalValue: originalParent[k],
|
|
62801
|
+
// FIXME: tests depend on `index` being passed around deeply,
|
|
62802
|
+
// we should not let the options.key/index bleed through
|
|
62803
|
+
key: undefined,
|
|
62804
|
+
// index: undefined,
|
|
62805
|
+
[isIndex ? 'index' : 'key']: k,
|
|
62806
|
+
path: isIndex || k.includes('.') ? `${parentPath || ''}[${isIndex ? k : `"${k}"`}]` : (parentPath ? `${parentPath}.` : '') + key
|
|
62807
|
+
});
|
|
62808
|
+
return (_, panic, next) => this.resolve(testOptions)._validate(value, testOptions, panic, next);
|
|
62809
|
+
}
|
|
62810
|
+
validate(value, options) {
|
|
62811
|
+
var _options$disableStack2;
|
|
62812
|
+
let schema = this.resolve(Object.assign({}, options, {
|
|
62813
|
+
value
|
|
62814
|
+
}));
|
|
62815
|
+
let disableStackTrace = (_options$disableStack2 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack2 : schema.spec.disableStackTrace;
|
|
62816
|
+
return new Promise((resolve, reject) => schema._validate(value, options, (error, parsed) => {
|
|
62817
|
+
if (ValidationError.isError(error)) error.value = parsed;
|
|
62818
|
+
reject(error);
|
|
62819
|
+
}, (errors, validated) => {
|
|
62820
|
+
if (errors.length) reject(new ValidationError(errors, validated, undefined, undefined, disableStackTrace));else resolve(validated);
|
|
62821
|
+
}));
|
|
62822
|
+
}
|
|
62823
|
+
validateSync(value, options) {
|
|
62824
|
+
var _options$disableStack3;
|
|
62825
|
+
let schema = this.resolve(Object.assign({}, options, {
|
|
62826
|
+
value
|
|
62827
|
+
}));
|
|
62828
|
+
let result;
|
|
62829
|
+
let disableStackTrace = (_options$disableStack3 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack3 : schema.spec.disableStackTrace;
|
|
62830
|
+
schema._validate(value, Object.assign({}, options, {
|
|
62831
|
+
sync: true
|
|
62832
|
+
}), (error, parsed) => {
|
|
62833
|
+
if (ValidationError.isError(error)) error.value = parsed;
|
|
62834
|
+
throw error;
|
|
62835
|
+
}, (errors, validated) => {
|
|
62836
|
+
if (errors.length) throw new ValidationError(errors, value, undefined, undefined, disableStackTrace);
|
|
62837
|
+
result = validated;
|
|
62838
|
+
});
|
|
62839
|
+
return result;
|
|
62840
|
+
}
|
|
62841
|
+
isValid(value, options) {
|
|
62842
|
+
return this.validate(value, options).then(() => true, err => {
|
|
62843
|
+
if (ValidationError.isError(err)) return false;
|
|
62844
|
+
throw err;
|
|
62845
|
+
});
|
|
62846
|
+
}
|
|
62847
|
+
isValidSync(value, options) {
|
|
62848
|
+
try {
|
|
62849
|
+
this.validateSync(value, options);
|
|
62850
|
+
return true;
|
|
62851
|
+
} catch (err) {
|
|
62852
|
+
if (ValidationError.isError(err)) return false;
|
|
62853
|
+
throw err;
|
|
62854
|
+
}
|
|
62855
|
+
}
|
|
62856
|
+
_getDefault(options) {
|
|
62857
|
+
let defaultValue = this.spec.default;
|
|
62858
|
+
if (defaultValue == null) {
|
|
62859
|
+
return defaultValue;
|
|
62860
|
+
}
|
|
62861
|
+
return typeof defaultValue === 'function' ? defaultValue.call(this, options) : clone(defaultValue);
|
|
62862
|
+
}
|
|
62863
|
+
getDefault(options
|
|
62864
|
+
// If schema is defaulted we know it's at least not undefined
|
|
62865
|
+
) {
|
|
62866
|
+
let schema = this.resolve(options || {});
|
|
62867
|
+
return schema._getDefault(options);
|
|
62868
|
+
}
|
|
62869
|
+
default(def) {
|
|
62870
|
+
if (arguments.length === 0) {
|
|
62871
|
+
return this._getDefault();
|
|
62872
|
+
}
|
|
62873
|
+
let next = this.clone({
|
|
62874
|
+
default: def
|
|
62875
|
+
});
|
|
62876
|
+
return next;
|
|
62877
|
+
}
|
|
62878
|
+
strict(isStrict = true) {
|
|
62879
|
+
return this.clone({
|
|
62880
|
+
strict: isStrict
|
|
62881
|
+
});
|
|
62882
|
+
}
|
|
62883
|
+
nullability(nullable, message) {
|
|
62884
|
+
const next = this.clone({
|
|
62885
|
+
nullable
|
|
62886
|
+
});
|
|
62887
|
+
next.internalTests.nullable = createValidation({
|
|
62888
|
+
message,
|
|
62889
|
+
name: 'nullable',
|
|
62890
|
+
test(value) {
|
|
62891
|
+
return value === null ? this.schema.spec.nullable : true;
|
|
62892
|
+
}
|
|
62893
|
+
});
|
|
62894
|
+
return next;
|
|
62895
|
+
}
|
|
62896
|
+
optionality(optional, message) {
|
|
62897
|
+
const next = this.clone({
|
|
62898
|
+
optional
|
|
62899
|
+
});
|
|
62900
|
+
next.internalTests.optionality = createValidation({
|
|
62901
|
+
message,
|
|
62902
|
+
name: 'optionality',
|
|
62903
|
+
test(value) {
|
|
62904
|
+
return value === undefined ? this.schema.spec.optional : true;
|
|
62905
|
+
}
|
|
62906
|
+
});
|
|
62907
|
+
return next;
|
|
62908
|
+
}
|
|
62909
|
+
optional() {
|
|
62910
|
+
return this.optionality(true);
|
|
62911
|
+
}
|
|
62912
|
+
defined(message = mixed.defined) {
|
|
62913
|
+
return this.optionality(false, message);
|
|
62914
|
+
}
|
|
62915
|
+
nullable() {
|
|
62916
|
+
return this.nullability(true);
|
|
62917
|
+
}
|
|
62918
|
+
nonNullable(message = mixed.notNull) {
|
|
62919
|
+
return this.nullability(false, message);
|
|
62920
|
+
}
|
|
62921
|
+
required(message = mixed.required) {
|
|
62922
|
+
return this.clone().withMutation(next => next.nonNullable(message).defined(message));
|
|
62923
|
+
}
|
|
62924
|
+
notRequired() {
|
|
62925
|
+
return this.clone().withMutation(next => next.nullable().optional());
|
|
62926
|
+
}
|
|
62927
|
+
transform(fn) {
|
|
62928
|
+
let next = this.clone();
|
|
62929
|
+
next.transforms.push(fn);
|
|
62930
|
+
return next;
|
|
62931
|
+
}
|
|
62932
|
+
|
|
62933
|
+
/**
|
|
62934
|
+
* Adds a test function to the schema's queue of tests.
|
|
62935
|
+
* tests can be exclusive or non-exclusive.
|
|
62936
|
+
*
|
|
62937
|
+
* - exclusive tests, will replace any existing tests of the same name.
|
|
62938
|
+
* - non-exclusive: can be stacked
|
|
62939
|
+
*
|
|
62940
|
+
* If a non-exclusive test is added to a schema with an exclusive test of the same name
|
|
62941
|
+
* the exclusive test is removed and further tests of the same name will be stacked.
|
|
62942
|
+
*
|
|
62943
|
+
* If an exclusive test is added to a schema with non-exclusive tests of the same name
|
|
62944
|
+
* the previous tests are removed and further tests of the same name will replace each other.
|
|
62945
|
+
*/
|
|
62946
|
+
|
|
62947
|
+
test(...args) {
|
|
62948
|
+
let opts;
|
|
62949
|
+
if (args.length === 1) {
|
|
62950
|
+
if (typeof args[0] === 'function') {
|
|
62951
|
+
opts = {
|
|
62952
|
+
test: args[0]
|
|
62953
|
+
};
|
|
62954
|
+
} else {
|
|
62955
|
+
opts = args[0];
|
|
62956
|
+
}
|
|
62957
|
+
} else if (args.length === 2) {
|
|
62958
|
+
opts = {
|
|
62959
|
+
name: args[0],
|
|
62960
|
+
test: args[1]
|
|
62961
|
+
};
|
|
62962
|
+
} else {
|
|
62963
|
+
opts = {
|
|
62964
|
+
name: args[0],
|
|
62965
|
+
message: args[1],
|
|
62966
|
+
test: args[2]
|
|
62967
|
+
};
|
|
62968
|
+
}
|
|
62969
|
+
if (opts.message === undefined) opts.message = mixed.default;
|
|
62970
|
+
if (typeof opts.test !== 'function') throw new TypeError('`test` is a required parameters');
|
|
62971
|
+
let next = this.clone();
|
|
62972
|
+
let validate = createValidation(opts);
|
|
62973
|
+
let isExclusive = opts.exclusive || opts.name && next.exclusiveTests[opts.name] === true;
|
|
62974
|
+
if (opts.exclusive) {
|
|
62975
|
+
if (!opts.name) throw new TypeError('Exclusive tests must provide a unique `name` identifying the test');
|
|
62976
|
+
}
|
|
62977
|
+
if (opts.name) next.exclusiveTests[opts.name] = !!opts.exclusive;
|
|
62978
|
+
next.tests = next.tests.filter(fn => {
|
|
62979
|
+
if (fn.OPTIONS.name === opts.name) {
|
|
62980
|
+
if (isExclusive) return false;
|
|
62981
|
+
if (fn.OPTIONS.test === validate.OPTIONS.test) return false;
|
|
62982
|
+
}
|
|
62983
|
+
return true;
|
|
62984
|
+
});
|
|
62985
|
+
next.tests.push(validate);
|
|
62986
|
+
return next;
|
|
62987
|
+
}
|
|
62988
|
+
when(keys, options) {
|
|
62989
|
+
if (!Array.isArray(keys) && typeof keys !== 'string') {
|
|
62990
|
+
options = keys;
|
|
62991
|
+
keys = '.';
|
|
62992
|
+
}
|
|
62993
|
+
let next = this.clone();
|
|
62994
|
+
let deps = toArray(keys).map(key => new Reference(key));
|
|
62995
|
+
deps.forEach(dep => {
|
|
62996
|
+
// @ts-ignore readonly array
|
|
62997
|
+
if (dep.isSibling) next.deps.push(dep.key);
|
|
62998
|
+
});
|
|
62999
|
+
next.conditions.push(typeof options === 'function' ? new Condition(deps, options) : Condition.fromOptions(deps, options));
|
|
63000
|
+
return next;
|
|
63001
|
+
}
|
|
63002
|
+
typeError(message) {
|
|
63003
|
+
let next = this.clone();
|
|
63004
|
+
next.internalTests.typeError = createValidation({
|
|
63005
|
+
message,
|
|
63006
|
+
name: 'typeError',
|
|
63007
|
+
skipAbsent: true,
|
|
63008
|
+
test(value) {
|
|
63009
|
+
if (!this.schema._typeCheck(value)) return this.createError({
|
|
63010
|
+
params: {
|
|
63011
|
+
type: this.schema.type
|
|
63012
|
+
}
|
|
63013
|
+
});
|
|
63014
|
+
return true;
|
|
63015
|
+
}
|
|
63016
|
+
});
|
|
63017
|
+
return next;
|
|
63018
|
+
}
|
|
63019
|
+
oneOf(enums, message = mixed.oneOf) {
|
|
63020
|
+
let next = this.clone();
|
|
63021
|
+
enums.forEach(val => {
|
|
63022
|
+
next._whitelist.add(val);
|
|
63023
|
+
next._blacklist.delete(val);
|
|
63024
|
+
});
|
|
63025
|
+
next.internalTests.whiteList = createValidation({
|
|
63026
|
+
message,
|
|
63027
|
+
name: 'oneOf',
|
|
63028
|
+
skipAbsent: true,
|
|
63029
|
+
test(value) {
|
|
63030
|
+
let valids = this.schema._whitelist;
|
|
63031
|
+
let resolved = valids.resolveAll(this.resolve);
|
|
63032
|
+
return resolved.includes(value) ? true : this.createError({
|
|
63033
|
+
params: {
|
|
63034
|
+
values: Array.from(valids).join(', '),
|
|
63035
|
+
resolved
|
|
63036
|
+
}
|
|
63037
|
+
});
|
|
63038
|
+
}
|
|
63039
|
+
});
|
|
63040
|
+
return next;
|
|
63041
|
+
}
|
|
63042
|
+
notOneOf(enums, message = mixed.notOneOf) {
|
|
63043
|
+
let next = this.clone();
|
|
63044
|
+
enums.forEach(val => {
|
|
63045
|
+
next._blacklist.add(val);
|
|
63046
|
+
next._whitelist.delete(val);
|
|
63047
|
+
});
|
|
63048
|
+
next.internalTests.blacklist = createValidation({
|
|
63049
|
+
message,
|
|
63050
|
+
name: 'notOneOf',
|
|
63051
|
+
test(value) {
|
|
63052
|
+
let invalids = this.schema._blacklist;
|
|
63053
|
+
let resolved = invalids.resolveAll(this.resolve);
|
|
63054
|
+
if (resolved.includes(value)) return this.createError({
|
|
63055
|
+
params: {
|
|
63056
|
+
values: Array.from(invalids).join(', '),
|
|
63057
|
+
resolved
|
|
63058
|
+
}
|
|
63059
|
+
});
|
|
63060
|
+
return true;
|
|
63061
|
+
}
|
|
63062
|
+
});
|
|
63063
|
+
return next;
|
|
63064
|
+
}
|
|
63065
|
+
strip(strip = true) {
|
|
63066
|
+
let next = this.clone();
|
|
63067
|
+
next.spec.strip = strip;
|
|
63068
|
+
return next;
|
|
63069
|
+
}
|
|
63070
|
+
|
|
63071
|
+
/**
|
|
63072
|
+
* Return a serialized description of the schema including validations, flags, types etc.
|
|
63073
|
+
*
|
|
63074
|
+
* @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
|
|
63075
|
+
*/
|
|
63076
|
+
describe(options) {
|
|
63077
|
+
const next = (options ? this.resolve(options) : this).clone();
|
|
63078
|
+
const {
|
|
63079
|
+
label,
|
|
63080
|
+
meta,
|
|
63081
|
+
optional,
|
|
63082
|
+
nullable
|
|
63083
|
+
} = next.spec;
|
|
63084
|
+
const description = {
|
|
63085
|
+
meta,
|
|
63086
|
+
label,
|
|
63087
|
+
optional,
|
|
63088
|
+
nullable,
|
|
63089
|
+
default: next.getDefault(options),
|
|
63090
|
+
type: next.type,
|
|
63091
|
+
oneOf: next._whitelist.describe(),
|
|
63092
|
+
notOneOf: next._blacklist.describe(),
|
|
63093
|
+
tests: next.tests.filter((n, idx, list) => list.findIndex(c => c.OPTIONS.name === n.OPTIONS.name) === idx).map(fn => {
|
|
63094
|
+
const params = fn.OPTIONS.params && options ? resolveParams(Object.assign({}, fn.OPTIONS.params), options) : fn.OPTIONS.params;
|
|
63095
|
+
return {
|
|
63096
|
+
name: fn.OPTIONS.name,
|
|
63097
|
+
params
|
|
63098
|
+
};
|
|
63099
|
+
})
|
|
63100
|
+
};
|
|
63101
|
+
return description;
|
|
63102
|
+
}
|
|
63103
|
+
get ['~standard']() {
|
|
63104
|
+
const schema = this;
|
|
63105
|
+
const standard = {
|
|
63106
|
+
version: 1,
|
|
63107
|
+
vendor: 'yup',
|
|
63108
|
+
async validate(value) {
|
|
63109
|
+
try {
|
|
63110
|
+
const result = await schema.validate(value, {
|
|
63111
|
+
abortEarly: false
|
|
63112
|
+
});
|
|
63113
|
+
return {
|
|
63114
|
+
value: result
|
|
63115
|
+
};
|
|
63116
|
+
} catch (err) {
|
|
63117
|
+
if (err instanceof ValidationError) {
|
|
63118
|
+
return {
|
|
63119
|
+
issues: issuesFromValidationError(err)
|
|
63120
|
+
};
|
|
63121
|
+
}
|
|
63122
|
+
throw err;
|
|
63123
|
+
}
|
|
63124
|
+
}
|
|
63125
|
+
};
|
|
63126
|
+
return standard;
|
|
63127
|
+
}
|
|
63128
|
+
}
|
|
63129
|
+
// @ts-expect-error
|
|
63130
|
+
Schema.prototype.__isYupSchema__ = true;
|
|
63131
|
+
for (const method of ['validate', 'validateSync']) Schema.prototype[`${method}At`] = function (path, value, options = {}) {
|
|
63132
|
+
const {
|
|
63133
|
+
parent,
|
|
63134
|
+
parentPath,
|
|
63135
|
+
schema
|
|
63136
|
+
} = getIn(this, path, value, options.context);
|
|
63137
|
+
return schema[method](parent && parent[parentPath], Object.assign({}, options, {
|
|
63138
|
+
parent,
|
|
63139
|
+
path
|
|
63140
|
+
}));
|
|
63141
|
+
};
|
|
63142
|
+
for (const alias of ['equals', 'is']) Schema.prototype[alias] = Schema.prototype.oneOf;
|
|
63143
|
+
for (const alias of ['not', 'nope']) Schema.prototype[alias] = Schema.prototype.notOneOf;
|
|
63144
|
+
|
|
63145
|
+
/**
|
|
63146
|
+
* This file is a modified version of the file from the following repository:
|
|
63147
|
+
* Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>
|
|
63148
|
+
* NON-CONFORMANT EDITION.
|
|
63149
|
+
* © 2011 Colin Snover <http://zetafleet.com>
|
|
63150
|
+
* Released under MIT license.
|
|
63151
|
+
*/
|
|
63152
|
+
|
|
63153
|
+
// prettier-ignore
|
|
63154
|
+
// 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
|
|
63155
|
+
const isoReg = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
|
|
63156
|
+
function parseIsoDate(date) {
|
|
63157
|
+
const struct = parseDateStruct(date);
|
|
63158
|
+
if (!struct) return Date.parse ? Date.parse(date) : Number.NaN;
|
|
63159
|
+
|
|
63160
|
+
// timestamps without timezone identifiers should be considered local time
|
|
63161
|
+
if (struct.z === undefined && struct.plusMinus === undefined) {
|
|
63162
|
+
return new Date(struct.year, struct.month, struct.day, struct.hour, struct.minute, struct.second, struct.millisecond).valueOf();
|
|
63163
|
+
}
|
|
63164
|
+
let totalMinutesOffset = 0;
|
|
63165
|
+
if (struct.z !== 'Z' && struct.plusMinus !== undefined) {
|
|
63166
|
+
totalMinutesOffset = struct.hourOffset * 60 + struct.minuteOffset;
|
|
63167
|
+
if (struct.plusMinus === '+') totalMinutesOffset = 0 - totalMinutesOffset;
|
|
63168
|
+
}
|
|
63169
|
+
return Date.UTC(struct.year, struct.month, struct.day, struct.hour, struct.minute + totalMinutesOffset, struct.second, struct.millisecond);
|
|
63170
|
+
}
|
|
63171
|
+
function parseDateStruct(date) {
|
|
63172
|
+
var _regexResult$7$length, _regexResult$;
|
|
63173
|
+
const regexResult = isoReg.exec(date);
|
|
63174
|
+
if (!regexResult) return null;
|
|
63175
|
+
|
|
63176
|
+
// use of toNumber() avoids NaN timestamps caused by “undefined”
|
|
63177
|
+
// values being passed to Date constructor
|
|
63178
|
+
return {
|
|
63179
|
+
year: toNumber(regexResult[1]),
|
|
63180
|
+
month: toNumber(regexResult[2], 1) - 1,
|
|
63181
|
+
day: toNumber(regexResult[3], 1),
|
|
63182
|
+
hour: toNumber(regexResult[4]),
|
|
63183
|
+
minute: toNumber(regexResult[5]),
|
|
63184
|
+
second: toNumber(regexResult[6]),
|
|
63185
|
+
millisecond: regexResult[7] ?
|
|
63186
|
+
// allow arbitrary sub-second precision beyond milliseconds
|
|
63187
|
+
toNumber(regexResult[7].substring(0, 3)) : 0,
|
|
63188
|
+
precision: (_regexResult$7$length = (_regexResult$ = regexResult[7]) == null ? void 0 : _regexResult$.length) != null ? _regexResult$7$length : undefined,
|
|
63189
|
+
z: regexResult[8] || undefined,
|
|
63190
|
+
plusMinus: regexResult[9] || undefined,
|
|
63191
|
+
hourOffset: toNumber(regexResult[10]),
|
|
63192
|
+
minuteOffset: toNumber(regexResult[11])
|
|
63193
|
+
};
|
|
63194
|
+
}
|
|
63195
|
+
function toNumber(str, defaultValue = 0) {
|
|
63196
|
+
return Number(str) || defaultValue;
|
|
63197
|
+
}
|
|
63198
|
+
|
|
63199
|
+
// Taken from HTML spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
|
|
63200
|
+
let rEmail =
|
|
63201
|
+
// eslint-disable-next-line
|
|
63202
|
+
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
63203
|
+
let rUrl =
|
|
63204
|
+
// eslint-disable-next-line
|
|
63205
|
+
/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
|
|
63206
|
+
|
|
63207
|
+
// eslint-disable-next-line
|
|
63208
|
+
let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
63209
|
+
let yearMonthDay = '^\\d{4}-\\d{2}-\\d{2}';
|
|
63210
|
+
let hourMinuteSecond = '\\d{2}:\\d{2}:\\d{2}';
|
|
63211
|
+
let zOrOffset = '(([+-]\\d{2}(:?\\d{2})?)|Z)';
|
|
63212
|
+
let rIsoDateTime = new RegExp(`${yearMonthDay}T${hourMinuteSecond}(\\.\\d+)?${zOrOffset}$`);
|
|
63213
|
+
let isTrimmed = value => isAbsent(value) || value === value.trim();
|
|
63214
|
+
let objStringTag = {}.toString();
|
|
63215
|
+
function create$6() {
|
|
63216
|
+
return new StringSchema();
|
|
63217
|
+
}
|
|
63218
|
+
class StringSchema extends Schema {
|
|
63219
|
+
constructor() {
|
|
63220
|
+
super({
|
|
63221
|
+
type: 'string',
|
|
63222
|
+
check(value) {
|
|
63223
|
+
if (value instanceof String) value = value.valueOf();
|
|
63224
|
+
return typeof value === 'string';
|
|
63225
|
+
}
|
|
63226
|
+
});
|
|
63227
|
+
this.withMutation(() => {
|
|
63228
|
+
this.transform((value, _raw) => {
|
|
63229
|
+
if (!this.spec.coerce || this.isType(value)) return value;
|
|
63230
|
+
|
|
63231
|
+
// don't ever convert arrays
|
|
63232
|
+
if (Array.isArray(value)) return value;
|
|
63233
|
+
const strValue = value != null && value.toString ? value.toString() : value;
|
|
63234
|
+
|
|
63235
|
+
// no one wants plain objects converted to [Object object]
|
|
63236
|
+
if (strValue === objStringTag) return value;
|
|
63237
|
+
return strValue;
|
|
63238
|
+
});
|
|
63239
|
+
});
|
|
63240
|
+
}
|
|
63241
|
+
required(message) {
|
|
63242
|
+
return super.required(message).withMutation(schema => schema.test({
|
|
63243
|
+
message: message || mixed.required,
|
|
63244
|
+
name: 'required',
|
|
63245
|
+
skipAbsent: true,
|
|
63246
|
+
test: value => !!value.length
|
|
63247
|
+
}));
|
|
63248
|
+
}
|
|
63249
|
+
notRequired() {
|
|
63250
|
+
return super.notRequired().withMutation(schema => {
|
|
63251
|
+
schema.tests = schema.tests.filter(t => t.OPTIONS.name !== 'required');
|
|
63252
|
+
return schema;
|
|
63253
|
+
});
|
|
63254
|
+
}
|
|
63255
|
+
length(length, message = string.length) {
|
|
63256
|
+
return this.test({
|
|
63257
|
+
message,
|
|
63258
|
+
name: 'length',
|
|
63259
|
+
exclusive: true,
|
|
63260
|
+
params: {
|
|
63261
|
+
length
|
|
63262
|
+
},
|
|
63263
|
+
skipAbsent: true,
|
|
63264
|
+
test(value) {
|
|
63265
|
+
return value.length === this.resolve(length);
|
|
63266
|
+
}
|
|
63267
|
+
});
|
|
63268
|
+
}
|
|
63269
|
+
min(min, message = string.min) {
|
|
63270
|
+
return this.test({
|
|
63271
|
+
message,
|
|
63272
|
+
name: 'min',
|
|
63273
|
+
exclusive: true,
|
|
63274
|
+
params: {
|
|
63275
|
+
min
|
|
63276
|
+
},
|
|
63277
|
+
skipAbsent: true,
|
|
63278
|
+
test(value) {
|
|
63279
|
+
return value.length >= this.resolve(min);
|
|
63280
|
+
}
|
|
63281
|
+
});
|
|
63282
|
+
}
|
|
63283
|
+
max(max, message = string.max) {
|
|
63284
|
+
return this.test({
|
|
63285
|
+
name: 'max',
|
|
63286
|
+
exclusive: true,
|
|
63287
|
+
message,
|
|
63288
|
+
params: {
|
|
63289
|
+
max
|
|
63290
|
+
},
|
|
63291
|
+
skipAbsent: true,
|
|
63292
|
+
test(value) {
|
|
63293
|
+
return value.length <= this.resolve(max);
|
|
63294
|
+
}
|
|
63295
|
+
});
|
|
63296
|
+
}
|
|
63297
|
+
matches(regex, options) {
|
|
63298
|
+
let excludeEmptyString = false;
|
|
63299
|
+
let message;
|
|
63300
|
+
let name;
|
|
63301
|
+
if (options) {
|
|
63302
|
+
if (typeof options === 'object') {
|
|
63303
|
+
({
|
|
63304
|
+
excludeEmptyString = false,
|
|
63305
|
+
message,
|
|
63306
|
+
name
|
|
63307
|
+
} = options);
|
|
63308
|
+
} else {
|
|
63309
|
+
message = options;
|
|
63310
|
+
}
|
|
63311
|
+
}
|
|
63312
|
+
return this.test({
|
|
63313
|
+
name: name || 'matches',
|
|
63314
|
+
message: message || string.matches,
|
|
63315
|
+
params: {
|
|
63316
|
+
regex
|
|
63317
|
+
},
|
|
63318
|
+
skipAbsent: true,
|
|
63319
|
+
test: value => value === '' && excludeEmptyString || value.search(regex) !== -1
|
|
63320
|
+
});
|
|
63321
|
+
}
|
|
63322
|
+
email(message = string.email) {
|
|
63323
|
+
return this.matches(rEmail, {
|
|
63324
|
+
name: 'email',
|
|
63325
|
+
message,
|
|
63326
|
+
excludeEmptyString: true
|
|
63327
|
+
});
|
|
63328
|
+
}
|
|
63329
|
+
url(message = string.url) {
|
|
63330
|
+
return this.matches(rUrl, {
|
|
63331
|
+
name: 'url',
|
|
63332
|
+
message,
|
|
63333
|
+
excludeEmptyString: true
|
|
63334
|
+
});
|
|
63335
|
+
}
|
|
63336
|
+
uuid(message = string.uuid) {
|
|
63337
|
+
return this.matches(rUUID, {
|
|
63338
|
+
name: 'uuid',
|
|
63339
|
+
message,
|
|
63340
|
+
excludeEmptyString: false
|
|
63341
|
+
});
|
|
63342
|
+
}
|
|
63343
|
+
datetime(options) {
|
|
63344
|
+
let message = '';
|
|
63345
|
+
let allowOffset;
|
|
63346
|
+
let precision;
|
|
63347
|
+
if (options) {
|
|
63348
|
+
if (typeof options === 'object') {
|
|
63349
|
+
({
|
|
63350
|
+
message = '',
|
|
63351
|
+
allowOffset = false,
|
|
63352
|
+
precision = undefined
|
|
63353
|
+
} = options);
|
|
63354
|
+
} else {
|
|
63355
|
+
message = options;
|
|
63356
|
+
}
|
|
63357
|
+
}
|
|
63358
|
+
return this.matches(rIsoDateTime, {
|
|
63359
|
+
name: 'datetime',
|
|
63360
|
+
message: message || string.datetime,
|
|
63361
|
+
excludeEmptyString: true
|
|
63362
|
+
}).test({
|
|
63363
|
+
name: 'datetime_offset',
|
|
63364
|
+
message: message || string.datetime_offset,
|
|
63365
|
+
params: {
|
|
63366
|
+
allowOffset
|
|
63367
|
+
},
|
|
63368
|
+
skipAbsent: true,
|
|
63369
|
+
test: value => {
|
|
63370
|
+
if (!value || allowOffset) return true;
|
|
63371
|
+
const struct = parseDateStruct(value);
|
|
63372
|
+
if (!struct) return false;
|
|
63373
|
+
return !!struct.z;
|
|
63374
|
+
}
|
|
63375
|
+
}).test({
|
|
63376
|
+
name: 'datetime_precision',
|
|
63377
|
+
message: message || string.datetime_precision,
|
|
63378
|
+
params: {
|
|
63379
|
+
precision
|
|
63380
|
+
},
|
|
63381
|
+
skipAbsent: true,
|
|
63382
|
+
test: value => {
|
|
63383
|
+
if (!value || precision == undefined) return true;
|
|
63384
|
+
const struct = parseDateStruct(value);
|
|
63385
|
+
if (!struct) return false;
|
|
63386
|
+
return struct.precision === precision;
|
|
63387
|
+
}
|
|
63388
|
+
});
|
|
63389
|
+
}
|
|
63390
|
+
|
|
63391
|
+
//-- transforms --
|
|
63392
|
+
ensure() {
|
|
63393
|
+
return this.default('').transform(val => val === null ? '' : val);
|
|
63394
|
+
}
|
|
63395
|
+
trim(message = string.trim) {
|
|
63396
|
+
return this.transform(val => val != null ? val.trim() : val).test({
|
|
63397
|
+
message,
|
|
63398
|
+
name: 'trim',
|
|
63399
|
+
test: isTrimmed
|
|
63400
|
+
});
|
|
63401
|
+
}
|
|
63402
|
+
lowercase(message = string.lowercase) {
|
|
63403
|
+
return this.transform(value => !isAbsent(value) ? value.toLowerCase() : value).test({
|
|
63404
|
+
message,
|
|
63405
|
+
name: 'string_case',
|
|
63406
|
+
exclusive: true,
|
|
63407
|
+
skipAbsent: true,
|
|
63408
|
+
test: value => isAbsent(value) || value === value.toLowerCase()
|
|
63409
|
+
});
|
|
63410
|
+
}
|
|
63411
|
+
uppercase(message = string.uppercase) {
|
|
63412
|
+
return this.transform(value => !isAbsent(value) ? value.toUpperCase() : value).test({
|
|
63413
|
+
message,
|
|
63414
|
+
name: 'string_case',
|
|
63415
|
+
exclusive: true,
|
|
63416
|
+
skipAbsent: true,
|
|
63417
|
+
test: value => isAbsent(value) || value === value.toUpperCase()
|
|
63418
|
+
});
|
|
63419
|
+
}
|
|
63420
|
+
}
|
|
63421
|
+
create$6.prototype = StringSchema.prototype;
|
|
63422
|
+
|
|
63423
|
+
//
|
|
63424
|
+
// Number Interfaces
|
|
63425
|
+
//
|
|
63426
|
+
|
|
63427
|
+
let invalidDate = new Date('');
|
|
63428
|
+
let isDate = obj => Object.prototype.toString.call(obj) === '[object Date]';
|
|
63429
|
+
class DateSchema extends Schema {
|
|
63430
|
+
constructor() {
|
|
63431
|
+
super({
|
|
63432
|
+
type: 'date',
|
|
63433
|
+
check(v) {
|
|
63434
|
+
return isDate(v) && !isNaN(v.getTime());
|
|
63435
|
+
}
|
|
63436
|
+
});
|
|
63437
|
+
this.withMutation(() => {
|
|
63438
|
+
this.transform((value, _raw) => {
|
|
63439
|
+
// null -> InvalidDate isn't useful; treat all nulls as null and let it fail on
|
|
63440
|
+
// nullability check vs TypeErrors
|
|
63441
|
+
if (!this.spec.coerce || this.isType(value) || value === null) return value;
|
|
63442
|
+
value = parseIsoDate(value);
|
|
63443
|
+
|
|
63444
|
+
// 0 is a valid timestamp equivalent to 1970-01-01T00:00:00Z(unix epoch) or before.
|
|
63445
|
+
return !isNaN(value) ? new Date(value) : DateSchema.INVALID_DATE;
|
|
63446
|
+
});
|
|
63447
|
+
});
|
|
63448
|
+
}
|
|
63449
|
+
prepareParam(ref, name) {
|
|
63450
|
+
let param;
|
|
63451
|
+
if (!Reference.isRef(ref)) {
|
|
63452
|
+
let cast = this.cast(ref);
|
|
63453
|
+
if (!this._typeCheck(cast)) throw new TypeError(`\`${name}\` must be a Date or a value that can be \`cast()\` to a Date`);
|
|
63454
|
+
param = cast;
|
|
63455
|
+
} else {
|
|
63456
|
+
param = ref;
|
|
63457
|
+
}
|
|
63458
|
+
return param;
|
|
63459
|
+
}
|
|
63460
|
+
min(min, message = date.min) {
|
|
63461
|
+
let limit = this.prepareParam(min, 'min');
|
|
63462
|
+
return this.test({
|
|
63463
|
+
message,
|
|
63464
|
+
name: 'min',
|
|
63465
|
+
exclusive: true,
|
|
63466
|
+
params: {
|
|
63467
|
+
min
|
|
63468
|
+
},
|
|
63469
|
+
skipAbsent: true,
|
|
63470
|
+
test(value) {
|
|
63471
|
+
return value >= this.resolve(limit);
|
|
63472
|
+
}
|
|
63473
|
+
});
|
|
63474
|
+
}
|
|
63475
|
+
max(max, message = date.max) {
|
|
63476
|
+
let limit = this.prepareParam(max, 'max');
|
|
63477
|
+
return this.test({
|
|
63478
|
+
message,
|
|
63479
|
+
name: 'max',
|
|
63480
|
+
exclusive: true,
|
|
63481
|
+
params: {
|
|
63482
|
+
max
|
|
63483
|
+
},
|
|
63484
|
+
skipAbsent: true,
|
|
63485
|
+
test(value) {
|
|
63486
|
+
return value <= this.resolve(limit);
|
|
63487
|
+
}
|
|
63488
|
+
});
|
|
63489
|
+
}
|
|
63490
|
+
}
|
|
63491
|
+
DateSchema.INVALID_DATE = invalidDate;
|
|
63492
|
+
|
|
63493
|
+
// @ts-expect-error
|
|
63494
|
+
function sortFields(fields, excludedEdges = []) {
|
|
63495
|
+
let edges = [];
|
|
63496
|
+
let nodes = new Set();
|
|
63497
|
+
let excludes = new Set(excludedEdges.map(([a, b]) => `${a}-${b}`));
|
|
63498
|
+
function addNode(depPath, key) {
|
|
63499
|
+
let node = propertyExprExports.split(depPath)[0];
|
|
63500
|
+
nodes.add(node);
|
|
63501
|
+
if (!excludes.has(`${key}-${node}`)) edges.push([key, node]);
|
|
63502
|
+
}
|
|
63503
|
+
for (const key of Object.keys(fields)) {
|
|
63504
|
+
let value = fields[key];
|
|
63505
|
+
nodes.add(key);
|
|
63506
|
+
if (Reference.isRef(value) && value.isSibling) addNode(value.path, key);else if (isSchema(value) && 'deps' in value) value.deps.forEach(path => addNode(path, key));
|
|
63507
|
+
}
|
|
63508
|
+
return toposort.array(Array.from(nodes), edges).reverse();
|
|
63509
|
+
}
|
|
63510
|
+
|
|
63511
|
+
function findIndex(arr, err) {
|
|
63512
|
+
let idx = Infinity;
|
|
63513
|
+
arr.some((key, ii) => {
|
|
63514
|
+
var _err$path;
|
|
63515
|
+
if ((_err$path = err.path) != null && _err$path.includes(key)) {
|
|
63516
|
+
idx = ii;
|
|
63517
|
+
return true;
|
|
63518
|
+
}
|
|
63519
|
+
});
|
|
63520
|
+
return idx;
|
|
63521
|
+
}
|
|
63522
|
+
function sortByKeyOrder(keys) {
|
|
63523
|
+
return (a, b) => {
|
|
63524
|
+
return findIndex(keys, a) - findIndex(keys, b);
|
|
63525
|
+
};
|
|
63526
|
+
}
|
|
63527
|
+
|
|
63528
|
+
const parseJson = (value, _, schema) => {
|
|
63529
|
+
if (typeof value !== 'string') {
|
|
63530
|
+
return value;
|
|
63531
|
+
}
|
|
63532
|
+
let parsed = value;
|
|
63533
|
+
try {
|
|
63534
|
+
parsed = JSON.parse(value);
|
|
63535
|
+
} catch (err) {
|
|
63536
|
+
/* */
|
|
63537
|
+
}
|
|
63538
|
+
return schema.isType(parsed) ? parsed : value;
|
|
63539
|
+
};
|
|
63540
|
+
|
|
63541
|
+
// @ts-ignore
|
|
63542
|
+
function deepPartial(schema) {
|
|
63543
|
+
if ('fields' in schema) {
|
|
63544
|
+
const partial = {};
|
|
63545
|
+
for (const [key, fieldSchema] of Object.entries(schema.fields)) {
|
|
63546
|
+
partial[key] = deepPartial(fieldSchema);
|
|
63547
|
+
}
|
|
63548
|
+
return schema.setFields(partial);
|
|
63549
|
+
}
|
|
63550
|
+
if (schema.type === 'array') {
|
|
63551
|
+
const nextArray = schema.optional();
|
|
63552
|
+
if (nextArray.innerType) nextArray.innerType = deepPartial(nextArray.innerType);
|
|
63553
|
+
return nextArray;
|
|
63554
|
+
}
|
|
63555
|
+
if (schema.type === 'tuple') {
|
|
63556
|
+
return schema.optional().clone({
|
|
63557
|
+
types: schema.spec.types.map(deepPartial)
|
|
63558
|
+
});
|
|
63559
|
+
}
|
|
63560
|
+
if ('optional' in schema) {
|
|
63561
|
+
return schema.optional();
|
|
63562
|
+
}
|
|
63563
|
+
return schema;
|
|
63564
|
+
}
|
|
63565
|
+
const deepHas = (obj, p) => {
|
|
63566
|
+
const path = [...propertyExprExports.normalizePath(p)];
|
|
63567
|
+
if (path.length === 1) return path[0] in obj;
|
|
63568
|
+
let last = path.pop();
|
|
63569
|
+
let parent = propertyExprExports.getter(propertyExprExports.join(path), true)(obj);
|
|
63570
|
+
return !!(parent && last in parent);
|
|
63571
|
+
};
|
|
63572
|
+
let isObject = obj => Object.prototype.toString.call(obj) === '[object Object]';
|
|
63573
|
+
function unknown(ctx, value) {
|
|
63574
|
+
let known = Object.keys(ctx.fields);
|
|
63575
|
+
return Object.keys(value).filter(key => known.indexOf(key) === -1);
|
|
63576
|
+
}
|
|
63577
|
+
const defaultSort = sortByKeyOrder([]);
|
|
63578
|
+
function create$3(spec) {
|
|
63579
|
+
return new ObjectSchema(spec);
|
|
63580
|
+
}
|
|
63581
|
+
class ObjectSchema extends Schema {
|
|
63582
|
+
constructor(spec) {
|
|
63583
|
+
super({
|
|
63584
|
+
type: 'object',
|
|
63585
|
+
check(value) {
|
|
63586
|
+
return isObject(value) || typeof value === 'function';
|
|
63587
|
+
}
|
|
63588
|
+
});
|
|
63589
|
+
this.fields = Object.create(null);
|
|
63590
|
+
this._sortErrors = defaultSort;
|
|
63591
|
+
this._nodes = [];
|
|
63592
|
+
this._excludedEdges = [];
|
|
63593
|
+
this.withMutation(() => {
|
|
63594
|
+
if (spec) {
|
|
63595
|
+
this.shape(spec);
|
|
63596
|
+
}
|
|
63597
|
+
});
|
|
63598
|
+
}
|
|
63599
|
+
_cast(_value, options = {}) {
|
|
63600
|
+
var _options$stripUnknown;
|
|
63601
|
+
let value = super._cast(_value, options);
|
|
63602
|
+
|
|
63603
|
+
//should ignore nulls here
|
|
63604
|
+
if (value === undefined) return this.getDefault(options);
|
|
63605
|
+
if (!this._typeCheck(value)) return value;
|
|
63606
|
+
let fields = this.fields;
|
|
63607
|
+
let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
|
|
63608
|
+
let props = [].concat(this._nodes, Object.keys(value).filter(v => !this._nodes.includes(v)));
|
|
63609
|
+
let intermediateValue = {}; // is filled during the transform below
|
|
63610
|
+
let innerOptions = Object.assign({}, options, {
|
|
63611
|
+
parent: intermediateValue,
|
|
63612
|
+
__validating: options.__validating || false
|
|
63613
|
+
});
|
|
63614
|
+
let isChanged = false;
|
|
63615
|
+
for (const prop of props) {
|
|
63616
|
+
let field = fields[prop];
|
|
63617
|
+
let exists = (prop in value);
|
|
63618
|
+
let inputValue = value[prop];
|
|
63619
|
+
if (field) {
|
|
63620
|
+
let fieldValue;
|
|
63621
|
+
|
|
63622
|
+
// safe to mutate since this is fired in sequence
|
|
63623
|
+
innerOptions.path = (options.path ? `${options.path}.` : '') + prop;
|
|
63624
|
+
field = field.resolve({
|
|
63625
|
+
value: inputValue,
|
|
63626
|
+
context: options.context,
|
|
63627
|
+
parent: intermediateValue
|
|
63628
|
+
});
|
|
63629
|
+
let fieldSpec = field instanceof Schema ? field.spec : undefined;
|
|
63630
|
+
let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
|
|
63631
|
+
if (fieldSpec != null && fieldSpec.strip) {
|
|
63632
|
+
isChanged = isChanged || prop in value;
|
|
63633
|
+
continue;
|
|
63634
|
+
}
|
|
63635
|
+
fieldValue = !options.__validating || !strict ? field.cast(inputValue, innerOptions) : inputValue;
|
|
63636
|
+
if (fieldValue !== undefined) {
|
|
63637
|
+
intermediateValue[prop] = fieldValue;
|
|
63638
|
+
}
|
|
63639
|
+
} else if (exists && !strip) {
|
|
63640
|
+
intermediateValue[prop] = inputValue;
|
|
63641
|
+
}
|
|
63642
|
+
if (exists !== prop in intermediateValue || intermediateValue[prop] !== inputValue) {
|
|
63643
|
+
isChanged = true;
|
|
63644
|
+
}
|
|
63645
|
+
}
|
|
63646
|
+
return isChanged ? intermediateValue : value;
|
|
63647
|
+
}
|
|
63648
|
+
_validate(_value, options = {}, panic, next) {
|
|
63649
|
+
let {
|
|
63650
|
+
from = [],
|
|
63651
|
+
originalValue = _value,
|
|
63652
|
+
recursive = this.spec.recursive
|
|
63653
|
+
} = options;
|
|
63654
|
+
options.from = [{
|
|
63655
|
+
schema: this,
|
|
63656
|
+
value: originalValue
|
|
63657
|
+
}, ...from];
|
|
63658
|
+
// this flag is needed for handling `strict` correctly in the context of
|
|
63659
|
+
// validation vs just casting. e.g strict() on a field is only used when validating
|
|
63660
|
+
options.__validating = true;
|
|
63661
|
+
options.originalValue = originalValue;
|
|
63662
|
+
super._validate(_value, options, panic, (objectErrors, value) => {
|
|
63663
|
+
if (!recursive || !isObject(value)) {
|
|
63664
|
+
next(objectErrors, value);
|
|
63665
|
+
return;
|
|
63666
|
+
}
|
|
63667
|
+
originalValue = originalValue || value;
|
|
63668
|
+
let tests = [];
|
|
63669
|
+
for (let key of this._nodes) {
|
|
63670
|
+
let field = this.fields[key];
|
|
63671
|
+
if (!field || Reference.isRef(field)) {
|
|
63672
|
+
continue;
|
|
63673
|
+
}
|
|
63674
|
+
tests.push(field.asNestedTest({
|
|
63675
|
+
options,
|
|
63676
|
+
key,
|
|
63677
|
+
parent: value,
|
|
63678
|
+
parentPath: options.path,
|
|
63679
|
+
originalParent: originalValue
|
|
63680
|
+
}));
|
|
63681
|
+
}
|
|
63682
|
+
this.runTests({
|
|
63683
|
+
tests,
|
|
63684
|
+
value,
|
|
63685
|
+
originalValue,
|
|
63686
|
+
options
|
|
63687
|
+
}, panic, fieldErrors => {
|
|
63688
|
+
next(fieldErrors.sort(this._sortErrors).concat(objectErrors), value);
|
|
63689
|
+
});
|
|
63690
|
+
});
|
|
63691
|
+
}
|
|
63692
|
+
clone(spec) {
|
|
63693
|
+
const next = super.clone(spec);
|
|
63694
|
+
next.fields = Object.assign({}, this.fields);
|
|
63695
|
+
next._nodes = this._nodes;
|
|
63696
|
+
next._excludedEdges = this._excludedEdges;
|
|
63697
|
+
next._sortErrors = this._sortErrors;
|
|
63698
|
+
return next;
|
|
63699
|
+
}
|
|
63700
|
+
concat(schema) {
|
|
63701
|
+
let next = super.concat(schema);
|
|
63702
|
+
let nextFields = next.fields;
|
|
63703
|
+
for (let [field, schemaOrRef] of Object.entries(this.fields)) {
|
|
63704
|
+
const target = nextFields[field];
|
|
63705
|
+
nextFields[field] = target === undefined ? schemaOrRef : target;
|
|
63706
|
+
}
|
|
63707
|
+
return next.withMutation(s =>
|
|
63708
|
+
// XXX: excludes here is wrong
|
|
63709
|
+
s.setFields(nextFields, [...this._excludedEdges, ...schema._excludedEdges]));
|
|
63710
|
+
}
|
|
63711
|
+
_getDefault(options) {
|
|
63712
|
+
if ('default' in this.spec) {
|
|
63713
|
+
return super._getDefault(options);
|
|
63714
|
+
}
|
|
63715
|
+
|
|
63716
|
+
// if there is no default set invent one
|
|
63717
|
+
if (!this._nodes.length) {
|
|
63718
|
+
return undefined;
|
|
63719
|
+
}
|
|
63720
|
+
let dft = {};
|
|
63721
|
+
this._nodes.forEach(key => {
|
|
63722
|
+
var _innerOptions;
|
|
63723
|
+
const field = this.fields[key];
|
|
63724
|
+
let innerOptions = options;
|
|
63725
|
+
if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
|
|
63726
|
+
innerOptions = Object.assign({}, innerOptions, {
|
|
63727
|
+
parent: innerOptions.value,
|
|
63728
|
+
value: innerOptions.value[key]
|
|
63729
|
+
});
|
|
63730
|
+
}
|
|
63731
|
+
dft[key] = field && 'getDefault' in field ? field.getDefault(innerOptions) : undefined;
|
|
63732
|
+
});
|
|
63733
|
+
return dft;
|
|
63734
|
+
}
|
|
63735
|
+
setFields(shape, excludedEdges) {
|
|
63736
|
+
let next = this.clone();
|
|
63737
|
+
next.fields = shape;
|
|
63738
|
+
next._nodes = sortFields(shape, excludedEdges);
|
|
63739
|
+
next._sortErrors = sortByKeyOrder(Object.keys(shape));
|
|
63740
|
+
// XXX: this carries over edges which may not be what you want
|
|
63741
|
+
if (excludedEdges) next._excludedEdges = excludedEdges;
|
|
63742
|
+
return next;
|
|
63743
|
+
}
|
|
63744
|
+
shape(additions, excludes = []) {
|
|
63745
|
+
return this.clone().withMutation(next => {
|
|
63746
|
+
let edges = next._excludedEdges;
|
|
63747
|
+
if (excludes.length) {
|
|
63748
|
+
if (!Array.isArray(excludes[0])) excludes = [excludes];
|
|
63749
|
+
edges = [...next._excludedEdges, ...excludes];
|
|
63750
|
+
}
|
|
63751
|
+
|
|
63752
|
+
// XXX: excludes here is wrong
|
|
63753
|
+
return next.setFields(Object.assign(next.fields, additions), edges);
|
|
63754
|
+
});
|
|
63755
|
+
}
|
|
63756
|
+
partial() {
|
|
63757
|
+
const partial = {};
|
|
63758
|
+
for (const [key, schema] of Object.entries(this.fields)) {
|
|
63759
|
+
partial[key] = 'optional' in schema && schema.optional instanceof Function ? schema.optional() : schema;
|
|
63760
|
+
}
|
|
63761
|
+
return this.setFields(partial);
|
|
63762
|
+
}
|
|
63763
|
+
deepPartial() {
|
|
63764
|
+
const next = deepPartial(this);
|
|
63765
|
+
return next;
|
|
63766
|
+
}
|
|
63767
|
+
pick(keys) {
|
|
63768
|
+
const picked = {};
|
|
63769
|
+
for (const key of keys) {
|
|
63770
|
+
if (this.fields[key]) picked[key] = this.fields[key];
|
|
63771
|
+
}
|
|
63772
|
+
return this.setFields(picked, this._excludedEdges.filter(([a, b]) => keys.includes(a) && keys.includes(b)));
|
|
63773
|
+
}
|
|
63774
|
+
omit(keys) {
|
|
63775
|
+
const remaining = [];
|
|
63776
|
+
for (const key of Object.keys(this.fields)) {
|
|
63777
|
+
if (keys.includes(key)) continue;
|
|
63778
|
+
remaining.push(key);
|
|
63779
|
+
}
|
|
63780
|
+
return this.pick(remaining);
|
|
63781
|
+
}
|
|
63782
|
+
from(from, to, alias) {
|
|
63783
|
+
let fromGetter = propertyExprExports.getter(from, true);
|
|
63784
|
+
return this.transform(obj => {
|
|
63785
|
+
if (!obj) return obj;
|
|
63786
|
+
let newObj = obj;
|
|
63787
|
+
if (deepHas(obj, from)) {
|
|
63788
|
+
newObj = Object.assign({}, obj);
|
|
63789
|
+
if (!alias) delete newObj[from];
|
|
63790
|
+
newObj[to] = fromGetter(obj);
|
|
63791
|
+
}
|
|
63792
|
+
return newObj;
|
|
63793
|
+
});
|
|
63794
|
+
}
|
|
63795
|
+
|
|
63796
|
+
/** Parse an input JSON string to an object */
|
|
63797
|
+
json() {
|
|
63798
|
+
return this.transform(parseJson);
|
|
63799
|
+
}
|
|
63800
|
+
|
|
63801
|
+
/**
|
|
63802
|
+
* Similar to `noUnknown` but only validates that an object is the right shape without stripping the unknown keys
|
|
63803
|
+
*/
|
|
63804
|
+
exact(message) {
|
|
63805
|
+
return this.test({
|
|
63806
|
+
name: 'exact',
|
|
63807
|
+
exclusive: true,
|
|
63808
|
+
message: message || object.exact,
|
|
63809
|
+
test(value) {
|
|
63810
|
+
if (value == null) return true;
|
|
63811
|
+
const unknownKeys = unknown(this.schema, value);
|
|
63812
|
+
return unknownKeys.length === 0 || this.createError({
|
|
63813
|
+
params: {
|
|
63814
|
+
properties: unknownKeys.join(', ')
|
|
63815
|
+
}
|
|
63816
|
+
});
|
|
63817
|
+
}
|
|
63818
|
+
});
|
|
63819
|
+
}
|
|
63820
|
+
stripUnknown() {
|
|
63821
|
+
return this.clone({
|
|
63822
|
+
noUnknown: true
|
|
63823
|
+
});
|
|
63824
|
+
}
|
|
63825
|
+
noUnknown(noAllow = true, message = object.noUnknown) {
|
|
63826
|
+
if (typeof noAllow !== 'boolean') {
|
|
63827
|
+
message = noAllow;
|
|
63828
|
+
noAllow = true;
|
|
63829
|
+
}
|
|
63830
|
+
let next = this.test({
|
|
63831
|
+
name: 'noUnknown',
|
|
63832
|
+
exclusive: true,
|
|
63833
|
+
message: message,
|
|
63834
|
+
test(value) {
|
|
63835
|
+
if (value == null) return true;
|
|
63836
|
+
const unknownKeys = unknown(this.schema, value);
|
|
63837
|
+
return !noAllow || unknownKeys.length === 0 || this.createError({
|
|
63838
|
+
params: {
|
|
63839
|
+
unknown: unknownKeys.join(', ')
|
|
63840
|
+
}
|
|
63841
|
+
});
|
|
63842
|
+
}
|
|
63843
|
+
});
|
|
63844
|
+
next.spec.noUnknown = noAllow;
|
|
63845
|
+
return next;
|
|
63846
|
+
}
|
|
63847
|
+
unknown(allow = true, message = object.noUnknown) {
|
|
63848
|
+
return this.noUnknown(!allow, message);
|
|
63849
|
+
}
|
|
63850
|
+
transformKeys(fn) {
|
|
63851
|
+
return this.transform(obj => {
|
|
63852
|
+
if (!obj) return obj;
|
|
63853
|
+
const result = {};
|
|
63854
|
+
for (const key of Object.keys(obj)) result[fn(key)] = obj[key];
|
|
63855
|
+
return result;
|
|
63856
|
+
});
|
|
63857
|
+
}
|
|
63858
|
+
camelCase() {
|
|
63859
|
+
return this.transformKeys(tinyCaseExports.camelCase);
|
|
63860
|
+
}
|
|
63861
|
+
snakeCase() {
|
|
63862
|
+
return this.transformKeys(tinyCaseExports.snakeCase);
|
|
63863
|
+
}
|
|
63864
|
+
constantCase() {
|
|
63865
|
+
return this.transformKeys(key => tinyCaseExports.snakeCase(key).toUpperCase());
|
|
63866
|
+
}
|
|
63867
|
+
describe(options) {
|
|
63868
|
+
const next = (options ? this.resolve(options) : this).clone();
|
|
63869
|
+
const base = super.describe(options);
|
|
63870
|
+
base.fields = {};
|
|
63871
|
+
for (const [key, value] of Object.entries(next.fields)) {
|
|
63872
|
+
var _innerOptions2;
|
|
63873
|
+
let innerOptions = options;
|
|
63874
|
+
if ((_innerOptions2 = innerOptions) != null && _innerOptions2.value) {
|
|
63875
|
+
innerOptions = Object.assign({}, innerOptions, {
|
|
63876
|
+
parent: innerOptions.value,
|
|
63877
|
+
value: innerOptions.value[key]
|
|
63878
|
+
});
|
|
63879
|
+
}
|
|
63880
|
+
base.fields[key] = value.describe(innerOptions);
|
|
63881
|
+
}
|
|
63882
|
+
return base;
|
|
63883
|
+
}
|
|
63884
|
+
}
|
|
63885
|
+
create$3.prototype = ObjectSchema.prototype;
|
|
63886
|
+
|
|
63887
|
+
const schema = create$3().shape({
|
|
63888
|
+
username: create$6().required(),
|
|
63889
|
+
password: create$6().required(),
|
|
63890
|
+
});
|
|
63891
|
+
|
|
63892
|
+
const AuthPage = ({ onSuccessSignIn }) => {
|
|
63893
|
+
const logout = useLogout();
|
|
63894
|
+
const signIn = useSignIn();
|
|
63895
|
+
const showSnackbar = useShowSnackbar();
|
|
63896
|
+
const form = useForm({
|
|
63897
|
+
defaultValues: {
|
|
63898
|
+
username: '',
|
|
63899
|
+
password: '',
|
|
63900
|
+
},
|
|
63901
|
+
resolver: o(schema),
|
|
63902
|
+
});
|
|
63903
|
+
const { register, formState: { isValid }, } = form;
|
|
63904
|
+
const onSubmit = (body) => {
|
|
63905
|
+
signIn.mutate({
|
|
63906
|
+
body,
|
|
63907
|
+
});
|
|
63908
|
+
};
|
|
63909
|
+
React__namespace.useEffect(() => {
|
|
63910
|
+
logout.mutate();
|
|
63911
|
+
}, []);
|
|
63912
|
+
React__namespace.useEffect(() => {
|
|
63913
|
+
if (signIn.error) {
|
|
63914
|
+
const { response } = signIn.error;
|
|
63915
|
+
if (response) {
|
|
63916
|
+
const { data: { detail }, } = response;
|
|
63917
|
+
showSnackbar({
|
|
63918
|
+
message: detail,
|
|
63919
|
+
variant: 'error',
|
|
63920
|
+
});
|
|
63921
|
+
}
|
|
63922
|
+
}
|
|
63923
|
+
}, [signIn.error]);
|
|
63924
|
+
React__namespace.useEffect(() => {
|
|
63925
|
+
if (signIn.data) {
|
|
63926
|
+
onSuccessSignIn(signIn.data);
|
|
63927
|
+
}
|
|
63928
|
+
}, [signIn.data]);
|
|
63929
|
+
return (jsxRuntime.jsx(AuthLayout$1, { children: jsxRuntime.jsxs(CustomForm, { form: form, onSubmit: onSubmit, sx: {
|
|
63930
|
+
justifyContent: 'center',
|
|
63931
|
+
justifyItems: 'center',
|
|
63932
|
+
alignContent: 'center',
|
|
63933
|
+
alignItems: 'center',
|
|
63934
|
+
}, children: [jsxRuntime.jsx(Typography, { variant: "h4", children: "Authorization" }), jsxRuntime.jsx(CustomInput, { ...register('username'), label: "Login", placeholder: "Enter your login" }), jsxRuntime.jsx(CustomInput, { ...register('password'), label: "Password", placeholder: "Enter your password", type: "password" }), jsxRuntime.jsx(Button$1, { type: "submit", variant: "contained", disabled: !isValid, children: "Sign in" })] }) }));
|
|
63935
|
+
};
|
|
63936
|
+
var auth = observer(AuthPage);
|
|
63937
|
+
|
|
59774
63938
|
// define() gets called for each chunk generated by the first Rollup pass.
|
|
59775
63939
|
// The order the chunks are called in is controlled by the imports in bundle.js:
|
|
59776
63940
|
//
|
|
@@ -59826,11 +63990,12 @@ var tangram_min = /*#__PURE__*/Object.freeze({
|
|
|
59826
63990
|
});
|
|
59827
63991
|
|
|
59828
63992
|
exports.ApiService = ApiService;
|
|
63993
|
+
exports.AuthPage = auth;
|
|
59829
63994
|
exports.AuthStore = AuthStore;
|
|
59830
|
-
exports.Button =
|
|
63995
|
+
exports.Button = Button$1;
|
|
59831
63996
|
exports.Card = CustomCard;
|
|
59832
63997
|
exports.Checkbox = CustomCheckbox;
|
|
59833
|
-
exports.DartcomAuthProvider = auth;
|
|
63998
|
+
exports.DartcomAuthProvider = auth$1;
|
|
59834
63999
|
exports.DartcomMobxProvider = DartcomMobxProvider;
|
|
59835
64000
|
exports.DartcomProviders = DartcomProviders;
|
|
59836
64001
|
exports.DeleteButton = DeleteButton;
|