md-components-mdigial-azamat 0.0.109 → 0.0.113
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/ActionCardList/ActionCardList.js +32 -7
- package/dist/ActionCardList/index.js +1 -1
- package/dist/ActionCardList/info.js +1 -1
- package/dist/ActionCardSecondaryList/ActionCardSecondaryList.js +32 -0
- package/dist/ActionCardSecondaryList/index.js +6 -0
- package/dist/ActionCardSecondaryList/info.js +11 -0
- package/dist/ActionCardSecondaryList/schema.js +51 -0
- package/dist/ActionCardSecondaryList/types.js +4 -0
- package/dist/ActionIconList/ActionIconList.js +29 -4
- package/dist/AllComponents.js +35 -9
- package/dist/AllComponentsInfo.js +107 -89
- package/dist/AnimatedSwiper/index.js +40 -38
- package/dist/ButtonsList/ButtonsList.js +25 -19
- package/dist/CardImageList/CardImageList.js +130 -73
- package/dist/CardImageList/info.js +1 -1
- package/dist/CardImageList/schema.js +62 -0
- package/dist/Cards/ActionSecondaryCard/ActionSecondaryCard.js +77 -0
- package/dist/Cards/ActionSecondaryCard/index.js +6 -0
- package/dist/Cards/ActionSecondaryCard/info.js +11 -0
- package/dist/Cards/ActionSecondaryCard/types.js +4 -0
- package/dist/Cards/CardImage/CardImage.js +100 -55
- package/dist/Cards/CardImage/index.js +6 -1
- package/dist/Cards/CardImage/info.js +1 -1
- package/dist/Cards/CardImage/schema.js +32 -0
- package/dist/Cards/CardImage/types.js +3 -2
- package/dist/Cards/InfoCard/InfoCard.js +114 -0
- package/dist/Cards/InfoCard/index.js +9 -0
- package/dist/Cards/InfoCard/info.js +11 -0
- package/dist/Cards/InfoCard/schema.js +60 -0
- package/dist/Cards/InfoCard/types.js +4 -0
- package/dist/Cards/PostCard/PostCard.js +60 -0
- package/dist/Cards/PostCard/index.js +6 -0
- package/dist/Cards/PostCard/info.js +11 -0
- package/dist/Cards/PostCard/types.js +4 -0
- package/dist/Cards/WarningCard/WarningCard.js +31 -6
- package/dist/Cards/WarningCard/index.js +1 -1
- package/dist/Cards/WarningCard/info.js +1 -1
- package/dist/Cards/WarningCard/model.js +1 -1
- package/dist/CurrencyRates/CurrencyRates.js +78 -0
- package/dist/CurrencyRates/components/Calculator.js +101 -0
- package/dist/CurrencyRates/components/RateCell.js +15 -0
- package/dist/CurrencyRates/components/RatesTable.js +134 -0
- package/dist/CurrencyRates/components/index.js +6 -0
- package/dist/CurrencyRates/index.js +8 -0
- package/dist/CurrencyRates/info.js +11 -0
- package/dist/CurrencyRates/schema.js +63 -0
- package/dist/CurrencyRates/types.js +4 -0
- package/dist/DownloadFile/components/DownloadFileBanner/DownloadFileBanner.js +1 -1
- package/dist/DownloadFile/components/DownloadFileFull/DownloadFileFull.js +1 -1
- package/dist/DownloadFile/components/DownloadFileHalf/DownloadFileHalf.js +1 -1
- package/dist/DownloadFile/components/DownloadFileMini/DownloadFileMini.js +1 -1
- package/dist/DownloadFile/components/FileBannerSecondary/FileBannerSecondary.js +1 -1
- package/dist/Faq/Faq.js +1 -1
- package/dist/Faq/components/FeedbackForm/FeedbackForm.js +55 -6
- package/dist/Faq/components/FeedbackForm/index.js +1 -1
- package/dist/FieldInput-ef2a18d4.js +2743 -0
- package/dist/Flex-86aee720.js +78 -0
- package/dist/Footer/Footer.js +5 -5
- package/dist/Forms/FormDefault/FormDefault.js +12 -0
- package/dist/Forms/FormDefault/components/FieldCustom.js +11 -0
- package/dist/Forms/FormDefault/components/FieldInput.js +11 -0
- package/dist/Forms/FormDefault/components/FieldSection.js +10 -0
- package/dist/Forms/FormDefault/components/FormContent.js +10 -0
- package/dist/Forms/FormDefault/components/FormFields.js +7 -0
- package/dist/Forms/FormDefault/components/FormSuccessMessage.js +49 -0
- package/dist/Forms/FormDefault/components/index.js +6 -0
- package/dist/Forms/FormDefault/hooks/index.js +10 -0
- package/dist/Forms/FormDefault/hooks/useFieldOptions.js +32 -0
- package/dist/Forms/FormDefault/hooks/useFieldValidation.js +33 -0
- package/dist/Forms/FormDefault/hooks/useFieldVisibility.js +24 -0
- package/dist/Forms/FormDefault/hooks/useFormSubmission.js +64 -0
- package/dist/Forms/FormDefault/index.js +6 -12
- package/dist/Forms/FormDefault/info.js +3 -113
- package/dist/Forms/FormDefault/model/componentRegistry.js +134 -0
- package/dist/Forms/FormDefault/model/fieldTypes.js +18 -0
- package/dist/Forms/FormDefault/model/formElementTypes.js +18 -0
- package/dist/Forms/FormDefault/model/index.js +13 -0
- package/dist/Forms/FormDefault/model/requestForm.js +4 -0
- package/dist/Forms/{model/components.js → FormDefault/schema.js} +36 -7
- package/dist/Forms/FormDefault/utils.js +20 -0
- package/dist/Grid-331af266.js +80 -0
- package/dist/Header/Header.js +54 -42
- package/dist/Header/components/HeaderMainMobile/HeaderMainMobile.js +26 -24
- package/dist/Header/components/HeaderMobile/HeaderMobile.js +67 -52
- package/dist/Header/components/HeaderSearch/HeaderSearch.js +1 -1
- package/dist/Header/components/HeaderTab/HeaderTab.js +17 -15
- package/dist/Header/components/HeaderTabsMobile/HeaderTabsMobile.js +10 -9
- package/dist/Header/components/HeaderWeb/HeaderWeb.js +134 -114
- package/dist/Header/components/TabsOutlined/TabsOutlined.js +8 -7
- package/dist/HeroIconsBanner/HeroIconsBanner.js +71 -54
- package/dist/IconList/IconList.js +59 -33
- package/dist/InfoCardList/InfoCardList.js +100 -0
- package/dist/InfoCardList/index.js +6 -0
- package/dist/InfoCardList/info.js +11 -0
- package/dist/InfoCardList/schema.js +39 -0
- package/dist/InfoCardList/types.js +1 -0
- package/dist/ModalBody/index.js +1 -1
- package/dist/PageViewer/renderComponents.js +1 -1
- package/dist/PostsList/PostsList.js +78 -0
- package/dist/PostsList/index.js +4 -0
- package/dist/PostsList/info.js +11 -0
- package/dist/PostsList/schema.js +49 -0
- package/dist/PostsList/types.js +1 -0
- package/dist/PostsSlider/PostsSlider.js +78 -0
- package/dist/PostsSlider/index.js +4 -0
- package/dist/PostsSlider/info.js +11 -0
- package/dist/PostsSlider/schema.js +49 -0
- package/dist/PostsSlider/types.js +1 -0
- package/dist/PreviewList/PreviewList.js +19 -19
- package/dist/PreviewList/components/PreviewCard/PreviewCard.js +29 -29
- package/dist/RenderAllComponents/RenderAllComponents.js +1 -1
- package/dist/RenderAllComponents/const.js +1 -1
- package/dist/SearchBlock/SearchBlock.js +101 -0
- package/dist/SearchBlock/index.js +4 -0
- package/dist/SearchBlock/info.js +11 -0
- package/dist/SearchBlock/schema.js +36 -0
- package/dist/SegmentedContent/SegmentedContent.js +160 -0
- package/dist/SegmentedContent/components/ContentCard.js +50 -0
- package/dist/SegmentedContent/components/index.js +4 -0
- package/dist/SegmentedContent/index.js +8 -0
- package/dist/SegmentedContent/info.js +12 -0
- package/dist/SegmentedContent/schema.js +108 -0
- package/dist/SegmentedContent/types.js +1 -0
- package/dist/Segments/Segments.js +36 -28
- package/dist/Segments/index.js +8 -2
- package/dist/Segments/info.js +1 -1
- package/dist/Segments/schema.js +21 -0
- package/dist/Segments/types.js +4 -1
- package/dist/SegmentsIcons/SegmentsIcons.js +92 -0
- package/dist/SegmentsIcons/index.js +8 -0
- package/dist/SegmentsIcons/info.js +11 -0
- package/dist/SegmentsIcons/schema.js +14 -0
- package/dist/SegmentsIcons/types.js +1 -0
- package/dist/SwiperList/SwiperList.js +13 -11
- package/dist/assets/index.css +1 -1
- package/dist/{clientApi-642fea4b.js → clientApi-ccb08ba6.js} +7 -7
- package/dist/{componentsMap-855b1df7.js → componentsMap-29ccdfcc.js} +6 -3
- package/dist/{data.mock-182979d1.js → data.mock-bb32e8ee.js} +485 -133
- package/dist/index-0791c17f.js +56 -0
- package/dist/index-2ec92a04.js +32 -0
- package/dist/{index-497f59a8.js → index-b795390d.js} +23 -20
- package/dist/index.esm-0558519f.js +1171 -0
- package/dist/{index.module-c8833286.js → index.module-8835bf96.js} +1 -1
- package/dist/info-72904479.js +791 -0
- package/dist/main.js +151 -116
- package/dist/{mousewheel-865ae601.js → mousewheel-afbc6d42.js} +1 -1
- package/dist/navigation-266856e7.js +136 -0
- package/dist/navigation-cd786a0d.js +133 -0
- package/dist/{palette-c2fe86ec.js → palette-256cf77a.js} +3 -1
- package/dist/{swiper-react-90953710.js → swiper-react-3c2710e8.js} +695 -825
- package/dist/trash/HeroLargeCards/index.js +7 -6
- package/dist/types-c3843cc0.js +4 -0
- package/dist/useDraggableScroll-440da9b7.js +29 -0
- package/dist/useTranslation-d7a3ca6f.js +298 -0
- package/package.json +1 -1
- package/dist/FileLoader/fileLoader.js +0 -22
- package/dist/FileLoader/index.js +0 -8
- package/dist/Forms/FormDefault/componentTypes.js +0 -31
- package/dist/Forms/FormDefault/fieldTypesList.js +0 -45
- package/dist/Forms/helpers/renderFormFields.js +0 -7
- package/dist/Forms/model/requestForm.js +0 -4
- package/dist/index-6686852d.js +0 -1794
- package/dist/index-a0ed2e4a.js +0 -1221
- package/dist/info-34fbb2a8.js +0 -1534
- package/dist/navigation-b894d0cd.js +0 -183
- /package/dist/Forms/{types/formItems.js → FormDefault/model/types.js} +0 -0
|
@@ -0,0 +1,1171 @@
|
|
|
1
|
+
import _ from "react";
|
|
2
|
+
var ge = (e) => e.type === "checkbox", ae = (e) => e instanceof Date, H = (e) => e == null;
|
|
3
|
+
const at = (e) => typeof e == "object";
|
|
4
|
+
var M = (e) => !H(e) && !Array.isArray(e) && at(e) && !ae(e), nt = (e) => M(e) && e.target ? ge(e.target) ? e.target.checked : e.target.value : e, kt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, ut = (e, s) => e.has(kt(s)), Dt = (e) => {
|
|
5
|
+
const s = e.constructor && e.constructor.prototype;
|
|
6
|
+
return M(s) && s.hasOwnProperty("isPrototypeOf");
|
|
7
|
+
}, Re = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
8
|
+
function U(e) {
|
|
9
|
+
let s;
|
|
10
|
+
const t = Array.isArray(e), i = typeof FileList < "u" ? e instanceof FileList : !1;
|
|
11
|
+
if (e instanceof Date)
|
|
12
|
+
s = new Date(e);
|
|
13
|
+
else if (!(Re && (e instanceof Blob || i)) && (t || M(e)))
|
|
14
|
+
if (s = t ? [] : Object.create(Object.getPrototypeOf(e)), !t && !Dt(e))
|
|
15
|
+
s = e;
|
|
16
|
+
else
|
|
17
|
+
for (const l in e)
|
|
18
|
+
e.hasOwnProperty(l) && (s[l] = U(e[l]));
|
|
19
|
+
else
|
|
20
|
+
return e;
|
|
21
|
+
return s;
|
|
22
|
+
}
|
|
23
|
+
var me = (e) => /^\w*$/.test(e), O = (e) => e === void 0, Oe = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Te = (e) => Oe(e.replace(/["|']|\]/g, "").split(/\.|\[/)), y = (e, s, t) => {
|
|
24
|
+
if (!s || !M(e))
|
|
25
|
+
return t;
|
|
26
|
+
const i = (me(s) ? [s] : Te(s)).reduce((l, n) => H(l) ? l : l[n], e);
|
|
27
|
+
return O(i) || i === e ? O(e[s]) ? t : e[s] : i;
|
|
28
|
+
}, j = (e) => typeof e == "boolean", S = (e, s, t) => {
|
|
29
|
+
let i = -1;
|
|
30
|
+
const l = me(s) ? [s] : Te(s), n = l.length, d = n - 1;
|
|
31
|
+
for (; ++i < n; ) {
|
|
32
|
+
const c = l[i];
|
|
33
|
+
let D = t;
|
|
34
|
+
if (i !== d) {
|
|
35
|
+
const R = e[c];
|
|
36
|
+
D = M(R) || Array.isArray(R) ? R : isNaN(+l[i + 1]) ? {} : [];
|
|
37
|
+
}
|
|
38
|
+
if (c === "__proto__" || c === "constructor" || c === "prototype")
|
|
39
|
+
return;
|
|
40
|
+
e[c] = D, e = e[c];
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const _e = {
|
|
44
|
+
BLUR: "blur",
|
|
45
|
+
FOCUS_OUT: "focusout",
|
|
46
|
+
CHANGE: "change"
|
|
47
|
+
}, Y = {
|
|
48
|
+
onBlur: "onBlur",
|
|
49
|
+
onChange: "onChange",
|
|
50
|
+
onSubmit: "onSubmit",
|
|
51
|
+
onTouched: "onTouched",
|
|
52
|
+
all: "all"
|
|
53
|
+
}, re = {
|
|
54
|
+
max: "max",
|
|
55
|
+
min: "min",
|
|
56
|
+
maxLength: "maxLength",
|
|
57
|
+
minLength: "minLength",
|
|
58
|
+
pattern: "pattern",
|
|
59
|
+
required: "required",
|
|
60
|
+
validate: "validate"
|
|
61
|
+
}, Le = _.createContext(null);
|
|
62
|
+
Le.displayName = "HookFormContext";
|
|
63
|
+
const Me = () => _.useContext(Le), zt = (e) => {
|
|
64
|
+
const { children: s, ...t } = e;
|
|
65
|
+
return _.createElement(Le.Provider, { value: t }, s);
|
|
66
|
+
};
|
|
67
|
+
var lt = (e, s, t, i = !0) => {
|
|
68
|
+
const l = {
|
|
69
|
+
defaultValues: s._defaultValues
|
|
70
|
+
};
|
|
71
|
+
for (const n in e)
|
|
72
|
+
Object.defineProperty(l, n, {
|
|
73
|
+
get: () => {
|
|
74
|
+
const d = n;
|
|
75
|
+
return s._proxyFormState[d] !== Y.all && (s._proxyFormState[d] = !i || Y.all), t && (t[d] = !0), e[d];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return l;
|
|
79
|
+
};
|
|
80
|
+
const Ue = typeof window < "u" ? _.useLayoutEffect : _.useEffect;
|
|
81
|
+
function Et(e) {
|
|
82
|
+
const s = Me(), { control: t = s.control, disabled: i, name: l, exact: n } = e || {}, [d, c] = _.useState(t._formState), D = _.useRef({
|
|
83
|
+
isDirty: !1,
|
|
84
|
+
isLoading: !1,
|
|
85
|
+
dirtyFields: !1,
|
|
86
|
+
touchedFields: !1,
|
|
87
|
+
validatingFields: !1,
|
|
88
|
+
isValidating: !1,
|
|
89
|
+
isValid: !1,
|
|
90
|
+
errors: !1
|
|
91
|
+
});
|
|
92
|
+
return Ue(() => t._subscribe({
|
|
93
|
+
name: l,
|
|
94
|
+
formState: D.current,
|
|
95
|
+
exact: n,
|
|
96
|
+
callback: (R) => {
|
|
97
|
+
!i && c({
|
|
98
|
+
...t._formState,
|
|
99
|
+
...R
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}), [l, i, n]), _.useEffect(() => {
|
|
103
|
+
D.current.isValid && t._setValid(!0);
|
|
104
|
+
}, [t]), _.useMemo(() => lt(d, t, D.current, !1), [d, t]);
|
|
105
|
+
}
|
|
106
|
+
var z = (e) => typeof e == "string", Ee = (e, s, t, i, l) => z(e) ? (i && s.watch.add(e), y(t, e, l)) : Array.isArray(e) ? e.map((n) => (i && s.watch.add(n), y(t, n))) : (i && (s.watchAll = !0), t), Se = (e) => H(e) || !at(e);
|
|
107
|
+
function J(e, s, t = /* @__PURE__ */ new WeakSet()) {
|
|
108
|
+
if (Se(e) || Se(s))
|
|
109
|
+
return Object.is(e, s);
|
|
110
|
+
if (ae(e) && ae(s))
|
|
111
|
+
return e.getTime() === s.getTime();
|
|
112
|
+
const i = Object.keys(e), l = Object.keys(s);
|
|
113
|
+
if (i.length !== l.length)
|
|
114
|
+
return !1;
|
|
115
|
+
if (t.has(e) || t.has(s))
|
|
116
|
+
return !0;
|
|
117
|
+
t.add(e), t.add(s);
|
|
118
|
+
for (const n of i) {
|
|
119
|
+
const d = e[n];
|
|
120
|
+
if (!l.includes(n))
|
|
121
|
+
return !1;
|
|
122
|
+
if (n !== "ref") {
|
|
123
|
+
const c = s[n];
|
|
124
|
+
if (ae(d) && ae(c) || M(d) && M(c) || Array.isArray(d) && Array.isArray(c) ? !J(d, c, t) : !Object.is(d, c))
|
|
125
|
+
return !1;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return !0;
|
|
129
|
+
}
|
|
130
|
+
function St(e) {
|
|
131
|
+
const s = Me(), { control: t = s.control, name: i, defaultValue: l, disabled: n, exact: d, compute: c } = e || {}, D = _.useRef(l), R = _.useRef(c), x = _.useRef(void 0), V = _.useRef(t), v = _.useRef(i);
|
|
132
|
+
R.current = c;
|
|
133
|
+
const [X, W] = _.useState(() => {
|
|
134
|
+
const m = t._getWatch(i, D.current);
|
|
135
|
+
return R.current ? R.current(m) : m;
|
|
136
|
+
}), C = _.useCallback((m) => {
|
|
137
|
+
const F = Ee(i, t._names, m || t._formValues, !1, D.current);
|
|
138
|
+
return R.current ? R.current(F) : F;
|
|
139
|
+
}, [t._formValues, t._names, i]), N = _.useCallback((m) => {
|
|
140
|
+
if (!n) {
|
|
141
|
+
const F = Ee(i, t._names, m || t._formValues, !1, D.current);
|
|
142
|
+
if (R.current) {
|
|
143
|
+
const $ = R.current(F);
|
|
144
|
+
J($, x.current) || (W($), x.current = $);
|
|
145
|
+
} else
|
|
146
|
+
W(F);
|
|
147
|
+
}
|
|
148
|
+
}, [t._formValues, t._names, n, i]);
|
|
149
|
+
Ue(() => ((V.current !== t || !J(v.current, i)) && (V.current = t, v.current = i, N()), t._subscribe({
|
|
150
|
+
name: i,
|
|
151
|
+
formState: {
|
|
152
|
+
values: !0
|
|
153
|
+
},
|
|
154
|
+
exact: d,
|
|
155
|
+
callback: (m) => {
|
|
156
|
+
N(m.values);
|
|
157
|
+
}
|
|
158
|
+
})), [t, d, i, N]), _.useEffect(() => t._removeUnmounted());
|
|
159
|
+
const Z = V.current !== t, b = v.current, B = _.useMemo(() => {
|
|
160
|
+
if (n)
|
|
161
|
+
return null;
|
|
162
|
+
const m = !Z && !J(b, i);
|
|
163
|
+
return Z || m ? C() : null;
|
|
164
|
+
}, [n, Z, i, b, C]);
|
|
165
|
+
return B !== null ? B : X;
|
|
166
|
+
}
|
|
167
|
+
function Ct(e) {
|
|
168
|
+
const s = Me(), { name: t, disabled: i, control: l = s.control, shouldUnregister: n, defaultValue: d, exact: c = !0 } = e, D = ut(l._names.array, t), R = _.useMemo(() => y(l._formValues, t, y(l._defaultValues, t, d)), [l, t, d]), x = St({
|
|
169
|
+
control: l,
|
|
170
|
+
name: t,
|
|
171
|
+
defaultValue: R,
|
|
172
|
+
exact: c
|
|
173
|
+
}), V = Et({
|
|
174
|
+
control: l,
|
|
175
|
+
name: t,
|
|
176
|
+
exact: c
|
|
177
|
+
}), v = _.useRef(e), X = _.useRef(void 0), W = _.useRef(l.register(t, {
|
|
178
|
+
...e.rules,
|
|
179
|
+
value: x,
|
|
180
|
+
...j(e.disabled) ? { disabled: e.disabled } : {}
|
|
181
|
+
}));
|
|
182
|
+
v.current = e;
|
|
183
|
+
const C = _.useMemo(() => Object.defineProperties({}, {
|
|
184
|
+
invalid: {
|
|
185
|
+
enumerable: !0,
|
|
186
|
+
get: () => !!y(V.errors, t)
|
|
187
|
+
},
|
|
188
|
+
isDirty: {
|
|
189
|
+
enumerable: !0,
|
|
190
|
+
get: () => !!y(V.dirtyFields, t)
|
|
191
|
+
},
|
|
192
|
+
isTouched: {
|
|
193
|
+
enumerable: !0,
|
|
194
|
+
get: () => !!y(V.touchedFields, t)
|
|
195
|
+
},
|
|
196
|
+
isValidating: {
|
|
197
|
+
enumerable: !0,
|
|
198
|
+
get: () => !!y(V.validatingFields, t)
|
|
199
|
+
},
|
|
200
|
+
error: {
|
|
201
|
+
enumerable: !0,
|
|
202
|
+
get: () => y(V.errors, t)
|
|
203
|
+
}
|
|
204
|
+
}), [V, t]), N = _.useCallback((m) => W.current.onChange({
|
|
205
|
+
target: {
|
|
206
|
+
value: nt(m),
|
|
207
|
+
name: t
|
|
208
|
+
},
|
|
209
|
+
type: _e.CHANGE
|
|
210
|
+
}), [t]), Z = _.useCallback(() => W.current.onBlur({
|
|
211
|
+
target: {
|
|
212
|
+
value: y(l._formValues, t),
|
|
213
|
+
name: t
|
|
214
|
+
},
|
|
215
|
+
type: _e.BLUR
|
|
216
|
+
}), [t, l._formValues]), b = _.useCallback((m) => {
|
|
217
|
+
const F = y(l._fields, t);
|
|
218
|
+
F && m && (F._f.ref = {
|
|
219
|
+
focus: () => m.focus && m.focus(),
|
|
220
|
+
select: () => m.select && m.select(),
|
|
221
|
+
setCustomValidity: ($) => m.setCustomValidity($),
|
|
222
|
+
reportValidity: () => m.reportValidity()
|
|
223
|
+
});
|
|
224
|
+
}, [l._fields, t]), B = _.useMemo(() => ({
|
|
225
|
+
name: t,
|
|
226
|
+
value: x,
|
|
227
|
+
...j(i) || V.disabled ? { disabled: V.disabled || i } : {},
|
|
228
|
+
onChange: N,
|
|
229
|
+
onBlur: Z,
|
|
230
|
+
ref: b
|
|
231
|
+
}), [t, i, V.disabled, N, Z, b, x]);
|
|
232
|
+
return _.useEffect(() => {
|
|
233
|
+
const m = l._options.shouldUnregister || n, F = X.current;
|
|
234
|
+
F && F !== t && !D && l.unregister(F), l.register(t, {
|
|
235
|
+
...v.current.rules,
|
|
236
|
+
...j(v.current.disabled) ? { disabled: v.current.disabled } : {}
|
|
237
|
+
});
|
|
238
|
+
const $ = (K, oe) => {
|
|
239
|
+
const I = y(l._fields, K);
|
|
240
|
+
I && I._f && (I._f.mount = oe);
|
|
241
|
+
};
|
|
242
|
+
if ($(t, !0), m) {
|
|
243
|
+
const K = U(y(l._options.defaultValues, t, v.current.defaultValue));
|
|
244
|
+
S(l._defaultValues, t, K), O(y(l._formValues, t)) && S(l._formValues, t, K);
|
|
245
|
+
}
|
|
246
|
+
return !D && l.register(t), X.current = t, () => {
|
|
247
|
+
(D ? m && !l._state.action : m) ? l.unregister(t) : $(t, !1);
|
|
248
|
+
};
|
|
249
|
+
}, [t, l, D, n]), _.useEffect(() => {
|
|
250
|
+
l._setDisabledField({
|
|
251
|
+
disabled: i,
|
|
252
|
+
name: t
|
|
253
|
+
});
|
|
254
|
+
}, [i, t, l]), _.useMemo(() => ({
|
|
255
|
+
field: B,
|
|
256
|
+
formState: V,
|
|
257
|
+
fieldState: C
|
|
258
|
+
}), [B, V, C]);
|
|
259
|
+
}
|
|
260
|
+
const Gt = (e) => e.render(Ct(e));
|
|
261
|
+
var Rt = (e, s, t, i, l) => s ? {
|
|
262
|
+
...t[e],
|
|
263
|
+
types: {
|
|
264
|
+
...t[e] && t[e].types ? t[e].types : {},
|
|
265
|
+
[i]: l || !0
|
|
266
|
+
}
|
|
267
|
+
} : {}, ce = (e) => Array.isArray(e) ? e : [e], Ge = () => {
|
|
268
|
+
let e = [];
|
|
269
|
+
return {
|
|
270
|
+
get observers() {
|
|
271
|
+
return e;
|
|
272
|
+
},
|
|
273
|
+
next: (l) => {
|
|
274
|
+
for (const n of e)
|
|
275
|
+
n.next && n.next(l);
|
|
276
|
+
},
|
|
277
|
+
subscribe: (l) => (e.push(l), {
|
|
278
|
+
unsubscribe: () => {
|
|
279
|
+
e = e.filter((n) => n !== l);
|
|
280
|
+
}
|
|
281
|
+
}),
|
|
282
|
+
unsubscribe: () => {
|
|
283
|
+
e = [];
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
function ot(e, s) {
|
|
288
|
+
const t = {};
|
|
289
|
+
for (const i in e)
|
|
290
|
+
if (e.hasOwnProperty(i)) {
|
|
291
|
+
const l = e[i], n = s[i];
|
|
292
|
+
if (l && M(l) && n) {
|
|
293
|
+
const d = ot(l, n);
|
|
294
|
+
M(d) && (t[i] = d);
|
|
295
|
+
} else
|
|
296
|
+
e[i] && (t[i] = n);
|
|
297
|
+
}
|
|
298
|
+
return t;
|
|
299
|
+
}
|
|
300
|
+
var p = (e) => M(e) && !Object.keys(e).length, Ne = (e) => e.type === "file", Q = (e) => typeof e == "function", be = (e) => {
|
|
301
|
+
if (!Re)
|
|
302
|
+
return !1;
|
|
303
|
+
const s = e ? e.ownerDocument : 0;
|
|
304
|
+
return e instanceof (s && s.defaultView ? s.defaultView.HTMLElement : HTMLElement);
|
|
305
|
+
}, dt = (e) => e.type === "select-multiple", Be = (e) => e.type === "radio", Ot = (e) => Be(e) || ge(e), De = (e) => be(e) && e.isConnected;
|
|
306
|
+
function Tt(e, s) {
|
|
307
|
+
const t = s.slice(0, -1).length;
|
|
308
|
+
let i = 0;
|
|
309
|
+
for (; i < t; )
|
|
310
|
+
e = O(e) ? i++ : e[s[i++]];
|
|
311
|
+
return e;
|
|
312
|
+
}
|
|
313
|
+
function Lt(e) {
|
|
314
|
+
for (const s in e)
|
|
315
|
+
if (e.hasOwnProperty(s) && !O(e[s]))
|
|
316
|
+
return !1;
|
|
317
|
+
return !0;
|
|
318
|
+
}
|
|
319
|
+
function L(e, s) {
|
|
320
|
+
const t = Array.isArray(s) ? s : me(s) ? [s] : Te(s), i = t.length === 1 ? e : Tt(e, t), l = t.length - 1, n = t[l];
|
|
321
|
+
return i && delete i[n], l !== 0 && (M(i) && p(i) || Array.isArray(i) && Lt(i)) && L(e, t.slice(0, -1)), e;
|
|
322
|
+
}
|
|
323
|
+
var Mt = (e) => {
|
|
324
|
+
for (const s in e)
|
|
325
|
+
if (Q(e[s]))
|
|
326
|
+
return !0;
|
|
327
|
+
return !1;
|
|
328
|
+
};
|
|
329
|
+
function ft(e) {
|
|
330
|
+
return Array.isArray(e) || M(e) && !Mt(e);
|
|
331
|
+
}
|
|
332
|
+
function Ce(e, s = {}) {
|
|
333
|
+
for (const t in e) {
|
|
334
|
+
const i = e[t];
|
|
335
|
+
ft(i) ? (s[t] = Array.isArray(i) ? [] : {}, Ce(i, s[t])) : O(i) || (s[t] = !0);
|
|
336
|
+
}
|
|
337
|
+
return s;
|
|
338
|
+
}
|
|
339
|
+
function le(e, s, t) {
|
|
340
|
+
t || (t = Ce(s));
|
|
341
|
+
for (const i in e) {
|
|
342
|
+
const l = e[i];
|
|
343
|
+
if (ft(l))
|
|
344
|
+
O(s) || Se(t[i]) ? t[i] = Ce(l, Array.isArray(l) ? [] : {}) : le(l, H(s) ? {} : s[i], t[i]);
|
|
345
|
+
else {
|
|
346
|
+
const n = s[i];
|
|
347
|
+
t[i] = !J(l, n);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return t;
|
|
351
|
+
}
|
|
352
|
+
const Ye = {
|
|
353
|
+
value: !1,
|
|
354
|
+
isValid: !1
|
|
355
|
+
}, Je = { value: !0, isValid: !0 };
|
|
356
|
+
var ct = (e) => {
|
|
357
|
+
if (Array.isArray(e)) {
|
|
358
|
+
if (e.length > 1) {
|
|
359
|
+
const s = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
|
|
360
|
+
return { value: s, isValid: !!s.length };
|
|
361
|
+
}
|
|
362
|
+
return e[0].checked && !e[0].disabled ? (
|
|
363
|
+
// @ts-expect-error expected to work in the browser
|
|
364
|
+
e[0].attributes && !O(e[0].attributes.value) ? O(e[0].value) || e[0].value === "" ? Je : { value: e[0].value, isValid: !0 } : Je
|
|
365
|
+
) : Ye;
|
|
366
|
+
}
|
|
367
|
+
return Ye;
|
|
368
|
+
}, yt = (e, { valueAsNumber: s, valueAsDate: t, setValueAs: i }) => O(e) ? e : s ? e === "" ? NaN : e && +e : t && z(e) ? new Date(e) : i ? i(e) : e;
|
|
369
|
+
const Qe = {
|
|
370
|
+
isValid: !1,
|
|
371
|
+
value: null
|
|
372
|
+
};
|
|
373
|
+
var gt = (e) => Array.isArray(e) ? e.reduce((s, t) => t && t.checked && !t.disabled ? {
|
|
374
|
+
isValid: !0,
|
|
375
|
+
value: t.value
|
|
376
|
+
} : s, Qe) : Qe;
|
|
377
|
+
function Xe(e) {
|
|
378
|
+
const s = e.ref;
|
|
379
|
+
return Ne(s) ? s.files : Be(s) ? gt(e.refs).value : dt(s) ? [...s.selectedOptions].map(({ value: t }) => t) : ge(s) ? ct(e.refs).value : yt(O(s.value) ? e.ref.value : s.value, e);
|
|
380
|
+
}
|
|
381
|
+
var Ut = (e, s, t, i) => {
|
|
382
|
+
const l = {};
|
|
383
|
+
for (const n of e) {
|
|
384
|
+
const d = y(s, n);
|
|
385
|
+
d && S(l, n, d._f);
|
|
386
|
+
}
|
|
387
|
+
return {
|
|
388
|
+
criteriaMode: t,
|
|
389
|
+
names: [...e],
|
|
390
|
+
fields: l,
|
|
391
|
+
shouldUseNativeValidation: i
|
|
392
|
+
};
|
|
393
|
+
}, Ve = (e) => e instanceof RegExp, fe = (e) => O(e) ? e : Ve(e) ? e.source : M(e) ? Ve(e.value) ? e.value.source : e.value : e, Ze = (e) => ({
|
|
394
|
+
isOnSubmit: !e || e === Y.onSubmit,
|
|
395
|
+
isOnBlur: e === Y.onBlur,
|
|
396
|
+
isOnChange: e === Y.onChange,
|
|
397
|
+
isOnAll: e === Y.all,
|
|
398
|
+
isOnTouch: e === Y.onTouched
|
|
399
|
+
});
|
|
400
|
+
const et = "AsyncFunction";
|
|
401
|
+
var Nt = (e) => !!e && !!e.validate && !!(Q(e.validate) && e.validate.constructor.name === et || M(e.validate) && Object.values(e.validate).find((s) => s.constructor.name === et)), Bt = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), tt = (e, s, t) => !t && (s.watchAll || s.watch.has(e) || [...s.watch].some((i) => e.startsWith(i) && /^\.\w+/.test(e.slice(i.length))));
|
|
402
|
+
const ye = (e, s, t, i) => {
|
|
403
|
+
for (const l of t || Object.keys(e)) {
|
|
404
|
+
const n = y(e, l);
|
|
405
|
+
if (n) {
|
|
406
|
+
const { _f: d, ...c } = n;
|
|
407
|
+
if (d) {
|
|
408
|
+
if (d.refs && d.refs[0] && s(d.refs[0], l) && !i)
|
|
409
|
+
return !0;
|
|
410
|
+
if (d.ref && s(d.ref, d.name) && !i)
|
|
411
|
+
return !0;
|
|
412
|
+
if (ye(c, s))
|
|
413
|
+
break;
|
|
414
|
+
} else if (M(c) && ye(c, s))
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
function rt(e, s, t) {
|
|
420
|
+
const i = y(e, t);
|
|
421
|
+
if (i || me(t))
|
|
422
|
+
return {
|
|
423
|
+
error: i,
|
|
424
|
+
name: t
|
|
425
|
+
};
|
|
426
|
+
const l = t.split(".");
|
|
427
|
+
for (; l.length; ) {
|
|
428
|
+
const n = l.join("."), d = y(s, n), c = y(e, n);
|
|
429
|
+
if (d && !Array.isArray(d) && t !== n)
|
|
430
|
+
return { name: t };
|
|
431
|
+
if (c && c.type)
|
|
432
|
+
return {
|
|
433
|
+
name: n,
|
|
434
|
+
error: c
|
|
435
|
+
};
|
|
436
|
+
if (c && c.root && c.root.type)
|
|
437
|
+
return {
|
|
438
|
+
name: `${n}.root`,
|
|
439
|
+
error: c.root
|
|
440
|
+
};
|
|
441
|
+
l.pop();
|
|
442
|
+
}
|
|
443
|
+
return {
|
|
444
|
+
name: t
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
var It = (e, s, t, i) => {
|
|
448
|
+
t(e);
|
|
449
|
+
const { name: l, ...n } = e;
|
|
450
|
+
return p(n) || Object.keys(n).length >= Object.keys(s).length || Object.keys(n).find((d) => s[d] === (!i || Y.all));
|
|
451
|
+
}, Pt = (e, s, t) => !e || !s || e === s || ce(e).some((i) => i && (t ? i === s : i.startsWith(s) || s.startsWith(i))), pt = (e, s, t, i, l) => l.isOnAll ? !1 : !t && l.isOnTouch ? !(s || e) : (t ? i.isOnBlur : l.isOnBlur) ? !e : (t ? i.isOnChange : l.isOnChange) ? e : !0, Wt = (e, s) => !Oe(y(e, s)).length && L(e, s), qt = (e, s, t) => {
|
|
452
|
+
const i = ce(y(e, t));
|
|
453
|
+
return S(i, "root", s[t]), S(e, t, i), e;
|
|
454
|
+
};
|
|
455
|
+
function st(e, s, t = "validate") {
|
|
456
|
+
if (z(e) || Array.isArray(e) && e.every(z) || j(e) && !e)
|
|
457
|
+
return {
|
|
458
|
+
type: t,
|
|
459
|
+
message: z(e) ? e : "",
|
|
460
|
+
ref: s
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
var ue = (e) => M(e) && !Ve(e) ? e : {
|
|
464
|
+
value: e,
|
|
465
|
+
message: ""
|
|
466
|
+
}, it = async (e, s, t, i, l, n) => {
|
|
467
|
+
const { ref: d, refs: c, required: D, maxLength: R, minLength: x, min: V, max: v, pattern: X, validate: W, name: C, valueAsNumber: N, mount: Z } = e._f, b = y(t, C);
|
|
468
|
+
if (!Z || s.has(C))
|
|
469
|
+
return {};
|
|
470
|
+
const B = c ? c[0] : d, m = (A) => {
|
|
471
|
+
l && B.reportValidity && (B.setCustomValidity(j(A) ? "" : A || ""), B.reportValidity());
|
|
472
|
+
}, F = {}, $ = Be(d), K = ge(d), oe = $ || K, I = (N || Ne(d)) && O(d.value) && O(b) || be(d) && d.value === "" || b === "" || Array.isArray(b) && !b.length, ie = Rt.bind(null, C, i, F), ee = (A, k, T, P = re.maxLength, q = re.minLength) => {
|
|
473
|
+
const te = A ? k : T;
|
|
474
|
+
F[C] = {
|
|
475
|
+
type: A ? P : q,
|
|
476
|
+
message: te,
|
|
477
|
+
ref: d,
|
|
478
|
+
...ie(A ? P : q, te)
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
if (n ? !Array.isArray(b) || !b.length : D && (!oe && (I || H(b)) || j(b) && !b || K && !ct(c).isValid || $ && !gt(c).isValid)) {
|
|
482
|
+
const { value: A, message: k } = z(D) ? { value: !!D, message: D } : ue(D);
|
|
483
|
+
if (A && (F[C] = {
|
|
484
|
+
type: re.required,
|
|
485
|
+
message: k,
|
|
486
|
+
ref: B,
|
|
487
|
+
...ie(re.required, k)
|
|
488
|
+
}, !i))
|
|
489
|
+
return m(k), F;
|
|
490
|
+
}
|
|
491
|
+
if (!I && (!H(V) || !H(v))) {
|
|
492
|
+
let A, k;
|
|
493
|
+
const T = ue(v), P = ue(V);
|
|
494
|
+
if (!H(b) && !isNaN(b)) {
|
|
495
|
+
const q = d.valueAsNumber || b && +b;
|
|
496
|
+
H(T.value) || (A = q > T.value), H(P.value) || (k = q < P.value);
|
|
497
|
+
} else {
|
|
498
|
+
const q = d.valueAsDate || new Date(b), te = (he) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + he), de = d.type == "time", ne = d.type == "week";
|
|
499
|
+
z(T.value) && b && (A = de ? te(b) > te(T.value) : ne ? b > T.value : q > new Date(T.value)), z(P.value) && b && (k = de ? te(b) < te(P.value) : ne ? b < P.value : q < new Date(P.value));
|
|
500
|
+
}
|
|
501
|
+
if ((A || k) && (ee(!!A, T.message, P.message, re.max, re.min), !i))
|
|
502
|
+
return m(F[C].message), F;
|
|
503
|
+
}
|
|
504
|
+
if ((R || x) && !I && (z(b) || n && Array.isArray(b))) {
|
|
505
|
+
const A = ue(R), k = ue(x), T = !H(A.value) && b.length > +A.value, P = !H(k.value) && b.length < +k.value;
|
|
506
|
+
if ((T || P) && (ee(T, A.message, k.message), !i))
|
|
507
|
+
return m(F[C].message), F;
|
|
508
|
+
}
|
|
509
|
+
if (X && !I && z(b)) {
|
|
510
|
+
const { value: A, message: k } = ue(X);
|
|
511
|
+
if (Ve(A) && !b.match(A) && (F[C] = {
|
|
512
|
+
type: re.pattern,
|
|
513
|
+
message: k,
|
|
514
|
+
ref: d,
|
|
515
|
+
...ie(re.pattern, k)
|
|
516
|
+
}, !i))
|
|
517
|
+
return m(k), F;
|
|
518
|
+
}
|
|
519
|
+
if (W) {
|
|
520
|
+
if (Q(W)) {
|
|
521
|
+
const A = await W(b, t), k = st(A, B);
|
|
522
|
+
if (k && (F[C] = {
|
|
523
|
+
...k,
|
|
524
|
+
...ie(re.validate, k.message)
|
|
525
|
+
}, !i))
|
|
526
|
+
return m(k.message), F;
|
|
527
|
+
} else if (M(W)) {
|
|
528
|
+
let A = {};
|
|
529
|
+
for (const k in W) {
|
|
530
|
+
if (!p(A) && !i)
|
|
531
|
+
break;
|
|
532
|
+
const T = st(await W[k](b, t), B, k);
|
|
533
|
+
T && (A = {
|
|
534
|
+
...T,
|
|
535
|
+
...ie(k, T.message)
|
|
536
|
+
}, m(T.message), i && (F[C] = A));
|
|
537
|
+
}
|
|
538
|
+
if (!p(A) && (F[C] = {
|
|
539
|
+
ref: B,
|
|
540
|
+
...A
|
|
541
|
+
}, !i))
|
|
542
|
+
return F;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return m(!0), F;
|
|
546
|
+
};
|
|
547
|
+
const Ht = {
|
|
548
|
+
mode: Y.onSubmit,
|
|
549
|
+
reValidateMode: Y.onChange,
|
|
550
|
+
shouldFocusError: !0
|
|
551
|
+
};
|
|
552
|
+
function $t(e = {}) {
|
|
553
|
+
let s = {
|
|
554
|
+
...Ht,
|
|
555
|
+
...e
|
|
556
|
+
}, t = {
|
|
557
|
+
submitCount: 0,
|
|
558
|
+
isDirty: !1,
|
|
559
|
+
isReady: !1,
|
|
560
|
+
isLoading: Q(s.defaultValues),
|
|
561
|
+
isValidating: !1,
|
|
562
|
+
isSubmitted: !1,
|
|
563
|
+
isSubmitting: !1,
|
|
564
|
+
isSubmitSuccessful: !1,
|
|
565
|
+
isValid: !1,
|
|
566
|
+
touchedFields: {},
|
|
567
|
+
dirtyFields: {},
|
|
568
|
+
validatingFields: {},
|
|
569
|
+
errors: s.errors || {},
|
|
570
|
+
disabled: s.disabled || !1
|
|
571
|
+
}, i = {}, l = M(s.defaultValues) || M(s.values) ? U(s.defaultValues || s.values) || {} : {}, n = s.shouldUnregister ? {} : U(l), d = {
|
|
572
|
+
action: !1,
|
|
573
|
+
mount: !1,
|
|
574
|
+
watch: !1
|
|
575
|
+
}, c = {
|
|
576
|
+
mount: /* @__PURE__ */ new Set(),
|
|
577
|
+
disabled: /* @__PURE__ */ new Set(),
|
|
578
|
+
unMount: /* @__PURE__ */ new Set(),
|
|
579
|
+
array: /* @__PURE__ */ new Set(),
|
|
580
|
+
watch: /* @__PURE__ */ new Set()
|
|
581
|
+
}, D, R = 0;
|
|
582
|
+
const x = {
|
|
583
|
+
isDirty: !1,
|
|
584
|
+
dirtyFields: !1,
|
|
585
|
+
validatingFields: !1,
|
|
586
|
+
touchedFields: !1,
|
|
587
|
+
isValidating: !1,
|
|
588
|
+
isValid: !1,
|
|
589
|
+
errors: !1
|
|
590
|
+
};
|
|
591
|
+
let V = {
|
|
592
|
+
...x
|
|
593
|
+
};
|
|
594
|
+
const v = {
|
|
595
|
+
array: Ge(),
|
|
596
|
+
state: Ge()
|
|
597
|
+
}, X = s.criteriaMode === Y.all, W = (r) => (a) => {
|
|
598
|
+
clearTimeout(R), R = setTimeout(r, a);
|
|
599
|
+
}, C = async (r) => {
|
|
600
|
+
if (!s.disabled && (x.isValid || V.isValid || r)) {
|
|
601
|
+
const a = s.resolver ? p((await K()).errors) : await I(i, !0);
|
|
602
|
+
a !== t.isValid && v.state.next({
|
|
603
|
+
isValid: a
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
}, N = (r, a) => {
|
|
607
|
+
!s.disabled && (x.isValidating || x.validatingFields || V.isValidating || V.validatingFields) && ((r || Array.from(c.mount)).forEach((u) => {
|
|
608
|
+
u && (a ? S(t.validatingFields, u, a) : L(t.validatingFields, u));
|
|
609
|
+
}), v.state.next({
|
|
610
|
+
validatingFields: t.validatingFields,
|
|
611
|
+
isValidating: !p(t.validatingFields)
|
|
612
|
+
}));
|
|
613
|
+
}, Z = (r, a = [], u, g, f = !0, o = !0) => {
|
|
614
|
+
if (g && u && !s.disabled) {
|
|
615
|
+
if (d.action = !0, o && Array.isArray(y(i, r))) {
|
|
616
|
+
const h = u(y(i, r), g.argA, g.argB);
|
|
617
|
+
f && S(i, r, h);
|
|
618
|
+
}
|
|
619
|
+
if (o && Array.isArray(y(t.errors, r))) {
|
|
620
|
+
const h = u(y(t.errors, r), g.argA, g.argB);
|
|
621
|
+
f && S(t.errors, r, h), Wt(t.errors, r);
|
|
622
|
+
}
|
|
623
|
+
if ((x.touchedFields || V.touchedFields) && o && Array.isArray(y(t.touchedFields, r))) {
|
|
624
|
+
const h = u(y(t.touchedFields, r), g.argA, g.argB);
|
|
625
|
+
f && S(t.touchedFields, r, h);
|
|
626
|
+
}
|
|
627
|
+
(x.dirtyFields || V.dirtyFields) && (t.dirtyFields = le(l, n)), v.state.next({
|
|
628
|
+
name: r,
|
|
629
|
+
isDirty: ee(r, a),
|
|
630
|
+
dirtyFields: t.dirtyFields,
|
|
631
|
+
errors: t.errors,
|
|
632
|
+
isValid: t.isValid
|
|
633
|
+
});
|
|
634
|
+
} else
|
|
635
|
+
S(n, r, a);
|
|
636
|
+
}, b = (r, a) => {
|
|
637
|
+
S(t.errors, r, a), v.state.next({
|
|
638
|
+
errors: t.errors
|
|
639
|
+
});
|
|
640
|
+
}, B = (r) => {
|
|
641
|
+
t.errors = r, v.state.next({
|
|
642
|
+
errors: t.errors,
|
|
643
|
+
isValid: !1
|
|
644
|
+
});
|
|
645
|
+
}, m = (r, a, u, g) => {
|
|
646
|
+
const f = y(i, r);
|
|
647
|
+
if (f) {
|
|
648
|
+
const o = y(n, r, O(u) ? y(l, r) : u);
|
|
649
|
+
O(o) || g && g.defaultChecked || a ? S(n, r, a ? o : Xe(f._f)) : T(r, o), d.mount && !d.action && C();
|
|
650
|
+
}
|
|
651
|
+
}, F = (r, a, u, g, f) => {
|
|
652
|
+
let o = !1, h = !1;
|
|
653
|
+
const w = {
|
|
654
|
+
name: r
|
|
655
|
+
};
|
|
656
|
+
if (!s.disabled) {
|
|
657
|
+
if (!u || g) {
|
|
658
|
+
(x.isDirty || V.isDirty) && (h = t.isDirty, t.isDirty = w.isDirty = ee(), o = h !== w.isDirty);
|
|
659
|
+
const E = J(y(l, r), a);
|
|
660
|
+
h = !!y(t.dirtyFields, r), E ? L(t.dirtyFields, r) : S(t.dirtyFields, r, !0), w.dirtyFields = t.dirtyFields, o = o || (x.dirtyFields || V.dirtyFields) && h !== !E;
|
|
661
|
+
}
|
|
662
|
+
if (u) {
|
|
663
|
+
const E = y(t.touchedFields, r);
|
|
664
|
+
E || (S(t.touchedFields, r, u), w.touchedFields = t.touchedFields, o = o || (x.touchedFields || V.touchedFields) && E !== u);
|
|
665
|
+
}
|
|
666
|
+
o && f && v.state.next(w);
|
|
667
|
+
}
|
|
668
|
+
return o ? w : {};
|
|
669
|
+
}, $ = (r, a, u, g) => {
|
|
670
|
+
const f = y(t.errors, r), o = (x.isValid || V.isValid) && j(a) && t.isValid !== a;
|
|
671
|
+
if (s.delayError && u ? (D = W(() => b(r, u)), D(s.delayError)) : (clearTimeout(R), D = null, u ? S(t.errors, r, u) : L(t.errors, r)), (u ? !J(f, u) : f) || !p(g) || o) {
|
|
672
|
+
const h = {
|
|
673
|
+
...g,
|
|
674
|
+
...o && j(a) ? { isValid: a } : {},
|
|
675
|
+
errors: t.errors,
|
|
676
|
+
name: r
|
|
677
|
+
};
|
|
678
|
+
t = {
|
|
679
|
+
...t,
|
|
680
|
+
...h
|
|
681
|
+
}, v.state.next(h);
|
|
682
|
+
}
|
|
683
|
+
}, K = async (r) => {
|
|
684
|
+
N(r, !0);
|
|
685
|
+
const a = await s.resolver(n, s.context, Ut(r || c.mount, i, s.criteriaMode, s.shouldUseNativeValidation));
|
|
686
|
+
return N(r), a;
|
|
687
|
+
}, oe = async (r) => {
|
|
688
|
+
const { errors: a } = await K(r);
|
|
689
|
+
if (r)
|
|
690
|
+
for (const u of r) {
|
|
691
|
+
const g = y(a, u);
|
|
692
|
+
g ? S(t.errors, u, g) : L(t.errors, u);
|
|
693
|
+
}
|
|
694
|
+
else
|
|
695
|
+
t.errors = a;
|
|
696
|
+
return a;
|
|
697
|
+
}, I = async (r, a, u = {
|
|
698
|
+
valid: !0
|
|
699
|
+
}) => {
|
|
700
|
+
for (const g in r) {
|
|
701
|
+
const f = r[g];
|
|
702
|
+
if (f) {
|
|
703
|
+
const { _f: o, ...h } = f;
|
|
704
|
+
if (o) {
|
|
705
|
+
const w = c.array.has(o.name), E = f._f && Nt(f._f);
|
|
706
|
+
E && x.validatingFields && N([o.name], !0);
|
|
707
|
+
const G = await it(f, c.disabled, n, X, s.shouldUseNativeValidation && !a, w);
|
|
708
|
+
if (E && x.validatingFields && N([o.name]), G[o.name] && (u.valid = !1, a))
|
|
709
|
+
break;
|
|
710
|
+
!a && (y(G, o.name) ? w ? qt(t.errors, G, o.name) : S(t.errors, o.name, G[o.name]) : L(t.errors, o.name));
|
|
711
|
+
}
|
|
712
|
+
!p(h) && await I(h, a, u);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return u.valid;
|
|
716
|
+
}, ie = () => {
|
|
717
|
+
for (const r of c.unMount) {
|
|
718
|
+
const a = y(i, r);
|
|
719
|
+
a && (a._f.refs ? a._f.refs.every((u) => !De(u)) : !De(a._f.ref)) && Fe(r);
|
|
720
|
+
}
|
|
721
|
+
c.unMount = /* @__PURE__ */ new Set();
|
|
722
|
+
}, ee = (r, a) => !s.disabled && (r && a && S(n, r, a), !J(he(), l)), A = (r, a, u) => Ee(r, c, {
|
|
723
|
+
...d.mount ? n : O(a) ? l : z(r) ? { [r]: a } : a
|
|
724
|
+
}, u, a), k = (r) => Oe(y(d.mount ? n : l, r, s.shouldUnregister ? y(l, r, []) : [])), T = (r, a, u = {}) => {
|
|
725
|
+
const g = y(i, r);
|
|
726
|
+
let f = a;
|
|
727
|
+
if (g) {
|
|
728
|
+
const o = g._f;
|
|
729
|
+
o && (!o.disabled && S(n, r, yt(a, o)), f = be(o.ref) && H(a) ? "" : a, dt(o.ref) ? [...o.ref.options].forEach((h) => h.selected = f.includes(h.value)) : o.refs ? ge(o.ref) ? o.refs.forEach((h) => {
|
|
730
|
+
(!h.defaultChecked || !h.disabled) && (Array.isArray(f) ? h.checked = !!f.find((w) => w === h.value) : h.checked = f === h.value || !!f);
|
|
731
|
+
}) : o.refs.forEach((h) => h.checked = h.value === f) : Ne(o.ref) ? o.ref.value = "" : (o.ref.value = f, o.ref.type || v.state.next({
|
|
732
|
+
name: r,
|
|
733
|
+
values: U(n)
|
|
734
|
+
})));
|
|
735
|
+
}
|
|
736
|
+
(u.shouldDirty || u.shouldTouch) && F(r, f, u.shouldTouch, u.shouldDirty, !0), u.shouldValidate && ne(r);
|
|
737
|
+
}, P = (r, a, u) => {
|
|
738
|
+
for (const g in a) {
|
|
739
|
+
if (!a.hasOwnProperty(g))
|
|
740
|
+
return;
|
|
741
|
+
const f = a[g], o = r + "." + g, h = y(i, o);
|
|
742
|
+
(c.array.has(r) || M(f) || h && !h._f) && !ae(f) ? P(o, f, u) : T(o, f, u);
|
|
743
|
+
}
|
|
744
|
+
}, q = (r, a, u = {}) => {
|
|
745
|
+
const g = y(i, r), f = c.array.has(r), o = U(a);
|
|
746
|
+
S(n, r, o), f ? (v.array.next({
|
|
747
|
+
name: r,
|
|
748
|
+
values: U(n)
|
|
749
|
+
}), (x.isDirty || x.dirtyFields || V.isDirty || V.dirtyFields) && u.shouldDirty && v.state.next({
|
|
750
|
+
name: r,
|
|
751
|
+
dirtyFields: le(l, n),
|
|
752
|
+
isDirty: ee(r, o)
|
|
753
|
+
})) : g && !g._f && !H(o) ? P(r, o, u) : T(r, o, u), tt(r, c) && v.state.next({ ...t, name: r }), v.state.next({
|
|
754
|
+
name: d.mount ? r : void 0,
|
|
755
|
+
values: U(n)
|
|
756
|
+
});
|
|
757
|
+
}, te = async (r) => {
|
|
758
|
+
d.mount = !0;
|
|
759
|
+
const a = r.target;
|
|
760
|
+
let u = a.name, g = !0;
|
|
761
|
+
const f = y(i, u), o = (E) => {
|
|
762
|
+
g = Number.isNaN(E) || ae(E) && isNaN(E.getTime()) || J(E, y(n, u, E));
|
|
763
|
+
}, h = Ze(s.mode), w = Ze(s.reValidateMode);
|
|
764
|
+
if (f) {
|
|
765
|
+
let E, G;
|
|
766
|
+
const ve = a.type ? Xe(f._f) : nt(r), se = r.type === _e.BLUR || r.type === _e.FOCUS_OUT, At = !Bt(f._f) && !s.resolver && !y(t.errors, u) && !f._f.deps || pt(se, y(t.touchedFields, u), t.isSubmitted, w, h), we = tt(u, c, se);
|
|
767
|
+
S(n, u, ve), se ? (!a || !a.readOnly) && (f._f.onBlur && f._f.onBlur(r), D && D(0)) : f._f.onChange && f._f.onChange(r);
|
|
768
|
+
const ke = F(u, ve, se), xt = !p(ke) || we;
|
|
769
|
+
if (!se && v.state.next({
|
|
770
|
+
name: u,
|
|
771
|
+
type: r.type,
|
|
772
|
+
values: U(n)
|
|
773
|
+
}), At)
|
|
774
|
+
return (x.isValid || V.isValid) && (s.mode === "onBlur" ? se && C() : se || C()), xt && v.state.next({ name: u, ...we ? {} : ke });
|
|
775
|
+
if (!se && we && v.state.next({ ...t }), s.resolver) {
|
|
776
|
+
const { errors: je } = await K([u]);
|
|
777
|
+
if (o(ve), g) {
|
|
778
|
+
const wt = rt(t.errors, i, u), ze = rt(je, i, wt.name || u);
|
|
779
|
+
E = ze.error, u = ze.name, G = p(je);
|
|
780
|
+
}
|
|
781
|
+
} else
|
|
782
|
+
N([u], !0), E = (await it(f, c.disabled, n, X, s.shouldUseNativeValidation))[u], N([u]), o(ve), g && (E ? G = !1 : (x.isValid || V.isValid) && (G = await I(i, !0)));
|
|
783
|
+
g && (f._f.deps && (!Array.isArray(f._f.deps) || f._f.deps.length > 0) && ne(f._f.deps), $(u, G, E, ke));
|
|
784
|
+
}
|
|
785
|
+
}, de = (r, a) => {
|
|
786
|
+
if (y(t.errors, a) && r.focus)
|
|
787
|
+
return r.focus(), 1;
|
|
788
|
+
}, ne = async (r, a = {}) => {
|
|
789
|
+
let u, g;
|
|
790
|
+
const f = ce(r);
|
|
791
|
+
if (s.resolver) {
|
|
792
|
+
const o = await oe(O(r) ? r : f);
|
|
793
|
+
u = p(o), g = r ? !f.some((h) => y(o, h)) : u;
|
|
794
|
+
} else
|
|
795
|
+
r ? (g = (await Promise.all(f.map(async (o) => {
|
|
796
|
+
const h = y(i, o);
|
|
797
|
+
return await I(h && h._f ? { [o]: h } : h);
|
|
798
|
+
}))).every(Boolean), !(!g && !t.isValid) && C()) : g = u = await I(i);
|
|
799
|
+
return v.state.next({
|
|
800
|
+
...!z(r) || (x.isValid || V.isValid) && u !== t.isValid ? {} : { name: r },
|
|
801
|
+
...s.resolver || !r ? { isValid: u } : {},
|
|
802
|
+
errors: t.errors
|
|
803
|
+
}), a.shouldFocus && !g && ye(i, de, r ? f : c.mount), g;
|
|
804
|
+
}, he = (r, a) => {
|
|
805
|
+
let u = {
|
|
806
|
+
...d.mount ? n : l
|
|
807
|
+
};
|
|
808
|
+
return a && (u = ot(a.dirtyFields ? t.dirtyFields : t.touchedFields, u)), O(r) ? u : z(r) ? y(u, r) : r.map((g) => y(u, g));
|
|
809
|
+
}, Ie = (r, a) => ({
|
|
810
|
+
invalid: !!y((a || t).errors, r),
|
|
811
|
+
isDirty: !!y((a || t).dirtyFields, r),
|
|
812
|
+
error: y((a || t).errors, r),
|
|
813
|
+
isValidating: !!y(t.validatingFields, r),
|
|
814
|
+
isTouched: !!y((a || t).touchedFields, r)
|
|
815
|
+
}), ht = (r) => {
|
|
816
|
+
r && ce(r).forEach((a) => L(t.errors, a)), v.state.next({
|
|
817
|
+
errors: r ? t.errors : {}
|
|
818
|
+
});
|
|
819
|
+
}, Pe = (r, a, u) => {
|
|
820
|
+
const g = (y(i, r, { _f: {} })._f || {}).ref, f = y(t.errors, r) || {}, { ref: o, message: h, type: w, ...E } = f;
|
|
821
|
+
S(t.errors, r, {
|
|
822
|
+
...E,
|
|
823
|
+
...a,
|
|
824
|
+
ref: g
|
|
825
|
+
}), v.state.next({
|
|
826
|
+
name: r,
|
|
827
|
+
errors: t.errors,
|
|
828
|
+
isValid: !1
|
|
829
|
+
}), u && u.shouldFocus && g && g.focus && g.focus();
|
|
830
|
+
}, vt = (r, a) => Q(r) ? v.state.subscribe({
|
|
831
|
+
next: (u) => "values" in u && r(A(void 0, a), u)
|
|
832
|
+
}) : A(r, a, !0), pe = (r) => v.state.subscribe({
|
|
833
|
+
next: (a) => {
|
|
834
|
+
Pt(r.name, a.name, r.exact) && It(a, r.formState || x, Ft, r.reRenderRoot) && r.callback({
|
|
835
|
+
values: { ...n },
|
|
836
|
+
...t,
|
|
837
|
+
...a,
|
|
838
|
+
defaultValues: l
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
}).unsubscribe, _t = (r) => (d.mount = !0, V = {
|
|
842
|
+
...V,
|
|
843
|
+
...r.formState
|
|
844
|
+
}, pe({
|
|
845
|
+
...r,
|
|
846
|
+
formState: V
|
|
847
|
+
})), Fe = (r, a = {}) => {
|
|
848
|
+
for (const u of r ? ce(r) : c.mount)
|
|
849
|
+
c.mount.delete(u), c.array.delete(u), a.keepValue || (L(i, u), L(n, u)), !a.keepError && L(t.errors, u), !a.keepDirty && L(t.dirtyFields, u), !a.keepTouched && L(t.touchedFields, u), !a.keepIsValidating && L(t.validatingFields, u), !s.shouldUnregister && !a.keepDefaultValue && L(l, u);
|
|
850
|
+
v.state.next({
|
|
851
|
+
values: U(n)
|
|
852
|
+
}), v.state.next({
|
|
853
|
+
...t,
|
|
854
|
+
...a.keepDirty ? { isDirty: ee() } : {}
|
|
855
|
+
}), !a.keepIsValid && C();
|
|
856
|
+
}, We = ({ disabled: r, name: a }) => {
|
|
857
|
+
(j(r) && d.mount || r || c.disabled.has(a)) && (r ? c.disabled.add(a) : c.disabled.delete(a));
|
|
858
|
+
}, Ae = (r, a = {}) => {
|
|
859
|
+
let u = y(i, r);
|
|
860
|
+
const g = j(a.disabled) || j(s.disabled);
|
|
861
|
+
return S(i, r, {
|
|
862
|
+
...u || {},
|
|
863
|
+
_f: {
|
|
864
|
+
...u && u._f ? u._f : { ref: { name: r } },
|
|
865
|
+
name: r,
|
|
866
|
+
mount: !0,
|
|
867
|
+
...a
|
|
868
|
+
}
|
|
869
|
+
}), c.mount.add(r), u ? We({
|
|
870
|
+
disabled: j(a.disabled) ? a.disabled : s.disabled,
|
|
871
|
+
name: r
|
|
872
|
+
}) : m(r, !0, a.value), {
|
|
873
|
+
...g ? { disabled: a.disabled || s.disabled } : {},
|
|
874
|
+
...s.progressive ? {
|
|
875
|
+
required: !!a.required,
|
|
876
|
+
min: fe(a.min),
|
|
877
|
+
max: fe(a.max),
|
|
878
|
+
minLength: fe(a.minLength),
|
|
879
|
+
maxLength: fe(a.maxLength),
|
|
880
|
+
pattern: fe(a.pattern)
|
|
881
|
+
} : {},
|
|
882
|
+
name: r,
|
|
883
|
+
onChange: te,
|
|
884
|
+
onBlur: te,
|
|
885
|
+
ref: (f) => {
|
|
886
|
+
if (f) {
|
|
887
|
+
Ae(r, a), u = y(i, r);
|
|
888
|
+
const o = O(f.value) && f.querySelectorAll && f.querySelectorAll("input,select,textarea")[0] || f, h = Ot(o), w = u._f.refs || [];
|
|
889
|
+
if (h ? w.find((E) => E === o) : o === u._f.ref)
|
|
890
|
+
return;
|
|
891
|
+
S(i, r, {
|
|
892
|
+
_f: {
|
|
893
|
+
...u._f,
|
|
894
|
+
...h ? {
|
|
895
|
+
refs: [
|
|
896
|
+
...w.filter(De),
|
|
897
|
+
o,
|
|
898
|
+
...Array.isArray(y(l, r)) ? [{}] : []
|
|
899
|
+
],
|
|
900
|
+
ref: { type: o.type, name: r }
|
|
901
|
+
} : { ref: o }
|
|
902
|
+
}
|
|
903
|
+
}), m(r, !1, void 0, o);
|
|
904
|
+
} else
|
|
905
|
+
u = y(i, r, {}), u._f && (u._f.mount = !1), (s.shouldUnregister || a.shouldUnregister) && !(ut(c.array, r) && d.action) && c.unMount.add(r);
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
}, xe = () => s.shouldFocusError && ye(i, de, c.mount), bt = (r) => {
|
|
909
|
+
j(r) && (v.state.next({ disabled: r }), ye(i, (a, u) => {
|
|
910
|
+
const g = y(i, u);
|
|
911
|
+
g && (a.disabled = g._f.disabled || r, Array.isArray(g._f.refs) && g._f.refs.forEach((f) => {
|
|
912
|
+
f.disabled = g._f.disabled || r;
|
|
913
|
+
}));
|
|
914
|
+
}, 0, !1));
|
|
915
|
+
}, qe = (r, a) => async (u) => {
|
|
916
|
+
let g;
|
|
917
|
+
u && (u.preventDefault && u.preventDefault(), u.persist && u.persist());
|
|
918
|
+
let f = U(n);
|
|
919
|
+
if (v.state.next({
|
|
920
|
+
isSubmitting: !0
|
|
921
|
+
}), s.resolver) {
|
|
922
|
+
const { errors: o, values: h } = await K();
|
|
923
|
+
t.errors = o, f = U(h);
|
|
924
|
+
} else
|
|
925
|
+
await I(i);
|
|
926
|
+
if (c.disabled.size)
|
|
927
|
+
for (const o of c.disabled)
|
|
928
|
+
L(f, o);
|
|
929
|
+
if (L(t.errors, "root"), p(t.errors)) {
|
|
930
|
+
v.state.next({
|
|
931
|
+
errors: {}
|
|
932
|
+
});
|
|
933
|
+
try {
|
|
934
|
+
await r(f, u);
|
|
935
|
+
} catch (o) {
|
|
936
|
+
g = o;
|
|
937
|
+
}
|
|
938
|
+
} else
|
|
939
|
+
a && await a({ ...t.errors }, u), xe(), setTimeout(xe);
|
|
940
|
+
if (v.state.next({
|
|
941
|
+
isSubmitted: !0,
|
|
942
|
+
isSubmitting: !1,
|
|
943
|
+
isSubmitSuccessful: p(t.errors) && !g,
|
|
944
|
+
submitCount: t.submitCount + 1,
|
|
945
|
+
errors: t.errors
|
|
946
|
+
}), g)
|
|
947
|
+
throw g;
|
|
948
|
+
}, Vt = (r, a = {}) => {
|
|
949
|
+
y(i, r) && (O(a.defaultValue) ? q(r, U(y(l, r))) : (q(r, a.defaultValue), S(l, r, U(a.defaultValue))), a.keepTouched || L(t.touchedFields, r), a.keepDirty || (L(t.dirtyFields, r), t.isDirty = a.defaultValue ? ee(r, U(y(l, r))) : ee()), a.keepError || (L(t.errors, r), x.isValid && C()), v.state.next({ ...t }));
|
|
950
|
+
}, He = (r, a = {}) => {
|
|
951
|
+
const u = r ? U(r) : l, g = U(u), f = p(r), o = f ? l : g;
|
|
952
|
+
if (a.keepDefaultValues || (l = u), !a.keepValues) {
|
|
953
|
+
if (a.keepDirtyValues) {
|
|
954
|
+
const h = /* @__PURE__ */ new Set([
|
|
955
|
+
...c.mount,
|
|
956
|
+
...Object.keys(le(l, n))
|
|
957
|
+
]);
|
|
958
|
+
for (const w of Array.from(h))
|
|
959
|
+
y(t.dirtyFields, w) ? S(o, w, y(n, w)) : q(w, y(o, w));
|
|
960
|
+
} else {
|
|
961
|
+
if (Re && O(r))
|
|
962
|
+
for (const h of c.mount) {
|
|
963
|
+
const w = y(i, h);
|
|
964
|
+
if (w && w._f) {
|
|
965
|
+
const E = Array.isArray(w._f.refs) ? w._f.refs[0] : w._f.ref;
|
|
966
|
+
if (be(E)) {
|
|
967
|
+
const G = E.closest("form");
|
|
968
|
+
if (G) {
|
|
969
|
+
G.reset();
|
|
970
|
+
break;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
if (a.keepFieldsRef)
|
|
976
|
+
for (const h of c.mount)
|
|
977
|
+
q(h, y(o, h));
|
|
978
|
+
else
|
|
979
|
+
i = {};
|
|
980
|
+
}
|
|
981
|
+
n = s.shouldUnregister ? a.keepDefaultValues ? U(l) : {} : U(o), v.array.next({
|
|
982
|
+
values: { ...o }
|
|
983
|
+
}), v.state.next({
|
|
984
|
+
values: { ...o }
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
c = {
|
|
988
|
+
mount: a.keepDirtyValues ? c.mount : /* @__PURE__ */ new Set(),
|
|
989
|
+
unMount: /* @__PURE__ */ new Set(),
|
|
990
|
+
array: /* @__PURE__ */ new Set(),
|
|
991
|
+
disabled: /* @__PURE__ */ new Set(),
|
|
992
|
+
watch: /* @__PURE__ */ new Set(),
|
|
993
|
+
watchAll: !1,
|
|
994
|
+
focus: ""
|
|
995
|
+
}, d.mount = !x.isValid || !!a.keepIsValid || !!a.keepDirtyValues || !s.shouldUnregister && !p(o), d.watch = !!s.shouldUnregister, d.action = !1, a.keepErrors || (t.errors = {}), v.state.next({
|
|
996
|
+
submitCount: a.keepSubmitCount ? t.submitCount : 0,
|
|
997
|
+
isDirty: f ? !1 : a.keepDirty ? t.isDirty : !!(a.keepDefaultValues && !J(r, l)),
|
|
998
|
+
isSubmitted: a.keepIsSubmitted ? t.isSubmitted : !1,
|
|
999
|
+
dirtyFields: f ? {} : a.keepDirtyValues ? a.keepDefaultValues && n ? le(l, n) : t.dirtyFields : a.keepDefaultValues && r ? le(l, r) : a.keepDirty ? t.dirtyFields : {},
|
|
1000
|
+
touchedFields: a.keepTouched ? t.touchedFields : {},
|
|
1001
|
+
errors: a.keepErrors ? t.errors : {},
|
|
1002
|
+
isSubmitSuccessful: a.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
|
|
1003
|
+
isSubmitting: !1,
|
|
1004
|
+
defaultValues: l
|
|
1005
|
+
});
|
|
1006
|
+
}, $e = (r, a) => He(Q(r) ? r(n) : r, a), mt = (r, a = {}) => {
|
|
1007
|
+
const u = y(i, r), g = u && u._f;
|
|
1008
|
+
if (g) {
|
|
1009
|
+
const f = g.refs ? g.refs[0] : g.ref;
|
|
1010
|
+
f.focus && (f.focus(), a.shouldSelect && Q(f.select) && f.select());
|
|
1011
|
+
}
|
|
1012
|
+
}, Ft = (r) => {
|
|
1013
|
+
t = {
|
|
1014
|
+
...t,
|
|
1015
|
+
...r
|
|
1016
|
+
};
|
|
1017
|
+
}, Ke = {
|
|
1018
|
+
control: {
|
|
1019
|
+
register: Ae,
|
|
1020
|
+
unregister: Fe,
|
|
1021
|
+
getFieldState: Ie,
|
|
1022
|
+
handleSubmit: qe,
|
|
1023
|
+
setError: Pe,
|
|
1024
|
+
_subscribe: pe,
|
|
1025
|
+
_runSchema: K,
|
|
1026
|
+
_focusError: xe,
|
|
1027
|
+
_getWatch: A,
|
|
1028
|
+
_getDirty: ee,
|
|
1029
|
+
_setValid: C,
|
|
1030
|
+
_setFieldArray: Z,
|
|
1031
|
+
_setDisabledField: We,
|
|
1032
|
+
_setErrors: B,
|
|
1033
|
+
_getFieldArray: k,
|
|
1034
|
+
_reset: He,
|
|
1035
|
+
_resetDefaultValues: () => Q(s.defaultValues) && s.defaultValues().then((r) => {
|
|
1036
|
+
$e(r, s.resetOptions), v.state.next({
|
|
1037
|
+
isLoading: !1
|
|
1038
|
+
});
|
|
1039
|
+
}),
|
|
1040
|
+
_removeUnmounted: ie,
|
|
1041
|
+
_disableForm: bt,
|
|
1042
|
+
_subjects: v,
|
|
1043
|
+
_proxyFormState: x,
|
|
1044
|
+
get _fields() {
|
|
1045
|
+
return i;
|
|
1046
|
+
},
|
|
1047
|
+
get _formValues() {
|
|
1048
|
+
return n;
|
|
1049
|
+
},
|
|
1050
|
+
get _state() {
|
|
1051
|
+
return d;
|
|
1052
|
+
},
|
|
1053
|
+
set _state(r) {
|
|
1054
|
+
d = r;
|
|
1055
|
+
},
|
|
1056
|
+
get _defaultValues() {
|
|
1057
|
+
return l;
|
|
1058
|
+
},
|
|
1059
|
+
get _names() {
|
|
1060
|
+
return c;
|
|
1061
|
+
},
|
|
1062
|
+
set _names(r) {
|
|
1063
|
+
c = r;
|
|
1064
|
+
},
|
|
1065
|
+
get _formState() {
|
|
1066
|
+
return t;
|
|
1067
|
+
},
|
|
1068
|
+
get _options() {
|
|
1069
|
+
return s;
|
|
1070
|
+
},
|
|
1071
|
+
set _options(r) {
|
|
1072
|
+
s = {
|
|
1073
|
+
...s,
|
|
1074
|
+
...r
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
},
|
|
1078
|
+
subscribe: _t,
|
|
1079
|
+
trigger: ne,
|
|
1080
|
+
register: Ae,
|
|
1081
|
+
handleSubmit: qe,
|
|
1082
|
+
watch: vt,
|
|
1083
|
+
setValue: q,
|
|
1084
|
+
getValues: he,
|
|
1085
|
+
reset: $e,
|
|
1086
|
+
resetField: Vt,
|
|
1087
|
+
clearErrors: ht,
|
|
1088
|
+
unregister: Fe,
|
|
1089
|
+
setError: Pe,
|
|
1090
|
+
setFocus: mt,
|
|
1091
|
+
getFieldState: Ie
|
|
1092
|
+
};
|
|
1093
|
+
return {
|
|
1094
|
+
...Ke,
|
|
1095
|
+
formControl: Ke
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
function Yt(e = {}) {
|
|
1099
|
+
const s = _.useRef(void 0), t = _.useRef(void 0), [i, l] = _.useState({
|
|
1100
|
+
isDirty: !1,
|
|
1101
|
+
isValidating: !1,
|
|
1102
|
+
isLoading: Q(e.defaultValues),
|
|
1103
|
+
isSubmitted: !1,
|
|
1104
|
+
isSubmitting: !1,
|
|
1105
|
+
isSubmitSuccessful: !1,
|
|
1106
|
+
isValid: !1,
|
|
1107
|
+
submitCount: 0,
|
|
1108
|
+
dirtyFields: {},
|
|
1109
|
+
touchedFields: {},
|
|
1110
|
+
validatingFields: {},
|
|
1111
|
+
errors: e.errors || {},
|
|
1112
|
+
disabled: e.disabled || !1,
|
|
1113
|
+
isReady: !1,
|
|
1114
|
+
defaultValues: Q(e.defaultValues) ? void 0 : e.defaultValues
|
|
1115
|
+
});
|
|
1116
|
+
if (!s.current)
|
|
1117
|
+
if (e.formControl)
|
|
1118
|
+
s.current = {
|
|
1119
|
+
...e.formControl,
|
|
1120
|
+
formState: i
|
|
1121
|
+
}, e.defaultValues && !Q(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
1122
|
+
else {
|
|
1123
|
+
const { formControl: d, ...c } = $t(e);
|
|
1124
|
+
s.current = {
|
|
1125
|
+
...c,
|
|
1126
|
+
formState: i
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
const n = s.current.control;
|
|
1130
|
+
return n._options = e, Ue(() => {
|
|
1131
|
+
const d = n._subscribe({
|
|
1132
|
+
formState: n._proxyFormState,
|
|
1133
|
+
callback: () => l({ ...n._formState }),
|
|
1134
|
+
reRenderRoot: !0
|
|
1135
|
+
});
|
|
1136
|
+
return l((c) => ({
|
|
1137
|
+
...c,
|
|
1138
|
+
isReady: !0
|
|
1139
|
+
})), n._formState.isReady = !0, d;
|
|
1140
|
+
}, [n]), _.useEffect(() => n._disableForm(e.disabled), [n, e.disabled]), _.useEffect(() => {
|
|
1141
|
+
e.mode && (n._options.mode = e.mode), e.reValidateMode && (n._options.reValidateMode = e.reValidateMode);
|
|
1142
|
+
}, [n, e.mode, e.reValidateMode]), _.useEffect(() => {
|
|
1143
|
+
e.errors && (n._setErrors(e.errors), n._focusError());
|
|
1144
|
+
}, [n, e.errors]), _.useEffect(() => {
|
|
1145
|
+
e.shouldUnregister && n._subjects.state.next({
|
|
1146
|
+
values: n._getWatch()
|
|
1147
|
+
});
|
|
1148
|
+
}, [n, e.shouldUnregister]), _.useEffect(() => {
|
|
1149
|
+
if (n._proxyFormState.isDirty) {
|
|
1150
|
+
const d = n._getDirty();
|
|
1151
|
+
d !== i.isDirty && n._subjects.state.next({
|
|
1152
|
+
isDirty: d
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
}, [n, i.isDirty]), _.useEffect(() => {
|
|
1156
|
+
var d;
|
|
1157
|
+
e.values && !J(e.values, t.current) ? (n._reset(e.values, {
|
|
1158
|
+
keepFieldsRef: !0,
|
|
1159
|
+
...n._options.resetOptions
|
|
1160
|
+
}), !((d = n._options.resetOptions) === null || d === void 0) && d.keepIsValid || n._setValid(), t.current = e.values, l((c) => ({ ...c }))) : n._resetDefaultValues();
|
|
1161
|
+
}, [n, e.values]), _.useEffect(() => {
|
|
1162
|
+
n._state.mount || (n._setValid(), n._state.mount = !0), n._state.watch && (n._state.watch = !1, n._subjects.state.next({ ...n._formState })), n._removeUnmounted();
|
|
1163
|
+
}), s.current.formState = lt(i, n), s.current;
|
|
1164
|
+
}
|
|
1165
|
+
export {
|
|
1166
|
+
Gt as C,
|
|
1167
|
+
zt as F,
|
|
1168
|
+
St as a,
|
|
1169
|
+
Me as b,
|
|
1170
|
+
Yt as u
|
|
1171
|
+
};
|