@skiddph/prui 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +1 -1
- package/dist/chunks/{auth-shell-DQJ4UmUv.js → auth-shell-a-3J0_PB.js} +131 -131
- package/dist/core/input.d.ts +4 -0
- package/dist/core/input.js +40 -27
- package/dist/core/modal.js +133 -126
- package/dist/core/select.d.ts +25 -9
- package/dist/core/select.js +236 -153
- package/dist/core/toast.js +73 -64
- package/dist/index.js +1 -1
- package/dist/prui-utilities.css +1 -1
- package/dist/prui.css +1 -1
- package/package.json +1 -1
package/dist/core/select.js
CHANGED
|
@@ -1,248 +1,331 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import { ChevronDown as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { useOverlayStack as
|
|
6
|
-
import { useAnchoredPosition as
|
|
7
|
-
import { typeaheadIndex as
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { jsxs as P, jsx as b, Fragment as G } from "react/jsx-runtime";
|
|
2
|
+
import * as r from "react";
|
|
3
|
+
import { ChevronDown as te, Search as re, Check as ae } from "lucide-react";
|
|
4
|
+
import { cn as V } from "./cn.js";
|
|
5
|
+
import { useOverlayStack as ne, useEscapeKey as se, Portal as le } from "./overlay.js";
|
|
6
|
+
import { useAnchoredPosition as ie } from "./anchor.js";
|
|
7
|
+
import { typeaheadIndex as oe, endIndex as K, homeIndex as ue, moveIndex as Q } from "./list-nav.js";
|
|
8
|
+
import { usePruiI18n as ce } from "../i18n.js";
|
|
9
|
+
const J = r.createContext(null);
|
|
10
|
+
function $() {
|
|
11
|
+
const o = r.useContext(J);
|
|
12
|
+
if (!o) throw new Error("Select parts must be used inside <Select>");
|
|
13
|
+
return o;
|
|
13
14
|
}
|
|
14
|
-
const
|
|
15
|
-
options:
|
|
16
|
-
value:
|
|
17
|
-
defaultValue:
|
|
18
|
-
placeholder:
|
|
19
|
-
disabled:
|
|
15
|
+
const B = (o) => o === void 0 ? [] : Array.isArray(o) ? o : [o], de = ({
|
|
16
|
+
options: o,
|
|
17
|
+
value: m,
|
|
18
|
+
defaultValue: h,
|
|
19
|
+
placeholder: v = "Select...",
|
|
20
|
+
disabled: g,
|
|
20
21
|
name: l,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
onChange: c,
|
|
23
|
+
onOpenChange: n,
|
|
24
|
+
searchable: f = !1,
|
|
25
|
+
multiple: y = !1,
|
|
26
|
+
id: w,
|
|
27
|
+
children: N,
|
|
28
|
+
...T
|
|
26
29
|
}) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const [A, p] = r.useState(B(h)), [a, j] = r.useState(!1), [R, C] = r.useState(null), [F, M] = r.useState({}), U = m !== void 0, S = U ? B(m) : A, q = (t) => {
|
|
31
|
+
let u;
|
|
32
|
+
y ? u = S.includes(t) ? S.filter((k) => k !== t) : [...S, t] : u = S.includes(t) ? [] : [t], U || p(u), c == null || c(y ? u : u[0] ?? "");
|
|
33
|
+
}, W = (t) => {
|
|
34
|
+
j(t), n == null || n(t);
|
|
35
|
+
}, H = () => R == null ? void 0 : R.focus(), D = (t) => {
|
|
36
|
+
var u;
|
|
37
|
+
return F[t] ?? ((u = o == null ? void 0 : o.find((k) => k.value === t)) == null ? void 0 : u.label);
|
|
38
|
+
}, L = S.length ? S.map((t) => D(t) ?? t).join(", ") : void 0, E = r.useCallback((t, u) => {
|
|
39
|
+
M((k) => {
|
|
40
|
+
if (u === null) {
|
|
41
|
+
if (!(t in k)) return k;
|
|
42
|
+
const z = { ...k };
|
|
43
|
+
return delete z[t], z;
|
|
34
44
|
}
|
|
35
|
-
return
|
|
45
|
+
return k[t] === u ? k : { ...k, [t]: u };
|
|
36
46
|
});
|
|
37
|
-
}, [])
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
S(r), p == null || p(r);
|
|
41
|
-
}, j = () => e == null ? void 0 : e.focus(), t = O[T] ?? ((o = i == null ? void 0 : i.find((r) => r.value === T)) == null ? void 0 : o.label);
|
|
42
|
-
return /* @__PURE__ */ D(
|
|
43
|
-
L.Provider,
|
|
47
|
+
}, []);
|
|
48
|
+
return /* @__PURE__ */ P(
|
|
49
|
+
J.Provider,
|
|
44
50
|
{
|
|
45
|
-
value: {
|
|
51
|
+
value: { values: S, multiple: y, searchable: f, displayValue: L, open: a, triggerEl: R, triggerId: (R == null ? void 0 : R.id) || void 0, toggleValue: q, setOpen: W, registerTrigger: C, returnFocusToTrigger: H, registerLabel: E },
|
|
46
52
|
children: [
|
|
47
|
-
l ? /* @__PURE__ */
|
|
48
|
-
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
/* @__PURE__ */
|
|
53
|
+
l ? /* @__PURE__ */ b("input", { type: "hidden", name: l, value: S.join(",") }) : null,
|
|
54
|
+
N ?? /* @__PURE__ */ P(G, { children: [
|
|
55
|
+
/* @__PURE__ */ b(X, { disabled: g, id: w, ...T, children: /* @__PURE__ */ b(Y, { placeholder: v }) }),
|
|
56
|
+
/* @__PURE__ */ b(Z, { children: (o ?? []).map((t) => /* @__PURE__ */ b(_, { value: t.value, disabled: t.disabled, children: t.label }, t.value)) })
|
|
51
57
|
] })
|
|
52
58
|
]
|
|
53
59
|
}
|
|
54
60
|
);
|
|
55
61
|
};
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
({ className:
|
|
59
|
-
const { open:
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
return /* @__PURE__ */
|
|
62
|
+
de.displayName = "Select";
|
|
63
|
+
const X = r.forwardRef(
|
|
64
|
+
({ className: o, children: m, onClick: h, onKeyDown: v, disabled: g, id: l, ...c }, n) => {
|
|
65
|
+
const { open: f, setOpen: y, registerTrigger: w } = $(), N = r.useRef(null), T = r.useId(), A = l ?? `prui-select-${T}`;
|
|
66
|
+
r.useEffect(() => (w(N.current), () => w(null)), [w]);
|
|
67
|
+
const p = `${A}-listbox`;
|
|
68
|
+
return /* @__PURE__ */ P(
|
|
63
69
|
"button",
|
|
64
70
|
{
|
|
65
|
-
ref: (
|
|
66
|
-
|
|
71
|
+
ref: (a) => {
|
|
72
|
+
N.current = a, typeof n == "function" ? n(a) : n && (n.current = a);
|
|
67
73
|
},
|
|
68
|
-
id:
|
|
74
|
+
id: A,
|
|
69
75
|
type: "button",
|
|
70
76
|
role: "combobox",
|
|
71
|
-
"aria-expanded":
|
|
77
|
+
"aria-expanded": f,
|
|
72
78
|
"aria-haspopup": "listbox",
|
|
73
|
-
"aria-controls":
|
|
74
|
-
disabled:
|
|
75
|
-
"data-state":
|
|
76
|
-
className:
|
|
79
|
+
"aria-controls": f ? p : void 0,
|
|
80
|
+
disabled: g,
|
|
81
|
+
"data-state": f ? "open" : "closed",
|
|
82
|
+
className: V(
|
|
77
83
|
"prui-select-trigger flex h-9 w-full items-center justify-between gap-2 border border-[var(--prui-line)]",
|
|
78
84
|
"bg-[var(--prui-background)] rounded-[var(--prui-radius)] px-3 text-sm text-[var(--prui-fg)]",
|
|
79
85
|
"outline-none transition-colors focus:border-[var(--prui-brand)] focus:ring-2 focus:ring-[var(--prui-brand)]/30",
|
|
80
86
|
"disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",
|
|
81
|
-
|
|
87
|
+
o
|
|
82
88
|
),
|
|
83
|
-
onClick: (
|
|
84
|
-
|
|
89
|
+
onClick: (a) => {
|
|
90
|
+
h == null || h(a), a.defaultPrevented || y(!f);
|
|
85
91
|
},
|
|
86
|
-
onKeyDown: (
|
|
87
|
-
|
|
92
|
+
onKeyDown: (a) => {
|
|
93
|
+
v == null || v(a), !a.defaultPrevented && !f && (a.key === "ArrowDown" || a.key === "ArrowUp" || a.key === "Enter" || a.key === " ") && (a.preventDefault(), y(!0));
|
|
88
94
|
},
|
|
89
|
-
...
|
|
95
|
+
...c,
|
|
90
96
|
children: [
|
|
91
|
-
|
|
92
|
-
/* @__PURE__ */
|
|
97
|
+
m,
|
|
98
|
+
/* @__PURE__ */ b(te, { className: V("h-4 w-4 shrink-0 text-[var(--prui-dim)] transition-transform", f && "rotate-180"), "aria-hidden": !0 })
|
|
93
99
|
]
|
|
94
100
|
}
|
|
95
101
|
);
|
|
96
102
|
}
|
|
97
103
|
);
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
({ className:
|
|
101
|
-
const {
|
|
102
|
-
return /* @__PURE__ */
|
|
104
|
+
X.displayName = "SelectTrigger";
|
|
105
|
+
const Y = r.forwardRef(
|
|
106
|
+
({ className: o, placeholder: m, children: h, ...v }, g) => {
|
|
107
|
+
const { values: l, displayValue: c, multiple: n } = $(), f = l.length === 0;
|
|
108
|
+
return /* @__PURE__ */ b("span", { ref: g, className: V("truncate", o), ...v, children: h ?? (f ? /* @__PURE__ */ b("span", { className: "text-[var(--prui-dim)]", children: m }) : n && l.length > 1 ? /* @__PURE__ */ P(G, { children: [
|
|
109
|
+
/* @__PURE__ */ b("span", { className: "text-[var(--prui-fg)]", children: (c == null ? void 0 : c.split(", ")[0]) ?? l[0] }),
|
|
110
|
+
/* @__PURE__ */ P("span", { className: "ml-1 rounded-[var(--prui-radius-full)] bg-[var(--prui-raise)] px-1.5 text-xs text-[var(--prui-dim)]", children: [
|
|
111
|
+
"+",
|
|
112
|
+
l.length - 1
|
|
113
|
+
] })
|
|
114
|
+
] }) : c ?? l[0]) });
|
|
103
115
|
}
|
|
104
116
|
);
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
({ className:
|
|
108
|
-
const { open: l, setOpen:
|
|
109
|
-
|
|
110
|
-
const [
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
Y.displayName = "SelectValue";
|
|
118
|
+
const Z = r.forwardRef(
|
|
119
|
+
({ className: o, children: m, id: h, ...v }, g) => {
|
|
120
|
+
const { open: l, setOpen: c, triggerEl: n, toggleValue: f, returnFocusToTrigger: y, searchable: w, multiple: N } = $(), T = r.useRef(null), A = r.useRef(null), [p, a] = r.useState(-1), [j, R] = r.useState(""), C = r.useRef({ buffer: "", at: 0 }), F = r.useRef(null);
|
|
121
|
+
F.current = n;
|
|
122
|
+
const [M, U] = r.useState(null), { t: S } = ce(), { setElement: q, isTop: W } = ne(l);
|
|
123
|
+
se(l, W, () => {
|
|
124
|
+
c(!1), y();
|
|
113
125
|
});
|
|
114
|
-
const { ref:
|
|
115
|
-
const
|
|
116
|
-
return
|
|
117
|
-
}, []),
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
const { ref: H, position: D } = ie({ active: l, anchorRef: F, side: "bottom", align: "start" }), L = r.useCallback(() => {
|
|
127
|
+
const e = T.current;
|
|
128
|
+
return e ? Array.from(e.querySelectorAll("[role='option']")) : [];
|
|
129
|
+
}, []), E = r.useCallback(
|
|
130
|
+
() => L().filter((e) => e.style.display !== "none"),
|
|
131
|
+
[L]
|
|
132
|
+
), t = (e) => {
|
|
133
|
+
const s = e.trim().toLowerCase();
|
|
134
|
+
for (const i of L())
|
|
135
|
+
i.style.display = (i.textContent ?? "").toLowerCase().includes(s) ? "" : "none";
|
|
136
|
+
a(-1);
|
|
137
|
+
};
|
|
138
|
+
r.useEffect(() => {
|
|
139
|
+
if (!l) {
|
|
140
|
+
R("");
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
t("");
|
|
144
|
+
}, [l]);
|
|
145
|
+
const u = (e) => {
|
|
146
|
+
var d;
|
|
147
|
+
const s = E();
|
|
148
|
+
if (e < 0 || s.length === 0) return;
|
|
149
|
+
const i = Math.min(e, s.length - 1);
|
|
150
|
+
a(i), (d = s[i]) == null || d.focus();
|
|
120
151
|
};
|
|
121
|
-
if (
|
|
122
|
-
var
|
|
123
|
-
if (!l || !
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
152
|
+
if (r.useEffect(() => {
|
|
153
|
+
var x, I;
|
|
154
|
+
if (!l || !M) return;
|
|
155
|
+
if (a(-1), w) {
|
|
156
|
+
(x = A.current) == null || x.focus();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const e = L(), s = e.findIndex((O) => O.getAttribute("aria-selected") === "true"), i = e.findIndex((O) => O.getAttribute("aria-disabled") !== "true"), d = s >= 0 ? s : i;
|
|
160
|
+
d >= 0 && (a(d), (I = e[d]) == null || I.focus());
|
|
161
|
+
}, [l, M, L, w]), !l) return null;
|
|
162
|
+
const k = (e) => {
|
|
163
|
+
var d;
|
|
164
|
+
if (((d = e.target) == null ? void 0 : d.tagName) === "INPUT") {
|
|
165
|
+
e.key === "Tab" && c(!1);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const s = E(), i = (x) => {
|
|
169
|
+
var I;
|
|
170
|
+
return ((I = s[x]) == null ? void 0 : I.getAttribute("aria-disabled")) !== "true";
|
|
132
171
|
};
|
|
133
|
-
switch (
|
|
172
|
+
switch (e.key) {
|
|
134
173
|
case "ArrowDown":
|
|
135
|
-
|
|
174
|
+
e.preventDefault(), u(Q(p, 1, s.length, { enabled: i }));
|
|
136
175
|
break;
|
|
137
176
|
case "ArrowUp":
|
|
138
|
-
|
|
177
|
+
e.preventDefault(), u(Q(p, -1, s.length, { enabled: i }));
|
|
139
178
|
break;
|
|
140
179
|
case "Home":
|
|
141
|
-
|
|
180
|
+
e.preventDefault(), u(ue(s.length, i));
|
|
142
181
|
break;
|
|
143
182
|
case "End":
|
|
144
|
-
|
|
183
|
+
e.preventDefault(), u(K(s.length, i));
|
|
145
184
|
break;
|
|
146
185
|
case "Enter":
|
|
147
186
|
case " ": {
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
151
|
-
const
|
|
152
|
-
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
const x = s[p];
|
|
189
|
+
if (x && i(p)) {
|
|
190
|
+
const I = x.dataset.value;
|
|
191
|
+
I !== void 0 ? (f(I), N || (c(!1), y())) : x.click();
|
|
153
192
|
}
|
|
154
193
|
break;
|
|
155
194
|
}
|
|
156
195
|
case "Tab":
|
|
157
|
-
|
|
196
|
+
c(!1);
|
|
158
197
|
break;
|
|
159
198
|
default:
|
|
160
|
-
if (
|
|
161
|
-
const
|
|
162
|
-
|
|
199
|
+
if (e.key.length === 1) {
|
|
200
|
+
const x = () => s.map((O) => O.textContent ?? ""), { index: I } = oe(x, C.current, e.key, p);
|
|
201
|
+
I >= 0 && I !== p && (e.preventDefault(), u(I));
|
|
163
202
|
}
|
|
164
203
|
}
|
|
165
|
-
}
|
|
166
|
-
|
|
204
|
+
}, z = (e) => {
|
|
205
|
+
if (e.key === "ArrowDown") {
|
|
206
|
+
e.preventDefault();
|
|
207
|
+
const i = E().findIndex((d) => d.getAttribute("aria-disabled") !== "true");
|
|
208
|
+
i >= 0 && u(i);
|
|
209
|
+
} else if (e.key === "ArrowUp") {
|
|
210
|
+
e.preventDefault();
|
|
211
|
+
const s = E(), i = K(s.length, (d) => {
|
|
212
|
+
var x;
|
|
213
|
+
return ((x = s[d]) == null ? void 0 : x.getAttribute("aria-disabled")) !== "true";
|
|
214
|
+
});
|
|
215
|
+
i >= 0 && u(i);
|
|
216
|
+
} else if (e.key === "Enter") {
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
const s = E(), i = s.findIndex((d) => d.getAttribute("aria-disabled") !== "true");
|
|
219
|
+
if (i >= 0) {
|
|
220
|
+
const d = s[i].dataset.value;
|
|
221
|
+
d !== void 0 && (f(d), N || (c(!1), y()));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}, ee = w && j !== "" && E().length === 0;
|
|
225
|
+
return /* @__PURE__ */ b(le, { children: /* @__PURE__ */ P(
|
|
167
226
|
"div",
|
|
168
227
|
{
|
|
169
|
-
ref: (
|
|
170
|
-
|
|
228
|
+
ref: (e) => {
|
|
229
|
+
T.current = e, U(e), H(e), q(e), typeof g == "function" ? g(e) : g && (g.current = e);
|
|
171
230
|
},
|
|
172
|
-
id:
|
|
231
|
+
id: h ?? (n != null && n.id ? `${n.id}-listbox` : void 0),
|
|
173
232
|
role: "listbox",
|
|
174
233
|
"aria-labelledby": (n == null ? void 0 : n.id) || void 0,
|
|
234
|
+
"aria-multiselectable": N || void 0,
|
|
175
235
|
tabIndex: -1,
|
|
176
236
|
"data-state": l ? "open" : "closed",
|
|
177
|
-
onKeyDown:
|
|
178
|
-
className:
|
|
237
|
+
onKeyDown: k,
|
|
238
|
+
className: V(
|
|
179
239
|
"prui-select-content fixed z-[var(--prui-z-overlay)] max-h-60 overflow-auto p-1",
|
|
180
240
|
"bg-[var(--prui-surface)] border border-[var(--prui-line)] rounded-[var(--prui-radius)] shadow-[var(--prui-shadow-md)] outline-none",
|
|
181
|
-
|
|
241
|
+
o
|
|
182
242
|
),
|
|
183
243
|
style: {
|
|
184
|
-
top: (
|
|
185
|
-
left: (
|
|
244
|
+
top: (D == null ? void 0 : D.top) ?? -9999,
|
|
245
|
+
left: (D == null ? void 0 : D.left) ?? -9999,
|
|
186
246
|
minWidth: n ? Math.max(n.offsetWidth, 160) : 160
|
|
187
247
|
},
|
|
188
|
-
...
|
|
189
|
-
children:
|
|
248
|
+
...v,
|
|
249
|
+
children: [
|
|
250
|
+
w ? /* @__PURE__ */ b("div", { className: "sticky top-0 z-[var(--prui-z-content)] mb-1 bg-[var(--prui-surface)] p-1", children: /* @__PURE__ */ P("div", { className: "relative", children: [
|
|
251
|
+
/* @__PURE__ */ b(re, { className: "pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--prui-dim)]", "aria-hidden": !0 }),
|
|
252
|
+
/* @__PURE__ */ b(
|
|
253
|
+
"input",
|
|
254
|
+
{
|
|
255
|
+
ref: A,
|
|
256
|
+
type: "text",
|
|
257
|
+
role: "searchbox",
|
|
258
|
+
"aria-label": S.search,
|
|
259
|
+
value: j,
|
|
260
|
+
onChange: (e) => {
|
|
261
|
+
R(e.target.value), t(e.target.value);
|
|
262
|
+
},
|
|
263
|
+
onKeyDown: z,
|
|
264
|
+
placeholder: `${S.search}…`,
|
|
265
|
+
className: "h-8 w-full rounded-[calc(var(--prui-radius)-2px)] border border-[var(--prui-line)] bg-[var(--prui-background)] pl-8 pr-2 text-sm text-[var(--prui-fg)] placeholder:text-[var(--prui-dim)] outline-none focus:border-[var(--prui-brand)]"
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
] }) }) : null,
|
|
269
|
+
ee ? /* @__PURE__ */ b("div", { className: "px-3 py-2 text-sm text-[var(--prui-dim)]", role: "option", "aria-selected": "false", "aria-disabled": "true", children: S.noResults }) : m
|
|
270
|
+
]
|
|
190
271
|
}
|
|
191
272
|
) });
|
|
192
273
|
}
|
|
193
274
|
);
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
({ className:
|
|
197
|
-
const {
|
|
198
|
-
return
|
|
199
|
-
|
|
200
|
-
}, [
|
|
275
|
+
Z.displayName = "SelectContent";
|
|
276
|
+
const _ = r.forwardRef(
|
|
277
|
+
({ className: o, value: m, disabled: h, children: v, onClick: g, tabIndex: l = -1, ...c }, n) => {
|
|
278
|
+
const { values: f, toggleValue: y, setOpen: w, returnFocusToTrigger: N, multiple: T, registerLabel: A } = $(), p = f.includes(m), a = typeof v == "string" || typeof v == "number" ? String(v) : void 0;
|
|
279
|
+
return r.useEffect(() => {
|
|
280
|
+
a !== void 0 && A(m, a);
|
|
281
|
+
}, [m, a, A]), /* @__PURE__ */ P(
|
|
201
282
|
"div",
|
|
202
283
|
{
|
|
203
284
|
ref: n,
|
|
204
285
|
role: "option",
|
|
205
|
-
"aria-selected":
|
|
206
|
-
"aria-disabled":
|
|
207
|
-
"data-selected":
|
|
208
|
-
"data-value":
|
|
286
|
+
"aria-selected": p,
|
|
287
|
+
"aria-disabled": h,
|
|
288
|
+
"data-selected": p || void 0,
|
|
289
|
+
"data-value": m,
|
|
209
290
|
tabIndex: l,
|
|
210
|
-
className:
|
|
291
|
+
className: V(
|
|
211
292
|
"prui-select-item relative flex cursor-pointer items-center gap-2 rounded-[calc(var(--prui-radius)-1px)]",
|
|
212
293
|
"py-1.5 pl-3 pr-8 text-sm text-[var(--prui-fg)] hover:bg-[var(--prui-raise)] focus-visible:bg-[var(--prui-raise)] outline-none",
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
294
|
+
p && "font-medium",
|
|
295
|
+
h && "opacity-50 pointer-events-none",
|
|
296
|
+
o
|
|
216
297
|
),
|
|
217
|
-
onClick: (
|
|
218
|
-
|
|
298
|
+
onClick: (j) => {
|
|
299
|
+
g == null || g(j), !(j.defaultPrevented || h) && (y(m), T || (w(!1), N()));
|
|
219
300
|
},
|
|
220
|
-
...
|
|
301
|
+
...c,
|
|
221
302
|
children: [
|
|
222
|
-
|
|
223
|
-
|
|
303
|
+
v,
|
|
304
|
+
p ? /* @__PURE__ */ b(ae, { className: "absolute right-2 h-4 w-4 text-[var(--prui-brand)]", "aria-hidden": !0 }) : null
|
|
224
305
|
]
|
|
225
306
|
}
|
|
226
307
|
);
|
|
227
308
|
}
|
|
228
309
|
);
|
|
229
|
-
|
|
230
|
-
const
|
|
310
|
+
_.displayName = "SelectItem";
|
|
311
|
+
const xe = {
|
|
231
312
|
name: "Select",
|
|
232
313
|
props: [
|
|
233
314
|
{ name: "options", type: "SelectOption[]", default: "[]", control: "object" },
|
|
234
|
-
{ name: "value", type: "string", default: "undefined", control: "text" },
|
|
235
|
-
{ name: "defaultValue", type: "string", default: "undefined", control: "text" },
|
|
315
|
+
{ name: "value", type: "string | string[]", default: "undefined", control: "text" },
|
|
316
|
+
{ name: "defaultValue", type: "string | string[]", default: "undefined", control: "text" },
|
|
236
317
|
{ name: "placeholder", type: "string", default: "'Select...'", control: "text" },
|
|
237
318
|
{ name: "disabled", type: "boolean", default: "false", control: "boolean" },
|
|
238
|
-
{ name: "onChange", type: "(value: string) => void", default: null, control: "none" }
|
|
319
|
+
{ name: "onChange", type: "(value: string | string[]) => void", default: null, control: "none", description: "string in single mode, string[] with multiple." },
|
|
320
|
+
{ name: "searchable", type: "boolean", default: "false", control: "boolean", description: "Adds a filter input to the listbox." },
|
|
321
|
+
{ name: "multiple", type: "boolean", default: "false", control: "boolean", description: "Multi-select; items toggle, value becomes string[]." }
|
|
239
322
|
]
|
|
240
323
|
};
|
|
241
324
|
export {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
325
|
+
de as Select,
|
|
326
|
+
Z as SelectContent,
|
|
327
|
+
_ as SelectItem,
|
|
328
|
+
X as SelectTrigger,
|
|
329
|
+
Y as SelectValue,
|
|
330
|
+
xe as selectPropsMeta
|
|
248
331
|
};
|