react-artasys-ui 0.1.30 → 0.1.31
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/{lib/src → dist}/Button/Button.d.ts +1 -1
- package/dist/Button/index.d.ts +3 -0
- package/dist/Checkbox/Checkbox.d.ts +8 -0
- package/dist/Checkbox/index.d.ts +2 -0
- package/{lib/src → dist}/Components/Arrow/Arrow.d.ts +1 -1
- package/dist/Components/Arrow/index.d.ts +2 -0
- package/{lib/src → dist}/Dropdown/Dropdown.d.ts +4 -4
- package/{lib/src → dist}/Dropdown/Item.d.ts +1 -1
- package/{lib/src → dist}/Dropdown/Items.d.ts +1 -1
- package/{lib/src → dist}/Dropdown/index.d.ts +3 -3
- package/{lib/src → dist}/File/File.d.ts +2 -2
- package/dist/File/index.d.ts +3 -0
- package/dist/FileInput/index.d.ts +3 -0
- package/{lib/src → dist}/Form/Element/Element.d.ts +1 -1
- package/dist/Form/Element/index.d.ts +3 -0
- package/dist/Form/index.d.ts +5 -0
- package/{lib/src → dist}/Form/types.d.ts +1 -1
- package/{lib/src → dist}/Form/useForm.d.ts +3 -3
- package/dist/Input/Input.d.ts +12 -0
- package/dist/Input/index.d.ts +2 -0
- package/dist/Loading/index.d.ts +3 -0
- package/dist/Progress/index.d.ts +2 -0
- package/{lib/src → dist}/Provider/Provider.d.ts +2 -2
- package/dist/Provider/ProviderContext.d.ts +1 -0
- package/dist/Provider/index.d.ts +2 -0
- package/{lib/src → dist}/Select/Optgroup.d.ts +1 -1
- package/{lib/src → dist}/Select/Option.d.ts +1 -1
- package/{lib/src → dist}/Select/Select.d.ts +6 -6
- package/{lib/src → dist}/Select/index.d.ts +4 -4
- package/{lib/src → dist}/Spinner/Spinner.d.ts +2 -2
- package/dist/Spinner/index.d.ts +3 -0
- package/{lib/src → dist}/TextArea/TextArea.d.ts +3 -3
- package/dist/TextArea/index.d.ts +2 -0
- package/{lib/src → dist}/UploadImages/Image.d.ts +1 -1
- package/{lib/src → dist}/UploadImages/UploadImages.d.ts +1 -1
- package/dist/UploadImages/index.d.ts +4 -0
- package/dist/index.cjs.js +10 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.es.js +1423 -0
- package/dist/styles.css +2 -80
- package/package.json +14 -8
- package/dist/index.js +0 -3
- package/dist/index.js.LICENSE.txt +0 -9
- package/dist/index.js.map +0 -1
- package/dist/styles.css.map +0 -1
- package/lib/src/Button/index.d.ts +0 -3
- package/lib/src/Checkbox/Checkbox.d.ts +0 -8
- package/lib/src/Checkbox/index.d.ts +0 -2
- package/lib/src/Components/Arrow/index.d.ts +0 -2
- package/lib/src/File/index.d.ts +0 -3
- package/lib/src/FileInput/index.d.ts +0 -3
- package/lib/src/Form/Element/index.d.ts +0 -3
- package/lib/src/Form/index.d.ts +0 -5
- package/lib/src/Input/Input.d.ts +0 -12
- package/lib/src/Input/index.d.ts +0 -2
- package/lib/src/Loading/index.d.ts +0 -3
- package/lib/src/Progress/index.d.ts +0 -2
- package/lib/src/Provider/ProviderContext.d.ts +0 -1
- package/lib/src/Provider/index.d.ts +0 -2
- package/lib/src/Spinner/index.d.ts +0 -3
- package/lib/src/TextArea/index.d.ts +0 -2
- package/lib/src/UploadImages/index.d.ts +0 -5
- package/lib/src/index.d.ts +0 -20
- package/lib/stories/Button.stories.d.ts +0 -6
- package/lib/stories/Checkbox.stories.d.ts +0 -6
- package/lib/stories/Dropdown/Dropdown.stories.d.ts +0 -6
- package/lib/stories/Dropdown/Item.stories.d.ts +0 -6
- package/lib/stories/Dropdown/Items.stories.d.ts +0 -6
- package/lib/stories/File.stories.d.ts +0 -6
- package/lib/stories/FileInput.stories.d.ts +0 -9
- package/lib/stories/Form/Element/Element.stories.d.ts +0 -6
- package/lib/stories/Form/Form.stories.d.ts +0 -6
- package/lib/stories/Input.stories.d.ts +0 -6
- package/lib/stories/Loading.stories.d.ts +0 -6
- package/lib/stories/Progress.stories.d.ts +0 -6
- package/lib/stories/Select/Select.stories.d.ts +0 -6
- package/lib/stories/Spinner.stories.d.ts +0 -6
- package/lib/stories/TextArea.stories.d.ts +0 -6
- /package/{lib/src → dist}/FileInput/FileInput.d.ts +0 -0
- /package/{lib/src → dist}/Form/Form.d.ts +0 -0
- /package/{lib/src → dist}/Loading/Loading.d.ts +0 -0
- /package/{lib/src → dist}/Progress/Progress.d.ts +0 -0
- /package/{lib/src → dist}/ui-types.d.ts +0 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,1423 @@
|
|
|
1
|
+
import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import r, { cloneElement as i, createContext as a, forwardRef as o, useCallback as s, useContext as c, useEffect as l, useImperativeHandle as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
3
|
+
var m = {
|
|
4
|
+
container: "style-module__container__62IoS",
|
|
5
|
+
"wait-indicator": "style-module__wait-indicator__gf4Cz",
|
|
6
|
+
wait: "style-module__wait__gRt9X"
|
|
7
|
+
}, h = {
|
|
8
|
+
spinner: "style-module__spinner__bqxDY",
|
|
9
|
+
"button-spinner-border": "style-module__button-spinner-border__Zu60W",
|
|
10
|
+
"ui-spinner-contrast": "style-module__ui-spinner-contrast__uV5ba",
|
|
11
|
+
small: "style-module__small__A2XhO",
|
|
12
|
+
middle: "style-module__middle__5esgZ",
|
|
13
|
+
large: "style-module__large__5MX0S"
|
|
14
|
+
}, g = ({ size: e, contrast: n, ...r }) => {
|
|
15
|
+
let i = ["ui-spinner"];
|
|
16
|
+
return i.push(h.spinner), e && i.push(h[e], "ui-spinner-" + e), n && i.push(h["ui-spinner-contrast"]), r.className && i.push(r.className), /* @__PURE__ */ t("div", {
|
|
17
|
+
...r,
|
|
18
|
+
className: i.join(" ")
|
|
19
|
+
});
|
|
20
|
+
}, _ = {
|
|
21
|
+
container: "style-module__container__Tcehc",
|
|
22
|
+
radius: "style-module__radius__9sZ2F",
|
|
23
|
+
small: "style-module__small__GbGdW",
|
|
24
|
+
middle: "style-module__middle__Xb1-y",
|
|
25
|
+
large: "style-module__large__eTEPS"
|
|
26
|
+
}, v = ({ value: e = 0, size: n, radius: r = !1 }) => {
|
|
27
|
+
e = Math.ceil(Number(e) * 10) / 10, e > 100 && (e = 100), e < 0 && (e = 0);
|
|
28
|
+
let i = r ? 360 / 100 * e + "deg" : e + "%", a = ["ui-progress"];
|
|
29
|
+
return a.push(_.container), n && a.push(_[n]), r && a.push(_.radius), /* @__PURE__ */ t("div", {
|
|
30
|
+
className: a.join(" "),
|
|
31
|
+
"data-progress": e,
|
|
32
|
+
style: { "--progress": i }
|
|
33
|
+
});
|
|
34
|
+
}, y = ({ children: e, wait: r, progress: i, progressRadius: a = !0, className: o, onSubmit: s, ...c }) => {
|
|
35
|
+
let l = (e) => {
|
|
36
|
+
e.preventDefault(), typeof s == "function" && s(e);
|
|
37
|
+
}, u = [];
|
|
38
|
+
return u.push(m.container), r && u.push(m.wait), o && u.push(o), /* @__PURE__ */ n("form", {
|
|
39
|
+
...c,
|
|
40
|
+
onSubmit: l,
|
|
41
|
+
className: u.join(" "),
|
|
42
|
+
children: [e, /* @__PURE__ */ t("div", {
|
|
43
|
+
className: m["wait-indicator"],
|
|
44
|
+
children: typeof i == "number" ? /* @__PURE__ */ t(v, {
|
|
45
|
+
radius: a,
|
|
46
|
+
value: i
|
|
47
|
+
}) : /* @__PURE__ */ t(g, {})
|
|
48
|
+
})]
|
|
49
|
+
});
|
|
50
|
+
}, b = (e) => e.type === "checkbox", x = (e) => e instanceof Date, S = (e) => e == null, C = (e) => typeof e == "object", w = (e) => !S(e) && !Array.isArray(e) && C(e) && !x(e), T = (e) => w(e) && e.target ? b(e.target) ? e.target.checked : e.target.value : e, E = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, ee = (e, t) => e.has(E(t)), D = (e) => {
|
|
51
|
+
let t = e.constructor && e.constructor.prototype;
|
|
52
|
+
return w(t) && t.hasOwnProperty("isPrototypeOf");
|
|
53
|
+
}, O = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
|
|
54
|
+
function k(e) {
|
|
55
|
+
let t, n = Array.isArray(e), r = typeof FileList < "u" ? e instanceof FileList : !1;
|
|
56
|
+
if (e instanceof Date) t = new Date(e);
|
|
57
|
+
else if (e instanceof Set) t = new Set(e);
|
|
58
|
+
else if (!(O && (e instanceof Blob || r)) && (n || w(e))) if (t = n ? [] : {}, !n && !D(e)) t = e;
|
|
59
|
+
else for (let n in e) e.hasOwnProperty(n) && (t[n] = k(e[n]));
|
|
60
|
+
else return e;
|
|
61
|
+
return t;
|
|
62
|
+
}
|
|
63
|
+
var te = (e) => Array.isArray(e) ? e.filter(Boolean) : [], A = (e) => e === void 0, j = (e, t, n) => {
|
|
64
|
+
if (!t || !w(e)) return n;
|
|
65
|
+
let r = te(t.split(/[,[\].]+?/)).reduce((e, t) => S(e) ? e : e[t], e);
|
|
66
|
+
return A(r) || r === e ? A(e[t]) ? n : e[t] : r;
|
|
67
|
+
}, M = (e) => typeof e == "boolean", ne = (e) => /^\w*$/.test(e), N = (e) => te(e.replace(/["|']|\]/g, "").split(/\.|\[/)), P = (e, t, n) => {
|
|
68
|
+
let r = -1, i = ne(t) ? [t] : N(t), a = i.length, o = a - 1;
|
|
69
|
+
for (; ++r < a;) {
|
|
70
|
+
let t = i[r], a = n;
|
|
71
|
+
if (r !== o) {
|
|
72
|
+
let n = e[t];
|
|
73
|
+
a = w(n) || Array.isArray(n) ? n : isNaN(+i[r + 1]) ? {} : [];
|
|
74
|
+
}
|
|
75
|
+
if (t === "__proto__" || t === "constructor" || t === "prototype") return;
|
|
76
|
+
e[t] = a, e = e[t];
|
|
77
|
+
}
|
|
78
|
+
return e;
|
|
79
|
+
}, re = {
|
|
80
|
+
BLUR: "blur",
|
|
81
|
+
FOCUS_OUT: "focusout",
|
|
82
|
+
CHANGE: "change"
|
|
83
|
+
}, F = {
|
|
84
|
+
onBlur: "onBlur",
|
|
85
|
+
onChange: "onChange",
|
|
86
|
+
onSubmit: "onSubmit",
|
|
87
|
+
onTouched: "onTouched",
|
|
88
|
+
all: "all"
|
|
89
|
+
}, I = {
|
|
90
|
+
max: "max",
|
|
91
|
+
min: "min",
|
|
92
|
+
maxLength: "maxLength",
|
|
93
|
+
minLength: "minLength",
|
|
94
|
+
pattern: "pattern",
|
|
95
|
+
required: "required",
|
|
96
|
+
validate: "validate"
|
|
97
|
+
};
|
|
98
|
+
r.createContext(null);
|
|
99
|
+
var L = (e, t, n, r = !0) => {
|
|
100
|
+
let i = { defaultValues: t._defaultValues };
|
|
101
|
+
for (let a in e) Object.defineProperty(i, a, { get: () => {
|
|
102
|
+
let i = a;
|
|
103
|
+
return t._proxyFormState[i] !== F.all && (t._proxyFormState[i] = !r || F.all), n && (n[i] = !0), e[i];
|
|
104
|
+
} });
|
|
105
|
+
return i;
|
|
106
|
+
}, R = (e) => w(e) && !Object.keys(e).length, ie = (e, t, n, r) => {
|
|
107
|
+
n(e);
|
|
108
|
+
let { name: i, ...a } = e;
|
|
109
|
+
return R(a) || Object.keys(a).length >= Object.keys(t).length || Object.keys(a).find((e) => t[e] === (!r || F.all));
|
|
110
|
+
}, ae = (e) => Array.isArray(e) ? e : [e];
|
|
111
|
+
function z(e) {
|
|
112
|
+
let t = r.useRef(e);
|
|
113
|
+
t.current = e, r.useEffect(() => {
|
|
114
|
+
let n = !e.disabled && t.current.subject && t.current.subject.subscribe({ next: t.current.next });
|
|
115
|
+
return () => {
|
|
116
|
+
n && n.unsubscribe();
|
|
117
|
+
};
|
|
118
|
+
}, [e.disabled]);
|
|
119
|
+
}
|
|
120
|
+
var B = (e) => typeof e == "string", oe = (e, t, n, r, i) => B(e) ? (r && t.watch.add(e), j(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), j(n, e))) : (r && (t.watchAll = !0), n), se = (e, t, n, r, i) => t ? {
|
|
121
|
+
...n[e],
|
|
122
|
+
types: {
|
|
123
|
+
...n[e] && n[e].types ? n[e].types : {},
|
|
124
|
+
[r]: i || !0
|
|
125
|
+
}
|
|
126
|
+
} : {}, ce = (e) => ({
|
|
127
|
+
isOnSubmit: !e || e === F.onSubmit,
|
|
128
|
+
isOnBlur: e === F.onBlur,
|
|
129
|
+
isOnChange: e === F.onChange,
|
|
130
|
+
isOnAll: e === F.all,
|
|
131
|
+
isOnTouch: e === F.onTouched
|
|
132
|
+
}), le = (e, t, n) => !n && (t.watchAll || t.watch.has(e) || [...t.watch].some((t) => e.startsWith(t) && /^\.\w+/.test(e.slice(t.length)))), ue = (e, t, n, r) => {
|
|
133
|
+
for (let i of n || Object.keys(e)) {
|
|
134
|
+
let n = j(e, i);
|
|
135
|
+
if (n) {
|
|
136
|
+
let { _f: e, ...a } = n;
|
|
137
|
+
if (e) {
|
|
138
|
+
if (e.refs && e.refs[0] && t(e.refs[0], i) && !r || e.ref && t(e.ref, e.name) && !r) return !0;
|
|
139
|
+
if (ue(a, t)) break;
|
|
140
|
+
} else if (w(a) && ue(a, t)) break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}, de = (e, t, n) => {
|
|
144
|
+
let r = ae(j(e, n));
|
|
145
|
+
return P(r, "root", t[n]), P(e, n, r), e;
|
|
146
|
+
}, fe = (e) => e.type === "file", V = (e) => typeof e == "function", pe = (e) => {
|
|
147
|
+
if (!O) return !1;
|
|
148
|
+
let t = e ? e.ownerDocument : 0;
|
|
149
|
+
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
|
|
150
|
+
}, me = (e) => B(e), H = (e) => e.type === "radio", U = (e) => e instanceof RegExp, W = {
|
|
151
|
+
value: !1,
|
|
152
|
+
isValid: !1
|
|
153
|
+
}, he = {
|
|
154
|
+
value: !0,
|
|
155
|
+
isValid: !0
|
|
156
|
+
}, ge = (e) => {
|
|
157
|
+
if (Array.isArray(e)) {
|
|
158
|
+
if (e.length > 1) {
|
|
159
|
+
let t = e.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
|
|
160
|
+
return {
|
|
161
|
+
value: t,
|
|
162
|
+
isValid: !!t.length
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return e[0].checked && !e[0].disabled ? e[0].attributes && !A(e[0].attributes.value) ? A(e[0].value) || e[0].value === "" ? he : {
|
|
166
|
+
value: e[0].value,
|
|
167
|
+
isValid: !0
|
|
168
|
+
} : he : W;
|
|
169
|
+
}
|
|
170
|
+
return W;
|
|
171
|
+
}, _e = {
|
|
172
|
+
isValid: !1,
|
|
173
|
+
value: null
|
|
174
|
+
}, ve = (e) => Array.isArray(e) ? e.reduce((e, t) => t && t.checked && !t.disabled ? {
|
|
175
|
+
isValid: !0,
|
|
176
|
+
value: t.value
|
|
177
|
+
} : e, _e) : _e;
|
|
178
|
+
function ye(e, t, n = "validate") {
|
|
179
|
+
if (me(e) || Array.isArray(e) && e.every(me) || M(e) && !e) return {
|
|
180
|
+
type: n,
|
|
181
|
+
message: me(e) ? e : "",
|
|
182
|
+
ref: t
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
var G = (e) => w(e) && !U(e) ? e : {
|
|
186
|
+
value: e,
|
|
187
|
+
message: ""
|
|
188
|
+
}, be = async (e, t, n, r, i, a) => {
|
|
189
|
+
let { ref: o, refs: s, required: c, maxLength: l, minLength: u, min: d, max: f, pattern: p, validate: m, name: h, valueAsNumber: g, mount: _ } = e._f, v = j(n, h);
|
|
190
|
+
if (!_ || t.has(h)) return {};
|
|
191
|
+
let y = s ? s[0] : o, x = (e) => {
|
|
192
|
+
i && y.reportValidity && (y.setCustomValidity(M(e) ? "" : e || ""), y.reportValidity());
|
|
193
|
+
}, C = {}, T = H(o), E = b(o), ee = T || E, D = (g || fe(o)) && A(o.value) && A(v) || pe(o) && o.value === "" || v === "" || Array.isArray(v) && !v.length, O = se.bind(null, h, r, C), k = (e, t, n, r = I.maxLength, i = I.minLength) => {
|
|
194
|
+
let a = e ? t : n;
|
|
195
|
+
C[h] = {
|
|
196
|
+
type: e ? r : i,
|
|
197
|
+
message: a,
|
|
198
|
+
ref: o,
|
|
199
|
+
...O(e ? r : i, a)
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
if (a ? !Array.isArray(v) || !v.length : c && (!ee && (D || S(v)) || M(v) && !v || E && !ge(s).isValid || T && !ve(s).isValid)) {
|
|
203
|
+
let { value: e, message: t } = me(c) ? {
|
|
204
|
+
value: !!c,
|
|
205
|
+
message: c
|
|
206
|
+
} : G(c);
|
|
207
|
+
if (e && (C[h] = {
|
|
208
|
+
type: I.required,
|
|
209
|
+
message: t,
|
|
210
|
+
ref: y,
|
|
211
|
+
...O(I.required, t)
|
|
212
|
+
}, !r)) return x(t), C;
|
|
213
|
+
}
|
|
214
|
+
if (!D && (!S(d) || !S(f))) {
|
|
215
|
+
let e, t, n = G(f), i = G(d);
|
|
216
|
+
if (!S(v) && !isNaN(v)) {
|
|
217
|
+
let r = o.valueAsNumber || v && +v;
|
|
218
|
+
S(n.value) || (e = r > n.value), S(i.value) || (t = r < i.value);
|
|
219
|
+
} else {
|
|
220
|
+
let r = o.valueAsDate || new Date(v), a = (e) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + e), s = o.type == "time", c = o.type == "week";
|
|
221
|
+
B(n.value) && v && (e = s ? a(v) > a(n.value) : c ? v > n.value : r > new Date(n.value)), B(i.value) && v && (t = s ? a(v) < a(i.value) : c ? v < i.value : r < new Date(i.value));
|
|
222
|
+
}
|
|
223
|
+
if ((e || t) && (k(!!e, n.message, i.message, I.max, I.min), !r)) return x(C[h].message), C;
|
|
224
|
+
}
|
|
225
|
+
if ((l || u) && !D && (B(v) || a && Array.isArray(v))) {
|
|
226
|
+
let e = G(l), t = G(u), n = !S(e.value) && v.length > +e.value, i = !S(t.value) && v.length < +t.value;
|
|
227
|
+
if ((n || i) && (k(n, e.message, t.message), !r)) return x(C[h].message), C;
|
|
228
|
+
}
|
|
229
|
+
if (p && !D && B(v)) {
|
|
230
|
+
let { value: e, message: t } = G(p);
|
|
231
|
+
if (U(e) && !v.match(e) && (C[h] = {
|
|
232
|
+
type: I.pattern,
|
|
233
|
+
message: t,
|
|
234
|
+
ref: o,
|
|
235
|
+
...O(I.pattern, t)
|
|
236
|
+
}, !r)) return x(t), C;
|
|
237
|
+
}
|
|
238
|
+
if (m) {
|
|
239
|
+
if (V(m)) {
|
|
240
|
+
let e = ye(await m(v, n), y);
|
|
241
|
+
if (e && (C[h] = {
|
|
242
|
+
...e,
|
|
243
|
+
...O(I.validate, e.message)
|
|
244
|
+
}, !r)) return x(e.message), C;
|
|
245
|
+
} else if (w(m)) {
|
|
246
|
+
let e = {};
|
|
247
|
+
for (let t in m) {
|
|
248
|
+
if (!R(e) && !r) break;
|
|
249
|
+
let i = ye(await m[t](v, n), y, t);
|
|
250
|
+
i && (e = {
|
|
251
|
+
...i,
|
|
252
|
+
...O(t, i.message)
|
|
253
|
+
}, x(i.message), r && (C[h] = e));
|
|
254
|
+
}
|
|
255
|
+
if (!R(e) && (C[h] = {
|
|
256
|
+
ref: y,
|
|
257
|
+
...e
|
|
258
|
+
}, !r)) return C;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return x(!0), C;
|
|
262
|
+
};
|
|
263
|
+
function xe(e, t) {
|
|
264
|
+
let n = t.slice(0, -1).length, r = 0;
|
|
265
|
+
for (; r < n;) e = A(e) ? r++ : e[t[r++]];
|
|
266
|
+
return e;
|
|
267
|
+
}
|
|
268
|
+
function Se(e) {
|
|
269
|
+
for (let t in e) if (e.hasOwnProperty(t) && !A(e[t])) return !1;
|
|
270
|
+
return !0;
|
|
271
|
+
}
|
|
272
|
+
function K(e, t) {
|
|
273
|
+
let n = Array.isArray(t) ? t : ne(t) ? [t] : N(t), r = n.length === 1 ? e : xe(e, n), i = n.length - 1, a = n[i];
|
|
274
|
+
return r && delete r[a], i !== 0 && (w(r) && R(r) || Array.isArray(r) && Se(r)) && K(e, n.slice(0, -1)), e;
|
|
275
|
+
}
|
|
276
|
+
var Ce = () => {
|
|
277
|
+
let e = [];
|
|
278
|
+
return {
|
|
279
|
+
get observers() {
|
|
280
|
+
return e;
|
|
281
|
+
},
|
|
282
|
+
next: (t) => {
|
|
283
|
+
for (let n of e) n.next && n.next(t);
|
|
284
|
+
},
|
|
285
|
+
subscribe: (t) => (e.push(t), { unsubscribe: () => {
|
|
286
|
+
e = e.filter((e) => e !== t);
|
|
287
|
+
} }),
|
|
288
|
+
unsubscribe: () => {
|
|
289
|
+
e = [];
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}, we = (e) => S(e) || !C(e);
|
|
293
|
+
function q(e, t) {
|
|
294
|
+
if (we(e) || we(t)) return e === t;
|
|
295
|
+
if (x(e) && x(t)) return e.getTime() === t.getTime();
|
|
296
|
+
let n = Object.keys(e), r = Object.keys(t);
|
|
297
|
+
if (n.length !== r.length) return !1;
|
|
298
|
+
for (let i of n) {
|
|
299
|
+
let n = e[i];
|
|
300
|
+
if (!r.includes(i)) return !1;
|
|
301
|
+
if (i !== "ref") {
|
|
302
|
+
let e = t[i];
|
|
303
|
+
if (x(n) && x(e) || w(n) && w(e) || Array.isArray(n) && Array.isArray(e) ? !q(n, e) : n !== e) return !1;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return !0;
|
|
307
|
+
}
|
|
308
|
+
var Te = (e) => e.type === "select-multiple", Ee = (e) => H(e) || b(e), De = (e) => pe(e) && e.isConnected, Oe = (e) => {
|
|
309
|
+
for (let t in e) if (V(e[t])) return !0;
|
|
310
|
+
return !1;
|
|
311
|
+
};
|
|
312
|
+
function J(e, t = {}) {
|
|
313
|
+
let n = Array.isArray(e);
|
|
314
|
+
if (w(e) || n) for (let n in e) Array.isArray(e[n]) || w(e[n]) && !Oe(e[n]) ? (t[n] = Array.isArray(e[n]) ? [] : {}, J(e[n], t[n])) : S(e[n]) || (t[n] = !0);
|
|
315
|
+
return t;
|
|
316
|
+
}
|
|
317
|
+
function ke(e, t, n) {
|
|
318
|
+
let r = Array.isArray(e);
|
|
319
|
+
if (w(e) || r) for (let r in e) Array.isArray(e[r]) || w(e[r]) && !Oe(e[r]) ? A(t) || we(n[r]) ? n[r] = Array.isArray(e[r]) ? J(e[r], []) : { ...J(e[r]) } : ke(e[r], S(t) ? {} : t[r], n[r]) : n[r] = !q(e[r], t[r]);
|
|
320
|
+
return n;
|
|
321
|
+
}
|
|
322
|
+
var Ae = (e, t) => ke(e, t, J(t)), je = (e, { valueAsNumber: t, valueAsDate: n, setValueAs: r }) => A(e) ? e : t ? e === "" ? NaN : e && +e : n && B(e) ? new Date(e) : r ? r(e) : e;
|
|
323
|
+
function Me(e) {
|
|
324
|
+
let t = e.ref;
|
|
325
|
+
return fe(t) ? t.files : H(t) ? ve(e.refs).value : Te(t) ? [...t.selectedOptions].map(({ value: e }) => e) : b(t) ? ge(e.refs).value : je(A(t.value) ? e.ref.value : t.value, e);
|
|
326
|
+
}
|
|
327
|
+
var Ne = (e, t, n, r) => {
|
|
328
|
+
let i = {};
|
|
329
|
+
for (let n of e) {
|
|
330
|
+
let e = j(t, n);
|
|
331
|
+
e && P(i, n, e._f);
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
criteriaMode: n,
|
|
335
|
+
names: [...e],
|
|
336
|
+
fields: i,
|
|
337
|
+
shouldUseNativeValidation: r
|
|
338
|
+
};
|
|
339
|
+
}, Pe = (e) => A(e) ? e : U(e) ? e.source : w(e) ? U(e.value) ? e.value.source : e.value : e, Fe = "AsyncFunction", Ie = (e) => !!e && !!e.validate && !!(V(e.validate) && e.validate.constructor.name === Fe || w(e.validate) && Object.values(e.validate).find((e) => e.constructor.name === Fe)), Le = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate);
|
|
340
|
+
function Re(e, t, n) {
|
|
341
|
+
let r = j(e, n);
|
|
342
|
+
if (r || ne(n)) return {
|
|
343
|
+
error: r,
|
|
344
|
+
name: n
|
|
345
|
+
};
|
|
346
|
+
let i = n.split(".");
|
|
347
|
+
for (; i.length;) {
|
|
348
|
+
let r = i.join("."), a = j(t, r), o = j(e, r);
|
|
349
|
+
if (a && !Array.isArray(a) && n !== r) return { name: n };
|
|
350
|
+
if (o && o.type) return {
|
|
351
|
+
name: r,
|
|
352
|
+
error: o
|
|
353
|
+
};
|
|
354
|
+
i.pop();
|
|
355
|
+
}
|
|
356
|
+
return { name: n };
|
|
357
|
+
}
|
|
358
|
+
var ze = (e, t, n, r, i) => i.isOnAll ? !1 : !n && i.isOnTouch ? !(t || e) : (n ? r.isOnBlur : i.isOnBlur) ? !e : (n ? r.isOnChange : i.isOnChange) ? e : !0, Be = (e, t) => !te(j(e, t)).length && K(e, t), Ve = {
|
|
359
|
+
mode: F.onSubmit,
|
|
360
|
+
reValidateMode: F.onChange,
|
|
361
|
+
shouldFocusError: !0
|
|
362
|
+
};
|
|
363
|
+
function He(e = {}) {
|
|
364
|
+
let t = {
|
|
365
|
+
...Ve,
|
|
366
|
+
...e
|
|
367
|
+
}, n = {
|
|
368
|
+
submitCount: 0,
|
|
369
|
+
isDirty: !1,
|
|
370
|
+
isLoading: V(t.defaultValues),
|
|
371
|
+
isValidating: !1,
|
|
372
|
+
isSubmitted: !1,
|
|
373
|
+
isSubmitting: !1,
|
|
374
|
+
isSubmitSuccessful: !1,
|
|
375
|
+
isValid: !1,
|
|
376
|
+
touchedFields: {},
|
|
377
|
+
dirtyFields: {},
|
|
378
|
+
validatingFields: {},
|
|
379
|
+
errors: t.errors || {},
|
|
380
|
+
disabled: t.disabled || !1
|
|
381
|
+
}, r = {}, i = (w(t.defaultValues) || w(t.values)) && k(t.defaultValues || t.values) || {}, a = t.shouldUnregister ? {} : k(i), o = {
|
|
382
|
+
action: !1,
|
|
383
|
+
mount: !1,
|
|
384
|
+
watch: !1
|
|
385
|
+
}, s = {
|
|
386
|
+
mount: /* @__PURE__ */ new Set(),
|
|
387
|
+
disabled: /* @__PURE__ */ new Set(),
|
|
388
|
+
unMount: /* @__PURE__ */ new Set(),
|
|
389
|
+
array: /* @__PURE__ */ new Set(),
|
|
390
|
+
watch: /* @__PURE__ */ new Set()
|
|
391
|
+
}, c, l = 0, u = {
|
|
392
|
+
isDirty: !1,
|
|
393
|
+
dirtyFields: !1,
|
|
394
|
+
validatingFields: !1,
|
|
395
|
+
touchedFields: !1,
|
|
396
|
+
isValidating: !1,
|
|
397
|
+
isValid: !1,
|
|
398
|
+
errors: !1
|
|
399
|
+
}, d = {
|
|
400
|
+
values: Ce(),
|
|
401
|
+
array: Ce(),
|
|
402
|
+
state: Ce()
|
|
403
|
+
}, f = ce(t.mode), p = ce(t.reValidateMode), m = t.criteriaMode === F.all, h = (e) => (t) => {
|
|
404
|
+
clearTimeout(l), l = setTimeout(e, t);
|
|
405
|
+
}, g = async (e) => {
|
|
406
|
+
if (!t.disabled && (u.isValid || e)) {
|
|
407
|
+
let e = t.resolver ? R((await N()).errors) : await L(r, !0);
|
|
408
|
+
e !== n.isValid && d.state.next({ isValid: e });
|
|
409
|
+
}
|
|
410
|
+
}, _ = (e, r) => {
|
|
411
|
+
!t.disabled && (u.isValidating || u.validatingFields) && ((e || Array.from(s.mount)).forEach((e) => {
|
|
412
|
+
e && (r ? P(n.validatingFields, e, r) : K(n.validatingFields, e));
|
|
413
|
+
}), d.state.next({
|
|
414
|
+
validatingFields: n.validatingFields,
|
|
415
|
+
isValidating: !R(n.validatingFields)
|
|
416
|
+
}));
|
|
417
|
+
}, v = (e, s = [], c, l, f = !0, p = !0) => {
|
|
418
|
+
if (l && c && !t.disabled) {
|
|
419
|
+
if (o.action = !0, p && Array.isArray(j(r, e))) {
|
|
420
|
+
let t = c(j(r, e), l.argA, l.argB);
|
|
421
|
+
f && P(r, e, t);
|
|
422
|
+
}
|
|
423
|
+
if (p && Array.isArray(j(n.errors, e))) {
|
|
424
|
+
let t = c(j(n.errors, e), l.argA, l.argB);
|
|
425
|
+
f && P(n.errors, e, t), Be(n.errors, e);
|
|
426
|
+
}
|
|
427
|
+
if (u.touchedFields && p && Array.isArray(j(n.touchedFields, e))) {
|
|
428
|
+
let t = c(j(n.touchedFields, e), l.argA, l.argB);
|
|
429
|
+
f && P(n.touchedFields, e, t);
|
|
430
|
+
}
|
|
431
|
+
u.dirtyFields && (n.dirtyFields = Ae(i, a)), d.state.next({
|
|
432
|
+
name: e,
|
|
433
|
+
isDirty: z(e, s),
|
|
434
|
+
dirtyFields: n.dirtyFields,
|
|
435
|
+
errors: n.errors,
|
|
436
|
+
isValid: n.isValid
|
|
437
|
+
});
|
|
438
|
+
} else P(a, e, s);
|
|
439
|
+
}, y = (e, t) => {
|
|
440
|
+
P(n.errors, e, t), d.state.next({ errors: n.errors });
|
|
441
|
+
}, C = (e) => {
|
|
442
|
+
n.errors = e, d.state.next({
|
|
443
|
+
errors: n.errors,
|
|
444
|
+
isValid: !1
|
|
445
|
+
});
|
|
446
|
+
}, E = (e, t, n, s) => {
|
|
447
|
+
let c = j(r, e);
|
|
448
|
+
if (c) {
|
|
449
|
+
let r = j(a, e, A(n) ? j(i, e) : n);
|
|
450
|
+
A(r) || s && s.defaultChecked || t ? P(a, e, t ? r : Me(c._f)) : H(e, r), o.mount && g();
|
|
451
|
+
}
|
|
452
|
+
}, D = (e, a, o, s, c) => {
|
|
453
|
+
let l = !1, f = !1, p = { name: e };
|
|
454
|
+
if (!t.disabled) {
|
|
455
|
+
let t = !!(j(r, e) && j(r, e)._f && j(r, e)._f.disabled);
|
|
456
|
+
if (!o || s) {
|
|
457
|
+
u.isDirty && (f = n.isDirty, n.isDirty = p.isDirty = z(), l = f !== p.isDirty);
|
|
458
|
+
let r = t || q(j(i, e), a);
|
|
459
|
+
f = !!(!t && j(n.dirtyFields, e)), r || t ? K(n.dirtyFields, e) : P(n.dirtyFields, e, !0), p.dirtyFields = n.dirtyFields, l ||= u.dirtyFields && f !== !r;
|
|
460
|
+
}
|
|
461
|
+
if (o) {
|
|
462
|
+
let t = j(n.touchedFields, e);
|
|
463
|
+
t || (P(n.touchedFields, e, o), p.touchedFields = n.touchedFields, l ||= u.touchedFields && t !== o);
|
|
464
|
+
}
|
|
465
|
+
l && c && d.state.next(p);
|
|
466
|
+
}
|
|
467
|
+
return l ? p : {};
|
|
468
|
+
}, ne = (e, r, i, a) => {
|
|
469
|
+
let o = j(n.errors, e), s = u.isValid && M(r) && n.isValid !== r;
|
|
470
|
+
if (t.delayError && i ? (c = h(() => y(e, i)), c(t.delayError)) : (clearTimeout(l), c = null, i ? P(n.errors, e, i) : K(n.errors, e)), (i ? !q(o, i) : o) || !R(a) || s) {
|
|
471
|
+
let t = {
|
|
472
|
+
...a,
|
|
473
|
+
...s && M(r) ? { isValid: r } : {},
|
|
474
|
+
errors: n.errors,
|
|
475
|
+
name: e
|
|
476
|
+
};
|
|
477
|
+
n = {
|
|
478
|
+
...n,
|
|
479
|
+
...t
|
|
480
|
+
}, d.state.next(t);
|
|
481
|
+
}
|
|
482
|
+
}, N = async (e) => {
|
|
483
|
+
_(e, !0);
|
|
484
|
+
let n = await t.resolver(a, t.context, Ne(e || s.mount, r, t.criteriaMode, t.shouldUseNativeValidation));
|
|
485
|
+
return _(e), n;
|
|
486
|
+
}, I = async (e) => {
|
|
487
|
+
let { errors: t } = await N(e);
|
|
488
|
+
if (e) for (let r of e) {
|
|
489
|
+
let e = j(t, r);
|
|
490
|
+
e ? P(n.errors, r, e) : K(n.errors, r);
|
|
491
|
+
}
|
|
492
|
+
else n.errors = t;
|
|
493
|
+
return t;
|
|
494
|
+
}, L = async (e, r, i = { valid: !0 }) => {
|
|
495
|
+
for (let o in e) {
|
|
496
|
+
let c = e[o];
|
|
497
|
+
if (c) {
|
|
498
|
+
let { _f: e, ...l } = c;
|
|
499
|
+
if (e) {
|
|
500
|
+
let l = s.array.has(e.name), d = c._f && Ie(c._f);
|
|
501
|
+
d && u.validatingFields && _([o], !0);
|
|
502
|
+
let f = await be(c, s.disabled, a, m, t.shouldUseNativeValidation && !r, l);
|
|
503
|
+
if (d && u.validatingFields && _([o]), f[e.name] && (i.valid = !1, r)) break;
|
|
504
|
+
!r && (j(f, e.name) ? l ? de(n.errors, f, e.name) : P(n.errors, e.name, f[e.name]) : K(n.errors, e.name));
|
|
505
|
+
}
|
|
506
|
+
!R(l) && await L(l, r, i);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return i.valid;
|
|
510
|
+
}, ie = () => {
|
|
511
|
+
for (let e of s.unMount) {
|
|
512
|
+
let t = j(r, e);
|
|
513
|
+
t && (t._f.refs ? t._f.refs.every((e) => !De(e)) : !De(t._f.ref)) && we(e);
|
|
514
|
+
}
|
|
515
|
+
s.unMount = /* @__PURE__ */ new Set();
|
|
516
|
+
}, z = (e, n) => !t.disabled && (e && n && P(a, e, n), !q(ve(), i)), se = (e, t, n) => oe(e, s, { ...o.mount ? a : A(t) ? i : B(e) ? { [e]: t } : t }, n, t), me = (e) => te(j(o.mount ? a : i, e, t.shouldUnregister ? j(i, e, []) : [])), H = (e, t, n = {}) => {
|
|
517
|
+
let i = j(r, e), o = t;
|
|
518
|
+
if (i) {
|
|
519
|
+
let n = i._f;
|
|
520
|
+
n && (!n.disabled && P(a, e, je(t, n)), o = pe(n.ref) && S(t) ? "" : t, Te(n.ref) ? [...n.ref.options].forEach((e) => e.selected = o.includes(e.value)) : n.refs ? b(n.ref) ? n.refs.length > 1 ? n.refs.forEach((e) => (!e.defaultChecked || !e.disabled) && (e.checked = Array.isArray(o) ? !!o.find((t) => t === e.value) : o === e.value)) : n.refs[0] && (n.refs[0].checked = !!o) : n.refs.forEach((e) => e.checked = e.value === o) : fe(n.ref) ? n.ref.value = "" : (n.ref.value = o, n.ref.type || d.values.next({
|
|
521
|
+
name: e,
|
|
522
|
+
values: { ...a }
|
|
523
|
+
})));
|
|
524
|
+
}
|
|
525
|
+
(n.shouldDirty || n.shouldTouch) && D(e, o, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate && _e(e);
|
|
526
|
+
}, U = (e, t, n) => {
|
|
527
|
+
for (let i in t) {
|
|
528
|
+
let a = t[i], o = `${e}.${i}`, c = j(r, o);
|
|
529
|
+
(s.array.has(e) || w(a) || c && !c._f) && !x(a) ? U(o, a, n) : H(o, a, n);
|
|
530
|
+
}
|
|
531
|
+
}, W = (e, t, c = {}) => {
|
|
532
|
+
let l = j(r, e), f = s.array.has(e), p = k(t);
|
|
533
|
+
P(a, e, p), f ? (d.array.next({
|
|
534
|
+
name: e,
|
|
535
|
+
values: { ...a }
|
|
536
|
+
}), (u.isDirty || u.dirtyFields) && c.shouldDirty && d.state.next({
|
|
537
|
+
name: e,
|
|
538
|
+
dirtyFields: Ae(i, a),
|
|
539
|
+
isDirty: z(e, p)
|
|
540
|
+
})) : l && !l._f && !S(p) ? U(e, p, c) : H(e, p, c), le(e, s) && d.state.next({ ...n }), d.values.next({
|
|
541
|
+
name: o.mount ? e : void 0,
|
|
542
|
+
values: { ...a }
|
|
543
|
+
});
|
|
544
|
+
}, he = async (e) => {
|
|
545
|
+
o.mount = !0;
|
|
546
|
+
let i = e.target, l = i.name, h = !0, v = j(r, l), y = () => i.type ? Me(v._f) : T(e), b = (e) => {
|
|
547
|
+
h = Number.isNaN(e) || x(e) && isNaN(e.getTime()) || q(e, j(a, l, e));
|
|
548
|
+
};
|
|
549
|
+
if (v) {
|
|
550
|
+
let i, o, x = y(), S = e.type === re.BLUR || e.type === re.FOCUS_OUT, C = !Le(v._f) && !t.resolver && !j(n.errors, l) && !v._f.deps || ze(S, j(n.touchedFields, l), n.isSubmitted, p, f), w = le(l, s, S);
|
|
551
|
+
P(a, l, x), S ? (v._f.onBlur && v._f.onBlur(e), c && c(0)) : v._f.onChange && v._f.onChange(e);
|
|
552
|
+
let T = D(l, x, S, !1), E = !R(T) || w;
|
|
553
|
+
if (!S && d.values.next({
|
|
554
|
+
name: l,
|
|
555
|
+
type: e.type,
|
|
556
|
+
values: { ...a }
|
|
557
|
+
}), C) return u.isValid && (t.mode === "onBlur" && S ? g() : S || g()), E && d.state.next({
|
|
558
|
+
name: l,
|
|
559
|
+
...w ? {} : T
|
|
560
|
+
});
|
|
561
|
+
if (!S && w && d.state.next({ ...n }), t.resolver) {
|
|
562
|
+
let { errors: e } = await N([l]);
|
|
563
|
+
if (b(x), h) {
|
|
564
|
+
let t = Re(n.errors, r, l), a = Re(e, r, t.name || l);
|
|
565
|
+
i = a.error, l = a.name, o = R(e);
|
|
566
|
+
}
|
|
567
|
+
} else _([l], !0), i = (await be(v, s.disabled, a, m, t.shouldUseNativeValidation))[l], _([l]), b(x), h && (i ? o = !1 : u.isValid && (o = await L(r, !0)));
|
|
568
|
+
h && (v._f.deps && _e(v._f.deps), ne(l, o, i, T));
|
|
569
|
+
}
|
|
570
|
+
}, ge = (e, t) => {
|
|
571
|
+
if (j(n.errors, t) && e.focus) return e.focus(), 1;
|
|
572
|
+
}, _e = async (e, i = {}) => {
|
|
573
|
+
let a, o, c = ae(e);
|
|
574
|
+
if (t.resolver) {
|
|
575
|
+
let t = await I(A(e) ? e : c);
|
|
576
|
+
a = R(t), o = e ? !c.some((e) => j(t, e)) : a;
|
|
577
|
+
} else e ? (o = (await Promise.all(c.map(async (e) => {
|
|
578
|
+
let t = j(r, e);
|
|
579
|
+
return await L(t && t._f ? { [e]: t } : t);
|
|
580
|
+
}))).every(Boolean), !(!o && !n.isValid) && g()) : o = a = await L(r);
|
|
581
|
+
return d.state.next({
|
|
582
|
+
...!B(e) || u.isValid && a !== n.isValid ? {} : { name: e },
|
|
583
|
+
...t.resolver || !e ? { isValid: a } : {},
|
|
584
|
+
errors: n.errors
|
|
585
|
+
}), i.shouldFocus && !o && ue(r, ge, e ? c : s.mount), o;
|
|
586
|
+
}, ve = (e) => {
|
|
587
|
+
let t = { ...o.mount ? a : i };
|
|
588
|
+
return A(e) ? t : B(e) ? j(t, e) : e.map((e) => j(t, e));
|
|
589
|
+
}, ye = (e, t) => ({
|
|
590
|
+
invalid: !!j((t || n).errors, e),
|
|
591
|
+
isDirty: !!j((t || n).dirtyFields, e),
|
|
592
|
+
error: j((t || n).errors, e),
|
|
593
|
+
isValidating: !!j(n.validatingFields, e),
|
|
594
|
+
isTouched: !!j((t || n).touchedFields, e)
|
|
595
|
+
}), G = (e) => {
|
|
596
|
+
e && ae(e).forEach((e) => K(n.errors, e)), d.state.next({ errors: e ? n.errors : {} });
|
|
597
|
+
}, xe = (e, t, i) => {
|
|
598
|
+
let a = (j(r, e, { _f: {} })._f || {}).ref, { ref: o, message: s, type: c, ...l } = j(n.errors, e) || {};
|
|
599
|
+
P(n.errors, e, {
|
|
600
|
+
...l,
|
|
601
|
+
...t,
|
|
602
|
+
ref: a
|
|
603
|
+
}), d.state.next({
|
|
604
|
+
name: e,
|
|
605
|
+
errors: n.errors,
|
|
606
|
+
isValid: !1
|
|
607
|
+
}), i && i.shouldFocus && a && a.focus && a.focus();
|
|
608
|
+
}, Se = (e, t) => V(e) ? d.values.subscribe({ next: (n) => e(se(void 0, t), n) }) : se(e, t, !0), we = (e, o = {}) => {
|
|
609
|
+
for (let c of e ? ae(e) : s.mount) s.mount.delete(c), s.array.delete(c), o.keepValue || (K(r, c), K(a, c)), !o.keepError && K(n.errors, c), !o.keepDirty && K(n.dirtyFields, c), !o.keepTouched && K(n.touchedFields, c), !o.keepIsValidating && K(n.validatingFields, c), !t.shouldUnregister && !o.keepDefaultValue && K(i, c);
|
|
610
|
+
d.values.next({ values: { ...a } }), d.state.next({
|
|
611
|
+
...n,
|
|
612
|
+
...o.keepDirty ? { isDirty: z() } : {}
|
|
613
|
+
}), !o.keepIsValid && g();
|
|
614
|
+
}, Oe = ({ disabled: e, name: t, field: n, fields: r }) => {
|
|
615
|
+
(M(e) && o.mount || e || s.disabled.has(t)) && (e ? s.disabled.add(t) : s.disabled.delete(t), D(t, Me(n ? n._f : j(r, t)._f), !1, !1, !0));
|
|
616
|
+
}, J = (e, n = {}) => {
|
|
617
|
+
let a = j(r, e), c = M(n.disabled) || M(t.disabled);
|
|
618
|
+
return P(r, e, {
|
|
619
|
+
...a || {},
|
|
620
|
+
_f: {
|
|
621
|
+
...a && a._f ? a._f : { ref: { name: e } },
|
|
622
|
+
name: e,
|
|
623
|
+
mount: !0,
|
|
624
|
+
...n
|
|
625
|
+
}
|
|
626
|
+
}), s.mount.add(e), a ? Oe({
|
|
627
|
+
field: a,
|
|
628
|
+
disabled: M(n.disabled) ? n.disabled : t.disabled,
|
|
629
|
+
name: e
|
|
630
|
+
}) : E(e, !0, n.value), {
|
|
631
|
+
...c ? { disabled: n.disabled || t.disabled } : {},
|
|
632
|
+
...t.progressive ? {
|
|
633
|
+
required: !!n.required,
|
|
634
|
+
min: Pe(n.min),
|
|
635
|
+
max: Pe(n.max),
|
|
636
|
+
minLength: Pe(n.minLength),
|
|
637
|
+
maxLength: Pe(n.maxLength),
|
|
638
|
+
pattern: Pe(n.pattern)
|
|
639
|
+
} : {},
|
|
640
|
+
name: e,
|
|
641
|
+
onChange: he,
|
|
642
|
+
onBlur: he,
|
|
643
|
+
ref: (c) => {
|
|
644
|
+
if (c) {
|
|
645
|
+
J(e, n), a = j(r, e);
|
|
646
|
+
let t = A(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, o = Ee(t), s = a._f.refs || [];
|
|
647
|
+
if (o ? s.find((e) => e === t) : t === a._f.ref) return;
|
|
648
|
+
P(r, e, { _f: {
|
|
649
|
+
...a._f,
|
|
650
|
+
...o ? {
|
|
651
|
+
refs: [
|
|
652
|
+
...s.filter(De),
|
|
653
|
+
t,
|
|
654
|
+
...Array.isArray(j(i, e)) ? [{}] : []
|
|
655
|
+
],
|
|
656
|
+
ref: {
|
|
657
|
+
type: t.type,
|
|
658
|
+
name: e
|
|
659
|
+
}
|
|
660
|
+
} : { ref: t }
|
|
661
|
+
} }), E(e, !1, void 0, t);
|
|
662
|
+
} else a = j(r, e, {}), a._f && (a._f.mount = !1), (t.shouldUnregister || n.shouldUnregister) && !(ee(s.array, e) && o.action) && s.unMount.add(e);
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
}, ke = () => t.shouldFocusError && ue(r, ge, s.mount), Fe = (e) => {
|
|
666
|
+
M(e) && (d.state.next({ disabled: e }), ue(r, (t, n) => {
|
|
667
|
+
let i = j(r, n);
|
|
668
|
+
i && (t.disabled = i._f.disabled || e, Array.isArray(i._f.refs) && i._f.refs.forEach((t) => {
|
|
669
|
+
t.disabled = i._f.disabled || e;
|
|
670
|
+
}));
|
|
671
|
+
}, 0, !1));
|
|
672
|
+
}, He = (e, i) => async (o) => {
|
|
673
|
+
let c;
|
|
674
|
+
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
675
|
+
let l = k(a);
|
|
676
|
+
if (s.disabled.size) for (let e of s.disabled) P(l, e, void 0);
|
|
677
|
+
if (d.state.next({ isSubmitting: !0 }), t.resolver) {
|
|
678
|
+
let { errors: e, values: t } = await N();
|
|
679
|
+
n.errors = e, l = t;
|
|
680
|
+
} else await L(r);
|
|
681
|
+
if (K(n.errors, "root"), R(n.errors)) {
|
|
682
|
+
d.state.next({ errors: {} });
|
|
683
|
+
try {
|
|
684
|
+
await e(l, o);
|
|
685
|
+
} catch (e) {
|
|
686
|
+
c = e;
|
|
687
|
+
}
|
|
688
|
+
} else i && await i({ ...n.errors }, o), ke(), setTimeout(ke);
|
|
689
|
+
if (d.state.next({
|
|
690
|
+
isSubmitted: !0,
|
|
691
|
+
isSubmitting: !1,
|
|
692
|
+
isSubmitSuccessful: R(n.errors) && !c,
|
|
693
|
+
submitCount: n.submitCount + 1,
|
|
694
|
+
errors: n.errors
|
|
695
|
+
}), c) throw c;
|
|
696
|
+
}, Ue = (e, t = {}) => {
|
|
697
|
+
j(r, e) && (A(t.defaultValue) ? W(e, k(j(i, e))) : (W(e, t.defaultValue), P(i, e, k(t.defaultValue))), t.keepTouched || K(n.touchedFields, e), t.keepDirty || (K(n.dirtyFields, e), n.isDirty = t.defaultValue ? z(e, k(j(i, e))) : z()), t.keepError || (K(n.errors, e), u.isValid && g()), d.state.next({ ...n }));
|
|
698
|
+
}, We = (e, c = {}) => {
|
|
699
|
+
let l = e ? k(e) : i, f = k(l), p = R(e), m = p ? i : f;
|
|
700
|
+
if (c.keepDefaultValues || (i = l), !c.keepValues) {
|
|
701
|
+
if (c.keepDirtyValues) {
|
|
702
|
+
let e = new Set([...s.mount, ...Object.keys(Ae(i, a))]);
|
|
703
|
+
for (let t of Array.from(e)) j(n.dirtyFields, t) ? P(m, t, j(a, t)) : W(t, j(m, t));
|
|
704
|
+
} else {
|
|
705
|
+
if (O && A(e)) for (let e of s.mount) {
|
|
706
|
+
let t = j(r, e);
|
|
707
|
+
if (t && t._f) {
|
|
708
|
+
let e = Array.isArray(t._f.refs) ? t._f.refs[0] : t._f.ref;
|
|
709
|
+
if (pe(e)) {
|
|
710
|
+
let t = e.closest("form");
|
|
711
|
+
if (t) {
|
|
712
|
+
t.reset();
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
r = {};
|
|
719
|
+
}
|
|
720
|
+
a = t.shouldUnregister ? c.keepDefaultValues ? k(i) : {} : k(m), d.array.next({ values: { ...m } }), d.values.next({ values: { ...m } });
|
|
721
|
+
}
|
|
722
|
+
s = {
|
|
723
|
+
mount: c.keepDirtyValues ? s.mount : /* @__PURE__ */ new Set(),
|
|
724
|
+
unMount: /* @__PURE__ */ new Set(),
|
|
725
|
+
array: /* @__PURE__ */ new Set(),
|
|
726
|
+
disabled: /* @__PURE__ */ new Set(),
|
|
727
|
+
watch: /* @__PURE__ */ new Set(),
|
|
728
|
+
watchAll: !1,
|
|
729
|
+
focus: ""
|
|
730
|
+
}, o.mount = !u.isValid || !!c.keepIsValid || !!c.keepDirtyValues, o.watch = !!t.shouldUnregister, d.state.next({
|
|
731
|
+
submitCount: c.keepSubmitCount ? n.submitCount : 0,
|
|
732
|
+
isDirty: p ? !1 : c.keepDirty ? n.isDirty : !!(c.keepDefaultValues && !q(e, i)),
|
|
733
|
+
isSubmitted: c.keepIsSubmitted ? n.isSubmitted : !1,
|
|
734
|
+
dirtyFields: p ? {} : c.keepDirtyValues ? c.keepDefaultValues && a ? Ae(i, a) : n.dirtyFields : c.keepDefaultValues && e ? Ae(i, e) : c.keepDirty ? n.dirtyFields : {},
|
|
735
|
+
touchedFields: c.keepTouched ? n.touchedFields : {},
|
|
736
|
+
errors: c.keepErrors ? n.errors : {},
|
|
737
|
+
isSubmitSuccessful: c.keepIsSubmitSuccessful ? n.isSubmitSuccessful : !1,
|
|
738
|
+
isSubmitting: !1
|
|
739
|
+
});
|
|
740
|
+
}, Y = (e, t) => We(V(e) ? e(a) : e, t);
|
|
741
|
+
return {
|
|
742
|
+
control: {
|
|
743
|
+
register: J,
|
|
744
|
+
unregister: we,
|
|
745
|
+
getFieldState: ye,
|
|
746
|
+
handleSubmit: He,
|
|
747
|
+
setError: xe,
|
|
748
|
+
_executeSchema: N,
|
|
749
|
+
_getWatch: se,
|
|
750
|
+
_getDirty: z,
|
|
751
|
+
_updateValid: g,
|
|
752
|
+
_removeUnmounted: ie,
|
|
753
|
+
_updateFieldArray: v,
|
|
754
|
+
_updateDisabledField: Oe,
|
|
755
|
+
_getFieldArray: me,
|
|
756
|
+
_reset: We,
|
|
757
|
+
_resetDefaultValues: () => V(t.defaultValues) && t.defaultValues().then((e) => {
|
|
758
|
+
Y(e, t.resetOptions), d.state.next({ isLoading: !1 });
|
|
759
|
+
}),
|
|
760
|
+
_updateFormState: (e) => {
|
|
761
|
+
n = {
|
|
762
|
+
...n,
|
|
763
|
+
...e
|
|
764
|
+
};
|
|
765
|
+
},
|
|
766
|
+
_disableForm: Fe,
|
|
767
|
+
_subjects: d,
|
|
768
|
+
_proxyFormState: u,
|
|
769
|
+
_setErrors: C,
|
|
770
|
+
get _fields() {
|
|
771
|
+
return r;
|
|
772
|
+
},
|
|
773
|
+
get _formValues() {
|
|
774
|
+
return a;
|
|
775
|
+
},
|
|
776
|
+
get _state() {
|
|
777
|
+
return o;
|
|
778
|
+
},
|
|
779
|
+
set _state(e) {
|
|
780
|
+
o = e;
|
|
781
|
+
},
|
|
782
|
+
get _defaultValues() {
|
|
783
|
+
return i;
|
|
784
|
+
},
|
|
785
|
+
get _names() {
|
|
786
|
+
return s;
|
|
787
|
+
},
|
|
788
|
+
set _names(e) {
|
|
789
|
+
s = e;
|
|
790
|
+
},
|
|
791
|
+
get _formState() {
|
|
792
|
+
return n;
|
|
793
|
+
},
|
|
794
|
+
set _formState(e) {
|
|
795
|
+
n = e;
|
|
796
|
+
},
|
|
797
|
+
get _options() {
|
|
798
|
+
return t;
|
|
799
|
+
},
|
|
800
|
+
set _options(e) {
|
|
801
|
+
t = {
|
|
802
|
+
...t,
|
|
803
|
+
...e
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
trigger: _e,
|
|
808
|
+
register: J,
|
|
809
|
+
handleSubmit: He,
|
|
810
|
+
watch: Se,
|
|
811
|
+
setValue: W,
|
|
812
|
+
getValues: ve,
|
|
813
|
+
reset: Y,
|
|
814
|
+
resetField: Ue,
|
|
815
|
+
clearErrors: G,
|
|
816
|
+
unregister: we,
|
|
817
|
+
setError: xe,
|
|
818
|
+
setFocus: (e, t = {}) => {
|
|
819
|
+
let n = j(r, e), i = n && n._f;
|
|
820
|
+
if (i) {
|
|
821
|
+
let e = i.refs ? i.refs[0] : i.ref;
|
|
822
|
+
e.focus && (e.focus(), t.shouldSelect && V(e.select) && e.select());
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
getFieldState: ye
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function Ue(e = {}) {
|
|
829
|
+
let t = r.useRef(void 0), n = r.useRef(void 0), [i, a] = r.useState({
|
|
830
|
+
isDirty: !1,
|
|
831
|
+
isValidating: !1,
|
|
832
|
+
isLoading: V(e.defaultValues),
|
|
833
|
+
isSubmitted: !1,
|
|
834
|
+
isSubmitting: !1,
|
|
835
|
+
isSubmitSuccessful: !1,
|
|
836
|
+
isValid: !1,
|
|
837
|
+
submitCount: 0,
|
|
838
|
+
dirtyFields: {},
|
|
839
|
+
touchedFields: {},
|
|
840
|
+
validatingFields: {},
|
|
841
|
+
errors: e.errors || {},
|
|
842
|
+
disabled: e.disabled || !1,
|
|
843
|
+
defaultValues: V(e.defaultValues) ? void 0 : e.defaultValues
|
|
844
|
+
});
|
|
845
|
+
t.current ||= {
|
|
846
|
+
...He(e),
|
|
847
|
+
formState: i
|
|
848
|
+
};
|
|
849
|
+
let o = t.current.control;
|
|
850
|
+
return o._options = e, z({
|
|
851
|
+
subject: o._subjects.state,
|
|
852
|
+
next: (e) => {
|
|
853
|
+
ie(e, o._proxyFormState, o._updateFormState, !0) && a({ ...o._formState });
|
|
854
|
+
}
|
|
855
|
+
}), r.useEffect(() => o._disableForm(e.disabled), [o, e.disabled]), r.useEffect(() => {
|
|
856
|
+
if (o._proxyFormState.isDirty) {
|
|
857
|
+
let e = o._getDirty();
|
|
858
|
+
e !== i.isDirty && o._subjects.state.next({ isDirty: e });
|
|
859
|
+
}
|
|
860
|
+
}, [o, i.isDirty]), r.useEffect(() => {
|
|
861
|
+
e.values && !q(e.values, n.current) ? (o._reset(e.values, o._options.resetOptions), n.current = e.values, a((e) => ({ ...e }))) : o._resetDefaultValues();
|
|
862
|
+
}, [e.values, o]), r.useEffect(() => {
|
|
863
|
+
e.errors && o._setErrors(e.errors);
|
|
864
|
+
}, [e.errors, o]), r.useEffect(() => {
|
|
865
|
+
o._state.mount || (o._updateValid(), o._state.mount = !0), o._state.watch && (o._state.watch = !1, o._subjects.state.next({ ...o._formState })), o._removeUnmounted();
|
|
866
|
+
}), r.useEffect(() => {
|
|
867
|
+
e.shouldUnregister && o._subjects.values.next({ values: o._getWatch() });
|
|
868
|
+
}, [e.shouldUnregister, o]), t.current.formState = L(i, o), t.current;
|
|
869
|
+
}
|
|
870
|
+
//#endregion
|
|
871
|
+
//#region src/Form/useForm.tsx
|
|
872
|
+
var We = () => {
|
|
873
|
+
let [n, r] = p(), i = Ue({ reValidateMode: "onChange" }), a = (e, t) => {
|
|
874
|
+
let n = i.register(e, t), a = (t) => (r(null), i.clearErrors(e), n.onChange(t)), o = i?.formState.errors, s = i.watch(e);
|
|
875
|
+
return {
|
|
876
|
+
...n,
|
|
877
|
+
onChange: a,
|
|
878
|
+
formvalue: s,
|
|
879
|
+
error: o?.[e]?.message?.toString()
|
|
880
|
+
};
|
|
881
|
+
}, o = (e) => {
|
|
882
|
+
e.errors ? Object.keys(e.errors).forEach((t) => i.setError(t, { message: e.errors?.[t]?.[0] })) : r(e);
|
|
883
|
+
}, s = () => /* @__PURE__ */ t(e, { children: n && !n.errors && /* @__PURE__ */ t("div", {
|
|
884
|
+
className: m["global-error"],
|
|
885
|
+
children: n.message
|
|
886
|
+
}) });
|
|
887
|
+
return {
|
|
888
|
+
...i,
|
|
889
|
+
register: a,
|
|
890
|
+
GlobalError: s,
|
|
891
|
+
setErrors: o
|
|
892
|
+
};
|
|
893
|
+
}, Y = {
|
|
894
|
+
container: "style-module__container__JyG0-",
|
|
895
|
+
"loading-container": "style-module__loading-container__sphNQ",
|
|
896
|
+
hidden: "style-module__hidden__jvJWI",
|
|
897
|
+
element: "style-module__element__Ex50N",
|
|
898
|
+
disabled: "style-module__disabled__p40Jo",
|
|
899
|
+
placeholder: "style-module__placeholder__c-V0V",
|
|
900
|
+
error: "style-module__error__pSghy"
|
|
901
|
+
}, Ge = {
|
|
902
|
+
loading: "style-module__loading__r9fwC",
|
|
903
|
+
dot: "style-module__dot__mMqu2",
|
|
904
|
+
bounce: "style-module__bounce__ikJLW",
|
|
905
|
+
light: "style-module__light__Kubs1",
|
|
906
|
+
secondary: "style-module__secondary__EkNcU",
|
|
907
|
+
"secondary-light": "style-module__secondary-light__cJeWY"
|
|
908
|
+
}, Ke = ({ color: e = "primary", ...r }) => {
|
|
909
|
+
let i = ["ui-loading"];
|
|
910
|
+
return i.push(Ge.loading), e && i.push(Ge[e], "ui-loading-" + e), /* @__PURE__ */ n("div", {
|
|
911
|
+
...r,
|
|
912
|
+
className: i.join(" "),
|
|
913
|
+
children: [
|
|
914
|
+
/* @__PURE__ */ t("div", { className: Ge.dot }),
|
|
915
|
+
/* @__PURE__ */ t("div", { className: Ge.dot }),
|
|
916
|
+
/* @__PURE__ */ t("div", { className: Ge.dot }),
|
|
917
|
+
/* @__PURE__ */ t("div", { className: Ge.dot })
|
|
918
|
+
]
|
|
919
|
+
});
|
|
920
|
+
}, X = ({ children: r, beforeElement: a, afterElement: o, error: s, placeholder: c, styleContainer: u, classNameContainer: d, hiddenContainer: f, formvalue: m, wait: h, ...g }) => {
|
|
921
|
+
let [_, v] = p("");
|
|
922
|
+
l(() => {
|
|
923
|
+
v(s ?? "");
|
|
924
|
+
}, [s]);
|
|
925
|
+
let y = ["ui-form-element-container"];
|
|
926
|
+
return y.push(Y.container), _ && y.push(Y.error), g.disabled && y.push(Y.disabled), f && y.push(Y.hidden), d && y.push(d), /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ n("label", {
|
|
927
|
+
className: y.join(" "),
|
|
928
|
+
style: u,
|
|
929
|
+
children: [
|
|
930
|
+
a ? i(a, { key: "ui-before-element" }) : null,
|
|
931
|
+
/* @__PURE__ */ n("div", {
|
|
932
|
+
className: "ui-form-element " + Y.element,
|
|
933
|
+
children: [
|
|
934
|
+
typeof r == "function" ? r(g) : null,
|
|
935
|
+
c && h ? "" : /* @__PURE__ */ t("span", {
|
|
936
|
+
className: "ui-form-element-placeholder " + Y.placeholder,
|
|
937
|
+
children: c
|
|
938
|
+
}),
|
|
939
|
+
h && /* @__PURE__ */ t(Ke, {})
|
|
940
|
+
]
|
|
941
|
+
}),
|
|
942
|
+
o ? i(o, { key: "ui-after-element" }) : null
|
|
943
|
+
]
|
|
944
|
+
}), _ && /* @__PURE__ */ t("div", {
|
|
945
|
+
className: "ui-form-error " + Y.error,
|
|
946
|
+
children: _
|
|
947
|
+
})] });
|
|
948
|
+
}, qe = y, Je = o(({ onChange: e, onInput: n, onChangeText: r, wait: i, disabled: a, formvalue: o, children: s, ...c }, u) => {
|
|
949
|
+
let [d, f] = p(""), m = (t) => {
|
|
950
|
+
typeof e == "function" && e(t), typeof r == "function" && r(t.target.value);
|
|
951
|
+
}, h = (e) => {
|
|
952
|
+
a || i || (typeof n == "function" && n(e), f(e.target.value));
|
|
953
|
+
};
|
|
954
|
+
return l(() => {
|
|
955
|
+
let e = c.value ?? o;
|
|
956
|
+
f(e ? String(e) : "");
|
|
957
|
+
}, [c.value, o]), /* @__PURE__ */ t(X, {
|
|
958
|
+
...c,
|
|
959
|
+
wait: i,
|
|
960
|
+
children: (e) => /* @__PURE__ */ t("input", {
|
|
961
|
+
...e,
|
|
962
|
+
placeholder: "",
|
|
963
|
+
onChange: m,
|
|
964
|
+
disabled: a || i,
|
|
965
|
+
value: i ? "" : d,
|
|
966
|
+
onInput: h,
|
|
967
|
+
ref: u
|
|
968
|
+
})
|
|
969
|
+
});
|
|
970
|
+
}), Ye = o(({ onChange: e, onInput: n, onChangeText: r, formvalue: i, wait: a, ...o }, s) => {
|
|
971
|
+
let c = f(null), [d, m] = p(o.value ?? i ?? ""), h = (t) => {
|
|
972
|
+
typeof e == "function" && e(t), typeof r == "function" && r(t.target.value);
|
|
973
|
+
}, g = (e) => {
|
|
974
|
+
typeof n == "function" && n(e), m(e.target.value);
|
|
975
|
+
};
|
|
976
|
+
l(() => {
|
|
977
|
+
let e = c.current;
|
|
978
|
+
if (!e) return;
|
|
979
|
+
let t = e.offsetHeight;
|
|
980
|
+
e.style.height = "auto";
|
|
981
|
+
let n = e.scrollHeight, r = Math.max(n, 50);
|
|
982
|
+
e.style.height = `${Math.max(r, t)}px`;
|
|
983
|
+
}, [d]), l(() => {
|
|
984
|
+
m(o.value ?? i ?? "");
|
|
985
|
+
}, [o.value, i]), u(s, () => c.current);
|
|
986
|
+
let _ = a ? "" : d;
|
|
987
|
+
return /* @__PURE__ */ t(X, {
|
|
988
|
+
...o,
|
|
989
|
+
wait: a,
|
|
990
|
+
children: (e) => /* @__PURE__ */ t("textarea", {
|
|
991
|
+
...e,
|
|
992
|
+
disabled: a,
|
|
993
|
+
placeholder: e.placeholder ?? "",
|
|
994
|
+
value: _,
|
|
995
|
+
onChange: h,
|
|
996
|
+
onInput: g,
|
|
997
|
+
ref: c
|
|
998
|
+
})
|
|
999
|
+
});
|
|
1000
|
+
}), Xe = {
|
|
1001
|
+
"file-btn": "style-module__file-btn__WajPw",
|
|
1002
|
+
icon: "style-module__icon__f1VPN"
|
|
1003
|
+
}, Ze = ({ onChange: r, onChangeFiles: i, accept: a, multiple: o, wait: c, children: l, className: u, icon: d, ...p }) => {
|
|
1004
|
+
let m = f(null), h = `
|
|
1005
|
+
${Xe["file-btn"]}
|
|
1006
|
+
${d && !c ? Xe.icon : ""}
|
|
1007
|
+
`.trim(), g = s((e) => {
|
|
1008
|
+
let t = e.target.files;
|
|
1009
|
+
typeof r == "function" && r(e), typeof i == "function" && i(t);
|
|
1010
|
+
}, [r, i]);
|
|
1011
|
+
return /* @__PURE__ */ t(X, {
|
|
1012
|
+
...p,
|
|
1013
|
+
wait: c,
|
|
1014
|
+
children: (r) => /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t("input", {
|
|
1015
|
+
type: "file",
|
|
1016
|
+
ref: m,
|
|
1017
|
+
onChange: g,
|
|
1018
|
+
accept: a,
|
|
1019
|
+
multiple: o,
|
|
1020
|
+
style: { display: "none" },
|
|
1021
|
+
...r
|
|
1022
|
+
}), /* @__PURE__ */ t("div", {
|
|
1023
|
+
className: `ui-file-uploader ${h} ${u || ""}`,
|
|
1024
|
+
children: !c && (l || "Выбрать файл")
|
|
1025
|
+
})] })
|
|
1026
|
+
});
|
|
1027
|
+
}, Qe = ({ onChange: e, children: n, multiple: r, accept: i, ...a }) => {
|
|
1028
|
+
let o = f(null), s = (t) => {
|
|
1029
|
+
let n = t.target;
|
|
1030
|
+
if (n.files) for (let t of n.files) {
|
|
1031
|
+
let n = new FileReader();
|
|
1032
|
+
n.onload = (n) => {
|
|
1033
|
+
let r = n.target?.result?.toString().split(";base64,"), i = r?.[0].replace("data:", "") ?? "", a = r?.[1] ?? "";
|
|
1034
|
+
typeof e == "function" && (o.current.value = "", e({
|
|
1035
|
+
name: t.name,
|
|
1036
|
+
type: t.type,
|
|
1037
|
+
size: t.size,
|
|
1038
|
+
mime: i,
|
|
1039
|
+
data: a,
|
|
1040
|
+
base64: n.target?.result
|
|
1041
|
+
}));
|
|
1042
|
+
}, n.readAsDataURL(t);
|
|
1043
|
+
}
|
|
1044
|
+
}, c = (e) => {
|
|
1045
|
+
a.disabled || (o.current.click(), e.preventDefault());
|
|
1046
|
+
}, u = () => {
|
|
1047
|
+
let e = document.createElement("input");
|
|
1048
|
+
return e.setAttribute("type", "file"), e.onchange = s, i && i.length > 0 && e.setAttribute("accept", i.join(",")), r && e.setAttribute("multiple", "multiple"), e;
|
|
1049
|
+
};
|
|
1050
|
+
return l(() => (o.current = u(), () => {
|
|
1051
|
+
o.current?.remove();
|
|
1052
|
+
}), []), /* @__PURE__ */ t("div", {
|
|
1053
|
+
...a,
|
|
1054
|
+
onClick: c,
|
|
1055
|
+
children: n
|
|
1056
|
+
});
|
|
1057
|
+
}, Z = {
|
|
1058
|
+
container: "style-module__container__Y4Az4",
|
|
1059
|
+
"wait-indicator": "style-module__wait-indicator__qOZNZ",
|
|
1060
|
+
active: "style-module__active__SLZO0",
|
|
1061
|
+
btn: "style-module__btn__w2P2j",
|
|
1062
|
+
"icon-left": "style-module__icon-left__yptLL",
|
|
1063
|
+
"icon-right": "style-module__icon-right__WiI7N",
|
|
1064
|
+
"icon-only": "style-module__icon-only__EfIlC",
|
|
1065
|
+
"btn-light": "style-module__btn-light__sxtcL",
|
|
1066
|
+
"btn-secondary": "style-module__btn-secondary__t7dC7",
|
|
1067
|
+
"btn-secondary-light": "style-module__btn-secondary-light__wBuc1",
|
|
1068
|
+
"btn-tertiary": "style-module__btn-tertiary__2CjQz",
|
|
1069
|
+
"normal-btn": "style-module__normal-btn__qHevU",
|
|
1070
|
+
"small-btn": "style-module__small-btn__Axtvq",
|
|
1071
|
+
"large-btn": "style-module__large-btn__X3--3"
|
|
1072
|
+
}, $e = ({ children: e, className: r, classNameContainer: i, styleContainer: a, wait: o = !1, variant: s, size: c = "normal", icon: l, ...u }) => {
|
|
1073
|
+
let d = `
|
|
1074
|
+
${Z.btn}
|
|
1075
|
+
${s && Z[`btn-${s}`]}
|
|
1076
|
+
${c && Z[`${c}-btn`]}
|
|
1077
|
+
${l && !o ? Z[`icon-${l}`] : ""}
|
|
1078
|
+
${r || ""}
|
|
1079
|
+
`.replace(/\s+/g, " ").trim(), f = ["ui-button-container"];
|
|
1080
|
+
return f.push(Z.container), i && f.push(i), /* @__PURE__ */ n("div", {
|
|
1081
|
+
className: f.join(" "),
|
|
1082
|
+
style: a,
|
|
1083
|
+
children: [/* @__PURE__ */ t("button", {
|
|
1084
|
+
...u,
|
|
1085
|
+
className: d,
|
|
1086
|
+
children: !o && e
|
|
1087
|
+
}), o && /* @__PURE__ */ t("div", {
|
|
1088
|
+
className: "ui-button-spinner " + Z["wait-indicator"] + (o ? " " + Z.active : ""),
|
|
1089
|
+
children: /* @__PURE__ */ t(Ke, { color: s })
|
|
1090
|
+
})]
|
|
1091
|
+
});
|
|
1092
|
+
}, et = {
|
|
1093
|
+
container: "style-module__container__Qt7Ix",
|
|
1094
|
+
image: "style-module__image__1qdut",
|
|
1095
|
+
new: "style-module__new__fOnXf",
|
|
1096
|
+
close: "style-module__close__9k-p1",
|
|
1097
|
+
wait: "style-module__wait__qnGnj"
|
|
1098
|
+
}, tt = ({ onChange: e, onClick: r, onId: i, onRemove: a, ...o }) => {
|
|
1099
|
+
let { base64: s, src: c } = o, [u, d] = p(!0), m = f(!1), h = f(), _ = (e) => {
|
|
1100
|
+
h.current = e, typeof i == "function" && i(e);
|
|
1101
|
+
};
|
|
1102
|
+
return l(() => {
|
|
1103
|
+
typeof e != "function" || c || e({
|
|
1104
|
+
...o,
|
|
1105
|
+
setWait: d,
|
|
1106
|
+
setId: _,
|
|
1107
|
+
id: h.current
|
|
1108
|
+
});
|
|
1109
|
+
}, []), /* @__PURE__ */ n("span", {
|
|
1110
|
+
className: et.image,
|
|
1111
|
+
onClick: () => {
|
|
1112
|
+
typeof r == "function" && r({
|
|
1113
|
+
...o,
|
|
1114
|
+
setWait: d,
|
|
1115
|
+
setId: _,
|
|
1116
|
+
id: h.current
|
|
1117
|
+
});
|
|
1118
|
+
},
|
|
1119
|
+
children: [
|
|
1120
|
+
/* @__PURE__ */ t("span", {
|
|
1121
|
+
className: et.close,
|
|
1122
|
+
onClick: (e) => {
|
|
1123
|
+
if (!e.target) return;
|
|
1124
|
+
let t = e.target;
|
|
1125
|
+
m.current && (m.current = !1, t.blur(), typeof a == "function" && a()), m.current = !0;
|
|
1126
|
+
},
|
|
1127
|
+
onBlur: () => {
|
|
1128
|
+
m.current = !1;
|
|
1129
|
+
},
|
|
1130
|
+
tabIndex: 1
|
|
1131
|
+
}),
|
|
1132
|
+
/* @__PURE__ */ t("img", {
|
|
1133
|
+
src: c ?? s?.toString(),
|
|
1134
|
+
onLoad: () => {
|
|
1135
|
+
d(!1);
|
|
1136
|
+
}
|
|
1137
|
+
}),
|
|
1138
|
+
u && /* @__PURE__ */ t("span", {
|
|
1139
|
+
className: et.wait,
|
|
1140
|
+
children: /* @__PURE__ */ t(g, {})
|
|
1141
|
+
})
|
|
1142
|
+
]
|
|
1143
|
+
});
|
|
1144
|
+
}, nt = ({ imagesArray: e, onChange: r, onChangeArray: i, onClick: a }) => {
|
|
1145
|
+
let [o, s] = p([]), c = (e) => {
|
|
1146
|
+
s((t) => [...t, { ...e }]);
|
|
1147
|
+
}, u = (e) => (t) => {
|
|
1148
|
+
s((n) => n.map((n) => (e === n && (n.id = t), n)));
|
|
1149
|
+
}, d = (e) => () => s((t) => t.filter((t) => t !== e));
|
|
1150
|
+
return l(() => {
|
|
1151
|
+
typeof i == "function" && i(o);
|
|
1152
|
+
}, [o]), l(() => {
|
|
1153
|
+
e && s(e);
|
|
1154
|
+
}, [e]), /* @__PURE__ */ n("div", {
|
|
1155
|
+
className: et.container,
|
|
1156
|
+
children: [o.map((e, n) => /* @__PURE__ */ t(tt, {
|
|
1157
|
+
...e,
|
|
1158
|
+
onChange: r,
|
|
1159
|
+
onClick: a,
|
|
1160
|
+
onRemove: d(e),
|
|
1161
|
+
onId: u(e)
|
|
1162
|
+
}, e.name + n)), /* @__PURE__ */ t(Qe, {
|
|
1163
|
+
onChange: c,
|
|
1164
|
+
accept: ["image/png"],
|
|
1165
|
+
className: et.new,
|
|
1166
|
+
multiple: !0
|
|
1167
|
+
})]
|
|
1168
|
+
});
|
|
1169
|
+
}, rt = {
|
|
1170
|
+
container: "style-module__container__tUkU0",
|
|
1171
|
+
text: "style-module__text__5dksK",
|
|
1172
|
+
indicator: "style-module__indicator__BdmZs"
|
|
1173
|
+
}, it = o(({ type: e = "checkbox", hiddenContainer: r = !0, placeholder: i, onChecked: a, onChange: o, ...s }, c) => {
|
|
1174
|
+
let l = (e) => {
|
|
1175
|
+
typeof o == "function" && o(e), typeof a == "function" && a(e.target.checked, s.value);
|
|
1176
|
+
};
|
|
1177
|
+
return /* @__PURE__ */ t(X, {
|
|
1178
|
+
...s,
|
|
1179
|
+
hiddenContainer: r,
|
|
1180
|
+
children: (r) => /* @__PURE__ */ n("div", {
|
|
1181
|
+
className: "ui-checkbox-container " + rt.container,
|
|
1182
|
+
children: [
|
|
1183
|
+
/* @__PURE__ */ t("input", {
|
|
1184
|
+
...r,
|
|
1185
|
+
className: "ui-checkbox" + (r.className ? " " + r.className : ""),
|
|
1186
|
+
type: e,
|
|
1187
|
+
onChange: l,
|
|
1188
|
+
ref: c
|
|
1189
|
+
}),
|
|
1190
|
+
/* @__PURE__ */ t("span", { className: "ui-checkbox-indicator " + rt.indicator }),
|
|
1191
|
+
/* @__PURE__ */ t("span", {
|
|
1192
|
+
className: "ui-checkbox-text " + rt.text,
|
|
1193
|
+
children: i
|
|
1194
|
+
})
|
|
1195
|
+
]
|
|
1196
|
+
})
|
|
1197
|
+
});
|
|
1198
|
+
}), at = {
|
|
1199
|
+
container: "style-module__container__nvLZo",
|
|
1200
|
+
down: "style-module__down__0mCw1",
|
|
1201
|
+
up: "style-module__up__4e9Cz",
|
|
1202
|
+
left: "style-module__left__tsvvk",
|
|
1203
|
+
right: "style-module__right__-YgfC"
|
|
1204
|
+
}, ot = ({ className: e, direction: n = "down", ...r }) => {
|
|
1205
|
+
let i = ["ui-component-arrow"];
|
|
1206
|
+
return i.push(at.container), n && i.push(at[n]), e && i.push(e), /* @__PURE__ */ t("div", {
|
|
1207
|
+
...r,
|
|
1208
|
+
className: i.join(" ")
|
|
1209
|
+
});
|
|
1210
|
+
}, Q = {
|
|
1211
|
+
"container-element": "style-module__container-element__bbCnL",
|
|
1212
|
+
container: "style-module__container__P3B9C",
|
|
1213
|
+
select: "style-module__select__BYzzT",
|
|
1214
|
+
arrow: "style-module__arrow__pfRrX",
|
|
1215
|
+
opened: "style-module__opened__1ytU8",
|
|
1216
|
+
"select-list": "style-module__select-list__c--KX",
|
|
1217
|
+
left: "style-module__left__pbJ6F",
|
|
1218
|
+
right: "style-module__right__WUUwr",
|
|
1219
|
+
hidden: "style-module__hidden__u48qc",
|
|
1220
|
+
optgpoup: "style-module__optgpoup__VDA2I",
|
|
1221
|
+
label: "style-module__label__GP062",
|
|
1222
|
+
option: "style-module__option__byy-y",
|
|
1223
|
+
title: "style-module__title__x7nug",
|
|
1224
|
+
active: "style-module__active__ORdtQ",
|
|
1225
|
+
disabled: "style-module__disabled__xA0bc"
|
|
1226
|
+
}, st = a({
|
|
1227
|
+
selected: "",
|
|
1228
|
+
emptyValue: { current: {} },
|
|
1229
|
+
setSelect: (e) => {},
|
|
1230
|
+
setSelected: (e) => {},
|
|
1231
|
+
setTitle: (e) => {}
|
|
1232
|
+
}), ct = o(({ children: e, onChangeSelect: r, value: i, formvalue: a, ...o }, s) => {
|
|
1233
|
+
let c = f(null), d = f(null), m = f(!1), [h, g] = p(!1), [_, v] = p(""), [y, b] = p(), x = () => {
|
|
1234
|
+
o.disabled || g(!0);
|
|
1235
|
+
}, S = () => {
|
|
1236
|
+
g(!1);
|
|
1237
|
+
}, C = () => {
|
|
1238
|
+
h ? S() : x();
|
|
1239
|
+
}, w = (e) => {
|
|
1240
|
+
(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set)?.call(d.current, e);
|
|
1241
|
+
let t = new Event("input", { bubbles: !0 });
|
|
1242
|
+
d.current.dispatchEvent(t);
|
|
1243
|
+
}, T = (e) => {
|
|
1244
|
+
typeof r == "function" && r(e), i === void 0 && v(e), S();
|
|
1245
|
+
}, E = (e) => {
|
|
1246
|
+
o.disabled || (typeof o.onInput == "function" && o.onInput(e), typeof o.onChange == "function" && o.onChange(e), v(e.target.value));
|
|
1247
|
+
};
|
|
1248
|
+
l(() => {
|
|
1249
|
+
_ && w(_);
|
|
1250
|
+
}, [_]), l(() => {
|
|
1251
|
+
v(String(i ?? a));
|
|
1252
|
+
}, [i, a]), l(() => {
|
|
1253
|
+
let e = c.current, t = e.classList;
|
|
1254
|
+
h ? (t.remove(Q.hidden), requestAnimationFrame(() => {
|
|
1255
|
+
t.add(Q.opened), e?.focus();
|
|
1256
|
+
})) : (t.contains(Q.opened) && (e.ontransitionend = () => {
|
|
1257
|
+
t.add(Q.hidden), e.ontransitionend = null;
|
|
1258
|
+
}), t.remove(Q.opened));
|
|
1259
|
+
}, [h]), u(s, () => d.current, []);
|
|
1260
|
+
let ee = [""];
|
|
1261
|
+
return ee.push(Q.container, Q.hidden), /* @__PURE__ */ t(X, {
|
|
1262
|
+
...o,
|
|
1263
|
+
classNameContainer: Q["container-element"],
|
|
1264
|
+
children: (r) => /* @__PURE__ */ n(st.Provider, {
|
|
1265
|
+
value: {
|
|
1266
|
+
selected: _,
|
|
1267
|
+
emptyValue: m,
|
|
1268
|
+
setSelect: T,
|
|
1269
|
+
setSelected: v,
|
|
1270
|
+
setTitle: b
|
|
1271
|
+
},
|
|
1272
|
+
children: [/* @__PURE__ */ t("input", {
|
|
1273
|
+
...r,
|
|
1274
|
+
type: "hidden",
|
|
1275
|
+
value: _,
|
|
1276
|
+
onInput: E,
|
|
1277
|
+
ref: d
|
|
1278
|
+
}), /* @__PURE__ */ n("div", {
|
|
1279
|
+
className: ee.join(" "),
|
|
1280
|
+
ref: c,
|
|
1281
|
+
tabIndex: 1,
|
|
1282
|
+
onBlur: S,
|
|
1283
|
+
children: [/* @__PURE__ */ n("div", {
|
|
1284
|
+
className: Q.select,
|
|
1285
|
+
onClick: C,
|
|
1286
|
+
children: [/* @__PURE__ */ t("span", {
|
|
1287
|
+
className: Q.title,
|
|
1288
|
+
children: y
|
|
1289
|
+
}), /* @__PURE__ */ t(ot, { className: Q.arrow })]
|
|
1290
|
+
}), /* @__PURE__ */ t("ul", {
|
|
1291
|
+
className: Q["select-list"],
|
|
1292
|
+
children: e
|
|
1293
|
+
})]
|
|
1294
|
+
})]
|
|
1295
|
+
})
|
|
1296
|
+
});
|
|
1297
|
+
}), lt = ({ children: e, value: n, disabled: r, hidden: i, onClick: a, ...o }) => {
|
|
1298
|
+
let s = c(st), u = (e) => {
|
|
1299
|
+
n === void 0 || r || (s.setSelect(n), typeof a == "function" && a(e));
|
|
1300
|
+
};
|
|
1301
|
+
if (l(() => {
|
|
1302
|
+
e && (n === s.selected || !s.emptyValue.current) && (s.setTitle(e), !s.emptyValue.current && n && s.setSelected(n), s.emptyValue.current = !0);
|
|
1303
|
+
}, [s.selected, s.emptyValue.current]), i) return null;
|
|
1304
|
+
let f = d(() => {
|
|
1305
|
+
let e = ["ui-select-option"];
|
|
1306
|
+
return e.push(Q.option), s.selected === n && e.push(Q.active, "active"), r && e.push(Q.disabled, "disabled"), e;
|
|
1307
|
+
}, [s.selected, r]);
|
|
1308
|
+
return /* @__PURE__ */ t("li", {
|
|
1309
|
+
...o,
|
|
1310
|
+
onClick: u,
|
|
1311
|
+
className: f.join(" "),
|
|
1312
|
+
children: e
|
|
1313
|
+
});
|
|
1314
|
+
}, ut = ({ children: e, label: r }) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ n("ul", {
|
|
1315
|
+
className: Q.optgpoup,
|
|
1316
|
+
children: [r && /* @__PURE__ */ t("li", {
|
|
1317
|
+
className: Q.label,
|
|
1318
|
+
children: r
|
|
1319
|
+
}), e]
|
|
1320
|
+
}) }), dt = {
|
|
1321
|
+
...o(({ ...e }, n) => /* @__PURE__ */ t(ct, {
|
|
1322
|
+
...e,
|
|
1323
|
+
ref: n
|
|
1324
|
+
})),
|
|
1325
|
+
Option: lt,
|
|
1326
|
+
Optgroup: ut
|
|
1327
|
+
}, $ = {
|
|
1328
|
+
container: "style-module__container__3-2SP",
|
|
1329
|
+
hide: "style-module__hide__4ywHX",
|
|
1330
|
+
down: "style-module__down__STzsX",
|
|
1331
|
+
"dropdown-list": "style-module__dropdown-list__O27el",
|
|
1332
|
+
up: "style-module__up__PYaUD",
|
|
1333
|
+
left: "style-module__left__9XBs6",
|
|
1334
|
+
right: "style-module__right__Tvd1-",
|
|
1335
|
+
opened: "style-module__opened__GjGrB",
|
|
1336
|
+
arrow: "style-module__arrow__SCvqs",
|
|
1337
|
+
item: "style-module__item__v8SnZ"
|
|
1338
|
+
}, ft = ({ items: e, isOpen: n, enableRerenderItems: r, disabled: i }) => {
|
|
1339
|
+
let a = f(null), o = d(() => r ? n ? e : null : e, [
|
|
1340
|
+
r,
|
|
1341
|
+
e,
|
|
1342
|
+
n
|
|
1343
|
+
]);
|
|
1344
|
+
return l(() => {
|
|
1345
|
+
a.current && (window.innerWidth, a.current.getBoundingClientRect().left);
|
|
1346
|
+
}, [n]), i ? null : /* @__PURE__ */ t("ul", {
|
|
1347
|
+
className: `${$["dropdown-list"]} ui-dropdown-list`,
|
|
1348
|
+
children: o,
|
|
1349
|
+
ref: a
|
|
1350
|
+
});
|
|
1351
|
+
}, pt = a({ close: () => {} }), mt = ({ children: e, className: r, items: i, arrow: a = !0, direction: o = "down", position: s = "right", split: c = !1, disabled: u, hover: d = !1, enableRerenderItems: m = !0, onShow: h, onHide: g, ..._ }) => {
|
|
1352
|
+
let v = f(null), y = f(null), [b, x] = p(!1), S = () => {
|
|
1353
|
+
x(!1);
|
|
1354
|
+
}, C = () => {
|
|
1355
|
+
x((e) => u ? !1 : !e);
|
|
1356
|
+
}, w = () => {
|
|
1357
|
+
C();
|
|
1358
|
+
}, T = () => {
|
|
1359
|
+
y.current || (!c || d) && C();
|
|
1360
|
+
}, E = (e) => {
|
|
1361
|
+
e.currentTarget.contains(e.relatedTarget) || S();
|
|
1362
|
+
}, ee = () => {
|
|
1363
|
+
!d || b || (y.current = setTimeout(C, 50));
|
|
1364
|
+
}, D = () => {
|
|
1365
|
+
y.current && clearTimeout(y.current);
|
|
1366
|
+
};
|
|
1367
|
+
l(() => {
|
|
1368
|
+
let e = v.current, t = e?.classList;
|
|
1369
|
+
b ? (t?.add($.opened), e?.focus(), typeof h == "function" && h()) : (t?.remove($.opened), typeof g == "function" && g());
|
|
1370
|
+
}, [b]);
|
|
1371
|
+
let O = ["ui-dropdown"];
|
|
1372
|
+
return O.push($.container), r && O.push(r), o && O.push($[o]), s && O.push($[s]), /* @__PURE__ */ t(pt.Provider, {
|
|
1373
|
+
value: { close: S },
|
|
1374
|
+
children: /* @__PURE__ */ n("div", {
|
|
1375
|
+
..._,
|
|
1376
|
+
className: O.join(" "),
|
|
1377
|
+
ref: v,
|
|
1378
|
+
onMouseEnter: ee,
|
|
1379
|
+
onMouseLeave: D,
|
|
1380
|
+
tabIndex: 1,
|
|
1381
|
+
onBlur: E,
|
|
1382
|
+
children: [
|
|
1383
|
+
s === "left" && !u && /* @__PURE__ */ t(ot, {
|
|
1384
|
+
className: $.arrow,
|
|
1385
|
+
onClick: w
|
|
1386
|
+
}),
|
|
1387
|
+
/* @__PURE__ */ t("div", {
|
|
1388
|
+
onClick: T,
|
|
1389
|
+
className: "ui-dropdown-block" + (b ? " " + $.hide : ""),
|
|
1390
|
+
children: e
|
|
1391
|
+
}),
|
|
1392
|
+
s === "right" && !u && a && /* @__PURE__ */ t(ot, {
|
|
1393
|
+
className: $.arrow,
|
|
1394
|
+
onClick: w
|
|
1395
|
+
}),
|
|
1396
|
+
/* @__PURE__ */ t(ft, {
|
|
1397
|
+
isOpen: b,
|
|
1398
|
+
disabled: u,
|
|
1399
|
+
enableRerenderItems: m,
|
|
1400
|
+
items: i
|
|
1401
|
+
})
|
|
1402
|
+
]
|
|
1403
|
+
})
|
|
1404
|
+
});
|
|
1405
|
+
}, ht = ({ children: e, onClick: n, autoClose: r = !0, active: i, className: a, ...o }) => {
|
|
1406
|
+
let s = c(pt), l = (e) => {
|
|
1407
|
+
typeof n == "function" && n(e), r && s.close();
|
|
1408
|
+
}, u = ["ui-dropdown-item"];
|
|
1409
|
+
return u.push($.item), i && u.push($.active, "active"), a && u.push(a), /* @__PURE__ */ t("li", {
|
|
1410
|
+
...o,
|
|
1411
|
+
onClick: l,
|
|
1412
|
+
className: u.join(" "),
|
|
1413
|
+
children: typeof e == "function" ? e(s) : e
|
|
1414
|
+
});
|
|
1415
|
+
}, gt = {
|
|
1416
|
+
...o(({ ...e }, n) => /* @__PURE__ */ t(mt, { ...e })),
|
|
1417
|
+
Item: ht
|
|
1418
|
+
}, _t = a({}), vt = ({ children: e }) => /* @__PURE__ */ t(_t.Provider, {
|
|
1419
|
+
value: {},
|
|
1420
|
+
children: e
|
|
1421
|
+
});
|
|
1422
|
+
//#endregion
|
|
1423
|
+
export { $e as Button, it as Checkbox, gt as Dropdown, ht as DropdownItem, X as Element, X as FormElement, Qe as File, Ze as FileInput, qe as Form, Je as Input, Ke as Loading, v as Progress, vt as Provider, dt as Select, ut as SelectOptgroup, lt as SelectOption, g as Spinner, Ye as TextArea, nt as UploadImages, We as useForm };
|