@nice2dev/ui 1.2.1 → 1.3.0
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/CHANGELOG.md +476 -0
- package/dist/NiceButton-CnAIqCbd.js +101 -0
- package/dist/NiceButton-DzCqkG5a.cjs +1 -0
- package/dist/NiceCodeEditor-C43xFG8v.cjs +260 -0
- package/dist/NiceCodeEditor-CK6B54mu.js +1215 -0
- package/dist/NiceCodeEditor-CspuYLh6.js +1174 -0
- package/dist/NiceCodeEditor-bJReZPDO.cjs +268 -0
- package/dist/NiceColorPicker-BV3olE3M.cjs +1 -0
- package/dist/NiceColorPicker-CyY-4q89.js +552 -0
- package/dist/NiceDataGrid-BQIqitMM.cjs +10 -0
- package/dist/NiceDataGrid-C1eI6Pso.js +2267 -0
- package/dist/NiceDataGrid-CrD4HPlO.cjs +10 -0
- package/dist/NiceDataGrid-Dfg1DVbU.js +2224 -0
- package/dist/NiceForm-CISJyzoW.cjs +1 -0
- package/dist/NiceForm-CfAPcXdX.cjs +1 -0
- package/dist/NiceForm-DfKYNQti.js +5017 -0
- package/dist/NiceForm-DmH6k1b_.js +4775 -0
- package/dist/NiceGantt-CHnq-n8f.cjs +1 -0
- package/dist/NiceGantt-CX3jVNaF.js +330 -0
- package/dist/NiceGantt-TEXbAELi.js +333 -0
- package/dist/NiceGantt-s2cgt5zD.cjs +1 -0
- package/dist/NiceHtmlEditor-CDZeF_zG.cjs +10 -0
- package/dist/NiceHtmlEditor-CdWgddg3.js +901 -0
- package/dist/NiceHtmlEditor-DeK0Of98.js +883 -0
- package/dist/NiceHtmlEditor-DvVxl4Fu.cjs +10 -0
- package/dist/NiceLoginForm-CHXbz0eu.js +747 -0
- package/dist/NiceLoginForm-DRPldHXa.js +808 -0
- package/dist/NiceLoginForm-IGLUCQUE.cjs +1 -0
- package/dist/NiceLoginForm-ix6J1adA.cjs +1 -0
- package/dist/NiceMention-CgDp0sl9.cjs +430 -0
- package/dist/NiceMention-DBvFvx71.js +11653 -0
- package/dist/NiceMention-DKhk3xdM.js +11321 -0
- package/dist/NiceMention-wp1AJ5oh.cjs +430 -0
- package/dist/NiceMention.css +1 -1
- package/dist/NiceModal-BbQwiEOp.cjs +1 -0
- package/dist/NiceModal-BlYhFDhP.js +80 -0
- package/dist/NiceModal-DQEfTcnZ.js +85 -0
- package/dist/NiceModal-DmWz2PDM.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-22CEEVbA.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-BCd9Wv5Y.js +6825 -0
- package/dist/NiceModuleLifecyclePanel-D8EoXqBy.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-SN6G7t64.js +7189 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-BFGt1v0a.js +165 -0
- package/dist/NicePagination-BJS65foT.js +200 -0
- package/dist/NicePagination-D_3GfWp5.cjs +1 -0
- package/dist/NicePagination-DltL3-Sz.cjs +1 -0
- package/dist/NicePivotGrid-BD87Na7P.js +1163 -0
- package/dist/NicePivotGrid-BPmnvbPQ.cjs +152 -0
- package/dist/NicePivotGrid-D_kRF1Dt.js +1180 -0
- package/dist/NicePivotGrid-DqluEkCI.cjs +152 -0
- package/dist/NiceSavedQueryPanel-BSTiZvFg.js +5130 -0
- package/dist/NiceSavedQueryPanel-C2Tn1cMW.js +5311 -0
- package/dist/NiceSavedQueryPanel-DDKtL1AA.cjs +586 -0
- package/dist/NiceSavedQueryPanel-DrR3sw4T.cjs +586 -0
- package/dist/NiceScheduler-DvxJ8N0I.js +1698 -0
- package/dist/NiceScheduler-GJLvkXJ3.cjs +5 -0
- package/dist/NiceScheduler-TIksdF0k.cjs +5 -0
- package/dist/NiceScheduler-UT49u2Vq.js +1710 -0
- package/dist/NiceSelect-CdUHd8rj.cjs +1 -0
- package/dist/NiceSelect-fOelG_QB.js +495 -0
- package/dist/NiceWindow-CqSsTjrS.cjs +1 -0
- package/dist/NiceWindow-DZLPhXbR.js +2223 -0
- package/dist/charts-BYQwl_GS.js +4789 -0
- package/dist/charts-BpELGDXh.cjs +768 -0
- package/dist/charts-C6iOu0H6.cjs +768 -0
- package/dist/charts-M6LuVI7F.js +4776 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +1 -29
- package/dist/charts.mjs +1 -1
- package/dist/core-lazy-B_laOXNf.cjs +1 -0
- package/dist/core-lazy-Ctin_LwS.cjs +1 -0
- package/dist/core-lazy-VQEjdz0L.js +351 -0
- package/dist/core-lazy-iDiropM6.js +351 -0
- package/dist/data-branching-7rpktFJ-.cjs +1 -0
- package/dist/data-branching-BS0aFUMu.js +6428 -0
- package/dist/data-branching-BgIAw01q.cjs +1 -0
- package/dist/data-branching-bvB9K6KS.js +6386 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.mjs +3 -3
- package/dist/devops-Bp-_aA-9.js +8682 -0
- package/dist/devops-CFytAJQr.cjs +18 -0
- package/dist/devops-CW8YY_zA.js +9122 -0
- package/dist/devops-CXBSjnyX.cjs +17 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.css +1 -0
- package/dist/devops.mjs +5 -5
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +8 -8
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +21 -16
- package/dist/feedback.mjs +3 -3
- package/dist/index.cjs +199 -194
- package/dist/index.css +1 -1
- package/dist/index.d.ts +378 -48
- package/dist/index.mjs +23248 -21783
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +31 -0
- package/dist/navigation.mjs +404 -354
- package/dist/no-code-BNFk_BDO.js +8275 -0
- package/dist/no-code-BaAI_sJR.js +8318 -0
- package/dist/no-code-CFdTp543.cjs +331 -0
- package/dist/no-code-oQTeAtnW.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +5 -0
- package/dist/overlays.mjs +1 -1
- package/dist/pickerCommons-BQi6IEAt.js +661 -0
- package/dist/pickerCommons-CMxFt9SW.js +548 -0
- package/dist/pickerCommons-Dc_hlz-e.cjs +1 -0
- package/dist/pickerCommons-DvQptSPX.cjs +1 -0
- package/dist/style.css +7 -4
- package/package.json +4 -3
|
@@ -0,0 +1,4775 @@
|
|
|
1
|
+
import { jsxs as f, jsx as e, Fragment as vn } from "react/jsx-runtime";
|
|
2
|
+
import { useComponentDisplayStyle as qn, useComponentDisplayClass as Rn, useNiceAccessMode as dn, useControlId as un, useNiceTranslation as Qe, useControllableState as dt, COMMON_SHORTCUTS as Ve, NiceKeyboardHint as gn, NiceIcon as Ae, useClickOutside as xt, useDisplayModeEdit as Rt, matchesShortcut as Ut, DisplayModeView as Et, NiceThemeContext as It, useHoldRepeat as Ft, useSubmitOnEnter as Lt, useNiceRecord as zt } from "@nice2dev/ui-core";
|
|
3
|
+
import xn, { useMemo as ge, useState as Te, useRef as be, useEffect as Le, useCallback as F, forwardRef as bn, useImperativeHandle as Pt, useContext as Bt, useLayoutEffect as ut } from "react";
|
|
4
|
+
import { N as Gn } from "./NiceButton-vkI07DP0.js";
|
|
5
|
+
import { u as Ht, F as nt, N as Yt, a as Vt } from "./pickerCommons-CMxFt9SW.js";
|
|
6
|
+
import { createPortal as pt } from "react-dom";
|
|
7
|
+
import { u as Gt, N as ft, s as Ot } from "./NiceSelect-CZR8Zu_k.js";
|
|
8
|
+
import { b as an, N as jt, a as tt } from "./no-code-BNFk_BDO.js";
|
|
9
|
+
import { NiceColorPicker as Kt } from "./NiceColorPicker-Cbop7VMu.js";
|
|
10
|
+
import { u as qt } from "./core-B8eBUE4m.js";
|
|
11
|
+
function Zt({ text: n, query: i }) {
|
|
12
|
+
if (!i)
|
|
13
|
+
return /* @__PURE__ */ e(vn, { children: n });
|
|
14
|
+
const t = n.toLowerCase().indexOf(i.toLowerCase());
|
|
15
|
+
return t < 0 ? /* @__PURE__ */ e(vn, { children: n }) : /* @__PURE__ */ f("span", { children: [
|
|
16
|
+
n.slice(0, t),
|
|
17
|
+
/* @__PURE__ */ e("strong", { children: n.slice(t, t + i.length) }),
|
|
18
|
+
n.slice(t + i.length)
|
|
19
|
+
] });
|
|
20
|
+
}
|
|
21
|
+
const Jt = [], Qt = ({
|
|
22
|
+
options: n = Jt,
|
|
23
|
+
value: i,
|
|
24
|
+
defaultValue: t,
|
|
25
|
+
onChange: o,
|
|
26
|
+
minSearchLength: a = 1,
|
|
27
|
+
maxResults: s = 10,
|
|
28
|
+
onSearch: u,
|
|
29
|
+
clearable: M,
|
|
30
|
+
loading: w,
|
|
31
|
+
multiple: A,
|
|
32
|
+
renderOption: ce,
|
|
33
|
+
highlightMatch: D = !0,
|
|
34
|
+
showAll: T = !0,
|
|
35
|
+
menuGap: X,
|
|
36
|
+
label: W,
|
|
37
|
+
error: z,
|
|
38
|
+
helperText: I,
|
|
39
|
+
required: $,
|
|
40
|
+
disabled: Z,
|
|
41
|
+
readOnly: ne,
|
|
42
|
+
size: J = "md",
|
|
43
|
+
id: pe,
|
|
44
|
+
className: ae,
|
|
45
|
+
style: k,
|
|
46
|
+
accessMode: U,
|
|
47
|
+
showKeyboardHints: L,
|
|
48
|
+
displayStyle: E,
|
|
49
|
+
labelPlacement: de,
|
|
50
|
+
errorPlacement: te,
|
|
51
|
+
labelWidth: ee,
|
|
52
|
+
controlWidth: R
|
|
53
|
+
}) => {
|
|
54
|
+
qn("input", E), Rn("input", E);
|
|
55
|
+
const S = dn(U, pe), P = S === "hidden";
|
|
56
|
+
(S === "disabled" || S === "readOnly") && (Z = !0);
|
|
57
|
+
const p = un(pe), { t: m } = Qe(), [y, V] = dt({
|
|
58
|
+
value: i,
|
|
59
|
+
defaultValue: t,
|
|
60
|
+
fallbackValue: A ? [] : "",
|
|
61
|
+
onChange: o,
|
|
62
|
+
componentName: "NiceAutocomplete"
|
|
63
|
+
}), H = ge(
|
|
64
|
+
() => A ? Array.isArray(y) ? y : y ? [y] : [] : [],
|
|
65
|
+
[y, A]
|
|
66
|
+
), [_, N] = Te(
|
|
67
|
+
() => A || Array.isArray(y) ? "" : n.find((d) => String(d.value) === y)?.label ?? y ?? ""
|
|
68
|
+
), [Y, K] = Te(!1), Q = be(null), [O, fe] = Te(-1), ue = be(null), re = be(null), { popupRef: le, coords: q, ready: Ce, themeClass: j, portalTarget: B } = Gt(
|
|
69
|
+
Y,
|
|
70
|
+
Q,
|
|
71
|
+
() => K(!1)
|
|
72
|
+
), oe = ge(() => {
|
|
73
|
+
const d = [
|
|
74
|
+
Ve.moveDown,
|
|
75
|
+
Ve.moveUp,
|
|
76
|
+
Ve.submit,
|
|
77
|
+
Ve.cancel
|
|
78
|
+
];
|
|
79
|
+
return A && d.push({ key: "Backspace", description: m("shortcuts.removeLastTag", "Remove last tag") }), d;
|
|
80
|
+
}, [A, m]);
|
|
81
|
+
Le(() => {
|
|
82
|
+
A || N(
|
|
83
|
+
Array.isArray(y) ? "" : n.find((d) => String(d.value) === y)?.label ?? y ?? ""
|
|
84
|
+
);
|
|
85
|
+
}, [y, A, n]);
|
|
86
|
+
const _e = ge(() => {
|
|
87
|
+
if (_.length < a)
|
|
88
|
+
return T ? (u ? n : [...n].sort((ke, ve) => ke.label.localeCompare(ve.label))).slice(0, s) : [];
|
|
89
|
+
if (u)
|
|
90
|
+
return n.slice(0, s);
|
|
91
|
+
const d = _.toLowerCase();
|
|
92
|
+
return n.filter((C) => C.label.toLowerCase().includes(d)).slice(0, s);
|
|
93
|
+
}, [n, _, a, s, u, T]), Ee = ge(() => {
|
|
94
|
+
const d = /* @__PURE__ */ new Map();
|
|
95
|
+
for (const C of _e) {
|
|
96
|
+
const ke = C.group || "";
|
|
97
|
+
d.has(ke) || d.set(ke, []), d.get(ke).push(C);
|
|
98
|
+
}
|
|
99
|
+
return d;
|
|
100
|
+
}, [_e]), Ne = F(
|
|
101
|
+
(d) => {
|
|
102
|
+
ne || (N(d), K(d.length >= a), fe(0), u?.(d));
|
|
103
|
+
},
|
|
104
|
+
[a, u, ne]
|
|
105
|
+
), Ye = F(
|
|
106
|
+
(d) => {
|
|
107
|
+
if (!ne)
|
|
108
|
+
if (A) {
|
|
109
|
+
const C = String(d.value), ke = H.includes(C) ? H.filter((ve) => ve !== C) : [...H, C];
|
|
110
|
+
V(ke), N("");
|
|
111
|
+
} else
|
|
112
|
+
N(d.label), V(String(d.value)), K(!1);
|
|
113
|
+
},
|
|
114
|
+
[V, A, H, ne]
|
|
115
|
+
), ze = (d) => {
|
|
116
|
+
if (!ne) {
|
|
117
|
+
if (A && d.key === "Backspace" && !_ && H.length > 0) {
|
|
118
|
+
V(H.slice(0, -1));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!Y && (d.key === "ArrowDown" || d.key === "ArrowUp")) {
|
|
122
|
+
d.preventDefault(), K(!0), fe(0);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
Y && (d.key === "ArrowDown" ? (d.preventDefault(), fe((C) => C < 0 ? 0 : Math.min(C + 1, _e.length - 1))) : d.key === "ArrowUp" ? (d.preventDefault(), fe((C) => C <= 0 ? _e.length - 1 : C - 1)) : (d.key === "Enter" || d.key === "Tab") && O >= 0 && O < _e.length ? (d.preventDefault(), Ye(_e[O])) : d.key === "Escape" && K(!1));
|
|
126
|
+
}
|
|
127
|
+
}, h = F(
|
|
128
|
+
(d) => {
|
|
129
|
+
ne || V(H.filter((C) => C !== d));
|
|
130
|
+
},
|
|
131
|
+
[H, V, ne]
|
|
132
|
+
);
|
|
133
|
+
return P ? null : /* @__PURE__ */ f(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
className: `nice-field nice-field--${J} ${de === "left" ? "nice-field--label-left" : ""} ${w ? "nice-field--loading" : ""} ${ae || ""}`,
|
|
137
|
+
style: {
|
|
138
|
+
width: "fit-content",
|
|
139
|
+
...k,
|
|
140
|
+
...ee != null && {
|
|
141
|
+
"--nice-field-label-width": typeof ee == "number" ? `${ee}px` : ee
|
|
142
|
+
},
|
|
143
|
+
...R != null && {
|
|
144
|
+
"--nice-field-control-width": typeof R == "number" ? `${R}px` : R
|
|
145
|
+
},
|
|
146
|
+
...X != null && { "--nice-dropdown-gap": `${X}px` }
|
|
147
|
+
},
|
|
148
|
+
ref: ue,
|
|
149
|
+
"aria-busy": w || void 0,
|
|
150
|
+
children: [
|
|
151
|
+
W && /* @__PURE__ */ f(
|
|
152
|
+
"label",
|
|
153
|
+
{
|
|
154
|
+
className: `nice-field__label ${$ ? "nice-field__label--required" : ""}`,
|
|
155
|
+
htmlFor: p,
|
|
156
|
+
children: [
|
|
157
|
+
W,
|
|
158
|
+
L && /* @__PURE__ */ e(gn, { shortcuts: oe, size: "sm" })
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ f("div", { className: "nice-field__control", style: { position: "relative" }, children: [
|
|
163
|
+
/* @__PURE__ */ e(
|
|
164
|
+
"div",
|
|
165
|
+
{
|
|
166
|
+
ref: Q,
|
|
167
|
+
className: `nice-input nice-input--${J} ${z ? "nice-input--error" : ""} ${Z ? "nice-input--disabled" : ""}`,
|
|
168
|
+
style: { width: "220px" },
|
|
169
|
+
children: /* @__PURE__ */ f(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
className: "nice-field__input-wrap",
|
|
173
|
+
style: {
|
|
174
|
+
display: "flex",
|
|
175
|
+
flexWrap: A ? "wrap" : "nowrap",
|
|
176
|
+
gap: 4,
|
|
177
|
+
alignItems: "center",
|
|
178
|
+
flex: 1,
|
|
179
|
+
minWidth: 0
|
|
180
|
+
},
|
|
181
|
+
children: [
|
|
182
|
+
A && H.map((d) => {
|
|
183
|
+
const C = n.find((ke) => String(ke.value) === d);
|
|
184
|
+
return /* @__PURE__ */ f("span", { className: "nice-autocomplete__tag", children: [
|
|
185
|
+
C?.label || d,
|
|
186
|
+
!ne && /* @__PURE__ */ e(
|
|
187
|
+
"button",
|
|
188
|
+
{
|
|
189
|
+
type: "button",
|
|
190
|
+
className: "nice-autocomplete__tag-remove",
|
|
191
|
+
onClick: () => h(d),
|
|
192
|
+
"aria-label": m("controls.remove", "Remove"),
|
|
193
|
+
children: /* @__PURE__ */ e(Ae, { name: "close", size: 14 })
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
] }, d);
|
|
197
|
+
}),
|
|
198
|
+
/* @__PURE__ */ e(
|
|
199
|
+
"input",
|
|
200
|
+
{
|
|
201
|
+
ref: re,
|
|
202
|
+
id: p,
|
|
203
|
+
type: "text",
|
|
204
|
+
className: "nice-input__native",
|
|
205
|
+
value: _,
|
|
206
|
+
onChange: (d) => Ne(d.target.value),
|
|
207
|
+
onFocus: () => !ne && (T || _.length >= a) && K(!0),
|
|
208
|
+
onKeyDown: ze,
|
|
209
|
+
disabled: Z,
|
|
210
|
+
readOnly: ne,
|
|
211
|
+
required: $,
|
|
212
|
+
role: "combobox",
|
|
213
|
+
"aria-expanded": Y,
|
|
214
|
+
"aria-autocomplete": "list",
|
|
215
|
+
autoComplete: "off",
|
|
216
|
+
style: {
|
|
217
|
+
flex: 1,
|
|
218
|
+
minWidth: 60,
|
|
219
|
+
border: "none",
|
|
220
|
+
outline: "none",
|
|
221
|
+
background: "transparent",
|
|
222
|
+
color: "inherit",
|
|
223
|
+
padding: 0,
|
|
224
|
+
font: "inherit"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
M && !A && _ && !Z && !ne && /* @__PURE__ */ e(
|
|
229
|
+
"button",
|
|
230
|
+
{
|
|
231
|
+
type: "button",
|
|
232
|
+
className: "nice-input__clear",
|
|
233
|
+
onClick: () => {
|
|
234
|
+
N(""), V("");
|
|
235
|
+
},
|
|
236
|
+
"aria-label": m("controls.clear", "Clear"),
|
|
237
|
+
children: /* @__PURE__ */ e(Ae, { name: "close", size: 14 })
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
),
|
|
245
|
+
Y && _e.length > 0 && q && B && pt(
|
|
246
|
+
/* @__PURE__ */ e(
|
|
247
|
+
"ul",
|
|
248
|
+
{
|
|
249
|
+
ref: le,
|
|
250
|
+
className: `nice-dropdown__list${j ? ` ${j}` : ""}`,
|
|
251
|
+
"data-theme": j === "nice-dark" ? "dark" : j === "nice-light" ? "light" : void 0,
|
|
252
|
+
role: "listbox",
|
|
253
|
+
style: {
|
|
254
|
+
position: "fixed",
|
|
255
|
+
left: q.left,
|
|
256
|
+
top: q.top,
|
|
257
|
+
width: q.width,
|
|
258
|
+
minWidth: q.width,
|
|
259
|
+
zIndex: 1e3,
|
|
260
|
+
// Stay transparent until the hook measures the real height (first open
|
|
261
|
+
// positions with an estimate that can flip above the trigger). opacity
|
|
262
|
+
// (not visibility) keeps the search input focusable while hidden.
|
|
263
|
+
opacity: Ce ? 1 : 0,
|
|
264
|
+
pointerEvents: Ce ? void 0 : "none"
|
|
265
|
+
},
|
|
266
|
+
children: Array.from(Ee.entries()).map(([d, C]) => /* @__PURE__ */ f(xn.Fragment, { children: [
|
|
267
|
+
d && /* @__PURE__ */ e("li", { className: "nice-dropdown__group-label", children: d }),
|
|
268
|
+
C.map((ke) => {
|
|
269
|
+
const g = _e.indexOf(ke) === O, v = A && H.includes(String(ke.value));
|
|
270
|
+
return /* @__PURE__ */ e(
|
|
271
|
+
"li",
|
|
272
|
+
{
|
|
273
|
+
role: "option",
|
|
274
|
+
className: `nice-dropdown__option ${g ? "nice-dropdown__option--active" : ""} ${v ? "nice-dropdown__option--selected" : ""}`,
|
|
275
|
+
onMouseDown: (Xe) => {
|
|
276
|
+
Xe.preventDefault(), Ye(ke);
|
|
277
|
+
},
|
|
278
|
+
"aria-selected": g,
|
|
279
|
+
children: ce ? ce(ke, _) : D ? /* @__PURE__ */ e(Zt, { text: ke.label, query: _ }) : ke.label
|
|
280
|
+
},
|
|
281
|
+
String(ke.value)
|
|
282
|
+
);
|
|
283
|
+
})
|
|
284
|
+
] }, d))
|
|
285
|
+
}
|
|
286
|
+
),
|
|
287
|
+
B
|
|
288
|
+
),
|
|
289
|
+
w && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
290
|
+
te === "right" && z && /* @__PURE__ */ e("div", { id: `${p}-error`, className: "nice-field__error", role: "alert", children: z }),
|
|
291
|
+
te === "right" && !z && I && /* @__PURE__ */ e("div", { id: `${p}-helper`, className: "nice-field__helper", children: I })
|
|
292
|
+
] }),
|
|
293
|
+
te !== "right" && z && /* @__PURE__ */ e("div", { id: `${p}-error`, className: "nice-field__error", role: "alert", children: z }),
|
|
294
|
+
te !== "right" && !z && I && /* @__PURE__ */ e("div", { id: `${p}-helper`, className: "nice-field__helper", children: I })
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
}, Xt = {
|
|
299
|
+
phone: "(999) 999-9999",
|
|
300
|
+
"credit-card": "9999 9999 9999 9999",
|
|
301
|
+
date: "99/99/9999",
|
|
302
|
+
ssn: "999-99-9999",
|
|
303
|
+
zip: "99-999",
|
|
304
|
+
time: "99:99",
|
|
305
|
+
iban: "aa99 9999 9999 9999 9999 9999"
|
|
306
|
+
};
|
|
307
|
+
function Wt(n) {
|
|
308
|
+
return [...n].map((i) => i === "9" ? { type: "digit" } : i === "a" ? { type: "letter" } : i === "*" ? { type: "alphanum" } : { type: "literal", literal: i });
|
|
309
|
+
}
|
|
310
|
+
function ei(n, i) {
|
|
311
|
+
return i.type === "digit" ? /\d/.test(n) : i.type === "letter" ? /[a-zA-Z]/.test(n) : i.type === "alphanum" ? /[a-zA-Z0-9]/.test(n) : !1;
|
|
312
|
+
}
|
|
313
|
+
function it(n, i, t) {
|
|
314
|
+
let o = 0, a = "";
|
|
315
|
+
for (const s of i)
|
|
316
|
+
s.type === "literal" ? a += s.literal : o < n.length ? (a += n[o], o++) : a += t;
|
|
317
|
+
return a;
|
|
318
|
+
}
|
|
319
|
+
function ni(n, i) {
|
|
320
|
+
return n.map((t) => t.type === "literal" ? t.literal : i).join("");
|
|
321
|
+
}
|
|
322
|
+
const ti = /* @__PURE__ */ Object.assign(
|
|
323
|
+
/* @__PURE__ */ bn(
|
|
324
|
+
({
|
|
325
|
+
label: n,
|
|
326
|
+
helperText: i,
|
|
327
|
+
error: t,
|
|
328
|
+
required: o,
|
|
329
|
+
disabled: a,
|
|
330
|
+
readOnly: s,
|
|
331
|
+
size: u = "md",
|
|
332
|
+
name: M,
|
|
333
|
+
id: w,
|
|
334
|
+
className: A,
|
|
335
|
+
style: ce,
|
|
336
|
+
value: D = "",
|
|
337
|
+
onChange: T,
|
|
338
|
+
onBlur: X,
|
|
339
|
+
onKeyDown: W,
|
|
340
|
+
mask: z,
|
|
341
|
+
maskPreset: I,
|
|
342
|
+
maskChar: $ = "_",
|
|
343
|
+
placeholder: Z,
|
|
344
|
+
showMaskAsPlaceholder: ne = !0,
|
|
345
|
+
clearable: J = !1,
|
|
346
|
+
autoFocus: pe,
|
|
347
|
+
labelPlacement: ae,
|
|
348
|
+
errorPlacement: k,
|
|
349
|
+
loading: U,
|
|
350
|
+
labelWidth: L,
|
|
351
|
+
controlWidth: E,
|
|
352
|
+
...de
|
|
353
|
+
}, te) => {
|
|
354
|
+
const { t: ee } = Qe(), R = un(w), S = be(null), [P, p] = Te(!1), m = z || (I ? Xt[I] : "") || "999", y = xn.useMemo(() => Wt(m), [m]), V = xn.useMemo(
|
|
355
|
+
() => it(D, y, $),
|
|
356
|
+
[D, y, $]
|
|
357
|
+
), H = P || D ? V : "", _ = Z ?? (ne ? ni(y, $) : void 0), N = F(
|
|
358
|
+
(re) => {
|
|
359
|
+
S.current = re, typeof te == "function" ? te(re) : te && (te.current = re);
|
|
360
|
+
},
|
|
361
|
+
[te]
|
|
362
|
+
), Y = F(
|
|
363
|
+
(re) => {
|
|
364
|
+
const le = it(re, y, $);
|
|
365
|
+
T?.(re, le);
|
|
366
|
+
},
|
|
367
|
+
[T, y, $]
|
|
368
|
+
), K = F(
|
|
369
|
+
(re) => {
|
|
370
|
+
const le = re.currentTarget, q = le.value, Ce = le.selectionStart ?? q.length;
|
|
371
|
+
let j = "", B = 0;
|
|
372
|
+
for (let oe = 0; oe < q.length && B < y.length; oe++) {
|
|
373
|
+
const _e = q[oe];
|
|
374
|
+
for (; B < y.length && y[B].type === "literal"; )
|
|
375
|
+
B++;
|
|
376
|
+
if (B >= y.length)
|
|
377
|
+
break;
|
|
378
|
+
ei(_e, y[B]) && (j += _e, B++);
|
|
379
|
+
}
|
|
380
|
+
Y(j), requestAnimationFrame(() => {
|
|
381
|
+
let oe = 0, _e = 0;
|
|
382
|
+
for (let Ee = 0; Ee < y.length; Ee++) {
|
|
383
|
+
if (y[Ee].type === "literal")
|
|
384
|
+
oe = Ee + 1;
|
|
385
|
+
else if (_e < j.length)
|
|
386
|
+
_e++, oe = Ee + 1;
|
|
387
|
+
else {
|
|
388
|
+
oe = Ee;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
if (oe >= Ce && _e >= j.length)
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
_e >= j.length && j.length > 0 && (oe = Math.min(oe, y.length)), le.setSelectionRange(oe, oe);
|
|
395
|
+
});
|
|
396
|
+
},
|
|
397
|
+
[y, Y]
|
|
398
|
+
), Q = F(
|
|
399
|
+
(re) => {
|
|
400
|
+
if (re.key === "Backspace" && D.length > 0) {
|
|
401
|
+
re.preventDefault();
|
|
402
|
+
const le = D.slice(0, -1);
|
|
403
|
+
Y(le);
|
|
404
|
+
}
|
|
405
|
+
W?.(re);
|
|
406
|
+
},
|
|
407
|
+
[D, Y, W]
|
|
408
|
+
), O = F(() => p(!0), []), fe = F(
|
|
409
|
+
(re) => {
|
|
410
|
+
p(!1), X?.(re);
|
|
411
|
+
},
|
|
412
|
+
[X]
|
|
413
|
+
), ue = F(() => {
|
|
414
|
+
Y(""), S.current?.focus();
|
|
415
|
+
}, [Y]);
|
|
416
|
+
return /* @__PURE__ */ f(
|
|
417
|
+
"div",
|
|
418
|
+
{
|
|
419
|
+
className: `nice-field nice-field--masked nice-field--${u} ${ae === "left" ? "nice-field--label-left" : ""} ${U ? "nice-field--loading" : ""} ${A || ""}`,
|
|
420
|
+
style: {
|
|
421
|
+
...ce,
|
|
422
|
+
...L != null && {
|
|
423
|
+
"--nice-field-label-width": typeof L == "number" ? `${L}px` : L
|
|
424
|
+
},
|
|
425
|
+
...E != null && {
|
|
426
|
+
"--nice-field-control-width": typeof E == "number" ? `${E}px` : E
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
"aria-busy": U || void 0,
|
|
430
|
+
children: [
|
|
431
|
+
n && /* @__PURE__ */ e(
|
|
432
|
+
"label",
|
|
433
|
+
{
|
|
434
|
+
htmlFor: R,
|
|
435
|
+
className: `nice-field__label ${o ? "nice-field__label--required" : ""}`,
|
|
436
|
+
children: n
|
|
437
|
+
}
|
|
438
|
+
),
|
|
439
|
+
/* @__PURE__ */ f("div", { className: "nice-field__control", children: [
|
|
440
|
+
/* @__PURE__ */ f(
|
|
441
|
+
"div",
|
|
442
|
+
{
|
|
443
|
+
className: `nice-input nice-input--${u} ${t ? "nice-input--error" : ""} ${a ? "nice-input--disabled" : ""} ${s ? "nice-input--readonly" : ""}`,
|
|
444
|
+
style: { width: "fit-content", minWidth: 0 },
|
|
445
|
+
children: [
|
|
446
|
+
/* @__PURE__ */ e(
|
|
447
|
+
"input",
|
|
448
|
+
{
|
|
449
|
+
ref: N,
|
|
450
|
+
id: R,
|
|
451
|
+
className: "nice-input__native nice-masked-input",
|
|
452
|
+
type: "text",
|
|
453
|
+
name: M,
|
|
454
|
+
value: H,
|
|
455
|
+
placeholder: _,
|
|
456
|
+
disabled: a || U,
|
|
457
|
+
readOnly: s,
|
|
458
|
+
autoFocus: pe,
|
|
459
|
+
style: {
|
|
460
|
+
width: `${m.length}ch`,
|
|
461
|
+
minWidth: 0,
|
|
462
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
463
|
+
fontVariantNumeric: "tabular-nums"
|
|
464
|
+
},
|
|
465
|
+
"aria-invalid": !!t,
|
|
466
|
+
"aria-describedby": t ? `${R}-error` : i ? `${R}-helper` : void 0,
|
|
467
|
+
onInput: K,
|
|
468
|
+
onChange: () => {
|
|
469
|
+
},
|
|
470
|
+
onKeyDown: Q,
|
|
471
|
+
onFocus: O,
|
|
472
|
+
onBlur: fe,
|
|
473
|
+
...de
|
|
474
|
+
}
|
|
475
|
+
),
|
|
476
|
+
J && D && /* @__PURE__ */ e(
|
|
477
|
+
"button",
|
|
478
|
+
{
|
|
479
|
+
type: "button",
|
|
480
|
+
className: "nice-input__clear",
|
|
481
|
+
disabled: a || s,
|
|
482
|
+
onClick: ue,
|
|
483
|
+
"aria-label": ee("controls.clear", "Clear"),
|
|
484
|
+
children: /* @__PURE__ */ e(Ae, { name: "close", size: 14 })
|
|
485
|
+
}
|
|
486
|
+
)
|
|
487
|
+
]
|
|
488
|
+
}
|
|
489
|
+
),
|
|
490
|
+
U && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
491
|
+
k === "right" && t && /* @__PURE__ */ e("div", { id: `${R}-error`, className: "nice-field__error", role: "alert", children: t }),
|
|
492
|
+
k === "right" && !t && i && /* @__PURE__ */ e("div", { id: `${R}-helper`, className: "nice-field__helper", children: i })
|
|
493
|
+
] }),
|
|
494
|
+
k !== "right" && t && /* @__PURE__ */ e("div", { id: `${R}-error`, className: "nice-field__error", role: "alert", children: t }),
|
|
495
|
+
k !== "right" && !t && i && /* @__PURE__ */ e("div", { id: `${R}-helper`, className: "nice-field__helper", children: i })
|
|
496
|
+
]
|
|
497
|
+
}
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
),
|
|
501
|
+
{ displayName: "NiceMaskedInput" }
|
|
502
|
+
), ii = [
|
|
503
|
+
{ id: "length", label: "At least 8 characters", test: (n) => n.length >= 8 },
|
|
504
|
+
{ id: "uppercase", label: "At least one uppercase letter", test: (n) => /[A-Z]/.test(n) },
|
|
505
|
+
{ id: "lowercase", label: "At least one lowercase letter", test: (n) => /[a-z]/.test(n) },
|
|
506
|
+
{ id: "digit", label: "At least one digit", test: (n) => /\d/.test(n) },
|
|
507
|
+
{ id: "special", label: "At least one special character", test: (n) => /[^a-zA-Z0-9]/.test(n) }
|
|
508
|
+
];
|
|
509
|
+
function ai(n, i) {
|
|
510
|
+
if (!n)
|
|
511
|
+
return { level: "none", passed: [], ratio: 0 };
|
|
512
|
+
const t = i.filter((s) => s.test(n)).map((s) => s.id), o = t.length / i.length;
|
|
513
|
+
let a = "weak";
|
|
514
|
+
return o >= 1 ? a = "strong" : o >= 0.75 ? a = "good" : o >= 0.5 && (a = "fair"), { level: a, passed: t, ratio: o };
|
|
515
|
+
}
|
|
516
|
+
const li = /* @__PURE__ */ Object.assign(
|
|
517
|
+
/* @__PURE__ */ bn(
|
|
518
|
+
({
|
|
519
|
+
label: n,
|
|
520
|
+
helperText: i,
|
|
521
|
+
error: t,
|
|
522
|
+
required: o,
|
|
523
|
+
disabled: a,
|
|
524
|
+
readOnly: s,
|
|
525
|
+
size: u = "md",
|
|
526
|
+
name: M,
|
|
527
|
+
id: w,
|
|
528
|
+
className: A,
|
|
529
|
+
style: ce,
|
|
530
|
+
value: D = "",
|
|
531
|
+
onChange: T,
|
|
532
|
+
onBlur: X,
|
|
533
|
+
onKeyDown: W,
|
|
534
|
+
placeholder: z,
|
|
535
|
+
maxLength: I,
|
|
536
|
+
showToggle: $ = !0,
|
|
537
|
+
showStrength: Z = !1,
|
|
538
|
+
strengthRules: ne,
|
|
539
|
+
validationPlacement: J = "bottom",
|
|
540
|
+
autoFocus: pe,
|
|
541
|
+
autoComplete: ae,
|
|
542
|
+
labelPlacement: k,
|
|
543
|
+
errorPlacement: U,
|
|
544
|
+
loading: L,
|
|
545
|
+
labelWidth: E,
|
|
546
|
+
controlWidth: de,
|
|
547
|
+
...te
|
|
548
|
+
}, ee) => {
|
|
549
|
+
const { t: R } = Qe(), S = un(w), [P, p] = Te(!1), m = ne ?? ii, y = ge(
|
|
550
|
+
() => Z ? ai(D, m) : null,
|
|
551
|
+
[Z, D, m]
|
|
552
|
+
), V = F(() => p((_) => !_), []), H = Z && y && D ? /* @__PURE__ */ f(
|
|
553
|
+
"div",
|
|
554
|
+
{
|
|
555
|
+
className: `nice-password__strength ${J === "right" ? "nice-password__strength--right" : ""}`,
|
|
556
|
+
children: [
|
|
557
|
+
/* @__PURE__ */ e("div", { className: "nice-password__meter", children: /* @__PURE__ */ e(
|
|
558
|
+
"div",
|
|
559
|
+
{
|
|
560
|
+
className: `nice-password__meter-fill nice-password__meter-fill--${y.level}`,
|
|
561
|
+
style: { width: `${y.ratio * 100}%` }
|
|
562
|
+
}
|
|
563
|
+
) }),
|
|
564
|
+
/* @__PURE__ */ e(
|
|
565
|
+
"span",
|
|
566
|
+
{
|
|
567
|
+
className: `nice-password__strength-label nice-password__strength-label--${y.level}`,
|
|
568
|
+
children: R(
|
|
569
|
+
`password.strength.${y.level}`,
|
|
570
|
+
y.level.charAt(0).toUpperCase() + y.level.slice(1)
|
|
571
|
+
)
|
|
572
|
+
}
|
|
573
|
+
),
|
|
574
|
+
/* @__PURE__ */ e("ul", { className: "nice-password__rules", children: m.map((_) => {
|
|
575
|
+
const N = y.passed.includes(_.id);
|
|
576
|
+
return /* @__PURE__ */ f(
|
|
577
|
+
"li",
|
|
578
|
+
{
|
|
579
|
+
className: `nice-password__rule ${N ? "nice-password__rule--passed" : ""}`,
|
|
580
|
+
children: [
|
|
581
|
+
/* @__PURE__ */ e("span", { className: "nice-password__rule-icon", children: /* @__PURE__ */ e(Ae, { name: N ? "check" : "close", size: 14 }) }),
|
|
582
|
+
_.label
|
|
583
|
+
]
|
|
584
|
+
},
|
|
585
|
+
_.id
|
|
586
|
+
);
|
|
587
|
+
}) })
|
|
588
|
+
]
|
|
589
|
+
}
|
|
590
|
+
) : null;
|
|
591
|
+
return /* @__PURE__ */ f(
|
|
592
|
+
"div",
|
|
593
|
+
{
|
|
594
|
+
className: `nice-field nice-field--${u} ${k === "left" ? "nice-field--label-left" : ""} ${L ? "nice-field--loading" : ""} ${A || ""}`,
|
|
595
|
+
style: {
|
|
596
|
+
...ce,
|
|
597
|
+
...E != null && {
|
|
598
|
+
"--nice-field-label-width": typeof E == "number" ? `${E}px` : E
|
|
599
|
+
},
|
|
600
|
+
...de != null && {
|
|
601
|
+
"--nice-field-control-width": typeof de == "number" ? `${de}px` : de
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
"aria-busy": L || void 0,
|
|
605
|
+
children: [
|
|
606
|
+
n && /* @__PURE__ */ e(
|
|
607
|
+
"label",
|
|
608
|
+
{
|
|
609
|
+
htmlFor: S,
|
|
610
|
+
className: `nice-field__label ${o ? "nice-field__label--required" : ""}`,
|
|
611
|
+
style: J === "right" && k === "left" ? (
|
|
612
|
+
/* When validation block sits to the right of the input it makes
|
|
613
|
+
`.nice-field__control` taller than a single input row. Without
|
|
614
|
+
this override the grid row centres the label against the whole
|
|
615
|
+
control (input + strength meter), pushing it visually too low.
|
|
616
|
+
`align-self: flex-start` + matching padding keeps the label
|
|
617
|
+
aligned with the input row only. */
|
|
618
|
+
{ alignSelf: "flex-start", paddingTop: 6 }
|
|
619
|
+
) : void 0,
|
|
620
|
+
children: n
|
|
621
|
+
}
|
|
622
|
+
),
|
|
623
|
+
/* @__PURE__ */ f(
|
|
624
|
+
"div",
|
|
625
|
+
{
|
|
626
|
+
className: "nice-field__control",
|
|
627
|
+
style: J === "right" ? { alignItems: "flex-start" } : void 0,
|
|
628
|
+
children: [
|
|
629
|
+
/* @__PURE__ */ f(
|
|
630
|
+
"div",
|
|
631
|
+
{
|
|
632
|
+
style: J === "right" ? { display: "flex", flexDirection: "column", flex: "1 1 auto", minWidth: 0 } : { display: "contents" },
|
|
633
|
+
children: [
|
|
634
|
+
/* @__PURE__ */ f(
|
|
635
|
+
"div",
|
|
636
|
+
{
|
|
637
|
+
className: `nice-input nice-input--${u} ${t ? "nice-input--error" : ""} ${a ? "nice-input--disabled" : ""} ${s ? "nice-input--readonly" : ""}`,
|
|
638
|
+
children: [
|
|
639
|
+
/* @__PURE__ */ e(
|
|
640
|
+
"input",
|
|
641
|
+
{
|
|
642
|
+
ref: ee,
|
|
643
|
+
id: S,
|
|
644
|
+
className: "nice-input__native",
|
|
645
|
+
type: P ? "text" : "password",
|
|
646
|
+
name: M,
|
|
647
|
+
value: D,
|
|
648
|
+
placeholder: z,
|
|
649
|
+
disabled: a || L,
|
|
650
|
+
readOnly: s,
|
|
651
|
+
maxLength: I,
|
|
652
|
+
autoFocus: pe,
|
|
653
|
+
autoComplete: ae,
|
|
654
|
+
"aria-invalid": !!t,
|
|
655
|
+
"aria-describedby": t ? `${S}-error` : i ? `${S}-helper` : void 0,
|
|
656
|
+
onChange: (_) => T?.(_.target.value),
|
|
657
|
+
onBlur: X,
|
|
658
|
+
onKeyDown: W,
|
|
659
|
+
...te
|
|
660
|
+
}
|
|
661
|
+
),
|
|
662
|
+
$ && /* @__PURE__ */ e(
|
|
663
|
+
"button",
|
|
664
|
+
{
|
|
665
|
+
type: "button",
|
|
666
|
+
className: "nice-password__toggle",
|
|
667
|
+
onClick: V,
|
|
668
|
+
disabled: a,
|
|
669
|
+
tabIndex: -1,
|
|
670
|
+
"aria-label": P ? R("password.hide", "Hide password") : R("password.show", "Show password"),
|
|
671
|
+
children: /* @__PURE__ */ e(Ae, { name: P ? "eye-off" : "eye", size: 18 })
|
|
672
|
+
}
|
|
673
|
+
)
|
|
674
|
+
]
|
|
675
|
+
}
|
|
676
|
+
),
|
|
677
|
+
J === "right" && U !== "right" && t && /* @__PURE__ */ e("div", { id: `${S}-error`, className: "nice-field__error", role: "alert", children: t }),
|
|
678
|
+
J === "right" && U !== "right" && !t && i && /* @__PURE__ */ e("div", { id: `${S}-helper`, className: "nice-field__helper", children: i })
|
|
679
|
+
]
|
|
680
|
+
}
|
|
681
|
+
),
|
|
682
|
+
L && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
683
|
+
J === "right" && H,
|
|
684
|
+
U === "right" && t && /* @__PURE__ */ e("div", { id: `${S}-error`, className: "nice-field__error", role: "alert", children: t }),
|
|
685
|
+
U === "right" && !t && i && /* @__PURE__ */ e("div", { id: `${S}-helper`, className: "nice-field__helper", children: i })
|
|
686
|
+
]
|
|
687
|
+
}
|
|
688
|
+
),
|
|
689
|
+
J !== "right" && H,
|
|
690
|
+
J !== "right" && U !== "right" && t && /* @__PURE__ */ e("div", { id: `${S}-error`, className: "nice-field__error", role: "alert", children: t }),
|
|
691
|
+
J !== "right" && U !== "right" && !t && i && /* @__PURE__ */ e("div", { id: `${S}-helper`, className: "nice-field__helper", children: i })
|
|
692
|
+
]
|
|
693
|
+
}
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
),
|
|
697
|
+
{ displayName: "NicePasswordInput" }
|
|
698
|
+
), ci = [], mt = ({
|
|
699
|
+
label: n,
|
|
700
|
+
helperText: i,
|
|
701
|
+
error: t,
|
|
702
|
+
required: o,
|
|
703
|
+
disabled: a,
|
|
704
|
+
size: s = "md",
|
|
705
|
+
name: u,
|
|
706
|
+
id: M,
|
|
707
|
+
className: w,
|
|
708
|
+
style: A,
|
|
709
|
+
accessMode: ce,
|
|
710
|
+
options: D = ci,
|
|
711
|
+
value: T,
|
|
712
|
+
onChange: X,
|
|
713
|
+
direction: W = "horizontal",
|
|
714
|
+
showKeyboardHints: z,
|
|
715
|
+
displayStyle: I,
|
|
716
|
+
labelPlacement: $,
|
|
717
|
+
errorPlacement: Z,
|
|
718
|
+
labelWidth: ne,
|
|
719
|
+
controlWidth: J,
|
|
720
|
+
loading: pe,
|
|
721
|
+
readOnly: ae
|
|
722
|
+
}) => {
|
|
723
|
+
Rn("toggle", I);
|
|
724
|
+
const k = dn(ce, M), U = k === "hidden";
|
|
725
|
+
(k === "disabled" || k === "readOnly") && (a = !0);
|
|
726
|
+
const { t: L } = Qe(), E = un(M), de = u || E, te = ge(
|
|
727
|
+
() => [
|
|
728
|
+
{ key: "ArrowUp", description: L("shortcuts.previousOption", "Previous option") },
|
|
729
|
+
{ key: "ArrowDown", description: L("shortcuts.nextOption", "Next option") },
|
|
730
|
+
{ key: "Space", description: L("shortcuts.select", "Select") }
|
|
731
|
+
],
|
|
732
|
+
[L]
|
|
733
|
+
);
|
|
734
|
+
return U ? null : /* @__PURE__ */ f(
|
|
735
|
+
"div",
|
|
736
|
+
{
|
|
737
|
+
className: `nice-field nice-field--inline nice-field--inline-block nice-field--${s} ${$ === "left" ? "nice-field--label-left" : ""} ${Z === "right" ? "nice-field--error-right" : ""} ${pe ? "nice-field--loading" : ""} ${w || ""}`,
|
|
738
|
+
style: {
|
|
739
|
+
...A,
|
|
740
|
+
...ne != null && {
|
|
741
|
+
"--nice-field-label-width": typeof ne == "number" ? `${ne}px` : ne
|
|
742
|
+
},
|
|
743
|
+
...J != null && {
|
|
744
|
+
"--nice-field-control-width": typeof J == "number" ? `${J}px` : J
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
role: "radiogroup",
|
|
748
|
+
"aria-labelledby": `${E}-label`,
|
|
749
|
+
"aria-busy": pe || void 0,
|
|
750
|
+
children: [
|
|
751
|
+
n && /* @__PURE__ */ f(
|
|
752
|
+
"span",
|
|
753
|
+
{
|
|
754
|
+
id: `${E}-label`,
|
|
755
|
+
className: `nice-field__label ${o ? "nice-field__label--required" : ""}`,
|
|
756
|
+
children: [
|
|
757
|
+
n,
|
|
758
|
+
z && /* @__PURE__ */ e(gn, { shortcuts: te, size: "sm" })
|
|
759
|
+
]
|
|
760
|
+
}
|
|
761
|
+
),
|
|
762
|
+
/* @__PURE__ */ f("div", { className: "nice-field__control", children: [
|
|
763
|
+
/* @__PURE__ */ e(
|
|
764
|
+
"div",
|
|
765
|
+
{
|
|
766
|
+
className: `nice-radio-group ${W === "vertical" ? "nice-radio-group--vertical" : ""}`,
|
|
767
|
+
children: D.map((ee) => /* @__PURE__ */ f(
|
|
768
|
+
"label",
|
|
769
|
+
{
|
|
770
|
+
className: `nice-radio ${a || ee.disabled || pe ? "nice-radio--disabled" : ""} ${ae ? "nice-radio--readonly" : ""}`,
|
|
771
|
+
children: [
|
|
772
|
+
/* @__PURE__ */ e(
|
|
773
|
+
"input",
|
|
774
|
+
{
|
|
775
|
+
type: "radio",
|
|
776
|
+
className: "nice-radio__input",
|
|
777
|
+
name: de,
|
|
778
|
+
value: ee.value,
|
|
779
|
+
checked: T === ee.value,
|
|
780
|
+
disabled: a || ee.disabled || pe,
|
|
781
|
+
"aria-readonly": ae || void 0,
|
|
782
|
+
onChange: () => {
|
|
783
|
+
ae || X?.(ee.value);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
),
|
|
787
|
+
/* @__PURE__ */ e("span", { className: "nice-radio__circle", children: /* @__PURE__ */ e("span", { className: "nice-radio__dot" }) }),
|
|
788
|
+
/* @__PURE__ */ e("span", { children: ee.label })
|
|
789
|
+
]
|
|
790
|
+
},
|
|
791
|
+
ee.value
|
|
792
|
+
))
|
|
793
|
+
}
|
|
794
|
+
),
|
|
795
|
+
pe && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
796
|
+
Z === "right" && t && /* @__PURE__ */ e("div", { id: `${E}-error`, className: "nice-field__error", role: "alert", children: t }),
|
|
797
|
+
Z === "right" && !t && i && /* @__PURE__ */ e("div", { id: `${E}-helper`, className: "nice-field__helper", children: i })
|
|
798
|
+
] }),
|
|
799
|
+
Z !== "right" && t && /* @__PURE__ */ e("div", { id: `${E}-error`, className: "nice-field__error", role: "alert", children: t }),
|
|
800
|
+
Z !== "right" && !t && i && /* @__PURE__ */ e("div", { id: `${E}-helper`, className: "nice-field__helper", children: i })
|
|
801
|
+
]
|
|
802
|
+
}
|
|
803
|
+
);
|
|
804
|
+
}, Ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
805
|
+
__proto__: null,
|
|
806
|
+
NiceRadioGroup: mt
|
|
807
|
+
}, Symbol.toStringTag, { value: "Module" })), ri = ({
|
|
808
|
+
filled: n,
|
|
809
|
+
size: i
|
|
810
|
+
}) => /* @__PURE__ */ f(
|
|
811
|
+
"svg",
|
|
812
|
+
{
|
|
813
|
+
width: i,
|
|
814
|
+
height: i,
|
|
815
|
+
viewBox: "0 0 24 24",
|
|
816
|
+
fill: "none",
|
|
817
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
818
|
+
children: [
|
|
819
|
+
n === "half" && /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ f("linearGradient", { id: "halfGrad", children: [
|
|
820
|
+
/* @__PURE__ */ e("stop", { offset: "50%", stopColor: "currentColor" }),
|
|
821
|
+
/* @__PURE__ */ e("stop", { offset: "50%", stopColor: "transparent" })
|
|
822
|
+
] }) }),
|
|
823
|
+
/* @__PURE__ */ e(
|
|
824
|
+
"path",
|
|
825
|
+
{
|
|
826
|
+
d: "M12 2l3.09 6.26L22 9.27l-5 4.87L18.18 22 12 18.27 5.82 22 7 14.14l-5-4.87 6.91-1.01L12 2z",
|
|
827
|
+
fill: n === "full" ? "currentColor" : n === "half" ? "url(#halfGrad)" : "none",
|
|
828
|
+
stroke: "currentColor",
|
|
829
|
+
strokeWidth: "1.5",
|
|
830
|
+
strokeLinejoin: "round"
|
|
831
|
+
}
|
|
832
|
+
)
|
|
833
|
+
]
|
|
834
|
+
}
|
|
835
|
+
), oi = {
|
|
836
|
+
xxs: 10,
|
|
837
|
+
xs: 14,
|
|
838
|
+
sm: 18,
|
|
839
|
+
md: 22,
|
|
840
|
+
lg: 28,
|
|
841
|
+
xl: 34,
|
|
842
|
+
xxl: 42,
|
|
843
|
+
small: 18,
|
|
844
|
+
medium: 22,
|
|
845
|
+
large: 28
|
|
846
|
+
}, ht = /* @__PURE__ */ Object.assign(
|
|
847
|
+
/* @__PURE__ */ bn(
|
|
848
|
+
({
|
|
849
|
+
value: n = 0,
|
|
850
|
+
onChange: i,
|
|
851
|
+
count: t = 5,
|
|
852
|
+
half: o = !1,
|
|
853
|
+
readOnly: a = !1,
|
|
854
|
+
disabled: s = !1,
|
|
855
|
+
size: u = "md",
|
|
856
|
+
label: M,
|
|
857
|
+
icon: w,
|
|
858
|
+
name: A,
|
|
859
|
+
error: ce,
|
|
860
|
+
helperText: D,
|
|
861
|
+
required: T,
|
|
862
|
+
id: X,
|
|
863
|
+
className: W,
|
|
864
|
+
style: z,
|
|
865
|
+
labelPlacement: I,
|
|
866
|
+
errorPlacement: $,
|
|
867
|
+
labelWidth: Z,
|
|
868
|
+
controlWidth: ne,
|
|
869
|
+
valuePlacement: J = "none",
|
|
870
|
+
valueTemplate: pe,
|
|
871
|
+
loading: ae,
|
|
872
|
+
...k
|
|
873
|
+
}, U) => {
|
|
874
|
+
const { t: L } = Qe(), E = un(X), [de, te] = Te(null), ee = oi[u], R = !a && !s && !ae, S = de ?? n, P = (_) => S >= _ + 1 ? "full" : o && S >= _ + 0.5 ? "half" : "empty", p = F(
|
|
875
|
+
(_, N) => {
|
|
876
|
+
if (!R)
|
|
877
|
+
return;
|
|
878
|
+
const Y = N && o ? _ + 0.5 : _ + 1;
|
|
879
|
+
i?.(Y === n ? 0 : Y);
|
|
880
|
+
},
|
|
881
|
+
[R, o, i, n]
|
|
882
|
+
), m = F(
|
|
883
|
+
(_, N) => {
|
|
884
|
+
if (R)
|
|
885
|
+
if (o) {
|
|
886
|
+
const Y = N.currentTarget.getBoundingClientRect(), K = N.clientX - Y.left < Y.width / 2;
|
|
887
|
+
te(K ? _ + 0.5 : _ + 1);
|
|
888
|
+
} else
|
|
889
|
+
te(_ + 1);
|
|
890
|
+
},
|
|
891
|
+
[R, o]
|
|
892
|
+
), y = F(() => {
|
|
893
|
+
R && te(null);
|
|
894
|
+
}, [R]), V = F(
|
|
895
|
+
(_) => {
|
|
896
|
+
if (!R)
|
|
897
|
+
return;
|
|
898
|
+
const N = o ? 0.5 : 1;
|
|
899
|
+
if (_.key === "ArrowRight" || _.key === "ArrowUp") {
|
|
900
|
+
_.preventDefault();
|
|
901
|
+
const Y = Math.min(t, n + N);
|
|
902
|
+
i?.(Y);
|
|
903
|
+
} else if (_.key === "ArrowLeft" || _.key === "ArrowDown") {
|
|
904
|
+
_.preventDefault();
|
|
905
|
+
const Y = Math.max(0, n - N);
|
|
906
|
+
i?.(Y);
|
|
907
|
+
}
|
|
908
|
+
},
|
|
909
|
+
[R, o, t, n, i]
|
|
910
|
+
), H = pe ? pe.replace("{value}", String(n)) : String(n);
|
|
911
|
+
return /* @__PURE__ */ f(
|
|
912
|
+
"div",
|
|
913
|
+
{
|
|
914
|
+
className: `nice-field nice-field--${u} ${I === "left" ? "nice-field--label-left" : ""} ${ae ? "nice-field--loading" : ""} ${W || ""}`,
|
|
915
|
+
style: {
|
|
916
|
+
...z,
|
|
917
|
+
...Z != null && {
|
|
918
|
+
"--nice-field-label-width": typeof Z == "number" ? `${Z}px` : Z
|
|
919
|
+
},
|
|
920
|
+
...ne != null && {
|
|
921
|
+
"--nice-field-control-width": typeof ne == "number" ? `${ne}px` : ne
|
|
922
|
+
}
|
|
923
|
+
},
|
|
924
|
+
"aria-busy": ae || void 0,
|
|
925
|
+
...k,
|
|
926
|
+
children: [
|
|
927
|
+
M && /* @__PURE__ */ e(
|
|
928
|
+
"label",
|
|
929
|
+
{
|
|
930
|
+
htmlFor: E,
|
|
931
|
+
className: `nice-field__label ${T ? "nice-field__label--required" : ""}`,
|
|
932
|
+
children: M
|
|
933
|
+
}
|
|
934
|
+
),
|
|
935
|
+
/* @__PURE__ */ f("div", { className: "nice-field__control", children: [
|
|
936
|
+
/* @__PURE__ */ f(
|
|
937
|
+
"div",
|
|
938
|
+
{
|
|
939
|
+
ref: U,
|
|
940
|
+
id: E,
|
|
941
|
+
className: `nice-rating nice-rating--${u} ${s ? "nice-rating--disabled" : ""} ${a ? "nice-rating--readonly" : ""}`,
|
|
942
|
+
role: "slider",
|
|
943
|
+
"aria-valuenow": n,
|
|
944
|
+
"aria-valuemin": 0,
|
|
945
|
+
"aria-valuemax": t,
|
|
946
|
+
"aria-label": M || L("controls.rating", "Rating"),
|
|
947
|
+
"aria-invalid": !!ce,
|
|
948
|
+
tabIndex: R ? 0 : -1,
|
|
949
|
+
onMouseLeave: y,
|
|
950
|
+
onKeyDown: V,
|
|
951
|
+
children: [
|
|
952
|
+
A && /* @__PURE__ */ e("input", { type: "hidden", name: A, value: n }),
|
|
953
|
+
Array.from({ length: t }, (_, N) => {
|
|
954
|
+
const Y = P(N);
|
|
955
|
+
return /* @__PURE__ */ e(
|
|
956
|
+
"span",
|
|
957
|
+
{
|
|
958
|
+
className: `nice-rating__star nice-rating__star--${Y}`,
|
|
959
|
+
onClick: (K) => {
|
|
960
|
+
if (!R)
|
|
961
|
+
return;
|
|
962
|
+
const Q = K.currentTarget.getBoundingClientRect(), O = o && K.clientX - Q.left < Q.width / 2;
|
|
963
|
+
p(N, O);
|
|
964
|
+
},
|
|
965
|
+
onMouseMove: (K) => m(N, K),
|
|
966
|
+
"aria-label": `${N + 1} ${L("controls.star", "star")}`,
|
|
967
|
+
children: w ? w(Y) : /* @__PURE__ */ e(ri, { filled: Y, size: ee })
|
|
968
|
+
},
|
|
969
|
+
N
|
|
970
|
+
);
|
|
971
|
+
}),
|
|
972
|
+
ae && /* @__PURE__ */ e("span", { className: "nice-rating__loading", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) })
|
|
973
|
+
]
|
|
974
|
+
}
|
|
975
|
+
),
|
|
976
|
+
J === "right" && !ae && /* @__PURE__ */ e("span", { className: "nice-rating__value", children: H }),
|
|
977
|
+
J === "bottom" && !ae && /* @__PURE__ */ e("div", { className: "nice-rating__value nice-rating__value--bottom", children: H }),
|
|
978
|
+
$ === "right" && ce && /* @__PURE__ */ e("div", { id: `${E}-error`, className: "nice-field__error", role: "alert", children: ce }),
|
|
979
|
+
$ === "right" && !ce && D && /* @__PURE__ */ e("div", { id: `${E}-helper`, className: "nice-field__helper", children: D })
|
|
980
|
+
] }),
|
|
981
|
+
$ !== "right" && ce && /* @__PURE__ */ e("div", { id: `${E}-error`, className: "nice-field__error", role: "alert", children: ce }),
|
|
982
|
+
$ !== "right" && !ce && D && /* @__PURE__ */ e("div", { id: `${E}-helper`, className: "nice-field__helper", children: D })
|
|
983
|
+
]
|
|
984
|
+
}
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
),
|
|
988
|
+
{ displayName: "NiceRating" }
|
|
989
|
+
), Qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
990
|
+
__proto__: null,
|
|
991
|
+
NiceRating: ht
|
|
992
|
+
}, Symbol.toStringTag, { value: "Module" })), gt = /* @__PURE__ */ Object.assign(
|
|
993
|
+
/* @__PURE__ */ bn(
|
|
994
|
+
({
|
|
995
|
+
label: n,
|
|
996
|
+
helperText: i,
|
|
997
|
+
error: t,
|
|
998
|
+
required: o,
|
|
999
|
+
disabled: a,
|
|
1000
|
+
id: s,
|
|
1001
|
+
className: u,
|
|
1002
|
+
style: M,
|
|
1003
|
+
accessMode: w,
|
|
1004
|
+
value: A = 0,
|
|
1005
|
+
onChange: ce,
|
|
1006
|
+
min: D = 0,
|
|
1007
|
+
max: T = 100,
|
|
1008
|
+
step: X = 1,
|
|
1009
|
+
showValue: W = !0,
|
|
1010
|
+
showMinMax: z = !1,
|
|
1011
|
+
formatValue: I,
|
|
1012
|
+
showKeyboardHints: $,
|
|
1013
|
+
displayStyle: Z,
|
|
1014
|
+
size: ne = "md",
|
|
1015
|
+
labelPlacement: J,
|
|
1016
|
+
errorPlacement: pe,
|
|
1017
|
+
labelWidth: ae,
|
|
1018
|
+
controlWidth: k,
|
|
1019
|
+
loading: U,
|
|
1020
|
+
showTicks: L = !1,
|
|
1021
|
+
tickInterval: E,
|
|
1022
|
+
maxTicks: de = 21,
|
|
1023
|
+
showTickLabels: te = !1
|
|
1024
|
+
}, ee) => {
|
|
1025
|
+
Rn("input", Z);
|
|
1026
|
+
const R = dn(w, s), S = R === "hidden";
|
|
1027
|
+
(R === "disabled" || R === "readOnly") && (a = !0);
|
|
1028
|
+
const { t: P } = Qe(), p = un(s), m = ge(() => (A - D) / (T - D) * 100, [A, D, T]), y = I ? I(A) : A.toString(), V = ge(() => {
|
|
1029
|
+
if (!L)
|
|
1030
|
+
return [];
|
|
1031
|
+
const N = T - D;
|
|
1032
|
+
if (N <= 0)
|
|
1033
|
+
return [D, T];
|
|
1034
|
+
let Y = E ?? X, K = Math.floor(N / Y) + 1;
|
|
1035
|
+
return K > de && (Y = N / (de - 1), K = de), Array.from({ length: K }, (Q, O) => {
|
|
1036
|
+
const fe = D + O * Y;
|
|
1037
|
+
return O === K - 1 ? T : fe;
|
|
1038
|
+
});
|
|
1039
|
+
}, [L, D, T, X, E, de]), H = ge(
|
|
1040
|
+
() => [
|
|
1041
|
+
Ve.increment,
|
|
1042
|
+
Ve.decrement,
|
|
1043
|
+
Ve.first,
|
|
1044
|
+
Ve.last,
|
|
1045
|
+
Ve.incrementBig,
|
|
1046
|
+
Ve.decrementBig
|
|
1047
|
+
],
|
|
1048
|
+
[]
|
|
1049
|
+
), _ = J === "left";
|
|
1050
|
+
return S ? null : /* @__PURE__ */ f(
|
|
1051
|
+
"div",
|
|
1052
|
+
{
|
|
1053
|
+
className: `nice-field nice-field--${ne} ${_ ? "nice-field--label-left" : ""} ${U ? "nice-field--loading" : ""} ${u || ""}`,
|
|
1054
|
+
style: {
|
|
1055
|
+
...M,
|
|
1056
|
+
...ae != null && {
|
|
1057
|
+
"--nice-field-label-width": typeof ae == "number" ? `${ae}px` : ae
|
|
1058
|
+
},
|
|
1059
|
+
...k != null && {
|
|
1060
|
+
"--nice-field-control-width": typeof k == "number" ? `${k}px` : k
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
"aria-busy": U || void 0,
|
|
1064
|
+
children: [
|
|
1065
|
+
_ ? n && /* @__PURE__ */ f(
|
|
1066
|
+
"label",
|
|
1067
|
+
{
|
|
1068
|
+
htmlFor: p,
|
|
1069
|
+
className: `nice-field__label ${o ? "nice-field__label--required" : ""}`,
|
|
1070
|
+
children: [
|
|
1071
|
+
n,
|
|
1072
|
+
$ && /* @__PURE__ */ e(gn, { shortcuts: H, size: "sm" })
|
|
1073
|
+
]
|
|
1074
|
+
}
|
|
1075
|
+
) : (n || W || $) && /* @__PURE__ */ f("div", { className: "nice-slider__header", children: [
|
|
1076
|
+
n ? /* @__PURE__ */ f(
|
|
1077
|
+
"label",
|
|
1078
|
+
{
|
|
1079
|
+
htmlFor: p,
|
|
1080
|
+
className: `nice-field__label ${o ? "nice-field__label--required" : ""}`,
|
|
1081
|
+
children: [
|
|
1082
|
+
n,
|
|
1083
|
+
$ && /* @__PURE__ */ e(gn, { shortcuts: H, size: "sm" })
|
|
1084
|
+
]
|
|
1085
|
+
}
|
|
1086
|
+
) : /* @__PURE__ */ e("span", {}),
|
|
1087
|
+
W && /* @__PURE__ */ e("span", { className: "nice-slider__value nice-slider__value--header", children: y })
|
|
1088
|
+
] }),
|
|
1089
|
+
/* @__PURE__ */ f("div", { className: "nice-field__control nice-field__control--slider", children: [
|
|
1090
|
+
/* @__PURE__ */ f(
|
|
1091
|
+
"div",
|
|
1092
|
+
{
|
|
1093
|
+
className: `nice-slider ${a || U ? "nice-slider--disabled" : ""} ${L ? "nice-slider--with-ticks" : ""}`,
|
|
1094
|
+
children: [
|
|
1095
|
+
/* @__PURE__ */ f("div", { className: "nice-slider__track-wrapper", children: [
|
|
1096
|
+
/* @__PURE__ */ e("div", { className: "nice-slider__track", children: /* @__PURE__ */ e("div", { className: "nice-slider__fill", style: { width: `${m}%` } }) }),
|
|
1097
|
+
L && V.length > 0 && /* @__PURE__ */ e("div", { className: "nice-slider__ticks", "aria-hidden": "true", children: V.map((N, Y) => {
|
|
1098
|
+
const K = (N - D) / (T - D) * 100, Q = N <= A;
|
|
1099
|
+
return /* @__PURE__ */ e(
|
|
1100
|
+
"span",
|
|
1101
|
+
{
|
|
1102
|
+
className: `nice-slider__tick ${Q ? "nice-slider__tick--active" : ""}`,
|
|
1103
|
+
style: { left: `${K}%` },
|
|
1104
|
+
children: te && /* @__PURE__ */ e("span", { className: "nice-slider__tick-label", children: I ? I(N) : N })
|
|
1105
|
+
},
|
|
1106
|
+
Y
|
|
1107
|
+
);
|
|
1108
|
+
}) }),
|
|
1109
|
+
/* @__PURE__ */ e(
|
|
1110
|
+
"input",
|
|
1111
|
+
{
|
|
1112
|
+
ref: ee,
|
|
1113
|
+
id: p,
|
|
1114
|
+
type: "range",
|
|
1115
|
+
className: "nice-slider__native",
|
|
1116
|
+
min: D,
|
|
1117
|
+
max: T,
|
|
1118
|
+
step: X,
|
|
1119
|
+
value: A,
|
|
1120
|
+
disabled: a || U,
|
|
1121
|
+
"aria-valuenow": A,
|
|
1122
|
+
"aria-valuemin": D,
|
|
1123
|
+
"aria-valuemax": T,
|
|
1124
|
+
onChange: (N) => ce?.(parseFloat(N.target.value))
|
|
1125
|
+
}
|
|
1126
|
+
),
|
|
1127
|
+
/* @__PURE__ */ e("div", { className: "nice-slider__thumb-visual", style: { left: `${m}%` } })
|
|
1128
|
+
] }),
|
|
1129
|
+
z && /* @__PURE__ */ f("div", { className: "nice-slider__labels", children: [
|
|
1130
|
+
/* @__PURE__ */ e("span", { children: I ? I(D) : D }),
|
|
1131
|
+
/* @__PURE__ */ e("span", { children: I ? I(T) : T })
|
|
1132
|
+
] })
|
|
1133
|
+
]
|
|
1134
|
+
}
|
|
1135
|
+
),
|
|
1136
|
+
_ && W && /* @__PURE__ */ e("span", { className: "nice-slider__value nice-slider__value--inline", children: y }),
|
|
1137
|
+
U && /* @__PURE__ */ e("span", { className: "nice-field__spinner nice-field__spinner--slider", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
1138
|
+
pe === "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error nice-field__error--slider", role: "alert", children: t }),
|
|
1139
|
+
pe === "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper nice-field__helper--slider", children: i })
|
|
1140
|
+
] }),
|
|
1141
|
+
pe !== "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
|
|
1142
|
+
pe !== "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: i })
|
|
1143
|
+
]
|
|
1144
|
+
}
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
),
|
|
1148
|
+
{ displayName: "NiceSlider" }
|
|
1149
|
+
), Xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1150
|
+
__proto__: null,
|
|
1151
|
+
NiceSlider: gt
|
|
1152
|
+
}, Symbol.toStringTag, { value: "Module" })), si = ({
|
|
1153
|
+
options: n,
|
|
1154
|
+
suggestions: i,
|
|
1155
|
+
value: t,
|
|
1156
|
+
defaultValue: o,
|
|
1157
|
+
onChange: a,
|
|
1158
|
+
searchable: s = !0,
|
|
1159
|
+
clearable: u,
|
|
1160
|
+
maxTags: M,
|
|
1161
|
+
allowCustom: w,
|
|
1162
|
+
placeholder: A,
|
|
1163
|
+
label: ce,
|
|
1164
|
+
error: D,
|
|
1165
|
+
helperText: T,
|
|
1166
|
+
required: X,
|
|
1167
|
+
disabled: W,
|
|
1168
|
+
size: z = "md",
|
|
1169
|
+
loading: I,
|
|
1170
|
+
id: $,
|
|
1171
|
+
className: Z,
|
|
1172
|
+
style: ne,
|
|
1173
|
+
accessMode: J,
|
|
1174
|
+
showKeyboardHints: pe,
|
|
1175
|
+
labelPlacement: ae,
|
|
1176
|
+
errorPlacement: k,
|
|
1177
|
+
labelWidth: U,
|
|
1178
|
+
controlWidth: L,
|
|
1179
|
+
readOnly: E,
|
|
1180
|
+
autoExpand: de = !1
|
|
1181
|
+
}) => {
|
|
1182
|
+
const te = dn(J, $), ee = te === "hidden";
|
|
1183
|
+
(te === "disabled" || te === "readOnly") && (W = !0);
|
|
1184
|
+
const R = un($), { t: S } = Qe(), [P, p] = Te(!1), [m, y] = Te(""), V = be(null), H = be(null);
|
|
1185
|
+
xt(V, () => p(!1));
|
|
1186
|
+
const _ = ge(
|
|
1187
|
+
() => [
|
|
1188
|
+
Ve.submit,
|
|
1189
|
+
Ve.cancel,
|
|
1190
|
+
{ key: "Backspace", description: S("shortcuts.removeLastTag", "Remove last tag") }
|
|
1191
|
+
],
|
|
1192
|
+
[S]
|
|
1193
|
+
), N = ge(() => Array.isArray(n) && n.length > 0 ? n : Array.isArray(i) ? i.map((q) => ({ label: q, value: q })) : [], [n, i]), [Y, K] = dt({
|
|
1194
|
+
value: t,
|
|
1195
|
+
defaultValue: o,
|
|
1196
|
+
fallbackValue: [],
|
|
1197
|
+
onChange: a,
|
|
1198
|
+
componentName: "NiceTagBox"
|
|
1199
|
+
}), Q = ge(() => Array.isArray(Y) ? Y : [], [Y]), O = ge(() => {
|
|
1200
|
+
let q = N.filter((Ce) => !Q.includes(String(Ce.value)));
|
|
1201
|
+
if (m) {
|
|
1202
|
+
const Ce = m.toLowerCase();
|
|
1203
|
+
q = q.filter((j) => j.label.toLowerCase().includes(Ce));
|
|
1204
|
+
}
|
|
1205
|
+
return q;
|
|
1206
|
+
}, [N, Q, m]), fe = F(
|
|
1207
|
+
(q) => {
|
|
1208
|
+
M && Q.length >= M || (Q.includes(q) || K([...Q, q]), y(""));
|
|
1209
|
+
},
|
|
1210
|
+
[Q, K, M]
|
|
1211
|
+
), ue = F(
|
|
1212
|
+
(q) => {
|
|
1213
|
+
K(Q.filter((Ce) => Ce !== q));
|
|
1214
|
+
},
|
|
1215
|
+
[Q, K]
|
|
1216
|
+
), re = (q) => {
|
|
1217
|
+
E || (q.key === "Backspace" && !m && Q.length > 0 ? ue(Q[Q.length - 1]) : q.key === "Enter" && m ? (q.preventDefault(), O.length > 0 ? fe(String(O[0].value)) : w && fe(m)) : q.key === "Escape" && p(!1));
|
|
1218
|
+
}, le = (q) => N.find((Ce) => String(Ce.value) === q)?.label ?? q;
|
|
1219
|
+
return ee ? null : /* @__PURE__ */ f(
|
|
1220
|
+
"div",
|
|
1221
|
+
{
|
|
1222
|
+
className: `nice-field nice-field--${z} ${ae === "left" ? "nice-field--label-left" : ""} ${I ? "nice-field--loading" : ""} ${Z || ""}`,
|
|
1223
|
+
style: {
|
|
1224
|
+
...ne,
|
|
1225
|
+
...U != null && {
|
|
1226
|
+
"--nice-field-label-width": typeof U == "number" ? `${U}px` : U
|
|
1227
|
+
},
|
|
1228
|
+
...L != null && {
|
|
1229
|
+
"--nice-field-control-width": typeof L == "number" ? `${L}px` : L
|
|
1230
|
+
}
|
|
1231
|
+
},
|
|
1232
|
+
ref: V,
|
|
1233
|
+
"aria-busy": I || void 0,
|
|
1234
|
+
children: [
|
|
1235
|
+
ce && /* @__PURE__ */ f(
|
|
1236
|
+
"label",
|
|
1237
|
+
{
|
|
1238
|
+
className: `nice-field__label ${X ? "nice-field__label--required" : ""}`,
|
|
1239
|
+
htmlFor: R,
|
|
1240
|
+
children: [
|
|
1241
|
+
ce,
|
|
1242
|
+
pe && /* @__PURE__ */ e(gn, { shortcuts: _, size: "sm" })
|
|
1243
|
+
]
|
|
1244
|
+
}
|
|
1245
|
+
),
|
|
1246
|
+
/* @__PURE__ */ f("div", { className: "nice-field__control", children: [
|
|
1247
|
+
/* @__PURE__ */ f(
|
|
1248
|
+
"div",
|
|
1249
|
+
{
|
|
1250
|
+
className: `nice-tagbox nice-tagbox--${z} ${de ? "nice-tagbox--expand" : "nice-tagbox--fixed"} ${D ? "nice-tagbox--error" : ""} ${W ? "nice-tagbox--disabled" : ""} ${E ? "nice-tagbox--readonly" : ""}`,
|
|
1251
|
+
onClick: () => {
|
|
1252
|
+
!W && !I && !E && (p(!0), H.current?.focus());
|
|
1253
|
+
},
|
|
1254
|
+
style: {
|
|
1255
|
+
position: "relative",
|
|
1256
|
+
cursor: W || I ? "not-allowed" : E ? "default" : "text"
|
|
1257
|
+
},
|
|
1258
|
+
children: [
|
|
1259
|
+
/* @__PURE__ */ f("div", { className: "nice-tagbox__tags", children: [
|
|
1260
|
+
Q.map((q) => /* @__PURE__ */ f("span", { className: "nice-tag nice-tagbox__tag", children: [
|
|
1261
|
+
le(q),
|
|
1262
|
+
!W && !E && /* @__PURE__ */ e(
|
|
1263
|
+
"button",
|
|
1264
|
+
{
|
|
1265
|
+
type: "button",
|
|
1266
|
+
className: "nice-tag__remove",
|
|
1267
|
+
onClick: (Ce) => {
|
|
1268
|
+
Ce.stopPropagation(), ue(q);
|
|
1269
|
+
},
|
|
1270
|
+
"aria-label": S("controls.remove", "Remove"),
|
|
1271
|
+
children: /* @__PURE__ */ e(Ae, { name: "close", size: 14 })
|
|
1272
|
+
}
|
|
1273
|
+
)
|
|
1274
|
+
] }, q)),
|
|
1275
|
+
s && /* @__PURE__ */ e(
|
|
1276
|
+
"input",
|
|
1277
|
+
{
|
|
1278
|
+
ref: H,
|
|
1279
|
+
id: R,
|
|
1280
|
+
type: "text",
|
|
1281
|
+
className: "nice-tagbox__input nice-input__native",
|
|
1282
|
+
value: m,
|
|
1283
|
+
onChange: (q) => {
|
|
1284
|
+
y(q.target.value), p(!0);
|
|
1285
|
+
},
|
|
1286
|
+
onFocus: () => p(!0),
|
|
1287
|
+
onKeyDown: re,
|
|
1288
|
+
placeholder: Q.length === 0 ? A || S("controls.select", "Select...") : "",
|
|
1289
|
+
disabled: W || I,
|
|
1290
|
+
readOnly: E,
|
|
1291
|
+
autoComplete: "off",
|
|
1292
|
+
style: {
|
|
1293
|
+
border: "none",
|
|
1294
|
+
outline: "none",
|
|
1295
|
+
background: "transparent",
|
|
1296
|
+
color: "inherit",
|
|
1297
|
+
flex: 1,
|
|
1298
|
+
minWidth: 80,
|
|
1299
|
+
padding: 0,
|
|
1300
|
+
font: "inherit",
|
|
1301
|
+
caretColor: "var(--nice-color-primary)"
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
)
|
|
1305
|
+
] }),
|
|
1306
|
+
u && Q.length > 0 && !W && !E && /* @__PURE__ */ e(
|
|
1307
|
+
"button",
|
|
1308
|
+
{
|
|
1309
|
+
type: "button",
|
|
1310
|
+
className: "nice-input__clear",
|
|
1311
|
+
onClick: (q) => {
|
|
1312
|
+
q.stopPropagation(), K([]);
|
|
1313
|
+
},
|
|
1314
|
+
"aria-label": S("controls.clear", "Clear"),
|
|
1315
|
+
children: /* @__PURE__ */ e(Ae, { name: "close", size: 14 })
|
|
1316
|
+
}
|
|
1317
|
+
),
|
|
1318
|
+
P && (O.length > 0 || w && m) && /* @__PURE__ */ f("ul", { className: "nice-dropdown__list nice-tagbox__dropdown", role: "listbox", children: [
|
|
1319
|
+
O.map((q) => /* @__PURE__ */ e(
|
|
1320
|
+
"li",
|
|
1321
|
+
{
|
|
1322
|
+
role: "option",
|
|
1323
|
+
className: "nice-dropdown__option",
|
|
1324
|
+
onMouseDown: (Ce) => {
|
|
1325
|
+
Ce.preventDefault(), fe(String(q.value));
|
|
1326
|
+
},
|
|
1327
|
+
children: q.label
|
|
1328
|
+
},
|
|
1329
|
+
String(q.value)
|
|
1330
|
+
)),
|
|
1331
|
+
w && m && !O.some((q) => String(q.value).toLowerCase() === m.toLowerCase()) && /* @__PURE__ */ f(
|
|
1332
|
+
"li",
|
|
1333
|
+
{
|
|
1334
|
+
role: "option",
|
|
1335
|
+
className: "nice-dropdown__option nice-dropdown__option--add",
|
|
1336
|
+
onMouseDown: (q) => {
|
|
1337
|
+
q.preventDefault(), fe(m);
|
|
1338
|
+
},
|
|
1339
|
+
children: [
|
|
1340
|
+
"+ ",
|
|
1341
|
+
S("controls.add", "Add"),
|
|
1342
|
+
" “",
|
|
1343
|
+
m,
|
|
1344
|
+
"”"
|
|
1345
|
+
]
|
|
1346
|
+
}
|
|
1347
|
+
)
|
|
1348
|
+
] })
|
|
1349
|
+
]
|
|
1350
|
+
}
|
|
1351
|
+
),
|
|
1352
|
+
I && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
1353
|
+
k === "right" && D && /* @__PURE__ */ e("div", { id: `${R}-error`, className: "nice-field__error", role: "alert", children: D }),
|
|
1354
|
+
k === "right" && !D && T && /* @__PURE__ */ e("div", { id: `${R}-helper`, className: "nice-field__helper", children: T })
|
|
1355
|
+
] }),
|
|
1356
|
+
k !== "right" && D && /* @__PURE__ */ e("div", { id: `${R}-error`, className: "nice-field__error", role: "alert", children: D }),
|
|
1357
|
+
k !== "right" && !D && T && /* @__PURE__ */ e("div", { id: `${R}-helper`, className: "nice-field__helper", children: T })
|
|
1358
|
+
]
|
|
1359
|
+
}
|
|
1360
|
+
);
|
|
1361
|
+
}, yt = /* @__PURE__ */ Object.assign(
|
|
1362
|
+
/* @__PURE__ */ bn(
|
|
1363
|
+
({
|
|
1364
|
+
label: n,
|
|
1365
|
+
helperText: i,
|
|
1366
|
+
error: t,
|
|
1367
|
+
required: o,
|
|
1368
|
+
disabled: a,
|
|
1369
|
+
readOnly: s,
|
|
1370
|
+
size: u = "md",
|
|
1371
|
+
name: M,
|
|
1372
|
+
id: w,
|
|
1373
|
+
className: A,
|
|
1374
|
+
style: ce,
|
|
1375
|
+
accessMode: D,
|
|
1376
|
+
displayStyle: T,
|
|
1377
|
+
value: X,
|
|
1378
|
+
defaultValue: W,
|
|
1379
|
+
onChange: z,
|
|
1380
|
+
onBlur: I,
|
|
1381
|
+
onKeyDown: $,
|
|
1382
|
+
placeholder: Z,
|
|
1383
|
+
rows: ne = 3,
|
|
1384
|
+
maxLength: J,
|
|
1385
|
+
resize: pe = "vertical",
|
|
1386
|
+
autoFocus: ae,
|
|
1387
|
+
showCount: k,
|
|
1388
|
+
counterPlacement: U = "bottom",
|
|
1389
|
+
submitOnEnter: L,
|
|
1390
|
+
onSubmit: E,
|
|
1391
|
+
showKeyboardHints: de,
|
|
1392
|
+
labelPlacement: te,
|
|
1393
|
+
errorPlacement: ee,
|
|
1394
|
+
loading: R,
|
|
1395
|
+
labelWidth: S,
|
|
1396
|
+
controlWidth: P,
|
|
1397
|
+
displayMode: p
|
|
1398
|
+
}, m) => {
|
|
1399
|
+
const y = dn(D, w), V = y === "hidden";
|
|
1400
|
+
y === "disabled" && (a = !0), y === "readOnly" && (s = !0);
|
|
1401
|
+
const { t: H } = Qe(), _ = un(w), N = qn("input", T), Y = Rn("input", T), K = X?.length ?? 0, Q = J ? K > J : !1, O = Rt({ enabled: p, readOnly: s, disabled: a }), fe = ge(
|
|
1402
|
+
() => ({ key: "Enter", ctrl: !0, description: H("shortcuts.submit", "Submit") }),
|
|
1403
|
+
[H]
|
|
1404
|
+
), ue = F(
|
|
1405
|
+
(le) => {
|
|
1406
|
+
L && Ut(le, fe) && (le.preventDefault(), E?.()), $?.(le);
|
|
1407
|
+
},
|
|
1408
|
+
[L, E, $, fe]
|
|
1409
|
+
), re = ge(() => {
|
|
1410
|
+
const le = [];
|
|
1411
|
+
return L && le.push(fe), le.push({ key: "Tab", description: H("shortcuts.indent", "Indent (when supported)") }), le;
|
|
1412
|
+
}, [L, H, fe]);
|
|
1413
|
+
return V ? null : /* @__PURE__ */ f(
|
|
1414
|
+
"div",
|
|
1415
|
+
{
|
|
1416
|
+
className: `nice-field nice-field--${u} ${te === "left" ? "nice-field--label-left" : ""} ${R ? "nice-field--loading" : ""} ${A || ""}`,
|
|
1417
|
+
style: {
|
|
1418
|
+
...ce,
|
|
1419
|
+
...S != null && {
|
|
1420
|
+
"--nice-field-label-width": typeof S == "number" ? `${S}px` : S
|
|
1421
|
+
},
|
|
1422
|
+
...P != null && {
|
|
1423
|
+
"--nice-field-control-width": typeof P == "number" ? `${P}px` : P
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
"aria-busy": R || void 0,
|
|
1427
|
+
children: [
|
|
1428
|
+
n && /* @__PURE__ */ f(
|
|
1429
|
+
"label",
|
|
1430
|
+
{
|
|
1431
|
+
htmlFor: _,
|
|
1432
|
+
className: `nice-field__label ${o ? "nice-field__label--required" : ""}`,
|
|
1433
|
+
children: [
|
|
1434
|
+
n,
|
|
1435
|
+
de && re.length > 0 && /* @__PURE__ */ e(gn, { shortcuts: re, size: "sm" })
|
|
1436
|
+
]
|
|
1437
|
+
}
|
|
1438
|
+
),
|
|
1439
|
+
/* @__PURE__ */ f("div", { className: "nice-field__control nice-field__control--textarea", children: [
|
|
1440
|
+
O.isDisplay ? /* @__PURE__ */ e(
|
|
1441
|
+
Et,
|
|
1442
|
+
{
|
|
1443
|
+
value: X ?? W ?? "",
|
|
1444
|
+
placeholder: Z,
|
|
1445
|
+
disabled: a,
|
|
1446
|
+
readOnly: s,
|
|
1447
|
+
onActivate: O.enterEdit,
|
|
1448
|
+
ariaLabel: n,
|
|
1449
|
+
className: "nice-display-value--textarea"
|
|
1450
|
+
}
|
|
1451
|
+
) : /* @__PURE__ */ f(vn, { children: [
|
|
1452
|
+
/* @__PURE__ */ f(
|
|
1453
|
+
"div",
|
|
1454
|
+
{
|
|
1455
|
+
style: {
|
|
1456
|
+
display: "flex",
|
|
1457
|
+
flexDirection: "column",
|
|
1458
|
+
flex: "1 1 auto",
|
|
1459
|
+
minWidth: 0
|
|
1460
|
+
},
|
|
1461
|
+
children: [
|
|
1462
|
+
/* @__PURE__ */ e(
|
|
1463
|
+
"textarea",
|
|
1464
|
+
{
|
|
1465
|
+
ref: (le) => {
|
|
1466
|
+
typeof m == "function" ? m(le) : m && (m.current = le), O.autoFocusRef(le);
|
|
1467
|
+
},
|
|
1468
|
+
id: _,
|
|
1469
|
+
className: `nice-textarea nice-input--${u} nice-textarea--ds-${Y} ${t ? "nice-textarea--error" : ""} ${a ? "nice-textarea--disabled" : ""}`,
|
|
1470
|
+
style: { ...N, resize: pe },
|
|
1471
|
+
name: M,
|
|
1472
|
+
value: X,
|
|
1473
|
+
defaultValue: W,
|
|
1474
|
+
placeholder: Z,
|
|
1475
|
+
rows: ne,
|
|
1476
|
+
maxLength: J,
|
|
1477
|
+
disabled: a || R,
|
|
1478
|
+
readOnly: s,
|
|
1479
|
+
autoFocus: ae,
|
|
1480
|
+
"aria-invalid": !!t,
|
|
1481
|
+
"aria-describedby": t ? `${_}-error` : i ? `${_}-helper` : void 0,
|
|
1482
|
+
onChange: (le) => z?.(le.target.value),
|
|
1483
|
+
onBlur: (le) => {
|
|
1484
|
+
p && O.exitEdit(), I?.(le);
|
|
1485
|
+
},
|
|
1486
|
+
onKeyDown: ue
|
|
1487
|
+
}
|
|
1488
|
+
),
|
|
1489
|
+
U !== "right" && (k || J) && /* @__PURE__ */ f(
|
|
1490
|
+
"div",
|
|
1491
|
+
{
|
|
1492
|
+
className: `nice-textarea__counter ${Q ? "nice-textarea__counter--over" : ""}`,
|
|
1493
|
+
children: [
|
|
1494
|
+
K,
|
|
1495
|
+
J ? ` / ${J}` : ""
|
|
1496
|
+
]
|
|
1497
|
+
}
|
|
1498
|
+
)
|
|
1499
|
+
]
|
|
1500
|
+
}
|
|
1501
|
+
),
|
|
1502
|
+
U === "right" && (k || J) && /* @__PURE__ */ f(
|
|
1503
|
+
"div",
|
|
1504
|
+
{
|
|
1505
|
+
className: `nice-textarea__counter nice-textarea__counter--right ${Q ? "nice-textarea__counter--over" : ""}`,
|
|
1506
|
+
children: [
|
|
1507
|
+
K,
|
|
1508
|
+
J ? ` / ${J}` : ""
|
|
1509
|
+
]
|
|
1510
|
+
}
|
|
1511
|
+
)
|
|
1512
|
+
] }),
|
|
1513
|
+
R && /* @__PURE__ */ e("span", { className: "nice-field__spinner nice-field__spinner--textarea", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
1514
|
+
ee === "right" && t && /* @__PURE__ */ e("div", { id: `${_}-error`, className: "nice-field__error", role: "alert", children: t }),
|
|
1515
|
+
ee === "right" && !t && i && /* @__PURE__ */ e("div", { id: `${_}-helper`, className: "nice-field__helper", children: i })
|
|
1516
|
+
] }),
|
|
1517
|
+
ee !== "right" && t && /* @__PURE__ */ e("div", { id: `${_}-error`, className: "nice-field__error", role: "alert", children: t }),
|
|
1518
|
+
ee !== "right" && !t && i && /* @__PURE__ */ e("div", { id: `${_}-helper`, className: "nice-field__helper", children: i })
|
|
1519
|
+
]
|
|
1520
|
+
}
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1523
|
+
),
|
|
1524
|
+
{ displayName: "NiceTextArea" }
|
|
1525
|
+
), Wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1526
|
+
__proto__: null,
|
|
1527
|
+
NiceTextArea: yt
|
|
1528
|
+
}, Symbol.toStringTag, { value: "Module" })), di = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, On = (n) => {
|
|
1529
|
+
if (n === 0)
|
|
1530
|
+
return "0 B";
|
|
1531
|
+
const i = 1024, t = ["B", "KB", "MB", "GB", "TB"], o = Math.floor(Math.log(n) / Math.log(i));
|
|
1532
|
+
return `${parseFloat((n / Math.pow(i, o)).toFixed(2))} ${t[o]}`;
|
|
1533
|
+
}, Zn = (n) => n.startsWith("image/"), Jn = (n) => n.startsWith("video/"), _t = (n) => n.startsWith("audio/"), ui = (n) => Zn(n) ? "image" : Jn(n) ? "video" : _t(n) ? "music" : /pdf|word|document|text|json|xml/.test(n) ? "file" : /excel|spreadsheet/.test(n) ? "table" : /powerpoint|presentation/.test(n) ? "monitor" : /zip|rar|7z/.test(n) ? "box" : "folder", pi = (n) => {
|
|
1534
|
+
if (Zn(n.type) || Jn(n.type) || _t(n.type))
|
|
1535
|
+
return URL.createObjectURL(n);
|
|
1536
|
+
}, fi = {
|
|
1537
|
+
xxs: 24,
|
|
1538
|
+
xs: 32,
|
|
1539
|
+
sm: 48,
|
|
1540
|
+
md: 80,
|
|
1541
|
+
lg: 120,
|
|
1542
|
+
xl: 160,
|
|
1543
|
+
xxl: 200
|
|
1544
|
+
}, mi = (n, i) => (t) => {
|
|
1545
|
+
const o = new FormData();
|
|
1546
|
+
t.chunk ? (o.append("chunk", t.chunk), o.append("chunkIndex", String(t.chunkIndex)), o.append("totalChunks", String(t.totalChunks)), o.append("fileName", t.file.name), o.append("fileId", t.fileId || "")) : o.append("file", t.file);
|
|
1547
|
+
const a = new XMLHttpRequest();
|
|
1548
|
+
return new Promise((s) => {
|
|
1549
|
+
a.upload.addEventListener("progress", (u) => {
|
|
1550
|
+
u.lengthComputable && t.onProgress && t.onProgress(u.loaded / u.total * 100);
|
|
1551
|
+
}), a.addEventListener("load", () => {
|
|
1552
|
+
if (a.status >= 200 && a.status < 300)
|
|
1553
|
+
try {
|
|
1554
|
+
const u = JSON.parse(a.responseText);
|
|
1555
|
+
s({
|
|
1556
|
+
success: !0,
|
|
1557
|
+
url: u.url,
|
|
1558
|
+
fileId: u.fileId || u.id,
|
|
1559
|
+
metadata: u
|
|
1560
|
+
});
|
|
1561
|
+
} catch {
|
|
1562
|
+
s({ success: !0, url: a.responseText });
|
|
1563
|
+
}
|
|
1564
|
+
else
|
|
1565
|
+
s({ success: !1, error: `Upload failed: ${a.status} ${a.statusText}` });
|
|
1566
|
+
}), a.addEventListener("error", () => s({ success: !1, error: "Network error" })), a.addEventListener("abort", () => s({ success: !1, error: "Upload cancelled" })), t.signal && t.signal.addEventListener("abort", () => a.abort()), a.open("POST", n), i && Object.entries(i).forEach(([u, M]) => a.setRequestHeader(u, M)), a.send(o);
|
|
1567
|
+
});
|
|
1568
|
+
}, hi = /* @__PURE__ */ Object.assign(
|
|
1569
|
+
/* @__PURE__ */ bn((n, i) => {
|
|
1570
|
+
const {
|
|
1571
|
+
accept: t,
|
|
1572
|
+
multiple: o = !0,
|
|
1573
|
+
maxFileSize: a,
|
|
1574
|
+
maxFiles: s,
|
|
1575
|
+
minFileSize: u,
|
|
1576
|
+
onFilesSelected: M,
|
|
1577
|
+
uploadMode: w = "instant",
|
|
1578
|
+
labelText: A,
|
|
1579
|
+
text: ce,
|
|
1580
|
+
dropzoneText: D,
|
|
1581
|
+
browseText: T,
|
|
1582
|
+
dragActiveText: X,
|
|
1583
|
+
labelPlacement: W = "right",
|
|
1584
|
+
icon: z = "upload",
|
|
1585
|
+
showFileList: I = !0,
|
|
1586
|
+
imagePreview: $,
|
|
1587
|
+
showPreview: Z = !0,
|
|
1588
|
+
listMode: ne = "list",
|
|
1589
|
+
previewSize: J = "md",
|
|
1590
|
+
fileProgress: pe,
|
|
1591
|
+
renderPreview: ae,
|
|
1592
|
+
renderFileItem: k,
|
|
1593
|
+
variant: U = "dropzone",
|
|
1594
|
+
trigger: L,
|
|
1595
|
+
dropChildren: E,
|
|
1596
|
+
autoUpload: de = !1,
|
|
1597
|
+
uploadHandler: te,
|
|
1598
|
+
uploadUrl: ee,
|
|
1599
|
+
uploadHeaders: R,
|
|
1600
|
+
concurrentUploads: S = 3,
|
|
1601
|
+
maxRetries: P = 3,
|
|
1602
|
+
chunkSize: p = 5 * 1024 * 1024,
|
|
1603
|
+
chunkThreshold: m = 10 * 1024 * 1024,
|
|
1604
|
+
validateFile: y,
|
|
1605
|
+
keepFilesAfterUpload: V = !0,
|
|
1606
|
+
initialFiles: H,
|
|
1607
|
+
disabled: _,
|
|
1608
|
+
readOnly: N,
|
|
1609
|
+
onFilesAdded: Y,
|
|
1610
|
+
onUploadComplete: K,
|
|
1611
|
+
onUploadError: Q,
|
|
1612
|
+
onProgress: O,
|
|
1613
|
+
onFileRemoved: fe,
|
|
1614
|
+
onChange: ue,
|
|
1615
|
+
apiRef: re,
|
|
1616
|
+
pasteFromClipboard: le,
|
|
1617
|
+
className: q,
|
|
1618
|
+
style: Ce
|
|
1619
|
+
} = n, { t: j } = Qe(), [B, oe] = Te(() => H ?? []), [_e, Ee] = Te(!1), Ne = be(B), Ye = be(null), ze = be(/* @__PURE__ */ new Map()), h = be([]), d = be(/* @__PURE__ */ new Set()), C = be(0), ke = be(() => {
|
|
1620
|
+
}), ve = be(ue), g = !!(te || ee);
|
|
1621
|
+
Le(() => {
|
|
1622
|
+
Ne.current = B;
|
|
1623
|
+
}, [B]), Le(() => {
|
|
1624
|
+
ve.current = ue;
|
|
1625
|
+
}), Le(() => {
|
|
1626
|
+
ve.current?.(B);
|
|
1627
|
+
}, [B]), Le(
|
|
1628
|
+
() => () => {
|
|
1629
|
+
Ne.current.forEach((r) => r.previewUrl && URL.revokeObjectURL(r.previewUrl));
|
|
1630
|
+
},
|
|
1631
|
+
[]
|
|
1632
|
+
);
|
|
1633
|
+
const v = F(
|
|
1634
|
+
(r) => M(r.map((G) => G.file)),
|
|
1635
|
+
[M]
|
|
1636
|
+
), Xe = F(
|
|
1637
|
+
(r) => {
|
|
1638
|
+
if (y) {
|
|
1639
|
+
const G = y(r);
|
|
1640
|
+
if (G)
|
|
1641
|
+
return G;
|
|
1642
|
+
}
|
|
1643
|
+
if (a && r.size > a)
|
|
1644
|
+
return j("fileUpload.error.tooLarge", "File is too large. Maximum size: {size}").replace(
|
|
1645
|
+
"{size}",
|
|
1646
|
+
On(a)
|
|
1647
|
+
);
|
|
1648
|
+
if (u && r.size < u)
|
|
1649
|
+
return j("fileUpload.error.tooSmall", "File is too small. Minimum size: {size}").replace(
|
|
1650
|
+
"{size}",
|
|
1651
|
+
On(u)
|
|
1652
|
+
);
|
|
1653
|
+
if (t) {
|
|
1654
|
+
const G = t.split(",").map((me) => me.trim().toLowerCase()), se = r.type.toLowerCase(), we = "." + (r.name.split(".").pop()?.toLowerCase() ?? "");
|
|
1655
|
+
if (!G.some((me) => me.startsWith(".") ? we === me : me.endsWith("/*") ? se.startsWith(me.replace("/*", "/")) : se === me))
|
|
1656
|
+
return j(
|
|
1657
|
+
"fileUpload.error.badType",
|
|
1658
|
+
"File type not allowed. Accepted types: {accept}"
|
|
1659
|
+
).replace("{accept}", t);
|
|
1660
|
+
}
|
|
1661
|
+
return null;
|
|
1662
|
+
},
|
|
1663
|
+
[y, a, u, t, j]
|
|
1664
|
+
), Ke = F(() => te || (ee ? mi(ee, R) : null), [te, ee, R]), Nn = F(
|
|
1665
|
+
async (r, G, se) => {
|
|
1666
|
+
const we = r.file, Se = Math.ceil(we.size / p);
|
|
1667
|
+
let me = 0, Pe = { success: !1 };
|
|
1668
|
+
for (let Fe = 0; Fe < Se; Fe++) {
|
|
1669
|
+
if (se.aborted)
|
|
1670
|
+
throw new Error("Upload cancelled");
|
|
1671
|
+
const qe = Fe * p, $n = Math.min(qe + p, we.size), _n = we.slice(qe, $n);
|
|
1672
|
+
let We = 0, fn = !1;
|
|
1673
|
+
for (; !fn && We < P; )
|
|
1674
|
+
try {
|
|
1675
|
+
Pe = await G({
|
|
1676
|
+
file: we,
|
|
1677
|
+
chunk: _n,
|
|
1678
|
+
chunkIndex: Fe,
|
|
1679
|
+
totalChunks: Se,
|
|
1680
|
+
fileId: r.id,
|
|
1681
|
+
onProgress: (mn) => {
|
|
1682
|
+
const Yn = (me + _n.size * mn / 100) / we.size * 100;
|
|
1683
|
+
oe(
|
|
1684
|
+
(In) => In.map((kn) => kn.id === r.id ? { ...kn, progress: Yn } : kn)
|
|
1685
|
+
);
|
|
1686
|
+
},
|
|
1687
|
+
signal: se
|
|
1688
|
+
}), Pe.success ? (fn = !0, me += _n.size) : We++;
|
|
1689
|
+
} catch (mn) {
|
|
1690
|
+
if (We++, We >= P)
|
|
1691
|
+
throw mn;
|
|
1692
|
+
}
|
|
1693
|
+
if (!fn)
|
|
1694
|
+
throw new Error(`Failed to upload chunk ${Fe + 1}/${Se}`);
|
|
1695
|
+
}
|
|
1696
|
+
return Pe;
|
|
1697
|
+
},
|
|
1698
|
+
[p, P]
|
|
1699
|
+
), Cn = F(
|
|
1700
|
+
async (r, G) => {
|
|
1701
|
+
const se = Ne.current.find((Se) => Se.id === r);
|
|
1702
|
+
if (!se || se.status === "uploading" || se.status === "success")
|
|
1703
|
+
return;
|
|
1704
|
+
const we = new AbortController();
|
|
1705
|
+
ze.current.set(r, we), d.current.add(r), oe(
|
|
1706
|
+
(Se) => Se.map(
|
|
1707
|
+
(me) => me.id === r ? { ...me, status: "uploading", progress: 0, error: void 0 } : me
|
|
1708
|
+
)
|
|
1709
|
+
);
|
|
1710
|
+
try {
|
|
1711
|
+
const Se = se.file;
|
|
1712
|
+
let me;
|
|
1713
|
+
if (Se.size > m ? me = await Nn(se, G, we.signal) : me = await G({
|
|
1714
|
+
file: Se,
|
|
1715
|
+
onProgress: (Pe) => {
|
|
1716
|
+
oe((Fe) => Fe.map((qe) => qe.id === r ? { ...qe, progress: Pe } : qe)), O?.(se, Pe);
|
|
1717
|
+
},
|
|
1718
|
+
signal: we.signal
|
|
1719
|
+
}), me.success) {
|
|
1720
|
+
if (oe(
|
|
1721
|
+
(Pe) => Pe.map(
|
|
1722
|
+
(Fe) => Fe.id === r ? {
|
|
1723
|
+
...Fe,
|
|
1724
|
+
status: "success",
|
|
1725
|
+
progress: 100,
|
|
1726
|
+
uploadedUrl: me.url,
|
|
1727
|
+
uploadedAt: /* @__PURE__ */ new Date()
|
|
1728
|
+
} : Fe
|
|
1729
|
+
)
|
|
1730
|
+
), K?.({ ...se, status: "success", uploadedUrl: me.url }), !V) {
|
|
1731
|
+
const Pe = Ne.current.find((Fe) => Fe.id === r);
|
|
1732
|
+
Pe?.previewUrl && URL.revokeObjectURL(Pe.previewUrl), oe((Fe) => Fe.filter((qe) => qe.id !== r));
|
|
1733
|
+
}
|
|
1734
|
+
} else
|
|
1735
|
+
throw new Error(me.error || "Upload failed");
|
|
1736
|
+
} catch (Se) {
|
|
1737
|
+
const me = Se;
|
|
1738
|
+
if (me.name === "AbortError" || me.message === "Upload cancelled")
|
|
1739
|
+
oe(
|
|
1740
|
+
(Pe) => Pe.map(
|
|
1741
|
+
(Fe) => Fe.id === r ? {
|
|
1742
|
+
...Fe,
|
|
1743
|
+
status: "cancelled",
|
|
1744
|
+
error: j("fileUpload.status.cancelled", "Cancelled")
|
|
1745
|
+
} : Fe
|
|
1746
|
+
)
|
|
1747
|
+
);
|
|
1748
|
+
else {
|
|
1749
|
+
const Pe = me.message || j("fileUpload.error.generic", "Upload error");
|
|
1750
|
+
oe(
|
|
1751
|
+
(Fe) => Fe.map(
|
|
1752
|
+
(qe) => qe.id === r ? { ...qe, status: "error", error: Pe } : qe
|
|
1753
|
+
)
|
|
1754
|
+
), Q?.(se, Pe);
|
|
1755
|
+
}
|
|
1756
|
+
} finally {
|
|
1757
|
+
ze.current.delete(r), d.current.delete(r), ke.current();
|
|
1758
|
+
}
|
|
1759
|
+
},
|
|
1760
|
+
[
|
|
1761
|
+
m,
|
|
1762
|
+
Nn,
|
|
1763
|
+
O,
|
|
1764
|
+
K,
|
|
1765
|
+
Q,
|
|
1766
|
+
V,
|
|
1767
|
+
j
|
|
1768
|
+
]
|
|
1769
|
+
), cn = be(Cn);
|
|
1770
|
+
Le(() => {
|
|
1771
|
+
cn.current = Cn;
|
|
1772
|
+
});
|
|
1773
|
+
const Me = F(() => {
|
|
1774
|
+
const r = Ke();
|
|
1775
|
+
if (r)
|
|
1776
|
+
for (; h.current.length > 0 && d.current.size < S; ) {
|
|
1777
|
+
const G = h.current.shift();
|
|
1778
|
+
G && cn.current(G, r);
|
|
1779
|
+
}
|
|
1780
|
+
}, [Ke, S]);
|
|
1781
|
+
Le(() => {
|
|
1782
|
+
ke.current = Me;
|
|
1783
|
+
});
|
|
1784
|
+
const rn = F(
|
|
1785
|
+
(r) => {
|
|
1786
|
+
const G = Ke();
|
|
1787
|
+
if (!G) {
|
|
1788
|
+
console.error("No upload handler configured");
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
cn.current(r, G);
|
|
1792
|
+
},
|
|
1793
|
+
[Ke]
|
|
1794
|
+
), pn = F(
|
|
1795
|
+
(r) => {
|
|
1796
|
+
ze.current.get(r)?.abort(), oe(
|
|
1797
|
+
(G) => G.map(
|
|
1798
|
+
(se) => se.id === r && se.status === "uploading" ? { ...se, status: "cancelled", error: j("fileUpload.status.cancelled", "Cancelled") } : se
|
|
1799
|
+
)
|
|
1800
|
+
);
|
|
1801
|
+
},
|
|
1802
|
+
[j]
|
|
1803
|
+
), l = F(
|
|
1804
|
+
(r) => {
|
|
1805
|
+
oe(
|
|
1806
|
+
(G) => G.map(
|
|
1807
|
+
(se) => se.id === r ? { ...se, status: "pending", progress: 0, error: void 0 } : se
|
|
1808
|
+
)
|
|
1809
|
+
), rn(r);
|
|
1810
|
+
},
|
|
1811
|
+
[rn]
|
|
1812
|
+
), ie = F(
|
|
1813
|
+
(r) => {
|
|
1814
|
+
const G = Ne.current.find((we) => we.id === r);
|
|
1815
|
+
if (!G)
|
|
1816
|
+
return;
|
|
1817
|
+
ze.current.get(r)?.abort(), G.previewUrl && URL.revokeObjectURL(G.previewUrl);
|
|
1818
|
+
const se = Ne.current.filter((we) => we.id !== r);
|
|
1819
|
+
Ne.current = se, oe((we) => we.filter((Se) => Se.id !== r)), fe?.(G), w === "instant" && v(se);
|
|
1820
|
+
},
|
|
1821
|
+
[fe, w, v]
|
|
1822
|
+
), De = F(() => {
|
|
1823
|
+
Ne.current.filter((r) => r.status === "pending").forEach((r) => h.current.push(r.id)), Me();
|
|
1824
|
+
}, [Me]), Ge = F(() => {
|
|
1825
|
+
ze.current.forEach((r) => r.abort()), oe(
|
|
1826
|
+
(r) => r.map(
|
|
1827
|
+
(G) => G.status === "uploading" ? { ...G, status: "cancelled", error: j("fileUpload.status.cancelled", "Cancelled") } : G
|
|
1828
|
+
)
|
|
1829
|
+
);
|
|
1830
|
+
}, [j]), Ie = F(() => {
|
|
1831
|
+
Ge(), Ne.current.forEach((r) => r.previewUrl && URL.revokeObjectURL(r.previewUrl)), oe([]), w === "instant" && v([]);
|
|
1832
|
+
}, [Ge, w, v]), je = F(() => {
|
|
1833
|
+
Ne.current.filter((r) => r.status === "error").forEach((r) => l(r.id));
|
|
1834
|
+
}, [l]), Je = F(
|
|
1835
|
+
(r) => {
|
|
1836
|
+
if (_ || N)
|
|
1837
|
+
return;
|
|
1838
|
+
const G = Ne.current;
|
|
1839
|
+
let se = o ? r : r.slice(0, 1);
|
|
1840
|
+
s && (se = se.slice(0, Math.max(0, s - G.length)));
|
|
1841
|
+
const we = se.map((me) => {
|
|
1842
|
+
const Pe = Xe(me);
|
|
1843
|
+
return {
|
|
1844
|
+
id: di(),
|
|
1845
|
+
file: me,
|
|
1846
|
+
name: me.name,
|
|
1847
|
+
size: me.size,
|
|
1848
|
+
type: me.type,
|
|
1849
|
+
status: Pe ? "error" : "pending",
|
|
1850
|
+
progress: 0,
|
|
1851
|
+
error: Pe || void 0,
|
|
1852
|
+
previewUrl: pi(me)
|
|
1853
|
+
};
|
|
1854
|
+
}), Se = o ? [...G, ...we] : we;
|
|
1855
|
+
oe(Se), Ne.current = Se, Y?.(we), w === "instant" && v(Se), de && (we.filter((me) => me.status === "pending").forEach((me) => h.current.push(me.id)), Me());
|
|
1856
|
+
},
|
|
1857
|
+
[
|
|
1858
|
+
_,
|
|
1859
|
+
N,
|
|
1860
|
+
o,
|
|
1861
|
+
s,
|
|
1862
|
+
Xe,
|
|
1863
|
+
Y,
|
|
1864
|
+
w,
|
|
1865
|
+
v,
|
|
1866
|
+
de,
|
|
1867
|
+
Me
|
|
1868
|
+
]
|
|
1869
|
+
), on = F(() => Ye.current?.click(), []);
|
|
1870
|
+
Pt(
|
|
1871
|
+
re,
|
|
1872
|
+
() => ({
|
|
1873
|
+
addFiles: Je,
|
|
1874
|
+
uploadAll: De,
|
|
1875
|
+
cancelAll: Ge,
|
|
1876
|
+
clearAll: Ie,
|
|
1877
|
+
getFiles: () => Ne.current,
|
|
1878
|
+
getFile: (r) => Ne.current.find((G) => G.id === r),
|
|
1879
|
+
retryFailed: je,
|
|
1880
|
+
openFileBrowser: on
|
|
1881
|
+
}),
|
|
1882
|
+
[Je, De, Ge, Ie, je, on]
|
|
1883
|
+
), Le(() => {
|
|
1884
|
+
if (!le || _ || N)
|
|
1885
|
+
return;
|
|
1886
|
+
const r = (G) => {
|
|
1887
|
+
const se = G.clipboardData?.items;
|
|
1888
|
+
if (!se)
|
|
1889
|
+
return;
|
|
1890
|
+
const we = [];
|
|
1891
|
+
for (let Se = 0; Se < se.length; Se++)
|
|
1892
|
+
if (se[Se].kind === "file") {
|
|
1893
|
+
const me = se[Se].getAsFile();
|
|
1894
|
+
me && we.push(me);
|
|
1895
|
+
}
|
|
1896
|
+
we.length > 0 && (G.preventDefault(), Je(we));
|
|
1897
|
+
};
|
|
1898
|
+
return document.addEventListener("paste", r), () => document.removeEventListener("paste", r);
|
|
1899
|
+
}, [le, _, N, Je]);
|
|
1900
|
+
const Un = (r) => {
|
|
1901
|
+
r.preventDefault(), !(_ || N) && (C.current++, Ee(!0));
|
|
1902
|
+
}, Sn = (r) => {
|
|
1903
|
+
r.preventDefault(), C.current--, C.current <= 0 && (C.current = 0, Ee(!1));
|
|
1904
|
+
}, En = (r) => {
|
|
1905
|
+
r.preventDefault(), C.current = 0, Ee(!1), !(_ || N) && Je(Array.from(r.dataTransfer.files));
|
|
1906
|
+
}, Oe = (r) => {
|
|
1907
|
+
r.target.files && Je(Array.from(r.target.files)), r.target.value = "";
|
|
1908
|
+
}, nn = ge(() => {
|
|
1909
|
+
const r = { total: B.length, pending: 0, uploading: 0, success: 0, error: 0 };
|
|
1910
|
+
for (const G of B)
|
|
1911
|
+
G.status === "pending" ? r.pending++ : G.status === "uploading" ? r.uploading++ : G.status === "success" ? r.success++ : G.status === "error" && r.error++;
|
|
1912
|
+
return r;
|
|
1913
|
+
}, [B]), tn = A ?? ce ?? D ?? j("dropOrClick", "Drop files here or click to browse"), yn = X ?? j("fileUpload.dropzone.dragActive", "Drop files here"), zn = (r) => j(
|
|
1914
|
+
`fileUpload.status.${r}`,
|
|
1915
|
+
{
|
|
1916
|
+
pending: "Pending",
|
|
1917
|
+
uploading: "Uploading…",
|
|
1918
|
+
success: "Uploaded",
|
|
1919
|
+
error: "Error",
|
|
1920
|
+
cancelled: "Cancelled"
|
|
1921
|
+
}[r]
|
|
1922
|
+
), Pn = (r) => g || r.status !== "pending", Bn = (r) => {
|
|
1923
|
+
if (ae)
|
|
1924
|
+
return ae(r);
|
|
1925
|
+
const G = fi[J] ?? 80, se = $ ?? Z;
|
|
1926
|
+
return se && r.previewUrl && Zn(r.type) ? /* @__PURE__ */ e(
|
|
1927
|
+
"img",
|
|
1928
|
+
{
|
|
1929
|
+
src: r.previewUrl,
|
|
1930
|
+
alt: r.name,
|
|
1931
|
+
className: "nice-fileuploader__thumb nice-upload__thumb nice-upload__preview",
|
|
1932
|
+
style: { width: G, height: G, objectFit: "cover" }
|
|
1933
|
+
}
|
|
1934
|
+
) : se && r.previewUrl && Jn(r.type) ? /* @__PURE__ */ f(
|
|
1935
|
+
"span",
|
|
1936
|
+
{
|
|
1937
|
+
className: "nice-upload__preview",
|
|
1938
|
+
style: { position: "relative", display: "inline-flex" },
|
|
1939
|
+
children: [
|
|
1940
|
+
/* @__PURE__ */ e("video", { src: r.previewUrl, muted: !0, style: { width: G, height: G, objectFit: "cover" } }),
|
|
1941
|
+
/* @__PURE__ */ e("span", { className: "nice-upload__preview-overlay", "aria-hidden": "true", children: /* @__PURE__ */ e(Ae, { name: "play", size: 20 }) })
|
|
1942
|
+
]
|
|
1943
|
+
}
|
|
1944
|
+
) : /* @__PURE__ */ e("span", { className: "nice-upload__preview nice-upload__preview--icon", "aria-hidden": "true", children: /* @__PURE__ */ e(Ae, { name: ui(r.type), size: Math.round(G * 0.5) }) });
|
|
1945
|
+
}, Mn = (r) => {
|
|
1946
|
+
const G = {
|
|
1947
|
+
upload: () => rn(r.id),
|
|
1948
|
+
cancel: () => pn(r.id),
|
|
1949
|
+
retry: () => l(r.id),
|
|
1950
|
+
remove: () => ie(r.id)
|
|
1951
|
+
};
|
|
1952
|
+
if (k)
|
|
1953
|
+
return /* @__PURE__ */ e(xn.Fragment, { children: k(r, G) }, r.id);
|
|
1954
|
+
const se = pe?.[r.name] ?? r.progress, we = Pn(r);
|
|
1955
|
+
return /* @__PURE__ */ f(
|
|
1956
|
+
"div",
|
|
1957
|
+
{
|
|
1958
|
+
className: `nice-fileuploader__file nice-upload__file nice-upload__item nice-upload__item--${r.status}`,
|
|
1959
|
+
children: [
|
|
1960
|
+
($ ?? Z) && Bn(r),
|
|
1961
|
+
/* @__PURE__ */ e("span", { className: "nice-fileuploader__filename nice-upload__filename", title: r.name, children: r.name }),
|
|
1962
|
+
/* @__PURE__ */ e("span", { className: "nice-fileuploader__filesize nice-upload__filesize", children: On(r.size) }),
|
|
1963
|
+
we && /* @__PURE__ */ e("span", { className: `nice-upload__badge nice-upload__badge--${r.status}`, children: zn(r.status) }),
|
|
1964
|
+
(r.status === "uploading" || se != null && se > 0 && se < 100) && /* @__PURE__ */ e("div", { className: "nice-fileuploader__progress nice-upload__progress", children: /* @__PURE__ */ e(
|
|
1965
|
+
"div",
|
|
1966
|
+
{
|
|
1967
|
+
className: "nice-fileuploader__progress-bar nice-upload__progress-bar",
|
|
1968
|
+
style: { width: `${Math.min(100, Math.max(0, se))}%` }
|
|
1969
|
+
}
|
|
1970
|
+
) }),
|
|
1971
|
+
r.error && r.status === "error" && /* @__PURE__ */ e("span", { className: "nice-upload__item-error", children: r.error }),
|
|
1972
|
+
r.uploadedUrl && /* @__PURE__ */ e(
|
|
1973
|
+
"a",
|
|
1974
|
+
{
|
|
1975
|
+
className: "nice-upload__link",
|
|
1976
|
+
href: r.uploadedUrl,
|
|
1977
|
+
target: "_blank",
|
|
1978
|
+
rel: "noopener noreferrer",
|
|
1979
|
+
children: j("fileUpload.openFile", "Open file")
|
|
1980
|
+
}
|
|
1981
|
+
),
|
|
1982
|
+
!N && !_ && /* @__PURE__ */ f("span", { className: "nice-upload__item-actions", children: [
|
|
1983
|
+
g && r.status === "pending" && /* @__PURE__ */ e(
|
|
1984
|
+
"button",
|
|
1985
|
+
{
|
|
1986
|
+
type: "button",
|
|
1987
|
+
className: "nice-upload__btn nice-upload__btn--upload",
|
|
1988
|
+
onClick: G.upload,
|
|
1989
|
+
title: j("fileUpload.action.upload", "Upload"),
|
|
1990
|
+
"aria-label": j("fileUpload.action.upload", "Upload"),
|
|
1991
|
+
children: /* @__PURE__ */ e(Ae, { name: "upload", size: 14 })
|
|
1992
|
+
}
|
|
1993
|
+
),
|
|
1994
|
+
r.status === "uploading" && /* @__PURE__ */ e(
|
|
1995
|
+
"button",
|
|
1996
|
+
{
|
|
1997
|
+
type: "button",
|
|
1998
|
+
className: "nice-upload__btn nice-upload__btn--cancel",
|
|
1999
|
+
onClick: G.cancel,
|
|
2000
|
+
title: j("fileUpload.action.cancel", "Cancel"),
|
|
2001
|
+
"aria-label": j("fileUpload.action.cancel", "Cancel"),
|
|
2002
|
+
children: /* @__PURE__ */ e(Ae, { name: "stop", size: 14 })
|
|
2003
|
+
}
|
|
2004
|
+
),
|
|
2005
|
+
g && r.status === "error" && /* @__PURE__ */ e(
|
|
2006
|
+
"button",
|
|
2007
|
+
{
|
|
2008
|
+
type: "button",
|
|
2009
|
+
className: "nice-upload__btn nice-upload__btn--retry",
|
|
2010
|
+
onClick: G.retry,
|
|
2011
|
+
title: j("fileUpload.action.retry", "Retry"),
|
|
2012
|
+
"aria-label": j("fileUpload.action.retry", "Retry"),
|
|
2013
|
+
children: /* @__PURE__ */ e(Ae, { name: "refresh", size: 14 })
|
|
2014
|
+
}
|
|
2015
|
+
),
|
|
2016
|
+
r.status !== "uploading" && /* @__PURE__ */ e(
|
|
2017
|
+
"button",
|
|
2018
|
+
{
|
|
2019
|
+
type: "button",
|
|
2020
|
+
className: "nice-fileuploader__remove nice-upload__remove nice-upload__btn nice-upload__btn--remove",
|
|
2021
|
+
onClick: G.remove,
|
|
2022
|
+
title: j("remove", "Remove"),
|
|
2023
|
+
"aria-label": j("remove", "Remove"),
|
|
2024
|
+
children: /* @__PURE__ */ e(Ae, { name: "close", size: 14 })
|
|
2025
|
+
}
|
|
2026
|
+
)
|
|
2027
|
+
] })
|
|
2028
|
+
]
|
|
2029
|
+
},
|
|
2030
|
+
r.id
|
|
2031
|
+
);
|
|
2032
|
+
}, Hn = (r) => {
|
|
2033
|
+
(r.key === "Enter" || r.key === " ") && (r.preventDefault(), on());
|
|
2034
|
+
}, sn = /* @__PURE__ */ e(
|
|
2035
|
+
"input",
|
|
2036
|
+
{
|
|
2037
|
+
ref: Ye,
|
|
2038
|
+
type: "file",
|
|
2039
|
+
accept: t,
|
|
2040
|
+
multiple: o,
|
|
2041
|
+
hidden: !0,
|
|
2042
|
+
disabled: _,
|
|
2043
|
+
onChange: Oe
|
|
2044
|
+
}
|
|
2045
|
+
);
|
|
2046
|
+
return /* @__PURE__ */ f(
|
|
2047
|
+
"div",
|
|
2048
|
+
{
|
|
2049
|
+
ref: i,
|
|
2050
|
+
className: `nice-fileuploader nice-upload ${_ ? "nice-fileuploader--disabled nice-upload--disabled" : ""} ${N ? "nice-upload--readonly" : ""} ${q || ""}`,
|
|
2051
|
+
style: Ce,
|
|
2052
|
+
children: [
|
|
2053
|
+
U === "button" ? /* @__PURE__ */ f(vn, { children: [
|
|
2054
|
+
/* @__PURE__ */ e(
|
|
2055
|
+
"button",
|
|
2056
|
+
{
|
|
2057
|
+
type: "button",
|
|
2058
|
+
className: "nice-upload__trigger nice-btn nice-btn--primary",
|
|
2059
|
+
onClick: on,
|
|
2060
|
+
disabled: _ || N,
|
|
2061
|
+
children: L ?? j("filePicker.label", "Choose files")
|
|
2062
|
+
}
|
|
2063
|
+
),
|
|
2064
|
+
sn
|
|
2065
|
+
] }) : !N && /* @__PURE__ */ f(
|
|
2066
|
+
"div",
|
|
2067
|
+
{
|
|
2068
|
+
className: `nice-fileuploader__dropzone nice-upload__dropzone nice-upload__dropzone--label-${W} ${!E && !tn ? "nice-upload__dropzone--icon-only" : ""} ${_e ? "nice-fileuploader__dropzone--active nice-upload__dropzone--active" : ""}`,
|
|
2069
|
+
role: "button",
|
|
2070
|
+
tabIndex: _ ? -1 : 0,
|
|
2071
|
+
"aria-disabled": _ || void 0,
|
|
2072
|
+
onDragEnter: Un,
|
|
2073
|
+
onDragOver: (r) => r.preventDefault(),
|
|
2074
|
+
onDragLeave: Sn,
|
|
2075
|
+
onDrop: En,
|
|
2076
|
+
onClick: () => !_ && on(),
|
|
2077
|
+
onKeyDown: Hn,
|
|
2078
|
+
children: [
|
|
2079
|
+
sn,
|
|
2080
|
+
E ?? /* @__PURE__ */ f(vn, { children: [
|
|
2081
|
+
z && /* @__PURE__ */ e("div", { className: "nice-upload__icon", "aria-hidden": "true", children: /* @__PURE__ */ e(Ae, { name: z, size: "lg" }) }),
|
|
2082
|
+
(_e ? yn : tn) && /* @__PURE__ */ f("div", { className: "nice-fileuploader__label nice-upload__label", children: [
|
|
2083
|
+
_e ? yn : tn,
|
|
2084
|
+
T && /* @__PURE__ */ f("span", { className: "nice-upload__browse", children: [
|
|
2085
|
+
" ",
|
|
2086
|
+
T
|
|
2087
|
+
] })
|
|
2088
|
+
] })
|
|
2089
|
+
] })
|
|
2090
|
+
]
|
|
2091
|
+
}
|
|
2092
|
+
),
|
|
2093
|
+
I && B.length > 0 && /* @__PURE__ */ e(
|
|
2094
|
+
"div",
|
|
2095
|
+
{
|
|
2096
|
+
className: `nice-fileuploader__list nice-upload__list nice-upload__list--${ne}`,
|
|
2097
|
+
children: B.map(Mn)
|
|
2098
|
+
}
|
|
2099
|
+
),
|
|
2100
|
+
g && B.length > 0 && !N && /* @__PURE__ */ f("div", { className: "nice-upload__bulk", children: [
|
|
2101
|
+
nn.pending > 0 && /* @__PURE__ */ e(
|
|
2102
|
+
"button",
|
|
2103
|
+
{
|
|
2104
|
+
type: "button",
|
|
2105
|
+
className: "nice-btn nice-btn--primary nice-btn--sm",
|
|
2106
|
+
onClick: De,
|
|
2107
|
+
children: j("fileUpload.bulk.uploadAll", "Upload all ({n})").replace(
|
|
2108
|
+
"{n}",
|
|
2109
|
+
String(nn.pending)
|
|
2110
|
+
)
|
|
2111
|
+
}
|
|
2112
|
+
),
|
|
2113
|
+
nn.error > 0 && /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: je, children: j("fileUpload.bulk.retryFailed", "Retry failed ({n})").replace(
|
|
2114
|
+
"{n}",
|
|
2115
|
+
String(nn.error)
|
|
2116
|
+
) }),
|
|
2117
|
+
/* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: Ie, children: j("fileUpload.bulk.clear", "Clear") })
|
|
2118
|
+
] }),
|
|
2119
|
+
!g && w === "useButtons" && B.length > 0 && !N && /* @__PURE__ */ f("div", { className: "nice-fileuploader__actions nice-upload__actions", children: [
|
|
2120
|
+
/* @__PURE__ */ e(
|
|
2121
|
+
"button",
|
|
2122
|
+
{
|
|
2123
|
+
type: "button",
|
|
2124
|
+
className: "nice-btn nice-btn--primary nice-btn--sm",
|
|
2125
|
+
onClick: () => v(Ne.current),
|
|
2126
|
+
children: j("upload", "Upload")
|
|
2127
|
+
}
|
|
2128
|
+
),
|
|
2129
|
+
/* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: Ie, children: j("clearAll", "Clear All") })
|
|
2130
|
+
] })
|
|
2131
|
+
]
|
|
2132
|
+
}
|
|
2133
|
+
);
|
|
2134
|
+
}),
|
|
2135
|
+
{ displayName: "NiceUpload" }
|
|
2136
|
+
), gi = [
|
|
2137
|
+
{ label: "Polska", value: "PL" },
|
|
2138
|
+
{ label: "Deutschland", value: "DE" },
|
|
2139
|
+
{ label: "Česko", value: "CZ" },
|
|
2140
|
+
{ label: "Slovensko", value: "SK" },
|
|
2141
|
+
{ label: "United Kingdom", value: "GB" },
|
|
2142
|
+
{ label: "United States", value: "US" },
|
|
2143
|
+
{ label: "France", value: "FR" },
|
|
2144
|
+
{ label: "Italia", value: "IT" },
|
|
2145
|
+
{ label: "España", value: "ES" },
|
|
2146
|
+
{ label: "Nederland", value: "NL" }
|
|
2147
|
+
], vt = ({
|
|
2148
|
+
label: n,
|
|
2149
|
+
helperText: i,
|
|
2150
|
+
error: t,
|
|
2151
|
+
errorPlacement: o = "bottom",
|
|
2152
|
+
required: a,
|
|
2153
|
+
disabled: s,
|
|
2154
|
+
readOnly: u,
|
|
2155
|
+
loading: M,
|
|
2156
|
+
size: w = "md",
|
|
2157
|
+
className: A,
|
|
2158
|
+
style: ce,
|
|
2159
|
+
accessMode: D,
|
|
2160
|
+
id: T,
|
|
2161
|
+
value: X,
|
|
2162
|
+
defaultValue: W,
|
|
2163
|
+
onChange: z,
|
|
2164
|
+
columns: I = 2,
|
|
2165
|
+
showState: $ = !1,
|
|
2166
|
+
showBuilding: Z = !0,
|
|
2167
|
+
showApartment: ne = !0,
|
|
2168
|
+
showCountry: J = !0,
|
|
2169
|
+
countryOptions: pe = gi,
|
|
2170
|
+
defaultCountry: ae = "PL",
|
|
2171
|
+
fieldLabels: k,
|
|
2172
|
+
fieldPlaceholders: U,
|
|
2173
|
+
showLabel: L = !0,
|
|
2174
|
+
labelPlacement: E,
|
|
2175
|
+
labelWidth: de,
|
|
2176
|
+
controlWidth: te
|
|
2177
|
+
}) => {
|
|
2178
|
+
const ee = dn(D, T), R = ee === "hidden";
|
|
2179
|
+
ee === "disabled" && (s = !0), ee === "readOnly" && (u = !0);
|
|
2180
|
+
const { t: S } = Qe(), P = X !== void 0, [p, m] = xn.useState(W ?? {}), y = P ? X : p, V = (ue) => {
|
|
2181
|
+
const re = { ...y, ...ue };
|
|
2182
|
+
P || m(re), z?.(re);
|
|
2183
|
+
}, H = {
|
|
2184
|
+
street: k?.street ?? S("address.street", "Street"),
|
|
2185
|
+
building: k?.building ?? S("address.building", "Building"),
|
|
2186
|
+
apartment: k?.apartment ?? S("address.apartment", "Apt."),
|
|
2187
|
+
postalCode: k?.postalCode ?? S("address.postalCode", "Postal code"),
|
|
2188
|
+
city: k?.city ?? S("address.city", "City"),
|
|
2189
|
+
state: k?.state ?? S("address.state", "State / Region"),
|
|
2190
|
+
country: k?.country ?? S("address.country", "Country")
|
|
2191
|
+
}, _ = U ?? {}, N = y.country ?? ae, Y = E === "left" ? "left" : "top", K = {
|
|
2192
|
+
...ce,
|
|
2193
|
+
...de != null && {
|
|
2194
|
+
"--nice-field-label-width": typeof de == "number" ? `${de}px` : de
|
|
2195
|
+
},
|
|
2196
|
+
...te != null && {
|
|
2197
|
+
"--nice-field-control-width": typeof te == "number" ? `${te}px` : te
|
|
2198
|
+
}
|
|
2199
|
+
}, Q = {
|
|
2200
|
+
display: "grid",
|
|
2201
|
+
gridTemplateColumns: `repeat(${I}, minmax(0, 1fr))`,
|
|
2202
|
+
gap: "8px 12px"
|
|
2203
|
+
}, O = I === 2 ? { gridColumn: "span 2" } : {}, fe = {
|
|
2204
|
+
size: w,
|
|
2205
|
+
disabled: s || M,
|
|
2206
|
+
readOnly: u,
|
|
2207
|
+
labelPlacement: Y
|
|
2208
|
+
};
|
|
2209
|
+
return R ? null : /* @__PURE__ */ f(
|
|
2210
|
+
"div",
|
|
2211
|
+
{
|
|
2212
|
+
className: `nice-field nice-field--${w} nice-address nice-address--cols-${I} ${M ? "nice-field--loading" : ""} ${A || ""}`,
|
|
2213
|
+
style: K,
|
|
2214
|
+
"aria-busy": M || void 0,
|
|
2215
|
+
children: [
|
|
2216
|
+
L && n && /* @__PURE__ */ e("label", { className: `nice-field__label ${a ? "nice-field__label--required" : ""}`, children: n }),
|
|
2217
|
+
/* @__PURE__ */ f("div", { className: "nice-field__control", children: [
|
|
2218
|
+
/* @__PURE__ */ f("div", { className: "nice-address__grid", style: Q, children: [
|
|
2219
|
+
/* @__PURE__ */ e("div", { style: O, children: /* @__PURE__ */ e(
|
|
2220
|
+
an,
|
|
2221
|
+
{
|
|
2222
|
+
...fe,
|
|
2223
|
+
label: H.street,
|
|
2224
|
+
value: y.street ?? "",
|
|
2225
|
+
onChange: (ue) => V({ street: ue }),
|
|
2226
|
+
placeholder: _.street,
|
|
2227
|
+
required: a
|
|
2228
|
+
}
|
|
2229
|
+
) }),
|
|
2230
|
+
Z && /* @__PURE__ */ e(
|
|
2231
|
+
an,
|
|
2232
|
+
{
|
|
2233
|
+
...fe,
|
|
2234
|
+
label: H.building,
|
|
2235
|
+
value: y.building ?? "",
|
|
2236
|
+
onChange: (ue) => V({ building: ue }),
|
|
2237
|
+
placeholder: _.building
|
|
2238
|
+
}
|
|
2239
|
+
),
|
|
2240
|
+
ne && /* @__PURE__ */ e(
|
|
2241
|
+
an,
|
|
2242
|
+
{
|
|
2243
|
+
...fe,
|
|
2244
|
+
label: H.apartment,
|
|
2245
|
+
value: y.apartment ?? "",
|
|
2246
|
+
onChange: (ue) => V({ apartment: ue }),
|
|
2247
|
+
placeholder: _.apartment
|
|
2248
|
+
}
|
|
2249
|
+
),
|
|
2250
|
+
/* @__PURE__ */ e(
|
|
2251
|
+
an,
|
|
2252
|
+
{
|
|
2253
|
+
...fe,
|
|
2254
|
+
label: H.postalCode,
|
|
2255
|
+
value: y.postalCode ?? "",
|
|
2256
|
+
onChange: (ue) => V({ postalCode: ue }),
|
|
2257
|
+
placeholder: _.postalCode ?? "00-000",
|
|
2258
|
+
required: a
|
|
2259
|
+
}
|
|
2260
|
+
),
|
|
2261
|
+
/* @__PURE__ */ e(
|
|
2262
|
+
an,
|
|
2263
|
+
{
|
|
2264
|
+
...fe,
|
|
2265
|
+
label: H.city,
|
|
2266
|
+
value: y.city ?? "",
|
|
2267
|
+
onChange: (ue) => V({ city: ue }),
|
|
2268
|
+
placeholder: _.city,
|
|
2269
|
+
required: a
|
|
2270
|
+
}
|
|
2271
|
+
),
|
|
2272
|
+
$ && /* @__PURE__ */ e(
|
|
2273
|
+
an,
|
|
2274
|
+
{
|
|
2275
|
+
...fe,
|
|
2276
|
+
label: H.state,
|
|
2277
|
+
value: y.state ?? "",
|
|
2278
|
+
onChange: (ue) => V({ state: ue }),
|
|
2279
|
+
placeholder: _.state
|
|
2280
|
+
}
|
|
2281
|
+
),
|
|
2282
|
+
J && /* @__PURE__ */ e(
|
|
2283
|
+
ft,
|
|
2284
|
+
{
|
|
2285
|
+
...fe,
|
|
2286
|
+
label: H.country,
|
|
2287
|
+
value: N,
|
|
2288
|
+
onChange: (ue) => V({ country: typeof ue == "string" ? ue : String(ue ?? "") }),
|
|
2289
|
+
options: pe,
|
|
2290
|
+
required: a
|
|
2291
|
+
}
|
|
2292
|
+
)
|
|
2293
|
+
] }),
|
|
2294
|
+
M && /* @__PURE__ */ e("span", { className: "nice-field__spinner nice-field__spinner--address", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
2295
|
+
o === "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
|
|
2296
|
+
o === "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: i })
|
|
2297
|
+
] }),
|
|
2298
|
+
o !== "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
|
|
2299
|
+
o !== "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: i })
|
|
2300
|
+
]
|
|
2301
|
+
}
|
|
2302
|
+
);
|
|
2303
|
+
};
|
|
2304
|
+
process.env.NODE_ENV !== "production" && (vt.displayName = "NiceAddress");
|
|
2305
|
+
const yi = [
|
|
2306
|
+
{ code: "US", name: "United States", dialCode: "+1", flag: "🇺🇸" },
|
|
2307
|
+
{ code: "GB", name: "United Kingdom", dialCode: "+44", flag: "🇬🇧" },
|
|
2308
|
+
{ code: "DE", name: "Germany", dialCode: "+49", flag: "🇩🇪" },
|
|
2309
|
+
{ code: "FR", name: "France", dialCode: "+33", flag: "🇫🇷" },
|
|
2310
|
+
{ code: "PL", name: "Poland", dialCode: "+48", flag: "🇵🇱" },
|
|
2311
|
+
{ code: "ES", name: "Spain", dialCode: "+34", flag: "🇪🇸" },
|
|
2312
|
+
{ code: "IT", name: "Italy", dialCode: "+39", flag: "🇮🇹" },
|
|
2313
|
+
{ code: "NL", name: "Netherlands", dialCode: "+31", flag: "🇳🇱" },
|
|
2314
|
+
{ code: "BE", name: "Belgium", dialCode: "+32", flag: "🇧🇪" },
|
|
2315
|
+
{ code: "AT", name: "Austria", dialCode: "+43", flag: "🇦🇹" },
|
|
2316
|
+
{ code: "CH", name: "Switzerland", dialCode: "+41", flag: "🇨🇭" },
|
|
2317
|
+
{ code: "SE", name: "Sweden", dialCode: "+46", flag: "🇸🇪" },
|
|
2318
|
+
{ code: "NO", name: "Norway", dialCode: "+47", flag: "🇳🇴" },
|
|
2319
|
+
{ code: "DK", name: "Denmark", dialCode: "+45", flag: "🇩🇰" },
|
|
2320
|
+
{ code: "FI", name: "Finland", dialCode: "+358", flag: "🇫🇮" },
|
|
2321
|
+
{ code: "PT", name: "Portugal", dialCode: "+351", flag: "🇵🇹" },
|
|
2322
|
+
{ code: "IE", name: "Ireland", dialCode: "+353", flag: "🇮🇪" },
|
|
2323
|
+
{ code: "CZ", name: "Czech Republic", dialCode: "+420", flag: "🇨🇿" },
|
|
2324
|
+
{ code: "SK", name: "Slovakia", dialCode: "+421", flag: "🇸🇰" },
|
|
2325
|
+
{ code: "HU", name: "Hungary", dialCode: "+36", flag: "🇭🇺" },
|
|
2326
|
+
{ code: "RO", name: "Romania", dialCode: "+40", flag: "🇷🇴" },
|
|
2327
|
+
{ code: "BG", name: "Bulgaria", dialCode: "+359", flag: "🇧🇬" },
|
|
2328
|
+
{ code: "GR", name: "Greece", dialCode: "+30", flag: "🇬🇷" },
|
|
2329
|
+
{ code: "UA", name: "Ukraine", dialCode: "+380", flag: "🇺🇦" },
|
|
2330
|
+
{ code: "RU", name: "Russia", dialCode: "+7", flag: "🇷🇺" },
|
|
2331
|
+
{ code: "CA", name: "Canada", dialCode: "+1", flag: "🇨🇦" },
|
|
2332
|
+
{ code: "AU", name: "Australia", dialCode: "+61", flag: "🇦🇺" },
|
|
2333
|
+
{ code: "NZ", name: "New Zealand", dialCode: "+64", flag: "🇳🇿" },
|
|
2334
|
+
{ code: "JP", name: "Japan", dialCode: "+81", flag: "🇯🇵" },
|
|
2335
|
+
{ code: "KR", name: "South Korea", dialCode: "+82", flag: "🇰🇷" },
|
|
2336
|
+
{ code: "CN", name: "China", dialCode: "+86", flag: "🇨🇳" },
|
|
2337
|
+
{ code: "IN", name: "India", dialCode: "+91", flag: "🇮🇳" },
|
|
2338
|
+
{ code: "SG", name: "Singapore", dialCode: "+65", flag: "🇸🇬" },
|
|
2339
|
+
{ code: "MY", name: "Malaysia", dialCode: "+60", flag: "🇲🇾" },
|
|
2340
|
+
{ code: "TH", name: "Thailand", dialCode: "+66", flag: "🇹🇭" },
|
|
2341
|
+
{ code: "VN", name: "Vietnam", dialCode: "+84", flag: "🇻🇳" },
|
|
2342
|
+
{ code: "ID", name: "Indonesia", dialCode: "+62", flag: "🇮🇩" },
|
|
2343
|
+
{ code: "PH", name: "Philippines", dialCode: "+63", flag: "🇵🇭" },
|
|
2344
|
+
{ code: "BR", name: "Brazil", dialCode: "+55", flag: "🇧🇷" },
|
|
2345
|
+
{ code: "MX", name: "Mexico", dialCode: "+52", flag: "🇲🇽" },
|
|
2346
|
+
{ code: "AR", name: "Argentina", dialCode: "+54", flag: "🇦🇷" },
|
|
2347
|
+
{ code: "CL", name: "Chile", dialCode: "+56", flag: "🇨🇱" },
|
|
2348
|
+
{ code: "CO", name: "Colombia", dialCode: "+57", flag: "🇨🇴" },
|
|
2349
|
+
{ code: "PE", name: "Peru", dialCode: "+51", flag: "🇵🇪" },
|
|
2350
|
+
{ code: "ZA", name: "South Africa", dialCode: "+27", flag: "🇿🇦" },
|
|
2351
|
+
{ code: "EG", name: "Egypt", dialCode: "+20", flag: "🇪🇬" },
|
|
2352
|
+
{ code: "NG", name: "Nigeria", dialCode: "+234", flag: "🇳🇬" },
|
|
2353
|
+
{ code: "KE", name: "Kenya", dialCode: "+254", flag: "🇰🇪" },
|
|
2354
|
+
{ code: "AE", name: "United Arab Emirates", dialCode: "+971", flag: "🇦🇪" },
|
|
2355
|
+
{ code: "SA", name: "Saudi Arabia", dialCode: "+966", flag: "🇸🇦" },
|
|
2356
|
+
{ code: "IL", name: "Israel", dialCode: "+972", flag: "🇮🇱" },
|
|
2357
|
+
{ code: "TR", name: "Turkey", dialCode: "+90", flag: "🇹🇷" },
|
|
2358
|
+
// Additional countries
|
|
2359
|
+
{ code: "AF", name: "Afghanistan", dialCode: "+93", flag: "🇦🇫" },
|
|
2360
|
+
{ code: "AL", name: "Albania", dialCode: "+355", flag: "🇦🇱" },
|
|
2361
|
+
{ code: "DZ", name: "Algeria", dialCode: "+213", flag: "🇩🇿" },
|
|
2362
|
+
{ code: "AD", name: "Andorra", dialCode: "+376", flag: "🇦🇩" },
|
|
2363
|
+
{ code: "AO", name: "Angola", dialCode: "+244", flag: "🇦🇴" },
|
|
2364
|
+
{ code: "AG", name: "Antigua and Barbuda", dialCode: "+1268", flag: "🇦🇬" },
|
|
2365
|
+
{ code: "AM", name: "Armenia", dialCode: "+374", flag: "🇦🇲" },
|
|
2366
|
+
{ code: "AZ", name: "Azerbaijan", dialCode: "+994", flag: "🇦🇿" },
|
|
2367
|
+
{ code: "BS", name: "Bahamas", dialCode: "+1242", flag: "🇧🇸" },
|
|
2368
|
+
{ code: "BH", name: "Bahrain", dialCode: "+973", flag: "🇧🇭" },
|
|
2369
|
+
{ code: "BD", name: "Bangladesh", dialCode: "+880", flag: "🇧🇩" },
|
|
2370
|
+
{ code: "BB", name: "Barbados", dialCode: "+1246", flag: "🇧🇧" },
|
|
2371
|
+
{ code: "BY", name: "Belarus", dialCode: "+375", flag: "🇧🇾" },
|
|
2372
|
+
{ code: "BZ", name: "Belize", dialCode: "+501", flag: "🇧🇿" },
|
|
2373
|
+
{ code: "BJ", name: "Benin", dialCode: "+229", flag: "🇧🇯" },
|
|
2374
|
+
{ code: "BT", name: "Bhutan", dialCode: "+975", flag: "🇧🇹" },
|
|
2375
|
+
{ code: "BO", name: "Bolivia", dialCode: "+591", flag: "🇧🇴" },
|
|
2376
|
+
{ code: "BA", name: "Bosnia and Herzegovina", dialCode: "+387", flag: "🇧🇦" },
|
|
2377
|
+
{ code: "BW", name: "Botswana", dialCode: "+267", flag: "🇧🇼" },
|
|
2378
|
+
{ code: "BN", name: "Brunei", dialCode: "+673", flag: "🇧🇳" },
|
|
2379
|
+
{ code: "BF", name: "Burkina Faso", dialCode: "+226", flag: "🇧🇫" },
|
|
2380
|
+
{ code: "BI", name: "Burundi", dialCode: "+257", flag: "🇧🇮" },
|
|
2381
|
+
{ code: "CV", name: "Cape Verde", dialCode: "+238", flag: "🇨🇻" },
|
|
2382
|
+
{ code: "KH", name: "Cambodia", dialCode: "+855", flag: "🇰🇭" },
|
|
2383
|
+
{ code: "CM", name: "Cameroon", dialCode: "+237", flag: "🇨🇲" },
|
|
2384
|
+
{ code: "CF", name: "Central African Republic", dialCode: "+236", flag: "🇨🇫" },
|
|
2385
|
+
{ code: "TD", name: "Chad", dialCode: "+235", flag: "🇹🇩" },
|
|
2386
|
+
{ code: "KM", name: "Comoros", dialCode: "+269", flag: "🇰🇲" },
|
|
2387
|
+
{ code: "CG", name: "Congo", dialCode: "+242", flag: "🇨🇬" },
|
|
2388
|
+
{ code: "CD", name: "DR Congo", dialCode: "+243", flag: "🇨🇩" },
|
|
2389
|
+
{ code: "CR", name: "Costa Rica", dialCode: "+506", flag: "🇨🇷" },
|
|
2390
|
+
{ code: "CI", name: "Côte d'Ivoire", dialCode: "+225", flag: "🇨🇮" },
|
|
2391
|
+
{ code: "HR", name: "Croatia", dialCode: "+385", flag: "🇭🇷" },
|
|
2392
|
+
{ code: "CU", name: "Cuba", dialCode: "+53", flag: "🇨🇺" },
|
|
2393
|
+
{ code: "CY", name: "Cyprus", dialCode: "+357", flag: "🇨🇾" },
|
|
2394
|
+
{ code: "DJ", name: "Djibouti", dialCode: "+253", flag: "🇩🇯" },
|
|
2395
|
+
{ code: "DM", name: "Dominica", dialCode: "+1767", flag: "🇩🇲" },
|
|
2396
|
+
{ code: "DO", name: "Dominican Republic", dialCode: "+1809", flag: "🇩🇴" },
|
|
2397
|
+
{ code: "EC", name: "Ecuador", dialCode: "+593", flag: "🇪🇨" },
|
|
2398
|
+
{ code: "SV", name: "El Salvador", dialCode: "+503", flag: "🇸🇻" },
|
|
2399
|
+
{ code: "GQ", name: "Equatorial Guinea", dialCode: "+240", flag: "🇬🇶" },
|
|
2400
|
+
{ code: "ER", name: "Eritrea", dialCode: "+291", flag: "🇪🇷" },
|
|
2401
|
+
{ code: "EE", name: "Estonia", dialCode: "+372", flag: "🇪🇪" },
|
|
2402
|
+
{ code: "SZ", name: "Eswatini", dialCode: "+268", flag: "🇸🇿" },
|
|
2403
|
+
{ code: "ET", name: "Ethiopia", dialCode: "+251", flag: "🇪🇹" },
|
|
2404
|
+
{ code: "FJ", name: "Fiji", dialCode: "+679", flag: "🇫🇯" },
|
|
2405
|
+
{ code: "GA", name: "Gabon", dialCode: "+241", flag: "🇬🇦" },
|
|
2406
|
+
{ code: "GM", name: "Gambia", dialCode: "+220", flag: "🇬🇲" },
|
|
2407
|
+
{ code: "GE", name: "Georgia", dialCode: "+995", flag: "🇬🇪" },
|
|
2408
|
+
{ code: "GH", name: "Ghana", dialCode: "+233", flag: "🇬🇭" },
|
|
2409
|
+
{ code: "GD", name: "Grenada", dialCode: "+1473", flag: "🇬🇩" },
|
|
2410
|
+
{ code: "GT", name: "Guatemala", dialCode: "+502", flag: "🇬🇹" },
|
|
2411
|
+
{ code: "GN", name: "Guinea", dialCode: "+224", flag: "🇬🇳" },
|
|
2412
|
+
{ code: "GW", name: "Guinea-Bissau", dialCode: "+245", flag: "🇬🇼" },
|
|
2413
|
+
{ code: "GY", name: "Guyana", dialCode: "+592", flag: "🇬🇾" },
|
|
2414
|
+
{ code: "HT", name: "Haiti", dialCode: "+509", flag: "🇭🇹" },
|
|
2415
|
+
{ code: "HN", name: "Honduras", dialCode: "+504", flag: "🇭🇳" },
|
|
2416
|
+
{ code: "HK", name: "Hong Kong", dialCode: "+852", flag: "🇭🇰" },
|
|
2417
|
+
{ code: "IS", name: "Iceland", dialCode: "+354", flag: "🇮🇸" },
|
|
2418
|
+
{ code: "IQ", name: "Iraq", dialCode: "+964", flag: "🇮🇶" },
|
|
2419
|
+
{ code: "IR", name: "Iran", dialCode: "+98", flag: "🇮🇷" },
|
|
2420
|
+
{ code: "JM", name: "Jamaica", dialCode: "+1876", flag: "🇯🇲" },
|
|
2421
|
+
{ code: "JO", name: "Jordan", dialCode: "+962", flag: "🇯🇴" },
|
|
2422
|
+
{ code: "KZ", name: "Kazakhstan", dialCode: "+7", flag: "🇰🇿" },
|
|
2423
|
+
{ code: "KW", name: "Kuwait", dialCode: "+965", flag: "🇰🇼" },
|
|
2424
|
+
{ code: "KG", name: "Kyrgyzstan", dialCode: "+996", flag: "🇰🇬" },
|
|
2425
|
+
{ code: "LA", name: "Laos", dialCode: "+856", flag: "🇱🇦" },
|
|
2426
|
+
{ code: "LV", name: "Latvia", dialCode: "+371", flag: "🇱🇻" },
|
|
2427
|
+
{ code: "LB", name: "Lebanon", dialCode: "+961", flag: "🇱🇧" },
|
|
2428
|
+
{ code: "LS", name: "Lesotho", dialCode: "+266", flag: "🇱🇸" },
|
|
2429
|
+
{ code: "LR", name: "Liberia", dialCode: "+231", flag: "🇱🇷" },
|
|
2430
|
+
{ code: "LY", name: "Libya", dialCode: "+218", flag: "🇱🇾" },
|
|
2431
|
+
{ code: "LI", name: "Liechtenstein", dialCode: "+423", flag: "🇱🇮" },
|
|
2432
|
+
{ code: "LT", name: "Lithuania", dialCode: "+370", flag: "🇱🇹" },
|
|
2433
|
+
{ code: "LU", name: "Luxembourg", dialCode: "+352", flag: "🇱🇺" },
|
|
2434
|
+
{ code: "MO", name: "Macau", dialCode: "+853", flag: "🇲🇴" },
|
|
2435
|
+
{ code: "MK", name: "North Macedonia", dialCode: "+389", flag: "🇲🇰" },
|
|
2436
|
+
{ code: "MG", name: "Madagascar", dialCode: "+261", flag: "🇲🇬" },
|
|
2437
|
+
{ code: "MW", name: "Malawi", dialCode: "+265", flag: "🇲🇼" },
|
|
2438
|
+
{ code: "MV", name: "Maldives", dialCode: "+960", flag: "🇲🇻" },
|
|
2439
|
+
{ code: "ML", name: "Mali", dialCode: "+223", flag: "🇲🇱" },
|
|
2440
|
+
{ code: "MT", name: "Malta", dialCode: "+356", flag: "🇲🇹" },
|
|
2441
|
+
{ code: "MR", name: "Mauritania", dialCode: "+222", flag: "🇲🇷" },
|
|
2442
|
+
{ code: "MU", name: "Mauritius", dialCode: "+230", flag: "🇲🇺" },
|
|
2443
|
+
{ code: "MD", name: "Moldova", dialCode: "+373", flag: "🇲🇩" },
|
|
2444
|
+
{ code: "MC", name: "Monaco", dialCode: "+377", flag: "🇲🇨" },
|
|
2445
|
+
{ code: "MN", name: "Mongolia", dialCode: "+976", flag: "🇲🇳" },
|
|
2446
|
+
{ code: "ME", name: "Montenegro", dialCode: "+382", flag: "🇲🇪" },
|
|
2447
|
+
{ code: "MA", name: "Morocco", dialCode: "+212", flag: "🇲🇦" },
|
|
2448
|
+
{ code: "MZ", name: "Mozambique", dialCode: "+258", flag: "🇲🇿" },
|
|
2449
|
+
{ code: "MM", name: "Myanmar", dialCode: "+95", flag: "🇲🇲" },
|
|
2450
|
+
{ code: "NA", name: "Namibia", dialCode: "+264", flag: "🇳🇦" },
|
|
2451
|
+
{ code: "NP", name: "Nepal", dialCode: "+977", flag: "🇳🇵" },
|
|
2452
|
+
{ code: "NI", name: "Nicaragua", dialCode: "+505", flag: "🇳🇮" },
|
|
2453
|
+
{ code: "NE", name: "Niger", dialCode: "+227", flag: "🇳🇪" },
|
|
2454
|
+
{ code: "KP", name: "North Korea", dialCode: "+850", flag: "🇰🇵" },
|
|
2455
|
+
{ code: "OM", name: "Oman", dialCode: "+968", flag: "🇴🇲" },
|
|
2456
|
+
{ code: "PK", name: "Pakistan", dialCode: "+92", flag: "🇵🇰" },
|
|
2457
|
+
{ code: "PS", name: "Palestine", dialCode: "+970", flag: "🇵🇸" },
|
|
2458
|
+
{ code: "PA", name: "Panama", dialCode: "+507", flag: "🇵🇦" },
|
|
2459
|
+
{ code: "PG", name: "Papua New Guinea", dialCode: "+675", flag: "🇵🇬" },
|
|
2460
|
+
{ code: "PY", name: "Paraguay", dialCode: "+595", flag: "🇵🇾" },
|
|
2461
|
+
{ code: "QA", name: "Qatar", dialCode: "+974", flag: "🇶🇦" },
|
|
2462
|
+
{ code: "RW", name: "Rwanda", dialCode: "+250", flag: "🇷🇼" },
|
|
2463
|
+
{ code: "WS", name: "Samoa", dialCode: "+685", flag: "🇼🇸" },
|
|
2464
|
+
{ code: "SM", name: "San Marino", dialCode: "+378", flag: "🇸🇲" },
|
|
2465
|
+
{ code: "ST", name: "São Tomé and Príncipe", dialCode: "+239", flag: "🇸🇹" },
|
|
2466
|
+
{ code: "SN", name: "Senegal", dialCode: "+221", flag: "🇸🇳" },
|
|
2467
|
+
{ code: "RS", name: "Serbia", dialCode: "+381", flag: "🇷🇸" },
|
|
2468
|
+
{ code: "SC", name: "Seychelles", dialCode: "+248", flag: "🇸🇨" },
|
|
2469
|
+
{ code: "SL", name: "Sierra Leone", dialCode: "+232", flag: "🇸🇱" },
|
|
2470
|
+
{ code: "SI", name: "Slovenia", dialCode: "+386", flag: "🇸🇮" },
|
|
2471
|
+
{ code: "SB", name: "Solomon Islands", dialCode: "+677", flag: "🇸🇧" },
|
|
2472
|
+
{ code: "SO", name: "Somalia", dialCode: "+252", flag: "🇸🇴" },
|
|
2473
|
+
{ code: "SS", name: "South Sudan", dialCode: "+211", flag: "🇸🇸" },
|
|
2474
|
+
{ code: "LK", name: "Sri Lanka", dialCode: "+94", flag: "🇱🇰" },
|
|
2475
|
+
{ code: "SD", name: "Sudan", dialCode: "+249", flag: "🇸🇩" },
|
|
2476
|
+
{ code: "SR", name: "Suriname", dialCode: "+597", flag: "🇸🇷" },
|
|
2477
|
+
{ code: "SY", name: "Syria", dialCode: "+963", flag: "🇸🇾" },
|
|
2478
|
+
{ code: "TW", name: "Taiwan", dialCode: "+886", flag: "🇹🇼" },
|
|
2479
|
+
{ code: "TJ", name: "Tajikistan", dialCode: "+992", flag: "🇹🇯" },
|
|
2480
|
+
{ code: "TZ", name: "Tanzania", dialCode: "+255", flag: "🇹🇿" },
|
|
2481
|
+
{ code: "TL", name: "Timor-Leste", dialCode: "+670", flag: "🇹🇱" },
|
|
2482
|
+
{ code: "TG", name: "Togo", dialCode: "+228", flag: "🇹🇬" },
|
|
2483
|
+
{ code: "TO", name: "Tonga", dialCode: "+676", flag: "🇹🇴" },
|
|
2484
|
+
{ code: "TT", name: "Trinidad and Tobago", dialCode: "+1868", flag: "🇹🇹" },
|
|
2485
|
+
{ code: "TN", name: "Tunisia", dialCode: "+216", flag: "🇹🇳" },
|
|
2486
|
+
{ code: "TM", name: "Turkmenistan", dialCode: "+993", flag: "🇹🇲" },
|
|
2487
|
+
{ code: "UG", name: "Uganda", dialCode: "+256", flag: "🇺🇬" },
|
|
2488
|
+
{ code: "UY", name: "Uruguay", dialCode: "+598", flag: "🇺🇾" },
|
|
2489
|
+
{ code: "UZ", name: "Uzbekistan", dialCode: "+998", flag: "🇺🇿" },
|
|
2490
|
+
{ code: "VU", name: "Vanuatu", dialCode: "+678", flag: "🇻🇺" },
|
|
2491
|
+
{ code: "VA", name: "Vatican City", dialCode: "+379", flag: "🇻🇦" },
|
|
2492
|
+
{ code: "VE", name: "Venezuela", dialCode: "+58", flag: "🇻🇪" },
|
|
2493
|
+
{ code: "YE", name: "Yemen", dialCode: "+967", flag: "🇾🇪" },
|
|
2494
|
+
{ code: "ZM", name: "Zambia", dialCode: "+260", flag: "🇿🇲" },
|
|
2495
|
+
{ code: "ZW", name: "Zimbabwe", dialCode: "+263", flag: "🇿🇼" }
|
|
2496
|
+
], bt = ({
|
|
2497
|
+
value: n,
|
|
2498
|
+
defaultValue: i,
|
|
2499
|
+
onChange: t,
|
|
2500
|
+
placeholder: o,
|
|
2501
|
+
showSearch: a = !0,
|
|
2502
|
+
searchPlaceholder: s,
|
|
2503
|
+
showFlagInValue: u,
|
|
2504
|
+
showFlagInMenu: M,
|
|
2505
|
+
showTextInValue: w,
|
|
2506
|
+
showTextInMenu: A,
|
|
2507
|
+
showDialCodeInValue: ce,
|
|
2508
|
+
showDialCodeInMenu: D,
|
|
2509
|
+
showCodeInValue: T = !1,
|
|
2510
|
+
showCodeInMenu: X = !1,
|
|
2511
|
+
compact: W = !1,
|
|
2512
|
+
variant: z = "default",
|
|
2513
|
+
dropdownAlign: I,
|
|
2514
|
+
disabled: $ = !1,
|
|
2515
|
+
countries: Z,
|
|
2516
|
+
priorityCountries: ne = ["US", "GB", "DE", "FR", "PL"],
|
|
2517
|
+
allowClear: J = !1,
|
|
2518
|
+
size: pe = "md",
|
|
2519
|
+
className: ae = "",
|
|
2520
|
+
style: k,
|
|
2521
|
+
// NiceFormFieldProps extras (label/error/state placement etc.)
|
|
2522
|
+
label: U,
|
|
2523
|
+
helperText: L,
|
|
2524
|
+
error: E,
|
|
2525
|
+
required: de,
|
|
2526
|
+
readOnly: te,
|
|
2527
|
+
loading: ee,
|
|
2528
|
+
labelPlacement: R,
|
|
2529
|
+
errorPlacement: S,
|
|
2530
|
+
labelWidth: P,
|
|
2531
|
+
controlWidth: p,
|
|
2532
|
+
id: m,
|
|
2533
|
+
"data-testid": y = "nice-country-picker"
|
|
2534
|
+
}) => {
|
|
2535
|
+
const { t: V } = Qe(), H = be(null), _ = be(null), N = be(null), [Y, K] = Te(i), [Q, O] = Te(!1), [fe, ue] = Te(""), [re, le] = Te(0), q = u ?? !0, Ce = M ?? !0, j = w ?? !W, B = A ?? !0, oe = ce ?? !W, _e = D ?? !0, Ee = Ht(
|
|
2536
|
+
Q,
|
|
2537
|
+
_,
|
|
2538
|
+
I ?? (W ? "auto" : "left")
|
|
2539
|
+
), Ne = n !== void 0 ? n : Y, Ye = ge(() => {
|
|
2540
|
+
let g = yi;
|
|
2541
|
+
if (Z) {
|
|
2542
|
+
const v = new Set(Z.map((Xe) => Xe.toUpperCase()));
|
|
2543
|
+
g = g.filter((Xe) => v.has(Xe.code));
|
|
2544
|
+
}
|
|
2545
|
+
return g;
|
|
2546
|
+
}, [Z]), ze = ge(() => {
|
|
2547
|
+
if (!ne?.length)
|
|
2548
|
+
return Ye;
|
|
2549
|
+
const g = new Set(ne.map((Ke) => Ke.toUpperCase())), v = Ye.filter((Ke) => g.has(Ke.code)), Xe = Ye.filter((Ke) => !g.has(Ke.code));
|
|
2550
|
+
return [...v, ...Xe];
|
|
2551
|
+
}, [Ye, ne]), h = ge(() => {
|
|
2552
|
+
if (!fe)
|
|
2553
|
+
return ze;
|
|
2554
|
+
const g = fe.toLowerCase();
|
|
2555
|
+
return ze.filter(
|
|
2556
|
+
(v) => v.name.toLowerCase().includes(g) || v.code.toLowerCase().includes(g) || v.dialCode.includes(g)
|
|
2557
|
+
);
|
|
2558
|
+
}, [ze, fe]), d = ge(() => Ne ? Ye.find((g) => g.code === Ne) ?? null : null, [Ne, Ye]);
|
|
2559
|
+
Le(() => {
|
|
2560
|
+
if (!Q)
|
|
2561
|
+
return;
|
|
2562
|
+
const g = (v) => {
|
|
2563
|
+
H.current && !H.current.contains(v.target) && (O(!1), ue(""));
|
|
2564
|
+
};
|
|
2565
|
+
return document.addEventListener("mousedown", g), () => document.removeEventListener("mousedown", g);
|
|
2566
|
+
}, [Q]), Le(() => {
|
|
2567
|
+
Q && a && N.current && N.current.focus();
|
|
2568
|
+
}, [Q, a]), Le(() => {
|
|
2569
|
+
le(0);
|
|
2570
|
+
}, [fe]);
|
|
2571
|
+
const C = F(
|
|
2572
|
+
(g) => {
|
|
2573
|
+
n === void 0 && K(g.code), t?.(g), O(!1), ue("");
|
|
2574
|
+
},
|
|
2575
|
+
[n, t]
|
|
2576
|
+
), ke = F(
|
|
2577
|
+
(g) => {
|
|
2578
|
+
g.stopPropagation(), n === void 0 && K(void 0), t?.(null);
|
|
2579
|
+
},
|
|
2580
|
+
[n, t]
|
|
2581
|
+
), ve = F(
|
|
2582
|
+
(g) => {
|
|
2583
|
+
if (!Q) {
|
|
2584
|
+
(g.key === "Enter" || g.key === " " || g.key === "ArrowDown") && (g.preventDefault(), O(!0));
|
|
2585
|
+
return;
|
|
2586
|
+
}
|
|
2587
|
+
switch (g.key) {
|
|
2588
|
+
case "ArrowDown":
|
|
2589
|
+
g.preventDefault(), le((v) => Math.min(v + 1, h.length - 1));
|
|
2590
|
+
break;
|
|
2591
|
+
case "ArrowUp":
|
|
2592
|
+
g.preventDefault(), le((v) => Math.max(v - 1, 0));
|
|
2593
|
+
break;
|
|
2594
|
+
case "Enter":
|
|
2595
|
+
g.preventDefault(), h[re] && C(h[re]);
|
|
2596
|
+
break;
|
|
2597
|
+
case "Escape":
|
|
2598
|
+
g.preventDefault(), O(!1), ue("");
|
|
2599
|
+
break;
|
|
2600
|
+
}
|
|
2601
|
+
},
|
|
2602
|
+
[Q, h, re, C]
|
|
2603
|
+
);
|
|
2604
|
+
return /* @__PURE__ */ f(
|
|
2605
|
+
"div",
|
|
2606
|
+
{
|
|
2607
|
+
ref: H,
|
|
2608
|
+
className: `nice-field nice-field--${pe} nice-field--country-picker ${R === "left" ? "nice-field--label-left" : ""} ${S === "right" ? "nice-field--error-right" : ""} ${E ? "nice-field--error" : ""} ${ee ? "nice-field--loading" : ""} nice-country-picker nice-country-picker--${pe} ${W ? "nice-country-picker--compact" : ""} ${z === "ghost" ? "nice-country-picker--ghost" : ""} ${Q ? "nice-country-picker--open" : ""} ${$ ? "nice-country-picker--disabled" : ""} ${ae}`,
|
|
2609
|
+
style: {
|
|
2610
|
+
...k,
|
|
2611
|
+
...P != null && {
|
|
2612
|
+
"--nice-field-label-width": typeof P == "number" ? `${P}px` : P
|
|
2613
|
+
},
|
|
2614
|
+
...p != null && {
|
|
2615
|
+
"--nice-field-control-width": typeof p == "number" ? `${p}px` : p
|
|
2616
|
+
}
|
|
2617
|
+
},
|
|
2618
|
+
"data-testid": y,
|
|
2619
|
+
"aria-busy": ee || void 0,
|
|
2620
|
+
children: [
|
|
2621
|
+
U && /* @__PURE__ */ f("label", { className: "nice-field__label", htmlFor: m, children: [
|
|
2622
|
+
U,
|
|
2623
|
+
de && /* @__PURE__ */ e("span", { className: "nice-field__required", children: "*" })
|
|
2624
|
+
] }),
|
|
2625
|
+
/* @__PURE__ */ f("div", { className: "nice-field__control", children: [
|
|
2626
|
+
/* @__PURE__ */ f(
|
|
2627
|
+
"button",
|
|
2628
|
+
{
|
|
2629
|
+
ref: _,
|
|
2630
|
+
type: "button",
|
|
2631
|
+
className: "nice-country-picker__trigger",
|
|
2632
|
+
onClick: () => !$ && !te && O(!Q),
|
|
2633
|
+
onKeyDown: ve,
|
|
2634
|
+
disabled: $,
|
|
2635
|
+
id: m,
|
|
2636
|
+
"aria-haspopup": "listbox",
|
|
2637
|
+
"aria-expanded": Q,
|
|
2638
|
+
"aria-invalid": E ? !0 : void 0,
|
|
2639
|
+
"data-testid": `${y}-trigger`,
|
|
2640
|
+
children: [
|
|
2641
|
+
d ? /* @__PURE__ */ f("span", { className: "nice-country-picker__value", children: [
|
|
2642
|
+
q && /* @__PURE__ */ e("span", { className: "nice-country-picker__flag", "aria-hidden": "true", children: /* @__PURE__ */ e(nt, { code: d.code }) }),
|
|
2643
|
+
j && /* @__PURE__ */ e("span", { className: "nice-country-picker__name", children: d.name }),
|
|
2644
|
+
T && /* @__PURE__ */ e("span", { className: "nice-country-picker__code", children: d.code }),
|
|
2645
|
+
oe && /* @__PURE__ */ f("span", { className: "nice-country-picker__dial-code", children: [
|
|
2646
|
+
"(",
|
|
2647
|
+
d.dialCode,
|
|
2648
|
+
")"
|
|
2649
|
+
] })
|
|
2650
|
+
] }) : /* @__PURE__ */ e("span", { className: "nice-country-picker__placeholder", children: W ? "" : o ?? V("controls.select", "Select country") }),
|
|
2651
|
+
/* @__PURE__ */ f("span", { className: "nice-country-picker__icons", children: [
|
|
2652
|
+
J && d && !$ && !te && /* @__PURE__ */ e(
|
|
2653
|
+
"span",
|
|
2654
|
+
{
|
|
2655
|
+
className: "nice-country-picker__clear",
|
|
2656
|
+
onClick: ke,
|
|
2657
|
+
"aria-label": V("clear", "Clear"),
|
|
2658
|
+
children: /* @__PURE__ */ e(Ae, { name: "close", size: 14 })
|
|
2659
|
+
}
|
|
2660
|
+
),
|
|
2661
|
+
z !== "ghost" && /* @__PURE__ */ e("span", { className: "nice-country-picker__arrow", children: /* @__PURE__ */ e(Ae, { name: Q ? "chevron-up" : "chevron-down", size: 16 }) })
|
|
2662
|
+
] })
|
|
2663
|
+
]
|
|
2664
|
+
}
|
|
2665
|
+
),
|
|
2666
|
+
Q && /* @__PURE__ */ f(
|
|
2667
|
+
"div",
|
|
2668
|
+
{
|
|
2669
|
+
className: `nice-country-picker__dropdown nice-country-picker__dropdown--align-${Ee}`,
|
|
2670
|
+
role: "listbox",
|
|
2671
|
+
"data-testid": `${y}-dropdown`,
|
|
2672
|
+
children: [
|
|
2673
|
+
a && /* @__PURE__ */ e("div", { className: "nice-country-picker__search", children: /* @__PURE__ */ e(
|
|
2674
|
+
"input",
|
|
2675
|
+
{
|
|
2676
|
+
ref: N,
|
|
2677
|
+
type: "text",
|
|
2678
|
+
value: fe,
|
|
2679
|
+
onChange: (g) => ue(g.target.value),
|
|
2680
|
+
onKeyDown: ve,
|
|
2681
|
+
placeholder: s ?? V("search", "Search"),
|
|
2682
|
+
className: "nice-country-picker__search-input",
|
|
2683
|
+
"data-testid": `${y}-search`
|
|
2684
|
+
}
|
|
2685
|
+
) }),
|
|
2686
|
+
/* @__PURE__ */ e("div", { className: "nice-country-picker__list", children: h.length === 0 ? /* @__PURE__ */ e("div", { className: "nice-country-picker__empty", children: V("noData", "No countries found") }) : h.map((g, v) => /* @__PURE__ */ f(
|
|
2687
|
+
"div",
|
|
2688
|
+
{
|
|
2689
|
+
className: `nice-country-picker__option ${g.code === Ne ? "nice-country-picker__option--selected" : ""} ${v === re ? "nice-country-picker__option--highlighted" : ""}`,
|
|
2690
|
+
onClick: () => C(g),
|
|
2691
|
+
onMouseEnter: () => le(v),
|
|
2692
|
+
role: "option",
|
|
2693
|
+
"aria-selected": g.code === Ne,
|
|
2694
|
+
"data-testid": `${y}-option-${g.code}`,
|
|
2695
|
+
children: [
|
|
2696
|
+
Ce && /* @__PURE__ */ e("span", { className: "nice-country-picker__flag", "aria-hidden": "true", children: /* @__PURE__ */ e(nt, { code: g.code }) }),
|
|
2697
|
+
B && /* @__PURE__ */ e("span", { className: "nice-country-picker__name", children: g.name }),
|
|
2698
|
+
X && /* @__PURE__ */ e("span", { className: "nice-country-picker__code", children: g.code }),
|
|
2699
|
+
_e && /* @__PURE__ */ e("span", { className: "nice-country-picker__dial-code", children: g.dialCode })
|
|
2700
|
+
]
|
|
2701
|
+
},
|
|
2702
|
+
g.code
|
|
2703
|
+
)) })
|
|
2704
|
+
]
|
|
2705
|
+
}
|
|
2706
|
+
),
|
|
2707
|
+
ee && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
2708
|
+
S === "right" && E && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: E }),
|
|
2709
|
+
S === "right" && !E && L && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: L })
|
|
2710
|
+
] }),
|
|
2711
|
+
S !== "right" && E && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: E }),
|
|
2712
|
+
S !== "right" && !E && L && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: L })
|
|
2713
|
+
]
|
|
2714
|
+
}
|
|
2715
|
+
);
|
|
2716
|
+
};
|
|
2717
|
+
process.env.NODE_ENV !== "production" && (bt.displayName = "NiceCountryPicker");
|
|
2718
|
+
const _i = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
2719
|
+
function vi(n, i) {
|
|
2720
|
+
return new Date(n, i + 1, 0).getDate();
|
|
2721
|
+
}
|
|
2722
|
+
function bi(n, i) {
|
|
2723
|
+
return new Date(n, i, 1).getDay();
|
|
2724
|
+
}
|
|
2725
|
+
function at(n, i, t) {
|
|
2726
|
+
return `${n}-${String(i + 1).padStart(2, "0")}-${String(t).padStart(2, "0")}`;
|
|
2727
|
+
}
|
|
2728
|
+
function Ni(n) {
|
|
2729
|
+
const i = new Date(Date.UTC(n.getFullYear(), n.getMonth(), n.getDate()));
|
|
2730
|
+
i.setUTCDate(i.getUTCDate() + 4 - (i.getUTCDay() || 7));
|
|
2731
|
+
const t = new Date(Date.UTC(i.getUTCFullYear(), 0, 1));
|
|
2732
|
+
return Math.ceil(((i.getTime() - t.getTime()) / 864e5 + 1) / 7);
|
|
2733
|
+
}
|
|
2734
|
+
const lt = [
|
|
2735
|
+
"January",
|
|
2736
|
+
"February",
|
|
2737
|
+
"March",
|
|
2738
|
+
"April",
|
|
2739
|
+
"May",
|
|
2740
|
+
"June",
|
|
2741
|
+
"July",
|
|
2742
|
+
"August",
|
|
2743
|
+
"September",
|
|
2744
|
+
"October",
|
|
2745
|
+
"November",
|
|
2746
|
+
"December"
|
|
2747
|
+
], Nt = ({
|
|
2748
|
+
value: n,
|
|
2749
|
+
onChange: i,
|
|
2750
|
+
min: t,
|
|
2751
|
+
max: o,
|
|
2752
|
+
disabledDates: a = [],
|
|
2753
|
+
firstDayOfWeek: s = 1,
|
|
2754
|
+
size: u = "md",
|
|
2755
|
+
showWeekNumbers: M,
|
|
2756
|
+
onMonthChange: w,
|
|
2757
|
+
className: A,
|
|
2758
|
+
style: ce,
|
|
2759
|
+
accessMode: D,
|
|
2760
|
+
id: T,
|
|
2761
|
+
multiple: X,
|
|
2762
|
+
selectedDates: W,
|
|
2763
|
+
onSelectedDatesChange: z,
|
|
2764
|
+
selectionMode: I = "single",
|
|
2765
|
+
rangeStart: $,
|
|
2766
|
+
rangeEnd: Z,
|
|
2767
|
+
onRangeChange: ne,
|
|
2768
|
+
renderDay: J,
|
|
2769
|
+
showKeyboardHints: pe,
|
|
2770
|
+
persistPreferences: ae = !1,
|
|
2771
|
+
fullWidth: k = !1,
|
|
2772
|
+
// Traceless storage props
|
|
2773
|
+
cookies: U = !1,
|
|
2774
|
+
localStorage: L = !0,
|
|
2775
|
+
sessionStorage: E = !1,
|
|
2776
|
+
storageMode: de,
|
|
2777
|
+
storageKey: te
|
|
2778
|
+
}) => {
|
|
2779
|
+
const ee = dn(D, T), R = ee === "hidden", S = ee === "disabled" || ee === "readOnly", { t: P } = Qe(), p = /* @__PURE__ */ new Date(), m = (I === "range" ? $ : n) || n, y = m ? new Date(m) : p, V = qt(te ?? "nice-calendar"), H = ge(() => ae ? V.get("prefs") ?? {} : {}, [ae, V]), _ = H.firstDayOfWeek ?? s, [N, Y] = Te(H.lastViewYear ?? y.getFullYear()), [K, Q] = Te(H.lastViewMonth ?? y.getMonth()), [O, fe] = Te(H.preferredView ?? "days"), [ue, re] = Te([]), le = W ?? ue, [q, Ce] = Te(null), j = F(
|
|
2780
|
+
(l) => {
|
|
2781
|
+
if (!ae)
|
|
2782
|
+
return;
|
|
2783
|
+
const ie = V.get("prefs") ?? {};
|
|
2784
|
+
V.set("prefs", { ...ie, ...l });
|
|
2785
|
+
},
|
|
2786
|
+
[ae, V]
|
|
2787
|
+
), B = F(
|
|
2788
|
+
(l) => {
|
|
2789
|
+
fe(l), j({ preferredView: l });
|
|
2790
|
+
},
|
|
2791
|
+
[j]
|
|
2792
|
+
), oe = F(
|
|
2793
|
+
(l, ie) => {
|
|
2794
|
+
j({ lastViewYear: l, lastViewMonth: ie });
|
|
2795
|
+
},
|
|
2796
|
+
[j]
|
|
2797
|
+
), _e = ge(
|
|
2798
|
+
() => [
|
|
2799
|
+
Ve.moveUp,
|
|
2800
|
+
Ve.moveDown,
|
|
2801
|
+
Ve.moveLeft,
|
|
2802
|
+
Ve.moveRight,
|
|
2803
|
+
{ key: "Enter", description: P("shortcuts.selectDate", "Select date") },
|
|
2804
|
+
Ve.pageUp,
|
|
2805
|
+
Ve.pageDown
|
|
2806
|
+
],
|
|
2807
|
+
[P]
|
|
2808
|
+
), Ee = ge(() => vi(N, K), [N, K]), Ne = ge(() => (bi(N, K) - _ + 7) % 7, [N, K, _]), Ye = ge(() => {
|
|
2809
|
+
const l = [..._i];
|
|
2810
|
+
for (let ie = 0; ie < _; ie++)
|
|
2811
|
+
l.push(l.shift());
|
|
2812
|
+
return l;
|
|
2813
|
+
}, [_]), ze = F(
|
|
2814
|
+
(l) => {
|
|
2815
|
+
const ie = (De) => /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])/.test(De);
|
|
2816
|
+
return t && ie(t) && l < t || o && ie(o) && l > o ? !0 : a.includes(l);
|
|
2817
|
+
},
|
|
2818
|
+
[t, o, a]
|
|
2819
|
+
), h = F(
|
|
2820
|
+
(l) => {
|
|
2821
|
+
if (O === "years") {
|
|
2822
|
+
Y((Ge) => Ge + l * 10);
|
|
2823
|
+
return;
|
|
2824
|
+
}
|
|
2825
|
+
if (O === "months") {
|
|
2826
|
+
Y((Ge) => Ge + l);
|
|
2827
|
+
return;
|
|
2828
|
+
}
|
|
2829
|
+
let ie = K + l, De = N;
|
|
2830
|
+
ie < 0 && (ie = 11, De--), ie > 11 && (ie = 0, De++), Q(ie), Y(De), oe(De, ie), w?.(De, ie);
|
|
2831
|
+
},
|
|
2832
|
+
[K, N, w, O, oe]
|
|
2833
|
+
), d = at(p.getFullYear(), p.getMonth(), p.getDate()), C = I === "range", ke = F(
|
|
2834
|
+
(l) => C ? l === $ || l === Z : X ? le.includes(l) : l === n,
|
|
2835
|
+
[C, $, Z, X, le, n]
|
|
2836
|
+
), [ve, g] = ge(() => {
|
|
2837
|
+
if (!C || !$)
|
|
2838
|
+
return ["", ""];
|
|
2839
|
+
const l = Z || q;
|
|
2840
|
+
return l ? l < $ ? [l, $] : [$, l] : [$, $];
|
|
2841
|
+
}, [C, $, Z, q]), v = F(
|
|
2842
|
+
(l) => {
|
|
2843
|
+
if (!S) {
|
|
2844
|
+
if (C) {
|
|
2845
|
+
const ie = !$ || Z ? { start: l, end: "" } : l < $ ? { start: l, end: $ } : { start: $, end: l };
|
|
2846
|
+
Ce(null), ne?.(ie), i?.(l);
|
|
2847
|
+
return;
|
|
2848
|
+
}
|
|
2849
|
+
if (X) {
|
|
2850
|
+
const ie = le.includes(l) ? le.filter((De) => De !== l) : [...le, l];
|
|
2851
|
+
W === void 0 && re(ie), z?.(ie);
|
|
2852
|
+
}
|
|
2853
|
+
i?.(l);
|
|
2854
|
+
}
|
|
2855
|
+
},
|
|
2856
|
+
[
|
|
2857
|
+
S,
|
|
2858
|
+
C,
|
|
2859
|
+
$,
|
|
2860
|
+
Z,
|
|
2861
|
+
ne,
|
|
2862
|
+
X,
|
|
2863
|
+
le,
|
|
2864
|
+
W,
|
|
2865
|
+
i,
|
|
2866
|
+
z
|
|
2867
|
+
]
|
|
2868
|
+
), Xe = F(() => {
|
|
2869
|
+
O === "days" ? B("months") : O === "months" && B("years");
|
|
2870
|
+
}, [O, B]), Ke = F(
|
|
2871
|
+
(l) => {
|
|
2872
|
+
Q(l), B("days"), oe(N, l), w?.(N, l);
|
|
2873
|
+
},
|
|
2874
|
+
[N, w, B, oe]
|
|
2875
|
+
), Nn = F(
|
|
2876
|
+
(l) => {
|
|
2877
|
+
Y(l), B("months");
|
|
2878
|
+
},
|
|
2879
|
+
[B]
|
|
2880
|
+
), Cn = O === "years" ? `${N - N % 10} – ${N - N % 10 + 9}` : O === "months" ? `${N}` : `${lt[K]} ${N}`, cn = O === "years" ? "decade" : O === "months" ? "year" : "month", Me = [];
|
|
2881
|
+
for (let l = 0; l < Ne; l++)
|
|
2882
|
+
Me.push(null);
|
|
2883
|
+
for (let l = 1; l <= Ee; l++)
|
|
2884
|
+
Me.push(l);
|
|
2885
|
+
for (; Me.length % 7 !== 0; )
|
|
2886
|
+
Me.push(null);
|
|
2887
|
+
const rn = [];
|
|
2888
|
+
for (let l = 0; l < Me.length; l += 7)
|
|
2889
|
+
rn.push(Me.slice(l, l + 7));
|
|
2890
|
+
const pn = N - N % 10;
|
|
2891
|
+
return R ? null : /* @__PURE__ */ f(
|
|
2892
|
+
"div",
|
|
2893
|
+
{
|
|
2894
|
+
className: `nice-calendar nice-calendar--${u}${k ? " nice-calendar--full-width" : ""} ${A || ""}`,
|
|
2895
|
+
style: ce,
|
|
2896
|
+
children: [
|
|
2897
|
+
/* @__PURE__ */ f("div", { className: "nice-calendar__header", children: [
|
|
2898
|
+
/* @__PURE__ */ e(
|
|
2899
|
+
"button",
|
|
2900
|
+
{
|
|
2901
|
+
type: "button",
|
|
2902
|
+
className: "nice-calendar__nav",
|
|
2903
|
+
onClick: () => h(-1),
|
|
2904
|
+
"aria-label": P("shortcuts.previous", "Previous {navLabel}").replace(
|
|
2905
|
+
"{navLabel}",
|
|
2906
|
+
String(cn)
|
|
2907
|
+
),
|
|
2908
|
+
children: /* @__PURE__ */ e(Ae, { name: "chevron-left", size: 16 })
|
|
2909
|
+
}
|
|
2910
|
+
),
|
|
2911
|
+
/* @__PURE__ */ e(
|
|
2912
|
+
"button",
|
|
2913
|
+
{
|
|
2914
|
+
type: "button",
|
|
2915
|
+
className: "nice-calendar__title",
|
|
2916
|
+
onClick: Xe,
|
|
2917
|
+
"aria-label": O === "days" ? P("shortcuts.showMonthPicker", "Show month picker") : O === "months" ? P("shortcuts.showYearPicker", "Show year picker") : void 0,
|
|
2918
|
+
disabled: O === "years",
|
|
2919
|
+
children: Cn
|
|
2920
|
+
}
|
|
2921
|
+
),
|
|
2922
|
+
/* @__PURE__ */ e(
|
|
2923
|
+
"button",
|
|
2924
|
+
{
|
|
2925
|
+
type: "button",
|
|
2926
|
+
className: "nice-calendar__nav",
|
|
2927
|
+
onClick: () => h(1),
|
|
2928
|
+
"aria-label": P("shortcuts.next", "Next {navLabel}").replace(
|
|
2929
|
+
"{navLabel}",
|
|
2930
|
+
String(cn)
|
|
2931
|
+
),
|
|
2932
|
+
children: /* @__PURE__ */ e(Ae, { name: "chevron-right", size: 16 })
|
|
2933
|
+
}
|
|
2934
|
+
),
|
|
2935
|
+
pe && /* @__PURE__ */ e(gn, { shortcuts: _e, size: "sm" })
|
|
2936
|
+
] }),
|
|
2937
|
+
O === "days" && /* @__PURE__ */ f(
|
|
2938
|
+
"table",
|
|
2939
|
+
{
|
|
2940
|
+
className: "nice-calendar__grid",
|
|
2941
|
+
role: "grid",
|
|
2942
|
+
onMouseLeave: C ? () => Ce(null) : void 0,
|
|
2943
|
+
children: [
|
|
2944
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ f("tr", { children: [
|
|
2945
|
+
M && /* @__PURE__ */ e("th", { className: "nice-calendar__wk", children: "W" }),
|
|
2946
|
+
Ye.map((l) => /* @__PURE__ */ e("th", { children: l }, l))
|
|
2947
|
+
] }) }),
|
|
2948
|
+
/* @__PURE__ */ e("tbody", { children: rn.map((l, ie) => /* @__PURE__ */ f("tr", { children: [
|
|
2949
|
+
M && /* @__PURE__ */ e("td", { className: "nice-calendar__wk", children: l.find((De) => De != null) ? Ni(
|
|
2950
|
+
new Date(
|
|
2951
|
+
N,
|
|
2952
|
+
K,
|
|
2953
|
+
l.find((De) => De != null)
|
|
2954
|
+
)
|
|
2955
|
+
) : "" }),
|
|
2956
|
+
l.map((De, Ge) => {
|
|
2957
|
+
if (De == null)
|
|
2958
|
+
return /* @__PURE__ */ e("td", { className: "nice-calendar__empty-cell" }, Ge);
|
|
2959
|
+
const Ie = at(N, K, De), je = ze(Ie), Je = ke(Ie), on = Ie === d, Sn = ve !== "" && Ie >= ve && Ie <= g ? ` nice-calendar__day--in-range${Ie === ve ? " nice-calendar__day--range-start" : ""}${Ie === g ? " nice-calendar__day--range-end" : ""}` : "";
|
|
2960
|
+
return /* @__PURE__ */ e(
|
|
2961
|
+
"td",
|
|
2962
|
+
{
|
|
2963
|
+
className: `nice-calendar__day${Je ? " nice-calendar__day--selected" : ""}${Sn}${on ? " nice-calendar__day--today" : ""}${je ? " nice-calendar__day--disabled" : ""}`,
|
|
2964
|
+
onClick: () => !je && v(Ie),
|
|
2965
|
+
onMouseEnter: C && !je ? () => Ce(Ie) : void 0,
|
|
2966
|
+
role: "gridcell",
|
|
2967
|
+
"aria-selected": Je,
|
|
2968
|
+
"aria-disabled": je,
|
|
2969
|
+
children: J ? J(Ie, De) : De
|
|
2970
|
+
},
|
|
2971
|
+
Ge
|
|
2972
|
+
);
|
|
2973
|
+
})
|
|
2974
|
+
] }, ie)) })
|
|
2975
|
+
]
|
|
2976
|
+
}
|
|
2977
|
+
),
|
|
2978
|
+
O === "months" && /* @__PURE__ */ e("div", { className: "nice-calendar__picker-grid", children: lt.map((l, ie) => /* @__PURE__ */ e(
|
|
2979
|
+
"button",
|
|
2980
|
+
{
|
|
2981
|
+
type: "button",
|
|
2982
|
+
className: `nice-calendar__picker-cell${ie === K && N === y.getFullYear() ? " nice-calendar__picker-cell--selected" : ""}`,
|
|
2983
|
+
onClick: () => Ke(ie),
|
|
2984
|
+
children: l.slice(0, 3)
|
|
2985
|
+
},
|
|
2986
|
+
ie
|
|
2987
|
+
)) }),
|
|
2988
|
+
O === "years" && /* @__PURE__ */ e("div", { className: "nice-calendar__picker-grid", children: Array.from({ length: 12 }, (l, ie) => pn - 1 + ie).map((l) => /* @__PURE__ */ e(
|
|
2989
|
+
"button",
|
|
2990
|
+
{
|
|
2991
|
+
type: "button",
|
|
2992
|
+
className: `nice-calendar__picker-cell${l === N ? " nice-calendar__picker-cell--selected" : ""}${l < pn || l > pn + 9 ? " nice-calendar__picker-cell--other" : ""}`,
|
|
2993
|
+
onClick: () => Nn(l),
|
|
2994
|
+
children: l
|
|
2995
|
+
},
|
|
2996
|
+
l
|
|
2997
|
+
)) })
|
|
2998
|
+
]
|
|
2999
|
+
}
|
|
3000
|
+
);
|
|
3001
|
+
};
|
|
3002
|
+
process.env.NODE_ENV !== "production" && (Nt.displayName = "NiceCalendar");
|
|
3003
|
+
const Ci = {
|
|
3004
|
+
"date-local": { inputType: "date", localized: !0 },
|
|
3005
|
+
"date-utc": { inputType: "date", localized: !1 },
|
|
3006
|
+
"datetime-local": { inputType: "datetime-local", localized: !0 },
|
|
3007
|
+
"datetime-utc": { inputType: "datetime-local", localized: !1 },
|
|
3008
|
+
"month-local": { inputType: "month", localized: !0 },
|
|
3009
|
+
"month-utc": { inputType: "month", localized: !1 },
|
|
3010
|
+
week: { inputType: "week", localized: !1 },
|
|
3011
|
+
time: { inputType: "time", localized: !1 }
|
|
3012
|
+
}, ct = {
|
|
3013
|
+
date: "yyyy-MM-dd",
|
|
3014
|
+
"datetime-local": "yyyy-MM-ddTHH:mm",
|
|
3015
|
+
month: "yyyy-MM",
|
|
3016
|
+
week: "yyyy-Www",
|
|
3017
|
+
time: "HH:mm"
|
|
3018
|
+
}, Mi = {
|
|
3019
|
+
"yyyy-MM-dd": "YYYY-MM-DD",
|
|
3020
|
+
"yyyy-MM-ddTHH:mm": "YYYY-MM-DDTHH:MM",
|
|
3021
|
+
"yyyy-MM": "YYYY-MM",
|
|
3022
|
+
"yyyy-Www": "YYYY-Www",
|
|
3023
|
+
"HH:mm": "HH:MM"
|
|
3024
|
+
};
|
|
3025
|
+
function Kn(n) {
|
|
3026
|
+
const i = (n || "").toLowerCase().replace("_", "-"), t = i.split("-")[0], o = {
|
|
3027
|
+
// dd.MM.yyyy (dot)
|
|
3028
|
+
pl: "dd.MM.yyyy",
|
|
3029
|
+
"pl-pl": "dd.MM.yyyy",
|
|
3030
|
+
de: "dd.MM.yyyy",
|
|
3031
|
+
"de-de": "dd.MM.yyyy",
|
|
3032
|
+
"de-at": "dd.MM.yyyy",
|
|
3033
|
+
"de-ch": "dd.MM.yyyy",
|
|
3034
|
+
cs: "dd.MM.yyyy",
|
|
3035
|
+
"cs-cz": "dd.MM.yyyy",
|
|
3036
|
+
sk: "dd.MM.yyyy",
|
|
3037
|
+
"sk-sk": "dd.MM.yyyy",
|
|
3038
|
+
ru: "dd.MM.yyyy",
|
|
3039
|
+
"ru-ru": "dd.MM.yyyy",
|
|
3040
|
+
fi: "dd.MM.yyyy",
|
|
3041
|
+
"fi-fi": "dd.MM.yyyy",
|
|
3042
|
+
no: "dd.MM.yyyy",
|
|
3043
|
+
nb: "dd.MM.yyyy",
|
|
3044
|
+
nn: "dd.MM.yyyy",
|
|
3045
|
+
da: "dd.MM.yyyy",
|
|
3046
|
+
"da-dk": "dd.MM.yyyy",
|
|
3047
|
+
tr: "dd.MM.yyyy",
|
|
3048
|
+
"tr-tr": "dd.MM.yyyy",
|
|
3049
|
+
sl: "dd.MM.yyyy",
|
|
3050
|
+
hr: "dd.MM.yyyy",
|
|
3051
|
+
sr: "dd.MM.yyyy",
|
|
3052
|
+
ro: "dd.MM.yyyy",
|
|
3053
|
+
bg: "dd.MM.yyyy",
|
|
3054
|
+
uk: "dd.MM.yyyy",
|
|
3055
|
+
is: "dd.MM.yyyy",
|
|
3056
|
+
et: "dd.MM.yyyy",
|
|
3057
|
+
lv: "dd.MM.yyyy",
|
|
3058
|
+
lt: "dd.MM.yyyy",
|
|
3059
|
+
// dd/MM/yyyy (slash)
|
|
3060
|
+
"en-gb": "dd/MM/yyyy",
|
|
3061
|
+
"en-au": "dd/MM/yyyy",
|
|
3062
|
+
"en-ie": "dd/MM/yyyy",
|
|
3063
|
+
"en-nz": "dd/MM/yyyy",
|
|
3064
|
+
"en-in": "dd/MM/yyyy",
|
|
3065
|
+
fr: "dd/MM/yyyy",
|
|
3066
|
+
"fr-fr": "dd/MM/yyyy",
|
|
3067
|
+
"fr-be": "dd/MM/yyyy",
|
|
3068
|
+
es: "dd/MM/yyyy",
|
|
3069
|
+
"es-es": "dd/MM/yyyy",
|
|
3070
|
+
pt: "dd/MM/yyyy",
|
|
3071
|
+
"pt-pt": "dd/MM/yyyy",
|
|
3072
|
+
"pt-br": "dd/MM/yyyy",
|
|
3073
|
+
it: "dd/MM/yyyy",
|
|
3074
|
+
"it-it": "dd/MM/yyyy",
|
|
3075
|
+
nl: "dd-MM-yyyy",
|
|
3076
|
+
"nl-nl": "dd-MM-yyyy",
|
|
3077
|
+
"nl-be": "dd/MM/yyyy",
|
|
3078
|
+
el: "dd/MM/yyyy",
|
|
3079
|
+
hu: "yyyy.MM.dd",
|
|
3080
|
+
// MM/dd/yyyy
|
|
3081
|
+
en: "MM/dd/yyyy",
|
|
3082
|
+
"en-us": "MM/dd/yyyy",
|
|
3083
|
+
"en-ca": "MM/dd/yyyy",
|
|
3084
|
+
// yyyy-MM-dd / yyyy/MM/dd
|
|
3085
|
+
ja: "yyyy/MM/dd",
|
|
3086
|
+
"ja-jp": "yyyy/MM/dd",
|
|
3087
|
+
ko: "yyyy.MM.dd",
|
|
3088
|
+
"ko-kr": "yyyy.MM.dd",
|
|
3089
|
+
zh: "yyyy/MM/dd",
|
|
3090
|
+
"zh-cn": "yyyy/MM/dd",
|
|
3091
|
+
"zh-tw": "yyyy/MM/dd",
|
|
3092
|
+
sv: "yyyy-MM-dd",
|
|
3093
|
+
"sv-se": "yyyy-MM-dd"
|
|
3094
|
+
};
|
|
3095
|
+
if (o[i])
|
|
3096
|
+
return o[i];
|
|
3097
|
+
if (o[t])
|
|
3098
|
+
return o[t];
|
|
3099
|
+
try {
|
|
3100
|
+
const s = new Intl.DateTimeFormat(n, {
|
|
3101
|
+
year: "numeric",
|
|
3102
|
+
month: "2-digit",
|
|
3103
|
+
day: "2-digit"
|
|
3104
|
+
}).formatToParts(new Date(2024, 0, 15));
|
|
3105
|
+
let u = "";
|
|
3106
|
+
for (const M of s)
|
|
3107
|
+
if (M.type === "day")
|
|
3108
|
+
u += "dd";
|
|
3109
|
+
else if (M.type === "month")
|
|
3110
|
+
u += "MM";
|
|
3111
|
+
else if (M.type === "year")
|
|
3112
|
+
u += "yyyy";
|
|
3113
|
+
else if (M.type === "literal") {
|
|
3114
|
+
const w = M.value.replace(/[\u00A0\u202F\u2009]/g, " ").trim();
|
|
3115
|
+
u += w || ".";
|
|
3116
|
+
}
|
|
3117
|
+
return !/y/.test(u) || !/M/.test(u) || !/d/.test(u) ? "yyyy-MM-dd" : u;
|
|
3118
|
+
} catch {
|
|
3119
|
+
return "yyyy-MM-dd";
|
|
3120
|
+
}
|
|
3121
|
+
}
|
|
3122
|
+
function $i(n) {
|
|
3123
|
+
const t = Kn(n).replace(/dd[^\w]*/g, "").replace(/[^\w]*dd/g, "");
|
|
3124
|
+
return !/y/.test(t) || !/M/.test(t) ? "yyyy-MM" : t;
|
|
3125
|
+
}
|
|
3126
|
+
function Ct() {
|
|
3127
|
+
if (typeof document < "u") {
|
|
3128
|
+
const n = document.documentElement?.lang;
|
|
3129
|
+
if (n && /^[a-zA-Z]{2,}/.test(n))
|
|
3130
|
+
return n;
|
|
3131
|
+
}
|
|
3132
|
+
return typeof navigator < "u" && navigator.language ? navigator.language : "en-US";
|
|
3133
|
+
}
|
|
3134
|
+
function ki(n, i, t, o = !1) {
|
|
3135
|
+
ct[n] || (n = "date");
|
|
3136
|
+
let a = ct[n];
|
|
3137
|
+
o && (n === "datetime-local" || n === "time") && (a = a.replace("HH:mm", "HH:mm:ss"));
|
|
3138
|
+
let s = a;
|
|
3139
|
+
i && (n === "date" || n === "datetime-local" || n === "month") && (n === "date" ? s = Kn(t) : n === "datetime-local" ? s = `${Kn(t)} HH:mm${o ? ":ss" : ""}` : s = $i(t)), n === "datetime-local" && (s = s.replace("T", " · "));
|
|
3140
|
+
const u = Mi[s] ?? s.replace(/y/g, "Y").replace(/M/g, "M").replace(/d/g, "D").replace(/H/g, "H").replace(/m/g, "M").replace(/s/g, "S");
|
|
3141
|
+
return { displayTpl: s, isoTpl: a, placeholder: u };
|
|
3142
|
+
}
|
|
3143
|
+
const wi = /* @__PURE__ */ new Set(["y", "M", "d", "H", "m", "s", "w"]);
|
|
3144
|
+
function ln(n) {
|
|
3145
|
+
return wi.has(n);
|
|
3146
|
+
}
|
|
3147
|
+
function Qn(n) {
|
|
3148
|
+
let i = 0;
|
|
3149
|
+
for (const t of n)
|
|
3150
|
+
ln(t) && i++;
|
|
3151
|
+
return i;
|
|
3152
|
+
}
|
|
3153
|
+
function Xn(n, i) {
|
|
3154
|
+
let t = "", o = 0;
|
|
3155
|
+
for (const a of n)
|
|
3156
|
+
if (ln(a)) {
|
|
3157
|
+
if (o >= i.length)
|
|
3158
|
+
break;
|
|
3159
|
+
t += i[o++];
|
|
3160
|
+
} else {
|
|
3161
|
+
if (o === 0)
|
|
3162
|
+
break;
|
|
3163
|
+
o >= i.length, t += a;
|
|
3164
|
+
}
|
|
3165
|
+
return t;
|
|
3166
|
+
}
|
|
3167
|
+
function Ti(n, i, t) {
|
|
3168
|
+
if (t.length === 0)
|
|
3169
|
+
return "";
|
|
3170
|
+
const o = {};
|
|
3171
|
+
let a = 0;
|
|
3172
|
+
for (const M of n)
|
|
3173
|
+
ln(M) && (a >= t.length ? (o[M] ?? (o[M] = [])).push("") : (o[M] ?? (o[M] = [])).push(t[a]), a++);
|
|
3174
|
+
const s = {};
|
|
3175
|
+
let u = "";
|
|
3176
|
+
for (const M of i)
|
|
3177
|
+
if (ln(M)) {
|
|
3178
|
+
const w = o[M] ?? [], A = s[M] ?? 0;
|
|
3179
|
+
u += w[A] ?? "", s[M] = A + 1;
|
|
3180
|
+
}
|
|
3181
|
+
return u;
|
|
3182
|
+
}
|
|
3183
|
+
function hn(n, i, t) {
|
|
3184
|
+
if (t.length === 0)
|
|
3185
|
+
return "";
|
|
3186
|
+
const o = {};
|
|
3187
|
+
let a = 0;
|
|
3188
|
+
for (const M of i)
|
|
3189
|
+
ln(M) && ((o[M] ?? (o[M] = [])).push(t[a] ?? ""), a++);
|
|
3190
|
+
const s = {};
|
|
3191
|
+
let u = "";
|
|
3192
|
+
for (const M of n)
|
|
3193
|
+
if (ln(M)) {
|
|
3194
|
+
const w = o[M] ?? [], A = s[M] ?? 0;
|
|
3195
|
+
u += w[A] ?? "", s[M] = A + 1;
|
|
3196
|
+
}
|
|
3197
|
+
return u.replace(/\s+$/, "");
|
|
3198
|
+
}
|
|
3199
|
+
function rt(n, i, t) {
|
|
3200
|
+
const o = Qn(i);
|
|
3201
|
+
if (t.length < o)
|
|
3202
|
+
return "";
|
|
3203
|
+
const a = Ti(n, i, t);
|
|
3204
|
+
if (a.length < o)
|
|
3205
|
+
return "";
|
|
3206
|
+
let s = "", u = 0;
|
|
3207
|
+
for (const M of i)
|
|
3208
|
+
ln(M) ? s += a[u++] : s += M;
|
|
3209
|
+
return s;
|
|
3210
|
+
}
|
|
3211
|
+
function ot(n, i, t) {
|
|
3212
|
+
return n && (i && n < i ? i : t && n > t ? t : n);
|
|
3213
|
+
}
|
|
3214
|
+
function xe(n) {
|
|
3215
|
+
return n.toString().padStart(2, "0");
|
|
3216
|
+
}
|
|
3217
|
+
function An(n) {
|
|
3218
|
+
const i = /(\d{2}):(\d{2})(?::(\d{2}))?$/.exec(n);
|
|
3219
|
+
return i ? { hours: Number(i[1]), minutes: Number(i[2]), seconds: Number(i[3] ?? 0) } : null;
|
|
3220
|
+
}
|
|
3221
|
+
function st(n, i, t, o, a) {
|
|
3222
|
+
const s = a ? `${xe(i)}:${xe(t)}:${xe(o)}` : `${xe(i)}:${xe(t)}`;
|
|
3223
|
+
return n.replace(/\d{2}:\d{2}(?::\d{2})?$/, s);
|
|
3224
|
+
}
|
|
3225
|
+
function Mt(n, i) {
|
|
3226
|
+
if (n <= 0)
|
|
3227
|
+
return i;
|
|
3228
|
+
const t = Math.floor(n / 864e5), o = `${xe(Math.floor(n % 864e5 / 36e5))}:${xe(Math.floor(n % 36e5 / 6e4))}:${xe(Math.floor(n % 6e4 / 1e3))}`;
|
|
3229
|
+
return t > 0 ? `${t}d ${o}` : o;
|
|
3230
|
+
}
|
|
3231
|
+
function Di(n, i) {
|
|
3232
|
+
if (n <= 0)
|
|
3233
|
+
return i;
|
|
3234
|
+
const t = Math.floor(n / 864e5), o = Math.floor(n % 864e5 / 36e5), a = Math.floor(n % 36e5 / 6e4), s = Math.floor(n % 6e4 / 1e3), u = [];
|
|
3235
|
+
return t && u.push(`${t}d`), (t || o) && u.push(`${o}h`), (t || o || a) && u.push(`${a}m`), u.push(`${s}s`), u.join(" ");
|
|
3236
|
+
}
|
|
3237
|
+
function Si(n, i) {
|
|
3238
|
+
if (n <= 0)
|
|
3239
|
+
return i;
|
|
3240
|
+
const t = Math.floor(n / 1e3), o = Math.floor(t / 3600), a = Math.floor(t % 3600 / 60), s = t % 60;
|
|
3241
|
+
return o > 0 ? `${xe(o)}:${xe(a)}:${xe(s)}` : `${xe(a)}:${xe(s)}`;
|
|
3242
|
+
}
|
|
3243
|
+
function Ai(n, i) {
|
|
3244
|
+
if (n <= 0)
|
|
3245
|
+
return i;
|
|
3246
|
+
const t = Math.floor(n / 1e3), o = Math.floor(t / 86400);
|
|
3247
|
+
if (o)
|
|
3248
|
+
return `${o}d`;
|
|
3249
|
+
const a = Math.floor(t / 3600);
|
|
3250
|
+
if (a)
|
|
3251
|
+
return `${a}h`;
|
|
3252
|
+
const s = Math.floor(t / 60);
|
|
3253
|
+
return s ? `${s}m` : `${t}s`;
|
|
3254
|
+
}
|
|
3255
|
+
function xi(n, i) {
|
|
3256
|
+
if (n <= 0)
|
|
3257
|
+
return i;
|
|
3258
|
+
const t = Math.floor(n / 1e3), o = Math.floor(t / 86400), a = Math.floor(t % 86400 / 3600), s = Math.floor(t % 3600 / 60), u = [];
|
|
3259
|
+
return o && u.push(`${o} ${o === 1 ? "day" : "days"}`), a && u.push(`${a} ${a === 1 ? "hour" : "hours"}`), s && u.push(`${s} ${s === 1 ? "minute" : "minutes"}`), u.length ? u.join(", ") : "less than a minute";
|
|
3260
|
+
}
|
|
3261
|
+
const Ri = {
|
|
3262
|
+
verbose: Mt,
|
|
3263
|
+
compact: Di,
|
|
3264
|
+
short: Si,
|
|
3265
|
+
minimal: Ai,
|
|
3266
|
+
words: xi
|
|
3267
|
+
};
|
|
3268
|
+
function Ui(n, i, t) {
|
|
3269
|
+
const o = n ? An(n) : null, { hours: a, minutes: s, seconds: u } = o ?? { hours: 0, minutes: 0, seconds: 0 }, M = new Date(t);
|
|
3270
|
+
if (i != null) {
|
|
3271
|
+
const A = typeof i == "string" ? new Date(i) : new Date(i.getTime());
|
|
3272
|
+
if (!Number.isNaN(A.getTime()))
|
|
3273
|
+
return A.setHours(a, s, u, 0), A;
|
|
3274
|
+
}
|
|
3275
|
+
if (n && /^\d{4}-\d{2}-\d{2}T/.test(n)) {
|
|
3276
|
+
const A = new Date(n);
|
|
3277
|
+
if (!Number.isNaN(A.getTime()))
|
|
3278
|
+
return A;
|
|
3279
|
+
}
|
|
3280
|
+
const w = new Date(M);
|
|
3281
|
+
return w.setHours(a, s, u, 0), w.getTime() <= M.getTime() && w.setDate(w.getDate() + 1), w;
|
|
3282
|
+
}
|
|
3283
|
+
function Dn(n, i) {
|
|
3284
|
+
if (!n)
|
|
3285
|
+
return "";
|
|
3286
|
+
const t = n.replace(/[^0-9]/g, ""), o = Qn(i);
|
|
3287
|
+
return t.slice(0, o);
|
|
3288
|
+
}
|
|
3289
|
+
function en(n, i, t) {
|
|
3290
|
+
const o = Xn(n, t);
|
|
3291
|
+
let a = 0;
|
|
3292
|
+
const s = Math.min(i, o.length);
|
|
3293
|
+
for (let u = 0; u < s; u++)
|
|
3294
|
+
ln(n[u]) && a++;
|
|
3295
|
+
return Math.min(a, t.length);
|
|
3296
|
+
}
|
|
3297
|
+
function Ei(n, i, t) {
|
|
3298
|
+
if (t <= 0)
|
|
3299
|
+
return 0;
|
|
3300
|
+
const o = Xn(n, i);
|
|
3301
|
+
let a = 0;
|
|
3302
|
+
for (let s = 0; s < o.length; s++)
|
|
3303
|
+
if (ln(n[s]) && (a++, a === t)) {
|
|
3304
|
+
let u = s + 1;
|
|
3305
|
+
for (; u < o.length && !ln(n[u]); )
|
|
3306
|
+
u++;
|
|
3307
|
+
return u;
|
|
3308
|
+
}
|
|
3309
|
+
return o.length;
|
|
3310
|
+
}
|
|
3311
|
+
const jn = 40;
|
|
3312
|
+
function Ii() {
|
|
3313
|
+
return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
3314
|
+
}
|
|
3315
|
+
const Fi = ({
|
|
3316
|
+
part: n,
|
|
3317
|
+
label: i,
|
|
3318
|
+
value: t,
|
|
3319
|
+
max: o,
|
|
3320
|
+
step: a,
|
|
3321
|
+
onPick: s,
|
|
3322
|
+
onStep: u,
|
|
3323
|
+
startHold: M,
|
|
3324
|
+
stopHold: w
|
|
3325
|
+
}) => {
|
|
3326
|
+
const A = be(null), ce = be(!1), D = be(null), T = be(null), X = ge(() => {
|
|
3327
|
+
const k = [], U = a > 0 ? a : 1;
|
|
3328
|
+
for (let L = 0; L <= o; L += U)
|
|
3329
|
+
k.push(L);
|
|
3330
|
+
return k;
|
|
3331
|
+
}, [o, a]), W = Math.max(
|
|
3332
|
+
0,
|
|
3333
|
+
Math.min(X.length - 1, Math.round(t / (a > 0 ? a : 1)))
|
|
3334
|
+
), z = X.length, I = ge(() => [...X, ...X, ...X], [X]), $ = z + W, Z = be(!1);
|
|
3335
|
+
ut(() => {
|
|
3336
|
+
const k = A.current;
|
|
3337
|
+
if (!k)
|
|
3338
|
+
return;
|
|
3339
|
+
const U = $ * jn;
|
|
3340
|
+
if (Math.abs(k.scrollTop - U) < 1)
|
|
3341
|
+
return;
|
|
3342
|
+
const L = Math.abs(k.scrollTop / jn - $);
|
|
3343
|
+
ce.current = !0, D.current && (clearTimeout(D.current), D.current = null);
|
|
3344
|
+
const E = Z.current && L <= 3 && !Ii();
|
|
3345
|
+
k.scrollTo({ top: U, behavior: E ? "smooth" : "instant" }), Z.current = !0, T.current && clearTimeout(T.current), T.current = setTimeout(() => {
|
|
3346
|
+
ce.current = !1;
|
|
3347
|
+
}, 380);
|
|
3348
|
+
}, [$]), Le(
|
|
3349
|
+
() => () => {
|
|
3350
|
+
D.current && clearTimeout(D.current), T.current && clearTimeout(T.current);
|
|
3351
|
+
},
|
|
3352
|
+
[]
|
|
3353
|
+
);
|
|
3354
|
+
const ne = () => {
|
|
3355
|
+
ce.current || (D.current && clearTimeout(D.current), D.current = setTimeout(() => {
|
|
3356
|
+
const k = A.current;
|
|
3357
|
+
if (!k)
|
|
3358
|
+
return;
|
|
3359
|
+
const U = Math.round(k.scrollTop / jn), L = X[(U % z + z) % z];
|
|
3360
|
+
L !== t && s(L);
|
|
3361
|
+
}, 110));
|
|
3362
|
+
}, J = (k) => {
|
|
3363
|
+
k.key === "ArrowUp" ? (k.preventDefault(), u(-1)) : k.key === "ArrowDown" && (k.preventDefault(), u(1));
|
|
3364
|
+
}, pe = (k) => {
|
|
3365
|
+
const U = k.replace(/\D/g, "");
|
|
3366
|
+
if (!U)
|
|
3367
|
+
return;
|
|
3368
|
+
const L = Number(U.slice(-2));
|
|
3369
|
+
s(Math.max(0, Math.min(o, L)));
|
|
3370
|
+
}, ae = (k) => {
|
|
3371
|
+
A.current && A.current.scrollBy({ top: k.deltaY });
|
|
3372
|
+
};
|
|
3373
|
+
return /* @__PURE__ */ f("div", { className: "nice-datetime-popup__spinner", role: "group", "aria-label": i, children: [
|
|
3374
|
+
/* @__PURE__ */ e(
|
|
3375
|
+
"div",
|
|
3376
|
+
{
|
|
3377
|
+
ref: A,
|
|
3378
|
+
className: "nice-datetime-popup__spin-column",
|
|
3379
|
+
role: "listbox",
|
|
3380
|
+
tabIndex: -1,
|
|
3381
|
+
"aria-label": i,
|
|
3382
|
+
"aria-activedescendant": `${n}-opt-${$}`,
|
|
3383
|
+
onScroll: ne,
|
|
3384
|
+
children: I.map((k, U) => /* @__PURE__ */ e(
|
|
3385
|
+
"button",
|
|
3386
|
+
{
|
|
3387
|
+
type: "button",
|
|
3388
|
+
id: `${n}-opt-${U}`,
|
|
3389
|
+
role: "option",
|
|
3390
|
+
"aria-selected": U === $,
|
|
3391
|
+
className: `nice-datetime-popup__spin-item${U === $ ? " is-selected" : ""}`,
|
|
3392
|
+
onClick: () => s(k),
|
|
3393
|
+
tabIndex: -1,
|
|
3394
|
+
children: xe(k)
|
|
3395
|
+
},
|
|
3396
|
+
U
|
|
3397
|
+
))
|
|
3398
|
+
}
|
|
3399
|
+
),
|
|
3400
|
+
/* @__PURE__ */ f("div", { className: "nice-datetime-popup__spin-center", onWheel: ae, children: [
|
|
3401
|
+
/* @__PURE__ */ e(
|
|
3402
|
+
"button",
|
|
3403
|
+
{
|
|
3404
|
+
type: "button",
|
|
3405
|
+
className: "nice-datetime-popup__spin-btn",
|
|
3406
|
+
onClick: () => u(-1),
|
|
3407
|
+
onPointerDown: () => M(() => u(-1)),
|
|
3408
|
+
onPointerUp: w,
|
|
3409
|
+
onPointerLeave: w,
|
|
3410
|
+
"aria-label": `${i} -`,
|
|
3411
|
+
tabIndex: -1,
|
|
3412
|
+
children: /* @__PURE__ */ e(Ae, { name: "chevron-up", size: 14 })
|
|
3413
|
+
}
|
|
3414
|
+
),
|
|
3415
|
+
/* @__PURE__ */ e(
|
|
3416
|
+
"input",
|
|
3417
|
+
{
|
|
3418
|
+
className: "nice-datetime-popup__spin-value",
|
|
3419
|
+
inputMode: "numeric",
|
|
3420
|
+
"aria-label": i,
|
|
3421
|
+
value: xe(t),
|
|
3422
|
+
onFocus: (k) => k.currentTarget.select(),
|
|
3423
|
+
onChange: (k) => pe(k.target.value),
|
|
3424
|
+
onKeyDown: J
|
|
3425
|
+
}
|
|
3426
|
+
),
|
|
3427
|
+
/* @__PURE__ */ e(
|
|
3428
|
+
"button",
|
|
3429
|
+
{
|
|
3430
|
+
type: "button",
|
|
3431
|
+
className: "nice-datetime-popup__spin-btn",
|
|
3432
|
+
onClick: () => u(1),
|
|
3433
|
+
onPointerDown: () => M(() => u(1)),
|
|
3434
|
+
onPointerUp: w,
|
|
3435
|
+
onPointerLeave: w,
|
|
3436
|
+
"aria-label": `${i} +`,
|
|
3437
|
+
tabIndex: -1,
|
|
3438
|
+
children: /* @__PURE__ */ e(Ae, { name: "chevron-down", size: 14 })
|
|
3439
|
+
}
|
|
3440
|
+
)
|
|
3441
|
+
] })
|
|
3442
|
+
] });
|
|
3443
|
+
}, Li = ({ hours: n, minutes: i, minuteStep: t, onChange: o, t: a }) => {
|
|
3444
|
+
const [s, u] = Te("hours"), M = be(null), w = 100, A = 78, ce = 52, D = 62, T = 65, X = 18, W = n >= 12 ? "PM" : "AM", z = n % 12 === 0 ? 12 : n % 12, I = (p, m) => {
|
|
3445
|
+
const y = (p - 90) * Math.PI / 180;
|
|
3446
|
+
return { x: w + m * Math.cos(y), y: w + m * Math.sin(y) };
|
|
3447
|
+
}, $ = (p) => {
|
|
3448
|
+
const m = W === "PM" ? p % 12 + 12 : p % 12;
|
|
3449
|
+
o(m, i);
|
|
3450
|
+
}, Z = (p) => {
|
|
3451
|
+
const m = t && t > 1 ? t : 1, y = Math.round(p / m) * m % 60;
|
|
3452
|
+
o(n, y);
|
|
3453
|
+
}, ne = (p) => {
|
|
3454
|
+
if (p === W)
|
|
3455
|
+
return;
|
|
3456
|
+
const m = p === "PM" ? n + 12 : n - 12;
|
|
3457
|
+
o((m % 24 + 24) % 24, i);
|
|
3458
|
+
}, J = (p) => {
|
|
3459
|
+
const m = p.currentTarget.getBoundingClientRect(), y = (p.clientX - m.left) / m.width * 200 - w, V = (p.clientY - m.top) / m.height * 200 - w;
|
|
3460
|
+
let H = Math.atan2(V, y) * 180 / Math.PI + 90;
|
|
3461
|
+
return H < 0 && (H += 360), { ang: H, radius: Math.hypot(y, V) };
|
|
3462
|
+
}, pe = (p, m) => {
|
|
3463
|
+
if (p === "hours") {
|
|
3464
|
+
const y = Math.round(m / 30) % 12;
|
|
3465
|
+
$(y === 0 ? 12 : y);
|
|
3466
|
+
} else
|
|
3467
|
+
Z(Math.round(m / 6) % 60);
|
|
3468
|
+
}, ae = (p) => {
|
|
3469
|
+
const { ang: m, radius: y } = J(p);
|
|
3470
|
+
if (y < X)
|
|
3471
|
+
return;
|
|
3472
|
+
const V = y > T ? "hours" : "minutes";
|
|
3473
|
+
M.current = V, u(V), p.currentTarget.setPointerCapture?.(p.pointerId), pe(V, m);
|
|
3474
|
+
}, k = (p) => {
|
|
3475
|
+
const m = M.current;
|
|
3476
|
+
m && pe(m, J(p).ang);
|
|
3477
|
+
}, U = (p) => {
|
|
3478
|
+
M.current && (M.current = null, p.currentTarget.releasePointerCapture?.(p.pointerId));
|
|
3479
|
+
}, L = Array.from({ length: 12 }, (p, m) => m + 1), E = t && t > 1 ? t : 5, de = [];
|
|
3480
|
+
for (let p = 0; p < 60; p += E)
|
|
3481
|
+
de.push(p);
|
|
3482
|
+
const te = t && t > 1 ? t : 1, ee = Math.round(i / te) * te % 60, R = s === "hours", S = I(z % 12 * 30, A), P = I(ee * 6, ce);
|
|
3483
|
+
return /* @__PURE__ */ f("div", { className: "nice-datetime-popup__clock", children: [
|
|
3484
|
+
/* @__PURE__ */ f("div", { className: "nice-datetime-popup__clock-readout", children: [
|
|
3485
|
+
/* @__PURE__ */ e(
|
|
3486
|
+
"button",
|
|
3487
|
+
{
|
|
3488
|
+
type: "button",
|
|
3489
|
+
className: `nice-datetime-popup__clock-seg${s === "hours" ? " nice-datetime-popup__clock-seg--active" : ""}`,
|
|
3490
|
+
onClick: () => u("hours"),
|
|
3491
|
+
"aria-label": a("datetime.hours", "Hours"),
|
|
3492
|
+
children: xe(z)
|
|
3493
|
+
}
|
|
3494
|
+
),
|
|
3495
|
+
/* @__PURE__ */ e("span", { className: "nice-datetime-popup__clock-colon", children: ":" }),
|
|
3496
|
+
/* @__PURE__ */ e(
|
|
3497
|
+
"button",
|
|
3498
|
+
{
|
|
3499
|
+
type: "button",
|
|
3500
|
+
className: `nice-datetime-popup__clock-seg${s === "minutes" ? " nice-datetime-popup__clock-seg--active" : ""}`,
|
|
3501
|
+
onClick: () => u("minutes"),
|
|
3502
|
+
"aria-label": a("datetime.minutes", "Minutes"),
|
|
3503
|
+
children: xe(i)
|
|
3504
|
+
}
|
|
3505
|
+
),
|
|
3506
|
+
/* @__PURE__ */ f("div", { className: "nice-datetime-popup__clock-ampm", role: "group", children: [
|
|
3507
|
+
/* @__PURE__ */ e(
|
|
3508
|
+
"button",
|
|
3509
|
+
{
|
|
3510
|
+
type: "button",
|
|
3511
|
+
className: `nice-datetime-popup__clock-period${W === "AM" ? " nice-datetime-popup__clock-period--active" : ""}`,
|
|
3512
|
+
onClick: () => ne("AM"),
|
|
3513
|
+
"aria-pressed": W === "AM",
|
|
3514
|
+
children: a("datetime.am", "AM")
|
|
3515
|
+
}
|
|
3516
|
+
),
|
|
3517
|
+
/* @__PURE__ */ e(
|
|
3518
|
+
"button",
|
|
3519
|
+
{
|
|
3520
|
+
type: "button",
|
|
3521
|
+
className: `nice-datetime-popup__clock-period${W === "PM" ? " nice-datetime-popup__clock-period--active" : ""}`,
|
|
3522
|
+
onClick: () => ne("PM"),
|
|
3523
|
+
"aria-pressed": W === "PM",
|
|
3524
|
+
children: a("datetime.pm", "PM")
|
|
3525
|
+
}
|
|
3526
|
+
)
|
|
3527
|
+
] })
|
|
3528
|
+
] }),
|
|
3529
|
+
/* @__PURE__ */ f(
|
|
3530
|
+
"svg",
|
|
3531
|
+
{
|
|
3532
|
+
viewBox: "0 0 200 200",
|
|
3533
|
+
className: "nice-datetime-popup__clock-face",
|
|
3534
|
+
onPointerDown: ae,
|
|
3535
|
+
onPointerMove: k,
|
|
3536
|
+
onPointerUp: U,
|
|
3537
|
+
onPointerCancel: U,
|
|
3538
|
+
role: "img",
|
|
3539
|
+
"aria-label": a("datetime.clockMode", "Analog clock"),
|
|
3540
|
+
children: [
|
|
3541
|
+
/* @__PURE__ */ e("circle", { cx: w, cy: w, r: 96, className: "nice-datetime-popup__clock-bg" }),
|
|
3542
|
+
de.map((p) => {
|
|
3543
|
+
const m = I(p * 6, D);
|
|
3544
|
+
return /* @__PURE__ */ e(
|
|
3545
|
+
"circle",
|
|
3546
|
+
{
|
|
3547
|
+
cx: m.x,
|
|
3548
|
+
cy: m.y,
|
|
3549
|
+
r: p === ee ? 2.6 : 1.5,
|
|
3550
|
+
className: `nice-datetime-popup__clock-tick${p === ee ? " nice-datetime-popup__clock-tick--active" : ""}`
|
|
3551
|
+
},
|
|
3552
|
+
`tick-${p}`
|
|
3553
|
+
);
|
|
3554
|
+
}),
|
|
3555
|
+
/* @__PURE__ */ e(
|
|
3556
|
+
"line",
|
|
3557
|
+
{
|
|
3558
|
+
x1: w,
|
|
3559
|
+
y1: w,
|
|
3560
|
+
x2: S.x,
|
|
3561
|
+
y2: S.y,
|
|
3562
|
+
className: `nice-datetime-popup__clock-hand nice-datetime-popup__clock-hand--hour${R ? " nice-datetime-popup__clock-hand--active" : ""}`
|
|
3563
|
+
}
|
|
3564
|
+
),
|
|
3565
|
+
/* @__PURE__ */ e(
|
|
3566
|
+
"line",
|
|
3567
|
+
{
|
|
3568
|
+
x1: w,
|
|
3569
|
+
y1: w,
|
|
3570
|
+
x2: P.x,
|
|
3571
|
+
y2: P.y,
|
|
3572
|
+
className: `nice-datetime-popup__clock-hand nice-datetime-popup__clock-hand--minute${R ? "" : " nice-datetime-popup__clock-hand--active"}`
|
|
3573
|
+
}
|
|
3574
|
+
),
|
|
3575
|
+
/* @__PURE__ */ e("circle", { cx: S.x, cy: S.y, r: 15, className: "nice-datetime-popup__clock-knob" }),
|
|
3576
|
+
/* @__PURE__ */ e(
|
|
3577
|
+
"circle",
|
|
3578
|
+
{
|
|
3579
|
+
cx: P.x,
|
|
3580
|
+
cy: P.y,
|
|
3581
|
+
r: 12,
|
|
3582
|
+
className: "nice-datetime-popup__clock-knob nice-datetime-popup__clock-knob--minute"
|
|
3583
|
+
}
|
|
3584
|
+
),
|
|
3585
|
+
/* @__PURE__ */ e("circle", { cx: w, cy: w, r: 4, className: "nice-datetime-popup__clock-center" }),
|
|
3586
|
+
L.map((p) => {
|
|
3587
|
+
const m = I(p * 30, A);
|
|
3588
|
+
return /* @__PURE__ */ e(
|
|
3589
|
+
"text",
|
|
3590
|
+
{
|
|
3591
|
+
x: m.x,
|
|
3592
|
+
y: m.y,
|
|
3593
|
+
className: `nice-datetime-popup__clock-num${p === z ? " nice-datetime-popup__clock-num--active" : ""}`,
|
|
3594
|
+
textAnchor: "middle",
|
|
3595
|
+
dominantBaseline: "central",
|
|
3596
|
+
children: p
|
|
3597
|
+
},
|
|
3598
|
+
`h-${p}`
|
|
3599
|
+
);
|
|
3600
|
+
}),
|
|
3601
|
+
de.map((p) => {
|
|
3602
|
+
const m = I(p * 6, ce);
|
|
3603
|
+
return /* @__PURE__ */ e(
|
|
3604
|
+
"text",
|
|
3605
|
+
{
|
|
3606
|
+
x: m.x,
|
|
3607
|
+
y: m.y,
|
|
3608
|
+
className: `nice-datetime-popup__clock-num nice-datetime-popup__clock-num--minute${p === ee ? " nice-datetime-popup__clock-num--active" : ""}`,
|
|
3609
|
+
textAnchor: "middle",
|
|
3610
|
+
dominantBaseline: "central",
|
|
3611
|
+
children: xe(p)
|
|
3612
|
+
},
|
|
3613
|
+
`m-${p}`
|
|
3614
|
+
);
|
|
3615
|
+
})
|
|
3616
|
+
]
|
|
3617
|
+
}
|
|
3618
|
+
)
|
|
3619
|
+
] });
|
|
3620
|
+
}, Ln = /* @__PURE__ */ Object.assign(
|
|
3621
|
+
/* @__PURE__ */ bn(
|
|
3622
|
+
({
|
|
3623
|
+
label: n,
|
|
3624
|
+
helperText: i,
|
|
3625
|
+
error: t,
|
|
3626
|
+
required: o,
|
|
3627
|
+
disabled: a,
|
|
3628
|
+
readOnly: s,
|
|
3629
|
+
size: u = "md",
|
|
3630
|
+
name: M,
|
|
3631
|
+
id: w,
|
|
3632
|
+
className: A,
|
|
3633
|
+
style: ce,
|
|
3634
|
+
accessMode: D,
|
|
3635
|
+
value: T,
|
|
3636
|
+
onChange: X,
|
|
3637
|
+
onBlur: W,
|
|
3638
|
+
onKeyDown: z,
|
|
3639
|
+
min: I,
|
|
3640
|
+
max: $,
|
|
3641
|
+
dateFormatPreset: Z,
|
|
3642
|
+
submitOnEnter: ne,
|
|
3643
|
+
onSubmit: J,
|
|
3644
|
+
showKeyboardHints: pe,
|
|
3645
|
+
displayStyle: ae,
|
|
3646
|
+
labelPlacement: k,
|
|
3647
|
+
errorPlacement: U,
|
|
3648
|
+
loading: L,
|
|
3649
|
+
labelWidth: E,
|
|
3650
|
+
controlWidth: de,
|
|
3651
|
+
placeholder: te,
|
|
3652
|
+
clearable: ee = !1,
|
|
3653
|
+
showPickerButton: R = !0,
|
|
3654
|
+
displayLocale: S,
|
|
3655
|
+
keyboardShortcuts: P = !0,
|
|
3656
|
+
showSeconds: p = !1,
|
|
3657
|
+
minuteStep: m = 1,
|
|
3658
|
+
showNow: y = !1,
|
|
3659
|
+
hourFormat: V = "24",
|
|
3660
|
+
timeSelectorType: H = "spinners",
|
|
3661
|
+
targetDate: _,
|
|
3662
|
+
onTargetChange: N,
|
|
3663
|
+
countdown: Y = !1,
|
|
3664
|
+
countdownFormat: K = "verbose",
|
|
3665
|
+
formatCountdown: Q,
|
|
3666
|
+
countdownLabel: O,
|
|
3667
|
+
countdownInterval: fe = 1e3,
|
|
3668
|
+
countdownDoneText: ue
|
|
3669
|
+
}, re) => {
|
|
3670
|
+
const le = qn("input", ae), q = Rn("input", ae), Ce = dn(D, w), j = Ce === "hidden";
|
|
3671
|
+
Ce === "disabled" && (a = !0), Ce === "readOnly" && (s = !0);
|
|
3672
|
+
const { t: B } = Qe(), oe = un(w), _e = be(null), Ee = be(null), Ne = be(null), Ye = be(null), [ze, h] = Te(!1), [d, C] = Te(null), [ke, ve] = Te(""), [g, v] = Te(H);
|
|
3673
|
+
Le(() => {
|
|
3674
|
+
v(H);
|
|
3675
|
+
}, [H]);
|
|
3676
|
+
const Ke = Bt(It)?.portalTarget ?? (typeof document < "u" ? document.body : null), { start: Nn, stop: Cn } = Ft(), cn = Z ? Ci[Z] : null, Me = cn?.inputType ?? "date", rn = cn?.localized ?? !1, pn = S ?? Ct(), l = ge(
|
|
3677
|
+
() => ki(Me, rn, pn, p),
|
|
3678
|
+
[Me, rn, pn, p]
|
|
3679
|
+
), ie = ge(() => Qn(l.isoTpl), [l.isoTpl]), [De, Ge] = Te(() => {
|
|
3680
|
+
const c = Dn(T, l.isoTpl);
|
|
3681
|
+
return hn(l.displayTpl, l.isoTpl, c);
|
|
3682
|
+
}), Ie = be(De);
|
|
3683
|
+
Le(() => {
|
|
3684
|
+
Ie.current = De;
|
|
3685
|
+
}, [De]);
|
|
3686
|
+
const je = be(T ?? ""), Je = be(null);
|
|
3687
|
+
Le(() => {
|
|
3688
|
+
const c = T ?? "";
|
|
3689
|
+
if (c === je.current)
|
|
3690
|
+
return;
|
|
3691
|
+
const b = Dn(c, l.isoTpl), x = hn(l.displayTpl, l.isoTpl, b);
|
|
3692
|
+
Ge(x), je.current = c;
|
|
3693
|
+
}, [T, l.displayTpl, l.isoTpl]), Le(() => {
|
|
3694
|
+
const c = Dn(T, l.isoTpl);
|
|
3695
|
+
Ge(hn(l.displayTpl, l.isoTpl, c));
|
|
3696
|
+
}, [l.displayTpl, l.isoTpl]), Le(() => {
|
|
3697
|
+
if (Je.current == null)
|
|
3698
|
+
return;
|
|
3699
|
+
const c = Je.current;
|
|
3700
|
+
Je.current = null;
|
|
3701
|
+
const b = _e.current;
|
|
3702
|
+
if (b && document.activeElement === b)
|
|
3703
|
+
try {
|
|
3704
|
+
b.setSelectionRange(c, c);
|
|
3705
|
+
} catch {
|
|
3706
|
+
}
|
|
3707
|
+
});
|
|
3708
|
+
const on = ge(
|
|
3709
|
+
() => Xn(l.displayTpl, De),
|
|
3710
|
+
[l.displayTpl, De]
|
|
3711
|
+
), Un = te ?? l.placeholder, Sn = Math.max(l.displayTpl.length + 1, 9), En = Lt({
|
|
3712
|
+
enabled: ne,
|
|
3713
|
+
onSubmit: J
|
|
3714
|
+
}), Oe = F(
|
|
3715
|
+
(c, b) => {
|
|
3716
|
+
const x = c.slice(0, ie);
|
|
3717
|
+
Ie.current = x, Ge(x), Je.current = Ei(
|
|
3718
|
+
l.displayTpl,
|
|
3719
|
+
x,
|
|
3720
|
+
Math.max(0, Math.min(x.length, b))
|
|
3721
|
+
);
|
|
3722
|
+
const he = ot(rt(l.displayTpl, l.isoTpl, x), I, $);
|
|
3723
|
+
he !== je.current && (je.current = he, X?.(he));
|
|
3724
|
+
},
|
|
3725
|
+
[X, l.displayTpl, l.isoTpl, ie, I, $]
|
|
3726
|
+
), nn = F(
|
|
3727
|
+
(c) => {
|
|
3728
|
+
const b = ot(c, I, $), x = Dn(b, l.isoTpl);
|
|
3729
|
+
je.current = b, Ge(hn(l.displayTpl, l.isoTpl, x)), X?.(b);
|
|
3730
|
+
},
|
|
3731
|
+
[X, l.displayTpl, l.isoTpl, I, $]
|
|
3732
|
+
), tn = Me === "time" || Me === "datetime-local", yn = F(
|
|
3733
|
+
() => rt(l.displayTpl, l.isoTpl, Ie.current),
|
|
3734
|
+
[l.displayTpl, l.isoTpl]
|
|
3735
|
+
), zn = F(() => {
|
|
3736
|
+
if (a || s)
|
|
3737
|
+
return;
|
|
3738
|
+
const c = yn(), b = c ? An(c) : null;
|
|
3739
|
+
if (!b)
|
|
3740
|
+
return;
|
|
3741
|
+
const x = b.hours >= 12 ? b.hours - 12 : b.hours + 12;
|
|
3742
|
+
nn(st(c, x, b.minutes, b.seconds, p));
|
|
3743
|
+
}, [a, s, yn, nn, p]), Pn = (() => {
|
|
3744
|
+
const c = An(T ?? "");
|
|
3745
|
+
return c && c.hours >= 12 ? B("datetime.pm", "PM") : B("datetime.am", "AM");
|
|
3746
|
+
})(), Bn = F(
|
|
3747
|
+
(c) => {
|
|
3748
|
+
if (En(c), s || a) {
|
|
3749
|
+
z?.(c);
|
|
3750
|
+
return;
|
|
3751
|
+
}
|
|
3752
|
+
const b = c.key;
|
|
3753
|
+
if (c.ctrlKey || c.metaKey || c.altKey) {
|
|
3754
|
+
z?.(c);
|
|
3755
|
+
return;
|
|
3756
|
+
}
|
|
3757
|
+
if (tn && (b === "ArrowUp" || b === "ArrowDown")) {
|
|
3758
|
+
const ye = yn(), Ue = ye ? An(ye) : null;
|
|
3759
|
+
if (Ue) {
|
|
3760
|
+
c.preventDefault();
|
|
3761
|
+
const $e = b === "ArrowUp" ? 1 : -1;
|
|
3762
|
+
let { minutes: He, seconds: Ze } = Ue;
|
|
3763
|
+
p ? Ze = ((Ze + $e) % 60 + 60) % 60 : He = ((He + $e * m) % 60 + 60) % 60, nn(st(ye, Ue.hours, He, Ze, p)), z?.(c);
|
|
3764
|
+
return;
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
const x = Ie.current;
|
|
3768
|
+
if (b === "Escape" && x.length > 0) {
|
|
3769
|
+
c.preventDefault(), Oe("", 0), z?.(c);
|
|
3770
|
+
return;
|
|
3771
|
+
}
|
|
3772
|
+
if (P && (l.isoTpl === "yyyy-MM-dd" || l.isoTpl === "yyyy-MM-ddTHH:mm" || l.isoTpl === "yyyy-MM")) {
|
|
3773
|
+
const ye = ($e) => {
|
|
3774
|
+
const He = String($e.getFullYear()).padStart(4, "0"), Ze = String($e.getMonth() + 1).padStart(2, "0"), wn = String($e.getDate()).padStart(2, "0");
|
|
3775
|
+
let Tn = "";
|
|
3776
|
+
if (l.isoTpl === "yyyy-MM")
|
|
3777
|
+
Tn = `${He}-${Ze}`;
|
|
3778
|
+
else if (l.isoTpl === "yyyy-MM-dd")
|
|
3779
|
+
Tn = `${He}-${Ze}-${wn}`;
|
|
3780
|
+
else {
|
|
3781
|
+
const St = String($e.getHours()).padStart(2, "0"), At = String($e.getMinutes()).padStart(2, "0");
|
|
3782
|
+
Tn = `${He}-${Ze}-${wn}T${St}:${At}`;
|
|
3783
|
+
}
|
|
3784
|
+
nn(Tn);
|
|
3785
|
+
}, Ue = () => {
|
|
3786
|
+
if (T && /^\d{4}-\d{2}/.test(T)) {
|
|
3787
|
+
const $e = new Date(T);
|
|
3788
|
+
if (!Number.isNaN($e.getTime()))
|
|
3789
|
+
return $e;
|
|
3790
|
+
}
|
|
3791
|
+
return /* @__PURE__ */ new Date();
|
|
3792
|
+
};
|
|
3793
|
+
if (b === "t" || b === "T") {
|
|
3794
|
+
c.preventDefault(), ye(/* @__PURE__ */ new Date()), z?.(c);
|
|
3795
|
+
return;
|
|
3796
|
+
}
|
|
3797
|
+
if (b === "+" || b === "=" || b === "-") {
|
|
3798
|
+
c.preventDefault();
|
|
3799
|
+
const $e = b === "-" ? -1 : 1, He = Ue();
|
|
3800
|
+
He.setDate(He.getDate() + $e), ye(He), z?.(c);
|
|
3801
|
+
return;
|
|
3802
|
+
}
|
|
3803
|
+
if (b === "m" || b === "M") {
|
|
3804
|
+
c.preventDefault();
|
|
3805
|
+
const $e = Ue();
|
|
3806
|
+
$e.setMonth($e.getMonth() + (b === "M" ? -1 : 1)), ye($e), z?.(c);
|
|
3807
|
+
return;
|
|
3808
|
+
}
|
|
3809
|
+
if (b === "y" || b === "Y") {
|
|
3810
|
+
c.preventDefault();
|
|
3811
|
+
const $e = Ue();
|
|
3812
|
+
$e.setFullYear($e.getFullYear() + (b === "Y" ? -1 : 1)), ye($e), z?.(c);
|
|
3813
|
+
return;
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
const he = c.currentTarget, Re = he.selectionStart ?? 0, Be = he.selectionEnd ?? 0;
|
|
3817
|
+
if (/^[0-9]$/.test(b)) {
|
|
3818
|
+
c.preventDefault();
|
|
3819
|
+
const ye = en(l.displayTpl, Re, x), Ue = en(l.displayTpl, Be, x), $e = x.slice(0, ye), He = x.slice(Ue);
|
|
3820
|
+
let Ze = ($e + b + He).slice(0, ie);
|
|
3821
|
+
ye === Ue && $e.length + 1 + He.length > ie && (Ze = ($e + b + He.slice(1)).slice(0, ie)), Oe(Ze, ye + 1), z?.(c);
|
|
3822
|
+
return;
|
|
3823
|
+
}
|
|
3824
|
+
if (b === "Backspace") {
|
|
3825
|
+
if (c.preventDefault(), Re !== Be) {
|
|
3826
|
+
const ye = en(l.displayTpl, Re, x), Ue = en(l.displayTpl, Be, x), $e = x.slice(0, ye) + x.slice(Ue);
|
|
3827
|
+
Oe($e, ye);
|
|
3828
|
+
} else {
|
|
3829
|
+
const ye = en(l.displayTpl, Re, x);
|
|
3830
|
+
if (ye === 0) {
|
|
3831
|
+
z?.(c);
|
|
3832
|
+
return;
|
|
3833
|
+
}
|
|
3834
|
+
const Ue = x.slice(0, ye - 1) + x.slice(ye);
|
|
3835
|
+
Oe(Ue, ye - 1);
|
|
3836
|
+
}
|
|
3837
|
+
z?.(c);
|
|
3838
|
+
return;
|
|
3839
|
+
}
|
|
3840
|
+
if (b === "Delete") {
|
|
3841
|
+
if (c.preventDefault(), Re !== Be) {
|
|
3842
|
+
const ye = en(l.displayTpl, Re, x), Ue = en(l.displayTpl, Be, x), $e = x.slice(0, ye) + x.slice(Ue);
|
|
3843
|
+
Oe($e, ye);
|
|
3844
|
+
} else {
|
|
3845
|
+
const ye = en(l.displayTpl, Re, x);
|
|
3846
|
+
if (ye >= x.length) {
|
|
3847
|
+
z?.(c);
|
|
3848
|
+
return;
|
|
3849
|
+
}
|
|
3850
|
+
const Ue = x.slice(0, ye) + x.slice(ye + 1);
|
|
3851
|
+
Oe(Ue, ye);
|
|
3852
|
+
}
|
|
3853
|
+
z?.(c);
|
|
3854
|
+
return;
|
|
3855
|
+
}
|
|
3856
|
+
z?.(c);
|
|
3857
|
+
},
|
|
3858
|
+
[
|
|
3859
|
+
Oe,
|
|
3860
|
+
a,
|
|
3861
|
+
En,
|
|
3862
|
+
z,
|
|
3863
|
+
s,
|
|
3864
|
+
l.displayTpl,
|
|
3865
|
+
l.isoTpl,
|
|
3866
|
+
ie,
|
|
3867
|
+
P,
|
|
3868
|
+
T,
|
|
3869
|
+
tn,
|
|
3870
|
+
yn,
|
|
3871
|
+
nn,
|
|
3872
|
+
p,
|
|
3873
|
+
m
|
|
3874
|
+
]
|
|
3875
|
+
), [Mn, Hn] = Te(() => Date.now());
|
|
3876
|
+
Le(() => {
|
|
3877
|
+
if (!Y)
|
|
3878
|
+
return;
|
|
3879
|
+
const c = window.setInterval(
|
|
3880
|
+
() => Hn(Date.now()),
|
|
3881
|
+
Math.max(100, fe)
|
|
3882
|
+
);
|
|
3883
|
+
return () => window.clearInterval(c);
|
|
3884
|
+
}, [Y, fe]);
|
|
3885
|
+
const sn = ge(
|
|
3886
|
+
() => Ui(T, _, Mn),
|
|
3887
|
+
[T, _, Mn]
|
|
3888
|
+
), r = be(0);
|
|
3889
|
+
Le(() => {
|
|
3890
|
+
if (!N)
|
|
3891
|
+
return;
|
|
3892
|
+
const c = sn.getTime();
|
|
3893
|
+
c !== r.current && (r.current = c, N(sn));
|
|
3894
|
+
}, [sn, N]);
|
|
3895
|
+
const G = ge(() => {
|
|
3896
|
+
if (!Y)
|
|
3897
|
+
return null;
|
|
3898
|
+
const c = sn.getTime() - Mn;
|
|
3899
|
+
return Q ? Q(c, sn) : (Ri[K] ?? Mt)(c, ue ?? B("datetime.countdownDone", "Done"));
|
|
3900
|
+
}, [
|
|
3901
|
+
Y,
|
|
3902
|
+
sn,
|
|
3903
|
+
Mn,
|
|
3904
|
+
Q,
|
|
3905
|
+
K,
|
|
3906
|
+
ue,
|
|
3907
|
+
B
|
|
3908
|
+
]), se = F(
|
|
3909
|
+
(c) => {
|
|
3910
|
+
if (s || a)
|
|
3911
|
+
return;
|
|
3912
|
+
const b = c.clipboardData.getData("text");
|
|
3913
|
+
if (!b)
|
|
3914
|
+
return;
|
|
3915
|
+
c.preventDefault();
|
|
3916
|
+
const x = Ie.current, he = b.replace(/[^0-9]/g, "");
|
|
3917
|
+
let Re;
|
|
3918
|
+
he.length === ie && (b.includes("-") || b.includes("T")) ? Re = hn(l.displayTpl, l.isoTpl, he) : Re = he.slice(0, ie);
|
|
3919
|
+
const Be = c.currentTarget, ye = Be.selectionStart ?? 0, Ue = Be.selectionEnd ?? 0, $e = en(l.displayTpl, ye, x), He = en(l.displayTpl, Ue, x), Ze = x.slice(0, $e), wn = x.slice(He), Tn = (Ze + Re + wn).slice(0, ie);
|
|
3920
|
+
Oe(Tn, Math.min(ie, Ze.length + Re.length));
|
|
3921
|
+
},
|
|
3922
|
+
[Oe, a, s, l.displayTpl, l.isoTpl, ie]
|
|
3923
|
+
), we = F(
|
|
3924
|
+
(c) => {
|
|
3925
|
+
const b = c;
|
|
3926
|
+
if (b.inputType === "insertText" || b.inputType === "insertCompositionText" || b.inputType === "insertFromComposition") {
|
|
3927
|
+
const x = b.data ?? "";
|
|
3928
|
+
if (!/^[0-9]+$/.test(x)) {
|
|
3929
|
+
c.preventDefault();
|
|
3930
|
+
return;
|
|
3931
|
+
}
|
|
3932
|
+
if (x.length > 1) {
|
|
3933
|
+
c.preventDefault();
|
|
3934
|
+
const he = c.currentTarget, Re = he.selectionStart ?? 0, Be = he.selectionEnd ?? 0, ye = Ie.current, Ue = en(l.displayTpl, Re, ye), $e = en(l.displayTpl, Be, ye), He = ye.slice(0, Ue), Ze = ye.slice($e), wn = (He + x + Ze).slice(0, ie);
|
|
3935
|
+
Oe(wn, Math.min(ie, He.length + x.length));
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
},
|
|
3939
|
+
[Oe, l.displayTpl, ie]
|
|
3940
|
+
), Se = F(
|
|
3941
|
+
(c) => {
|
|
3942
|
+
if (s || a)
|
|
3943
|
+
return;
|
|
3944
|
+
const b = c.target.value, x = b.replace(/[^0-9]/g, "").slice(0, ie);
|
|
3945
|
+
if (x !== Ie.current)
|
|
3946
|
+
if (x.length === ie && (b.includes("-") || b.includes("T") || b.includes(":"))) {
|
|
3947
|
+
const he = hn(
|
|
3948
|
+
l.displayTpl,
|
|
3949
|
+
l.isoTpl,
|
|
3950
|
+
x
|
|
3951
|
+
);
|
|
3952
|
+
Oe(he, he.length);
|
|
3953
|
+
} else
|
|
3954
|
+
Oe(x, x.length);
|
|
3955
|
+
},
|
|
3956
|
+
[Oe, a, s, l.displayTpl, l.isoTpl, ie]
|
|
3957
|
+
), me = F(() => {
|
|
3958
|
+
Oe("", 0), requestAnimationFrame(() => _e.current?.focus());
|
|
3959
|
+
}, [Oe]), Pe = F(() => {
|
|
3960
|
+
if (a || s)
|
|
3961
|
+
return;
|
|
3962
|
+
if (Me === "date" || Me === "datetime-local" || Me === "time") {
|
|
3963
|
+
h((x) => !x);
|
|
3964
|
+
return;
|
|
3965
|
+
}
|
|
3966
|
+
const c = Ee.current;
|
|
3967
|
+
if (!c)
|
|
3968
|
+
return;
|
|
3969
|
+
const b = c;
|
|
3970
|
+
try {
|
|
3971
|
+
if (typeof b.showPicker == "function") {
|
|
3972
|
+
b.showPicker();
|
|
3973
|
+
return;
|
|
3974
|
+
}
|
|
3975
|
+
} catch {
|
|
3976
|
+
}
|
|
3977
|
+
c.focus(), c.click();
|
|
3978
|
+
}, [a, s, Me]), Fe = F(
|
|
3979
|
+
(c) => {
|
|
3980
|
+
const b = c.target.value, x = Dn(b, l.isoTpl), he = hn(l.displayTpl, l.isoTpl, x);
|
|
3981
|
+
je.current = b, Ge(he), X?.(b), requestAnimationFrame(() => _e.current?.focus());
|
|
3982
|
+
},
|
|
3983
|
+
[X, l.displayTpl, l.isoTpl]
|
|
3984
|
+
), qe = F(() => {
|
|
3985
|
+
if (a || s)
|
|
3986
|
+
return;
|
|
3987
|
+
const c = /* @__PURE__ */ new Date(), b = (Ue) => String(Ue).padStart(2, "0"), x = `${c.getFullYear()}-${b(c.getMonth() + 1)}-${b(c.getDate())}`, he = `${b(c.getHours())}:${b(c.getMinutes())}`, Re = p ? `${he}:${b(c.getSeconds())}` : he;
|
|
3988
|
+
let Be;
|
|
3989
|
+
Me === "time" ? Be = Re : Me === "datetime-local" ? Be = `${x}T${Re}` : Me === "month" ? Be = `${c.getFullYear()}-${b(c.getMonth() + 1)}` : Be = x;
|
|
3990
|
+
const ye = Dn(Be, l.isoTpl);
|
|
3991
|
+
je.current = Be, Ge(hn(l.displayTpl, l.isoTpl, ye)), X?.(Be);
|
|
3992
|
+
}, [a, s, Me, p, X, l.displayTpl, l.isoTpl]), $n = Me === "date" || Me === "datetime-local", _n = (() => {
|
|
3993
|
+
const c = /^(\d{4}-\d{2}-\d{2})/.exec(T ?? "");
|
|
3994
|
+
return c ? c[1] : "";
|
|
3995
|
+
})(), We = An(T ?? "") ?? { hours: 0, minutes: 0, seconds: 0 }, fn = () => {
|
|
3996
|
+
const c = /* @__PURE__ */ new Date();
|
|
3997
|
+
return `${c.getFullYear()}-${xe(c.getMonth() + 1)}-${xe(c.getDate())}`;
|
|
3998
|
+
}, mn = (c, b) => {
|
|
3999
|
+
const x = p ? `${xe(b.hours)}:${xe(b.minutes)}:${xe(b.seconds)}` : `${xe(b.hours)}:${xe(b.minutes)}`;
|
|
4000
|
+
let he;
|
|
4001
|
+
Me === "time" ? he = x : Me === "datetime-local" ? he = `${c}T${x}` : he = c, nn(he);
|
|
4002
|
+
}, Yn = (c) => {
|
|
4003
|
+
c && mn(c, tn ? We : { hours: 0, minutes: 0, seconds: 0 });
|
|
4004
|
+
}, In = (c, b) => {
|
|
4005
|
+
mn($n ? _n || fn() : "", { ...We, [c]: b });
|
|
4006
|
+
}, kn = (c) => c === "hours" ? 23 : 59, Wn = (c) => c === "minutes" && m && m > 0 ? m : 1, $t = (c, b) => {
|
|
4007
|
+
const x = kn(c), he = Wn(c), Re = x + 1, Be = ((We[c] + b * he) % Re + Re) % Re;
|
|
4008
|
+
In(c, Be);
|
|
4009
|
+
}, Vn = (c, b, x) => /* @__PURE__ */ e(
|
|
4010
|
+
Fi,
|
|
4011
|
+
{
|
|
4012
|
+
part: c,
|
|
4013
|
+
label: B(b, x),
|
|
4014
|
+
value: We[c],
|
|
4015
|
+
max: kn(c),
|
|
4016
|
+
step: Wn(c),
|
|
4017
|
+
onPick: (he) => In(c, he),
|
|
4018
|
+
onStep: (he) => $t(c, he),
|
|
4019
|
+
startHold: Nn,
|
|
4020
|
+
stopHold: Cn
|
|
4021
|
+
}
|
|
4022
|
+
), kt = () => {
|
|
4023
|
+
mn(fn(), tn ? We : { hours: 0, minutes: 0, seconds: 0 });
|
|
4024
|
+
}, Fn = (() => {
|
|
4025
|
+
const c = fn(), b = I && I.length >= 10 ? I.slice(0, 10) : I, x = $ && $.length >= 10 ? $.slice(0, 10) : $;
|
|
4026
|
+
return !!(b && c < b || x && c > x);
|
|
4027
|
+
})(), wt = () => {
|
|
4028
|
+
h(!1), requestAnimationFrame(() => _e.current?.focus());
|
|
4029
|
+
};
|
|
4030
|
+
ut(() => {
|
|
4031
|
+
if (!ze)
|
|
4032
|
+
return;
|
|
4033
|
+
const c = Ne.current?.getBoundingClientRect();
|
|
4034
|
+
c && (C({ left: c.left, top: c.bottom + 6 }), ve(Ot(Ne.current)));
|
|
4035
|
+
}, [ze]), Le(() => {
|
|
4036
|
+
if (!ze)
|
|
4037
|
+
return;
|
|
4038
|
+
const c = (he) => {
|
|
4039
|
+
const Re = he.target;
|
|
4040
|
+
Ne.current?.contains(Re) || Ye.current?.contains(Re) || h(!1);
|
|
4041
|
+
}, b = (he) => {
|
|
4042
|
+
he.key === "Escape" && h(!1);
|
|
4043
|
+
}, x = () => {
|
|
4044
|
+
const he = Ne.current?.getBoundingClientRect();
|
|
4045
|
+
he && C({ left: he.left, top: he.bottom + 6 });
|
|
4046
|
+
};
|
|
4047
|
+
return document.addEventListener("mousedown", c), document.addEventListener("keydown", b), window.addEventListener("scroll", x, !0), window.addEventListener("resize", x), () => {
|
|
4048
|
+
document.removeEventListener("mousedown", c), document.removeEventListener("keydown", b), window.removeEventListener("scroll", x, !0), window.removeEventListener("resize", x);
|
|
4049
|
+
};
|
|
4050
|
+
}, [ze]);
|
|
4051
|
+
const Tt = F(
|
|
4052
|
+
(c) => {
|
|
4053
|
+
_e.current = c, typeof re == "function" ? re(c) : re && (re.current = c);
|
|
4054
|
+
},
|
|
4055
|
+
[re]
|
|
4056
|
+
), et = ge(() => {
|
|
4057
|
+
const c = [];
|
|
4058
|
+
return ne && c.push(Ve.submit), c.push({ key: "Esc", description: B("shortcuts.clearDate", "Clear value") }), c;
|
|
4059
|
+
}, [ne, B]), Dt = Me === "time";
|
|
4060
|
+
return j ? null : /* @__PURE__ */ f(
|
|
4061
|
+
"div",
|
|
4062
|
+
{
|
|
4063
|
+
className: `nice-field nice-field--${u}${k ? ` nice-field--label-${k}` : ""}${U === "right" ? " nice-field--error-right" : ""} ${L ? "nice-field--loading" : ""} ${A || ""}`,
|
|
4064
|
+
style: {
|
|
4065
|
+
...ce,
|
|
4066
|
+
...E != null && {
|
|
4067
|
+
"--nice-field-label-width": typeof E == "number" ? `${E}px` : E
|
|
4068
|
+
},
|
|
4069
|
+
...de != null && {
|
|
4070
|
+
"--nice-field-control-width": typeof de == "number" ? `${de}px` : de
|
|
4071
|
+
}
|
|
4072
|
+
},
|
|
4073
|
+
"aria-busy": L || void 0,
|
|
4074
|
+
children: [
|
|
4075
|
+
n && /* @__PURE__ */ f(
|
|
4076
|
+
"label",
|
|
4077
|
+
{
|
|
4078
|
+
htmlFor: oe,
|
|
4079
|
+
className: `nice-field__label ${o ? "nice-field__label--required" : ""}`,
|
|
4080
|
+
children: [
|
|
4081
|
+
n,
|
|
4082
|
+
pe && et.length > 0 && /* @__PURE__ */ e(gn, { shortcuts: et, size: "sm" })
|
|
4083
|
+
]
|
|
4084
|
+
}
|
|
4085
|
+
),
|
|
4086
|
+
/* @__PURE__ */ f("div", { className: "nice-field__control", children: [
|
|
4087
|
+
/* @__PURE__ */ f(
|
|
4088
|
+
"div",
|
|
4089
|
+
{
|
|
4090
|
+
ref: Ne,
|
|
4091
|
+
className: `nice-input nice-input--date nice-input--${u} nice-input--ds-${q} ${t ? "nice-input--error" : ""} ${a ? "nice-input--disabled" : ""} ${s ? "nice-input--readonly" : ""}`,
|
|
4092
|
+
style: { ...le, width: "fit-content", position: "relative" },
|
|
4093
|
+
children: [
|
|
4094
|
+
/* @__PURE__ */ e(
|
|
4095
|
+
"input",
|
|
4096
|
+
{
|
|
4097
|
+
ref: Tt,
|
|
4098
|
+
id: oe,
|
|
4099
|
+
className: "nice-input__native nice-masked-input",
|
|
4100
|
+
type: "text",
|
|
4101
|
+
name: M,
|
|
4102
|
+
value: on,
|
|
4103
|
+
placeholder: Un,
|
|
4104
|
+
disabled: a || L,
|
|
4105
|
+
readOnly: s,
|
|
4106
|
+
autoComplete: "off",
|
|
4107
|
+
spellCheck: !1,
|
|
4108
|
+
inputMode: "numeric",
|
|
4109
|
+
"aria-invalid": !!t,
|
|
4110
|
+
"aria-label": n ? void 0 : B("controls.date", "Date"),
|
|
4111
|
+
"data-display-tpl": l.displayTpl,
|
|
4112
|
+
"data-iso-tpl": l.isoTpl,
|
|
4113
|
+
style: {
|
|
4114
|
+
width: `${Sn}ch`,
|
|
4115
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
4116
|
+
fontVariantNumeric: "tabular-nums"
|
|
4117
|
+
},
|
|
4118
|
+
onBeforeInput: we,
|
|
4119
|
+
onChange: Se,
|
|
4120
|
+
onBlur: W,
|
|
4121
|
+
onKeyDown: Bn,
|
|
4122
|
+
onPaste: se
|
|
4123
|
+
}
|
|
4124
|
+
),
|
|
4125
|
+
ee && /* @__PURE__ */ e(
|
|
4126
|
+
"button",
|
|
4127
|
+
{
|
|
4128
|
+
type: "button",
|
|
4129
|
+
className: "nice-input__clear",
|
|
4130
|
+
onClick: me,
|
|
4131
|
+
disabled: !T || a || s,
|
|
4132
|
+
"aria-label": B("controls.clear", "Clear"),
|
|
4133
|
+
tabIndex: T && !a && !s ? 0 : -1,
|
|
4134
|
+
children: /* @__PURE__ */ e(Ae, { name: "close", size: 14 })
|
|
4135
|
+
}
|
|
4136
|
+
),
|
|
4137
|
+
R && /* @__PURE__ */ f(vn, { children: [
|
|
4138
|
+
/* @__PURE__ */ e(
|
|
4139
|
+
"button",
|
|
4140
|
+
{
|
|
4141
|
+
type: "button",
|
|
4142
|
+
className: "nice-input__picker-trigger",
|
|
4143
|
+
onClick: Pe,
|
|
4144
|
+
"aria-label": B("controls.openPicker", "Open picker"),
|
|
4145
|
+
tabIndex: -1,
|
|
4146
|
+
disabled: a || s,
|
|
4147
|
+
children: Dt ? (
|
|
4148
|
+
/* Clock icon */
|
|
4149
|
+
/* @__PURE__ */ e(Ae, { name: "clock", size: 16 })
|
|
4150
|
+
) : (
|
|
4151
|
+
/* Calendar icon — outline style, matches NtdCalendar.outline */
|
|
4152
|
+
/* @__PURE__ */ e(Ae, { name: "calendar", size: 16 })
|
|
4153
|
+
)
|
|
4154
|
+
}
|
|
4155
|
+
),
|
|
4156
|
+
/* @__PURE__ */ e(
|
|
4157
|
+
"input",
|
|
4158
|
+
{
|
|
4159
|
+
ref: Ee,
|
|
4160
|
+
type: Me,
|
|
4161
|
+
className: "nice-input__picker-companion",
|
|
4162
|
+
value: T ?? "",
|
|
4163
|
+
min: I,
|
|
4164
|
+
max: $,
|
|
4165
|
+
step: Me === "time" || Me === "datetime-local" ? p ? 1 : m ? m * 60 : void 0 : void 0,
|
|
4166
|
+
onChange: Fe,
|
|
4167
|
+
tabIndex: -1,
|
|
4168
|
+
"aria-hidden": "true",
|
|
4169
|
+
style: {
|
|
4170
|
+
position: "absolute",
|
|
4171
|
+
width: 0,
|
|
4172
|
+
height: 0,
|
|
4173
|
+
opacity: 0,
|
|
4174
|
+
pointerEvents: "none",
|
|
4175
|
+
border: 0,
|
|
4176
|
+
padding: 0,
|
|
4177
|
+
left: 0,
|
|
4178
|
+
bottom: 0
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4181
|
+
)
|
|
4182
|
+
] }),
|
|
4183
|
+
tn && V === "12" && !a && !s && /* @__PURE__ */ e(
|
|
4184
|
+
"button",
|
|
4185
|
+
{
|
|
4186
|
+
type: "button",
|
|
4187
|
+
className: "nice-input__ampm",
|
|
4188
|
+
onClick: zn,
|
|
4189
|
+
disabled: !T,
|
|
4190
|
+
"aria-label": B("datetime.toggleAmPm", "Toggle AM/PM"),
|
|
4191
|
+
tabIndex: -1,
|
|
4192
|
+
children: Pn
|
|
4193
|
+
}
|
|
4194
|
+
),
|
|
4195
|
+
y && !a && !s && /* @__PURE__ */ e("button", { type: "button", className: "nice-input__now", onClick: qe, tabIndex: -1, children: B("controls.now", "Now") })
|
|
4196
|
+
]
|
|
4197
|
+
}
|
|
4198
|
+
),
|
|
4199
|
+
ze && d && Ke && pt(
|
|
4200
|
+
/* @__PURE__ */ f(
|
|
4201
|
+
"div",
|
|
4202
|
+
{
|
|
4203
|
+
ref: Ye,
|
|
4204
|
+
className: `nice-datetime-popup${ke ? ` ${ke}` : ""}`,
|
|
4205
|
+
style: {
|
|
4206
|
+
position: "fixed",
|
|
4207
|
+
left: d.left,
|
|
4208
|
+
top: d.top,
|
|
4209
|
+
zIndex: 1e3
|
|
4210
|
+
},
|
|
4211
|
+
role: "dialog",
|
|
4212
|
+
"aria-label": B("controls.openPicker", "Open picker"),
|
|
4213
|
+
children: [
|
|
4214
|
+
/* @__PURE__ */ f("div", { className: "nice-datetime-popup__body", children: [
|
|
4215
|
+
$n && /* @__PURE__ */ e("div", { className: "nice-datetime-popup__col nice-datetime-popup__col--date", children: /* @__PURE__ */ e(
|
|
4216
|
+
Nt,
|
|
4217
|
+
{
|
|
4218
|
+
value: _n,
|
|
4219
|
+
onChange: Yn,
|
|
4220
|
+
min: I && I.length >= 10 ? I.slice(0, 10) : void 0,
|
|
4221
|
+
max: $ && $.length >= 10 ? $.slice(0, 10) : void 0
|
|
4222
|
+
}
|
|
4223
|
+
) }),
|
|
4224
|
+
tn && /* @__PURE__ */ f("div", { className: "nice-datetime-popup__col nice-datetime-popup__col--time", children: [
|
|
4225
|
+
/* @__PURE__ */ f(
|
|
4226
|
+
"div",
|
|
4227
|
+
{
|
|
4228
|
+
className: "nice-datetime-popup__time-modes",
|
|
4229
|
+
role: "group",
|
|
4230
|
+
"aria-label": B("datetime.timeSelector", "Time selector"),
|
|
4231
|
+
children: [
|
|
4232
|
+
/* @__PURE__ */ e(
|
|
4233
|
+
"button",
|
|
4234
|
+
{
|
|
4235
|
+
type: "button",
|
|
4236
|
+
className: `nice-datetime-popup__mode-btn${g === "spinners" ? " nice-datetime-popup__mode-btn--active" : ""}`,
|
|
4237
|
+
onClick: () => v("spinners"),
|
|
4238
|
+
"aria-pressed": g === "spinners",
|
|
4239
|
+
"aria-label": B("datetime.spinnersMode", "Spinner wheels"),
|
|
4240
|
+
title: B("datetime.spinnersMode", "Spinner wheels"),
|
|
4241
|
+
tabIndex: -1,
|
|
4242
|
+
children: /* @__PURE__ */ e(Ae, { name: "list", size: 16 })
|
|
4243
|
+
}
|
|
4244
|
+
),
|
|
4245
|
+
/* @__PURE__ */ e(
|
|
4246
|
+
"button",
|
|
4247
|
+
{
|
|
4248
|
+
type: "button",
|
|
4249
|
+
className: `nice-datetime-popup__mode-btn${g === "clock" ? " nice-datetime-popup__mode-btn--active" : ""}`,
|
|
4250
|
+
onClick: () => v("clock"),
|
|
4251
|
+
"aria-pressed": g === "clock",
|
|
4252
|
+
"aria-label": B("datetime.clockMode", "Analog clock"),
|
|
4253
|
+
title: B("datetime.clockMode", "Analog clock"),
|
|
4254
|
+
tabIndex: -1,
|
|
4255
|
+
children: /* @__PURE__ */ e(Ae, { name: "clock", size: 16 })
|
|
4256
|
+
}
|
|
4257
|
+
)
|
|
4258
|
+
]
|
|
4259
|
+
}
|
|
4260
|
+
),
|
|
4261
|
+
g === "clock" ? /* @__PURE__ */ e(
|
|
4262
|
+
Li,
|
|
4263
|
+
{
|
|
4264
|
+
hours: We.hours,
|
|
4265
|
+
minutes: We.minutes,
|
|
4266
|
+
minuteStep: m,
|
|
4267
|
+
onChange: (c, b) => mn($n ? _n || fn() : "", {
|
|
4268
|
+
...We,
|
|
4269
|
+
hours: c,
|
|
4270
|
+
minutes: b
|
|
4271
|
+
}),
|
|
4272
|
+
t: B
|
|
4273
|
+
}
|
|
4274
|
+
) : /* @__PURE__ */ f("div", { className: "nice-datetime-popup__time", role: "group", children: [
|
|
4275
|
+
Vn("hours", "datetime.hours", "Hours"),
|
|
4276
|
+
/* @__PURE__ */ e("span", { className: "nice-datetime-popup__time-sep", children: ":" }),
|
|
4277
|
+
Vn("minutes", "datetime.minutes", "Minutes"),
|
|
4278
|
+
p && /* @__PURE__ */ f(vn, { children: [
|
|
4279
|
+
/* @__PURE__ */ e("span", { className: "nice-datetime-popup__time-sep", children: ":" }),
|
|
4280
|
+
Vn("seconds", "datetime.seconds", "Seconds")
|
|
4281
|
+
] })
|
|
4282
|
+
] })
|
|
4283
|
+
] })
|
|
4284
|
+
] }),
|
|
4285
|
+
/* @__PURE__ */ f("div", { className: "nice-datetime-popup__footer", children: [
|
|
4286
|
+
ee && /* @__PURE__ */ e(
|
|
4287
|
+
"button",
|
|
4288
|
+
{
|
|
4289
|
+
type: "button",
|
|
4290
|
+
className: "nice-datetime-popup__btn",
|
|
4291
|
+
onClick: me,
|
|
4292
|
+
children: B("controls.clear", "Clear")
|
|
4293
|
+
}
|
|
4294
|
+
),
|
|
4295
|
+
$n && /* @__PURE__ */ e(
|
|
4296
|
+
"button",
|
|
4297
|
+
{
|
|
4298
|
+
type: "button",
|
|
4299
|
+
className: "nice-datetime-popup__btn",
|
|
4300
|
+
onClick: kt,
|
|
4301
|
+
disabled: Fn,
|
|
4302
|
+
"aria-disabled": Fn || void 0,
|
|
4303
|
+
children: B("controls.today", "Today")
|
|
4304
|
+
}
|
|
4305
|
+
),
|
|
4306
|
+
tn && /* @__PURE__ */ e(
|
|
4307
|
+
"button",
|
|
4308
|
+
{
|
|
4309
|
+
type: "button",
|
|
4310
|
+
className: "nice-datetime-popup__btn",
|
|
4311
|
+
onClick: qe,
|
|
4312
|
+
disabled: Fn,
|
|
4313
|
+
"aria-disabled": Fn || void 0,
|
|
4314
|
+
children: B("controls.now", "Now")
|
|
4315
|
+
}
|
|
4316
|
+
),
|
|
4317
|
+
/* @__PURE__ */ e(
|
|
4318
|
+
"button",
|
|
4319
|
+
{
|
|
4320
|
+
type: "button",
|
|
4321
|
+
className: "nice-datetime-popup__btn nice-datetime-popup__btn--primary",
|
|
4322
|
+
onClick: wt,
|
|
4323
|
+
children: B("controls.confirm", "Confirm")
|
|
4324
|
+
}
|
|
4325
|
+
)
|
|
4326
|
+
] })
|
|
4327
|
+
]
|
|
4328
|
+
}
|
|
4329
|
+
),
|
|
4330
|
+
Ke
|
|
4331
|
+
),
|
|
4332
|
+
Y && G != null && /* @__PURE__ */ f("span", { className: "nice-datetime__countdown", "aria-live": "polite", children: [
|
|
4333
|
+
O && /* @__PURE__ */ f("span", { className: "nice-datetime__countdown-label", children: [
|
|
4334
|
+
O,
|
|
4335
|
+
" "
|
|
4336
|
+
] }),
|
|
4337
|
+
/* @__PURE__ */ e("span", { className: "nice-datetime__countdown-value", children: G })
|
|
4338
|
+
] }),
|
|
4339
|
+
L && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
4340
|
+
U === "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
|
|
4341
|
+
U === "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: i })
|
|
4342
|
+
] }),
|
|
4343
|
+
U !== "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
|
|
4344
|
+
U !== "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: i })
|
|
4345
|
+
]
|
|
4346
|
+
}
|
|
4347
|
+
);
|
|
4348
|
+
}
|
|
4349
|
+
),
|
|
4350
|
+
{ displayName: "NiceDateTimePicker" }
|
|
4351
|
+
), ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4352
|
+
__proto__: null,
|
|
4353
|
+
NiceDateTimePicker: Ln,
|
|
4354
|
+
getDefaultLocale: Ct
|
|
4355
|
+
}, Symbol.toStringTag, { value: "Module" })), zi = [], Pi = ({
|
|
4356
|
+
items: n = zi,
|
|
4357
|
+
data: i,
|
|
4358
|
+
onFieldChange: t,
|
|
4359
|
+
onSubmit: o,
|
|
4360
|
+
dataSource: a,
|
|
4361
|
+
recordKey: s,
|
|
4362
|
+
columns: u = 1,
|
|
4363
|
+
responsiveColumns: M,
|
|
4364
|
+
gap: w = 16,
|
|
4365
|
+
labelPosition: A = "top",
|
|
4366
|
+
size: ce = "md",
|
|
4367
|
+
readOnly: D,
|
|
4368
|
+
disabled: T,
|
|
4369
|
+
className: X,
|
|
4370
|
+
style: W,
|
|
4371
|
+
accessMode: z,
|
|
4372
|
+
id: I,
|
|
4373
|
+
autoSaveDelay: $,
|
|
4374
|
+
onDirtyChange: Z,
|
|
4375
|
+
showActions: ne,
|
|
4376
|
+
submitLabel: J,
|
|
4377
|
+
resetLabel: pe,
|
|
4378
|
+
onCancel: ae,
|
|
4379
|
+
cancelLabel: k
|
|
4380
|
+
}) => {
|
|
4381
|
+
const { t: U } = Qe(), L = J ?? U("form.submit", "Submit"), E = pe ?? U("form.reset", "Reset"), de = k ?? U("form.cancel", "Cancel"), te = dn(z, I), ee = te === "hidden";
|
|
4382
|
+
te === "disabled" && (T = !0), te === "readOnly" && (D = !0);
|
|
4383
|
+
const R = zt(a ?? null, s), S = !!a && s != null, P = ge(
|
|
4384
|
+
() => S ? R.editData : i ?? {},
|
|
4385
|
+
[S, R.editData, i]
|
|
4386
|
+
), [p] = Te(() => ({ ...P })), [m, y] = Te([]), V = ge(() => Object.keys(P).some((h) => P[h] !== p[h]), [P, p]), H = be(!1);
|
|
4387
|
+
Le(() => {
|
|
4388
|
+
V !== H.current && (H.current = V, Z?.(V));
|
|
4389
|
+
}, [V, Z]);
|
|
4390
|
+
const _ = be(null), N = F(() => {
|
|
4391
|
+
$ && (_.current && clearTimeout(_.current), _.current = setTimeout(() => {
|
|
4392
|
+
S ? R.save() : o?.(P);
|
|
4393
|
+
}, $));
|
|
4394
|
+
}, [$, S, R, o, P]), Y = F(
|
|
4395
|
+
(h, d) => {
|
|
4396
|
+
D || T || (y((C) => [...C, { field: h, prev: P[h] }]), S ? R.set(h, d) : t?.(h, d), N());
|
|
4397
|
+
},
|
|
4398
|
+
[S, R, t, D, T, P, N]
|
|
4399
|
+
), K = F(() => {
|
|
4400
|
+
if (m.length === 0)
|
|
4401
|
+
return;
|
|
4402
|
+
const h = m[m.length - 1];
|
|
4403
|
+
y((d) => d.slice(0, -1)), S ? R.set(h.field, h.prev) : t?.(h.field, h.prev);
|
|
4404
|
+
}, [m, S, R, t]), Q = F(
|
|
4405
|
+
(h) => {
|
|
4406
|
+
h.preventDefault(), _.current && clearTimeout(_.current), S ? R.save() : o?.(P);
|
|
4407
|
+
},
|
|
4408
|
+
[P, o, S, R]
|
|
4409
|
+
), O = be(null), [fe, ue] = Te(u);
|
|
4410
|
+
Le(() => {
|
|
4411
|
+
if (!M || !O.current) {
|
|
4412
|
+
ue(u);
|
|
4413
|
+
return;
|
|
4414
|
+
}
|
|
4415
|
+
const h = O.current, d = new ResizeObserver((C) => {
|
|
4416
|
+
const ke = C[0]?.contentRect.width ?? 0, ve = Object.keys(M).map(Number).sort((g, v) => v - g);
|
|
4417
|
+
for (const g of ve)
|
|
4418
|
+
if (ke >= g) {
|
|
4419
|
+
ue(M[g]);
|
|
4420
|
+
return;
|
|
4421
|
+
}
|
|
4422
|
+
ue(u);
|
|
4423
|
+
});
|
|
4424
|
+
return d.observe(h), () => d.disconnect();
|
|
4425
|
+
}, [M, u]);
|
|
4426
|
+
const re = ge(
|
|
4427
|
+
() => n.filter((h) => !(h.visible === !1 || h.visibleWhen && !h.visibleWhen(P))),
|
|
4428
|
+
[n, P]
|
|
4429
|
+
), le = ge(() => {
|
|
4430
|
+
const h = [];
|
|
4431
|
+
let d = null;
|
|
4432
|
+
for (const C of re)
|
|
4433
|
+
!d || d.name !== C.group ? (d = { name: C.group, items: [C] }, h.push(d)) : d.items.push(C);
|
|
4434
|
+
return h;
|
|
4435
|
+
}, [re]), q = F(
|
|
4436
|
+
(h) => {
|
|
4437
|
+
const d = P[h.field] !== void 0 ? P[h.field] : h.defaultValue, C = (v) => Y(h.field, v);
|
|
4438
|
+
if (h.render)
|
|
4439
|
+
return h.render(d, C);
|
|
4440
|
+
const ke = h.type || "text", ve = h.options?.map(
|
|
4441
|
+
(v) => typeof v == "string" ? { label: v, value: v } : { label: v.label, value: String(v.value) }
|
|
4442
|
+
), g = { size: ce, disabled: T, readOnly: D };
|
|
4443
|
+
switch (ke) {
|
|
4444
|
+
case "number":
|
|
4445
|
+
return /* @__PURE__ */ e(
|
|
4446
|
+
tt,
|
|
4447
|
+
{
|
|
4448
|
+
...g,
|
|
4449
|
+
value: d ?? null,
|
|
4450
|
+
onChange: (v) => C(v),
|
|
4451
|
+
required: h.required
|
|
4452
|
+
}
|
|
4453
|
+
);
|
|
4454
|
+
case "currency":
|
|
4455
|
+
return /* @__PURE__ */ e(
|
|
4456
|
+
tt,
|
|
4457
|
+
{
|
|
4458
|
+
...g,
|
|
4459
|
+
value: d ?? null,
|
|
4460
|
+
onChange: (v) => C(v),
|
|
4461
|
+
required: h.required,
|
|
4462
|
+
precision: h.precision ?? 2,
|
|
4463
|
+
step: h.step ?? 100,
|
|
4464
|
+
suffix: h.unit ?? "PLN",
|
|
4465
|
+
formatPreset: "money"
|
|
4466
|
+
}
|
|
4467
|
+
);
|
|
4468
|
+
case "textarea":
|
|
4469
|
+
return /* @__PURE__ */ e(yt, { ...g, value: d ?? "", onChange: (v) => C(v), rows: 3 });
|
|
4470
|
+
case "address":
|
|
4471
|
+
return /* @__PURE__ */ e(
|
|
4472
|
+
vt,
|
|
4473
|
+
{
|
|
4474
|
+
...g,
|
|
4475
|
+
value: d ?? {},
|
|
4476
|
+
onChange: (v) => C(v),
|
|
4477
|
+
required: h.required,
|
|
4478
|
+
columns: h.columns ?? 2
|
|
4479
|
+
}
|
|
4480
|
+
);
|
|
4481
|
+
case "select":
|
|
4482
|
+
return /* @__PURE__ */ e(
|
|
4483
|
+
ft,
|
|
4484
|
+
{
|
|
4485
|
+
...g,
|
|
4486
|
+
value: d ?? "",
|
|
4487
|
+
onChange: (v) => C(v),
|
|
4488
|
+
options: ve ?? []
|
|
4489
|
+
}
|
|
4490
|
+
);
|
|
4491
|
+
case "autocomplete":
|
|
4492
|
+
return /* @__PURE__ */ e(
|
|
4493
|
+
Qt,
|
|
4494
|
+
{
|
|
4495
|
+
...g,
|
|
4496
|
+
value: d ?? "",
|
|
4497
|
+
onChange: (v) => C(v),
|
|
4498
|
+
options: ve ?? []
|
|
4499
|
+
}
|
|
4500
|
+
);
|
|
4501
|
+
case "radio":
|
|
4502
|
+
return /* @__PURE__ */ e(
|
|
4503
|
+
mt,
|
|
4504
|
+
{
|
|
4505
|
+
...g,
|
|
4506
|
+
value: d ?? "",
|
|
4507
|
+
onChange: (v) => C(v),
|
|
4508
|
+
options: ve ?? []
|
|
4509
|
+
}
|
|
4510
|
+
);
|
|
4511
|
+
case "checkbox":
|
|
4512
|
+
return /* @__PURE__ */ e(
|
|
4513
|
+
jt,
|
|
4514
|
+
{
|
|
4515
|
+
...g,
|
|
4516
|
+
checked: !!d,
|
|
4517
|
+
onChange: (v) => C(v),
|
|
4518
|
+
label: h.label
|
|
4519
|
+
}
|
|
4520
|
+
);
|
|
4521
|
+
case "toggle":
|
|
4522
|
+
return /* @__PURE__ */ e(Yt, { ...g, checked: !!d, onChange: (v) => C(v) });
|
|
4523
|
+
case "date":
|
|
4524
|
+
return /* @__PURE__ */ e(Ln, { ...g, value: d ?? "", onChange: (v) => C(v) });
|
|
4525
|
+
case "time":
|
|
4526
|
+
return /* @__PURE__ */ e(
|
|
4527
|
+
Ln,
|
|
4528
|
+
{
|
|
4529
|
+
...g,
|
|
4530
|
+
dateFormatPreset: "time",
|
|
4531
|
+
value: d ?? "",
|
|
4532
|
+
onChange: (v) => C(v)
|
|
4533
|
+
}
|
|
4534
|
+
);
|
|
4535
|
+
case "datetime":
|
|
4536
|
+
return /* @__PURE__ */ e(
|
|
4537
|
+
Ln,
|
|
4538
|
+
{
|
|
4539
|
+
...g,
|
|
4540
|
+
dateFormatPreset: "datetime-local",
|
|
4541
|
+
value: d ?? "",
|
|
4542
|
+
onChange: (v) => C(v)
|
|
4543
|
+
}
|
|
4544
|
+
);
|
|
4545
|
+
case "color":
|
|
4546
|
+
return /* @__PURE__ */ e(
|
|
4547
|
+
Kt,
|
|
4548
|
+
{
|
|
4549
|
+
...g,
|
|
4550
|
+
value: d ?? "var(--nice-text-primary, #000000)",
|
|
4551
|
+
onChange: (v) => C(v)
|
|
4552
|
+
}
|
|
4553
|
+
);
|
|
4554
|
+
case "slider":
|
|
4555
|
+
return /* @__PURE__ */ e(
|
|
4556
|
+
gt,
|
|
4557
|
+
{
|
|
4558
|
+
...g,
|
|
4559
|
+
value: typeof d == "number" ? d : 0,
|
|
4560
|
+
onChange: (v) => C(v)
|
|
4561
|
+
}
|
|
4562
|
+
);
|
|
4563
|
+
case "rating":
|
|
4564
|
+
return /* @__PURE__ */ e(
|
|
4565
|
+
ht,
|
|
4566
|
+
{
|
|
4567
|
+
...g,
|
|
4568
|
+
value: typeof d == "number" ? d : 0,
|
|
4569
|
+
onChange: (v) => C(v)
|
|
4570
|
+
}
|
|
4571
|
+
);
|
|
4572
|
+
case "password":
|
|
4573
|
+
return /* @__PURE__ */ e(
|
|
4574
|
+
li,
|
|
4575
|
+
{
|
|
4576
|
+
...g,
|
|
4577
|
+
value: d ?? "",
|
|
4578
|
+
onChange: (v) => C(v),
|
|
4579
|
+
required: h.required
|
|
4580
|
+
}
|
|
4581
|
+
);
|
|
4582
|
+
case "phone":
|
|
4583
|
+
case "tel":
|
|
4584
|
+
return /* @__PURE__ */ e(
|
|
4585
|
+
an,
|
|
4586
|
+
{
|
|
4587
|
+
...g,
|
|
4588
|
+
type: "tel",
|
|
4589
|
+
value: d ?? "",
|
|
4590
|
+
onChange: (v) => C(v),
|
|
4591
|
+
required: h.required
|
|
4592
|
+
}
|
|
4593
|
+
);
|
|
4594
|
+
case "country":
|
|
4595
|
+
return /* @__PURE__ */ e(bt, { ...g, value: d ?? "", onChange: (v) => C(v) });
|
|
4596
|
+
case "tags":
|
|
4597
|
+
return /* @__PURE__ */ e(
|
|
4598
|
+
si,
|
|
4599
|
+
{
|
|
4600
|
+
...g,
|
|
4601
|
+
value: Array.isArray(d) ? d : [],
|
|
4602
|
+
onChange: (v) => C(v),
|
|
4603
|
+
options: ve ?? []
|
|
4604
|
+
}
|
|
4605
|
+
);
|
|
4606
|
+
case "masked":
|
|
4607
|
+
return /* @__PURE__ */ e(
|
|
4608
|
+
ti,
|
|
4609
|
+
{
|
|
4610
|
+
...g,
|
|
4611
|
+
value: d ?? "",
|
|
4612
|
+
mask: h.mask ?? "999-999-9999",
|
|
4613
|
+
onChange: (v) => C(v)
|
|
4614
|
+
}
|
|
4615
|
+
);
|
|
4616
|
+
case "file":
|
|
4617
|
+
return /* @__PURE__ */ e(hi, { ...g, onFilesSelected: (v) => C(v) });
|
|
4618
|
+
case "email":
|
|
4619
|
+
return /* @__PURE__ */ e(
|
|
4620
|
+
an,
|
|
4621
|
+
{
|
|
4622
|
+
...g,
|
|
4623
|
+
type: "email",
|
|
4624
|
+
value: d ?? "",
|
|
4625
|
+
onChange: (v) => C(v),
|
|
4626
|
+
required: h.required
|
|
4627
|
+
}
|
|
4628
|
+
);
|
|
4629
|
+
case "url":
|
|
4630
|
+
return /* @__PURE__ */ e(
|
|
4631
|
+
an,
|
|
4632
|
+
{
|
|
4633
|
+
...g,
|
|
4634
|
+
type: "url",
|
|
4635
|
+
value: d ?? "",
|
|
4636
|
+
onChange: (v) => C(v),
|
|
4637
|
+
required: h.required
|
|
4638
|
+
}
|
|
4639
|
+
);
|
|
4640
|
+
default:
|
|
4641
|
+
return /* @__PURE__ */ e(
|
|
4642
|
+
an,
|
|
4643
|
+
{
|
|
4644
|
+
...g,
|
|
4645
|
+
value: d ?? "",
|
|
4646
|
+
onChange: (v) => C(v),
|
|
4647
|
+
required: h.required
|
|
4648
|
+
}
|
|
4649
|
+
);
|
|
4650
|
+
}
|
|
4651
|
+
},
|
|
4652
|
+
[P, Y, T, D, ce]
|
|
4653
|
+
), Ce = (h) => /* @__PURE__ */ f(
|
|
4654
|
+
"div",
|
|
4655
|
+
{
|
|
4656
|
+
className: "nice-form__item",
|
|
4657
|
+
style: { gridColumn: h.colSpan ? `span ${h.colSpan}` : void 0 },
|
|
4658
|
+
children: [
|
|
4659
|
+
h.label && /* @__PURE__ */ f("label", { className: "nice-form__label", children: [
|
|
4660
|
+
h.label,
|
|
4661
|
+
h.required && /* @__PURE__ */ e("span", { className: "nice-field__required", children: "*" })
|
|
4662
|
+
] }),
|
|
4663
|
+
/* @__PURE__ */ e("div", { className: "nice-form__control", children: q(h) }),
|
|
4664
|
+
h.hint && /* @__PURE__ */ e("div", { className: "nice-form__hint", children: h.hint })
|
|
4665
|
+
]
|
|
4666
|
+
},
|
|
4667
|
+
h.field
|
|
4668
|
+
), j = {
|
|
4669
|
+
display: "grid",
|
|
4670
|
+
gridTemplateColumns: `repeat(${fe}, 1fr)`,
|
|
4671
|
+
gap: w
|
|
4672
|
+
}, B = le.some((h) => h.name != null), oe = ge(() => {
|
|
4673
|
+
const h = /* @__PURE__ */ new Set(), d = [];
|
|
4674
|
+
for (const C of re)
|
|
4675
|
+
C.tab && !h.has(C.tab) && (h.add(C.tab), d.push(C.tab));
|
|
4676
|
+
return d;
|
|
4677
|
+
}, [re]), _e = oe.length > 0, [Ee, Ne] = Te("");
|
|
4678
|
+
Le(() => {
|
|
4679
|
+
_e && !oe.includes(Ee) && Ne(oe[0]);
|
|
4680
|
+
}, [_e, oe, Ee]);
|
|
4681
|
+
const Ye = (h) => {
|
|
4682
|
+
const d = [];
|
|
4683
|
+
let C = null;
|
|
4684
|
+
for (const ve of h)
|
|
4685
|
+
!C || C.name !== ve.group ? (C = { name: ve.group, items: [ve] }, d.push(C)) : C.items.push(ve);
|
|
4686
|
+
return d.some((ve) => ve.name != null) ? d.map((ve, g) => /* @__PURE__ */ f(
|
|
4687
|
+
"fieldset",
|
|
4688
|
+
{
|
|
4689
|
+
className: ve.name ? "nice-form__group" : "nice-form__group nice-form__group--no-title",
|
|
4690
|
+
children: [
|
|
4691
|
+
ve.name && /* @__PURE__ */ e("legend", { className: "nice-form__group-title", children: ve.name }),
|
|
4692
|
+
/* @__PURE__ */ e("div", { style: j, children: ve.items.map(Ce) })
|
|
4693
|
+
]
|
|
4694
|
+
},
|
|
4695
|
+
g
|
|
4696
|
+
)) : /* @__PURE__ */ e("div", { style: j, children: h.map(Ce) });
|
|
4697
|
+
}, ze = ne ? /* @__PURE__ */ f("div", { className: "nice-form__actions", children: [
|
|
4698
|
+
/* @__PURE__ */ f("div", { className: "nice-form__actions-left", children: [
|
|
4699
|
+
ae && /* @__PURE__ */ e(Gn, { type: "button", variant: "secondary", size: ce, onClick: ae, children: de }),
|
|
4700
|
+
/* @__PURE__ */ e(
|
|
4701
|
+
Gn,
|
|
4702
|
+
{
|
|
4703
|
+
type: "button",
|
|
4704
|
+
variant: "ghost",
|
|
4705
|
+
size: ce,
|
|
4706
|
+
onClick: K,
|
|
4707
|
+
disabled: m.length === 0,
|
|
4708
|
+
children: E
|
|
4709
|
+
}
|
|
4710
|
+
)
|
|
4711
|
+
] }),
|
|
4712
|
+
/* @__PURE__ */ e("div", { className: "nice-form__actions-right", children: /* @__PURE__ */ e(Gn, { type: "submit", variant: "primary", size: ce, children: L }) })
|
|
4713
|
+
] }) : null;
|
|
4714
|
+
return ee ? null : /* @__PURE__ */ f(
|
|
4715
|
+
"form",
|
|
4716
|
+
{
|
|
4717
|
+
ref: O,
|
|
4718
|
+
className: `nice-form nice-form--label-${A}${V ? " nice-form--dirty" : ""} ${X || ""}`,
|
|
4719
|
+
style: B || _e ? { ...W } : { ...j, ...W },
|
|
4720
|
+
onSubmit: Q,
|
|
4721
|
+
noValidate: !0,
|
|
4722
|
+
children: [
|
|
4723
|
+
_e ? /* @__PURE__ */ e(
|
|
4724
|
+
Vt,
|
|
4725
|
+
{
|
|
4726
|
+
className: "nice-form__tabs",
|
|
4727
|
+
activeTab: Ee || oe[0],
|
|
4728
|
+
onChange: Ne,
|
|
4729
|
+
tabs: oe.map((h) => ({
|
|
4730
|
+
id: h,
|
|
4731
|
+
label: h,
|
|
4732
|
+
content: /* @__PURE__ */ e("div", { className: "nice-form__tab-panel", children: Ye(re.filter((d) => (d.tab ?? oe[0]) === h)) })
|
|
4733
|
+
}))
|
|
4734
|
+
}
|
|
4735
|
+
) : B ? le.map((h, d) => /* @__PURE__ */ f(
|
|
4736
|
+
"fieldset",
|
|
4737
|
+
{
|
|
4738
|
+
className: h.name ? "nice-form__group" : "nice-form__group nice-form__group--no-title",
|
|
4739
|
+
children: [
|
|
4740
|
+
h.name && /* @__PURE__ */ e("legend", { className: "nice-form__group-title", children: h.name }),
|
|
4741
|
+
/* @__PURE__ */ e("div", { style: j, children: h.items.map(Ce) })
|
|
4742
|
+
]
|
|
4743
|
+
},
|
|
4744
|
+
d
|
|
4745
|
+
)) : re.map(Ce),
|
|
4746
|
+
ze
|
|
4747
|
+
]
|
|
4748
|
+
}
|
|
4749
|
+
);
|
|
4750
|
+
};
|
|
4751
|
+
process.env.NODE_ENV !== "production" && (Pi.displayName = "NiceForm");
|
|
4752
|
+
export {
|
|
4753
|
+
yi as C,
|
|
4754
|
+
Xt as M,
|
|
4755
|
+
Qt as N,
|
|
4756
|
+
Nt as a,
|
|
4757
|
+
bt as b,
|
|
4758
|
+
Ln as c,
|
|
4759
|
+
Pi as d,
|
|
4760
|
+
ti as e,
|
|
4761
|
+
li as f,
|
|
4762
|
+
mt as g,
|
|
4763
|
+
ht as h,
|
|
4764
|
+
gt as i,
|
|
4765
|
+
si as j,
|
|
4766
|
+
yt as k,
|
|
4767
|
+
hi as l,
|
|
4768
|
+
Ct as m,
|
|
4769
|
+
vt as n,
|
|
4770
|
+
Ji as o,
|
|
4771
|
+
Qi as p,
|
|
4772
|
+
Xi as q,
|
|
4773
|
+
Wi as r,
|
|
4774
|
+
ea as s
|
|
4775
|
+
};
|