tri-ui-library 1.0.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.
@@ -0,0 +1,868 @@
1
+ import { jsx as e, jsxs as b, Fragment as x } from "react/jsx-runtime";
2
+ import p, { useState as y, useEffect as w, useRef as B, useId as D } from "react";
3
+ function A({ items: n = [], multiple: a = !1, disabled: i = !1, variant: t = "default", className: s = "" }) {
4
+ const [l, o] = p.useState(a ? [] : null), u = (d) => a ? Array.isArray(l) && l.includes(d) : l === d, r = (d) => {
5
+ if (i) return;
6
+ const h = n[d];
7
+ h != null && h.disabled || o(
8
+ a ? (m) => m.includes(d) ? m.filter((f) => f !== d) : [...m, d] : (m) => m === d ? null : d
9
+ );
10
+ }, c = [
11
+ "ui-accordion",
12
+ `ui-accordion--${t}`,
13
+ i && "ui-accordion--disabled",
14
+ s
15
+ ].filter(Boolean).join(" ");
16
+ return /* @__PURE__ */ e("div", { className: c, role: "region", "aria-label": "Accordion", children: n.map((d, h) => {
17
+ const m = i || d.disabled;
18
+ return /* @__PURE__ */ b("div", { className: "ui-accordion-item", children: [
19
+ /* @__PURE__ */ b(
20
+ "button",
21
+ {
22
+ type: "button",
23
+ className: "ui-accordion-trigger",
24
+ onClick: () => r(h),
25
+ "aria-expanded": u(h),
26
+ "aria-controls": `ui-accordion-panel-${h}`,
27
+ "aria-disabled": m,
28
+ id: `ui-accordion-trigger-${h}`,
29
+ disabled: m,
30
+ children: [
31
+ /* @__PURE__ */ e("span", { className: "ui-accordion-trigger-text", children: d.title }),
32
+ /* @__PURE__ */ e("span", { className: "ui-accordion-trigger-icon", "aria-hidden": "true" })
33
+ ]
34
+ }
35
+ ),
36
+ /* @__PURE__ */ e(
37
+ "div",
38
+ {
39
+ id: `ui-accordion-panel-${h}`,
40
+ role: "region",
41
+ "aria-labelledby": `ui-accordion-trigger-${h}`,
42
+ className: "ui-accordion-panel",
43
+ hidden: !u(h),
44
+ children: d.content
45
+ }
46
+ )
47
+ ] }, h);
48
+ }) });
49
+ }
50
+ function F({
51
+ type: n = "info",
52
+ children: a,
53
+ title: i,
54
+ className: t = "",
55
+ dismissible: s = !1,
56
+ onDismiss: l,
57
+ ...o
58
+ }) {
59
+ const [u, r] = p.useState(!1), c = () => {
60
+ r(!0), l == null || l();
61
+ }, d = [
62
+ "ui-alert",
63
+ `ui-alert--${n}`,
64
+ t
65
+ ].filter(Boolean).join(" ");
66
+ return u ? null : /* @__PURE__ */ b(
67
+ "div",
68
+ {
69
+ className: d,
70
+ role: "alert",
71
+ "aria-live": "polite",
72
+ ...o,
73
+ children: [
74
+ /* @__PURE__ */ b("div", { className: "ui-alert-content", children: [
75
+ i && /* @__PURE__ */ e("div", { className: "ui-alert-title", children: i }),
76
+ /* @__PURE__ */ e("div", { className: "ui-alert-message", children: a })
77
+ ] }),
78
+ s && /* @__PURE__ */ e(
79
+ "button",
80
+ {
81
+ type: "button",
82
+ className: "ui-alert-dismiss",
83
+ onClick: c,
84
+ "aria-label": "Dismiss alert",
85
+ children: "×"
86
+ }
87
+ )
88
+ ]
89
+ }
90
+ );
91
+ }
92
+ function R({
93
+ open: n,
94
+ onClose: a,
95
+ title: i,
96
+ description: t,
97
+ confirmLabel: s = "OK",
98
+ cancelLabel: l = "Cancel",
99
+ onConfirm: o,
100
+ showCancel: u = !0
101
+ }) {
102
+ return n ? /* @__PURE__ */ e("div", { className: "ui-alertdialog-overlay", role: "alertdialog", "aria-modal": "true", "aria-labelledby": "ui-alertdialog-title", children: /* @__PURE__ */ b("div", { className: "ui-alertdialog", children: [
103
+ /* @__PURE__ */ e("h2", { id: "ui-alertdialog-title", className: "ui-alertdialog-title", children: i }),
104
+ t && /* @__PURE__ */ e("p", { className: "ui-alertdialog-desc", children: t }),
105
+ /* @__PURE__ */ b("div", { className: "ui-alertdialog-actions", children: [
106
+ u && /* @__PURE__ */ e("button", { type: "button", className: "ui-alertdialog-btn ui-alertdialog-btn--secondary", onClick: a, children: l }),
107
+ /* @__PURE__ */ e("button", { type: "button", className: "ui-alertdialog-btn ui-alertdialog-btn--primary", onClick: () => {
108
+ o == null || o(), a == null || a();
109
+ }, children: s })
110
+ ] })
111
+ ] }) }) : null;
112
+ }
113
+ function I({ ratio: n = 16 / 9, children: a, className: i = "" }) {
114
+ const t = ["ui-aspectratio", i].filter(Boolean).join(" ");
115
+ return /* @__PURE__ */ e("div", { className: t, style: { aspectRatio: n }, children: a });
116
+ }
117
+ function T({ src: n, alt: a = "", fallback: i, size: t = "md", className: s = "" }) {
118
+ const [l, o] = p.useState(!1), u = ["ui-avatar", `ui-avatar--${t}`, s].filter(Boolean).join(" ");
119
+ return /* @__PURE__ */ b("div", { className: u, role: "img", "aria-label": a || void 0, children: [
120
+ n && /* @__PURE__ */ e(
121
+ "img",
122
+ {
123
+ src: n,
124
+ alt: a,
125
+ className: "ui-avatar-img",
126
+ onLoad: () => o(!0),
127
+ onError: () => o(!1)
128
+ }
129
+ ),
130
+ (!n || !l) && /* @__PURE__ */ e("span", { className: "ui-avatar-fallback", children: i || (a ? a[0] : "?") })
131
+ ] });
132
+ }
133
+ function K({ children: n, variant: a = "default", className: i = "" }) {
134
+ const t = ["ui-badge", `ui-badge--${a}`, i].filter(Boolean).join(" ");
135
+ return /* @__PURE__ */ e("span", { className: t, children: n });
136
+ }
137
+ function M({ items: n = [], separator: a = "/", className: i = "" }) {
138
+ const t = ["ui-breadcrumb", i].filter(Boolean).join(" ");
139
+ return /* @__PURE__ */ e("nav", { className: t, "aria-label": "Breadcrumb", children: /* @__PURE__ */ e("ol", { className: "ui-breadcrumb-list", children: n.map((s, l) => /* @__PURE__ */ b("li", { className: "ui-breadcrumb-item", children: [
140
+ l > 0 && /* @__PURE__ */ e("span", { className: "ui-breadcrumb-sep", "aria-hidden": "true", children: a }),
141
+ s.href ? /* @__PURE__ */ e("a", { href: s.href, className: "ui-breadcrumb-link", children: s.label }) : /* @__PURE__ */ e("span", { className: "ui-breadcrumb-current", "aria-current": "page", children: s.label })
142
+ ] }, l)) }) });
143
+ }
144
+ function P({
145
+ variant: n = "primary",
146
+ size: a = "md",
147
+ disabled: i = !1,
148
+ onClick: t,
149
+ children: s,
150
+ leftIcon: l,
151
+ rightIcon: o,
152
+ type: u = "button",
153
+ className: r = "",
154
+ ariaLabel: c,
155
+ ...d
156
+ }) {
157
+ const h = s != null && s !== "", m = [
158
+ "ui-btn",
159
+ `ui-btn--${n}`,
160
+ `ui-btn--${a}`,
161
+ i && "ui-btn--disabled",
162
+ l && "ui-btn--has-left-icon",
163
+ o && "ui-btn--has-right-icon",
164
+ (l || o) && !h && "ui-btn--icon-only",
165
+ r
166
+ ].filter(Boolean).join(" ");
167
+ return /* @__PURE__ */ b(
168
+ "button",
169
+ {
170
+ type: u,
171
+ className: m,
172
+ disabled: i,
173
+ onClick: t,
174
+ "aria-label": c,
175
+ "aria-disabled": i,
176
+ ...d,
177
+ children: [
178
+ l && /* @__PURE__ */ e("span", { className: "ui-btn-icon ui-btn-icon--left", "aria-hidden": "true", children: l }),
179
+ h && /* @__PURE__ */ e("span", { className: "ui-btn-label", children: s }),
180
+ o && /* @__PURE__ */ e("span", { className: "ui-btn-icon ui-btn-icon--right", "aria-hidden": "true", children: o })
181
+ ]
182
+ }
183
+ );
184
+ }
185
+ function O({ children: n, className: a = "" }) {
186
+ const i = ["ui-buttongroup", a].filter(Boolean).join(" ");
187
+ return /* @__PURE__ */ e("div", { className: i, role: "group", children: n });
188
+ }
189
+ function j({ value: n, onChange: a, className: i = "" }) {
190
+ const t = ["ui-calendar", i].filter(Boolean).join(" "), s = n ? new Date(n) : /* @__PURE__ */ new Date(), [l, o] = p.useState({ year: s.getFullYear(), month: s.getMonth() }), u = new Date(l.year, l.month + 1, 0).getDate(), r = new Date(l.year, l.month, 1).getDay(), c = Array.from({ length: u }, (m, f) => f + 1), h = [...Array.from({ length: r }, () => null), ...c];
191
+ return /* @__PURE__ */ b("div", { className: t, role: "application", "aria-label": "Calendar", children: [
192
+ /* @__PURE__ */ b("div", { className: "ui-calendar-header", children: [
193
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => o((m) => ({ ...m, month: m.month - 1 })), children: "←" }),
194
+ /* @__PURE__ */ e("span", { children: new Date(l.year, l.month).toLocaleString("default", { month: "long", year: "numeric" }) }),
195
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => o((m) => ({ ...m, month: m.month + 1 })), children: "→" })
196
+ ] }),
197
+ /* @__PURE__ */ b("div", { className: "ui-calendar-grid", children: [
198
+ ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((m) => /* @__PURE__ */ e("div", { className: "ui-calendar-weekday", children: m }, m)),
199
+ h.map((m, f) => m ? /* @__PURE__ */ e(
200
+ "button",
201
+ {
202
+ type: "button",
203
+ className: "ui-calendar-day",
204
+ onClick: () => a == null ? void 0 : a(new Date(l.year, l.month, m)),
205
+ children: m
206
+ },
207
+ f
208
+ ) : /* @__PURE__ */ e("div", { className: "ui-calendar-day ui-calendar-day--empty" }, f))
209
+ ] })
210
+ ] });
211
+ }
212
+ function G({ children: n, title: a, footer: i, className: t = "", variant: s = "outlined", ...l }) {
213
+ const o = ["ui-card", `ui-card--${s}`, t].filter(Boolean).join(" ");
214
+ return /* @__PURE__ */ b("div", { className: o, ...l, children: [
215
+ a && /* @__PURE__ */ e("div", { className: "ui-card-header", children: /* @__PURE__ */ e("h3", { className: "ui-card-title", children: a }) }),
216
+ /* @__PURE__ */ e("div", { className: "ui-card-body", children: n }),
217
+ i && /* @__PURE__ */ e("div", { className: "ui-card-footer", children: i })
218
+ ] });
219
+ }
220
+ function H({ children: n, className: a = "" }) {
221
+ const [i, t] = p.useState(0), s = p.Children.toArray(n), l = s.length;
222
+ return /* @__PURE__ */ b("div", { className: `ui-carousel ${a}`, role: "region", "aria-label": "Carousel", children: [
223
+ /* @__PURE__ */ e("div", { className: "ui-carousel-track", style: { transform: `translateX(-${i * 100}%)` }, children: s.map((o, u) => /* @__PURE__ */ e("div", { className: "ui-carousel-slide", children: o }, u)) }),
224
+ l > 1 && /* @__PURE__ */ e("div", { className: "ui-carousel-dots", children: s.map((o, u) => /* @__PURE__ */ e(
225
+ "button",
226
+ {
227
+ type: "button",
228
+ "aria-label": `Go to slide ${u + 1}`,
229
+ className: `ui-carousel-dot ${u === i ? "ui-carousel-dot--active" : ""}`,
230
+ onClick: () => t(u)
231
+ },
232
+ u
233
+ )) })
234
+ ] });
235
+ }
236
+ function X({ data: n = [], type: a = "bar", className: i = "" }) {
237
+ const t = ["ui-chart", `ui-chart--${a}`, i].filter(Boolean).join(" "), s = Math.max(...n.map((l) => l.value), 1);
238
+ return /* @__PURE__ */ e("div", { className: t, role: "img", "aria-label": "Chart", children: /* @__PURE__ */ e("div", { className: "ui-chart-bars", children: n.map((l, o) => /* @__PURE__ */ b("div", { className: "ui-chart-bar-wrap", children: [
239
+ /* @__PURE__ */ e(
240
+ "div",
241
+ {
242
+ className: "ui-chart-bar",
243
+ style: { height: `${l.value / s * 100}%` },
244
+ title: l.label
245
+ }
246
+ ),
247
+ /* @__PURE__ */ e("span", { className: "ui-chart-label", children: l.label })
248
+ ] }, o)) }) });
249
+ }
250
+ function Y({
251
+ checked: n = !1,
252
+ onChange: a,
253
+ disabled: i = !1,
254
+ label: t,
255
+ id: s,
256
+ className: l = "",
257
+ indeterminate: o,
258
+ ...u
259
+ }) {
260
+ const r = s || `ui-checkbox-${p.useId().replace(/:/g, "")}`, c = p.useRef(null);
261
+ p.useEffect(() => {
262
+ c.current && (c.current.indeterminate = !!o);
263
+ }, [o]);
264
+ const d = [
265
+ "ui-checkbox-wrapper",
266
+ i && "ui-checkbox-wrapper--disabled",
267
+ l
268
+ ].filter(Boolean).join(" ");
269
+ return /* @__PURE__ */ e("div", { className: d, children: /* @__PURE__ */ b("label", { className: "ui-checkbox-label", htmlFor: r, children: [
270
+ /* @__PURE__ */ e(
271
+ "input",
272
+ {
273
+ ref: c,
274
+ id: r,
275
+ type: "checkbox",
276
+ className: "ui-checkbox",
277
+ checked: n,
278
+ onChange: a,
279
+ disabled: i,
280
+ "aria-checked": o ? "mixed" : n,
281
+ "aria-disabled": i,
282
+ ...u
283
+ }
284
+ ),
285
+ /* @__PURE__ */ e("span", { className: "ui-checkbox-box", "aria-hidden": "true" }),
286
+ t && /* @__PURE__ */ e("span", { className: "ui-checkbox-text", children: t })
287
+ ] }) });
288
+ }
289
+ function _({ open: n, defaultOpen: a = !1, onOpenChange: i, trigger: t, children: s, className: l = "" }) {
290
+ const [o, u] = p.useState(a), r = n !== void 0, c = r ? n : o, d = (m) => {
291
+ r || u(m), i == null || i(m);
292
+ }, h = ["ui-collapsible", l].filter(Boolean).join(" ");
293
+ return /* @__PURE__ */ b("div", { className: h, children: [
294
+ /* @__PURE__ */ e(
295
+ "button",
296
+ {
297
+ type: "button",
298
+ className: "ui-collapsible-trigger",
299
+ onClick: () => d(!c),
300
+ "aria-expanded": c,
301
+ children: t
302
+ }
303
+ ),
304
+ /* @__PURE__ */ e("div", { className: "ui-collapsible-content", hidden: !c, children: s })
305
+ ] });
306
+ }
307
+ function q({ options: n = [], value: a, onChange: i, placeholder: t = "Select...", className: s = "" }) {
308
+ const [l, o] = y(!1), [u, r] = y(""), c = n.filter((m) => m.label.toLowerCase().includes(u.toLowerCase())), d = n.find((m) => m.value === a), h = ["ui-combobox", s].filter(Boolean).join(" ");
309
+ return /* @__PURE__ */ b("div", { className: h, children: [
310
+ /* @__PURE__ */ e("div", { className: "ui-combobox-input-wrap", children: /* @__PURE__ */ e(
311
+ "input",
312
+ {
313
+ type: "text",
314
+ className: "ui-combobox-input",
315
+ value: l ? u : (d == null ? void 0 : d.label) ?? "",
316
+ onChange: (m) => {
317
+ r(m.target.value), o(!0);
318
+ },
319
+ onFocus: () => o(!0),
320
+ onBlur: () => setTimeout(() => o(!1), 150),
321
+ placeholder: t,
322
+ role: "combobox",
323
+ "aria-expanded": l,
324
+ "aria-autocomplete": "list"
325
+ }
326
+ ) }),
327
+ l && /* @__PURE__ */ e("ul", { className: "ui-combobox-list", role: "listbox", children: c.map((m) => /* @__PURE__ */ e(
328
+ "li",
329
+ {
330
+ role: "option",
331
+ "aria-selected": a === m.value,
332
+ className: "ui-combobox-option",
333
+ onMouseDown: () => {
334
+ i == null || i(m.value), o(!1), r("");
335
+ },
336
+ children: m.label
337
+ },
338
+ m.value
339
+ )) })
340
+ ] });
341
+ }
342
+ function U({ children: n, placeholder: a = "Search...", className: i = "" }) {
343
+ const t = ["ui-command", i].filter(Boolean).join(" ");
344
+ return /* @__PURE__ */ b("div", { className: t, role: "command", children: [
345
+ /* @__PURE__ */ e("input", { type: "text", className: "ui-command-input", placeholder: a }),
346
+ /* @__PURE__ */ e("div", { className: "ui-command-list", children: n })
347
+ ] });
348
+ }
349
+ function V({ children: n, items: a = [], onOpenChange: i }) {
350
+ const [t, s] = p.useState(!1), [l, o] = p.useState({ x: 0, y: 0 }), u = p.useRef(null);
351
+ return p.useEffect(() => {
352
+ const r = (d) => {
353
+ d.button === 2 && (d.preventDefault(), o({ x: d.clientX, y: d.clientY }), s(!0), i == null || i(!0));
354
+ }, c = u.current;
355
+ return c == null || c.addEventListener("contextmenu", r), () => c == null ? void 0 : c.removeEventListener("contextmenu", r);
356
+ }, [i]), p.useEffect(() => {
357
+ if (!t) return;
358
+ const r = () => {
359
+ s(!1), i == null || i(!1);
360
+ };
361
+ return document.addEventListener("click", r), () => document.removeEventListener("click", r);
362
+ }, [t, i]), /* @__PURE__ */ b("div", { ref: u, className: "ui-contextmenu-wrapper", children: [
363
+ n,
364
+ t && /* @__PURE__ */ e(
365
+ "ul",
366
+ {
367
+ className: "ui-contextmenu",
368
+ style: { left: l.x, top: l.y },
369
+ role: "menu",
370
+ children: a.map((r, c) => /* @__PURE__ */ e("li", { role: "none", children: /* @__PURE__ */ e("button", { type: "button", className: "ui-contextmenu-item", role: "menuitem", onClick: r.onClick, children: r.label }) }, c))
371
+ }
372
+ )
373
+ ] });
374
+ }
375
+ function W({
376
+ navbar: n,
377
+ sidebar: a,
378
+ children: i,
379
+ sidebarCollapsed: t = !1,
380
+ mainWidth: s = "fluid",
381
+ fullHeight: l = !0,
382
+ className: o = ""
383
+ }) {
384
+ const u = [
385
+ "ui-dashboard",
386
+ l && "ui-dashboard--full-height",
387
+ t && "ui-dashboard--sidebar-collapsed",
388
+ o
389
+ ].filter(Boolean).join(" "), r = [
390
+ "ui-dashboard-main",
391
+ s === "contained" && "ui-dashboard-main--contained"
392
+ ].filter(Boolean).join(" ");
393
+ return /* @__PURE__ */ b("div", { className: u, children: [
394
+ n && /* @__PURE__ */ e("div", { className: "ui-dashboard-navbar", children: n }),
395
+ /* @__PURE__ */ b("div", { className: "ui-dashboard-body", children: [
396
+ a && /* @__PURE__ */ e("div", { className: "ui-dashboard-sidebar-wrap", children: a }),
397
+ /* @__PURE__ */ e("main", { className: r, role: "main", children: /* @__PURE__ */ e("div", { className: "ui-dashboard-main-inner", children: i }) })
398
+ ] })
399
+ ] });
400
+ }
401
+ function z({
402
+ columns: n = [],
403
+ data: a = [],
404
+ className: i = "",
405
+ emptyMessage: t = "No data"
406
+ }) {
407
+ const s = ["ui-datatable", i].filter(Boolean).join(" ");
408
+ return n.length ? a.length ? /* @__PURE__ */ e("div", { className: s, role: "region", "aria-label": "Data table", children: /* @__PURE__ */ b("table", { className: "ui-datatable-table", children: [
409
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: n.map((l) => /* @__PURE__ */ e("th", { scope: "col", className: "ui-datatable-th", children: l.header }, l.key)) }) }),
410
+ /* @__PURE__ */ e("tbody", { children: a.map((l, o) => /* @__PURE__ */ e("tr", { className: "ui-datatable-tr", children: n.map((u) => /* @__PURE__ */ e("td", { className: "ui-datatable-td", children: l[u.key] ?? "" }, u.key)) }, o)) })
411
+ ] }) }) : /* @__PURE__ */ e("div", { className: s, role: "region", "aria-label": "Data table", children: /* @__PURE__ */ b("table", { className: "ui-datatable-table", children: [
412
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: n.map((l) => /* @__PURE__ */ e("th", { scope: "col", className: "ui-datatable-th", children: l.header }, l.key)) }) }),
413
+ /* @__PURE__ */ e("tbody", { children: /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: n.length, className: "ui-datatable-empty-cell", children: t }) }) })
414
+ ] }) }) : /* @__PURE__ */ e("div", { className: s, role: "region", "aria-label": "Data table", children: /* @__PURE__ */ e("p", { className: "ui-datatable-empty", children: t }) });
415
+ }
416
+ function $({
417
+ label: n,
418
+ error: a,
419
+ type: i = "text",
420
+ placeholder: t,
421
+ disabled: s = !1,
422
+ id: l,
423
+ className: o = "",
424
+ ...u
425
+ }) {
426
+ const r = l || `ui-input-${p.useId().replace(/:/g, "")}`, c = a ? `${r}-error` : void 0, d = [
427
+ "ui-input",
428
+ a && "ui-input--error",
429
+ s && "ui-input--disabled",
430
+ o
431
+ ].filter(Boolean).join(" ");
432
+ return /* @__PURE__ */ b("div", { className: "ui-input-wrapper", children: [
433
+ n && /* @__PURE__ */ e("label", { htmlFor: r, className: "ui-input-label", children: n }),
434
+ /* @__PURE__ */ e(
435
+ "input",
436
+ {
437
+ id: r,
438
+ type: i,
439
+ className: d,
440
+ placeholder: t,
441
+ disabled: s,
442
+ "aria-invalid": !!a,
443
+ "aria-describedby": c,
444
+ ...u
445
+ }
446
+ ),
447
+ a && /* @__PURE__ */ e("span", { id: c, className: "ui-input-error", role: "alert", children: a })
448
+ ] });
449
+ }
450
+ function J({ value: n, onChange: a, placeholder: i = "Select date", className: t = "" }) {
451
+ const [s, l] = p.useState(!1), o = n ? new Date(n).toLocaleDateString() : "", u = ["ui-datepicker", t].filter(Boolean).join(" ");
452
+ return /* @__PURE__ */ b("div", { className: u, children: [
453
+ /* @__PURE__ */ e(
454
+ $,
455
+ {
456
+ readOnly: !0,
457
+ value: o,
458
+ placeholder: i,
459
+ onFocus: () => l(!0),
460
+ onClick: () => l((r) => !r)
461
+ }
462
+ ),
463
+ s && /* @__PURE__ */ b(x, { children: [
464
+ /* @__PURE__ */ e("div", { className: "ui-datepicker-overlay", onClick: () => l(!1), "aria-hidden": "true" }),
465
+ /* @__PURE__ */ e("div", { className: "ui-datepicker-dropdown", children: /* @__PURE__ */ e(j, { value: n, onChange: (r) => {
466
+ a == null || a(r), l(!1);
467
+ } }) })
468
+ ] })
469
+ ] });
470
+ }
471
+ function Q({ open: n, onClose: a, title: i, children: t, footer: s, className: l = "" }) {
472
+ const o = p.useRef(null);
473
+ w(() => {
474
+ if (!n) return;
475
+ const r = (c) => {
476
+ c.key === "Escape" && (a == null || a());
477
+ };
478
+ return document.addEventListener("keydown", r), document.body.style.overflow = "hidden", () => {
479
+ document.removeEventListener("keydown", r), document.body.style.overflow = "";
480
+ };
481
+ }, [n, a]);
482
+ const u = (r) => {
483
+ r.target === r.currentTarget && (a == null || a());
484
+ };
485
+ return n ? /* @__PURE__ */ e(
486
+ "div",
487
+ {
488
+ className: "ui-dialog-overlay",
489
+ role: "dialog",
490
+ "aria-modal": "true",
491
+ "aria-labelledby": i ? "ui-dialog-title" : void 0,
492
+ onClick: u,
493
+ children: /* @__PURE__ */ b(
494
+ "div",
495
+ {
496
+ ref: o,
497
+ className: `ui-dialog ${l}`,
498
+ role: "document",
499
+ onClick: (r) => r.stopPropagation(),
500
+ children: [
501
+ /* @__PURE__ */ b("div", { className: "ui-dialog-content", children: [
502
+ i && /* @__PURE__ */ e("h2", { id: "ui-dialog-title", className: "ui-dialog-title", children: i }),
503
+ /* @__PURE__ */ e("div", { className: "ui-dialog-body", children: t }),
504
+ s && /* @__PURE__ */ e("div", { className: "ui-dialog-footer", children: s })
505
+ ] }),
506
+ /* @__PURE__ */ e(
507
+ "button",
508
+ {
509
+ type: "button",
510
+ className: "ui-dialog-close",
511
+ onClick: a,
512
+ "aria-label": "Close dialog",
513
+ children: "×"
514
+ }
515
+ )
516
+ ]
517
+ }
518
+ )
519
+ }
520
+ ) : null;
521
+ }
522
+ function Z({ open: n, onClose: a, title: i, children: t, side: s = "right", className: l = "" }) {
523
+ return w(() => (n && (document.body.style.overflow = "hidden"), () => {
524
+ document.body.style.overflow = "";
525
+ }), [n]), n ? /* @__PURE__ */ b(x, { children: [
526
+ /* @__PURE__ */ e("div", { className: "ui-drawer-overlay", onClick: a, "aria-hidden": "true" }),
527
+ /* @__PURE__ */ b("div", { className: `ui-drawer ui-drawer--${s} ${l}`, role: "dialog", "aria-modal": "true", "aria-labelledby": "ui-drawer-title", children: [
528
+ i && /* @__PURE__ */ e("h2", { id: "ui-drawer-title", className: "ui-drawer-title", children: i }),
529
+ /* @__PURE__ */ e("div", { className: "ui-drawer-body", children: t }),
530
+ /* @__PURE__ */ e("button", { type: "button", className: "ui-drawer-close", onClick: a, "aria-label": "Close", children: "×" })
531
+ ] })
532
+ ] }) : null;
533
+ }
534
+ function C({ trigger: n, items: a = [], align: i = "end" }) {
535
+ const [t, s] = y(!1), l = B(null);
536
+ w(() => {
537
+ if (!t) return;
538
+ const r = (c) => {
539
+ l.current && !l.current.contains(c.target) && s(!1);
540
+ };
541
+ return document.addEventListener("mousedown", r), () => document.removeEventListener("mousedown", r);
542
+ }, [t]), w(() => {
543
+ if (!t) return;
544
+ const r = (c) => {
545
+ c.key === "Escape" && s(!1);
546
+ };
547
+ return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
548
+ }, [t]);
549
+ const o = (r) => {
550
+ var c;
551
+ r.disabled || ((c = r.onClick) == null || c.call(r), s(!1));
552
+ };
553
+ return /* @__PURE__ */ b(
554
+ "div",
555
+ {
556
+ className: "ui-dropdown",
557
+ ref: l,
558
+ onKeyDown: (r) => {
559
+ var f, N, k, g, v;
560
+ if (!t) return;
561
+ const c = (f = l.current) == null ? void 0 : f.querySelectorAll(".ui-dropdown-item"), d = c ? Array.from(c) : [], h = document.activeElement, m = d.indexOf(h);
562
+ r.key === "ArrowDown" && m < d.length - 1 ? (r.preventDefault(), (N = d[m + 1]) == null || N.focus()) : r.key === "ArrowUp" && m > 0 ? (r.preventDefault(), (k = d[m - 1]) == null || k.focus()) : r.key === "Home" ? (r.preventDefault(), (g = d[0]) == null || g.focus()) : r.key === "End" && (r.preventDefault(), (v = d[d.length - 1]) == null || v.focus());
563
+ },
564
+ children: [
565
+ /* @__PURE__ */ e(
566
+ "div",
567
+ {
568
+ className: "ui-dropdown-trigger",
569
+ onClick: () => s((r) => !r),
570
+ onKeyDown: (r) => {
571
+ (r.key === "Enter" || r.key === " ") && (r.preventDefault(), s((c) => !c));
572
+ },
573
+ role: "button",
574
+ "aria-haspopup": "menu",
575
+ "aria-expanded": t,
576
+ "aria-controls": "ui-dropdown-menu",
577
+ tabIndex: 0,
578
+ children: n
579
+ }
580
+ ),
581
+ t && /* @__PURE__ */ e(
582
+ "ul",
583
+ {
584
+ id: "ui-dropdown-menu",
585
+ className: `ui-dropdown-menu ui-dropdown-menu--${i}`,
586
+ role: "menu",
587
+ children: a.map((r, c) => /* @__PURE__ */ e("li", { role: "none", children: /* @__PURE__ */ e(
588
+ "button",
589
+ {
590
+ type: "button",
591
+ className: "ui-dropdown-item",
592
+ role: "menuitem",
593
+ disabled: r.disabled,
594
+ onClick: () => o(r),
595
+ tabIndex: 0,
596
+ children: r.label
597
+ }
598
+ ) }, c))
599
+ }
600
+ )
601
+ ]
602
+ }
603
+ );
604
+ }
605
+ function ee({ title: n = "No data", description: a, icon: i, children: t, className: s = "" }) {
606
+ const l = ["ui-empty", s].filter(Boolean).join(" ");
607
+ return /* @__PURE__ */ b("div", { className: l, role: "status", children: [
608
+ i && /* @__PURE__ */ e("div", { className: "ui-empty-icon", children: i }),
609
+ /* @__PURE__ */ e("h3", { className: "ui-empty-title", children: n }),
610
+ a && /* @__PURE__ */ e("p", { className: "ui-empty-desc", children: a }),
611
+ t && /* @__PURE__ */ e("div", { className: "ui-empty-actions", children: t })
612
+ ] });
613
+ }
614
+ function ae({ label: n, error: a, hint: i, id: t, children: s, className: l = "" }) {
615
+ const o = ["ui-field", l].filter(Boolean).join(" ");
616
+ return /* @__PURE__ */ b("div", { className: o, children: [
617
+ n && /* @__PURE__ */ e("label", { htmlFor: t, className: "ui-field-label", children: n }),
618
+ s,
619
+ i && /* @__PURE__ */ e("span", { className: "ui-field-hint", children: i }),
620
+ a && /* @__PURE__ */ e("span", { className: "ui-field-error", role: "alert", children: a })
621
+ ] });
622
+ }
623
+ function ie({ trigger: n, content: a, className: i = "" }) {
624
+ const [t, s] = y(!1), l = ["ui-hovercard", i].filter(Boolean).join(" ");
625
+ return /* @__PURE__ */ b(
626
+ "div",
627
+ {
628
+ className: l,
629
+ onMouseEnter: () => s(!0),
630
+ onMouseLeave: () => s(!1),
631
+ children: [
632
+ /* @__PURE__ */ e("div", { className: "ui-hovercard-trigger", children: n }),
633
+ t && /* @__PURE__ */ e("div", { className: "ui-hovercard-content", children: a })
634
+ ]
635
+ }
636
+ );
637
+ }
638
+ function le({ left: n, right: a, children: i, className: t = "" }) {
639
+ const s = ["ui-inputgroup", t].filter(Boolean).join(" ");
640
+ return /* @__PURE__ */ b("div", { className: s, children: [
641
+ n && /* @__PURE__ */ e("span", { className: "ui-inputgroup-addon ui-inputgroup-addon--left", children: n }),
642
+ /* @__PURE__ */ e("span", { className: "ui-inputgroup-input", children: i }),
643
+ a && /* @__PURE__ */ e("span", { className: "ui-inputgroup-addon ui-inputgroup-addon--right", children: a })
644
+ ] });
645
+ }
646
+ function ne({ length: n = 6, value: a = "", onChange: i, className: t = "" }) {
647
+ const s = B([]), l = a.split("").concat(Array(n).fill("")).slice(0, n), o = (c, d) => {
648
+ var m;
649
+ const h = l.slice();
650
+ h[c] = d.replace(/\D/g, "").slice(-1), i == null || i(h.join("")), d && c < n - 1 && ((m = s.current[c + 1]) == null || m.focus());
651
+ }, u = (c, d) => {
652
+ var h;
653
+ d.key === "Backspace" && !l[c] && c > 0 && ((h = s.current[c - 1]) == null || h.focus());
654
+ }, r = ["ui-inputotp", t].filter(Boolean).join(" ");
655
+ return /* @__PURE__ */ e("div", { className: r, role: "group", "aria-label": "One-time code", children: l.map((c, d) => /* @__PURE__ */ e(
656
+ "input",
657
+ {
658
+ ref: (h) => s.current[d] = h,
659
+ type: "text",
660
+ inputMode: "numeric",
661
+ maxLength: 1,
662
+ className: "ui-inputotp-digit",
663
+ value: c,
664
+ onChange: (h) => o(d, h.target.value),
665
+ onKeyDown: (h) => u(d, h),
666
+ "aria-label": `Digit ${d + 1}`
667
+ },
668
+ d
669
+ )) });
670
+ }
671
+ function E({
672
+ href: n,
673
+ onClick: a,
674
+ active: i = !1,
675
+ disabled: t = !1,
676
+ icon: s,
677
+ children: l,
678
+ className: o = "",
679
+ ...u
680
+ }) {
681
+ const r = [
682
+ "ui-navlink",
683
+ i && "ui-navlink--active",
684
+ t && "ui-navlink--disabled",
685
+ o
686
+ ].filter(Boolean).join(" "), c = /* @__PURE__ */ b(x, { children: [
687
+ s && /* @__PURE__ */ e("span", { className: "ui-navlink-icon", "aria-hidden": "true", children: s }),
688
+ /* @__PURE__ */ e("span", { className: "ui-navlink-text", children: l })
689
+ ] });
690
+ return n && !t ? /* @__PURE__ */ e(
691
+ "a",
692
+ {
693
+ href: n,
694
+ className: r,
695
+ onClick: a,
696
+ "aria-current": i ? "page" : void 0,
697
+ ...u,
698
+ children: c
699
+ }
700
+ ) : /* @__PURE__ */ e(
701
+ "button",
702
+ {
703
+ type: "button",
704
+ className: r,
705
+ onClick: t ? void 0 : a,
706
+ disabled: t,
707
+ "aria-current": i ? "page" : void 0,
708
+ ...u,
709
+ children: c
710
+ }
711
+ );
712
+ }
713
+ function re({
714
+ brand: n,
715
+ nav: a,
716
+ actions: i,
717
+ variant: t = "default",
718
+ sticky: s = !1,
719
+ dense: l = !1,
720
+ /** When true, shows a gradient mark before brand (text logos). Set false for custom image logos. */
721
+ brandMark: o = !1,
722
+ mobileMenuOpen: u,
723
+ onMobileMenuChange: r,
724
+ className: c = ""
725
+ }) {
726
+ const d = D().replace(/:/g, ""), [h, m] = y(!1), f = u !== void 0, N = f ? u : h, k = (v) => {
727
+ f || m(v), r == null || r(v);
728
+ }, g = [
729
+ "ui-navbar",
730
+ `ui-navbar--${t}`,
731
+ s && "ui-navbar--sticky",
732
+ l && "ui-navbar--dense",
733
+ c
734
+ ].filter(Boolean).join(" ");
735
+ return /* @__PURE__ */ b("header", { className: g, role: "banner", children: [
736
+ /* @__PURE__ */ b("div", { className: "ui-navbar-inner", children: [
737
+ /* @__PURE__ */ e(
738
+ "div",
739
+ {
740
+ className: ["ui-navbar-brand", o && "ui-navbar-brand--with-mark"].filter(Boolean).join(" "),
741
+ children: n
742
+ }
743
+ ),
744
+ /* @__PURE__ */ e("nav", { className: "ui-navbar-nav", "aria-label": "Main", children: a }),
745
+ /* @__PURE__ */ e("div", { className: "ui-navbar-actions", children: i }),
746
+ /* @__PURE__ */ e(
747
+ "button",
748
+ {
749
+ type: "button",
750
+ className: "ui-navbar-menu-toggle",
751
+ "aria-expanded": N,
752
+ "aria-controls": `ui-navbar-mobile-${d}`,
753
+ "aria-label": "Toggle menu",
754
+ onClick: () => k(!N),
755
+ children: /* @__PURE__ */ e("span", { className: "ui-navbar-menu-icon", "aria-hidden": "true" })
756
+ }
757
+ )
758
+ ] }),
759
+ /* @__PURE__ */ e(
760
+ "div",
761
+ {
762
+ id: `ui-navbar-mobile-${d}`,
763
+ className: "ui-navbar-mobile",
764
+ hidden: !N,
765
+ role: "navigation",
766
+ "aria-label": "Mobile",
767
+ children: /* @__PURE__ */ b("div", { className: "ui-navbar-mobile-inner", children: [
768
+ a,
769
+ i && /* @__PURE__ */ e("div", { className: "ui-navbar-mobile-actions", children: i })
770
+ ] })
771
+ }
772
+ )
773
+ ] });
774
+ }
775
+ function te({
776
+ items: n = [],
777
+ header: a,
778
+ footer: i,
779
+ collapsed: t = !1,
780
+ onToggleCollapse: s,
781
+ showCollapseButton: l = !0,
782
+ position: o = "left",
783
+ variant: u = "default",
784
+ width: r = "normal",
785
+ className: c = ""
786
+ }) {
787
+ const d = [
788
+ "ui-sidebar",
789
+ `ui-sidebar--${u}`,
790
+ `ui-sidebar--${o}`,
791
+ `ui-sidebar--width-${r}`,
792
+ t && "ui-sidebar--collapsed",
793
+ c
794
+ ].filter(Boolean).join(" "), h = !!(l && s);
795
+ return /* @__PURE__ */ b("aside", { className: d, "aria-label": "Sidebar navigation", children: [
796
+ !!(a || h) && /* @__PURE__ */ b(
797
+ "div",
798
+ {
799
+ className: [
800
+ "ui-sidebar-top",
801
+ !a && h && "ui-sidebar-top--collapse-only"
802
+ ].filter(Boolean).join(" "),
803
+ children: [
804
+ a ? /* @__PURE__ */ e("div", { className: "ui-sidebar-header", children: a }) : null,
805
+ h ? /* @__PURE__ */ e(
806
+ "button",
807
+ {
808
+ type: "button",
809
+ className: "ui-sidebar-collapse-btn",
810
+ onClick: () => s(!t),
811
+ "aria-expanded": !t,
812
+ "aria-label": t ? "Expand sidebar" : "Collapse sidebar",
813
+ children: /* @__PURE__ */ e("span", { className: "ui-sidebar-collapse-icon", "aria-hidden": "true" })
814
+ }
815
+ ) : null
816
+ ]
817
+ }
818
+ ),
819
+ /* @__PURE__ */ e("nav", { className: "ui-sidebar-nav", "aria-label": "Sidebar", children: /* @__PURE__ */ e("ul", { className: "ui-sidebar-list", children: n.map((f, N) => /* @__PURE__ */ e("li", { className: "ui-sidebar-item", children: /* @__PURE__ */ e(
820
+ E,
821
+ {
822
+ href: f.href,
823
+ onClick: f.onClick,
824
+ active: f.active,
825
+ disabled: f.disabled,
826
+ icon: f.icon,
827
+ children: f.label
828
+ }
829
+ ) }, f.id ?? N)) }) }),
830
+ i && /* @__PURE__ */ e("div", { className: "ui-sidebar-footer", children: i })
831
+ ] });
832
+ }
833
+ export {
834
+ A as Accordion,
835
+ F as Alert,
836
+ R as AlertDialog,
837
+ I as AspectRatio,
838
+ T as Avatar,
839
+ K as Badge,
840
+ M as Breadcrumb,
841
+ P as Button,
842
+ O as ButtonGroup,
843
+ j as Calendar,
844
+ G as Card,
845
+ H as Carousel,
846
+ X as Chart,
847
+ Y as Checkbox,
848
+ _ as Collapsible,
849
+ q as Combobox,
850
+ U as Command,
851
+ V as ContextMenu,
852
+ W as DashboardPage,
853
+ z as DataTable,
854
+ J as DatePicker,
855
+ Q as Dialog,
856
+ Z as Drawer,
857
+ C as DropdownMenu,
858
+ ee as Empty,
859
+ ae as Field,
860
+ ie as HoverCard,
861
+ $ as Input,
862
+ le as InputGroup,
863
+ ne as InputOTP,
864
+ E as NavLink,
865
+ re as Navbar,
866
+ te as Sidebar
867
+ };
868
+ //# sourceMappingURL=tri-ui-library.js.map