stone-kit 0.0.260 → 0.0.261
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/README.md
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
# Stone-kit
|
|
2
|
-
|
|
3
|
-
Uikit for stone redesign 2.0
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Package installation:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm i stone-kit@latest
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
For Next.js page router in App.tsx:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
import 'stone-kit/dist/style.css'
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
and then:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
import {Button} from 'stone-kit'
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
For other projects u can immediately:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
import {Button} from 'stone-kit'
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Docs
|
|
34
|
-
|
|
35
|
-
### ButtonProps
|
|
36
|
-
|
|
37
|
-
size: optional, size of button. types : 'large' | 'medium' | 'small' | 'tiny'
|
|
38
|
-
|
|
39
|
-
pre: optional, insert icon/text before button text. type: ReactNode
|
|
40
|
-
|
|
41
|
-
post: optional, insert icon/text after button text. type: ReactNode
|
|
42
|
-
|
|
43
|
-
variant: optional, color variants of button. type:
|
|
44
|
-
'blue',
|
|
45
|
-
'gray',
|
|
46
|
-
'whiteStroke',
|
|
47
|
-
'sokolniki',
|
|
48
|
-
'black',
|
|
49
|
-
'whiteFilled'
|
|
50
|
-
|
|
51
|
-
width: optional, width of button. type: 'auto' | 'full'
|
|
52
|
-
|
|
53
|
-
additionalClass: optional, add your custom class to button. type: 'string'
|
|
54
|
-
|
|
55
|
-
as: optional, u can convert button to link. type: 'button' | 'link'. 'button' by default.
|
|
56
|
-
|
|
57
|
-
### MobileButtonProps
|
|
58
|
-
|
|
59
|
-
### Tag
|
|
1
|
+
# Stone-kit
|
|
2
|
+
|
|
3
|
+
Uikit for stone redesign 2.0
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Package installation:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i stone-kit@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
For Next.js page router in App.tsx:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
import 'stone-kit/dist/style.css'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
and then:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
import {Button} from 'stone-kit'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
For other projects u can immediately:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
import {Button} from 'stone-kit'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Docs
|
|
34
|
+
|
|
35
|
+
### ButtonProps
|
|
36
|
+
|
|
37
|
+
size: optional, size of button. types : 'large' | 'medium' | 'small' | 'tiny'
|
|
38
|
+
|
|
39
|
+
pre: optional, insert icon/text before button text. type: ReactNode
|
|
40
|
+
|
|
41
|
+
post: optional, insert icon/text after button text. type: ReactNode
|
|
42
|
+
|
|
43
|
+
variant: optional, color variants of button. type:
|
|
44
|
+
'blue',
|
|
45
|
+
'gray',
|
|
46
|
+
'whiteStroke',
|
|
47
|
+
'sokolniki',
|
|
48
|
+
'black',
|
|
49
|
+
'whiteFilled'
|
|
50
|
+
|
|
51
|
+
width: optional, width of button. type: 'auto' | 'full'
|
|
52
|
+
|
|
53
|
+
additionalClass: optional, add your custom class to button. type: 'string'
|
|
54
|
+
|
|
55
|
+
as: optional, u can convert button to link. type: 'button' | 'link'. 'button' by default.
|
|
56
|
+
|
|
57
|
+
### MobileButtonProps
|
|
58
|
+
|
|
59
|
+
### Tag
|
|
@@ -29,5 +29,5 @@ type IFormPageInputs = {
|
|
|
29
29
|
advCheckBox?: boolean;
|
|
30
30
|
textarea?: string;
|
|
31
31
|
};
|
|
32
|
-
export declare const ModalForm: ({ isFormOpen, setIsFormOpen, title, isEmail, isTextArea, isRequiredPhone, isRequiredEmail, isRequiredPhoneOrEmail, textAreaPlaceholder, subTitle, submitHandler, modalWidth, rowsTextArea, personalCheckBox, advCheckBox, }: IModalFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export declare const ModalForm: ({ isFormOpen, setIsFormOpen, title, isEmail, isTextArea, isRequiredPhone, isRequiredEmail, isRequiredPhoneOrEmail, textAreaPlaceholder, subTitle, submitHandler, modalWidth, rowsTextArea, personalCheckBox, advCheckBox, }: IModalFormProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
33
33
|
export {};
|
|
@@ -20,8 +20,8 @@ const Et = "_btn_q5rib_1", Ct = "_modal_q5rib_9", Bt = "_modalBody_q5rib_16", Tt
|
|
|
20
20
|
inputWrapper: Mt
|
|
21
21
|
};
|
|
22
22
|
var ge = (e) => e.type === "checkbox", oe = (e) => e instanceof Date, T = (e) => e == null;
|
|
23
|
-
const
|
|
24
|
-
var E = (e) => !T(e) && !Array.isArray(e) &&
|
|
23
|
+
const lt = (e) => typeof e == "object";
|
|
24
|
+
var E = (e) => !T(e) && !Array.isArray(e) && lt(e) && !oe(e), Ot = (e) => E(e) && e.target ? ge(e.target) ? e.target.checked : e.target.value : e, Nt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Ut = (e, s) => e.has(Nt(s)), qt = (e) => {
|
|
25
25
|
const s = e.constructor && e.constructor.prototype;
|
|
26
26
|
return E(s) && s.hasOwnProperty("isPrototypeOf");
|
|
27
27
|
}, Re = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
@@ -42,15 +42,15 @@ function P(e) {
|
|
|
42
42
|
return e;
|
|
43
43
|
return s;
|
|
44
44
|
}
|
|
45
|
-
var Ae = (e) => Array.isArray(e) ? e.filter(Boolean) : [],
|
|
45
|
+
var Ae = (e) => Array.isArray(e) ? e.filter(Boolean) : [], p = (e) => e === void 0, d = (e, s, r) => {
|
|
46
46
|
if (!s || !E(e))
|
|
47
47
|
return r;
|
|
48
|
-
const n = Ae(s.split(/[,[\].]+?/)).reduce((u,
|
|
49
|
-
return
|
|
50
|
-
}, te = (e) => typeof e == "boolean", Le = (e) => /^\w*$/.test(e),
|
|
48
|
+
const n = Ae(s.split(/[,[\].]+?/)).reduce((u, a) => T(u) ? u : u[a], e);
|
|
49
|
+
return p(n) || n === e ? p(e[s]) ? r : e[s] : n;
|
|
50
|
+
}, te = (e) => typeof e == "boolean", Le = (e) => /^\w*$/.test(e), at = (e) => Ae(e.replace(/["|']|\]/g, "").split(/\.|\[/)), V = (e, s, r) => {
|
|
51
51
|
let n = -1;
|
|
52
|
-
const u = Le(s) ? [s] :
|
|
53
|
-
for (; ++n <
|
|
52
|
+
const u = Le(s) ? [s] : at(s), a = u.length, y = a - 1;
|
|
53
|
+
for (; ++n < a; ) {
|
|
54
54
|
const g = u[n];
|
|
55
55
|
let M = r;
|
|
56
56
|
if (n !== y) {
|
|
@@ -87,18 +87,18 @@ var It = (e, s, r, n = !0) => {
|
|
|
87
87
|
const u = {
|
|
88
88
|
defaultValues: s._defaultValues
|
|
89
89
|
};
|
|
90
|
-
for (const
|
|
91
|
-
Object.defineProperty(u,
|
|
90
|
+
for (const a in e)
|
|
91
|
+
Object.defineProperty(u, a, {
|
|
92
92
|
get: () => {
|
|
93
|
-
const y =
|
|
93
|
+
const y = a;
|
|
94
94
|
return s._proxyFormState[y] !== j.all && (s._proxyFormState[y] = !n || j.all), e[y];
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
return u;
|
|
98
98
|
}, L = (e) => E(e) && !Object.keys(e).length, Pt = (e, s, r, n) => {
|
|
99
99
|
r(e);
|
|
100
|
-
const { name: u, ...
|
|
101
|
-
return L(
|
|
100
|
+
const { name: u, ...a } = e;
|
|
101
|
+
return L(a) || Object.keys(a).length >= Object.keys(s).length || Object.keys(a).find((y) => s[y] === j.all);
|
|
102
102
|
}, _e = (e) => Array.isArray(e) ? e : [e];
|
|
103
103
|
function Wt(e) {
|
|
104
104
|
const s = W.useRef(e);
|
|
@@ -111,7 +111,7 @@ function Wt(e) {
|
|
|
111
111
|
};
|
|
112
112
|
}, [e.disabled]);
|
|
113
113
|
}
|
|
114
|
-
var J = (e) => typeof e == "string", Ht = (e, s, r, n, u) => J(e) ? (n && s.watch.add(e), d(r, e, u)) : Array.isArray(e) ? e.map((
|
|
114
|
+
var J = (e) => typeof e == "string", Ht = (e, s, r, n, u) => J(e) ? (n && s.watch.add(e), d(r, e, u)) : Array.isArray(e) ? e.map((a) => (n && s.watch.add(a), d(r, a))) : (n && (s.watchAll = !0), r), zt = (e, s, r, n, u) => s ? {
|
|
115
115
|
...r[e],
|
|
116
116
|
types: {
|
|
117
117
|
...r[e] && r[e].types ? r[e].types : {},
|
|
@@ -126,9 +126,9 @@ var J = (e) => typeof e == "string", Ht = (e, s, r, n, u) => J(e) ? (n && s.watc
|
|
|
126
126
|
}), Xe = (e, s, r) => !r && (s.watchAll || s.watch.has(e) || [...s.watch].some((n) => e.startsWith(n) && /^\.\w+/.test(e.slice(n.length))));
|
|
127
127
|
const he = (e, s, r, n) => {
|
|
128
128
|
for (const u of r || Object.keys(e)) {
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
const { _f: y, ...g } =
|
|
129
|
+
const a = d(e, u);
|
|
130
|
+
if (a) {
|
|
131
|
+
const { _f: y, ...g } = a;
|
|
132
132
|
if (y) {
|
|
133
133
|
if (y.refs && y.refs[0] && s(y.refs[0], u) && !n)
|
|
134
134
|
break;
|
|
@@ -161,7 +161,7 @@ var nt = (e) => {
|
|
|
161
161
|
}
|
|
162
162
|
return e[0].checked && !e[0].disabled ? (
|
|
163
163
|
// @ts-expect-error expected to work in the browser
|
|
164
|
-
e[0].attributes && !
|
|
164
|
+
e[0].attributes && !p(e[0].attributes.value) ? p(e[0].value) || e[0].value === "" ? Ze : { value: e[0].value, isValid: !0 } : Ze
|
|
165
165
|
) : Ye;
|
|
166
166
|
}
|
|
167
167
|
return Ye;
|
|
@@ -186,23 +186,23 @@ var ue = (e) => E(e) && !xe(e) ? e : {
|
|
|
186
186
|
value: e,
|
|
187
187
|
message: ""
|
|
188
188
|
}, rt = async (e, s, r, n, u) => {
|
|
189
|
-
const { ref:
|
|
189
|
+
const { ref: a, refs: y, required: g, maxLength: M, minLength: q, min: F, max: _, pattern: ie, validate: H, name: k, valueAsNumber: z, mount: K, disabled: G } = e._f, m = d(s, k);
|
|
190
190
|
if (!K || G)
|
|
191
191
|
return {};
|
|
192
|
-
const O = y ? y[0] :
|
|
192
|
+
const O = y ? y[0] : a, B = (v) => {
|
|
193
193
|
n && O.reportValidity && (O.setCustomValidity(te(v) ? "" : v || ""), O.reportValidity());
|
|
194
|
-
}, A = {}, Y = Oe(
|
|
195
|
-
const I = v ? b :
|
|
196
|
-
A[
|
|
194
|
+
}, A = {}, Y = Oe(a), le = ge(a), Q = Y || le, Z = (z || Me(a)) && p(a.value) && p(m) || be(a) && a.value === "" || m === "" || Array.isArray(m) && !m.length, R = zt.bind(null, k, r, A), ae = (v, b, w, C = X.maxLength, $ = X.minLength) => {
|
|
195
|
+
const I = v ? b : w;
|
|
196
|
+
A[k] = {
|
|
197
197
|
type: v ? C : $,
|
|
198
198
|
message: I,
|
|
199
|
-
ref:
|
|
199
|
+
ref: a,
|
|
200
200
|
...R(v ? C : $, I)
|
|
201
201
|
};
|
|
202
202
|
};
|
|
203
|
-
if (u ? !Array.isArray(m) || !m.length : g && (!Q && (Z || T(m)) || te(m) && !m ||
|
|
203
|
+
if (u ? !Array.isArray(m) || !m.length : g && (!Q && (Z || T(m)) || te(m) && !m || le && !nt(y).isValid || Y && !ut(y).isValid)) {
|
|
204
204
|
const { value: v, message: b } = me(g) ? { value: !!g, message: g } : ue(g);
|
|
205
|
-
if (v && (A[
|
|
205
|
+
if (v && (A[k] = {
|
|
206
206
|
type: X.required,
|
|
207
207
|
message: b,
|
|
208
208
|
ref: O,
|
|
@@ -212,28 +212,28 @@ var ue = (e) => E(e) && !xe(e) ? e : {
|
|
|
212
212
|
}
|
|
213
213
|
if (!Z && (!T(F) || !T(_))) {
|
|
214
214
|
let v, b;
|
|
215
|
-
const
|
|
215
|
+
const w = ue(_), C = ue(F);
|
|
216
216
|
if (!T(m) && !isNaN(m)) {
|
|
217
|
-
const $ =
|
|
218
|
-
T(
|
|
217
|
+
const $ = a.valueAsNumber || m && +m;
|
|
218
|
+
T(w.value) || (v = $ > w.value), T(C.value) || (b = $ < C.value);
|
|
219
219
|
} else {
|
|
220
|
-
const $ =
|
|
221
|
-
J(
|
|
220
|
+
const $ = a.valueAsDate || new Date(m), I = (de) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + de), ce = a.type == "time", fe = a.type == "week";
|
|
221
|
+
J(w.value) && m && (v = ce ? I(m) > I(w.value) : fe ? m > w.value : $ > new Date(w.value)), J(C.value) && m && (b = ce ? I(m) < I(C.value) : fe ? m < C.value : $ < new Date(C.value));
|
|
222
222
|
}
|
|
223
|
-
if ((v || b) && (
|
|
224
|
-
return B(A[
|
|
223
|
+
if ((v || b) && (ae(!!v, w.message, C.message, X.max, X.min), !r))
|
|
224
|
+
return B(A[k].message), A;
|
|
225
225
|
}
|
|
226
226
|
if ((M || q) && !Z && (J(m) || u && Array.isArray(m))) {
|
|
227
|
-
const v = ue(M), b = ue(q),
|
|
228
|
-
if ((
|
|
229
|
-
return B(A[
|
|
227
|
+
const v = ue(M), b = ue(q), w = !T(v.value) && m.length > +v.value, C = !T(b.value) && m.length < +b.value;
|
|
228
|
+
if ((w || C) && (ae(w, v.message, b.message), !r))
|
|
229
|
+
return B(A[k].message), A;
|
|
230
230
|
}
|
|
231
231
|
if (ie && !Z && J(m)) {
|
|
232
232
|
const { value: v, message: b } = ue(ie);
|
|
233
|
-
if (xe(v) && !m.match(v) && (A[
|
|
233
|
+
if (xe(v) && !m.match(v) && (A[k] = {
|
|
234
234
|
type: X.pattern,
|
|
235
235
|
message: b,
|
|
236
|
-
ref:
|
|
236
|
+
ref: a,
|
|
237
237
|
...R(X.pattern, b)
|
|
238
238
|
}, !r))
|
|
239
239
|
return B(b), A;
|
|
@@ -241,7 +241,7 @@ var ue = (e) => E(e) && !xe(e) ? e : {
|
|
|
241
241
|
if (H) {
|
|
242
242
|
if (re(H)) {
|
|
243
243
|
const v = await H(m, s), b = tt(v, O);
|
|
244
|
-
if (b && (A[
|
|
244
|
+
if (b && (A[k] = {
|
|
245
245
|
...b,
|
|
246
246
|
...R(X.validate, b.message)
|
|
247
247
|
}, !r))
|
|
@@ -251,13 +251,13 @@ var ue = (e) => E(e) && !xe(e) ? e : {
|
|
|
251
251
|
for (const b in H) {
|
|
252
252
|
if (!L(v) && !r)
|
|
253
253
|
break;
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
...
|
|
257
|
-
...R(b,
|
|
258
|
-
}, B(
|
|
254
|
+
const w = tt(await H[b](m, s), O, b);
|
|
255
|
+
w && (v = {
|
|
256
|
+
...w,
|
|
257
|
+
...R(b, w.message)
|
|
258
|
+
}, B(w.message), r && (A[k] = v));
|
|
259
259
|
}
|
|
260
|
-
if (!L(v) && (A[
|
|
260
|
+
if (!L(v) && (A[k] = {
|
|
261
261
|
ref: O,
|
|
262
262
|
...v
|
|
263
263
|
}, !r))
|
|
@@ -270,18 +270,18 @@ function jt(e, s) {
|
|
|
270
270
|
const r = s.slice(0, -1).length;
|
|
271
271
|
let n = 0;
|
|
272
272
|
for (; n < r; )
|
|
273
|
-
e =
|
|
273
|
+
e = p(e) ? n++ : e[s[n++]];
|
|
274
274
|
return e;
|
|
275
275
|
}
|
|
276
276
|
function Kt(e) {
|
|
277
277
|
for (const s in e)
|
|
278
|
-
if (e.hasOwnProperty(s) && !
|
|
278
|
+
if (e.hasOwnProperty(s) && !p(e[s]))
|
|
279
279
|
return !1;
|
|
280
280
|
return !0;
|
|
281
281
|
}
|
|
282
282
|
function S(e, s) {
|
|
283
|
-
const r = Array.isArray(s) ? s : Le(s) ? [s] :
|
|
284
|
-
return n && delete n[
|
|
283
|
+
const r = Array.isArray(s) ? s : Le(s) ? [s] : at(s), n = r.length === 1 ? e : jt(e, r), u = r.length - 1, a = r[u];
|
|
284
|
+
return n && delete n[a], u !== 0 && (E(n) && L(n) || Array.isArray(n) && Kt(n)) && S(e, r.slice(0, -1)), e;
|
|
285
285
|
}
|
|
286
286
|
var Ce = () => {
|
|
287
287
|
let e = [];
|
|
@@ -290,19 +290,19 @@ var Ce = () => {
|
|
|
290
290
|
return e;
|
|
291
291
|
},
|
|
292
292
|
next: (u) => {
|
|
293
|
-
for (const
|
|
294
|
-
|
|
293
|
+
for (const a of e)
|
|
294
|
+
a.next && a.next(u);
|
|
295
295
|
},
|
|
296
296
|
subscribe: (u) => (e.push(u), {
|
|
297
297
|
unsubscribe: () => {
|
|
298
|
-
e = e.filter((
|
|
298
|
+
e = e.filter((a) => a !== u);
|
|
299
299
|
}
|
|
300
300
|
}),
|
|
301
301
|
unsubscribe: () => {
|
|
302
302
|
e = [];
|
|
303
303
|
}
|
|
304
304
|
};
|
|
305
|
-
}, Ve = (e) => T(e) || !
|
|
305
|
+
}, Ve = (e) => T(e) || !lt(e);
|
|
306
306
|
function se(e, s) {
|
|
307
307
|
if (Ve(e) || Ve(s))
|
|
308
308
|
return e === s;
|
|
@@ -312,12 +312,12 @@ function se(e, s) {
|
|
|
312
312
|
if (r.length !== n.length)
|
|
313
313
|
return !1;
|
|
314
314
|
for (const u of r) {
|
|
315
|
-
const
|
|
315
|
+
const a = e[u];
|
|
316
316
|
if (!n.includes(u))
|
|
317
317
|
return !1;
|
|
318
318
|
if (u !== "ref") {
|
|
319
319
|
const y = s[u];
|
|
320
|
-
if (oe(
|
|
320
|
+
if (oe(a) && oe(y) || E(a) && E(y) || Array.isArray(a) && Array.isArray(y) ? !se(a, y) : a !== y)
|
|
321
321
|
return !1;
|
|
322
322
|
}
|
|
323
323
|
}
|
|
@@ -340,20 +340,20 @@ function ft(e, s, r) {
|
|
|
340
340
|
const n = Array.isArray(e);
|
|
341
341
|
if (E(e) || n)
|
|
342
342
|
for (const u in e)
|
|
343
|
-
Array.isArray(e[u]) || E(e[u]) && !ct(e[u]) ?
|
|
343
|
+
Array.isArray(e[u]) || E(e[u]) && !ct(e[u]) ? p(s) || Ve(r[u]) ? r[u] = Array.isArray(e[u]) ? Fe(e[u], []) : { ...Fe(e[u]) } : ft(e[u], T(s) ? {} : s[u], r[u]) : r[u] = !se(e[u], s[u]);
|
|
344
344
|
return r;
|
|
345
345
|
}
|
|
346
|
-
var ve = (e, s) => ft(e, s, Fe(s)), dt = (e, { valueAsNumber: s, valueAsDate: r, setValueAs: n }) =>
|
|
346
|
+
var ve = (e, s) => ft(e, s, Fe(s)), dt = (e, { valueAsNumber: s, valueAsDate: r, setValueAs: n }) => p(e) ? e : s ? e === "" ? NaN : e && +e : r && J(e) ? new Date(e) : n ? n(e) : e;
|
|
347
347
|
function Te(e) {
|
|
348
348
|
const s = e.ref;
|
|
349
349
|
if (!(e.refs ? e.refs.every((r) => r.disabled) : s.disabled))
|
|
350
|
-
return Me(s) ? s.files : Oe(s) ? ut(e.refs).value : ot(s) ? [...s.selectedOptions].map(({ value: r }) => r) : ge(s) ? nt(e.refs).value : dt(
|
|
350
|
+
return Me(s) ? s.files : Oe(s) ? ut(e.refs).value : ot(s) ? [...s.selectedOptions].map(({ value: r }) => r) : ge(s) ? nt(e.refs).value : dt(p(s.value) ? e.ref.value : s.value, e);
|
|
351
351
|
}
|
|
352
352
|
var Jt = (e, s, r, n) => {
|
|
353
353
|
const u = {};
|
|
354
|
-
for (const
|
|
355
|
-
const y = d(s,
|
|
356
|
-
y && V(u,
|
|
354
|
+
for (const a of e) {
|
|
355
|
+
const y = d(s, a);
|
|
356
|
+
y && V(u, a, y._f);
|
|
357
357
|
}
|
|
358
358
|
return {
|
|
359
359
|
criteriaMode: r,
|
|
@@ -361,7 +361,7 @@ var Jt = (e, s, r, n) => {
|
|
|
361
361
|
fields: u,
|
|
362
362
|
shouldUseNativeValidation: n
|
|
363
363
|
};
|
|
364
|
-
}, ye = (e) =>
|
|
364
|
+
}, ye = (e) => p(e) ? e : xe(e) ? e.source : E(e) ? xe(e.value) ? e.value.source : e.value : e, Qt = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate);
|
|
365
365
|
function st(e, s, r) {
|
|
366
366
|
const n = d(e, r);
|
|
367
367
|
if (n || Le(r))
|
|
@@ -371,12 +371,12 @@ function st(e, s, r) {
|
|
|
371
371
|
};
|
|
372
372
|
const u = r.split(".");
|
|
373
373
|
for (; u.length; ) {
|
|
374
|
-
const
|
|
375
|
-
if (y && !Array.isArray(y) && r !==
|
|
374
|
+
const a = u.join("."), y = d(s, a), g = d(e, a);
|
|
375
|
+
if (y && !Array.isArray(y) && r !== a)
|
|
376
376
|
return { name: r };
|
|
377
377
|
if (g && g.type)
|
|
378
378
|
return {
|
|
379
|
-
name:
|
|
379
|
+
name: a,
|
|
380
380
|
error: g
|
|
381
381
|
};
|
|
382
382
|
u.pop();
|
|
@@ -409,7 +409,7 @@ function er(e = {}) {
|
|
|
409
409
|
validatingFields: {},
|
|
410
410
|
errors: s.errors || {},
|
|
411
411
|
disabled: s.disabled || !1
|
|
412
|
-
}, n = {}, u = E(s.defaultValues) || E(s.values) ? P(s.defaultValues || s.values) || {} : {},
|
|
412
|
+
}, n = {}, u = E(s.defaultValues) || E(s.values) ? P(s.defaultValues || s.values) || {} : {}, a = s.shouldUnregister ? {} : P(u), y = {
|
|
413
413
|
action: !1,
|
|
414
414
|
mount: !1,
|
|
415
415
|
watch: !1
|
|
@@ -431,7 +431,7 @@ function er(e = {}) {
|
|
|
431
431
|
values: Ce(),
|
|
432
432
|
array: Ce(),
|
|
433
433
|
state: Ce()
|
|
434
|
-
}, ie = Qe(s.mode), H = Qe(s.reValidateMode),
|
|
434
|
+
}, ie = Qe(s.mode), H = Qe(s.reValidateMode), k = s.criteriaMode === j.all, z = (t) => (i) => {
|
|
435
435
|
clearTimeout(q), q = setTimeout(t, i);
|
|
436
436
|
}, K = async (t) => {
|
|
437
437
|
if (F.isValid || t) {
|
|
@@ -441,27 +441,27 @@ function er(e = {}) {
|
|
|
441
441
|
});
|
|
442
442
|
}
|
|
443
443
|
}, G = (t, i) => {
|
|
444
|
-
(F.isValidating || F.validatingFields) && ((t || Array.from(g.mount)).forEach((
|
|
445
|
-
|
|
444
|
+
(F.isValidating || F.validatingFields) && ((t || Array.from(g.mount)).forEach((l) => {
|
|
445
|
+
l && (i ? V(r.validatingFields, l, i) : S(r.validatingFields, l));
|
|
446
446
|
}), _.state.next({
|
|
447
447
|
validatingFields: r.validatingFields,
|
|
448
448
|
isValidating: !L(r.validatingFields)
|
|
449
449
|
}));
|
|
450
|
-
}, m = (t, i = [],
|
|
451
|
-
if (f &&
|
|
450
|
+
}, m = (t, i = [], l, f, c = !0, o = !0) => {
|
|
451
|
+
if (f && l) {
|
|
452
452
|
if (y.action = !0, o && Array.isArray(d(n, t))) {
|
|
453
|
-
const h =
|
|
453
|
+
const h = l(d(n, t), f.argA, f.argB);
|
|
454
454
|
c && V(n, t, h);
|
|
455
455
|
}
|
|
456
456
|
if (o && Array.isArray(d(r.errors, t))) {
|
|
457
|
-
const h =
|
|
457
|
+
const h = l(d(r.errors, t), f.argA, f.argB);
|
|
458
458
|
c && V(r.errors, t, h), Yt(r.errors, t);
|
|
459
459
|
}
|
|
460
460
|
if (F.touchedFields && o && Array.isArray(d(r.touchedFields, t))) {
|
|
461
|
-
const h =
|
|
461
|
+
const h = l(d(r.touchedFields, t), f.argA, f.argB);
|
|
462
462
|
c && V(r.touchedFields, t, h);
|
|
463
463
|
}
|
|
464
|
-
F.dirtyFields && (r.dirtyFields = ve(u,
|
|
464
|
+
F.dirtyFields && (r.dirtyFields = ve(u, a)), _.state.next({
|
|
465
465
|
name: t,
|
|
466
466
|
isDirty: v(t, i),
|
|
467
467
|
dirtyFields: r.dirtyFields,
|
|
@@ -469,7 +469,7 @@ function er(e = {}) {
|
|
|
469
469
|
isValid: r.isValid
|
|
470
470
|
});
|
|
471
471
|
} else
|
|
472
|
-
V(
|
|
472
|
+
V(a, t, i);
|
|
473
473
|
}, O = (t, i) => {
|
|
474
474
|
V(r.errors, t, i), _.state.next({
|
|
475
475
|
errors: r.errors
|
|
@@ -479,30 +479,30 @@ function er(e = {}) {
|
|
|
479
479
|
errors: r.errors,
|
|
480
480
|
isValid: !1
|
|
481
481
|
});
|
|
482
|
-
}, A = (t, i,
|
|
482
|
+
}, A = (t, i, l, f) => {
|
|
483
483
|
const c = d(n, t);
|
|
484
484
|
if (c) {
|
|
485
|
-
const o = d(
|
|
486
|
-
|
|
485
|
+
const o = d(a, t, p(l) ? d(u, t) : l);
|
|
486
|
+
p(o) || f && f.defaultChecked || i ? V(a, t, i ? o : Te(c._f)) : C(t, o), y.mount && K();
|
|
487
487
|
}
|
|
488
|
-
}, Y = (t, i,
|
|
488
|
+
}, Y = (t, i, l, f, c) => {
|
|
489
489
|
let o = !1, h = !1;
|
|
490
490
|
const x = {
|
|
491
491
|
name: t
|
|
492
|
-
},
|
|
493
|
-
if (!
|
|
492
|
+
}, D = !!(d(n, t) && d(n, t)._f && d(n, t)._f.disabled);
|
|
493
|
+
if (!l || f) {
|
|
494
494
|
F.isDirty && (h = r.isDirty, r.isDirty = x.isDirty = v(), o = h !== x.isDirty);
|
|
495
|
-
const N =
|
|
496
|
-
h = !!(!
|
|
495
|
+
const N = D || se(d(u, t), i);
|
|
496
|
+
h = !!(!D && d(r.dirtyFields, t)), N || D ? S(r.dirtyFields, t) : V(r.dirtyFields, t, !0), x.dirtyFields = r.dirtyFields, o = o || F.dirtyFields && h !== !N;
|
|
497
497
|
}
|
|
498
|
-
if (
|
|
498
|
+
if (l) {
|
|
499
499
|
const N = d(r.touchedFields, t);
|
|
500
|
-
N || (V(r.touchedFields, t,
|
|
500
|
+
N || (V(r.touchedFields, t, l), x.touchedFields = r.touchedFields, o = o || F.touchedFields && N !== l);
|
|
501
501
|
}
|
|
502
502
|
return o && c && _.state.next(x), o ? x : {};
|
|
503
|
-
},
|
|
503
|
+
}, le = (t, i, l, f) => {
|
|
504
504
|
const c = d(r.errors, t), o = F.isValid && te(i) && r.isValid !== i;
|
|
505
|
-
if (e.delayError &&
|
|
505
|
+
if (e.delayError && l ? (M = z(() => O(t, l)), M(e.delayError)) : (clearTimeout(q), M = null, l ? V(r.errors, t, l) : S(r.errors, t)), (l ? !se(c, l) : c) || !L(f) || o) {
|
|
506
506
|
const h = {
|
|
507
507
|
...f,
|
|
508
508
|
...o && te(i) ? { isValid: i } : {},
|
|
@@ -516,19 +516,19 @@ function er(e = {}) {
|
|
|
516
516
|
}
|
|
517
517
|
}, Q = async (t) => {
|
|
518
518
|
G(t, !0);
|
|
519
|
-
const i = await s.resolver(
|
|
519
|
+
const i = await s.resolver(a, s.context, Jt(t || g.mount, n, s.criteriaMode, s.shouldUseNativeValidation));
|
|
520
520
|
return G(t), i;
|
|
521
521
|
}, Z = async (t) => {
|
|
522
522
|
const { errors: i } = await Q(t);
|
|
523
523
|
if (t)
|
|
524
|
-
for (const
|
|
525
|
-
const f = d(i,
|
|
526
|
-
f ? V(r.errors,
|
|
524
|
+
for (const l of t) {
|
|
525
|
+
const f = d(i, l);
|
|
526
|
+
f ? V(r.errors, l, f) : S(r.errors, l);
|
|
527
527
|
}
|
|
528
528
|
else
|
|
529
529
|
r.errors = i;
|
|
530
530
|
return i;
|
|
531
|
-
}, R = async (t, i,
|
|
531
|
+
}, R = async (t, i, l = {
|
|
532
532
|
valid: !0
|
|
533
533
|
}) => {
|
|
534
534
|
for (const f in t) {
|
|
@@ -538,104 +538,104 @@ function er(e = {}) {
|
|
|
538
538
|
if (o) {
|
|
539
539
|
const x = g.array.has(o.name);
|
|
540
540
|
G([f], !0);
|
|
541
|
-
const
|
|
542
|
-
if (G([f]),
|
|
541
|
+
const D = await rt(c, a, k, s.shouldUseNativeValidation && !i, x);
|
|
542
|
+
if (G([f]), D[o.name] && (l.valid = !1, i))
|
|
543
543
|
break;
|
|
544
|
-
!i && (d(
|
|
544
|
+
!i && (d(D, o.name) ? x ? $t(r.errors, D, o.name) : V(r.errors, o.name, D[o.name]) : S(r.errors, o.name));
|
|
545
545
|
}
|
|
546
|
-
!L(h) && await R(h, i,
|
|
546
|
+
!L(h) && await R(h, i, l);
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
|
-
return
|
|
550
|
-
},
|
|
549
|
+
return l.valid;
|
|
550
|
+
}, ae = () => {
|
|
551
551
|
for (const t of g.unMount) {
|
|
552
552
|
const i = d(n, t);
|
|
553
|
-
i && (i._f.refs ? i._f.refs.every((
|
|
553
|
+
i && (i._f.refs ? i._f.refs.every((l) => !Be(l)) : !Be(i._f.ref)) && we(t);
|
|
554
554
|
}
|
|
555
555
|
g.unMount = /* @__PURE__ */ new Set();
|
|
556
|
-
}, v = (t, i) => (t && i && V(
|
|
557
|
-
...y.mount ?
|
|
558
|
-
},
|
|
556
|
+
}, v = (t, i) => (t && i && V(a, t, i), !se(Ne(), u)), b = (t, i, l) => Ht(t, g, {
|
|
557
|
+
...y.mount ? a : p(i) ? u : J(t) ? { [t]: i } : i
|
|
558
|
+
}, l, i), w = (t) => Ae(d(y.mount ? a : u, t, e.shouldUnregister ? d(u, t, []) : [])), C = (t, i, l = {}) => {
|
|
559
559
|
const f = d(n, t);
|
|
560
560
|
let c = i;
|
|
561
561
|
if (f) {
|
|
562
562
|
const o = f._f;
|
|
563
|
-
o && (!o.disabled && V(
|
|
563
|
+
o && (!o.disabled && V(a, t, dt(i, o)), c = be(o.ref) && T(i) ? "" : i, ot(o.ref) ? [...o.ref.options].forEach((h) => h.selected = c.includes(h.value)) : o.refs ? ge(o.ref) ? o.refs.length > 1 ? o.refs.forEach((h) => (!h.defaultChecked || !h.disabled) && (h.checked = Array.isArray(c) ? !!c.find((x) => x === h.value) : c === h.value)) : o.refs[0] && (o.refs[0].checked = !!c) : o.refs.forEach((h) => h.checked = h.value === c) : Me(o.ref) ? o.ref.value = "" : (o.ref.value = c, o.ref.type || _.values.next({
|
|
564
564
|
name: t,
|
|
565
|
-
values: { ...
|
|
565
|
+
values: { ...a }
|
|
566
566
|
})));
|
|
567
567
|
}
|
|
568
|
-
(
|
|
569
|
-
}, $ = (t, i,
|
|
568
|
+
(l.shouldDirty || l.shouldTouch) && Y(t, c, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && de(t);
|
|
569
|
+
}, $ = (t, i, l) => {
|
|
570
570
|
for (const f in i) {
|
|
571
571
|
const c = i[f], o = `${t}.${f}`, h = d(n, o);
|
|
572
|
-
(g.array.has(t) || !Ve(c) || h && !h._f) && !oe(c) ? $(o, c,
|
|
572
|
+
(g.array.has(t) || !Ve(c) || h && !h._f) && !oe(c) ? $(o, c, l) : C(o, c, l);
|
|
573
573
|
}
|
|
574
|
-
}, I = (t, i,
|
|
574
|
+
}, I = (t, i, l = {}) => {
|
|
575
575
|
const f = d(n, t), c = g.array.has(t), o = P(i);
|
|
576
|
-
V(
|
|
576
|
+
V(a, t, o), c ? (_.array.next({
|
|
577
577
|
name: t,
|
|
578
|
-
values: { ...
|
|
579
|
-
}), (F.isDirty || F.dirtyFields) &&
|
|
578
|
+
values: { ...a }
|
|
579
|
+
}), (F.isDirty || F.dirtyFields) && l.shouldDirty && _.state.next({
|
|
580
580
|
name: t,
|
|
581
|
-
dirtyFields: ve(u,
|
|
581
|
+
dirtyFields: ve(u, a),
|
|
582
582
|
isDirty: v(t, o)
|
|
583
|
-
})) : f && !f._f && !T(o) ? $(t, o,
|
|
583
|
+
})) : f && !f._f && !T(o) ? $(t, o, l) : C(t, o, l), Xe(t, g) && _.state.next({ ...r }), _.values.next({
|
|
584
584
|
name: y.mount ? t : void 0,
|
|
585
|
-
values: { ...
|
|
585
|
+
values: { ...a }
|
|
586
586
|
});
|
|
587
587
|
}, ce = async (t) => {
|
|
588
588
|
y.mount = !0;
|
|
589
589
|
const i = t.target;
|
|
590
|
-
let
|
|
591
|
-
const c = d(n,
|
|
592
|
-
f = Number.isNaN(x) || x === d(
|
|
590
|
+
let l = i.name, f = !0;
|
|
591
|
+
const c = d(n, l), o = () => i.type ? Te(c._f) : Ot(t), h = (x) => {
|
|
592
|
+
f = Number.isNaN(x) || x === d(a, l, x);
|
|
593
593
|
};
|
|
594
594
|
if (c) {
|
|
595
|
-
let x,
|
|
596
|
-
const N = o(), ne = t.type === Je.BLUR || t.type === Je.FOCUS_OUT, _t = !Qt(c._f) && !s.resolver && !d(r.errors,
|
|
597
|
-
V(
|
|
598
|
-
const ke = Y(
|
|
595
|
+
let x, D;
|
|
596
|
+
const N = o(), ne = t.type === Je.BLUR || t.type === Je.FOCUS_OUT, _t = !Qt(c._f) && !s.resolver && !d(r.errors, l) && !c._f.deps || Xt(ne, d(r.touchedFields, l), r.isSubmitted, H, ie), De = Xe(l, g, ne);
|
|
597
|
+
V(a, l, N), ne ? (c._f.onBlur && c._f.onBlur(t), M && M(0)) : c._f.onChange && c._f.onChange(t);
|
|
598
|
+
const ke = Y(l, N, ne, !1), mt = !L(ke) || De;
|
|
599
599
|
if (!ne && _.values.next({
|
|
600
|
-
name:
|
|
600
|
+
name: l,
|
|
601
601
|
type: t.type,
|
|
602
|
-
values: { ...
|
|
602
|
+
values: { ...a }
|
|
603
603
|
}), _t)
|
|
604
|
-
return F.isValid && K(), mt && _.state.next({ name:
|
|
604
|
+
return F.isValid && K(), mt && _.state.next({ name: l, ...De ? {} : ke });
|
|
605
605
|
if (!ne && De && _.state.next({ ...r }), s.resolver) {
|
|
606
|
-
const { errors: $e } = await Q([
|
|
606
|
+
const { errors: $e } = await Q([l]);
|
|
607
607
|
if (h(N), f) {
|
|
608
|
-
const bt = st(r.errors, n,
|
|
609
|
-
x = je.error,
|
|
608
|
+
const bt = st(r.errors, n, l), je = st($e, n, bt.name || l);
|
|
609
|
+
x = je.error, l = je.name, D = L($e);
|
|
610
610
|
}
|
|
611
611
|
} else
|
|
612
|
-
G([
|
|
613
|
-
f && (c._f.deps && de(c._f.deps),
|
|
612
|
+
G([l], !0), x = (await rt(c, a, k, s.shouldUseNativeValidation))[l], G([l]), h(N), f && (x ? D = !1 : F.isValid && (D = await R(n, !0)));
|
|
613
|
+
f && (c._f.deps && de(c._f.deps), le(l, D, x, ke));
|
|
614
614
|
}
|
|
615
615
|
}, fe = (t, i) => {
|
|
616
616
|
if (d(r.errors, i) && t.focus)
|
|
617
617
|
return t.focus(), 1;
|
|
618
618
|
}, de = async (t, i = {}) => {
|
|
619
|
-
let
|
|
619
|
+
let l, f;
|
|
620
620
|
const c = _e(t);
|
|
621
621
|
if (s.resolver) {
|
|
622
|
-
const o = await Z(
|
|
623
|
-
|
|
622
|
+
const o = await Z(p(t) ? t : c);
|
|
623
|
+
l = L(o), f = t ? !c.some((h) => d(o, h)) : l;
|
|
624
624
|
} else
|
|
625
625
|
t ? (f = (await Promise.all(c.map(async (o) => {
|
|
626
626
|
const h = d(n, o);
|
|
627
627
|
return await R(h && h._f ? { [o]: h } : h);
|
|
628
|
-
}))).every(Boolean), !(!f && !r.isValid) && K()) : f =
|
|
628
|
+
}))).every(Boolean), !(!f && !r.isValid) && K()) : f = l = await R(n);
|
|
629
629
|
return _.state.next({
|
|
630
|
-
...!J(t) || F.isValid &&
|
|
631
|
-
...s.resolver || !t ? { isValid:
|
|
630
|
+
...!J(t) || F.isValid && l !== r.isValid ? {} : { name: t },
|
|
631
|
+
...s.resolver || !t ? { isValid: l } : {},
|
|
632
632
|
errors: r.errors
|
|
633
633
|
}), i.shouldFocus && !f && he(n, fe, t ? c : g.mount), f;
|
|
634
634
|
}, Ne = (t) => {
|
|
635
635
|
const i = {
|
|
636
|
-
...y.mount ?
|
|
636
|
+
...y.mount ? a : u
|
|
637
637
|
};
|
|
638
|
-
return
|
|
638
|
+
return p(t) ? i : J(t) ? d(i, t) : t.map((l) => d(i, l));
|
|
639
639
|
}, Ue = (t, i) => ({
|
|
640
640
|
invalid: !!d((i || r).errors, t),
|
|
641
641
|
isDirty: !!d((i || r).dirtyFields, t),
|
|
@@ -646,46 +646,46 @@ function er(e = {}) {
|
|
|
646
646
|
t && _e(t).forEach((i) => S(r.errors, i)), _.state.next({
|
|
647
647
|
errors: t ? r.errors : {}
|
|
648
648
|
});
|
|
649
|
-
}, qe = (t, i,
|
|
650
|
-
const f = (d(n, t, { _f: {} })._f || {}).ref, c = d(r.errors, t) || {}, { ref: o, message: h, type: x, ...
|
|
649
|
+
}, qe = (t, i, l) => {
|
|
650
|
+
const f = (d(n, t, { _f: {} })._f || {}).ref, c = d(r.errors, t) || {}, { ref: o, message: h, type: x, ...D } = c;
|
|
651
651
|
V(r.errors, t, {
|
|
652
|
-
...
|
|
652
|
+
...D,
|
|
653
653
|
...i,
|
|
654
654
|
ref: f
|
|
655
655
|
}), _.state.next({
|
|
656
656
|
name: t,
|
|
657
657
|
errors: r.errors,
|
|
658
658
|
isValid: !1
|
|
659
|
-
}),
|
|
659
|
+
}), l && l.shouldFocus && f && f.focus && f.focus();
|
|
660
660
|
}, ht = (t, i) => re(t) ? _.values.subscribe({
|
|
661
|
-
next: (
|
|
661
|
+
next: (l) => t(b(void 0, i), l)
|
|
662
662
|
}) : b(t, i, !0), we = (t, i = {}) => {
|
|
663
|
-
for (const
|
|
664
|
-
g.mount.delete(
|
|
663
|
+
for (const l of t ? _e(t) : g.mount)
|
|
664
|
+
g.mount.delete(l), g.array.delete(l), i.keepValue || (S(n, l), S(a, l)), !i.keepError && S(r.errors, l), !i.keepDirty && S(r.dirtyFields, l), !i.keepTouched && S(r.touchedFields, l), !i.keepIsValidating && S(r.validatingFields, l), !s.shouldUnregister && !i.keepDefaultValue && S(u, l);
|
|
665
665
|
_.values.next({
|
|
666
|
-
values: { ...
|
|
666
|
+
values: { ...a }
|
|
667
667
|
}), _.state.next({
|
|
668
668
|
...r,
|
|
669
669
|
...i.keepDirty ? { isDirty: v() } : {}
|
|
670
670
|
}), !i.keepIsValid && K();
|
|
671
|
-
}, Ie = ({ disabled: t, name: i, field:
|
|
671
|
+
}, Ie = ({ disabled: t, name: i, field: l, fields: f, value: c }) => {
|
|
672
672
|
if (te(t) && y.mount || t) {
|
|
673
|
-
const o = t ? void 0 :
|
|
674
|
-
V(
|
|
673
|
+
const o = t ? void 0 : p(c) ? Te(l ? l._f : d(f, i)._f) : c;
|
|
674
|
+
V(a, i, o), Y(i, o, !1, !1, !0);
|
|
675
675
|
}
|
|
676
676
|
}, pe = (t, i = {}) => {
|
|
677
|
-
let
|
|
677
|
+
let l = d(n, t);
|
|
678
678
|
const f = te(i.disabled);
|
|
679
679
|
return V(n, t, {
|
|
680
|
-
...
|
|
680
|
+
...l || {},
|
|
681
681
|
_f: {
|
|
682
|
-
...
|
|
682
|
+
...l && l._f ? l._f : { ref: { name: t } },
|
|
683
683
|
name: t,
|
|
684
684
|
mount: !0,
|
|
685
685
|
...i
|
|
686
686
|
}
|
|
687
|
-
}), g.mount.add(t),
|
|
688
|
-
field:
|
|
687
|
+
}), g.mount.add(t), l ? Ie({
|
|
688
|
+
field: l,
|
|
689
689
|
disabled: i.disabled,
|
|
690
690
|
name: t,
|
|
691
691
|
value: i.value
|
|
@@ -704,13 +704,13 @@ function er(e = {}) {
|
|
|
704
704
|
onBlur: ce,
|
|
705
705
|
ref: (c) => {
|
|
706
706
|
if (c) {
|
|
707
|
-
pe(t, i),
|
|
708
|
-
const o =
|
|
709
|
-
if (h ? x.find((
|
|
707
|
+
pe(t, i), l = d(n, t);
|
|
708
|
+
const o = p(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, h = Gt(o), x = l._f.refs || [];
|
|
709
|
+
if (h ? x.find((D) => D === o) : o === l._f.ref)
|
|
710
710
|
return;
|
|
711
711
|
V(n, t, {
|
|
712
712
|
_f: {
|
|
713
|
-
...
|
|
713
|
+
...l._f,
|
|
714
714
|
...h ? {
|
|
715
715
|
refs: [
|
|
716
716
|
...x.filter(Be),
|
|
@@ -722,20 +722,20 @@ function er(e = {}) {
|
|
|
722
722
|
}
|
|
723
723
|
}), A(t, !1, void 0, o);
|
|
724
724
|
} else
|
|
725
|
-
|
|
725
|
+
l = d(n, t, {}), l._f && (l._f.mount = !1), (s.shouldUnregister || i.shouldUnregister) && !(Ut(g.array, t) && y.action) && g.unMount.add(t);
|
|
726
726
|
}
|
|
727
727
|
};
|
|
728
728
|
}, Pe = () => s.shouldFocusError && he(n, fe, g.mount), gt = (t) => {
|
|
729
|
-
te(t) && (_.state.next({ disabled: t }), he(n, (i,
|
|
730
|
-
const f = d(n,
|
|
729
|
+
te(t) && (_.state.next({ disabled: t }), he(n, (i, l) => {
|
|
730
|
+
const f = d(n, l);
|
|
731
731
|
f && (i.disabled = f._f.disabled || t, Array.isArray(f._f.refs) && f._f.refs.forEach((c) => {
|
|
732
732
|
c.disabled = f._f.disabled || t;
|
|
733
733
|
}));
|
|
734
734
|
}, 0, !1));
|
|
735
|
-
}, We = (t, i) => async (
|
|
735
|
+
}, We = (t, i) => async (l) => {
|
|
736
736
|
let f;
|
|
737
|
-
|
|
738
|
-
let c = P(
|
|
737
|
+
l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
|
|
738
|
+
let c = P(a);
|
|
739
739
|
if (_.state.next({
|
|
740
740
|
isSubmitting: !0
|
|
741
741
|
}), s.resolver) {
|
|
@@ -748,12 +748,12 @@ function er(e = {}) {
|
|
|
748
748
|
errors: {}
|
|
749
749
|
});
|
|
750
750
|
try {
|
|
751
|
-
await t(c,
|
|
751
|
+
await t(c, l);
|
|
752
752
|
} catch (o) {
|
|
753
753
|
f = o;
|
|
754
754
|
}
|
|
755
755
|
} else
|
|
756
|
-
i && await i({ ...r.errors },
|
|
756
|
+
i && await i({ ...r.errors }, l), Pe(), setTimeout(Pe);
|
|
757
757
|
if (_.state.next({
|
|
758
758
|
isSubmitted: !0,
|
|
759
759
|
isSubmitting: !1,
|
|
@@ -763,21 +763,21 @@ function er(e = {}) {
|
|
|
763
763
|
}), f)
|
|
764
764
|
throw f;
|
|
765
765
|
}, vt = (t, i = {}) => {
|
|
766
|
-
d(n, t) && (
|
|
766
|
+
d(n, t) && (p(i.defaultValue) ? I(t, P(d(u, t))) : (I(t, i.defaultValue), V(u, t, P(i.defaultValue))), i.keepTouched || S(r.touchedFields, t), i.keepDirty || (S(r.dirtyFields, t), r.isDirty = i.defaultValue ? v(t, P(d(u, t))) : v()), i.keepError || (S(r.errors, t), F.isValid && K()), _.state.next({ ...r }));
|
|
767
767
|
}, He = (t, i = {}) => {
|
|
768
|
-
const
|
|
769
|
-
if (i.keepDefaultValues || (u =
|
|
768
|
+
const l = t ? P(t) : u, f = P(l), c = L(t), o = c ? u : f;
|
|
769
|
+
if (i.keepDefaultValues || (u = l), !i.keepValues) {
|
|
770
770
|
if (i.keepDirtyValues)
|
|
771
771
|
for (const h of g.mount)
|
|
772
|
-
d(r.dirtyFields, h) ? V(o, h, d(
|
|
772
|
+
d(r.dirtyFields, h) ? V(o, h, d(a, h)) : I(h, d(o, h));
|
|
773
773
|
else {
|
|
774
|
-
if (Re &&
|
|
774
|
+
if (Re && p(t))
|
|
775
775
|
for (const h of g.mount) {
|
|
776
776
|
const x = d(n, h);
|
|
777
777
|
if (x && x._f) {
|
|
778
|
-
const
|
|
779
|
-
if (be(
|
|
780
|
-
const N =
|
|
778
|
+
const D = Array.isArray(x._f.refs) ? x._f.refs[0] : x._f.ref;
|
|
779
|
+
if (be(D)) {
|
|
780
|
+
const N = D.closest("form");
|
|
781
781
|
if (N) {
|
|
782
782
|
N.reset();
|
|
783
783
|
break;
|
|
@@ -787,7 +787,7 @@ function er(e = {}) {
|
|
|
787
787
|
}
|
|
788
788
|
n = {};
|
|
789
789
|
}
|
|
790
|
-
|
|
790
|
+
a = e.shouldUnregister ? i.keepDefaultValues ? P(u) : {} : P(o), _.array.next({
|
|
791
791
|
values: { ...o }
|
|
792
792
|
}), _.values.next({
|
|
793
793
|
values: { ...o }
|
|
@@ -804,13 +804,13 @@ function er(e = {}) {
|
|
|
804
804
|
submitCount: i.keepSubmitCount ? r.submitCount : 0,
|
|
805
805
|
isDirty: c ? !1 : i.keepDirty ? r.isDirty : !!(i.keepDefaultValues && !se(t, u)),
|
|
806
806
|
isSubmitted: i.keepIsSubmitted ? r.isSubmitted : !1,
|
|
807
|
-
dirtyFields: c ? {} : i.keepDirtyValues ? i.keepDefaultValues &&
|
|
807
|
+
dirtyFields: c ? {} : i.keepDirtyValues ? i.keepDefaultValues && a ? ve(u, a) : r.dirtyFields : i.keepDefaultValues && t ? ve(u, t) : i.keepDirty ? r.dirtyFields : {},
|
|
808
808
|
touchedFields: i.keepTouched ? r.touchedFields : {},
|
|
809
809
|
errors: i.keepErrors ? r.errors : {},
|
|
810
810
|
isSubmitSuccessful: i.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
|
|
811
811
|
isSubmitting: !1
|
|
812
812
|
});
|
|
813
|
-
}, ze = (t, i) => He(re(t) ? t(
|
|
813
|
+
}, ze = (t, i) => He(re(t) ? t(a) : t, i);
|
|
814
814
|
return {
|
|
815
815
|
control: {
|
|
816
816
|
register: pe,
|
|
@@ -822,10 +822,10 @@ function er(e = {}) {
|
|
|
822
822
|
_getWatch: b,
|
|
823
823
|
_getDirty: v,
|
|
824
824
|
_updateValid: K,
|
|
825
|
-
_removeUnmounted:
|
|
825
|
+
_removeUnmounted: ae,
|
|
826
826
|
_updateFieldArray: m,
|
|
827
827
|
_updateDisabledField: Ie,
|
|
828
|
-
_getFieldArray:
|
|
828
|
+
_getFieldArray: w,
|
|
829
829
|
_reset: He,
|
|
830
830
|
_resetDefaultValues: () => re(s.defaultValues) && s.defaultValues().then((t) => {
|
|
831
831
|
ze(t, s.resetOptions), _.state.next({
|
|
@@ -846,7 +846,7 @@ function er(e = {}) {
|
|
|
846
846
|
return n;
|
|
847
847
|
},
|
|
848
848
|
get _formValues() {
|
|
849
|
-
return
|
|
849
|
+
return a;
|
|
850
850
|
},
|
|
851
851
|
get _state() {
|
|
852
852
|
return y;
|
|
@@ -891,7 +891,7 @@ function er(e = {}) {
|
|
|
891
891
|
unregister: we,
|
|
892
892
|
setError: qe,
|
|
893
893
|
setFocus: (t, i = {}) => {
|
|
894
|
-
const
|
|
894
|
+
const l = d(n, t), f = l && l._f;
|
|
895
895
|
if (f) {
|
|
896
896
|
const c = f.refs ? f.refs[0] : f.ref;
|
|
897
897
|
c.focus && (c.focus(), i.shouldSelect && c.select());
|
|
@@ -921,30 +921,30 @@ function tr(e = {}) {
|
|
|
921
921
|
...er(e),
|
|
922
922
|
formState: n
|
|
923
923
|
});
|
|
924
|
-
const
|
|
925
|
-
return
|
|
926
|
-
subject:
|
|
924
|
+
const a = s.current.control;
|
|
925
|
+
return a._options = e, Wt({
|
|
926
|
+
subject: a._subjects.state,
|
|
927
927
|
next: (y) => {
|
|
928
|
-
Pt(y,
|
|
928
|
+
Pt(y, a._proxyFormState, a._updateFormState) && u({ ...a._formState });
|
|
929
929
|
}
|
|
930
|
-
}), W.useEffect(() =>
|
|
931
|
-
if (
|
|
932
|
-
const y =
|
|
933
|
-
y !== n.isDirty &&
|
|
930
|
+
}), W.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), W.useEffect(() => {
|
|
931
|
+
if (a._proxyFormState.isDirty) {
|
|
932
|
+
const y = a._getDirty();
|
|
933
|
+
y !== n.isDirty && a._subjects.state.next({
|
|
934
934
|
isDirty: y
|
|
935
935
|
});
|
|
936
936
|
}
|
|
937
|
-
}, [
|
|
938
|
-
e.values && !se(e.values, r.current) ? (
|
|
939
|
-
}, [e.values,
|
|
940
|
-
e.errors &&
|
|
941
|
-
}, [e.errors,
|
|
942
|
-
|
|
937
|
+
}, [a, n.isDirty]), W.useEffect(() => {
|
|
938
|
+
e.values && !se(e.values, r.current) ? (a._reset(e.values, a._options.resetOptions), r.current = e.values, u((y) => ({ ...y }))) : a._resetDefaultValues();
|
|
939
|
+
}, [e.values, a]), W.useEffect(() => {
|
|
940
|
+
e.errors && a._setErrors(e.errors);
|
|
941
|
+
}, [e.errors, a]), W.useEffect(() => {
|
|
942
|
+
a._state.mount || (a._updateValid(), a._state.mount = !0), a._state.watch && (a._state.watch = !1, a._subjects.state.next({ ...a._formState })), a._removeUnmounted();
|
|
943
943
|
}), W.useEffect(() => {
|
|
944
|
-
e.shouldUnregister &&
|
|
945
|
-
values:
|
|
944
|
+
e.shouldUnregister && a._subjects.values.next({
|
|
945
|
+
values: a._getWatch()
|
|
946
946
|
});
|
|
947
|
-
}, [e.shouldUnregister,
|
|
947
|
+
}, [e.shouldUnregister, a]), s.current.formState = It(n, a), s.current;
|
|
948
948
|
}
|
|
949
949
|
const it = `Я принимаю условия Политики обработки
|
|
950
950
|
и защиты персональных данных, даю согласия на обработку персональных
|
|
@@ -954,7 +954,7 @@ const it = `Я принимаю условия Политики обработк
|
|
|
954
954
|
title: r,
|
|
955
955
|
isEmail: n,
|
|
956
956
|
isTextArea: u,
|
|
957
|
-
isRequiredPhone:
|
|
957
|
+
isRequiredPhone: a = !0,
|
|
958
958
|
isRequiredEmail: y = !1,
|
|
959
959
|
isRequiredPhoneOrEmail: g,
|
|
960
960
|
textAreaPlaceholder: M,
|
|
@@ -963,7 +963,7 @@ const it = `Я принимаю условия Политики обработк
|
|
|
963
963
|
modalWidth: _ = "442px",
|
|
964
964
|
rowsTextArea: ie = 2,
|
|
965
965
|
personalCheckBox: H = { text: it, isRequired: !0 },
|
|
966
|
-
advCheckBox:
|
|
966
|
+
advCheckBox: k = { text: it, isRequired: !0 }
|
|
967
967
|
}) => {
|
|
968
968
|
const {
|
|
969
969
|
register: z,
|
|
@@ -972,14 +972,14 @@ const it = `Я принимаю условия Политики обработк
|
|
|
972
972
|
reset: m,
|
|
973
973
|
watch: O,
|
|
974
974
|
formState: { errors: B }
|
|
975
|
-
} = tr(), A = !!O("email"), { onChange: Y, onBlur:
|
|
976
|
-
required:
|
|
975
|
+
} = tr(), A = !!O("email"), { onChange: Y, onBlur: le, ...Q } = z("phone", {
|
|
976
|
+
required: a || g ? !A : !0,
|
|
977
977
|
pattern: { value: wt, message: "" },
|
|
978
978
|
onBlur: () => G("phone")
|
|
979
|
-
}), { isMobile: Z } = St(),
|
|
980
|
-
F(
|
|
979
|
+
}), { isMobile: Z, currentClientWidth: R } = St(), ae = O("personalCheckBox"), v = O("advCheckBox"), b = (w) => {
|
|
980
|
+
F(w), m();
|
|
981
981
|
};
|
|
982
|
-
return /* @__PURE__ */ U(
|
|
982
|
+
return R ? /* @__PURE__ */ U(
|
|
983
983
|
Vt,
|
|
984
984
|
{
|
|
985
985
|
isOpen: e,
|
|
@@ -997,7 +997,7 @@ const it = `Я принимаю условия Политики обработк
|
|
|
997
997
|
dangerouslySetInnerHTML: { __html: q ?? "Оставьте номер телефона для получения консультации" }
|
|
998
998
|
}
|
|
999
999
|
),
|
|
1000
|
-
/* @__PURE__ */ Se("form", { onSubmit: K(
|
|
1000
|
+
/* @__PURE__ */ Se("form", { onSubmit: K(b), children: [
|
|
1001
1001
|
/* @__PURE__ */ Se(Ft, { className: ee.inputWrapper, children: [
|
|
1002
1002
|
/* @__PURE__ */ U(
|
|
1003
1003
|
Ee,
|
|
@@ -1019,7 +1019,7 @@ const it = `Я принимаю условия Политики обработк
|
|
|
1019
1019
|
mask: "+7 (999) 999-99-99",
|
|
1020
1020
|
onChange: Y,
|
|
1021
1021
|
placeholder: "+7 (- - -) - - - - - - -",
|
|
1022
|
-
onBlur:
|
|
1022
|
+
onBlur: le,
|
|
1023
1023
|
children: /* @__PURE__ */ U(
|
|
1024
1024
|
Ee,
|
|
1025
1025
|
{
|
|
@@ -1063,21 +1063,21 @@ const it = `Я принимаю условия Политики обработк
|
|
|
1063
1063
|
...z("textarea")
|
|
1064
1064
|
}
|
|
1065
1065
|
),
|
|
1066
|
-
|
|
1066
|
+
k && /* @__PURE__ */ U(
|
|
1067
1067
|
Ge,
|
|
1068
1068
|
{
|
|
1069
1069
|
"data-testid": "modal_advCheckBox",
|
|
1070
|
-
isChecked:
|
|
1070
|
+
isChecked: v,
|
|
1071
1071
|
error: !!B.advCheckBox,
|
|
1072
|
-
text:
|
|
1073
|
-
...z("advCheckBox", { required:
|
|
1072
|
+
text: k.text,
|
|
1073
|
+
...z("advCheckBox", { required: k == null ? void 0 : k.isRequired })
|
|
1074
1074
|
}
|
|
1075
1075
|
),
|
|
1076
1076
|
/* @__PURE__ */ U(
|
|
1077
1077
|
Ge,
|
|
1078
1078
|
{
|
|
1079
1079
|
"data-testid": "modal_personalCheckBox",
|
|
1080
|
-
isChecked:
|
|
1080
|
+
isChecked: ae,
|
|
1081
1081
|
error: !!B.personalCheckBox,
|
|
1082
1082
|
text: H.text,
|
|
1083
1083
|
...z("personalCheckBox", { required: H.isRequired })
|
|
@@ -1119,7 +1119,7 @@ const it = `Я принимаю условия Политики обработк
|
|
|
1119
1119
|
] })
|
|
1120
1120
|
] })
|
|
1121
1121
|
}
|
|
1122
|
-
);
|
|
1122
|
+
) : null;
|
|
1123
1123
|
};
|
|
1124
1124
|
export {
|
|
1125
1125
|
_r as ModalForm
|