@bzync/rui 0.0.3
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 +15 -0
- package/README.md +115 -0
- package/dist/autocomplete-CaysJRpk.cjs +1 -0
- package/dist/autocomplete-CfbfpcO4.js +453 -0
- package/dist/calendar-Bnld4G59.cjs +1 -0
- package/dist/calendar-CdICOROs.js +573 -0
- package/dist/charts-CxEy2c3M.js +1248 -0
- package/dist/charts-UDqS1BH1.cjs +1 -0
- package/dist/cn-BdjraxxU.cjs +1 -0
- package/dist/cn-DpgY2leY.js +1736 -0
- package/dist/component-styles-Ce56hn9T.js +16 -0
- package/dist/component-styles-TkZ7v6Ef.cjs +1 -0
- package/dist/components/accordion.cjs +1 -0
- package/dist/components/accordion.d.ts +22 -0
- package/dist/components/accordion.js +122 -0
- package/dist/components/alert.cjs +1 -0
- package/dist/components/alert.d.ts +13 -0
- package/dist/components/alert.js +165 -0
- package/dist/components/auth-backdrop.cjs +1 -0
- package/dist/components/auth-backdrop.d.ts +7 -0
- package/dist/components/auth-backdrop.js +10 -0
- package/dist/components/autocomplete/dropdown.d.ts +21 -0
- package/dist/components/autocomplete/icons.d.ts +8 -0
- package/dist/components/autocomplete/multi-trigger.d.ts +25 -0
- package/dist/components/autocomplete/single-trigger.d.ts +21 -0
- package/dist/components/autocomplete/types.d.ts +34 -0
- package/dist/components/autocomplete.cjs +1 -0
- package/dist/components/autocomplete.d.ts +5 -0
- package/dist/components/autocomplete.js +3 -0
- package/dist/components/avatar.cjs +1 -0
- package/dist/components/avatar.d.ts +17 -0
- package/dist/components/avatar.js +56 -0
- package/dist/components/badge.cjs +1 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +32 -0
- package/dist/components/billing-interval-toggle.cjs +1 -0
- package/dist/components/billing-interval-toggle.d.ts +18 -0
- package/dist/components/billing-interval-toggle.js +39 -0
- package/dist/components/breadcrumb.cjs +1 -0
- package/dist/components/breadcrumb.d.ts +11 -0
- package/dist/components/breadcrumb.js +52 -0
- package/dist/components/button.cjs +1 -0
- package/dist/components/button.d.ts +17 -0
- package/dist/components/button.js +90 -0
- package/dist/components/calendar/month-view.d.ts +17 -0
- package/dist/components/calendar/types.d.ts +54 -0
- package/dist/components/calendar/week-view.d.ts +17 -0
- package/dist/components/calendar.cjs +1 -0
- package/dist/components/calendar.d.ts +3 -0
- package/dist/components/calendar.js +3 -0
- package/dist/components/callout.cjs +1 -0
- package/dist/components/callout.d.ts +9 -0
- package/dist/components/callout.js +131 -0
- package/dist/components/card.cjs +1 -0
- package/dist/components/card.d.ts +17 -0
- package/dist/components/card.js +59 -0
- package/dist/components/charts/bar-chart.d.ts +16 -0
- package/dist/components/charts/donut-chart.d.ts +10 -0
- package/dist/components/charts/funnel-chart.d.ts +8 -0
- package/dist/components/charts/gantt-chart.d.ts +15 -0
- package/dist/components/charts/heatmap-chart.d.ts +10 -0
- package/dist/components/charts/index.d.ts +11 -0
- package/dist/components/charts/line-chart.d.ts +16 -0
- package/dist/components/charts/multi-line-chart.d.ts +18 -0
- package/dist/components/charts/radar-chart.d.ts +13 -0
- package/dist/components/charts/scatter-chart.d.ts +24 -0
- package/dist/components/charts/shared.d.ts +15 -0
- package/dist/components/charts/waterfall-chart.d.ts +14 -0
- package/dist/components/charts.cjs +1 -0
- package/dist/components/charts.d.ts +2 -0
- package/dist/components/charts.js +2 -0
- package/dist/components/checkbox.cjs +1 -0
- package/dist/components/checkbox.d.ts +9 -0
- package/dist/components/checkbox.js +135 -0
- package/dist/components/code.cjs +7 -0
- package/dist/components/code.d.ts +23 -0
- package/dist/components/code.js +276 -0
- package/dist/components/command.cjs +1 -0
- package/dist/components/command.d.ts +29 -0
- package/dist/components/command.js +208 -0
- package/dist/components/confirm-dialog.cjs +1 -0
- package/dist/components/confirm-dialog.d.ts +14 -0
- package/dist/components/confirm-dialog.js +69 -0
- package/dist/components/copy-button.cjs +1 -0
- package/dist/components/copy-button.d.ts +8 -0
- package/dist/components/copy-button.js +87 -0
- package/dist/components/datatable/pagination-footer.d.ts +10 -0
- package/dist/components/datatable/rows-dropdown.d.ts +5 -0
- package/dist/components/datatable/skeleton-row.d.ts +3 -0
- package/dist/components/datatable/sort-icon.d.ts +4 -0
- package/dist/components/datatable/types.d.ts +30 -0
- package/dist/components/datatable.cjs +1 -0
- package/dist/components/datatable.d.ts +9 -0
- package/dist/components/datatable.js +3 -0
- package/dist/components/datepicker.cjs +1 -0
- package/dist/components/datepicker.d.ts +14 -0
- package/dist/components/datepicker.js +267 -0
- package/dist/components/drawer.cjs +1 -0
- package/dist/components/drawer.d.ts +18 -0
- package/dist/components/drawer.js +3 -0
- package/dist/components/dropdown-menu.cjs +1 -0
- package/dist/components/dropdown-menu.d.ts +26 -0
- package/dist/components/dropdown-menu.js +122 -0
- package/dist/components/empty-state.cjs +1 -0
- package/dist/components/empty-state.d.ts +10 -0
- package/dist/components/empty-state.js +68 -0
- package/dist/components/error-state.cjs +1 -0
- package/dist/components/error-state.d.ts +10 -0
- package/dist/components/error-state.js +80 -0
- package/dist/components/file-upload.cjs +1 -0
- package/dist/components/file-upload.d.ts +10 -0
- package/dist/components/file-upload.js +173 -0
- package/dist/components/form-field.cjs +1 -0
- package/dist/components/form-field.d.ts +10 -0
- package/dist/components/form-field.js +36 -0
- package/dist/components/info-button.cjs +1 -0
- package/dist/components/info-button.d.ts +4 -0
- package/dist/components/info-button.js +32 -0
- package/dist/components/input.cjs +1 -0
- package/dist/components/input.d.ts +19 -0
- package/dist/components/input.js +117 -0
- package/dist/components/kbd.cjs +1 -0
- package/dist/components/kbd.d.ts +6 -0
- package/dist/components/kbd.js +16 -0
- package/dist/components/label.cjs +1 -0
- package/dist/components/label.d.ts +6 -0
- package/dist/components/label.js +31 -0
- package/dist/components/layout.cjs +1 -0
- package/dist/components/layout.d.ts +51 -0
- package/dist/components/layout.js +117 -0
- package/dist/components/link.cjs +1 -0
- package/dist/components/link.d.ts +9 -0
- package/dist/components/link.js +48 -0
- package/dist/components/list.cjs +1 -0
- package/dist/components/list.d.ts +13 -0
- package/dist/components/list.js +46 -0
- package/dist/components/modal.cjs +1 -0
- package/dist/components/modal.d.ts +31 -0
- package/dist/components/modal.js +219 -0
- package/dist/components/navigation.cjs +1 -0
- package/dist/components/navigation.d.ts +42 -0
- package/dist/components/navigation.js +127 -0
- package/dist/components/number-input.cjs +1 -0
- package/dist/components/number-input.d.ts +16 -0
- package/dist/components/number-input.js +142 -0
- package/dist/components/otp-input.cjs +1 -0
- package/dist/components/otp-input.d.ts +13 -0
- package/dist/components/otp-input.js +71 -0
- package/dist/components/pagination.cjs +1 -0
- package/dist/components/pagination.d.ts +8 -0
- package/dist/components/pagination.js +77 -0
- package/dist/components/popover.cjs +1 -0
- package/dist/components/popover.d.ts +16 -0
- package/dist/components/popover.js +115 -0
- package/dist/components/progressbar.cjs +1 -0
- package/dist/components/progressbar.d.ts +15 -0
- package/dist/components/progressbar.js +108 -0
- package/dist/components/radio.cjs +1 -0
- package/dist/components/radio.d.ts +22 -0
- package/dist/components/radio.js +96 -0
- package/dist/components/richtext.cjs +1 -0
- package/dist/components/richtext.d.ts +10 -0
- package/dist/components/richtext.js +370 -0
- package/dist/components/select/option-list.d.ts +16 -0
- package/dist/components/select/select-multi.d.ts +2 -0
- package/dist/components/select/select-single.d.ts +2 -0
- package/dist/components/select/types.d.ts +54 -0
- package/dist/components/select/utils.d.ts +10 -0
- package/dist/components/select.cjs +1 -0
- package/dist/components/select.d.ts +3 -0
- package/dist/components/select.js +2 -0
- package/dist/components/seo.cjs +1 -0
- package/dist/components/seo.d.ts +45 -0
- package/dist/components/seo.js +64 -0
- package/dist/components/separator.cjs +1 -0
- package/dist/components/separator.d.ts +6 -0
- package/dist/components/separator.js +25 -0
- package/dist/components/skeleton.cjs +1 -0
- package/dist/components/skeleton.d.ts +37 -0
- package/dist/components/skeleton.js +146 -0
- package/dist/components/slider.cjs +1 -0
- package/dist/components/slider.d.ts +12 -0
- package/dist/components/slider.js +72 -0
- package/dist/components/snackbar.cjs +1 -0
- package/dist/components/snackbar.d.ts +35 -0
- package/dist/components/snackbar.js +220 -0
- package/dist/components/spinner.cjs +1 -0
- package/dist/components/spinner.d.ts +7 -0
- package/dist/components/spinner.js +31 -0
- package/dist/components/stat.cjs +1 -0
- package/dist/components/stat.d.ts +18 -0
- package/dist/components/stat.js +90 -0
- package/dist/components/status-dot.cjs +1 -0
- package/dist/components/status-dot.d.ts +10 -0
- package/dist/components/status-dot.js +29 -0
- package/dist/components/stepper.cjs +1 -0
- package/dist/components/stepper.d.ts +11 -0
- package/dist/components/stepper.js +67 -0
- package/dist/components/switch.cjs +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.js +79 -0
- package/dist/components/table.cjs +1 -0
- package/dist/components/table.d.ts +12 -0
- package/dist/components/table.js +54 -0
- package/dist/components/tabs.cjs +1 -0
- package/dist/components/tabs.d.ts +22 -0
- package/dist/components/tabs.js +120 -0
- package/dist/components/tag.cjs +1 -0
- package/dist/components/tag.d.ts +12 -0
- package/dist/components/tag.js +58 -0
- package/dist/components/terminal/fs.d.ts +10 -0
- package/dist/components/terminal/shell-commands-sim.d.ts +5 -0
- package/dist/components/terminal/shell-commands.d.ts +16 -0
- package/dist/components/terminal/shell-run.d.ts +11 -0
- package/dist/components/terminal/terminal-block.d.ts +13 -0
- package/dist/components/terminal/terminal-emulator.d.ts +10 -0
- package/dist/components/terminal/types.d.ts +35 -0
- package/dist/components/terminal.cjs +1 -0
- package/dist/components/terminal.d.ts +2 -0
- package/dist/components/terminal.js +2 -0
- package/dist/components/textarea.cjs +1 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +54 -0
- package/dist/components/theme-provider.cjs +1 -0
- package/dist/components/theme-provider.d.ts +89 -0
- package/dist/components/theme-provider.js +93 -0
- package/dist/components/theme-toggle.cjs +1 -0
- package/dist/components/theme-toggle.d.ts +9 -0
- package/dist/components/theme-toggle.js +4 -0
- package/dist/components/timeline.cjs +1 -0
- package/dist/components/timeline.d.ts +14 -0
- package/dist/components/timeline.js +54 -0
- package/dist/components/tooltip.cjs +1 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +84 -0
- package/dist/components/tree.cjs +1 -0
- package/dist/components/tree.d.ts +16 -0
- package/dist/components/tree.js +92 -0
- package/dist/createLucideIcon-DDY8HuQR.js +42 -0
- package/dist/createLucideIcon-b_X_3fj-.cjs +1 -0
- package/dist/datatable-BB3v__r5.cjs +1 -0
- package/dist/datatable-DlBhUhuO.js +316 -0
- package/dist/drawer-Cbuh6qdL.cjs +1 -0
- package/dist/drawer-CqkVZT9Y.js +189 -0
- package/dist/focus-Dk1YWVPN.js +42 -0
- package/dist/focus-DmG6Ge7X.cjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +215 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/component-styles.d.ts +10 -0
- package/dist/select-Ch5fp1GT.js +461 -0
- package/dist/select-q0YCMhBP.cjs +1 -0
- package/dist/styles.css +3 -0
- package/dist/terminal-BOR2cFi1.js +1060 -0
- package/dist/terminal-CpraMs50.cjs +77 -0
- package/dist/theme-toggle-CnoiorKV.js +71 -0
- package/dist/theme-toggle-Dp1-24zH.cjs +1 -0
- package/dist/use-event-callback-DGkfO_uu.js +10 -0
- package/dist/use-event-callback-Du9_9eAi.cjs +1 -0
- package/dist/utils-CQ8pvCtk.js +72 -0
- package/dist/utils-DOFJTw8o.cjs +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { t as e } from "./cn-DpgY2leY.js";
|
|
2
|
+
import { o as t, t as n } from "./component-styles-Ce56hn9T.js";
|
|
3
|
+
import { a as r, i, n as a, o, r as s, t as c } from "./utils-CQ8pvCtk.js";
|
|
4
|
+
import { t as l } from "./use-event-callback-DGkfO_uu.js";
|
|
5
|
+
import { AnimatePresence as u, motion as d } from "framer-motion";
|
|
6
|
+
import { forwardRef as f, useCallback as p, useEffect as m, useId as h, useMemo as g, useRef as _, useState as v } from "react";
|
|
7
|
+
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
8
|
+
import { createPortal as S } from "react-dom";
|
|
9
|
+
//#region src/components/select/option-list.tsx
|
|
10
|
+
function C({ listId: t, listRef: n, open: i, pos: a, options: o, flat: s, activeIdx: c, setActiveIdx: l, isSelected: f, onSelect: p, colorDot: m, multiselectable: h = !1, className: g }) {
|
|
11
|
+
return typeof document > "u" ? null : S(/* @__PURE__ */ b(u, { children: i && a && /* @__PURE__ */ b(d.ul, {
|
|
12
|
+
ref: n,
|
|
13
|
+
id: t,
|
|
14
|
+
role: "listbox",
|
|
15
|
+
"aria-multiselectable": h,
|
|
16
|
+
initial: {
|
|
17
|
+
opacity: 0,
|
|
18
|
+
y: a.placement === "bottom" ? -4 : 4,
|
|
19
|
+
scaleY: .97
|
|
20
|
+
},
|
|
21
|
+
animate: {
|
|
22
|
+
opacity: 1,
|
|
23
|
+
y: 0,
|
|
24
|
+
scaleY: 1
|
|
25
|
+
},
|
|
26
|
+
exit: {
|
|
27
|
+
opacity: 0,
|
|
28
|
+
y: a.placement === "bottom" ? -4 : 4,
|
|
29
|
+
scaleY: .97
|
|
30
|
+
},
|
|
31
|
+
transition: { duration: .13 },
|
|
32
|
+
style: {
|
|
33
|
+
originY: a.placement === "bottom" ? 0 : 1,
|
|
34
|
+
position: "fixed",
|
|
35
|
+
top: a.top,
|
|
36
|
+
left: a.left,
|
|
37
|
+
width: a.width,
|
|
38
|
+
maxHeight: a.maxHeight
|
|
39
|
+
},
|
|
40
|
+
className: e("z-[110] overflow-y-auto rounded-[var(--radius-lg)] border border-border bg-surface-raised py-1 shadow-floating", g),
|
|
41
|
+
children: o.map((e, n) => r(e) ? /* @__PURE__ */ x("li", { children: [/* @__PURE__ */ b("p", {
|
|
42
|
+
className: "px-3 pt-2 pb-1 text-xs font-semibold text-slate-600 uppercase tracking-widest",
|
|
43
|
+
children: e.group
|
|
44
|
+
}), /* @__PURE__ */ b("ul", { children: e.options.map((e) => {
|
|
45
|
+
let n = s.find((t) => t.value === e.value);
|
|
46
|
+
return /* @__PURE__ */ b(w, {
|
|
47
|
+
opt: e,
|
|
48
|
+
listId: t,
|
|
49
|
+
flatIdx: n.flatIdx,
|
|
50
|
+
isActive: n.flatIdx === c,
|
|
51
|
+
isSelected: f(e.value),
|
|
52
|
+
onSelect: p,
|
|
53
|
+
onHover: l,
|
|
54
|
+
colorDot: m
|
|
55
|
+
}, e.value);
|
|
56
|
+
}) })] }, n) : /* @__PURE__ */ b(w, {
|
|
57
|
+
opt: e,
|
|
58
|
+
listId: t,
|
|
59
|
+
flatIdx: s.find((t) => t.value === e.value).flatIdx,
|
|
60
|
+
isActive: s.find((t) => t.value === e.value).flatIdx === c,
|
|
61
|
+
isSelected: f(e.value),
|
|
62
|
+
onSelect: p,
|
|
63
|
+
onHover: l,
|
|
64
|
+
colorDot: m
|
|
65
|
+
}, e.value))
|
|
66
|
+
}) }), document.body);
|
|
67
|
+
}
|
|
68
|
+
function w({ opt: t, listId: n, flatIdx: r, isActive: i, isSelected: a, onSelect: o, onHover: s, colorDot: c }) {
|
|
69
|
+
return /* @__PURE__ */ x("li", {
|
|
70
|
+
id: `${n}-opt-${r}`,
|
|
71
|
+
role: "option",
|
|
72
|
+
"aria-selected": a,
|
|
73
|
+
"aria-disabled": t.disabled,
|
|
74
|
+
"data-idx": r,
|
|
75
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
76
|
+
onClick: () => !t.disabled && o(t),
|
|
77
|
+
onMouseEnter: () => !t.disabled && s(r),
|
|
78
|
+
className: e("flex min-h-9 items-center gap-3 px-3 py-2 cursor-pointer transition-colors select-none", i && "bg-surface-muted", a && !i && "bg-accent-50 dark:bg-accent-500/10", t.disabled && "opacity-40 cursor-not-allowed pointer-events-none"),
|
|
79
|
+
children: [
|
|
80
|
+
t.icon && /* @__PURE__ */ b("span", {
|
|
81
|
+
className: "shrink-0 text-slate-500 dark:text-slate-400",
|
|
82
|
+
children: t.icon
|
|
83
|
+
}),
|
|
84
|
+
t.color && t.color !== "default" && /* @__PURE__ */ b("span", { className: e("w-2 h-2 rounded-full shrink-0", c[t.color]) }),
|
|
85
|
+
/* @__PURE__ */ x("div", {
|
|
86
|
+
className: "min-w-0 flex-1",
|
|
87
|
+
children: [/* @__PURE__ */ b("p", {
|
|
88
|
+
className: e("text-sm leading-snug truncate", a ? "text-accent-700 dark:text-accent-300 font-medium" : "text-foreground"),
|
|
89
|
+
children: t.label
|
|
90
|
+
}), t.description && /* @__PURE__ */ b("p", {
|
|
91
|
+
className: "mt-0.5 truncate text-xs text-muted-foreground",
|
|
92
|
+
children: t.description
|
|
93
|
+
})]
|
|
94
|
+
}),
|
|
95
|
+
a && /* @__PURE__ */ b("svg", {
|
|
96
|
+
"aria-hidden": "true",
|
|
97
|
+
width: "14",
|
|
98
|
+
height: "14",
|
|
99
|
+
viewBox: "0 0 24 24",
|
|
100
|
+
fill: "none",
|
|
101
|
+
stroke: "currentColor",
|
|
102
|
+
strokeWidth: "2.5",
|
|
103
|
+
strokeLinecap: "round",
|
|
104
|
+
strokeLinejoin: "round",
|
|
105
|
+
className: "text-accent-600 shrink-0",
|
|
106
|
+
children: /* @__PURE__ */ b("path", { d: "m20 6-11 11-5-5" })
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/components/select/select-single.tsx
|
|
113
|
+
var T = f(({ options: r, value: u, defaultValue: d, onChange: f, placeholder: S = "Select…", label: w, hint: T, error: E, disabled: D, required: O, clearable: k = !1, className: A, wrapperClassName: j, triggerClassName: M, listClassName: N, id: P, unstyled: F = !1 }, I) => {
|
|
114
|
+
let L = h(), R = P ?? L, z = `${R}-list`, B = `${R}-message`, [V, H] = v(!1), [U, W] = v(d ?? ""), [G, K] = v(-1), q = _(null), J = _(null), Y = l((e) => f?.(e)), X = u === void 0 ? U : u, Z = g(() => i(r), [r]), Q = g(() => Z.find((e) => e.value === X), [Z, X]), $ = p((e) => {
|
|
115
|
+
u === void 0 && W(e.value), Y(e.value), H(!1), K(-1);
|
|
116
|
+
}, [u, Y]), ee = p((e) => {
|
|
117
|
+
e.stopPropagation(), u === void 0 && W(""), Y("");
|
|
118
|
+
}, [u, Y]), te = p((e) => {
|
|
119
|
+
if (!V) {
|
|
120
|
+
if ([
|
|
121
|
+
"Enter",
|
|
122
|
+
" ",
|
|
123
|
+
"ArrowDown",
|
|
124
|
+
"ArrowUp"
|
|
125
|
+
].includes(e.key)) {
|
|
126
|
+
e.preventDefault(), H(!0);
|
|
127
|
+
let t = Z.find((e) => e.value === X && e.flatIdx >= 0)?.flatIdx ?? -1, n = Z.filter((e) => e.flatIdx >= 0);
|
|
128
|
+
K(t >= 0 ? t : e.key === "ArrowUp" ? n[n.length - 1]?.flatIdx ?? -1 : n[0]?.flatIdx ?? -1);
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (e.key === "ArrowDown") e.preventDefault(), K((e) => {
|
|
133
|
+
let t = Z.filter((e) => e.flatIdx >= 0), n = t.findIndex((t) => t.flatIdx === e);
|
|
134
|
+
return t[Math.min(n + 1, t.length - 1)]?.flatIdx ?? e;
|
|
135
|
+
});
|
|
136
|
+
else if (e.key === "ArrowUp") e.preventDefault(), K((e) => {
|
|
137
|
+
let t = Z.filter((e) => e.flatIdx >= 0), n = t.findIndex((t) => t.flatIdx === e);
|
|
138
|
+
return t[Math.max(n - 1, 0)]?.flatIdx ?? e;
|
|
139
|
+
});
|
|
140
|
+
else if (e.key === "Enter" || e.key === " ") {
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
let t = Z.find((e) => e.flatIdx === G);
|
|
143
|
+
t && $(t);
|
|
144
|
+
} else (e.key === "Escape" || e.key === "Tab") && (H(!1), K(-1));
|
|
145
|
+
}, [
|
|
146
|
+
V,
|
|
147
|
+
Z,
|
|
148
|
+
X,
|
|
149
|
+
G,
|
|
150
|
+
$
|
|
151
|
+
]);
|
|
152
|
+
m(() => {
|
|
153
|
+
G < 0 || !J.current || J.current.querySelector(`[data-idx="${G}"]`)?.scrollIntoView({ block: "nearest" });
|
|
154
|
+
}, [G]), m(() => {
|
|
155
|
+
function e(e) {
|
|
156
|
+
let t = e.target;
|
|
157
|
+
q.current?.contains(t) || J.current?.contains(t) || H(!1);
|
|
158
|
+
}
|
|
159
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
160
|
+
}, []);
|
|
161
|
+
let ne = o(V, q);
|
|
162
|
+
return F ? /* @__PURE__ */ x("div", {
|
|
163
|
+
ref: q,
|
|
164
|
+
className: e(A, j),
|
|
165
|
+
children: [/* @__PURE__ */ b("button", {
|
|
166
|
+
ref: I,
|
|
167
|
+
id: R,
|
|
168
|
+
type: "button",
|
|
169
|
+
role: "combobox",
|
|
170
|
+
"aria-expanded": V,
|
|
171
|
+
onClick: () => H((e) => !e),
|
|
172
|
+
className: M,
|
|
173
|
+
children: Q?.label ?? S
|
|
174
|
+
}), V && /* @__PURE__ */ b("ul", {
|
|
175
|
+
ref: J,
|
|
176
|
+
id: z,
|
|
177
|
+
className: N,
|
|
178
|
+
children: Z.map((e) => /* @__PURE__ */ b("li", {
|
|
179
|
+
"data-idx": e.flatIdx,
|
|
180
|
+
onClick: () => $(e),
|
|
181
|
+
children: e.label
|
|
182
|
+
}, e.value))
|
|
183
|
+
})]
|
|
184
|
+
}) : /* @__PURE__ */ x("div", {
|
|
185
|
+
ref: q,
|
|
186
|
+
className: e("relative", t, j, A),
|
|
187
|
+
children: [
|
|
188
|
+
w && /* @__PURE__ */ x("label", {
|
|
189
|
+
htmlFor: R,
|
|
190
|
+
className: "text-sm font-medium leading-5 text-foreground",
|
|
191
|
+
children: [w, O && /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("span", {
|
|
192
|
+
"aria-hidden": "true",
|
|
193
|
+
className: "ml-1 text-destructive",
|
|
194
|
+
children: "*"
|
|
195
|
+
}), /* @__PURE__ */ b("span", {
|
|
196
|
+
className: "sr-only",
|
|
197
|
+
children: " (required)"
|
|
198
|
+
})] })]
|
|
199
|
+
}),
|
|
200
|
+
/* @__PURE__ */ x("button", {
|
|
201
|
+
ref: I,
|
|
202
|
+
id: R,
|
|
203
|
+
type: "button",
|
|
204
|
+
role: "combobox",
|
|
205
|
+
"aria-haspopup": "listbox",
|
|
206
|
+
"aria-expanded": V,
|
|
207
|
+
"aria-controls": z,
|
|
208
|
+
"aria-activedescendant": V && G >= 0 ? `${z}-opt-${G}` : void 0,
|
|
209
|
+
"aria-invalid": E ? !0 : void 0,
|
|
210
|
+
"aria-required": O || void 0,
|
|
211
|
+
"aria-describedby": E || T ? B : void 0,
|
|
212
|
+
disabled: D,
|
|
213
|
+
onKeyDown: te,
|
|
214
|
+
onClick: () => {
|
|
215
|
+
D || (H((e) => !e), V || K(Z.find((e) => e.value === X && e.flatIdx >= 0)?.flatIdx ?? -1));
|
|
216
|
+
},
|
|
217
|
+
className: e("flex h-9 w-full items-center gap-2 rounded-[var(--radius-md)] px-3 text-left outline-none", n, "focus:border-accent-500 focus:ring-2 focus:ring-focus-ring/20", E && "border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20", D && "opacity-50 cursor-not-allowed", M),
|
|
218
|
+
children: [
|
|
219
|
+
Q?.icon && /* @__PURE__ */ b("span", {
|
|
220
|
+
className: "shrink-0 text-slate-500 dark:text-slate-400",
|
|
221
|
+
children: Q.icon
|
|
222
|
+
}),
|
|
223
|
+
Q?.color && Q.color !== "default" && /* @__PURE__ */ b("span", { className: e("w-2 h-2 rounded-full shrink-0", s[Q.color]) }),
|
|
224
|
+
/* @__PURE__ */ b("span", {
|
|
225
|
+
className: e("flex-1 min-w-0 text-sm truncate", Q ? "text-foreground" : "text-muted-foreground"),
|
|
226
|
+
children: Q?.label ?? S
|
|
227
|
+
}),
|
|
228
|
+
k && X && !D && /* @__PURE__ */ b("span", {
|
|
229
|
+
role: "button",
|
|
230
|
+
tabIndex: -1,
|
|
231
|
+
onClick: ee,
|
|
232
|
+
className: "shrink-0 text-slate-400 hover:text-slate-600 dark:hover:text-slate-300 transition-colors",
|
|
233
|
+
children: /* @__PURE__ */ b(a, {})
|
|
234
|
+
}),
|
|
235
|
+
/* @__PURE__ */ b(c, { open: V })
|
|
236
|
+
]
|
|
237
|
+
}),
|
|
238
|
+
/* @__PURE__ */ b(C, {
|
|
239
|
+
listId: z,
|
|
240
|
+
listRef: J,
|
|
241
|
+
open: V,
|
|
242
|
+
pos: ne,
|
|
243
|
+
options: r,
|
|
244
|
+
flat: Z,
|
|
245
|
+
activeIdx: G,
|
|
246
|
+
setActiveIdx: K,
|
|
247
|
+
isSelected: (e) => e === X,
|
|
248
|
+
onSelect: $,
|
|
249
|
+
colorDot: s,
|
|
250
|
+
className: N
|
|
251
|
+
}),
|
|
252
|
+
E && /* @__PURE__ */ b("p", {
|
|
253
|
+
id: B,
|
|
254
|
+
"aria-live": "polite",
|
|
255
|
+
className: "text-xs leading-5 text-destructive",
|
|
256
|
+
children: E
|
|
257
|
+
}),
|
|
258
|
+
T && !E && /* @__PURE__ */ b("p", {
|
|
259
|
+
id: B,
|
|
260
|
+
className: "text-xs leading-5 text-muted-foreground",
|
|
261
|
+
children: T
|
|
262
|
+
})
|
|
263
|
+
]
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
T.displayName = "SelectSingle";
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/components/select/select-multi.tsx
|
|
269
|
+
var E = f(({ options: r, value: l, defaultValue: u, onChange: d, placeholder: f = "Select…", label: p, hint: g, error: S, disabled: w, required: T, clearable: E = !1, className: D, wrapperClassName: O, triggerClassName: k, listClassName: A, id: j, unstyled: M = !1 }, N) => {
|
|
270
|
+
let P = h(), F = j ?? P, I = `${F}-list`, L = `${F}-message`, [R, z] = v(!1), [B, V] = v(u ?? []), [H, U] = v(-1), W = _(null), G = _(null), K = l === void 0 ? B : l, q = i(r), J = q.filter((e) => K.includes(e.value));
|
|
271
|
+
function Y(e) {
|
|
272
|
+
let t = K.includes(e.value) ? K.filter((t) => t !== e.value) : [...K, e.value];
|
|
273
|
+
l === void 0 && V(t), d?.(t);
|
|
274
|
+
}
|
|
275
|
+
function X(e, t) {
|
|
276
|
+
t.stopPropagation();
|
|
277
|
+
let n = K.filter((t) => t !== e);
|
|
278
|
+
l === void 0 && V(n), d?.(n);
|
|
279
|
+
}
|
|
280
|
+
function Z(e) {
|
|
281
|
+
e.stopPropagation(), l === void 0 && V([]), d?.([]);
|
|
282
|
+
}
|
|
283
|
+
function Q(e) {
|
|
284
|
+
if (!R) {
|
|
285
|
+
[
|
|
286
|
+
"Enter",
|
|
287
|
+
" ",
|
|
288
|
+
"ArrowDown",
|
|
289
|
+
"ArrowUp"
|
|
290
|
+
].includes(e.key) && (e.preventDefault(), z(!0));
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (e.key === "ArrowDown") e.preventDefault(), U((e) => {
|
|
294
|
+
let t = q.filter((e) => e.flatIdx >= 0), n = t.findIndex((t) => t.flatIdx === e);
|
|
295
|
+
return t[Math.min(n + 1, t.length - 1)]?.flatIdx ?? e;
|
|
296
|
+
});
|
|
297
|
+
else if (e.key === "ArrowUp") e.preventDefault(), U((e) => {
|
|
298
|
+
let t = q.filter((e) => e.flatIdx >= 0), n = t.findIndex((t) => t.flatIdx === e);
|
|
299
|
+
return t[Math.max(n - 1, 0)]?.flatIdx ?? e;
|
|
300
|
+
});
|
|
301
|
+
else if (e.key === "Enter" || e.key === " ") {
|
|
302
|
+
e.preventDefault();
|
|
303
|
+
let t = q.find((e) => e.flatIdx === H);
|
|
304
|
+
t && Y(t);
|
|
305
|
+
} else (e.key === "Escape" || e.key === "Tab") && (z(!1), U(-1));
|
|
306
|
+
}
|
|
307
|
+
m(() => {
|
|
308
|
+
H < 0 || !G.current || G.current.querySelector(`[data-idx="${H}"]`)?.scrollIntoView({ block: "nearest" });
|
|
309
|
+
}, [H]), m(() => {
|
|
310
|
+
function e(e) {
|
|
311
|
+
let t = e.target;
|
|
312
|
+
W.current?.contains(t) || G.current?.contains(t) || z(!1);
|
|
313
|
+
}
|
|
314
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
315
|
+
}, []);
|
|
316
|
+
let $ = o(R, W);
|
|
317
|
+
return M ? /* @__PURE__ */ x("div", {
|
|
318
|
+
ref: W,
|
|
319
|
+
className: e(D, O),
|
|
320
|
+
children: [/* @__PURE__ */ b("button", {
|
|
321
|
+
ref: N,
|
|
322
|
+
id: F,
|
|
323
|
+
type: "button",
|
|
324
|
+
role: "combobox",
|
|
325
|
+
"aria-expanded": R,
|
|
326
|
+
"aria-controls": I,
|
|
327
|
+
onKeyDown: Q,
|
|
328
|
+
onClick: () => z((e) => !e),
|
|
329
|
+
className: k,
|
|
330
|
+
children: J.length > 0 ? J.map((e) => e.label).join(", ") : f
|
|
331
|
+
}), /* @__PURE__ */ b(C, {
|
|
332
|
+
listId: I,
|
|
333
|
+
listRef: G,
|
|
334
|
+
open: R,
|
|
335
|
+
pos: $,
|
|
336
|
+
options: r,
|
|
337
|
+
flat: q,
|
|
338
|
+
activeIdx: H,
|
|
339
|
+
setActiveIdx: U,
|
|
340
|
+
isSelected: (e) => K.includes(e),
|
|
341
|
+
onSelect: Y,
|
|
342
|
+
multiselectable: !0,
|
|
343
|
+
colorDot: s,
|
|
344
|
+
className: A
|
|
345
|
+
})]
|
|
346
|
+
}) : /* @__PURE__ */ x("div", {
|
|
347
|
+
ref: W,
|
|
348
|
+
className: e("relative", t, O, D),
|
|
349
|
+
children: [
|
|
350
|
+
p && /* @__PURE__ */ x("label", {
|
|
351
|
+
htmlFor: F,
|
|
352
|
+
className: "text-sm font-medium leading-5 text-foreground",
|
|
353
|
+
children: [p, T && /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("span", {
|
|
354
|
+
"aria-hidden": "true",
|
|
355
|
+
className: "ml-1 text-destructive",
|
|
356
|
+
children: "*"
|
|
357
|
+
}), /* @__PURE__ */ b("span", {
|
|
358
|
+
className: "sr-only",
|
|
359
|
+
children: " (required)"
|
|
360
|
+
})] })]
|
|
361
|
+
}),
|
|
362
|
+
/* @__PURE__ */ x("button", {
|
|
363
|
+
ref: N,
|
|
364
|
+
id: F,
|
|
365
|
+
type: "button",
|
|
366
|
+
role: "combobox",
|
|
367
|
+
"aria-haspopup": "listbox",
|
|
368
|
+
"aria-expanded": R,
|
|
369
|
+
"aria-controls": I,
|
|
370
|
+
"aria-activedescendant": R && H >= 0 ? `${I}-opt-${H}` : void 0,
|
|
371
|
+
"aria-invalid": S ? !0 : void 0,
|
|
372
|
+
"aria-required": T || void 0,
|
|
373
|
+
"aria-describedby": S || g ? L : void 0,
|
|
374
|
+
disabled: w,
|
|
375
|
+
onKeyDown: Q,
|
|
376
|
+
onClick: () => {
|
|
377
|
+
w || z((e) => !e);
|
|
378
|
+
},
|
|
379
|
+
className: e("flex min-h-9 w-full flex-wrap items-center gap-1.5 rounded-[var(--radius-md)] px-2.5 py-1.5 text-left outline-none", n, "focus:border-accent-500 focus:ring-2 focus:ring-focus-ring/20", S && "border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20", w && "opacity-50 cursor-not-allowed", k),
|
|
380
|
+
children: [J.length === 0 ? /* @__PURE__ */ b("span", {
|
|
381
|
+
className: "flex-1 text-sm text-slate-500 truncate",
|
|
382
|
+
children: f
|
|
383
|
+
}) : J.map((t) => /* @__PURE__ */ x("span", {
|
|
384
|
+
className: "inline-flex max-w-[160px] items-center gap-1 rounded-md border border-border bg-surface-muted px-2 py-0.5 text-xs font-medium text-foreground",
|
|
385
|
+
children: [
|
|
386
|
+
t.color && t.color !== "default" && /* @__PURE__ */ b("span", { className: e("w-1.5 h-1.5 rounded-full shrink-0", s[t.color]) }),
|
|
387
|
+
/* @__PURE__ */ b("span", {
|
|
388
|
+
className: "truncate",
|
|
389
|
+
children: t.label
|
|
390
|
+
}),
|
|
391
|
+
/* @__PURE__ */ b("span", {
|
|
392
|
+
role: "button",
|
|
393
|
+
tabIndex: -1,
|
|
394
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
395
|
+
onClick: (e) => X(t.value, e),
|
|
396
|
+
className: "shrink-0 text-slate-500 dark:text-slate-400 hover:text-gray-900 dark:hover:text-white transition-colors cursor-pointer ml-0.5",
|
|
397
|
+
"aria-label": `Remove ${t.label}`,
|
|
398
|
+
children: /* @__PURE__ */ b(a, {})
|
|
399
|
+
})
|
|
400
|
+
]
|
|
401
|
+
}, t.value)), /* @__PURE__ */ x("span", {
|
|
402
|
+
className: "ml-auto flex items-center gap-1.5 shrink-0 pl-1",
|
|
403
|
+
children: [
|
|
404
|
+
E && K.length > 0 && !w && /* @__PURE__ */ b("span", {
|
|
405
|
+
role: "button",
|
|
406
|
+
tabIndex: -1,
|
|
407
|
+
onClick: Z,
|
|
408
|
+
className: "text-slate-500 hover:text-slate-600 dark:hover:text-slate-300 transition-colors",
|
|
409
|
+
"aria-label": "Clear all",
|
|
410
|
+
children: /* @__PURE__ */ b(a, {})
|
|
411
|
+
}),
|
|
412
|
+
K.length > 0 && /* @__PURE__ */ b("span", {
|
|
413
|
+
className: "text-[10px] font-medium text-slate-500 tabular-nums",
|
|
414
|
+
children: K.length
|
|
415
|
+
}),
|
|
416
|
+
/* @__PURE__ */ b(c, { open: R })
|
|
417
|
+
]
|
|
418
|
+
})]
|
|
419
|
+
}),
|
|
420
|
+
/* @__PURE__ */ b(C, {
|
|
421
|
+
listId: I,
|
|
422
|
+
listRef: G,
|
|
423
|
+
open: R,
|
|
424
|
+
pos: $,
|
|
425
|
+
options: r,
|
|
426
|
+
flat: q,
|
|
427
|
+
activeIdx: H,
|
|
428
|
+
setActiveIdx: U,
|
|
429
|
+
isSelected: (e) => K.includes(e),
|
|
430
|
+
onSelect: Y,
|
|
431
|
+
multiselectable: !0,
|
|
432
|
+
colorDot: s,
|
|
433
|
+
className: A
|
|
434
|
+
}),
|
|
435
|
+
S && /* @__PURE__ */ b("p", {
|
|
436
|
+
id: L,
|
|
437
|
+
"aria-live": "polite",
|
|
438
|
+
className: "text-xs leading-5 text-destructive",
|
|
439
|
+
children: S
|
|
440
|
+
}),
|
|
441
|
+
g && !S && /* @__PURE__ */ b("p", {
|
|
442
|
+
id: L,
|
|
443
|
+
className: "text-xs leading-5 text-muted-foreground",
|
|
444
|
+
children: g
|
|
445
|
+
})
|
|
446
|
+
]
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
E.displayName = "SelectMulti";
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/components/select.tsx
|
|
452
|
+
var D = f((e, t) => e.multiple ? /* @__PURE__ */ b(E, {
|
|
453
|
+
...e,
|
|
454
|
+
ref: t
|
|
455
|
+
}) : /* @__PURE__ */ b(T, {
|
|
456
|
+
...e,
|
|
457
|
+
ref: t
|
|
458
|
+
}));
|
|
459
|
+
D.displayName = "Select";
|
|
460
|
+
//#endregion
|
|
461
|
+
export { D as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./cn-BdjraxxU.cjs"),t=require("./component-styles-TkZ7v6Ef.cjs"),n=require("./utils-DOFJTw8o.cjs"),r=require("./use-event-callback-Du9_9eAi.cjs");let i=require("framer-motion"),a=require("react"),o=require("react/jsx-runtime"),s=require("react-dom");function c({listId:t,listRef:r,open:a,pos:c,options:u,flat:d,activeIdx:f,setActiveIdx:p,isSelected:m,onSelect:h,colorDot:g,multiselectable:_=!1,className:v}){return typeof document>`u`?null:(0,s.createPortal)((0,o.jsx)(i.AnimatePresence,{children:a&&c&&(0,o.jsx)(i.motion.ul,{ref:r,id:t,role:`listbox`,"aria-multiselectable":_,initial:{opacity:0,y:c.placement===`bottom`?-4:4,scaleY:.97},animate:{opacity:1,y:0,scaleY:1},exit:{opacity:0,y:c.placement===`bottom`?-4:4,scaleY:.97},transition:{duration:.13},style:{originY:c.placement===`bottom`?0:1,position:`fixed`,top:c.top,left:c.left,width:c.width,maxHeight:c.maxHeight},className:e.t(`z-[110] overflow-y-auto rounded-[var(--radius-lg)] border border-border bg-surface-raised py-1 shadow-floating`,v),children:u.map((e,r)=>n.a(e)?(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`p`,{className:`px-3 pt-2 pb-1 text-xs font-semibold text-slate-600 uppercase tracking-widest`,children:e.group}),(0,o.jsx)(`ul`,{children:e.options.map(e=>{let n=d.find(t=>t.value===e.value);return(0,o.jsx)(l,{opt:e,listId:t,flatIdx:n.flatIdx,isActive:n.flatIdx===f,isSelected:m(e.value),onSelect:h,onHover:p,colorDot:g},e.value)})})]},r):(0,o.jsx)(l,{opt:e,listId:t,flatIdx:d.find(t=>t.value===e.value).flatIdx,isActive:d.find(t=>t.value===e.value).flatIdx===f,isSelected:m(e.value),onSelect:h,onHover:p,colorDot:g},e.value))})}),document.body)}function l({opt:t,listId:n,flatIdx:r,isActive:i,isSelected:a,onSelect:s,onHover:c,colorDot:l}){return(0,o.jsxs)(`li`,{id:`${n}-opt-${r}`,role:`option`,"aria-selected":a,"aria-disabled":t.disabled,"data-idx":r,onMouseDown:e=>e.preventDefault(),onClick:()=>!t.disabled&&s(t),onMouseEnter:()=>!t.disabled&&c(r),className:e.t(`flex min-h-9 items-center gap-3 px-3 py-2 cursor-pointer transition-colors select-none`,i&&`bg-surface-muted`,a&&!i&&`bg-accent-50 dark:bg-accent-500/10`,t.disabled&&`opacity-40 cursor-not-allowed pointer-events-none`),children:[t.icon&&(0,o.jsx)(`span`,{className:`shrink-0 text-slate-500 dark:text-slate-400`,children:t.icon}),t.color&&t.color!=="default"&&(0,o.jsx)(`span`,{className:e.t(`w-2 h-2 rounded-full shrink-0`,l[t.color])}),(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`p`,{className:e.t(`text-sm leading-snug truncate`,a?`text-accent-700 dark:text-accent-300 font-medium`:`text-foreground`),children:t.label}),t.description&&(0,o.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:t.description})]}),a&&(0,o.jsx)(`svg`,{"aria-hidden":`true`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-accent-600 shrink-0`,children:(0,o.jsx)(`path`,{d:`m20 6-11 11-5-5`})})]})}var u=(0,a.forwardRef)(({options:i,value:s,defaultValue:l,onChange:u,placeholder:d=`Select…`,label:f,hint:p,error:m,disabled:h,required:g,clearable:_=!1,className:v,wrapperClassName:y,triggerClassName:b,listClassName:x,id:S,unstyled:C=!1},w)=>{let T=(0,a.useId)(),E=S??T,D=`${E}-list`,O=`${E}-message`,[k,A]=(0,a.useState)(!1),[j,M]=(0,a.useState)(l??``),[N,P]=(0,a.useState)(-1),F=(0,a.useRef)(null),I=(0,a.useRef)(null),L=r.t(e=>u?.(e)),R=s===void 0?j:s,z=(0,a.useMemo)(()=>n.i(i),[i]),B=(0,a.useMemo)(()=>z.find(e=>e.value===R),[z,R]),V=(0,a.useCallback)(e=>{s===void 0&&M(e.value),L(e.value),A(!1),P(-1)},[s,L]),H=(0,a.useCallback)(e=>{e.stopPropagation(),s===void 0&&M(``),L(``)},[s,L]),U=(0,a.useCallback)(e=>{if(!k){if([`Enter`,` `,`ArrowDown`,`ArrowUp`].includes(e.key)){e.preventDefault(),A(!0);let t=z.find(e=>e.value===R&&e.flatIdx>=0)?.flatIdx??-1,n=z.filter(e=>e.flatIdx>=0);P(t>=0?t:e.key===`ArrowUp`?n[n.length-1]?.flatIdx??-1:n[0]?.flatIdx??-1)}return}if(e.key===`ArrowDown`)e.preventDefault(),P(e=>{let t=z.filter(e=>e.flatIdx>=0),n=t.findIndex(t=>t.flatIdx===e);return t[Math.min(n+1,t.length-1)]?.flatIdx??e});else if(e.key===`ArrowUp`)e.preventDefault(),P(e=>{let t=z.filter(e=>e.flatIdx>=0),n=t.findIndex(t=>t.flatIdx===e);return t[Math.max(n-1,0)]?.flatIdx??e});else if(e.key===`Enter`||e.key===` `){e.preventDefault();let t=z.find(e=>e.flatIdx===N);t&&V(t)}else(e.key===`Escape`||e.key===`Tab`)&&(A(!1),P(-1))},[k,z,R,N,V]);(0,a.useEffect)(()=>{N<0||!I.current||I.current.querySelector(`[data-idx="${N}"]`)?.scrollIntoView({block:`nearest`})},[N]),(0,a.useEffect)(()=>{function e(e){let t=e.target;F.current?.contains(t)||I.current?.contains(t)||A(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let W=n.o(k,F);return C?(0,o.jsxs)(`div`,{ref:F,className:e.t(v,y),children:[(0,o.jsx)(`button`,{ref:w,id:E,type:`button`,role:`combobox`,"aria-expanded":k,onClick:()=>A(e=>!e),className:b,children:B?.label??d}),k&&(0,o.jsx)(`ul`,{ref:I,id:D,className:x,children:z.map(e=>(0,o.jsx)(`li`,{"data-idx":e.flatIdx,onClick:()=>V(e),children:e.label},e.value))})]}):(0,o.jsxs)(`div`,{ref:F,className:e.t(`relative`,t.o,y,v),children:[f&&(0,o.jsxs)(`label`,{htmlFor:E,className:`text-sm font-medium leading-5 text-foreground`,children:[f,g&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`ml-1 text-destructive`,children:`*`}),(0,o.jsx)(`span`,{className:`sr-only`,children:` (required)`})]})]}),(0,o.jsxs)(`button`,{ref:w,id:E,type:`button`,role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":k,"aria-controls":D,"aria-activedescendant":k&&N>=0?`${D}-opt-${N}`:void 0,"aria-invalid":m?!0:void 0,"aria-required":g||void 0,"aria-describedby":m||p?O:void 0,disabled:h,onKeyDown:U,onClick:()=>{h||(A(e=>!e),k||P(z.find(e=>e.value===R&&e.flatIdx>=0)?.flatIdx??-1))},className:e.t(`flex h-9 w-full items-center gap-2 rounded-[var(--radius-md)] px-3 text-left outline-none`,t.t,`focus:border-accent-500 focus:ring-2 focus:ring-focus-ring/20`,m&&`border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20`,h&&`opacity-50 cursor-not-allowed`,b),children:[B?.icon&&(0,o.jsx)(`span`,{className:`shrink-0 text-slate-500 dark:text-slate-400`,children:B.icon}),B?.color&&B.color!=="default"&&(0,o.jsx)(`span`,{className:e.t(`w-2 h-2 rounded-full shrink-0`,n.r[B.color])}),(0,o.jsx)(`span`,{className:e.t(`flex-1 min-w-0 text-sm truncate`,B?`text-foreground`:`text-muted-foreground`),children:B?.label??d}),_&&R&&!h&&(0,o.jsx)(`span`,{role:`button`,tabIndex:-1,onClick:H,className:`shrink-0 text-slate-400 hover:text-slate-600 dark:hover:text-slate-300 transition-colors`,children:(0,o.jsx)(n.n,{})}),(0,o.jsx)(n.t,{open:k})]}),(0,o.jsx)(c,{listId:D,listRef:I,open:k,pos:W,options:i,flat:z,activeIdx:N,setActiveIdx:P,isSelected:e=>e===R,onSelect:V,colorDot:n.r,className:x}),m&&(0,o.jsx)(`p`,{id:O,"aria-live":`polite`,className:`text-xs leading-5 text-destructive`,children:m}),p&&!m&&(0,o.jsx)(`p`,{id:O,className:`text-xs leading-5 text-muted-foreground`,children:p})]})});u.displayName=`SelectSingle`;var d=(0,a.forwardRef)(({options:r,value:i,defaultValue:s,onChange:l,placeholder:u=`Select…`,label:d,hint:f,error:p,disabled:m,required:h,clearable:g=!1,className:_,wrapperClassName:v,triggerClassName:y,listClassName:b,id:x,unstyled:S=!1},C)=>{let w=(0,a.useId)(),T=x??w,E=`${T}-list`,D=`${T}-message`,[O,k]=(0,a.useState)(!1),[A,j]=(0,a.useState)(s??[]),[M,N]=(0,a.useState)(-1),P=(0,a.useRef)(null),F=(0,a.useRef)(null),I=i===void 0?A:i,L=n.i(r),R=L.filter(e=>I.includes(e.value));function z(e){let t=I.includes(e.value)?I.filter(t=>t!==e.value):[...I,e.value];i===void 0&&j(t),l?.(t)}function B(e,t){t.stopPropagation();let n=I.filter(t=>t!==e);i===void 0&&j(n),l?.(n)}function V(e){e.stopPropagation(),i===void 0&&j([]),l?.([])}function H(e){if(!O){[`Enter`,` `,`ArrowDown`,`ArrowUp`].includes(e.key)&&(e.preventDefault(),k(!0));return}if(e.key===`ArrowDown`)e.preventDefault(),N(e=>{let t=L.filter(e=>e.flatIdx>=0),n=t.findIndex(t=>t.flatIdx===e);return t[Math.min(n+1,t.length-1)]?.flatIdx??e});else if(e.key===`ArrowUp`)e.preventDefault(),N(e=>{let t=L.filter(e=>e.flatIdx>=0),n=t.findIndex(t=>t.flatIdx===e);return t[Math.max(n-1,0)]?.flatIdx??e});else if(e.key===`Enter`||e.key===` `){e.preventDefault();let t=L.find(e=>e.flatIdx===M);t&&z(t)}else(e.key===`Escape`||e.key===`Tab`)&&(k(!1),N(-1))}(0,a.useEffect)(()=>{M<0||!F.current||F.current.querySelector(`[data-idx="${M}"]`)?.scrollIntoView({block:`nearest`})},[M]),(0,a.useEffect)(()=>{function e(e){let t=e.target;P.current?.contains(t)||F.current?.contains(t)||k(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let U=n.o(O,P);return S?(0,o.jsxs)(`div`,{ref:P,className:e.t(_,v),children:[(0,o.jsx)(`button`,{ref:C,id:T,type:`button`,role:`combobox`,"aria-expanded":O,"aria-controls":E,onKeyDown:H,onClick:()=>k(e=>!e),className:y,children:R.length>0?R.map(e=>e.label).join(`, `):u}),(0,o.jsx)(c,{listId:E,listRef:F,open:O,pos:U,options:r,flat:L,activeIdx:M,setActiveIdx:N,isSelected:e=>I.includes(e),onSelect:z,multiselectable:!0,colorDot:n.r,className:b})]}):(0,o.jsxs)(`div`,{ref:P,className:e.t(`relative`,t.o,v,_),children:[d&&(0,o.jsxs)(`label`,{htmlFor:T,className:`text-sm font-medium leading-5 text-foreground`,children:[d,h&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`ml-1 text-destructive`,children:`*`}),(0,o.jsx)(`span`,{className:`sr-only`,children:` (required)`})]})]}),(0,o.jsxs)(`button`,{ref:C,id:T,type:`button`,role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":O,"aria-controls":E,"aria-activedescendant":O&&M>=0?`${E}-opt-${M}`:void 0,"aria-invalid":p?!0:void 0,"aria-required":h||void 0,"aria-describedby":p||f?D:void 0,disabled:m,onKeyDown:H,onClick:()=>{m||k(e=>!e)},className:e.t(`flex min-h-9 w-full flex-wrap items-center gap-1.5 rounded-[var(--radius-md)] px-2.5 py-1.5 text-left outline-none`,t.t,`focus:border-accent-500 focus:ring-2 focus:ring-focus-ring/20`,p&&`border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20`,m&&`opacity-50 cursor-not-allowed`,y),children:[R.length===0?(0,o.jsx)(`span`,{className:`flex-1 text-sm text-slate-500 truncate`,children:u}):R.map(t=>(0,o.jsxs)(`span`,{className:`inline-flex max-w-[160px] items-center gap-1 rounded-md border border-border bg-surface-muted px-2 py-0.5 text-xs font-medium text-foreground`,children:[t.color&&t.color!=="default"&&(0,o.jsx)(`span`,{className:e.t(`w-1.5 h-1.5 rounded-full shrink-0`,n.r[t.color])}),(0,o.jsx)(`span`,{className:`truncate`,children:t.label}),(0,o.jsx)(`span`,{role:`button`,tabIndex:-1,onMouseDown:e=>e.stopPropagation(),onClick:e=>B(t.value,e),className:`shrink-0 text-slate-500 dark:text-slate-400 hover:text-gray-900 dark:hover:text-white transition-colors cursor-pointer ml-0.5`,"aria-label":`Remove ${t.label}`,children:(0,o.jsx)(n.n,{})})]},t.value)),(0,o.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0 pl-1`,children:[g&&I.length>0&&!m&&(0,o.jsx)(`span`,{role:`button`,tabIndex:-1,onClick:V,className:`text-slate-500 hover:text-slate-600 dark:hover:text-slate-300 transition-colors`,"aria-label":`Clear all`,children:(0,o.jsx)(n.n,{})}),I.length>0&&(0,o.jsx)(`span`,{className:`text-[10px] font-medium text-slate-500 tabular-nums`,children:I.length}),(0,o.jsx)(n.t,{open:O})]})]}),(0,o.jsx)(c,{listId:E,listRef:F,open:O,pos:U,options:r,flat:L,activeIdx:M,setActiveIdx:N,isSelected:e=>I.includes(e),onSelect:z,multiselectable:!0,colorDot:n.r,className:b}),p&&(0,o.jsx)(`p`,{id:D,"aria-live":`polite`,className:`text-xs leading-5 text-destructive`,children:p}),f&&!p&&(0,o.jsx)(`p`,{id:D,className:`text-xs leading-5 text-muted-foreground`,children:f})]})});d.displayName=`SelectMulti`;var f=(0,a.forwardRef)((e,t)=>e.multiple?(0,o.jsx)(d,{...e,ref:t}):(0,o.jsx)(u,{...e,ref:t}));f.displayName=`Select`,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return f}});
|