stone-kit 0.0.1048 → 0.0.1050

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.
Files changed (55) hide show
  1. package/README.md +88 -88
  2. package/dist/FilterWithSave-B2QqOGDk.js +2683 -0
  3. package/dist/components/CheckBoxNew/CheckBoxNew.js +5 -5
  4. package/dist/components/CommercialLotCard/CommercialLotCard.js +10 -80
  5. package/dist/components/CommercialLotCard/components/PaymentLink/PaymentLink.js +4 -4
  6. package/dist/components/CommercialLotCard/components/Snippets/Snippets.js +27 -98
  7. package/dist/components/CommercialLotCard/components/Tags/Tags.js +1 -1
  8. package/dist/components/FilterWithSave/hooks/useFilterWithSave.js +26 -54
  9. package/dist/components/FilterWithSave/ui/FilterWithSave.js +7 -323
  10. package/dist/components/FormModal/ui/ModalForm.js +29 -1516
  11. package/dist/components/Logo/ui/Logo.js +6 -6
  12. package/dist/components/LotCard/hooks/useLotCard.js +24 -6
  13. package/dist/components/LotCard/index.js +2 -2
  14. package/dist/components/LotCard/ui/LotCard.js +11 -221
  15. package/dist/components/ModalSuccess/ModalSuccess.js +1 -1
  16. package/dist/components/RoundButton/ui/RoundButton.js +1 -1
  17. package/dist/components/Select/ui/Category.js +2 -2
  18. package/dist/components/Select/ui/Option.js +2 -2
  19. package/dist/components/Select/ui/Select.js +2 -2
  20. package/dist/components/SliderNavigation/ui/SliderNavigation.js +6 -6
  21. package/dist/components/SortSelect/index.js +1 -1
  22. package/dist/components/SortSelect/ui/SortSelect.js +26 -108
  23. package/dist/components/SummarySelect/ui/SummarySelect.js +1 -1
  24. package/dist/components/TabSelect/ui/TabSelect.js +4 -4
  25. package/dist/components/TabSwitcher/index.js +2 -2
  26. package/dist/components/TabSwitcher/ui/TabSwitcher.js +26 -121
  27. package/dist/components/Tag/ui/Tag.js +97 -96
  28. package/dist/components/Tag/ui/Tag.types.d.ts +1 -0
  29. package/dist/components/Tag/ui/Tag.types.js +2 -1
  30. package/dist/layout/components/Header/Header.js +65 -44
  31. package/dist/layout/components/Menu.js +37 -15
  32. package/dist/main.js +65 -70
  33. package/dist/pages/ButtonsPage/Buttons.js +61 -44
  34. package/dist/pages/FormsPage/FormsPage.js +42 -22
  35. package/dist/pages/IconsPage/IconsPage.js +31 -9
  36. package/dist/pages/InputPage/InputPage.js +32 -10
  37. package/dist/pages/LogoPage/LogoPage.js +36 -13
  38. package/dist/pages/LotsPage/LotsPage.js +43 -25
  39. package/dist/pages/LotsPage/const.d.ts +5 -1
  40. package/dist/pages/LotsPage/const.js +42 -2
  41. package/dist/pages/ModalsPage/ModalPage.js +66 -46
  42. package/dist/pages/SelectPage/SelectPage.js +40 -41
  43. package/dist/pages/TabsPage/TabsPage.js +1 -1
  44. package/dist/pages/TagsPage/TagsPage.js +44 -23
  45. package/dist/stone-kit.css +1 -1
  46. package/dist/stories/entities/CommercialLotCard/CommercialLotCard.stories.js +1 -1
  47. package/dist/stories/shared/ui/Button/Button.stories.js +4 -4
  48. package/dist/stories/shared/ui/FilterWithSave/FilterWithSave.stories.js +1 -1
  49. package/dist/stories/shared/ui/FormModal/FormModal.stories.js +7 -7
  50. package/dist/stories/shared/ui/SortSelect/SortSelect.stories.js +1 -1
  51. package/dist/stories/shared/ui/TabSwitcher/TabSwitcher.stories.js +1 -1
  52. package/dist/stories/shared/ui/Tag/Tag.stories.js +4 -4
  53. package/package.json +1 -1
  54. package/dist/useLotCard-D-gK4J_o.js +0 -186
  55. package/dist/{Option-DmDx_xOt.js → Option-DdjBe9yb.js} +1 -1
