siddha-ui-react 0.0.0-stage → 1.0.1
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/LICENSE +21 -0
- package/README.md +126 -2
- package/lib/index.cjs +2 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.js +733 -0
- package/lib/index.js.map +1 -0
- package/package.json +54 -4
- package/styles.css +3593 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
import { jsx as e, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { useId as x, useState as C, useEffect as D, useRef as E, useLayoutEffect as O } from "react";
|
|
3
|
+
const p = (...i) => i.filter(Boolean).join(" ");
|
|
4
|
+
function A({
|
|
5
|
+
children: i,
|
|
6
|
+
variant: n = "primary",
|
|
7
|
+
size: t = "md",
|
|
8
|
+
className: r = "",
|
|
9
|
+
type: a = "button",
|
|
10
|
+
...s
|
|
11
|
+
}) {
|
|
12
|
+
const c = ["primary", "secondary"].includes(n) ? n : "primary";
|
|
13
|
+
return /* @__PURE__ */ e(
|
|
14
|
+
"button",
|
|
15
|
+
{
|
|
16
|
+
className: p("ui-button", `ui-button--${c}`, `ui-button--${t}`, r),
|
|
17
|
+
type: a,
|
|
18
|
+
...s,
|
|
19
|
+
children: i
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
function S({ label: i, children: n, size: t = "md", className: r = "", ...a }) {
|
|
24
|
+
return /* @__PURE__ */ e(
|
|
25
|
+
"button",
|
|
26
|
+
{
|
|
27
|
+
className: p("ui-icon-button", `ui-icon-button--${t}`, r),
|
|
28
|
+
type: "button",
|
|
29
|
+
"aria-label": i,
|
|
30
|
+
...a,
|
|
31
|
+
children: n
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
function P({ label: i, helper: n, error: t, className: r = "", id: a, ...s }) {
|
|
36
|
+
const c = x(), l = a || c;
|
|
37
|
+
return /* @__PURE__ */ d("label", { className: p("ui-field", t && "is-error", r), htmlFor: l, children: [
|
|
38
|
+
i && /* @__PURE__ */ e("span", { className: "ui-field__label", children: i }),
|
|
39
|
+
/* @__PURE__ */ e(
|
|
40
|
+
"input",
|
|
41
|
+
{
|
|
42
|
+
id: l,
|
|
43
|
+
"aria-invalid": !!t,
|
|
44
|
+
"aria-describedby": n || t ? `${l}-message` : void 0,
|
|
45
|
+
...s
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
(n || t) && /* @__PURE__ */ e("small", { id: `${l}-message`, className: "ui-field__message", children: t || n })
|
|
49
|
+
] });
|
|
50
|
+
}
|
|
51
|
+
function G({ label: i, helper: n, error: t, className: r = "", id: a, ...s }) {
|
|
52
|
+
const c = x(), l = a || c;
|
|
53
|
+
return /* @__PURE__ */ d("label", { className: p("ui-field", t && "is-error", r), htmlFor: l, children: [
|
|
54
|
+
i && /* @__PURE__ */ e("span", { className: "ui-field__label", children: i }),
|
|
55
|
+
/* @__PURE__ */ e(
|
|
56
|
+
"textarea",
|
|
57
|
+
{
|
|
58
|
+
id: l,
|
|
59
|
+
"aria-invalid": !!t,
|
|
60
|
+
"aria-describedby": n || t ? `${l}-message` : void 0,
|
|
61
|
+
...s
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
(n || t) && /* @__PURE__ */ e("small", { id: `${l}-message`, className: "ui-field__message", children: t || n })
|
|
65
|
+
] });
|
|
66
|
+
}
|
|
67
|
+
function U({ label: i, children: n, helper: t, error: r, className: a = "", id: s, ...c }) {
|
|
68
|
+
const l = x(), u = s || l;
|
|
69
|
+
return /* @__PURE__ */ d("label", { className: p("ui-field", r && "is-error", a), htmlFor: u, children: [
|
|
70
|
+
i && /* @__PURE__ */ e("span", { className: "ui-field__label", children: i }),
|
|
71
|
+
/* @__PURE__ */ e(
|
|
72
|
+
"select",
|
|
73
|
+
{
|
|
74
|
+
id: u,
|
|
75
|
+
"aria-invalid": !!r,
|
|
76
|
+
"aria-describedby": t || r ? `${u}-message` : void 0,
|
|
77
|
+
...c,
|
|
78
|
+
children: n
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
(t || r) && /* @__PURE__ */ e("small", { id: `${u}-message`, className: "ui-field__message", children: r || t })
|
|
82
|
+
] });
|
|
83
|
+
}
|
|
84
|
+
function q(i) {
|
|
85
|
+
return /* @__PURE__ */ e(P, { type: "date", ...i });
|
|
86
|
+
}
|
|
87
|
+
function H({
|
|
88
|
+
label: i = "Upload files",
|
|
89
|
+
helper: n,
|
|
90
|
+
error: t,
|
|
91
|
+
min: r,
|
|
92
|
+
max: a,
|
|
93
|
+
accept: s,
|
|
94
|
+
multiple: c = !1,
|
|
95
|
+
disabled: l = !1,
|
|
96
|
+
className: u = "",
|
|
97
|
+
id: h,
|
|
98
|
+
onChange: b,
|
|
99
|
+
...w
|
|
100
|
+
}) {
|
|
101
|
+
const g = x(), N = h || g, k = `${N}-message`, v = r == null || r === "" ? void 0 : Number(r), _ = a == null || a === "" ? void 0 : Number(a), o = v !== void 0 && (!Number.isFinite(v) || v < 0) ? "Minimum file size must be a non-negative number of bytes." : _ !== void 0 && (!Number.isFinite(_) || _ < 0) ? "Maximum file size must be a non-negative number of bytes." : v !== void 0 && _ !== void 0 && v > _ ? "Minimum file size cannot exceed maximum file size." : "", [m, f] = C(""), y = t || o || m, $ = y || n;
|
|
102
|
+
D(() => {
|
|
103
|
+
f("");
|
|
104
|
+
}, [v, _]);
|
|
105
|
+
const I = (M) => {
|
|
106
|
+
const B = Array.from(M.currentTarget.files ?? []), L = B.find((T) => v != null && T.size < v), z = B.find((T) => _ != null && T.size > _);
|
|
107
|
+
if (L) {
|
|
108
|
+
f(`${L.name} must be at least ${v} bytes.`), M.currentTarget.value = "";
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (z) {
|
|
112
|
+
f(`${z.name} must be no larger than ${_} bytes.`), M.currentTarget.value = "";
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
f(""), b?.(M);
|
|
116
|
+
};
|
|
117
|
+
return /* @__PURE__ */ d("label", { className: p("ui-file-upload", u), htmlFor: N, children: [
|
|
118
|
+
/* @__PURE__ */ e("span", { className: "ui-file-upload__label", children: i }),
|
|
119
|
+
/* @__PURE__ */ d("span", { className: "ui-file-upload__control", children: [
|
|
120
|
+
/* @__PURE__ */ e(
|
|
121
|
+
"input",
|
|
122
|
+
{
|
|
123
|
+
...w,
|
|
124
|
+
id: N,
|
|
125
|
+
type: "file",
|
|
126
|
+
accept: s,
|
|
127
|
+
multiple: c,
|
|
128
|
+
disabled: l || !!o,
|
|
129
|
+
"aria-invalid": !!y,
|
|
130
|
+
"aria-describedby": $ ? k : void 0,
|
|
131
|
+
onChange: I
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
$ && /* @__PURE__ */ e(
|
|
135
|
+
"small",
|
|
136
|
+
{
|
|
137
|
+
id: k,
|
|
138
|
+
className: p("ui-file-upload__message", y && "is-error"),
|
|
139
|
+
role: y ? "alert" : void 0,
|
|
140
|
+
children: $
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] })
|
|
144
|
+
] });
|
|
145
|
+
}
|
|
146
|
+
function R({ label: i, className: n = "", ...t }) {
|
|
147
|
+
return /* @__PURE__ */ d("label", { className: p("ui-choice", n), children: [
|
|
148
|
+
/* @__PURE__ */ e("input", { type: "checkbox", ...t }),
|
|
149
|
+
/* @__PURE__ */ e("span", { children: i })
|
|
150
|
+
] });
|
|
151
|
+
}
|
|
152
|
+
function V({ label: i, className: n = "", ...t }) {
|
|
153
|
+
return /* @__PURE__ */ d("label", { className: p("ui-choice", n), children: [
|
|
154
|
+
/* @__PURE__ */ e("input", { type: "radio", ...t }),
|
|
155
|
+
/* @__PURE__ */ e("span", { children: i })
|
|
156
|
+
] });
|
|
157
|
+
}
|
|
158
|
+
function W({ label: i, className: n = "", ...t }) {
|
|
159
|
+
return /* @__PURE__ */ d("label", { className: p("ui-switch", n), children: [
|
|
160
|
+
/* @__PURE__ */ e("input", { type: "checkbox", role: "switch", ...t }),
|
|
161
|
+
/* @__PURE__ */ e("span", { className: "ui-switch__track", "aria-hidden": "true", children: /* @__PURE__ */ e("span", {}) }),
|
|
162
|
+
i && /* @__PURE__ */ e("span", { children: i })
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
function X({ label: i, options: n, listId: t = "autocomplete-options", ...r }) {
|
|
166
|
+
return /* @__PURE__ */ d("label", { className: "ui-field", children: [
|
|
167
|
+
/* @__PURE__ */ e("span", { className: "ui-field__label", children: i }),
|
|
168
|
+
/* @__PURE__ */ e("input", { type: "text", list: t, autoComplete: "off", ...r }),
|
|
169
|
+
/* @__PURE__ */ e("datalist", { id: t, children: n.map((a) => /* @__PURE__ */ e("option", { value: a }, a)) })
|
|
170
|
+
] });
|
|
171
|
+
}
|
|
172
|
+
function Y({ label: i = "Select items", options: n, value: t, onChange: r }) {
|
|
173
|
+
const [a, s] = C(!1), c = (l) => r(t.includes(l) ? t.filter((u) => u !== l) : [...t, l]);
|
|
174
|
+
return /* @__PURE__ */ d("div", { className: "ui-field ui-multi-select", children: [
|
|
175
|
+
/* @__PURE__ */ e("span", { className: "ui-field__label", children: i }),
|
|
176
|
+
/* @__PURE__ */ d("button", { type: "button", "aria-expanded": a, onClick: () => s((l) => !l), children: [
|
|
177
|
+
/* @__PURE__ */ e("span", { children: t.length ? t.join(", ") : "Choose team members" }),
|
|
178
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", children: "⌄" })
|
|
179
|
+
] }),
|
|
180
|
+
a && /* @__PURE__ */ e("div", { className: "ui-multi-select__menu", children: n.map((l) => /* @__PURE__ */ e(
|
|
181
|
+
R,
|
|
182
|
+
{
|
|
183
|
+
label: l,
|
|
184
|
+
checked: t.includes(l),
|
|
185
|
+
onChange: () => c(l)
|
|
186
|
+
},
|
|
187
|
+
l
|
|
188
|
+
)) })
|
|
189
|
+
] });
|
|
190
|
+
}
|
|
191
|
+
function J({ options: i, value: n, onChange: t, label: r, disabled: a = !1 }) {
|
|
192
|
+
return /* @__PURE__ */ e(
|
|
193
|
+
"div",
|
|
194
|
+
{
|
|
195
|
+
className: p("ui-button-group", a && "is-disabled"),
|
|
196
|
+
role: "group",
|
|
197
|
+
"aria-label": r,
|
|
198
|
+
children: i.map((s) => /* @__PURE__ */ e(
|
|
199
|
+
"button",
|
|
200
|
+
{
|
|
201
|
+
className: n === s.value ? "is-active" : "",
|
|
202
|
+
type: "button",
|
|
203
|
+
onClick: () => t(s.value),
|
|
204
|
+
"aria-pressed": n === s.value,
|
|
205
|
+
disabled: a,
|
|
206
|
+
children: s.label
|
|
207
|
+
},
|
|
208
|
+
s.value
|
|
209
|
+
))
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
function Q({ children: i, tone: n = "neutral", className: t = "" }) {
|
|
214
|
+
return /* @__PURE__ */ e("span", { className: p("ui-badge", `ui-badge--${n}`, t), children: i });
|
|
215
|
+
}
|
|
216
|
+
function Z({ name: i, src: n, size: t = "md", className: r = "" }) {
|
|
217
|
+
const a = i.split(" ").map((s) => s[0]).slice(0, 2).join("").toUpperCase();
|
|
218
|
+
return /* @__PURE__ */ e("span", { className: p("ui-avatar", `ui-avatar--${t}`, r), "aria-label": i, children: n ? /* @__PURE__ */ e("img", { src: n, alt: "" }) : a });
|
|
219
|
+
}
|
|
220
|
+
function ee({ content: i, children: n = "?" }) {
|
|
221
|
+
return /* @__PURE__ */ e("button", { className: "ui-tooltip", type: "button", "data-tooltip": i, "aria-label": i, children: n });
|
|
222
|
+
}
|
|
223
|
+
function ie({ label: i, value: n, tone: t = "primary", success: r = !1 }) {
|
|
224
|
+
const a = ["primary", "success", "warning", "error"].includes(t) ? t : "primary";
|
|
225
|
+
return /* @__PURE__ */ d("div", { className: "ui-progress", children: [
|
|
226
|
+
/* @__PURE__ */ d("div", { children: [
|
|
227
|
+
/* @__PURE__ */ e("span", { children: i }),
|
|
228
|
+
/* @__PURE__ */ d("strong", { children: [
|
|
229
|
+
n,
|
|
230
|
+
"%"
|
|
231
|
+
] })
|
|
232
|
+
] }),
|
|
233
|
+
/* @__PURE__ */ d("progress", { className: `is-${r ? "success" : a}`, value: n, max: "100", children: [
|
|
234
|
+
n,
|
|
235
|
+
"%"
|
|
236
|
+
] })
|
|
237
|
+
] });
|
|
238
|
+
}
|
|
239
|
+
function ne({ label: i, value: n, ...t }) {
|
|
240
|
+
const r = x();
|
|
241
|
+
return /* @__PURE__ */ d("label", { className: "ui-field ui-slider", htmlFor: r, children: [
|
|
242
|
+
/* @__PURE__ */ d("span", { className: "ui-field__label", children: [
|
|
243
|
+
i,
|
|
244
|
+
/* @__PURE__ */ e("output", { children: n })
|
|
245
|
+
] }),
|
|
246
|
+
/* @__PURE__ */ e("input", { id: r, type: "range", value: n, ...t })
|
|
247
|
+
] });
|
|
248
|
+
}
|
|
249
|
+
function te({ className: i = "", animate: n = !0 }) {
|
|
250
|
+
return /* @__PURE__ */ e("div", { className: p("ui-skeleton", !n && "is-static", i), "aria-hidden": "true" });
|
|
251
|
+
}
|
|
252
|
+
function ae({ children: i, className: n = "" }) {
|
|
253
|
+
return /* @__PURE__ */ e("article", { className: p("ui-card", n), children: i });
|
|
254
|
+
}
|
|
255
|
+
function re({ label: i }) {
|
|
256
|
+
return /* @__PURE__ */ e("div", { className: "ui-divider", role: "separator", children: i && /* @__PURE__ */ e("span", { children: i }) });
|
|
257
|
+
}
|
|
258
|
+
function le({ tone: i = "info", title: n, children: t, onClose: r }) {
|
|
259
|
+
return /* @__PURE__ */ d("div", { className: `ui-alert ui-alert--${i}`, role: i === "error" ? "alert" : "status", children: [
|
|
260
|
+
/* @__PURE__ */ e("span", { className: "ui-alert__icon", "aria-hidden": "true", children: i === "success" ? "✓" : i === "error" ? "!" : "i" }),
|
|
261
|
+
/* @__PURE__ */ d("div", { children: [
|
|
262
|
+
n && /* @__PURE__ */ e("strong", { children: n }),
|
|
263
|
+
/* @__PURE__ */ e("p", { children: t })
|
|
264
|
+
] }),
|
|
265
|
+
r && /* @__PURE__ */ e("button", { type: "button", "aria-label": "Dismiss alert", onClick: r, children: "×" })
|
|
266
|
+
] });
|
|
267
|
+
}
|
|
268
|
+
function se({
|
|
269
|
+
message: i,
|
|
270
|
+
tone: n = "success",
|
|
271
|
+
position: t = "bottom-right",
|
|
272
|
+
inline: r = !1,
|
|
273
|
+
duration: a = 0,
|
|
274
|
+
onClose: s
|
|
275
|
+
}) {
|
|
276
|
+
const c = n === "error" || n === "warning" ? "!" : "✓";
|
|
277
|
+
return D(() => {
|
|
278
|
+
if (!a || !s) return;
|
|
279
|
+
const l = window.setTimeout(s, a);
|
|
280
|
+
return () => window.clearTimeout(l);
|
|
281
|
+
}, [a, s, i]), /* @__PURE__ */ d(
|
|
282
|
+
"div",
|
|
283
|
+
{
|
|
284
|
+
className: p(
|
|
285
|
+
r ? "inline-toast" : "toast",
|
|
286
|
+
`toast--${n}`,
|
|
287
|
+
r || i ? "is-visible" : "",
|
|
288
|
+
!r && `toast--${t}`
|
|
289
|
+
),
|
|
290
|
+
role: n === "error" ? "alert" : "status",
|
|
291
|
+
"aria-live": "polite",
|
|
292
|
+
children: [
|
|
293
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", children: c }),
|
|
294
|
+
/* @__PURE__ */ d("div", { children: [
|
|
295
|
+
/* @__PURE__ */ e("strong", { children: n === "success" ? "Completed" : n === "error" ? "Needs attention" : "Notice" }),
|
|
296
|
+
/* @__PURE__ */ e("p", { children: i })
|
|
297
|
+
] }),
|
|
298
|
+
s && /* @__PURE__ */ e("button", { type: "button", "aria-label": "Dismiss notification", onClick: s, children: "×" })
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
function F(i, n, t) {
|
|
304
|
+
D(() => {
|
|
305
|
+
if (!i) return;
|
|
306
|
+
const r = document.activeElement, a = (c) => {
|
|
307
|
+
if (c.key === "Escape") {
|
|
308
|
+
n();
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (c.key !== "Tab") return;
|
|
312
|
+
const l = [
|
|
313
|
+
...t.current?.querySelectorAll(
|
|
314
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
315
|
+
) ?? []
|
|
316
|
+
].filter((b) => !b.disabled);
|
|
317
|
+
if (!l.length) {
|
|
318
|
+
c.preventDefault();
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const u = l[0], h = l[l.length - 1];
|
|
322
|
+
t.current?.contains(document.activeElement) ? c.shiftKey && document.activeElement === u ? (c.preventDefault(), h.focus()) : !c.shiftKey && document.activeElement === h && (c.preventDefault(), u.focus()) : (c.preventDefault(), (c.shiftKey ? h : u).focus());
|
|
323
|
+
}, s = document.body.style.overflow;
|
|
324
|
+
return document.addEventListener("keydown", a), document.body.style.overflow = "hidden", window.setTimeout(() => t.current?.focus(), 0), () => {
|
|
325
|
+
document.removeEventListener("keydown", a), document.body.style.overflow = s, r?.focus?.();
|
|
326
|
+
};
|
|
327
|
+
}, [t, n, i]);
|
|
328
|
+
}
|
|
329
|
+
function oe({
|
|
330
|
+
trigger: i = "Open popover",
|
|
331
|
+
children: n,
|
|
332
|
+
position: t = "bottom-start",
|
|
333
|
+
tone: r = "neutral",
|
|
334
|
+
open: a,
|
|
335
|
+
onOpenChange: s
|
|
336
|
+
}) {
|
|
337
|
+
const [c, l] = C(!1), u = E(null), h = a ?? c, b = (w) => {
|
|
338
|
+
a === void 0 && l(w), s?.(w);
|
|
339
|
+
};
|
|
340
|
+
return D(() => {
|
|
341
|
+
if (!h) return;
|
|
342
|
+
const w = (N) => {
|
|
343
|
+
u.current?.contains(N.target) || b(!1);
|
|
344
|
+
}, g = (N) => {
|
|
345
|
+
N.key === "Escape" && b(!1);
|
|
346
|
+
};
|
|
347
|
+
return document.addEventListener("pointerdown", w), document.addEventListener("keydown", g), () => {
|
|
348
|
+
document.removeEventListener("pointerdown", w), document.removeEventListener("keydown", g);
|
|
349
|
+
};
|
|
350
|
+
}, [h]), /* @__PURE__ */ d("div", { className: "ui-popover", ref: u, children: [
|
|
351
|
+
/* @__PURE__ */ e(
|
|
352
|
+
A,
|
|
353
|
+
{
|
|
354
|
+
variant: "secondary",
|
|
355
|
+
size: "sm",
|
|
356
|
+
"aria-haspopup": "dialog",
|
|
357
|
+
"aria-expanded": h,
|
|
358
|
+
onClick: () => b(!h),
|
|
359
|
+
children: i
|
|
360
|
+
}
|
|
361
|
+
),
|
|
362
|
+
h && /* @__PURE__ */ e(
|
|
363
|
+
"div",
|
|
364
|
+
{
|
|
365
|
+
className: `ui-popover__panel ui-popover--${t} ui-popover--${r}`,
|
|
366
|
+
role: "dialog",
|
|
367
|
+
children: n
|
|
368
|
+
}
|
|
369
|
+
)
|
|
370
|
+
] });
|
|
371
|
+
}
|
|
372
|
+
function ce({
|
|
373
|
+
children: i,
|
|
374
|
+
items: n,
|
|
375
|
+
trigger: t,
|
|
376
|
+
label: r = "Context menu target",
|
|
377
|
+
menuLabel: a = "Context menu",
|
|
378
|
+
className: s = ""
|
|
379
|
+
}) {
|
|
380
|
+
const c = x(), l = E(null), u = E(null), h = E(null), [b, w] = C({ x: 0, y: 0 }), [g, N] = C(!1), k = (o, m, f = l.current) => {
|
|
381
|
+
h.current = f, w({ x: o, y: m }), N(!0);
|
|
382
|
+
}, v = (o = !1) => {
|
|
383
|
+
N(!1), o && h.current?.focus();
|
|
384
|
+
};
|
|
385
|
+
O(() => {
|
|
386
|
+
if (!g || !u.current) return;
|
|
387
|
+
const o = u.current, m = o.getBoundingClientRect(), f = Math.max(8, Math.min(b.x, window.innerWidth - m.width - 8)), y = Math.max(8, Math.min(b.y, window.innerHeight - m.height - 8));
|
|
388
|
+
(f !== b.x || y !== b.y) && w({ x: f, y }), o.querySelector('[role="menuitem"]:not(:disabled)')?.focus();
|
|
389
|
+
}, [g, b.x, b.y]), D(() => {
|
|
390
|
+
if (!g) return;
|
|
391
|
+
const o = (f) => {
|
|
392
|
+
u.current?.contains(f.target) || N(!1);
|
|
393
|
+
}, m = () => N(!1);
|
|
394
|
+
return document.addEventListener("pointerdown", o), document.addEventListener("scroll", m, !0), window.addEventListener("resize", m), () => {
|
|
395
|
+
document.removeEventListener("pointerdown", o), document.removeEventListener("scroll", m, !0), window.removeEventListener("resize", m);
|
|
396
|
+
};
|
|
397
|
+
}, [g]);
|
|
398
|
+
const _ = (o) => {
|
|
399
|
+
if (!g && (o.key === "ContextMenu" || o.shiftKey && o.key === "F10")) {
|
|
400
|
+
o.preventDefault();
|
|
401
|
+
const $ = l.current.getBoundingClientRect(), I = typeof o.target?.focus == "function" ? o.target : l.current;
|
|
402
|
+
k($.left, $.bottom, I);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (!g) return;
|
|
406
|
+
if (o.key === "Escape") {
|
|
407
|
+
o.preventDefault(), v(!0);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
if (o.key === "Tab") {
|
|
411
|
+
v(!0);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const m = [
|
|
415
|
+
...u.current?.querySelectorAll('[role="menuitem"]:not(:disabled)') ?? []
|
|
416
|
+
];
|
|
417
|
+
if (!m.length) return;
|
|
418
|
+
const f = m.indexOf(document.activeElement);
|
|
419
|
+
let y;
|
|
420
|
+
if (o.key === "ArrowDown")
|
|
421
|
+
y = f < 0 ? 0 : (f + 1) % m.length;
|
|
422
|
+
else if (o.key === "ArrowUp")
|
|
423
|
+
y = f < 0 ? m.length - 1 : (f - 1 + m.length) % m.length;
|
|
424
|
+
else if (o.key === "Home")
|
|
425
|
+
y = 0;
|
|
426
|
+
else if (o.key === "End")
|
|
427
|
+
y = m.length - 1;
|
|
428
|
+
else
|
|
429
|
+
return;
|
|
430
|
+
o.preventDefault(), m[y].focus();
|
|
431
|
+
};
|
|
432
|
+
return /* @__PURE__ */ d(
|
|
433
|
+
"div",
|
|
434
|
+
{
|
|
435
|
+
className: p("ui-context-menu", s),
|
|
436
|
+
ref: l,
|
|
437
|
+
role: "group",
|
|
438
|
+
"aria-label": r,
|
|
439
|
+
"aria-haspopup": "menu",
|
|
440
|
+
"aria-expanded": g,
|
|
441
|
+
"aria-controls": g ? c : void 0,
|
|
442
|
+
tabIndex: 0,
|
|
443
|
+
onContextMenu: (o) => {
|
|
444
|
+
o.preventDefault(), k(o.clientX, o.clientY, l.current);
|
|
445
|
+
},
|
|
446
|
+
onKeyDown: _,
|
|
447
|
+
children: [
|
|
448
|
+
i,
|
|
449
|
+
t && /* @__PURE__ */ e(
|
|
450
|
+
"button",
|
|
451
|
+
{
|
|
452
|
+
className: "ui-context-menu__trigger",
|
|
453
|
+
type: "button",
|
|
454
|
+
"aria-haspopup": "menu",
|
|
455
|
+
"aria-expanded": g,
|
|
456
|
+
"aria-controls": g ? c : void 0,
|
|
457
|
+
onClick: (o) => {
|
|
458
|
+
const m = o.currentTarget.getBoundingClientRect();
|
|
459
|
+
k(m.left, m.bottom, o.currentTarget);
|
|
460
|
+
},
|
|
461
|
+
children: t
|
|
462
|
+
}
|
|
463
|
+
),
|
|
464
|
+
g && /* @__PURE__ */ e(
|
|
465
|
+
"div",
|
|
466
|
+
{
|
|
467
|
+
className: "ui-context-menu__panel",
|
|
468
|
+
id: c,
|
|
469
|
+
role: "menu",
|
|
470
|
+
"aria-label": a,
|
|
471
|
+
ref: u,
|
|
472
|
+
style: { left: b.x, top: b.y },
|
|
473
|
+
children: n.map(
|
|
474
|
+
(o, m) => o.type === "separator" ? /* @__PURE__ */ e(
|
|
475
|
+
"div",
|
|
476
|
+
{
|
|
477
|
+
className: "ui-context-menu__separator",
|
|
478
|
+
role: "separator"
|
|
479
|
+
},
|
|
480
|
+
`separator-${m}`
|
|
481
|
+
) : /* @__PURE__ */ d(
|
|
482
|
+
"button",
|
|
483
|
+
{
|
|
484
|
+
className: p("ui-context-menu__item", o.destructive && "is-destructive"),
|
|
485
|
+
type: "button",
|
|
486
|
+
role: "menuitem",
|
|
487
|
+
tabIndex: -1,
|
|
488
|
+
disabled: o.disabled,
|
|
489
|
+
onClick: (f) => {
|
|
490
|
+
v(!0), o.onSelect?.(f);
|
|
491
|
+
},
|
|
492
|
+
children: [
|
|
493
|
+
/* @__PURE__ */ e("span", { children: o.label }),
|
|
494
|
+
o.shortcut && /* @__PURE__ */ e("kbd", { children: o.shortcut })
|
|
495
|
+
]
|
|
496
|
+
},
|
|
497
|
+
`${o.label}-${m}`
|
|
498
|
+
)
|
|
499
|
+
)
|
|
500
|
+
}
|
|
501
|
+
)
|
|
502
|
+
]
|
|
503
|
+
}
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
function de({
|
|
507
|
+
open: i,
|
|
508
|
+
title: n,
|
|
509
|
+
children: t,
|
|
510
|
+
onClose: r,
|
|
511
|
+
position: a = "center",
|
|
512
|
+
size: s = "md",
|
|
513
|
+
footer: c
|
|
514
|
+
}) {
|
|
515
|
+
const l = x(), u = E(null);
|
|
516
|
+
return F(i, r, u), i ? /* @__PURE__ */ e(
|
|
517
|
+
"div",
|
|
518
|
+
{
|
|
519
|
+
className: `ui-modal-backdrop ui-modal-backdrop--${a}`,
|
|
520
|
+
role: "presentation",
|
|
521
|
+
onMouseDown: (h) => {
|
|
522
|
+
h.target === h.currentTarget && r();
|
|
523
|
+
},
|
|
524
|
+
children: /* @__PURE__ */ d(
|
|
525
|
+
"section",
|
|
526
|
+
{
|
|
527
|
+
className: `ui-modal ui-modal--${s}`,
|
|
528
|
+
role: "dialog",
|
|
529
|
+
"aria-modal": "true",
|
|
530
|
+
"aria-labelledby": l,
|
|
531
|
+
tabIndex: -1,
|
|
532
|
+
ref: u,
|
|
533
|
+
children: [
|
|
534
|
+
/* @__PURE__ */ d("div", { className: "ui-modal__header", children: [
|
|
535
|
+
/* @__PURE__ */ d("div", { children: [
|
|
536
|
+
/* @__PURE__ */ e("span", { className: "ui-modal__eyebrow", children: "Modal" }),
|
|
537
|
+
/* @__PURE__ */ e("h2", { id: l, children: n })
|
|
538
|
+
] }),
|
|
539
|
+
/* @__PURE__ */ e(S, { label: "Close modal", onClick: r, children: "×" })
|
|
540
|
+
] }),
|
|
541
|
+
/* @__PURE__ */ e("div", { className: "ui-modal__body", children: t }),
|
|
542
|
+
c && /* @__PURE__ */ e("div", { className: "ui-modal__footer", children: c })
|
|
543
|
+
]
|
|
544
|
+
}
|
|
545
|
+
)
|
|
546
|
+
}
|
|
547
|
+
) : null;
|
|
548
|
+
}
|
|
549
|
+
function ue({
|
|
550
|
+
open: i,
|
|
551
|
+
title: n,
|
|
552
|
+
children: t,
|
|
553
|
+
onClose: r,
|
|
554
|
+
position: a = "right",
|
|
555
|
+
size: s = "md",
|
|
556
|
+
footer: c
|
|
557
|
+
}) {
|
|
558
|
+
const l = x(), u = E(null);
|
|
559
|
+
return F(i, r, u), i ? /* @__PURE__ */ e(
|
|
560
|
+
"div",
|
|
561
|
+
{
|
|
562
|
+
className: "ui-drawer-backdrop",
|
|
563
|
+
role: "presentation",
|
|
564
|
+
onMouseDown: (h) => {
|
|
565
|
+
h.target === h.currentTarget && r();
|
|
566
|
+
},
|
|
567
|
+
children: /* @__PURE__ */ d(
|
|
568
|
+
"aside",
|
|
569
|
+
{
|
|
570
|
+
className: `ui-drawer ui-drawer--${a} ui-drawer--${s}`,
|
|
571
|
+
role: "dialog",
|
|
572
|
+
"aria-modal": "true",
|
|
573
|
+
"aria-labelledby": l,
|
|
574
|
+
tabIndex: -1,
|
|
575
|
+
ref: u,
|
|
576
|
+
children: [
|
|
577
|
+
/* @__PURE__ */ d("div", { className: "ui-drawer__header", children: [
|
|
578
|
+
/* @__PURE__ */ d("div", { children: [
|
|
579
|
+
/* @__PURE__ */ e("span", { children: "Drawer" }),
|
|
580
|
+
/* @__PURE__ */ e("h2", { id: l, children: n })
|
|
581
|
+
] }),
|
|
582
|
+
/* @__PURE__ */ e(S, { label: "Close drawer", onClick: r, children: "×" })
|
|
583
|
+
] }),
|
|
584
|
+
/* @__PURE__ */ e("div", { className: "ui-drawer__body", children: t }),
|
|
585
|
+
c && /* @__PURE__ */ e("div", { className: "ui-drawer__footer", children: c })
|
|
586
|
+
]
|
|
587
|
+
}
|
|
588
|
+
)
|
|
589
|
+
}
|
|
590
|
+
) : null;
|
|
591
|
+
}
|
|
592
|
+
function me({ items: i, renderItem: n, className: t = "" }) {
|
|
593
|
+
return /* @__PURE__ */ e("div", { className: p("ui-grid", t), children: i.map(n) });
|
|
594
|
+
}
|
|
595
|
+
function he({ items: i }) {
|
|
596
|
+
return /* @__PURE__ */ e("div", { className: "ui-accordion", children: i.map((n, t) => /* @__PURE__ */ d("details", { open: t === 0, children: [
|
|
597
|
+
/* @__PURE__ */ d("summary", { children: [
|
|
598
|
+
n.title,
|
|
599
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", children: "+" })
|
|
600
|
+
] }),
|
|
601
|
+
/* @__PURE__ */ e("p", { children: n.body })
|
|
602
|
+
] }, n.title)) });
|
|
603
|
+
}
|
|
604
|
+
function pe({ items: i, value: n, onChange: t, label: r = "Tabs" }) {
|
|
605
|
+
return /* @__PURE__ */ e("div", { className: "ui-tabs", role: "tablist", "aria-label": r, children: i.map((a) => /* @__PURE__ */ e(
|
|
606
|
+
"button",
|
|
607
|
+
{
|
|
608
|
+
type: "button",
|
|
609
|
+
role: "tab",
|
|
610
|
+
"aria-selected": n === a.value,
|
|
611
|
+
className: n === a.value ? "is-active" : "",
|
|
612
|
+
onClick: () => t(a.value),
|
|
613
|
+
children: a.label
|
|
614
|
+
},
|
|
615
|
+
a.value
|
|
616
|
+
)) });
|
|
617
|
+
}
|
|
618
|
+
function fe({ count: i, page: n, onPageChange: t, className: r = "" }) {
|
|
619
|
+
const a = Math.max(1, Number(i) || 1), s = Math.min(a, Math.max(1, Number(n) || 1)), c = (l) => {
|
|
620
|
+
const u = Math.min(a, Math.max(1, l));
|
|
621
|
+
u !== s && t(u);
|
|
622
|
+
};
|
|
623
|
+
return /* @__PURE__ */ d("nav", { className: p("ui-pagination", r), "aria-label": "Pagination", children: [
|
|
624
|
+
/* @__PURE__ */ d(
|
|
625
|
+
"button",
|
|
626
|
+
{
|
|
627
|
+
type: "button",
|
|
628
|
+
className: "ui-pagination__previous",
|
|
629
|
+
disabled: s === 1,
|
|
630
|
+
onClick: () => c(s - 1),
|
|
631
|
+
"aria-label": "Go to previous page",
|
|
632
|
+
children: [
|
|
633
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", children: "←" }),
|
|
634
|
+
"Previous"
|
|
635
|
+
]
|
|
636
|
+
}
|
|
637
|
+
),
|
|
638
|
+
/* @__PURE__ */ e("div", { className: "ui-pagination__pages", children: Array.from({ length: a }, (l, u) => u + 1).map((l) => /* @__PURE__ */ e(
|
|
639
|
+
"button",
|
|
640
|
+
{
|
|
641
|
+
type: "button",
|
|
642
|
+
className: l === s ? "is-active" : "",
|
|
643
|
+
"aria-current": l === s ? "page" : void 0,
|
|
644
|
+
"aria-label": `Go to page ${l}`,
|
|
645
|
+
onClick: () => c(l),
|
|
646
|
+
children: l
|
|
647
|
+
},
|
|
648
|
+
l
|
|
649
|
+
)) }),
|
|
650
|
+
/* @__PURE__ */ d(
|
|
651
|
+
"button",
|
|
652
|
+
{
|
|
653
|
+
type: "button",
|
|
654
|
+
className: "ui-pagination__next",
|
|
655
|
+
disabled: s === a,
|
|
656
|
+
onClick: () => c(s + 1),
|
|
657
|
+
"aria-label": "Go to next page",
|
|
658
|
+
children: [
|
|
659
|
+
"Next",
|
|
660
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", children: "→" })
|
|
661
|
+
]
|
|
662
|
+
}
|
|
663
|
+
)
|
|
664
|
+
] });
|
|
665
|
+
}
|
|
666
|
+
function be({ items: i }) {
|
|
667
|
+
return /* @__PURE__ */ e("nav", { className: "ui-breadcrumbs", "aria-label": "Breadcrumb", children: /* @__PURE__ */ e("ol", { children: i.map((n, t) => /* @__PURE__ */ d("li", { children: [
|
|
668
|
+
t > 0 && /* @__PURE__ */ e("span", { "aria-hidden": "true", children: "/" }),
|
|
669
|
+
/* @__PURE__ */ e("span", { "aria-current": t === i.length - 1 ? "page" : void 0, children: n })
|
|
670
|
+
] }, n)) }) });
|
|
671
|
+
}
|
|
672
|
+
function ge({ columns: i, rows: n, rowKey: t = "id", emptyMessage: r = "No matching records." }) {
|
|
673
|
+
return /* @__PURE__ */ e("div", { className: "ui-table-wrap", children: /* @__PURE__ */ d("table", { className: "ui-table", children: [
|
|
674
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: i.map((a) => /* @__PURE__ */ e("th", { scope: "col", children: a.label }, a.key)) }) }),
|
|
675
|
+
/* @__PURE__ */ e("tbody", { children: n.length ? n.map((a) => /* @__PURE__ */ e("tr", { children: i.map((s) => /* @__PURE__ */ e("td", { children: s.render ? s.render(a) : a[s.key] }, s.key)) }, a[t])) : /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: i.length, className: "ui-table__empty", children: r }) }) })
|
|
676
|
+
] }) });
|
|
677
|
+
}
|
|
678
|
+
function ve({ open: i, title: n, onClose: t, children: r }) {
|
|
679
|
+
return i ? /* @__PURE__ */ e(
|
|
680
|
+
"div",
|
|
681
|
+
{
|
|
682
|
+
className: "ui-dialog-backdrop",
|
|
683
|
+
role: "presentation",
|
|
684
|
+
onMouseDown: (a) => {
|
|
685
|
+
a.target === a.currentTarget && t();
|
|
686
|
+
},
|
|
687
|
+
children: /* @__PURE__ */ d("section", { className: "ui-dialog", role: "dialog", "aria-modal": "true", "aria-labelledby": "dialog-title", children: [
|
|
688
|
+
/* @__PURE__ */ d("div", { className: "ui-dialog__heading", children: [
|
|
689
|
+
/* @__PURE__ */ e("h2", { id: "dialog-title", children: n }),
|
|
690
|
+
/* @__PURE__ */ e(S, { label: "Close dialog", onClick: t, children: "×" })
|
|
691
|
+
] }),
|
|
692
|
+
r
|
|
693
|
+
] })
|
|
694
|
+
}
|
|
695
|
+
) : null;
|
|
696
|
+
}
|
|
697
|
+
export {
|
|
698
|
+
he as Accordion,
|
|
699
|
+
le as Alert,
|
|
700
|
+
X as AutoSelect,
|
|
701
|
+
Z as Avatar,
|
|
702
|
+
Q as Badge,
|
|
703
|
+
be as Breadcrumbs,
|
|
704
|
+
A as Button,
|
|
705
|
+
J as ButtonGroup,
|
|
706
|
+
ae as Card,
|
|
707
|
+
R as Checkbox,
|
|
708
|
+
ce as ContextMenu,
|
|
709
|
+
ge as DataTable,
|
|
710
|
+
q as DatePicker,
|
|
711
|
+
ve as Dialog,
|
|
712
|
+
re as Divider,
|
|
713
|
+
ue as Drawer,
|
|
714
|
+
H as FileUpload,
|
|
715
|
+
me as Grid,
|
|
716
|
+
S as IconButton,
|
|
717
|
+
P as Input,
|
|
718
|
+
de as Modal,
|
|
719
|
+
Y as MultiSelect,
|
|
720
|
+
fe as Pagination,
|
|
721
|
+
oe as Popover,
|
|
722
|
+
ie as Progress,
|
|
723
|
+
V as Radio,
|
|
724
|
+
U as Select,
|
|
725
|
+
te as Skeleton,
|
|
726
|
+
ne as Slider,
|
|
727
|
+
W as Switch,
|
|
728
|
+
pe as Tabs,
|
|
729
|
+
G as Textarea,
|
|
730
|
+
se as Toast,
|
|
731
|
+
ee as Tooltip
|
|
732
|
+
};
|
|
733
|
+
//# sourceMappingURL=index.js.map
|