saha-ui 1.22.9 → 1.22.10
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/components/Select/index.d.ts +0 -4
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +397 -338
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +396 -389
- package/package.json +2 -2
|
@@ -1,63 +1,96 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { useClickOutside as
|
|
6
|
-
import { X as
|
|
7
|
-
import { selectTriggerVariants as
|
|
8
|
-
const
|
|
1
|
+
import { jsx as e, jsxs as b, Fragment as Le } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Ve, forwardRef as D, useState as L, useRef as I, useCallback as O, useEffect as M, useContext as J } from "react";
|
|
3
|
+
import { createPortal as me } from "react-dom";
|
|
4
|
+
import { cn as p } from "../../lib/utils.js";
|
|
5
|
+
import { useClickOutside as Re } from "../../hooks/useClickOutside.js";
|
|
6
|
+
import { X as pe, ChevronDown as he, Search as Ie, Check as ge } from "lucide-react";
|
|
7
|
+
import { selectTriggerVariants as ye, selectOptionVariants as ae, selectMenuVariants as we } from "./Select.styles.js";
|
|
8
|
+
const U = Ve({
|
|
9
|
+
items: /* @__PURE__ */ new Map(),
|
|
10
|
+
registerItem: () => {
|
|
11
|
+
},
|
|
12
|
+
unregisterItem: () => {
|
|
13
|
+
},
|
|
14
|
+
triggerRef: null
|
|
15
|
+
}), ve = D(
|
|
9
16
|
({
|
|
10
|
-
value:
|
|
11
|
-
defaultValue:
|
|
12
|
-
onValueChange:
|
|
13
|
-
open:
|
|
14
|
-
defaultOpen:
|
|
15
|
-
onOpenChange:
|
|
16
|
-
disabled:
|
|
17
|
-
variant:
|
|
18
|
-
size:
|
|
19
|
-
children:
|
|
20
|
-
className:
|
|
21
|
-
multiple:
|
|
22
|
-
closeOnSelect:
|
|
23
|
-
clearable:
|
|
24
|
-
name:
|
|
25
|
-
},
|
|
26
|
-
const [
|
|
27
|
-
|
|
28
|
-
),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
value: t,
|
|
18
|
+
defaultValue: o,
|
|
19
|
+
onValueChange: g,
|
|
20
|
+
open: n,
|
|
21
|
+
defaultOpen: h,
|
|
22
|
+
onOpenChange: v,
|
|
23
|
+
disabled: d = !1,
|
|
24
|
+
variant: u = "default",
|
|
25
|
+
size: f = "md",
|
|
26
|
+
children: i,
|
|
27
|
+
className: c,
|
|
28
|
+
multiple: s = !1,
|
|
29
|
+
closeOnSelect: y = !0,
|
|
30
|
+
clearable: k = !1,
|
|
31
|
+
name: x
|
|
32
|
+
}, X) => {
|
|
33
|
+
const [V, N] = L(o || (s ? [] : "")), [B, K] = L(
|
|
34
|
+
h || !1
|
|
35
|
+
), [Z, E] = L(/* @__PURE__ */ new Map()), _ = I(null), C = t !== void 0 ? t : V, F = n !== void 0 ? n : B, G = s ? !1 : y, P = O(
|
|
36
|
+
(w) => {
|
|
37
|
+
t === void 0 && N(w), g?.(w);
|
|
38
|
+
},
|
|
39
|
+
[t, g]
|
|
40
|
+
), Q = O(
|
|
41
|
+
(w) => {
|
|
42
|
+
n === void 0 && K(w), v?.(w);
|
|
43
|
+
},
|
|
44
|
+
[n, v]
|
|
45
|
+
), W = O(
|
|
46
|
+
(w, z) => {
|
|
47
|
+
E((j) => {
|
|
48
|
+
const $ = new Map(j);
|
|
49
|
+
return $.set(w, z), $;
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
[]
|
|
53
|
+
), ee = O((w) => {
|
|
54
|
+
E((z) => {
|
|
55
|
+
const j = new Map(z);
|
|
56
|
+
return j.delete(w), j;
|
|
57
|
+
});
|
|
58
|
+
}, []), te = O(
|
|
59
|
+
(w) => {
|
|
60
|
+
w.stopPropagation(), P(s ? [] : "");
|
|
61
|
+
},
|
|
62
|
+
[s, P]
|
|
63
|
+
), Y = s ? Array.isArray(C) && C.length > 0 : !!C;
|
|
33
64
|
return /* @__PURE__ */ e(
|
|
34
|
-
|
|
65
|
+
U.Provider,
|
|
35
66
|
{
|
|
36
67
|
value: {
|
|
37
|
-
value:
|
|
38
|
-
onValueChange:
|
|
39
|
-
open:
|
|
40
|
-
onOpenChange:
|
|
41
|
-
disabled:
|
|
42
|
-
variant:
|
|
43
|
-
size:
|
|
44
|
-
multiple:
|
|
45
|
-
closeOnSelect: G
|
|
68
|
+
value: C,
|
|
69
|
+
onValueChange: P,
|
|
70
|
+
open: F,
|
|
71
|
+
onOpenChange: Q,
|
|
72
|
+
disabled: d,
|
|
73
|
+
variant: u,
|
|
74
|
+
size: f,
|
|
75
|
+
multiple: s,
|
|
76
|
+
closeOnSelect: G,
|
|
77
|
+
items: Z,
|
|
78
|
+
registerItem: W,
|
|
79
|
+
unregisterItem: ee,
|
|
80
|
+
triggerRef: _
|
|
46
81
|
},
|
|
47
|
-
children: /* @__PURE__ */
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
children: /* @__PURE__ */ b("div", { ref: X, className: p("relative", c), children: [
|
|
83
|
+
i,
|
|
84
|
+
x && s && Array.isArray(C) && C.map((w) => /* @__PURE__ */ e("input", { type: "hidden", name: x, value: w }, w)),
|
|
85
|
+
x && !s && C && /* @__PURE__ */ e("input", { type: "hidden", name: x, value: String(C) }),
|
|
86
|
+
k && !d && Y && /* @__PURE__ */ e(
|
|
52
87
|
"button",
|
|
53
88
|
{
|
|
54
89
|
type: "button",
|
|
55
|
-
onClick:
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
className: "absolute right-10 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-foreground/10 transition-colors",
|
|
90
|
+
onClick: te,
|
|
91
|
+
className: "absolute right-10 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-foreground/10 transition-colors z-10",
|
|
59
92
|
"aria-label": "Clear selection",
|
|
60
|
-
children: /* @__PURE__ */ e(
|
|
93
|
+
children: /* @__PURE__ */ e(pe, { className: "w-4 h-4" })
|
|
61
94
|
}
|
|
62
95
|
)
|
|
63
96
|
] })
|
|
@@ -65,282 +98,289 @@ const P = Ae({}), pe = L(
|
|
|
65
98
|
);
|
|
66
99
|
}
|
|
67
100
|
);
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
(
|
|
101
|
+
ve.displayName = "SelectComposable";
|
|
102
|
+
const xe = D(
|
|
103
|
+
(t, o) => {
|
|
71
104
|
const {
|
|
72
|
-
label:
|
|
73
|
-
description:
|
|
74
|
-
placeholder:
|
|
75
|
-
error:
|
|
76
|
-
helperText:
|
|
77
|
-
value:
|
|
78
|
-
defaultValue:
|
|
79
|
-
onChange:
|
|
80
|
-
options:
|
|
81
|
-
multiple:
|
|
82
|
-
searchable:
|
|
83
|
-
clearable:
|
|
84
|
-
disabled:
|
|
85
|
-
required:
|
|
86
|
-
loading:
|
|
87
|
-
variant:
|
|
88
|
-
size:
|
|
89
|
-
fullWidth:
|
|
90
|
-
maxHeight:
|
|
91
|
-
maxSelections:
|
|
92
|
-
closeOnSelect:
|
|
93
|
-
showCheckmarks:
|
|
94
|
-
creatable:
|
|
95
|
-
onCreateOption:
|
|
96
|
-
renderOption:
|
|
97
|
-
renderValue:
|
|
98
|
-
icon:
|
|
99
|
-
clearIcon:
|
|
100
|
-
dropdownIcon:
|
|
101
|
-
name:
|
|
102
|
-
id:
|
|
103
|
-
className:
|
|
104
|
-
menuClassName:
|
|
105
|
-
optionClassName:
|
|
106
|
-
} =
|
|
105
|
+
label: g,
|
|
106
|
+
description: n,
|
|
107
|
+
placeholder: h = "Select an option...",
|
|
108
|
+
error: v,
|
|
109
|
+
helperText: d,
|
|
110
|
+
value: u,
|
|
111
|
+
defaultValue: f,
|
|
112
|
+
onChange: i,
|
|
113
|
+
options: c = [],
|
|
114
|
+
multiple: s = !1,
|
|
115
|
+
searchable: y = !1,
|
|
116
|
+
clearable: k = !1,
|
|
117
|
+
disabled: x = !1,
|
|
118
|
+
required: X = !1,
|
|
119
|
+
loading: V = !1,
|
|
120
|
+
variant: N = "default",
|
|
121
|
+
size: B = "md",
|
|
122
|
+
fullWidth: K = !0,
|
|
123
|
+
maxHeight: Z = "300px",
|
|
124
|
+
maxSelections: E,
|
|
125
|
+
closeOnSelect: _ = !0,
|
|
126
|
+
showCheckmarks: C = !0,
|
|
127
|
+
creatable: F = !1,
|
|
128
|
+
onCreateOption: G,
|
|
129
|
+
renderOption: P,
|
|
130
|
+
renderValue: Q,
|
|
131
|
+
icon: W,
|
|
132
|
+
clearIcon: ee,
|
|
133
|
+
dropdownIcon: te,
|
|
134
|
+
name: Y,
|
|
135
|
+
id: w,
|
|
136
|
+
className: z,
|
|
137
|
+
menuClassName: j,
|
|
138
|
+
optionClassName: $
|
|
139
|
+
} = t, [S, q] = L(!1), [A, re] = L(""), [be, le] = L(f || (s ? [] : "")), [H, Ne] = L({
|
|
107
140
|
top: 0,
|
|
108
141
|
left: 0,
|
|
109
142
|
width: 0
|
|
110
|
-
}),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
143
|
+
}), oe = s ? !1 : _, T = u !== void 0, m = T ? u : be, ie = I(null), ne = I(null), se = I(null), ce = I(null);
|
|
144
|
+
Re(
|
|
145
|
+
ie,
|
|
146
|
+
() => {
|
|
147
|
+
S && q(!1);
|
|
148
|
+
},
|
|
149
|
+
[ce]
|
|
150
|
+
), M(() => {
|
|
151
|
+
S && y && se.current && se.current.focus();
|
|
152
|
+
}, [S, y]), M(() => {
|
|
153
|
+
if (S && ne.current) {
|
|
154
|
+
const r = () => {
|
|
155
|
+
const l = ne.current?.getBoundingClientRect();
|
|
156
|
+
l && Ne({
|
|
157
|
+
top: l.bottom + window.scrollY,
|
|
158
|
+
left: l.left + window.scrollX,
|
|
159
|
+
width: l.width
|
|
123
160
|
});
|
|
124
161
|
};
|
|
125
|
-
return
|
|
126
|
-
window.removeEventListener("scroll",
|
|
162
|
+
return r(), window.addEventListener("scroll", r, !0), window.addEventListener("resize", r), () => {
|
|
163
|
+
window.removeEventListener("scroll", r, !0), window.removeEventListener("resize", r);
|
|
127
164
|
};
|
|
128
165
|
}
|
|
129
|
-
}, [
|
|
130
|
-
const
|
|
131
|
-
(
|
|
132
|
-
) :
|
|
133
|
-
(
|
|
134
|
-
const a =
|
|
135
|
-
return
|
|
166
|
+
}, [S]);
|
|
167
|
+
const de = A ? c.filter(
|
|
168
|
+
(r) => r.label.toLowerCase().includes(A.toLowerCase()) || r.description?.toLowerCase().includes(A.toLowerCase())
|
|
169
|
+
) : c, Ce = de.reduce(
|
|
170
|
+
(r, l) => {
|
|
171
|
+
const a = l.group || "default";
|
|
172
|
+
return r[a] || (r[a] = []), r[a].push(l), r;
|
|
136
173
|
},
|
|
137
174
|
{}
|
|
138
|
-
),
|
|
139
|
-
(
|
|
140
|
-
if (
|
|
141
|
-
let
|
|
142
|
-
if (
|
|
143
|
-
const a = Array.isArray(
|
|
144
|
-
if (a.includes(
|
|
145
|
-
|
|
175
|
+
), ue = O(
|
|
176
|
+
(r) => {
|
|
177
|
+
if (x) return;
|
|
178
|
+
let l;
|
|
179
|
+
if (s) {
|
|
180
|
+
const a = Array.isArray(m) ? m : [];
|
|
181
|
+
if (a.includes(r))
|
|
182
|
+
l = a.filter((R) => R !== r);
|
|
146
183
|
else {
|
|
147
|
-
if (
|
|
184
|
+
if (E && a.length >= E)
|
|
148
185
|
return;
|
|
149
|
-
|
|
186
|
+
l = [...a, r];
|
|
150
187
|
}
|
|
151
188
|
} else
|
|
152
|
-
|
|
153
|
-
|
|
189
|
+
l = r, oe && q(!1);
|
|
190
|
+
T || le(l), i && i(l), y && re("");
|
|
154
191
|
},
|
|
155
192
|
[
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
193
|
+
x,
|
|
194
|
+
s,
|
|
195
|
+
m,
|
|
196
|
+
E,
|
|
197
|
+
oe,
|
|
198
|
+
T,
|
|
199
|
+
i,
|
|
200
|
+
y
|
|
164
201
|
]
|
|
165
|
-
),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
202
|
+
), Se = O(
|
|
203
|
+
(r) => {
|
|
204
|
+
r.stopPropagation();
|
|
205
|
+
const l = s ? [] : "";
|
|
206
|
+
T || le(l), i && i(l);
|
|
207
|
+
},
|
|
208
|
+
[s, T, i]
|
|
209
|
+
), ke = () => {
|
|
210
|
+
F && A && G && (G(A), re(""), q(!1));
|
|
211
|
+
}, Ae = (r) => s && Array.isArray(m) ? m.includes(r) : m === r, Oe = () => {
|
|
212
|
+
if (Q)
|
|
213
|
+
return Q(m);
|
|
214
|
+
if (s && Array.isArray(m) && m.length > 0) {
|
|
215
|
+
const r = c.filter(
|
|
216
|
+
(l) => m.includes(l.value)
|
|
177
217
|
);
|
|
178
|
-
return
|
|
218
|
+
return r.length === 1 ? r[0].label : `${r.length} selected`;
|
|
179
219
|
}
|
|
180
|
-
return !
|
|
181
|
-
(
|
|
182
|
-
)?.label ||
|
|
183
|
-
},
|
|
184
|
-
return /* @__PURE__ */
|
|
185
|
-
(
|
|
186
|
-
|
|
220
|
+
return !s && m ? c.find(
|
|
221
|
+
(l) => l.value === m
|
|
222
|
+
)?.label || m : h;
|
|
223
|
+
}, fe = s ? Array.isArray(m) && m.length > 0 : !!m;
|
|
224
|
+
return /* @__PURE__ */ b("div", { ref: o, className: p("flex flex-col gap-2", z), children: [
|
|
225
|
+
(g || n) && /* @__PURE__ */ b("div", { className: "flex flex-col gap-1", children: [
|
|
226
|
+
g && /* @__PURE__ */ e(
|
|
187
227
|
"label",
|
|
188
228
|
{
|
|
189
|
-
htmlFor:
|
|
190
|
-
className:
|
|
229
|
+
htmlFor: w,
|
|
230
|
+
className: p(
|
|
191
231
|
"text-sm font-semibold text-foreground",
|
|
192
|
-
|
|
232
|
+
X && "after:content-['*'] after:ml-1 after:text-destructive"
|
|
193
233
|
),
|
|
194
|
-
children:
|
|
234
|
+
children: g
|
|
195
235
|
}
|
|
196
236
|
),
|
|
197
|
-
|
|
237
|
+
n && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: n })
|
|
198
238
|
] }),
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
/* @__PURE__ */
|
|
239
|
+
/* @__PURE__ */ b("div", { ref: ie, className: "relative", children: [
|
|
240
|
+
/* @__PURE__ */ b(
|
|
201
241
|
"button",
|
|
202
242
|
{
|
|
203
|
-
ref:
|
|
243
|
+
ref: ne,
|
|
204
244
|
type: "button",
|
|
205
|
-
id:
|
|
206
|
-
onClick: () => !
|
|
207
|
-
className:
|
|
208
|
-
|
|
209
|
-
variant:
|
|
210
|
-
size:
|
|
211
|
-
error: !!
|
|
212
|
-
fullWidth:
|
|
245
|
+
id: w,
|
|
246
|
+
onClick: () => !x && q(!S),
|
|
247
|
+
className: p(
|
|
248
|
+
ye({
|
|
249
|
+
variant: N,
|
|
250
|
+
size: B,
|
|
251
|
+
error: !!v,
|
|
252
|
+
fullWidth: K
|
|
213
253
|
})
|
|
214
254
|
),
|
|
215
|
-
disabled:
|
|
255
|
+
disabled: x,
|
|
216
256
|
"aria-haspopup": "listbox",
|
|
217
|
-
"aria-expanded":
|
|
257
|
+
"aria-expanded": S,
|
|
218
258
|
children: [
|
|
219
|
-
|
|
259
|
+
W && /* @__PURE__ */ e("span", { className: "shrink-0", children: W }),
|
|
220
260
|
/* @__PURE__ */ e(
|
|
221
261
|
"span",
|
|
222
262
|
{
|
|
223
|
-
className:
|
|
263
|
+
className: p(
|
|
224
264
|
"flex-1 text-left truncate",
|
|
225
|
-
!
|
|
265
|
+
!fe && "text-muted-foreground"
|
|
226
266
|
),
|
|
227
|
-
children:
|
|
267
|
+
children: V ? "Loading..." : Oe()
|
|
228
268
|
}
|
|
229
269
|
),
|
|
230
270
|
/* @__PURE__ */ e(
|
|
231
271
|
"span",
|
|
232
272
|
{
|
|
233
|
-
className:
|
|
273
|
+
className: p(
|
|
234
274
|
"transition-transform duration-200",
|
|
235
|
-
|
|
275
|
+
S && "rotate-180"
|
|
236
276
|
),
|
|
237
|
-
children:
|
|
277
|
+
children: te || /* @__PURE__ */ e(he, { className: "w-5 h-5" })
|
|
238
278
|
}
|
|
239
279
|
)
|
|
240
280
|
]
|
|
241
281
|
}
|
|
242
282
|
),
|
|
243
|
-
|
|
283
|
+
k && fe && !x && /* @__PURE__ */ e(
|
|
244
284
|
"button",
|
|
245
285
|
{
|
|
246
286
|
type: "button",
|
|
247
|
-
onClick:
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
className: "absolute right-10 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-foreground/10 transition-colors",
|
|
287
|
+
onClick: Se,
|
|
288
|
+
className: "absolute right-10 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-foreground/10 transition-colors z-10",
|
|
251
289
|
"aria-label": "Clear selection",
|
|
252
|
-
children:
|
|
290
|
+
children: ee || /* @__PURE__ */ e(pe, { className: "w-4 h-4" })
|
|
253
291
|
}
|
|
254
292
|
),
|
|
255
|
-
|
|
256
|
-
/* @__PURE__ */
|
|
293
|
+
S && !x && typeof window < "u" && me(
|
|
294
|
+
/* @__PURE__ */ b(
|
|
257
295
|
"div",
|
|
258
296
|
{
|
|
259
|
-
|
|
297
|
+
ref: ce,
|
|
298
|
+
className: p(we({ variant: N }), j),
|
|
260
299
|
style: {
|
|
261
300
|
position: "absolute",
|
|
262
|
-
top: `${
|
|
263
|
-
left: `${
|
|
264
|
-
width: `${
|
|
301
|
+
top: `${H.top}px`,
|
|
302
|
+
left: `${H.left}px`,
|
|
303
|
+
width: `${H.width}px`,
|
|
265
304
|
zIndex: 9999,
|
|
266
|
-
opacity:
|
|
305
|
+
opacity: H.width > 0 ? 1 : 0,
|
|
267
306
|
transition: "opacity 0.15s ease-out"
|
|
268
307
|
},
|
|
269
308
|
role: "listbox",
|
|
270
|
-
"aria-multiselectable":
|
|
309
|
+
"aria-multiselectable": s,
|
|
271
310
|
children: [
|
|
272
|
-
|
|
273
|
-
/* @__PURE__ */ e(
|
|
311
|
+
y && /* @__PURE__ */ e("div", { className: "p-2 border-b-2 border-border/50", children: /* @__PURE__ */ b("div", { className: "relative", children: [
|
|
312
|
+
/* @__PURE__ */ e(Ie, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" }),
|
|
274
313
|
/* @__PURE__ */ e(
|
|
275
314
|
"input",
|
|
276
315
|
{
|
|
277
|
-
ref:
|
|
316
|
+
ref: se,
|
|
278
317
|
type: "text",
|
|
279
|
-
value:
|
|
280
|
-
onChange: (
|
|
318
|
+
value: A,
|
|
319
|
+
onChange: (r) => re(r.target.value),
|
|
281
320
|
placeholder: "Search...",
|
|
282
321
|
className: "w-full pl-10 pr-4 py-2 bg-background/50 rounded-md border-2 border-border/50 focus:border-primary focus:outline-none transition-colors"
|
|
283
322
|
}
|
|
284
323
|
)
|
|
285
324
|
] }) }),
|
|
286
|
-
/* @__PURE__ */ e("div", { className: "overflow-y-auto", style: { maxHeight:
|
|
325
|
+
/* @__PURE__ */ e("div", { className: "overflow-y-auto", style: { maxHeight: Z }, children: de.length === 0 ? /* @__PURE__ */ e("div", { className: "px-4 py-8 text-center text-muted-foreground", children: A ? /* @__PURE__ */ b(Le, { children: [
|
|
287
326
|
/* @__PURE__ */ e("p", { children: "No results found" }),
|
|
288
|
-
|
|
327
|
+
F && /* @__PURE__ */ b(
|
|
289
328
|
"button",
|
|
290
329
|
{
|
|
291
|
-
|
|
330
|
+
type: "button",
|
|
331
|
+
onClick: ke,
|
|
292
332
|
className: "mt-2 text-primary hover:underline",
|
|
293
333
|
children: [
|
|
294
334
|
'Create "',
|
|
295
|
-
|
|
335
|
+
A,
|
|
296
336
|
'"'
|
|
297
337
|
]
|
|
298
338
|
}
|
|
299
339
|
)
|
|
300
|
-
] }) : "No options available" }) : Object.entries(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
return
|
|
340
|
+
] }) : "No options available" }) : Object.entries(Ce).map(([r, l]) => /* @__PURE__ */ b("div", { children: [
|
|
341
|
+
r !== "default" && /* @__PURE__ */ e("div", { className: "px-4 py-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider bg-foreground/5", children: r }),
|
|
342
|
+
l.map((a) => {
|
|
343
|
+
const R = Ae(a.value);
|
|
344
|
+
return P ? /* @__PURE__ */ e(
|
|
305
345
|
"div",
|
|
306
346
|
{
|
|
307
|
-
onClick: () => !a.disabled &&
|
|
308
|
-
className:
|
|
309
|
-
|
|
310
|
-
variant:
|
|
347
|
+
onClick: () => !a.disabled && ue(a.value),
|
|
348
|
+
className: p(
|
|
349
|
+
ae({
|
|
350
|
+
variant: N,
|
|
311
351
|
disabled: a.disabled
|
|
312
352
|
}),
|
|
313
|
-
|
|
353
|
+
$
|
|
314
354
|
),
|
|
315
|
-
"data-selected":
|
|
355
|
+
"data-selected": R,
|
|
316
356
|
role: "option",
|
|
317
|
-
"aria-selected":
|
|
318
|
-
children:
|
|
357
|
+
"aria-selected": R,
|
|
358
|
+
children: P(a)
|
|
319
359
|
},
|
|
320
360
|
a.value
|
|
321
|
-
) : /* @__PURE__ */
|
|
361
|
+
) : /* @__PURE__ */ b(
|
|
322
362
|
"div",
|
|
323
363
|
{
|
|
324
|
-
onClick: () => !a.disabled &&
|
|
325
|
-
className:
|
|
326
|
-
|
|
327
|
-
variant:
|
|
364
|
+
onClick: () => !a.disabled && ue(a.value),
|
|
365
|
+
className: p(
|
|
366
|
+
ae({
|
|
367
|
+
variant: N,
|
|
328
368
|
disabled: a.disabled
|
|
329
369
|
}),
|
|
330
|
-
|
|
370
|
+
$
|
|
331
371
|
),
|
|
332
|
-
"data-selected":
|
|
372
|
+
"data-selected": R,
|
|
333
373
|
role: "option",
|
|
334
|
-
"aria-selected":
|
|
374
|
+
"aria-selected": R,
|
|
335
375
|
children: [
|
|
336
|
-
|
|
376
|
+
C && /* @__PURE__ */ e(
|
|
337
377
|
"span",
|
|
338
378
|
{
|
|
339
|
-
className:
|
|
379
|
+
className: p(
|
|
340
380
|
"shrink-0 w-5 h-5 flex items-center justify-center",
|
|
341
|
-
|
|
381
|
+
R ? "opacity-100" : "opacity-0"
|
|
342
382
|
),
|
|
343
|
-
children: /* @__PURE__ */ e(
|
|
383
|
+
children: /* @__PURE__ */ e(ge, { className: "w-4 h-4" })
|
|
344
384
|
}
|
|
345
385
|
),
|
|
346
386
|
a.avatar && /* @__PURE__ */ e(
|
|
@@ -352,7 +392,7 @@ const me = L(
|
|
|
352
392
|
}
|
|
353
393
|
),
|
|
354
394
|
a.icon && /* @__PURE__ */ e("span", { className: "shrink-0", children: a.icon }),
|
|
355
|
-
/* @__PURE__ */
|
|
395
|
+
/* @__PURE__ */ b("div", { className: "flex-1 min-w-0", children: [
|
|
356
396
|
/* @__PURE__ */ e("div", { className: "font-medium truncate", children: a.label }),
|
|
357
397
|
a.description && /* @__PURE__ */ e("div", { className: "text-sm text-muted-foreground truncate", children: a.description })
|
|
358
398
|
] })
|
|
@@ -361,60 +401,65 @@ const me = L(
|
|
|
361
401
|
a.value
|
|
362
402
|
);
|
|
363
403
|
})
|
|
364
|
-
] },
|
|
404
|
+
] }, r)) })
|
|
365
405
|
]
|
|
366
406
|
}
|
|
367
407
|
),
|
|
368
408
|
document.body
|
|
369
409
|
)
|
|
370
410
|
] }),
|
|
371
|
-
|
|
411
|
+
Y && /* @__PURE__ */ e(
|
|
372
412
|
"input",
|
|
373
413
|
{
|
|
374
414
|
type: "hidden",
|
|
375
|
-
name:
|
|
376
|
-
value: Array.isArray(
|
|
415
|
+
name: Y,
|
|
416
|
+
value: Array.isArray(m) ? m.join(",") : m
|
|
377
417
|
}
|
|
378
418
|
),
|
|
379
|
-
|
|
380
|
-
!
|
|
419
|
+
v && /* @__PURE__ */ e("p", { className: "text-sm text-destructive font-medium", children: v }),
|
|
420
|
+
!v && d && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: d })
|
|
381
421
|
] });
|
|
382
422
|
}
|
|
383
423
|
);
|
|
384
|
-
|
|
385
|
-
const Ee =
|
|
424
|
+
xe.displayName = "SelectPropsBase";
|
|
425
|
+
const Ee = D((t, o) => !t.options && t.children ? /* @__PURE__ */ e(ve, { ...t, ref: o }) : /* @__PURE__ */ e(xe, { ...t, ref: o }));
|
|
386
426
|
Ee.displayName = "Select";
|
|
387
|
-
const
|
|
388
|
-
({ children:
|
|
389
|
-
const
|
|
390
|
-
|
|
427
|
+
const Pe = D(
|
|
428
|
+
({ children: t, className: o, ...g }, n) => {
|
|
429
|
+
const h = J(U), v = I(null), d = O(
|
|
430
|
+
(y) => {
|
|
431
|
+
v.current = y, typeof n == "function" ? n(y) : n && (n.current = y), h.triggerRef && (h.triggerRef.current = y);
|
|
432
|
+
},
|
|
433
|
+
[n, h.triggerRef]
|
|
434
|
+
), { disabled: u, onOpenChange: f, open: i, variant: c, size: s } = h;
|
|
435
|
+
return /* @__PURE__ */ b(
|
|
391
436
|
"button",
|
|
392
437
|
{
|
|
393
|
-
ref:
|
|
438
|
+
ref: d,
|
|
394
439
|
type: "button",
|
|
395
|
-
onClick: () => !
|
|
396
|
-
disabled:
|
|
397
|
-
className:
|
|
398
|
-
|
|
399
|
-
variant:
|
|
400
|
-
size: s
|
|
440
|
+
onClick: () => !u && f?.(!i),
|
|
441
|
+
disabled: u,
|
|
442
|
+
className: p(
|
|
443
|
+
ye({
|
|
444
|
+
variant: c,
|
|
445
|
+
size: s,
|
|
401
446
|
fullWidth: !0
|
|
402
447
|
}),
|
|
403
448
|
"justify-between",
|
|
404
|
-
|
|
449
|
+
o
|
|
405
450
|
),
|
|
406
451
|
"aria-haspopup": "listbox",
|
|
407
|
-
"aria-expanded":
|
|
452
|
+
"aria-expanded": i,
|
|
408
453
|
"data-select-trigger": "true",
|
|
409
|
-
...
|
|
454
|
+
...g,
|
|
410
455
|
children: [
|
|
411
|
-
|
|
456
|
+
t,
|
|
412
457
|
/* @__PURE__ */ e(
|
|
413
|
-
|
|
458
|
+
he,
|
|
414
459
|
{
|
|
415
|
-
className:
|
|
460
|
+
className: p(
|
|
416
461
|
"h-4 w-4 opacity-50 transition-transform duration-200",
|
|
417
|
-
|
|
462
|
+
i && "rotate-180"
|
|
418
463
|
)
|
|
419
464
|
}
|
|
420
465
|
)
|
|
@@ -423,147 +468,161 @@ const ze = L(
|
|
|
423
468
|
);
|
|
424
469
|
}
|
|
425
470
|
);
|
|
426
|
-
|
|
427
|
-
const
|
|
428
|
-
const
|
|
429
|
-
let
|
|
430
|
-
|
|
431
|
-
const
|
|
471
|
+
Pe.displayName = "SelectTrigger";
|
|
472
|
+
const ze = ({ placeholder: t, className: o }) => {
|
|
473
|
+
const g = J(U), { value: n, multiple: h, items: v } = g, d = (i) => v.get(i)?.label || i;
|
|
474
|
+
let u = t;
|
|
475
|
+
h && Array.isArray(n) ? n.length === 0 ? u = t : n.length === 1 ? u = d(n[0]) : u = `${n.length} selected` : !h && n && typeof n == "string" && (u = d(n));
|
|
476
|
+
const f = Array.isArray(n) ? n.length > 0 : !!n;
|
|
432
477
|
return /* @__PURE__ */ e(
|
|
433
478
|
"span",
|
|
434
479
|
{
|
|
435
|
-
className:
|
|
480
|
+
className: p(
|
|
436
481
|
"block truncate text-left",
|
|
437
|
-
!
|
|
438
|
-
|
|
482
|
+
!f && "text-muted-foreground",
|
|
483
|
+
o
|
|
439
484
|
),
|
|
440
|
-
children:
|
|
485
|
+
children: u
|
|
441
486
|
}
|
|
442
487
|
);
|
|
443
488
|
};
|
|
444
|
-
|
|
445
|
-
const
|
|
446
|
-
const
|
|
447
|
-
return
|
|
448
|
-
if (!
|
|
449
|
-
const
|
|
450
|
-
const
|
|
451
|
-
|
|
489
|
+
ze.displayName = "SelectValue";
|
|
490
|
+
const je = ({ children: t, className: o }) => {
|
|
491
|
+
const g = J(U), n = I(null), [h, v] = L({ top: 0, left: 0, width: 0 }), { open: d, onOpenChange: u, triggerRef: f, variant: i } = g;
|
|
492
|
+
return M(() => {
|
|
493
|
+
if (!d) return;
|
|
494
|
+
const c = (y) => {
|
|
495
|
+
const k = y.target;
|
|
496
|
+
n.current?.contains(k) || f?.current?.contains(k) || u?.(!1);
|
|
497
|
+
}, s = setTimeout(() => {
|
|
498
|
+
document.addEventListener("mousedown", c);
|
|
499
|
+
}, 0);
|
|
500
|
+
return () => {
|
|
501
|
+
clearTimeout(s), document.removeEventListener("mousedown", c);
|
|
452
502
|
};
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
};
|
|
468
|
-
return v(), window.addEventListener("scroll", v, !0), window.addEventListener("resize", v), () => {
|
|
469
|
-
window.removeEventListener("scroll", v, !0), window.removeEventListener("resize", v);
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}, [o.open]), !o.open || typeof window > "u" ? null : oe(
|
|
503
|
+
}, [d, u, f]), M(() => {
|
|
504
|
+
if (!d || !f?.current) return;
|
|
505
|
+
const c = () => {
|
|
506
|
+
const s = f?.current?.getBoundingClientRect();
|
|
507
|
+
s && v({
|
|
508
|
+
top: s.bottom + window.scrollY,
|
|
509
|
+
left: s.left + window.scrollX,
|
|
510
|
+
width: s.width
|
|
511
|
+
});
|
|
512
|
+
};
|
|
513
|
+
return c(), window.addEventListener("scroll", c, !0), window.addEventListener("resize", c), () => {
|
|
514
|
+
window.removeEventListener("scroll", c, !0), window.removeEventListener("resize", c);
|
|
515
|
+
};
|
|
516
|
+
}, [d, f]), !d || typeof window > "u" ? null : me(
|
|
474
517
|
/* @__PURE__ */ e(
|
|
475
518
|
"div",
|
|
476
519
|
{
|
|
477
|
-
ref:
|
|
478
|
-
className:
|
|
479
|
-
fe({ variant: o.variant }),
|
|
480
|
-
u
|
|
481
|
-
),
|
|
520
|
+
ref: n,
|
|
521
|
+
className: p(we({ variant: i }), o),
|
|
482
522
|
style: {
|
|
483
523
|
position: "absolute",
|
|
484
|
-
top: `${
|
|
485
|
-
left: `${
|
|
486
|
-
width: `${
|
|
524
|
+
top: `${h.top}px`,
|
|
525
|
+
left: `${h.left}px`,
|
|
526
|
+
width: `${h.width}px`,
|
|
487
527
|
zIndex: 9999,
|
|
488
|
-
opacity:
|
|
528
|
+
opacity: h.width > 0 ? 1 : 0,
|
|
489
529
|
transition: "opacity 0.15s ease-out"
|
|
490
530
|
},
|
|
491
531
|
role: "listbox",
|
|
492
|
-
children: /* @__PURE__ */ e("div", { className: "overflow-y-auto max-h-[300px]", children:
|
|
532
|
+
children: /* @__PURE__ */ e("div", { className: "overflow-y-auto max-h-[300px]", children: t })
|
|
493
533
|
}
|
|
494
534
|
),
|
|
495
535
|
document.body
|
|
496
536
|
);
|
|
497
537
|
};
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
({ value:
|
|
501
|
-
const
|
|
502
|
-
|
|
538
|
+
je.displayName = "SelectContent";
|
|
539
|
+
const Be = D(
|
|
540
|
+
({ value: t, children: o, disabled: g, className: n }, h) => {
|
|
541
|
+
const v = J(U), {
|
|
542
|
+
registerItem: d,
|
|
543
|
+
multiple: u,
|
|
544
|
+
value: f,
|
|
545
|
+
onValueChange: i,
|
|
546
|
+
closeOnSelect: c,
|
|
547
|
+
onOpenChange: s,
|
|
548
|
+
disabled: y,
|
|
549
|
+
variant: k
|
|
550
|
+
} = v;
|
|
551
|
+
M(() => {
|
|
552
|
+
d(t, {
|
|
553
|
+
value: t,
|
|
554
|
+
label: o,
|
|
555
|
+
disabled: g
|
|
556
|
+
});
|
|
557
|
+
}, [t, o, g, d]);
|
|
558
|
+
const x = u ? Array.isArray(f) && f.includes(t) : f === t;
|
|
559
|
+
return /* @__PURE__ */ b(
|
|
503
560
|
"div",
|
|
504
561
|
{
|
|
505
|
-
ref:
|
|
562
|
+
ref: h,
|
|
506
563
|
onClick: () => {
|
|
507
|
-
if (!(
|
|
508
|
-
if (
|
|
509
|
-
const
|
|
510
|
-
let
|
|
511
|
-
|
|
564
|
+
if (!(g || y)) {
|
|
565
|
+
if (u) {
|
|
566
|
+
const V = Array.isArray(f) ? f : [];
|
|
567
|
+
let N;
|
|
568
|
+
V.includes(t) ? N = V.filter((B) => B !== t) : N = [...V, t], i?.(N);
|
|
512
569
|
} else
|
|
513
|
-
|
|
570
|
+
i?.(t);
|
|
571
|
+
c && s?.(!1);
|
|
572
|
+
}
|
|
514
573
|
},
|
|
515
|
-
className:
|
|
516
|
-
|
|
517
|
-
variant:
|
|
518
|
-
disabled:
|
|
574
|
+
className: p(
|
|
575
|
+
ae({
|
|
576
|
+
variant: k,
|
|
577
|
+
disabled: g || y
|
|
519
578
|
}),
|
|
520
579
|
"flex items-center gap-2 cursor-pointer",
|
|
521
|
-
|
|
580
|
+
n
|
|
522
581
|
),
|
|
523
|
-
"data-selected":
|
|
582
|
+
"data-selected": x,
|
|
524
583
|
role: "option",
|
|
525
|
-
"aria-selected":
|
|
584
|
+
"aria-selected": x,
|
|
526
585
|
children: [
|
|
527
586
|
/* @__PURE__ */ e(
|
|
528
587
|
"span",
|
|
529
588
|
{
|
|
530
|
-
className:
|
|
589
|
+
className: p(
|
|
531
590
|
"shrink-0 w-5 h-5 flex items-center justify-center",
|
|
532
|
-
|
|
591
|
+
x ? "opacity-100" : "opacity-0"
|
|
533
592
|
),
|
|
534
|
-
children: /* @__PURE__ */ e(
|
|
593
|
+
children: /* @__PURE__ */ e(ge, { className: "w-4 h-4" })
|
|
535
594
|
}
|
|
536
595
|
),
|
|
537
|
-
/* @__PURE__ */ e("span", { className: "flex-1", children:
|
|
596
|
+
/* @__PURE__ */ e("span", { className: "flex-1", children: o })
|
|
538
597
|
]
|
|
539
598
|
}
|
|
540
599
|
);
|
|
541
600
|
}
|
|
542
601
|
);
|
|
543
|
-
|
|
544
|
-
const $e = ({ children:
|
|
602
|
+
Be.displayName = "SelectItem";
|
|
603
|
+
const $e = ({ children: t, className: o }) => /* @__PURE__ */ e("div", { className: p("py-1", o), children: t });
|
|
545
604
|
$e.displayName = "SelectGroup";
|
|
546
|
-
const
|
|
605
|
+
const Te = ({ children: t, className: o }) => /* @__PURE__ */ e(
|
|
547
606
|
"div",
|
|
548
607
|
{
|
|
549
|
-
className:
|
|
608
|
+
className: p(
|
|
550
609
|
"px-4 py-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",
|
|
551
|
-
|
|
610
|
+
o
|
|
552
611
|
),
|
|
553
|
-
children:
|
|
612
|
+
children: t
|
|
554
613
|
}
|
|
555
614
|
);
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
|
|
615
|
+
Te.displayName = "SelectLabel";
|
|
616
|
+
const Me = ({ className: t }) => /* @__PURE__ */ e("div", { className: p("h-px bg-border my-1", t) });
|
|
617
|
+
Me.displayName = "SelectSeparator";
|
|
559
618
|
export {
|
|
560
619
|
Ee as Select,
|
|
561
|
-
|
|
620
|
+
je as SelectContent,
|
|
562
621
|
$e as SelectGroup,
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
622
|
+
Be as SelectItem,
|
|
623
|
+
Te as SelectLabel,
|
|
624
|
+
Me as SelectSeparator,
|
|
625
|
+
Pe as SelectTrigger,
|
|
626
|
+
ze as SelectValue,
|
|
568
627
|
Ee as default
|
|
569
628
|
};
|