@@ -1,1518 +1,31 @@
1
- import { jsx as L, jsxs as de } from "react/jsx-runtime";
2
- import v, { useEffect as Ne } from "react";
3
- import { nameReg as Rt, phoneReg as Lt, emailReg as Ot } from "../utils/reg.js";
4
- import { TextArea as Nt } from "../../TextArea/TextArea.js";
5
- import { c as Mt } from "../../../index-YnD2EP-S.js";
6
- import { useClientWidth as Ut } from "../../../shared/useClientWidth.js";
7
- import { Modal as It } from "../../Modal/ui/Modal.js";
8
- import { NewIcon as tt } from "../../NewIcon/ui/NewIcon.js";
9
- import { Flex as Pt } from "../../Flex/ui/Flex.js";
10
- import { Input as Me } from "../../Input/ui/Input.js";
11
- import { CheckBox as rt } from "../../CheckBox/CheckBox.js";
12
- import { Button as st } from "../../Button/ui/Button.js";
13
- const Wt = "_btn_ky28a_1", qt = "_modal_ky28a_9", Ht = "_modalBody_ky28a_16", zt = "_root_ky28a_21", $t = "_title_ky28a_34", jt = "_description_ky28a_41", Gt = "_inputWrapper_ky28a_48", Kt = "_linkPolicy_ky28a_55", Jt = "_telegramLink_ky28a_60", Qt = "_telegramWrapper_ky28a_65", Xt = "_telegram_ky28a_60", Zt = "_orText_ky28a_88", Yt = "_checkboxText_ky28a_116", U = {
14
- btn: Wt,
15
- modal: qt,
16
- modalBody: Ht,
17
- root: zt,
18
- title: $t,
19
- description: jt,
20
- inputWrapper: Gt,
21
- linkPolicy: Kt,
22
- telegramLink: Jt,
23
- telegramWrapper: Qt,
24
- telegram: Xt,
25
- orText: Zt,
26
- checkboxText: Yt
27
- };
28
- var Fe = (e) => e.type === "checkbox", ye = (e) => e instanceof Date, X = (e) => e == null;
29
- const mt = (e) => typeof e == "object";
30
- var P = (e) => !X(e) && !Array.isArray(e) && mt(e) && !ye(e), _t = (e) => P(e) && e.target ? Fe(e.target) ? e.target.checked : e.target.value : e, er = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, gt = (e, s) => e.has(er(s)), tr = (e) => {
31
- const s = e.constructor && e.constructor.prototype;
32
- return P(s) && s.hasOwnProperty("isPrototypeOf");
33
- }, qe = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
34
- function W(e) {
35
- let s;
36
- const t = Array.isArray(e), i = typeof FileList < "u" ? e instanceof FileList : !1;
37
- if (e instanceof Date)
38
- s = new Date(e);
39
- else if (!(qe && (e instanceof Blob || i)) && (t || P(e)))
40
- if (s = t ? [] : Object.create(Object.getPrototypeOf(e)), !t && !tr(e))
41
- s = e;
42
- else
43
- for (const o in e)
44
- e.hasOwnProperty(o) && (s[o] = W(e[o]));
45
- else
46
- return e;
47
- return s;
48
- }
49
- var Ee = (e) => /^\w*$/.test(e), O = (e) => e === void 0, He = (e) => Array.isArray(e) ? e.filter(Boolean) : [], ze = (e) => He(e.replace(/["|']|\]/g, "").split(/\.|\[/)), y = (e, s, t) => {
50
- if (!s || !P(e))
51
- return t;
52
- const i = (Ee(s) ? [s] : ze(s)).reduce((o, n) => X(o) ? o : o[n], e);
53
- return O(i) || i === e ? O(e[s]) ? t : e[s] : i;
54
- }, Z = (e) => typeof e == "boolean", B = (e, s, t) => {
55
- let i = -1;
56
- const o = Ee(s) ? [s] : ze(s), n = o.length, c = n - 1;
57
- for (; ++i < n; ) {
58
- const d = o[i];
59
- let D = t;
60
- if (i !== c) {
61
- const w = e[d];
62
- D = P(w) || Array.isArray(w) ? w : isNaN(+o[i + 1]) ? {} : [];
63
- }
64
- if (d === "__proto__" || d === "constructor" || d === "prototype")
65
- return;
66
- e[d] = D, e = e[d];
67
- }
68
- };
69
- const Ce = {
70
- BLUR: "blur",
71
- FOCUS_OUT: "focusout",
72
- CHANGE: "change"
73
- }, ie = {
74
- onBlur: "onBlur",
75
- onChange: "onChange",
76
- onSubmit: "onSubmit",
77
- onTouched: "onTouched",
78
- all: "all"
79
- }, oe = {
80
- max: "max",
81
- min: "min",
82
- maxLength: "maxLength",
83
- minLength: "minLength",
84
- pattern: "pattern",
85
- required: "required",
86
- validate: "validate"
87
- }, vt = v.createContext(null);
88
- vt.displayName = "HookFormContext";
89
- const $e = () => v.useContext(vt);
90
- var bt = (e, s, t, i = !0) => {
91
- const o = {
92
- defaultValues: s._defaultValues
93
- };
94
- for (const n in e)
95
- Object.defineProperty(o, n, {
96
- get: () => {
97
- const c = n;
98
- return s._proxyFormState[c] !== ie.all && (s._proxyFormState[c] = !i || ie.all), t && (t[c] = !0), e[c];
99
- }
100
- });
101
- return o;
102
- };
103
- const je = typeof window < "u" ? v.useLayoutEffect : v.useEffect;
104
- function rr(e) {
105
- const s = $e(), { control: t = s.control, disabled: i, name: o, exact: n } = e || {}, [c, d] = v.useState(t._formState), D = v.useRef({
106
- isDirty: !1,
107
- isLoading: !1,
108
- dirtyFields: !1,
109
- touchedFields: !1,
110
- validatingFields: !1,
111
- isValidating: !1,
112
- isValid: !1,
113
- errors: !1
114
- });
115
- return je(() => t._subscribe({
116
- name: o,
117
- formState: D.current,
118
- exact: n,
119
- callback: (w) => {
120
- !i && d({
121
- ...t._formState,
122
- ...w
123
- });
124
- }
125
- }), [o, i, n]), v.useEffect(() => {
126
- D.current.isValid && t._setValid(!0);
127
- }, [t]), v.useMemo(() => bt(c, t, D.current, !1), [c, t]);
128
- }
129
- var Y = (e) => typeof e == "string", Ie = (e, s, t, i, o) => Y(e) ? (i && s.watch.add(e), y(t, e, o)) : Array.isArray(e) ? e.map((n) => (i && s.watch.add(n), y(t, n))) : (i && (s.watchAll = !0), t), Pe = (e) => X(e) || !mt(e);
130
- function ae(e, s, t = /* @__PURE__ */ new WeakSet()) {
131
- if (Pe(e) || Pe(s))
132
- return e === s;
133
- if (ye(e) && ye(s))
134
- return e.getTime() === s.getTime();
135
- const i = Object.keys(e), o = Object.keys(s);
136
- if (i.length !== o.length)
137
- return !1;
138
- if (t.has(e) || t.has(s))
139
- return !0;
140
- t.add(e), t.add(s);
141
- for (const n of i) {
142
- const c = e[n];
143
- if (!o.includes(n))
144
- return !1;
145
- if (n !== "ref") {
146
- const d = s[n];
147
- if (ye(c) && ye(d) || P(c) && P(d) || Array.isArray(c) && Array.isArray(d) ? !ae(c, d, t) : c !== d)
148
- return !1;
149
- }
150
- }
151
- return !0;
152
- }
153
- function sr(e) {
154
- const s = $e(), { control: t = s.control, name: i, defaultValue: o, disabled: n, exact: c, compute: d } = e || {}, D = v.useRef(o), w = v.useRef(d), g = v.useRef(void 0), x = v.useRef(t), _ = v.useRef(i);
155
- w.current = d;
156
- const [ee, H] = v.useState(() => {
157
- const F = t._getWatch(i, D.current);
158
- return w.current ? w.current(F) : F;
159
- }), S = v.useCallback((F) => {
160
- const V = Ie(i, t._names, F || t._formValues, !1, D.current);
161
- return w.current ? w.current(V) : V;
162
- }, [t._formValues, t._names, i]), M = v.useCallback((F) => {
163
- if (!n) {
164
- const V = Ie(i, t._names, F || t._formValues, !1, D.current);
165
- if (w.current) {
166
- const z = w.current(V);
167
- ae(z, g.current) || (H(z), g.current = z);
168
- } else
169
- H(V);
170
- }
171
- }, [t._formValues, t._names, n, i]);
172
- je(() => ((x.current !== t || !ae(_.current, i)) && (x.current = t, _.current = i, M()), t._subscribe({
173
- name: i,
174
- formState: {
175
- values: !0
176
- },
177
- exact: c,
178
- callback: (F) => {
179
- M(F.values);
180
- }
181
- })), [t, c, i, M]), v.useEffect(() => t._removeUnmounted());
182
- const te = x.current !== t, b = _.current, C = v.useMemo(() => {
183
- if (n)
184
- return null;
185
- const F = !te && !ae(b, i);
186
- return te || F ? S() : null;
187
- }, [n, te, i, b, S]);
188
- return C !== null ? C : ee;
189
- }
190
- function ir(e) {
191
- const s = $e(), { name: t, disabled: i, control: o = s.control, shouldUnregister: n, defaultValue: c } = e, d = gt(o._names.array, t), D = v.useMemo(() => y(o._formValues, t, y(o._defaultValues, t, c)), [o, t, c]), w = sr({
192
- control: o,
193
- name: t,
194
- defaultValue: D,
195
- exact: !0
196
- }), g = rr({
197
- control: o,
198
- name: t,
199
- exact: !0
200
- }), x = v.useRef(e), _ = v.useRef(void 0), ee = v.useRef(o.register(t, {
201
- ...e.rules,
202
- value: w,
203
- ...Z(e.disabled) ? { disabled: e.disabled } : {}
204
- }));
205
- x.current = e;
206
- const H = v.useMemo(() => Object.defineProperties({}, {
207
- invalid: {
208
- enumerable: !0,
209
- get: () => !!y(g.errors, t)
210
- },
211
- isDirty: {
212
- enumerable: !0,
213
- get: () => !!y(g.dirtyFields, t)
214
- },
215
- isTouched: {
216
- enumerable: !0,
217
- get: () => !!y(g.touchedFields, t)
218
- },
219
- isValidating: {
220
- enumerable: !0,
221
- get: () => !!y(g.validatingFields, t)
222
- },
223
- error: {
224
- enumerable: !0,
225
- get: () => y(g.errors, t)
226
- }
227
- }), [g, t]), S = v.useCallback((C) => ee.current.onChange({
228
- target: {
229
- value: _t(C),
230
- name: t
231
- },
232
- type: Ce.CHANGE
233
- }), [t]), M = v.useCallback(() => ee.current.onBlur({
234
- target: {
235
- value: y(o._formValues, t),
236
- name: t
237
- },
238
- type: Ce.BLUR
239
- }), [t, o._formValues]), te = v.useCallback((C) => {
240
- const F = y(o._fields, t);
241
- F && C && (F._f.ref = {
242
- focus: () => C.focus && C.focus(),
243
- select: () => C.select && C.select(),
244
- setCustomValidity: (V) => C.setCustomValidity(V),
245
- reportValidity: () => C.reportValidity()
246
- });
247
- }, [o._fields, t]), b = v.useMemo(() => ({
248
- name: t,
249
- value: w,
250
- ...Z(i) || g.disabled ? { disabled: g.disabled || i } : {},
251
- onChange: S,
252
- onBlur: M,
253
- ref: te
254
- }), [t, i, g.disabled, S, M, te, w]);
255
- return v.useEffect(() => {
256
- const C = o._options.shouldUnregister || n, F = _.current;
257
- F && F !== t && !d && o.unregister(F), o.register(t, {
258
- ...x.current.rules,
259
- ...Z(x.current.disabled) ? { disabled: x.current.disabled } : {}
260
- });
261
- const V = (z, j) => {
262
- const G = y(o._fields, z);
263
- G && G._f && (G._f.mount = j);
264
- };
265
- if (V(t, !0), C) {
266
- const z = W(y(o._options.defaultValues, t, x.current.defaultValue));
267
- B(o._defaultValues, t, z), O(y(o._formValues, t)) && B(o._formValues, t, z);
268
- }
269
- return !d && o.register(t), _.current = t, () => {
270
- (d ? C && !o._state.action : C) ? o.unregister(t) : V(t, !1);
271
- };
272
- }, [t, o, d, n]), v.useEffect(() => {
273
- o._setDisabledField({
274
- disabled: i,
275
- name: t
276
- });
277
- }, [i, t, o]), v.useMemo(() => ({
278
- field: b,
279
- formState: g,
280
- fieldState: H
281
- }), [b, g, H]);
282
- }
283
- const ar = (e) => e.render(ir(e));
284
- var nr = (e, s, t, i, o) => s ? {
285
- ...t[e],
286
- types: {
287
- ...t[e] && t[e].types ? t[e].types : {},
288
- [i]: o || !0
289
- }
290
- } : {}, ke = (e) => Array.isArray(e) ? e : [e], it = () => {
291
- let e = [];
292
- return {
293
- get observers() {
294
- return e;
295
- },
296
- next: (o) => {
297
- for (const n of e)
298
- n.next && n.next(o);
299
- },
300
- subscribe: (o) => (e.push(o), {
301
- unsubscribe: () => {
302
- e = e.filter((n) => n !== o);
303
- }
304
- }),
305
- unsubscribe: () => {
306
- e = [];
307
- }
308
- };
309
- };
310
- function Vt(e, s) {
311
- const t = {};
312
- for (const i in e)
313
- if (e.hasOwnProperty(i)) {
314
- const o = e[i], n = s[i];
315
- if (o && P(o) && n) {
316
- const c = Vt(o, n);
317
- P(c) && (t[i] = c);
318
- } else e[i] && (t[i] = n);
319
- }
320
- return t;
321
- }
322
- var Q = (e) => P(e) && !Object.keys(e).length, Ge = (e) => e.type === "file", ne = (e) => typeof e == "function", De = (e) => {
323
- if (!qe)
324
- return !1;
325
- const s = e ? e.ownerDocument : 0;
326
- return e instanceof (s && s.defaultView ? s.defaultView.HTMLElement : HTMLElement);
327
- }, kt = (e) => e.type === "select-multiple", Ke = (e) => e.type === "radio", lr = (e) => Ke(e) || Fe(e), Ue = (e) => De(e) && e.isConnected;
328
- function or(e, s) {
329
- const t = s.slice(0, -1).length;
330
- let i = 0;
331
- for (; i < t; )
332
- e = O(e) ? i++ : e[s[i++]];
333
- return e;
334
- }
335
- function ur(e) {
336
- for (const s in e)
337
- if (e.hasOwnProperty(s) && !O(e[s]))
338
- return !1;
339
- return !0;
340
- }
341
- function I(e, s) {
342
- const t = Array.isArray(s) ? s : Ee(s) ? [s] : ze(s), i = t.length === 1 ? e : or(e, t), o = t.length - 1, n = t[o];
343
- return i && delete i[n], o !== 0 && (P(i) && Q(i) || Array.isArray(i) && ur(i)) && I(e, t.slice(0, -1)), e;
344
- }
345
- var cr = (e) => {
346
- for (const s in e)
347
- if (ne(e[s]))
348
- return !0;
349
- return !1;
350
- };
351
- function xt(e) {
352
- return Array.isArray(e) || P(e) && !cr(e);
353
- }
354
- function We(e, s = {}) {
355
- for (const t in e)
356
- xt(e[t]) ? (s[t] = Array.isArray(e[t]) ? [] : {}, We(e[t], s[t])) : O(e[t]) || (s[t] = !0);
357
- return s;
358
- }
359
- function ge(e, s, t) {
360
- t || (t = We(s));
361
- for (const i in e)
362
- xt(e[i]) ? O(s) || Pe(t[i]) ? t[i] = We(e[i], Array.isArray(e[i]) ? [] : {}) : ge(e[i], X(s) ? {} : s[i], t[i]) : t[i] = !ae(e[i], s[i]);
363
- return t;
364
- }
365
- const at = {
366
- value: !1,
367
- isValid: !1
368
- }, nt = { value: !0, isValid: !0 };
369
- var Ft = (e) => {
370
- if (Array.isArray(e)) {
371
- if (e.length > 1) {
372
- const s = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
373
- return { value: s, isValid: !!s.length };
374
- }
375
- return e[0].checked && !e[0].disabled ? (
376
- // @ts-expect-error expected to work in the browser
377
- e[0].attributes && !O(e[0].attributes.value) ? O(e[0].value) || e[0].value === "" ? nt : { value: e[0].value, isValid: !0 } : nt
378
- ) : at;
379
- }
380
- return at;
381
- }, pt = (e, { valueAsNumber: s, valueAsDate: t, setValueAs: i }) => O(e) ? e : s ? e === "" ? NaN : e && +e : t && Y(e) ? new Date(e) : i ? i(e) : e;
382
- const lt = {
383
- isValid: !1,
384
- value: null
385
- };
386
- var At = (e) => Array.isArray(e) ? e.reduce((s, t) => t && t.checked && !t.disabled ? {
387
- isValid: !0,
388
- value: t.value
389
- } : s, lt) : lt;
390
- function ot(e) {
391
- const s = e.ref;
392
- return Ge(s) ? s.files : Ke(s) ? At(e.refs).value : kt(s) ? [...s.selectedOptions].map(({ value: t }) => t) : Fe(s) ? Ft(e.refs).value : pt(O(s.value) ? e.ref.value : s.value, e);
393
- }
394
- var dr = (e, s, t, i) => {
395
- const o = {};
396
- for (const n of e) {
397
- const c = y(s, n);
398
- c && B(o, n, c._f);
399
- }
400
- return {
401
- criteriaMode: t,
402
- names: [...e],
403
- fields: o,
404
- shouldUseNativeValidation: i
405
- };
406
- }, Se = (e) => e instanceof RegExp, Ve = (e) => O(e) ? e : Se(e) ? e.source : P(e) ? Se(e.value) ? e.value.source : e.value : e, ut = (e) => ({
407
- isOnSubmit: !e || e === ie.onSubmit,
408
- isOnBlur: e === ie.onBlur,
409
- isOnChange: e === ie.onChange,
410
- isOnAll: e === ie.all,
411
- isOnTouch: e === ie.onTouched
412
- });
413
- const ct = "AsyncFunction";
414
- var fr = (e) => !!e && !!e.validate && !!(ne(e.validate) && e.validate.constructor.name === ct || P(e.validate) && Object.values(e.validate).find((s) => s.constructor.name === ct)), yr = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), dt = (e, s, t) => !t && (s.watchAll || s.watch.has(e) || [...s.watch].some((i) => e.startsWith(i) && /^\.\w+/.test(e.slice(i.length))));
415
- const xe = (e, s, t, i) => {
416
- for (const o of t || Object.keys(e)) {
417
- const n = y(e, o);
418
- if (n) {
419
- const { _f: c, ...d } = n;
420
- if (c) {
421
- if (c.refs && c.refs[0] && s(c.refs[0], o) && !i)
422
- return !0;
423
- if (c.ref && s(c.ref, c.name) && !i)
424
- return !0;
425
- if (xe(d, s))
426
- break;
427
- } else if (P(d) && xe(d, s))
428
- break;
429
- }
430
- }
431
- };
432
- function ft(e, s, t) {
433
- const i = y(e, t);
434
- if (i || Ee(t))
435
- return {
436
- error: i,
437
- name: t
438
- };
439
- const o = t.split(".");
440
- for (; o.length; ) {
441
- const n = o.join("."), c = y(s, n), d = y(e, n);
442
- if (c && !Array.isArray(c) && t !== n)
443
- return { name: t };
444
- if (d && d.type)
445
- return {
446
- name: n,
447
- error: d
448
- };
449
- if (d && d.root && d.root.type)
450
- return {
451
- name: `${n}.root`,
452
- error: d.root
453
- };
454
- o.pop();
455
- }
456
- return {
457
- name: t
458
- };
459
- }
460
- var hr = (e, s, t, i) => {
461
- t(e);
462
- const { name: o, ...n } = e;
463
- return Q(n) || Object.keys(n).length >= Object.keys(s).length || Object.keys(n).find((c) => s[c] === (!i || ie.all));
464
- }, mr = (e, s, t) => !e || !s || e === s || ke(e).some((i) => i && (t ? i === s : i.startsWith(s) || s.startsWith(i))), _r = (e, s, t, i, o) => o.isOnAll ? !1 : !t && o.isOnTouch ? !(s || e) : (t ? i.isOnBlur : o.isOnBlur) ? !e : (t ? i.isOnChange : o.isOnChange) ? e : !0, gr = (e, s) => !He(y(e, s)).length && I(e, s), vr = (e, s, t) => {
465
- const i = ke(y(e, t));
466
- return B(i, "root", s[t]), B(e, t, i), e;
467
- };
468
- function yt(e, s, t = "validate") {
469
- if (Y(e) || Array.isArray(e) && e.every(Y) || Z(e) && !e)
470
- return {
471
- type: t,
472
- message: Y(e) ? e : "",
473
- ref: s
474
- };
475
- }
476
- var _e = (e) => P(e) && !Se(e) ? e : {
477
- value: e,
478
- message: ""
479
- }, ht = async (e, s, t, i, o, n) => {
480
- const { ref: c, refs: d, required: D, maxLength: w, minLength: g, min: x, max: _, pattern: ee, validate: H, name: S, valueAsNumber: M, mount: te } = e._f, b = y(t, S);
481
- if (!te || s.has(S))
482
- return {};
483
- const C = d ? d[0] : c, F = (k) => {
484
- o && C.reportValidity && (C.setCustomValidity(Z(k) ? "" : k || ""), C.reportValidity());
485
- }, V = {}, z = Ke(c), j = Fe(c), G = z || j, K = (M || Ge(c)) && O(c.value) && O(b) || De(c) && c.value === "" || b === "" || Array.isArray(b) && !b.length, se = nr.bind(null, S, i, V), $ = (k, p, R, N = oe.maxLength, q = oe.minLength) => {
486
- const T = k ? p : R;
487
- V[S] = {
488
- type: k ? N : q,
489
- message: T,
490
- ref: c,
491
- ...se(k ? N : q, T)
492
- };
493
- };
494
- if (n ? !Array.isArray(b) || !b.length : D && (!G && (K || X(b)) || Z(b) && !b || j && !Ft(d).isValid || z && !At(d).isValid)) {
495
- const { value: k, message: p } = Y(D) ? { value: !!D, message: D } : _e(D);
496
- if (k && (V[S] = {
497
- type: oe.required,
498
- message: p,
499
- ref: C,
500
- ...se(oe.required, p)
501
- }, !i))
502
- return F(p), V;
503
- }
504
- if (!K && (!X(x) || !X(_))) {
505
- let k, p;
506
- const R = _e(_), N = _e(x);
507
- if (!X(b) && !isNaN(b)) {
508
- const q = c.valueAsNumber || b && +b;
509
- X(R.value) || (k = q > R.value), X(N.value) || (p = q < N.value);
510
- } else {
511
- const q = c.valueAsDate || new Date(b), T = (fe) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + fe), ue = c.type == "time", le = c.type == "week";
512
- Y(R.value) && b && (k = ue ? T(b) > T(R.value) : le ? b > R.value : q > new Date(R.value)), Y(N.value) && b && (p = ue ? T(b) < T(N.value) : le ? b < N.value : q < new Date(N.value));
513
- }
514
- if ((k || p) && ($(!!k, R.message, N.message, oe.max, oe.min), !i))
515
- return F(V[S].message), V;
516
- }
517
- if ((w || g) && !K && (Y(b) || n && Array.isArray(b))) {
518
- const k = _e(w), p = _e(g), R = !X(k.value) && b.length > +k.value, N = !X(p.value) && b.length < +p.value;
519
- if ((R || N) && ($(R, k.message, p.message), !i))
520
- return F(V[S].message), V;
521
- }
522
- if (ee && !K && Y(b)) {
523
- const { value: k, message: p } = _e(ee);
524
- if (Se(k) && !b.match(k) && (V[S] = {
525
- type: oe.pattern,
526
- message: p,
527
- ref: c,
528
- ...se(oe.pattern, p)
529
- }, !i))
530
- return F(p), V;
531
- }
532
- if (H) {
533
- if (ne(H)) {
534
- const k = await H(b, t), p = yt(k, C);
535
- if (p && (V[S] = {
536
- ...p,
537
- ...se(oe.validate, p.message)
538
- }, !i))
539
- return F(p.message), V;
540
- } else if (P(H)) {
541
- let k = {};
542
- for (const p in H) {
543
- if (!Q(k) && !i)
544
- break;
545
- const R = yt(await H[p](b, t), C, p);
546
- R && (k = {
547
- ...R,
548
- ...se(p, R.message)
549
- }, F(R.message), i && (V[S] = k));
550
- }
551
- if (!Q(k) && (V[S] = {
552
- ref: C,
553
- ...k
554
- }, !i))
555
- return V;
556
- }
557
- }
558
- return F(!0), V;
559
- };
560
- const br = {
561
- mode: ie.onSubmit,
562
- reValidateMode: ie.onChange,
563
- shouldFocusError: !0
564
- };
565
- function Vr(e = {}) {
566
- let s = {
567
- ...br,
568
- ...e
569
- }, t = {
570
- submitCount: 0,
571
- isDirty: !1,
572
- isReady: !1,
573
- isLoading: ne(s.defaultValues),
574
- isValidating: !1,
575
- isSubmitted: !1,
576
- isSubmitting: !1,
577
- isSubmitSuccessful: !1,
578
- isValid: !1,
579
- touchedFields: {},
580
- dirtyFields: {},
581
- validatingFields: {},
582
- errors: s.errors || {},
583
- disabled: s.disabled || !1
584
- }, i = {}, o = P(s.defaultValues) || P(s.values) ? W(s.defaultValues || s.values) || {} : {}, n = s.shouldUnregister ? {} : W(o), c = {
585
- action: !1,
586
- mount: !1,
587
- watch: !1
588
- }, d = {
589
- mount: /* @__PURE__ */ new Set(),
590
- disabled: /* @__PURE__ */ new Set(),
591
- unMount: /* @__PURE__ */ new Set(),
592
- array: /* @__PURE__ */ new Set(),
593
- watch: /* @__PURE__ */ new Set()
594
- }, D, w = 0;
595
- const g = {
596
- isDirty: !1,
597
- dirtyFields: !1,
598
- validatingFields: !1,
599
- touchedFields: !1,
600
- isValidating: !1,
601
- isValid: !1,
602
- errors: !1
603
- };
604
- let x = {
605
- ...g
606
- };
607
- const _ = {
608
- array: it(),
609
- state: it()
610
- }, ee = s.criteriaMode === ie.all, H = (r) => (a) => {
611
- clearTimeout(w), w = setTimeout(r, a);
612
- }, S = async (r) => {
613
- if (!s.disabled && (g.isValid || x.isValid || r)) {
614
- const a = s.resolver ? Q((await j()).errors) : await K(i, !0);
615
- a !== t.isValid && _.state.next({
616
- isValid: a
617
- });
618
- }
619
- }, M = (r, a) => {
620
- !s.disabled && (g.isValidating || g.validatingFields || x.isValidating || x.validatingFields) && ((r || Array.from(d.mount)).forEach((l) => {
621
- l && (a ? B(t.validatingFields, l, a) : I(t.validatingFields, l));
622
- }), _.state.next({
623
- validatingFields: t.validatingFields,
624
- isValidating: !Q(t.validatingFields)
625
- }));
626
- }, te = (r, a = [], l, h, f = !0, u = !0) => {
627
- if (h && l && !s.disabled) {
628
- if (c.action = !0, u && Array.isArray(y(i, r))) {
629
- const m = l(y(i, r), h.argA, h.argB);
630
- f && B(i, r, m);
631
- }
632
- if (u && Array.isArray(y(t.errors, r))) {
633
- const m = l(y(t.errors, r), h.argA, h.argB);
634
- f && B(t.errors, r, m), gr(t.errors, r);
635
- }
636
- if ((g.touchedFields || x.touchedFields) && u && Array.isArray(y(t.touchedFields, r))) {
637
- const m = l(y(t.touchedFields, r), h.argA, h.argB);
638
- f && B(t.touchedFields, r, m);
639
- }
640
- (g.dirtyFields || x.dirtyFields) && (t.dirtyFields = ge(o, n)), _.state.next({
641
- name: r,
642
- isDirty: $(r, a),
643
- dirtyFields: t.dirtyFields,
644
- errors: t.errors,
645
- isValid: t.isValid
646
- });
647
- } else
648
- B(n, r, a);
649
- }, b = (r, a) => {
650
- B(t.errors, r, a), _.state.next({
651
- errors: t.errors
652
- });
653
- }, C = (r) => {
654
- t.errors = r, _.state.next({
655
- errors: t.errors,
656
- isValid: !1
657
- });
658
- }, F = (r, a, l, h) => {
659
- const f = y(i, r);
660
- if (f) {
661
- const u = y(n, r, O(l) ? y(o, r) : l);
662
- O(u) || h && h.defaultChecked || a ? B(n, r, a ? u : ot(f._f)) : R(r, u), c.mount && S();
663
- }
664
- }, V = (r, a, l, h, f) => {
665
- let u = !1, m = !1;
666
- const A = {
667
- name: r
668
- };
669
- if (!s.disabled) {
670
- if (!l || h) {
671
- (g.isDirty || x.isDirty) && (m = t.isDirty, t.isDirty = A.isDirty = $(), u = m !== A.isDirty);
672
- const E = ae(y(o, r), a);
673
- m = !!y(t.dirtyFields, r), E ? I(t.dirtyFields, r) : B(t.dirtyFields, r, !0), A.dirtyFields = t.dirtyFields, u = u || (g.dirtyFields || x.dirtyFields) && m !== !E;
674
- }
675
- if (l) {
676
- const E = y(t.touchedFields, r);
677
- E || (B(t.touchedFields, r, l), A.touchedFields = t.touchedFields, u = u || (g.touchedFields || x.touchedFields) && E !== l);
678
- }
679
- u && f && _.state.next(A);
680
- }
681
- return u ? A : {};
682
- }, z = (r, a, l, h) => {
683
- const f = y(t.errors, r), u = (g.isValid || x.isValid) && Z(a) && t.isValid !== a;
684
- if (s.delayError && l ? (D = H(() => b(r, l)), D(s.delayError)) : (clearTimeout(w), D = null, l ? B(t.errors, r, l) : I(t.errors, r)), (l ? !ae(f, l) : f) || !Q(h) || u) {
685
- const m = {
686
- ...h,
687
- ...u && Z(a) ? { isValid: a } : {},
688
- errors: t.errors,
689
- name: r
690
- };
691
- t = {
692
- ...t,
693
- ...m
694
- }, _.state.next(m);
695
- }
696
- }, j = async (r) => {
697
- M(r, !0);
698
- const a = await s.resolver(n, s.context, dr(r || d.mount, i, s.criteriaMode, s.shouldUseNativeValidation));
699
- return M(r), a;
700
- }, G = async (r) => {
701
- const { errors: a } = await j(r);
702
- if (r)
703
- for (const l of r) {
704
- const h = y(a, l);
705
- h ? B(t.errors, l, h) : I(t.errors, l);
706
- }
707
- else
708
- t.errors = a;
709
- return a;
710
- }, K = async (r, a, l = {
711
- valid: !0
712
- }) => {
713
- for (const h in r) {
714
- const f = r[h];
715
- if (f) {
716
- const { _f: u, ...m } = f;
717
- if (u) {
718
- const A = d.array.has(u.name), E = f._f && fr(f._f);
719
- E && g.validatingFields && M([u.name], !0);
720
- const re = await ht(f, d.disabled, n, ee, s.shouldUseNativeValidation && !a, A);
721
- if (E && g.validatingFields && M([u.name]), re[u.name] && (l.valid = !1, a))
722
- break;
723
- !a && (y(re, u.name) ? A ? vr(t.errors, re, u.name) : B(t.errors, u.name, re[u.name]) : I(t.errors, u.name));
724
- }
725
- !Q(m) && await K(m, a, l);
726
- }
727
- }
728
- return l.valid;
729
- }, se = () => {
730
- for (const r of d.unMount) {
731
- const a = y(i, r);
732
- a && (a._f.refs ? a._f.refs.every((l) => !Ue(l)) : !Ue(a._f.ref)) && J(r);
733
- }
734
- d.unMount = /* @__PURE__ */ new Set();
735
- }, $ = (r, a) => !s.disabled && (r && a && B(n, r, a), !ae(fe(), o)), k = (r, a, l) => Ie(r, d, {
736
- ...c.mount ? n : O(a) ? o : Y(r) ? { [r]: a } : a
737
- }, l, a), p = (r) => He(y(c.mount ? n : o, r, s.shouldUnregister ? y(o, r, []) : [])), R = (r, a, l = {}) => {
738
- const h = y(i, r);
739
- let f = a;
740
- if (h) {
741
- const u = h._f;
742
- u && (!u.disabled && B(n, r, pt(a, u)), f = De(u.ref) && X(a) ? "" : a, kt(u.ref) ? [...u.ref.options].forEach((m) => m.selected = f.includes(m.value)) : u.refs ? Fe(u.ref) ? u.refs.forEach((m) => {
743
- (!m.defaultChecked || !m.disabled) && (Array.isArray(f) ? m.checked = !!f.find((A) => A === m.value) : m.checked = f === m.value || !!f);
744
- }) : u.refs.forEach((m) => m.checked = m.value === f) : Ge(u.ref) ? u.ref.value = "" : (u.ref.value = f, u.ref.type || _.state.next({
745
- name: r,
746
- values: W(n)
747
- })));
748
- }
749
- (l.shouldDirty || l.shouldTouch) && V(r, f, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && le(r);
750
- }, N = (r, a, l) => {
751
- for (const h in a) {
752
- if (!a.hasOwnProperty(h))
753
- return;
754
- const f = a[h], u = r + "." + h, m = y(i, u);
755
- (d.array.has(r) || P(f) || m && !m._f) && !ye(f) ? N(u, f, l) : R(u, f, l);
756
- }
757
- }, q = (r, a, l = {}) => {
758
- const h = y(i, r), f = d.array.has(r), u = W(a);
759
- B(n, r, u), f ? (_.array.next({
760
- name: r,
761
- values: W(n)
762
- }), (g.isDirty || g.dirtyFields || x.isDirty || x.dirtyFields) && l.shouldDirty && _.state.next({
763
- name: r,
764
- dirtyFields: ge(o, n),
765
- isDirty: $(r, u)
766
- })) : h && !h._f && !X(u) ? N(r, u, l) : R(r, u, l), dt(r, d) && _.state.next({ ...t, name: r }), _.state.next({
767
- name: c.mount ? r : void 0,
768
- values: W(n)
769
- });
770
- }, T = async (r) => {
771
- c.mount = !0;
772
- const a = r.target;
773
- let l = a.name, h = !0;
774
- const f = y(i, l), u = (E) => {
775
- h = Number.isNaN(E) || ye(E) && isNaN(E.getTime()) || ae(E, y(n, l, E));
776
- }, m = ut(s.mode), A = ut(s.reValidateMode);
777
- if (f) {
778
- let E, re;
779
- const we = a.type ? ot(f._f) : _t(r), ce = r.type === Ce.BLUR || r.type === Ce.FOCUS_OUT, Et = !yr(f._f) && !s.resolver && !y(t.errors, l) && !f._f.deps || _r(ce, y(t.touchedFields, l), t.isSubmitted, A, m), Le = dt(l, d, ce);
780
- B(n, l, we), ce ? (!a || !a.readOnly) && (f._f.onBlur && f._f.onBlur(r), D && D(0)) : f._f.onChange && f._f.onChange(r);
781
- const Oe = V(l, we, ce), Bt = !Q(Oe) || Le;
782
- if (!ce && _.state.next({
783
- name: l,
784
- type: r.type,
785
- values: W(n)
786
- }), Et)
787
- return (g.isValid || x.isValid) && (s.mode === "onBlur" ? ce && S() : ce || S()), Bt && _.state.next({ name: l, ...Le ? {} : Oe });
788
- if (!ce && Le && _.state.next({ ...t }), s.resolver) {
789
- const { errors: Ye } = await j([l]);
790
- if (u(we), h) {
791
- const Tt = ft(t.errors, i, l), et = ft(Ye, i, Tt.name || l);
792
- E = et.error, l = et.name, re = Q(Ye);
793
- }
794
- } else
795
- M([l], !0), E = (await ht(f, d.disabled, n, ee, s.shouldUseNativeValidation))[l], M([l]), u(we), h && (E ? re = !1 : (g.isValid || x.isValid) && (re = await K(i, !0)));
796
- h && (f._f.deps && (!Array.isArray(f._f.deps) || f._f.deps.length > 0) && le(f._f.deps), z(l, re, E, Oe));
797
- }
798
- }, ue = (r, a) => {
799
- if (y(t.errors, a) && r.focus)
800
- return r.focus(), 1;
801
- }, le = async (r, a = {}) => {
802
- let l, h;
803
- const f = ke(r);
804
- if (s.resolver) {
805
- const u = await G(O(r) ? r : f);
806
- l = Q(u), h = r ? !f.some((m) => y(u, m)) : l;
807
- } else r ? (h = (await Promise.all(f.map(async (u) => {
808
- const m = y(i, u);
809
- return await K(m && m._f ? { [u]: m } : m);
810
- }))).every(Boolean), !(!h && !t.isValid) && S()) : h = l = await K(i);
811
- return _.state.next({
812
- ...!Y(r) || (g.isValid || x.isValid) && l !== t.isValid ? {} : { name: r },
813
- ...s.resolver || !r ? { isValid: l } : {},
814
- errors: t.errors
815
- }), a.shouldFocus && !h && xe(i, ue, r ? f : d.mount), h;
816
- }, fe = (r, a) => {
817
- let l = {
818
- ...c.mount ? n : o
819
- };
820
- return a && (l = Vt(a.dirtyFields ? t.dirtyFields : t.touchedFields, l)), O(r) ? l : Y(r) ? y(l, r) : r.map((h) => y(l, h));
821
- }, pe = (r, a) => ({
822
- invalid: !!y((a || t).errors, r),
823
- isDirty: !!y((a || t).dirtyFields, r),
824
- error: y((a || t).errors, r),
825
- isValidating: !!y(t.validatingFields, r),
826
- isTouched: !!y((a || t).touchedFields, r)
827
- }), Be = (r) => {
828
- r && ke(r).forEach((a) => I(t.errors, a)), _.state.next({
829
- errors: r ? t.errors : {}
830
- });
831
- }, he = (r, a, l) => {
832
- const h = (y(i, r, { _f: {} })._f || {}).ref, f = y(t.errors, r) || {}, { ref: u, message: m, type: A, ...E } = f;
833
- B(t.errors, r, {
834
- ...E,
835
- ...a,
836
- ref: h
837
- }), _.state.next({
838
- name: r,
839
- errors: t.errors,
840
- isValid: !1
841
- }), l && l.shouldFocus && h && h.focus && h.focus();
842
- }, Te = (r, a) => ne(r) ? _.state.subscribe({
843
- next: (l) => "values" in l && r(k(void 0, a), l)
844
- }) : k(r, a, !0), Ae = (r) => _.state.subscribe({
845
- next: (a) => {
846
- mr(r.name, a.name, r.exact) && hr(a, r.formState || g, St, r.reRenderRoot) && r.callback({
847
- values: { ...n },
848
- ...t,
849
- ...a,
850
- defaultValues: o
851
- });
852
- }
853
- }).unsubscribe, ve = (r) => (c.mount = !0, x = {
854
- ...x,
855
- ...r.formState
856
- }, Ae({
857
- ...r,
858
- formState: x
859
- })), J = (r, a = {}) => {
860
- for (const l of r ? ke(r) : d.mount)
861
- d.mount.delete(l), d.array.delete(l), a.keepValue || (I(i, l), I(n, l)), !a.keepError && I(t.errors, l), !a.keepDirty && I(t.dirtyFields, l), !a.keepTouched && I(t.touchedFields, l), !a.keepIsValidating && I(t.validatingFields, l), !s.shouldUnregister && !a.keepDefaultValue && I(o, l);
862
- _.state.next({
863
- values: W(n)
864
- }), _.state.next({
865
- ...t,
866
- ...a.keepDirty ? { isDirty: $() } : {}
867
- }), !a.keepIsValid && S();
868
- }, me = ({ disabled: r, name: a }) => {
869
- (Z(r) && c.mount || r || d.disabled.has(a)) && (r ? d.disabled.add(a) : d.disabled.delete(a));
870
- }, be = (r, a = {}) => {
871
- let l = y(i, r);
872
- const h = Z(a.disabled) || Z(s.disabled);
873
- return B(i, r, {
874
- ...l || {},
875
- _f: {
876
- ...l && l._f ? l._f : { ref: { name: r } },
877
- name: r,
878
- mount: !0,
879
- ...a
880
- }
881
- }), d.mount.add(r), l ? me({
882
- disabled: Z(a.disabled) ? a.disabled : s.disabled,
883
- name: r
884
- }) : F(r, !0, a.value), {
885
- ...h ? { disabled: a.disabled || s.disabled } : {},
886
- ...s.progressive ? {
887
- required: !!a.required,
888
- min: Ve(a.min),
889
- max: Ve(a.max),
890
- minLength: Ve(a.minLength),
891
- maxLength: Ve(a.maxLength),
892
- pattern: Ve(a.pattern)
893
- } : {},
894
- name: r,
895
- onChange: T,
896
- onBlur: T,
897
- ref: (f) => {
898
- if (f) {
899
- be(r, a), l = y(i, r);
900
- const u = O(f.value) && f.querySelectorAll && f.querySelectorAll("input,select,textarea")[0] || f, m = lr(u), A = l._f.refs || [];
901
- if (m ? A.find((E) => E === u) : u === l._f.ref)
902
- return;
903
- B(i, r, {
904
- _f: {
905
- ...l._f,
906
- ...m ? {
907
- refs: [
908
- ...A.filter(Ue),
909
- u,
910
- ...Array.isArray(y(o, r)) ? [{}] : []
911
- ],
912
- ref: { type: u.type, name: r }
913
- } : { ref: u }
914
- }
915
- }), F(r, !1, void 0, u);
916
- } else
917
- l = y(i, r, {}), l._f && (l._f.mount = !1), (s.shouldUnregister || a.shouldUnregister) && !(gt(d.array, r) && c.action) && d.unMount.add(r);
918
- }
919
- };
920
- }, Re = () => s.shouldFocusError && xe(i, ue, d.mount), wt = (r) => {
921
- Z(r) && (_.state.next({ disabled: r }), xe(i, (a, l) => {
922
- const h = y(i, l);
923
- h && (a.disabled = h._f.disabled || r, Array.isArray(h._f.refs) && h._f.refs.forEach((f) => {
924
- f.disabled = h._f.disabled || r;
925
- }));
926
- }, 0, !1));
927
- }, Je = (r, a) => async (l) => {
928
- let h;
929
- l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
930
- let f = W(n);
931
- if (_.state.next({
932
- isSubmitting: !0
933
- }), s.resolver) {
934
- const { errors: u, values: m } = await j();
935
- t.errors = u, f = W(m);
936
- } else
937
- await K(i);
938
- if (d.disabled.size)
939
- for (const u of d.disabled)
940
- I(f, u);
941
- if (I(t.errors, "root"), Q(t.errors)) {
942
- _.state.next({
943
- errors: {}
944
- });
945
- try {
946
- await r(f, l);
947
- } catch (u) {
948
- h = u;
949
- }
950
- } else
951
- a && await a({ ...t.errors }, l), Re(), setTimeout(Re);
952
- if (_.state.next({
953
- isSubmitted: !0,
954
- isSubmitting: !1,
955
- isSubmitSuccessful: Q(t.errors) && !h,
956
- submitCount: t.submitCount + 1,
957
- errors: t.errors
958
- }), h)
959
- throw h;
960
- }, Ct = (r, a = {}) => {
961
- y(i, r) && (O(a.defaultValue) ? q(r, W(y(o, r))) : (q(r, a.defaultValue), B(o, r, W(a.defaultValue))), a.keepTouched || I(t.touchedFields, r), a.keepDirty || (I(t.dirtyFields, r), t.isDirty = a.defaultValue ? $(r, W(y(o, r))) : $()), a.keepError || (I(t.errors, r), g.isValid && S()), _.state.next({ ...t }));
962
- }, Qe = (r, a = {}) => {
963
- const l = r ? W(r) : o, h = W(l), f = Q(r), u = f ? o : h;
964
- if (a.keepDefaultValues || (o = l), !a.keepValues) {
965
- if (a.keepDirtyValues) {
966
- const m = /* @__PURE__ */ new Set([
967
- ...d.mount,
968
- ...Object.keys(ge(o, n))
969
- ]);
970
- for (const A of Array.from(m))
971
- y(t.dirtyFields, A) ? B(u, A, y(n, A)) : q(A, y(u, A));
972
- } else {
973
- if (qe && O(r))
974
- for (const m of d.mount) {
975
- const A = y(i, m);
976
- if (A && A._f) {
977
- const E = Array.isArray(A._f.refs) ? A._f.refs[0] : A._f.ref;
978
- if (De(E)) {
979
- const re = E.closest("form");
980
- if (re) {
981
- re.reset();
982
- break;
983
- }
984
- }
985
- }
986
- }
987
- if (a.keepFieldsRef)
988
- for (const m of d.mount)
989
- q(m, y(u, m));
990
- else
991
- i = {};
992
- }
993
- n = s.shouldUnregister ? a.keepDefaultValues ? W(o) : {} : W(u), _.array.next({
994
- values: { ...u }
995
- }), _.state.next({
996
- values: { ...u }
997
- });
998
- }
999
- d = {
1000
- mount: a.keepDirtyValues ? d.mount : /* @__PURE__ */ new Set(),
1001
- unMount: /* @__PURE__ */ new Set(),
1002
- array: /* @__PURE__ */ new Set(),
1003
- disabled: /* @__PURE__ */ new Set(),
1004
- watch: /* @__PURE__ */ new Set(),
1005
- watchAll: !1,
1006
- focus: ""
1007
- }, c.mount = !g.isValid || !!a.keepIsValid || !!a.keepDirtyValues || !s.shouldUnregister && !Q(u), c.watch = !!s.shouldUnregister, _.state.next({
1008
- submitCount: a.keepSubmitCount ? t.submitCount : 0,
1009
- isDirty: f ? !1 : a.keepDirty ? t.isDirty : !!(a.keepDefaultValues && !ae(r, o)),
1010
- isSubmitted: a.keepIsSubmitted ? t.isSubmitted : !1,
1011
- dirtyFields: f ? {} : a.keepDirtyValues ? a.keepDefaultValues && n ? ge(o, n) : t.dirtyFields : a.keepDefaultValues && r ? ge(o, r) : a.keepDirty ? t.dirtyFields : {},
1012
- touchedFields: a.keepTouched ? t.touchedFields : {},
1013
- errors: a.keepErrors ? t.errors : {},
1014
- isSubmitSuccessful: a.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
1015
- isSubmitting: !1,
1016
- defaultValues: o
1017
- });
1018
- }, Xe = (r, a) => Qe(ne(r) ? r(n) : r, a), Dt = (r, a = {}) => {
1019
- const l = y(i, r), h = l && l._f;
1020
- if (h) {
1021
- const f = h.refs ? h.refs[0] : h.ref;
1022
- f.focus && (f.focus(), a.shouldSelect && ne(f.select) && f.select());
1023
- }
1024
- }, St = (r) => {
1025
- t = {
1026
- ...t,
1027
- ...r
1028
- };
1029
- }, Ze = {
1030
- control: {
1031
- register: be,
1032
- unregister: J,
1033
- getFieldState: pe,
1034
- handleSubmit: Je,
1035
- setError: he,
1036
- _subscribe: Ae,
1037
- _runSchema: j,
1038
- _focusError: Re,
1039
- _getWatch: k,
1040
- _getDirty: $,
1041
- _setValid: S,
1042
- _setFieldArray: te,
1043
- _setDisabledField: me,
1044
- _setErrors: C,
1045
- _getFieldArray: p,
1046
- _reset: Qe,
1047
- _resetDefaultValues: () => ne(s.defaultValues) && s.defaultValues().then((r) => {
1048
- Xe(r, s.resetOptions), _.state.next({
1049
- isLoading: !1
1050
- });
1051
- }),
1052
- _removeUnmounted: se,
1053
- _disableForm: wt,
1054
- _subjects: _,
1055
- _proxyFormState: g,
1056
- get _fields() {
1057
- return i;
1058
- },
1059
- get _formValues() {
1060
- return n;
1061
- },
1062
- get _state() {
1063
- return c;
1064
- },
1065
- set _state(r) {
1066
- c = r;
1067
- },
1068
- get _defaultValues() {
1069
- return o;
1070
- },
1071
- get _names() {
1072
- return d;
1073
- },
1074
- set _names(r) {
1075
- d = r;
1076
- },
1077
- get _formState() {
1078
- return t;
1079
- },
1080
- get _options() {
1081
- return s;
1082
- },
1083
- set _options(r) {
1084
- s = {
1085
- ...s,
1086
- ...r
1087
- };
1088
- }
1089
- },
1090
- subscribe: ve,
1091
- trigger: le,
1092
- register: be,
1093
- handleSubmit: Je,
1094
- watch: Te,
1095
- setValue: q,
1096
- getValues: fe,
1097
- reset: Xe,
1098
- resetField: Ct,
1099
- clearErrors: Be,
1100
- unregister: J,
1101
- setError: he,
1102
- setFocus: Dt,
1103
- getFieldState: pe
1104
- };
1105
- return {
1106
- ...Ze,
1107
- formControl: Ze
1108
- };
1109
- }
1110
- function kr(e = {}) {
1111
- const s = v.useRef(void 0), t = v.useRef(void 0), [i, o] = v.useState({
1112
- isDirty: !1,
1113
- isValidating: !1,
1114
- isLoading: ne(e.defaultValues),
1115
- isSubmitted: !1,
1116
- isSubmitting: !1,
1117
- isSubmitSuccessful: !1,
1118
- isValid: !1,
1119
- submitCount: 0,
1120
- dirtyFields: {},
1121
- touchedFields: {},
1122
- validatingFields: {},
1123
- errors: e.errors || {},
1124
- disabled: e.disabled || !1,
1125
- isReady: !1,
1126
- defaultValues: ne(e.defaultValues) ? void 0 : e.defaultValues
1127
- });
1128
- if (!s.current)
1129
- if (e.formControl)
1130
- s.current = {
1131
- ...e.formControl,
1132
- formState: i
1133
- }, e.defaultValues && !ne(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
1134
- else {
1135
- const { formControl: c, ...d } = Vr(e);
1136
- s.current = {
1137
- ...d,
1138
- formState: i
1139
- };
1140
- }
1141
- const n = s.current.control;
1142
- return n._options = e, je(() => {
1143
- const c = n._subscribe({
1144
- formState: n._proxyFormState,
1145
- callback: () => o({ ...n._formState }),
1146
- reRenderRoot: !0
1147
- });
1148
- return o((d) => ({
1149
- ...d,
1150
- isReady: !0
1151
- })), n._formState.isReady = !0, c;
1152
- }, [n]), v.useEffect(() => n._disableForm(e.disabled), [n, e.disabled]), v.useEffect(() => {
1153
- e.mode && (n._options.mode = e.mode), e.reValidateMode && (n._options.reValidateMode = e.reValidateMode);
1154
- }, [n, e.mode, e.reValidateMode]), v.useEffect(() => {
1155
- e.errors && (n._setErrors(e.errors), n._focusError());
1156
- }, [n, e.errors]), v.useEffect(() => {
1157
- e.shouldUnregister && n._subjects.state.next({
1158
- values: n._getWatch()
1159
- });
1160
- }, [n, e.shouldUnregister]), v.useEffect(() => {
1161
- if (n._proxyFormState.isDirty) {
1162
- const c = n._getDirty();
1163
- c !== i.isDirty && n._subjects.state.next({
1164
- isDirty: c
1165
- });
1166
- }
1167
- }, [n, i.isDirty]), v.useEffect(() => {
1168
- e.values && !ae(e.values, t.current) ? (n._reset(e.values, {
1169
- keepFieldsRef: !0,
1170
- ...n._options.resetOptions
1171
- }), t.current = e.values, o((c) => ({ ...c }))) : n._resetDefaultValues();
1172
- }, [n, e.values]), v.useEffect(() => {
1173
- n._state.mount || (n._setValid(), n._state.mount = !0), n._state.watch && (n._state.watch = !1, n._subjects.state.next({ ...n._formState })), n._removeUnmounted();
1174
- }), s.current.formState = bt(i, n), s.current;
1175
- }
1176
- var xr = /* @__PURE__ */ ((e) => (e.PRIVACY_POLICY = "privacy-policy", e.PERSONAL_DATA = "personal-data", e.MAILING = "mailing", e.STONE_VALUE = "stone-value", e))(xr || {});
1177
- const Fr = Mt.bind(U), pr = "Я принимаю условия Политики обработки и защиты персональных данных, даю согласия на обработку персональных данных", Ur = ({
1178
- isFormOpen: e,
1179
- setIsFormOpen: s,
1180
- isNews: t,
1181
- title: i,
1182
- isEmail: o,
1183
- isPhone: n,
1184
- isTextArea: c,
1185
- telegramLink: d = "https://t.me/stone_developer",
1186
- isRequiredPhone: D = !0,
1187
- isRequiredEmail: w = !1,
1188
- isRequiredPhoneOrEmail: g,
1189
- textAreaPlaceholder: x,
1190
- subTitle: _,
1191
- submitHandler: ee,
1192
- modalWidth: H = "442px",
1193
- rowsTextArea: S = 2,
1194
- advCheckBox: M = { text: pr, isRequired: !0 },
1195
- isAdvCheckBox: te,
1196
- addTitleClassName: b,
1197
- createPortalObj: C,
1198
- telegramClickHandler: F = () => null,
1199
- blurHandler: V,
1200
- handlerButton: z,
1201
- block_name: j,
1202
- policiesMap: G,
1203
- emitCheckBox: K,
1204
- emitAdvCheckBox: se
1205
- }) => {
1206
- const {
1207
- register: $,
1208
- handleSubmit: k,
1209
- reset: p,
1210
- control: R,
1211
- watch: N,
1212
- setValue: q,
1213
- formState: { errors: T }
1214
- } = kr(), ue = !!N("email"), le = N("personalCheckBox"), fe = N("advCheckBox");
1215
- Ne(() => {
1216
- typeof le < "u" && K && K();
1217
- }, [K, le]), Ne(() => {
1218
- typeof fe < "u" && se && se();
1219
- }, [se, fe]);
1220
- const { isMobile: pe, currentClientWidth: Be } = Ut(), he = N("personalCheckBox"), Te = N("advCheckBox"), Ae = (J) => {
1221
- ee(J), p();
1222
- }, ve = (J, { action_element_status: me, action_element: be }) => {
1223
- V && V({
1224
- e: J,
1225
- analyticParams: { action_element: be, action_element_status: me, block_name: j }
1226
- });
1227
- };
1228
- return Ne(() => {
1229
- if (!G)
1230
- return;
1231
- const J = ["personal-data", "privacy-policy", ...t ? [
1232
- "mailing"
1233
- /* MAILING */
1234
- ] : []];
1235
- he ? q(
1236
- "policy-slug",
1237
- J.join(", "),
1238
- { shouldDirty: !0 }
1239
- ) : q("policy-slug", "", { shouldDirty: !0 });
1240
- }, [G, he]), Be ? /* @__PURE__ */ L(
1241
- It,
1242
- {
1243
- additionalClass: U.modal,
1244
- additionalClassModalBody: U.modalBody,
1245
- createPortalObj: C,
1246
- isOpen: e,
1247
- isTransparentBack: !0,
1248
- emitIsOpen: () => s(!1),
1249
- opacity: 0.7,
1250
- children: /* @__PURE__ */ de(
1251
- "div",
1252
- {
1253
- className: U.root,
1254
- style: { width: pe ? "100%" : H },
1255
- "data-testid": "modal_window",
1256
- children: [
1257
- /* @__PURE__ */ L(
1258
- "div",
1259
- {
1260
- className: Fr(U.title, b),
1261
- dangerouslySetInnerHTML: { __html: i ?? "Оставить обращение" }
1262
- }
1263
- ),
1264
- t && /* @__PURE__ */ de("div", { className: U.telegramWrapper, children: [
1265
- /* @__PURE__ */ L(
1266
- "a",
1267
- {
1268
- className: U.telegramLink,
1269
- href: d,
1270
- target: "_blank",
1271
- "data-testid": "modal_telegram_link",
1272
- children: /* @__PURE__ */ de(
1273
- "div",
1274
- {
1275
- className: U.telegram,
1276
- onClick: F,
1277
- children: [
1278
- /* @__PURE__ */ L("div", { children: "Подписаться в Telegram" }),
1279
- /* @__PURE__ */ L(tt, { name: "telegram" })
1280
- ]
1281
- }
1282
- )
1283
- }
1284
- ),
1285
- /* @__PURE__ */ L("div", { className: U.orText, children: "или" })
1286
- ] }),
1287
- !t && /* @__PURE__ */ L(
1288
- "div",
1289
- {
1290
- className: U.description,
1291
- dangerouslySetInnerHTML: {
1292
- __html: _ && !t ? "Оставьте номер телефона для получения консультации" : `${/* @__PURE__ */ L("div", { children: "привет" })}`
1293
- }
1294
- }
1295
- ),
1296
- /* @__PURE__ */ de("form", { onSubmit: k(Ae), children: [
1297
- /* @__PURE__ */ de(Pt, { className: U.inputWrapper, children: [
1298
- /* @__PURE__ */ L(
1299
- Me,
1300
- {
1301
- width: "full",
1302
- size_s: "large",
1303
- variant: "light",
1304
- placeholder: "Введите имя",
1305
- "data-testid": "modal_name",
1306
- ...$("name", { required: !0, pattern: Rt }),
1307
- onBlur: (J) => ve(J, {
1308
- action_element_status: T.name ? "error" : "success",
1309
- action_element: `input_${j}_name`
1310
- }),
1311
- error: !!T.name
1312
- }
1313
- ),
1314
- n && /* @__PURE__ */ L(
1315
- ar,
1316
- {
1317
- name: "phone",
1318
- control: R,
1319
- rules: {
1320
- required: w || D || g && !ue,
1321
- pattern: { value: Lt, message: "" }
1322
- },
1323
- defaultValue: "",
1324
- render: ({ field: J }) => /* @__PURE__ */ L(
1325
- Me,
1326
- {
1327
- inputMode: "numeric",
1328
- isPhoneIMask: !0,
1329
- ...J,
1330
- width: "full",
1331
- "data-testid": "phone_modal",
1332
- type: "tel",
1333
- error: !!T.phone,
1334
- size_s: "large",
1335
- variant: "light",
1336
- onBlur: (me) => ve(me, {
1337
- action_element_status: T.phone ? "error" : "success",
1338
- action_element: `input_${j}_phone`
1339
- })
1340
- }
1341
- )
1342
- }
1343
- ),
1344
- o && /* @__PURE__ */ L(
1345
- Me,
1346
- {
1347
- width: "full",
1348
- size_s: "large",
1349
- variant: "light",
1350
- placeholder: "Введите email",
1351
- "data-testid": "modal_email",
1352
- ...$("email", {
1353
- required: w || g && !ue,
1354
- pattern: Ot
1355
- }),
1356
- error: !!T.email,
1357
- onBlur: (J) => ve(J, {
1358
- action_element_status: T.email ? "error" : "success",
1359
- action_element: `input_${j}_email`
1360
- })
1361
- }
1362
- ),
1363
- c && /* @__PURE__ */ L(
1364
- Nt,
1365
- {
1366
- "data-testid": "modal_textarea",
1367
- placeholder: x,
1368
- rows: S,
1369
- width: "full",
1370
- ...$("textarea")
1371
- }
1372
- ),
1373
- M && !t && te && /* @__PURE__ */ L(
1374
- rt,
1375
- {
1376
- "data-testid": "modal_advCheckBox",
1377
- isChecked: Te,
1378
- error: !!T.advCheckBox,
1379
- text: M.text,
1380
- ...$("advCheckBox", { required: M?.isRequired })
1381
- }
1382
- ),
1383
- /* @__PURE__ */ de(
1384
- rt,
1385
- {
1386
- "data-testid": "modal_personalCheckBox",
1387
- isChecked: he,
1388
- error: !!T.personalCheckBox,
1389
- ...$("personalCheckBox", { required: !t }),
1390
- children: [
1391
- t && /* @__PURE__ */ de("div", { className: U.checkboxText, children: [
1392
- "Я принимаю условия",
1393
- " ",
1394
- /* @__PURE__ */ L(
1395
- "a",
1396
- {
1397
- className: U.linkPolicy,
1398
- href: G?.[
1399
- "personal-data"
1400
- /* PERSONAL_DATA */
1401
- ] || "/documents/docs",
1402
- target: "_blank",
1403
- rel: "noopener noreferrer",
1404
- children: "Политики обработки"
1405
- }
1406
- ),
1407
- " ",
1408
- "и",
1409
- " ",
1410
- /* @__PURE__ */ L(
1411
- "a",
1412
- {
1413
- className: U.linkPolicy,
1414
- href: G?.[
1415
- "privacy-policy"
1416
- /* PRIVACY_POLICY */
1417
- ] || "/documents/politika-konfidenczialnosti",
1418
- target: "_blank",
1419
- rel: "noopener noreferrer",
1420
- children: "защиты персональных данных"
1421
- }
1422
- ),
1423
- ", даю",
1424
- " ",
1425
- /* @__PURE__ */ L(
1426
- "a",
1427
- {
1428
- className: U.linkPolicy,
1429
- href: G?.mailing || "/documents/soglasie-na-rassylki",
1430
- target: "_blank",
1431
- rel: "noopener noreferrer",
1432
- children: "согласие на получение новостных и рекламных сообщений"
1433
- }
1434
- )
1435
- ] }),
1436
- !t && /* @__PURE__ */ de("div", { className: U.checkboxText, children: [
1437
- "Я принимаю условия",
1438
- " ",
1439
- /* @__PURE__ */ L(
1440
- "a",
1441
- {
1442
- className: U.linkPolicy,
1443
- href: G?.[
1444
- "privacy-policy"
1445
- /* PRIVACY_POLICY */
1446
- ] || "/documents/politika-konfidenczialnosti",
1447
- target: "_blank",
1448
- rel: "noopener noreferrer",
1449
- children: "Политики обработки и защиты персональных данных"
1450
- }
1451
- ),
1452
- ", даю",
1453
- " ",
1454
- /* @__PURE__ */ L(
1455
- "a",
1456
- {
1457
- className: U.linkPolicy,
1458
- href: G?.[
1459
- "personal-data"
1460
- /* PERSONAL_DATA */
1461
- ] || "/documents/docs",
1462
- target: "_blank",
1463
- rel: "noopener noreferrer",
1464
- children: "согласие на обработку персональных данных"
1465
- }
1466
- )
1467
- ] })
1468
- ]
1469
- }
1470
- ),
1471
- /* @__PURE__ */ L(
1472
- st,
1473
- {
1474
- "data-testid": "modal_submit",
1475
- variant: "blue",
1476
- width: "full",
1477
- type: "submit",
1478
- size: "large",
1479
- as: "button",
1480
- additionalClass: U.modalBtn,
1481
- onClick: () => {
1482
- z && z();
1483
- },
1484
- disabled: !!T.name || !!T.phone && D || !!T.email && w || !!T.advCheckBox && M?.isRequired || !!T.personalCheckBox && !t,
1485
- children: "Отправить запрос"
1486
- }
1487
- )
1488
- ] }),
1489
- /* @__PURE__ */ L(
1490
- st,
1491
- {
1492
- additionalClass: U.btn,
1493
- onClick: () => s(!1),
1494
- as: "button",
1495
- variant: "gray",
1496
- type: "button",
1497
- size: "small",
1498
- children: /* @__PURE__ */ L(
1499
- tt,
1500
- {
1501
- name: "close",
1502
- size: "16",
1503
- color: "#141416"
1504
- }
1505
- )
1506
- }
1507
- )
1508
- ] })
1509
- ]
1510
- }
1511
- )
1512
- }
1513
- ) : null;
1514
- };
1
+ import "react/jsx-runtime";
2
+ import { M as j, P as k } from "../../../FilterWithSave-B2QqOGDk.js";
3
+ import "../../Modal/ui/Modal.js";
4
+ import "../../Flex/ui/Flex.js";
5
+ import "../../Input/ui/Input.js";
6
+ import "../../Button/ui/Button.js";
7
+ import "../../NewIcon/ui/NewIcon.js";
8
+ import "../utils/reg.js";
9
+ import "../../CheckBox/CheckBox.js";
10
+ import "../../TextArea/TextArea.js";
11
+ import "../../../index-YnD2EP-S.js";
12
+ import "../../mobileButton/ui/MobileButton.js";
13
+ import "../../DestinationTab/ui/DestinationTab.js";
14
+ import "../../RoundButton/ui/RoundButton.js";
15
+ import "../../Tag/ui/Tag.js";
16
+ import "../../Switcher/ui/Switcher.js";
17
+ import "../../Text/ui/Text.js";
18
+ import "../../GroupedInput/ui/GroupedInputs.js";
19
+ import "../../MetroTag/ui/MetroTag.js";
20
+ import "../../Select/ui/Select.js";
21
+ import "../../../shared/useClientWidth.js";
22
+ import "../../SliderNavigation/ui/SliderNavigation.js";
23
+ import "../../LotCardSkeleton/ui/LotCardSkeleton.js";
24
+ import "../../TabSelect/ui/TabSelect.js";
25
+ import "../../CheckBoxNew/CheckBoxNew.js";
26
+ import "../../CheckboxSelect/ui/CheckboxSelect.js";
27
+ import "react";
1515
28
  export {
1516
- Ur as ModalForm,
1517
- xr as POLICY_TYPE
29
+ j as ModalForm,
30
+ k as POLICY_TYPE
1518
31
  };