@telegraph/combobox 0.0.54 → 0.0.55
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/CHANGELOG.md +6 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +178 -177
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/Combobox/Combobox.d.ts.map +1 -1
- package/dist/types/Combobox/Combobox.helpers.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as u, jsxs as S, Fragment as K } from "react/jsx-runtime";
|
|
2
2
|
import { DismissableLayer as q } from "@radix-ui/react-dismissable-layer";
|
|
3
3
|
import * as U from "@radix-ui/react-portal";
|
|
4
4
|
import { useControllableState as W } from "@radix-ui/react-use-controllable-state";
|
|
@@ -10,43 +10,43 @@ import { Lucide as w, Icon as _ } from "@telegraph/icon";
|
|
|
10
10
|
import { Input as ee } from "@telegraph/input";
|
|
11
11
|
import { Stack as I, Box as $ } from "@telegraph/layout";
|
|
12
12
|
import { Menu as Q } from "@telegraph/menu";
|
|
13
|
-
import { motion as
|
|
13
|
+
import { motion as A, AnimatePresence as P } from "@telegraph/motion";
|
|
14
14
|
import { Tag as L } from "@telegraph/tag";
|
|
15
15
|
import { Tooltip as te } from "@telegraph/tooltip";
|
|
16
16
|
import { Text as M } from "@telegraph/typography";
|
|
17
|
-
import
|
|
17
|
+
import c from "react";
|
|
18
18
|
const oe = {
|
|
19
19
|
0: "5",
|
|
20
20
|
1: "6",
|
|
21
21
|
2: "8",
|
|
22
22
|
3: "10"
|
|
23
23
|
}, k = (t) => Array.isArray(t), T = (t) => typeof t == "object" && !Array.isArray(t) || typeof t == "string" || !t, ne = (t) => {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
}),
|
|
27
|
-
return
|
|
24
|
+
const a = (r, i = []) => (c.Children.toArray(r).forEach((n) => {
|
|
25
|
+
c.isValidElement(n) && (n.props.value ? i.push(n) : n.props.children && a(n.props.children, i));
|
|
26
|
+
}), i);
|
|
27
|
+
return a(t).map((r) => {
|
|
28
28
|
var o;
|
|
29
|
-
const
|
|
29
|
+
const i = r;
|
|
30
30
|
return {
|
|
31
|
-
value:
|
|
32
|
-
label: ((o =
|
|
31
|
+
value: i.props.value,
|
|
32
|
+
label: ((o = i.props) == null ? void 0 : o.label) || i.props.children || i.props.value
|
|
33
33
|
};
|
|
34
34
|
});
|
|
35
|
-
}, C = (t,
|
|
35
|
+
}, C = (t, a) => {
|
|
36
36
|
if (t)
|
|
37
|
-
return
|
|
38
|
-
}, F = (t,
|
|
39
|
-
if (!t || !
|
|
40
|
-
const p =
|
|
41
|
-
(
|
|
37
|
+
return a === !0 ? t == null ? void 0 : t.value : t;
|
|
38
|
+
}, F = (t, a, e) => {
|
|
39
|
+
if (!t || !a || a.length === 0) return;
|
|
40
|
+
const p = a.find(
|
|
41
|
+
(r) => r.value === C(t, e)
|
|
42
42
|
);
|
|
43
43
|
if (p)
|
|
44
44
|
return p;
|
|
45
45
|
}, re = ({
|
|
46
46
|
label: t,
|
|
47
|
-
value:
|
|
47
|
+
value: a,
|
|
48
48
|
searchQuery: e
|
|
49
|
-
}) => (
|
|
49
|
+
}) => (a == null ? void 0 : a.toLowerCase().includes(e.toLowerCase())) || (t == null ? void 0 : t.toLowerCase().includes(e.toLowerCase())), ae = ["ArrowDown", "PageUp", "Home"], ie = ["ArrowUp", "PageDown", "End"], z = ["Enter", " "], x = c.createContext({
|
|
50
50
|
value: void 0,
|
|
51
51
|
onValueChange: () => {
|
|
52
52
|
},
|
|
@@ -63,46 +63,46 @@ const oe = {
|
|
|
63
63
|
legacyBehavior: !1
|
|
64
64
|
}), ce = ({
|
|
65
65
|
modal: t = !0,
|
|
66
|
-
closeOnSelect:
|
|
66
|
+
closeOnSelect: a = !0,
|
|
67
67
|
clearable: e = !1,
|
|
68
68
|
disabled: p = !1,
|
|
69
|
-
legacyBehavior:
|
|
70
|
-
open:
|
|
69
|
+
legacyBehavior: r = !1,
|
|
70
|
+
open: i,
|
|
71
71
|
onOpenChange: o,
|
|
72
72
|
defaultOpen: n,
|
|
73
|
-
value:
|
|
73
|
+
value: s,
|
|
74
74
|
onValueChange: f,
|
|
75
75
|
errored: y,
|
|
76
76
|
placeholder: v,
|
|
77
77
|
layout: d,
|
|
78
|
-
children:
|
|
78
|
+
children: l,
|
|
79
79
|
...g
|
|
80
80
|
}) => {
|
|
81
|
-
const m =
|
|
82
|
-
prop:
|
|
81
|
+
const m = c.useId(), b = c.useId(), h = c.useRef(null), R = c.useRef(null), D = c.useRef(null), V = c.useMemo(() => ne(l), [l]), [Y, H] = c.useState(""), [O = !1, B] = W({
|
|
82
|
+
prop: i,
|
|
83
83
|
defaultProp: n,
|
|
84
84
|
onChange: o
|
|
85
|
-
}), N =
|
|
86
|
-
|
|
87
|
-
}, [
|
|
88
|
-
return
|
|
85
|
+
}), N = c.useCallback(() => {
|
|
86
|
+
B((X) => !X);
|
|
87
|
+
}, [B]);
|
|
88
|
+
return c.useEffect(() => {
|
|
89
89
|
O || H("");
|
|
90
|
-
}, [O]), /* @__PURE__ */
|
|
90
|
+
}, [O]), /* @__PURE__ */ u(
|
|
91
91
|
x.Provider,
|
|
92
92
|
{
|
|
93
93
|
value: {
|
|
94
94
|
contentId: m,
|
|
95
95
|
triggerId: b,
|
|
96
|
-
value:
|
|
96
|
+
value: s,
|
|
97
97
|
// Need to cast this to avoid type errors
|
|
98
98
|
// because the type of onValueChange is not
|
|
99
99
|
// consistent with the value type
|
|
100
100
|
onValueChange: f,
|
|
101
101
|
placeholder: v,
|
|
102
102
|
open: O,
|
|
103
|
-
setOpen:
|
|
103
|
+
setOpen: B,
|
|
104
104
|
onOpenToggle: N,
|
|
105
|
-
closeOnSelect:
|
|
105
|
+
closeOnSelect: a,
|
|
106
106
|
clearable: e,
|
|
107
107
|
disabled: p,
|
|
108
108
|
searchQuery: Y,
|
|
@@ -113,24 +113,24 @@ const oe = {
|
|
|
113
113
|
errored: y,
|
|
114
114
|
layout: d,
|
|
115
115
|
options: V,
|
|
116
|
-
legacyBehavior:
|
|
116
|
+
legacyBehavior: r
|
|
117
117
|
},
|
|
118
|
-
children: /* @__PURE__ */
|
|
118
|
+
children: /* @__PURE__ */ u(
|
|
119
119
|
Q.Root,
|
|
120
120
|
{
|
|
121
121
|
open: O,
|
|
122
|
-
onOpenChange:
|
|
122
|
+
onOpenChange: B,
|
|
123
123
|
modal: t,
|
|
124
124
|
...g,
|
|
125
|
-
children:
|
|
125
|
+
children: l
|
|
126
126
|
}
|
|
127
127
|
)
|
|
128
128
|
}
|
|
129
129
|
);
|
|
130
|
-
}, se = ({ value: t, ...
|
|
131
|
-
const e =
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
130
|
+
}, se = ({ value: t, ...a }) => {
|
|
131
|
+
const e = c.useContext(x), p = c.useMemo(() => {
|
|
132
|
+
const r = e.options.find((n) => n.value === t);
|
|
133
|
+
if (r) return r.label || r.value;
|
|
134
134
|
if (!e.value) return;
|
|
135
135
|
const o = e.value.find(
|
|
136
136
|
(n) => C(n, e.legacyBehavior) === t
|
|
@@ -141,7 +141,7 @@ const oe = {
|
|
|
141
141
|
return /* @__PURE__ */ S(
|
|
142
142
|
L.Root,
|
|
143
143
|
{
|
|
144
|
-
as:
|
|
144
|
+
as: A.span,
|
|
145
145
|
initializeWithAnimation: !1,
|
|
146
146
|
initial: { opacity: 0, scale: 0.5 },
|
|
147
147
|
animate: { opacity: 1, scale: 1 },
|
|
@@ -150,17 +150,17 @@ const oe = {
|
|
|
150
150
|
"tgph-motion-key": t,
|
|
151
151
|
size: "1",
|
|
152
152
|
layout: "position",
|
|
153
|
-
...
|
|
153
|
+
...a,
|
|
154
154
|
children: [
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
/* @__PURE__ */
|
|
155
|
+
/* @__PURE__ */ u(L.Text, { children: p }),
|
|
156
|
+
/* @__PURE__ */ u(
|
|
157
157
|
L.Button,
|
|
158
158
|
{
|
|
159
159
|
icon: { icon: w.X, alt: `Remove ${t}` },
|
|
160
|
-
onClick: (
|
|
160
|
+
onClick: (r) => {
|
|
161
161
|
if (!e.onValueChange) return;
|
|
162
|
-
const
|
|
163
|
-
|
|
162
|
+
const i = e.onValueChange, n = e.value.filter((s) => C(s, e.legacyBehavior) !== t);
|
|
163
|
+
i == null || i(n), r.stopPropagation(), r.preventDefault();
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
)
|
|
@@ -168,36 +168,37 @@ const oe = {
|
|
|
168
168
|
}
|
|
169
169
|
);
|
|
170
170
|
}, le = () => {
|
|
171
|
-
|
|
171
|
+
var a;
|
|
172
|
+
const t = c.useContext(x);
|
|
172
173
|
if (t.value && k(t.value)) {
|
|
173
|
-
const
|
|
174
|
-
return t.value.length === 0 ? /* @__PURE__ */
|
|
174
|
+
const e = t.layout || "truncate", p = t.value.length - 2, r = p.toString().split("");
|
|
175
|
+
return t.value.length === 0 ? /* @__PURE__ */ u(E.Text, { color: "gray", children: t.placeholder }) : /* @__PURE__ */ S(
|
|
175
176
|
I,
|
|
176
177
|
{
|
|
177
178
|
gap: "1",
|
|
178
179
|
w: "full",
|
|
179
|
-
wrap:
|
|
180
|
+
wrap: e === "wrap" ? "wrap" : "nowrap",
|
|
180
181
|
align: "center",
|
|
181
182
|
style: {
|
|
182
183
|
position: "relative",
|
|
183
184
|
flexGrow: 1
|
|
184
185
|
},
|
|
185
186
|
children: [
|
|
186
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ u(
|
|
187
188
|
P,
|
|
188
189
|
{
|
|
189
|
-
presenceMap: t.value.map((
|
|
190
|
-
"tgph-motion-key": C(
|
|
190
|
+
presenceMap: t.value.map((i) => ({
|
|
191
|
+
"tgph-motion-key": C(i, t.legacyBehavior) || "",
|
|
191
192
|
value: !0
|
|
192
193
|
})),
|
|
193
|
-
children: t.value.map((
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
return /* @__PURE__ */
|
|
194
|
+
children: t.value.map((i, o) => {
|
|
195
|
+
const n = C(i, t.legacyBehavior);
|
|
196
|
+
if (n && (e === "truncate" && o <= 1 || e === "wrap"))
|
|
197
|
+
return /* @__PURE__ */ u(Z, { children: /* @__PURE__ */ u(se, { value: n }) }, n);
|
|
197
198
|
})
|
|
198
199
|
}
|
|
199
200
|
),
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
+
/* @__PURE__ */ u(
|
|
201
202
|
P,
|
|
202
203
|
{
|
|
203
204
|
presenceMap: [
|
|
@@ -206,10 +207,10 @@ const oe = {
|
|
|
206
207
|
value: !0
|
|
207
208
|
}
|
|
208
209
|
],
|
|
209
|
-
children:
|
|
210
|
+
children: e === "truncate" && t.value.length > 2 && /* @__PURE__ */ u(
|
|
210
211
|
I,
|
|
211
212
|
{
|
|
212
|
-
as:
|
|
213
|
+
as: A.div,
|
|
213
214
|
initial: { opacity: 0 },
|
|
214
215
|
animate: { opacity: 1 },
|
|
215
216
|
exit: { opacity: 0 },
|
|
@@ -218,7 +219,7 @@ const oe = {
|
|
|
218
219
|
pr: "1",
|
|
219
220
|
pl: "8",
|
|
220
221
|
align: "center",
|
|
221
|
-
"aria-label": `${
|
|
222
|
+
"aria-label": `${p} more selected`,
|
|
222
223
|
position: "absolute",
|
|
223
224
|
right: "0",
|
|
224
225
|
style: {
|
|
@@ -229,25 +230,25 @@ const oe = {
|
|
|
229
230
|
/* @__PURE__ */ S(
|
|
230
231
|
P,
|
|
231
232
|
{
|
|
232
|
-
presenceMap:
|
|
233
|
-
"tgph-motion-key":
|
|
233
|
+
presenceMap: r.map((i) => ({
|
|
234
|
+
"tgph-motion-key": i,
|
|
234
235
|
value: !0
|
|
235
236
|
})),
|
|
236
237
|
children: [
|
|
237
|
-
|
|
238
|
+
r.map((i) => /* @__PURE__ */ u(
|
|
238
239
|
$,
|
|
239
240
|
{
|
|
240
|
-
as:
|
|
241
|
+
as: A.span,
|
|
241
242
|
initial: { opacity: 0 },
|
|
242
243
|
animate: { opacity: 1 },
|
|
243
244
|
exit: { opacity: 0 },
|
|
244
245
|
transition: { duration: 100, type: "spring" },
|
|
245
246
|
w: "2",
|
|
246
247
|
display: "inline-block",
|
|
247
|
-
"tgph-motion-key":
|
|
248
|
-
children:
|
|
248
|
+
"tgph-motion-key": i,
|
|
249
|
+
children: i
|
|
249
250
|
},
|
|
250
|
-
|
|
251
|
+
i
|
|
251
252
|
)),
|
|
252
253
|
" "
|
|
253
254
|
]
|
|
@@ -264,15 +265,15 @@ const oe = {
|
|
|
264
265
|
);
|
|
265
266
|
}
|
|
266
267
|
if (t && T(t.value)) {
|
|
267
|
-
const
|
|
268
|
+
const e = F(
|
|
268
269
|
t.value,
|
|
269
270
|
t.options,
|
|
270
271
|
t.legacyBehavior
|
|
271
|
-
);
|
|
272
|
-
return /* @__PURE__ */
|
|
272
|
+
), p = (e == null ? void 0 : e.label) || (e == null ? void 0 : e.value) || t.placeholder, r = t.legacyBehavior && ((a = t == null ? void 0 : t.value) == null ? void 0 : a.label);
|
|
273
|
+
return /* @__PURE__ */ u(E.Text, { color: t.value ? "default" : "gray", children: r ?? p });
|
|
273
274
|
}
|
|
274
|
-
}, ue = ({ size: t = "2", ...
|
|
275
|
-
const e =
|
|
275
|
+
}, ue = ({ size: t = "2", ...a }) => {
|
|
276
|
+
const e = c.useContext(x), p = c.useCallback(() => {
|
|
276
277
|
var o;
|
|
277
278
|
if (!e.value) return e.placeholder;
|
|
278
279
|
if (T(e.value)) {
|
|
@@ -285,44 +286,44 @@ const oe = {
|
|
|
285
286
|
}
|
|
286
287
|
if (k(e.value))
|
|
287
288
|
return ((o = e.value) == null ? void 0 : o.map((n) => {
|
|
288
|
-
const
|
|
289
|
+
const s = F(
|
|
289
290
|
n,
|
|
290
291
|
e.options,
|
|
291
292
|
e.legacyBehavior
|
|
292
293
|
);
|
|
293
|
-
return
|
|
294
|
+
return s == null ? void 0 : s.label;
|
|
294
295
|
}).join(", ")) || e.placeholder;
|
|
295
296
|
}, [
|
|
296
297
|
e.value,
|
|
297
298
|
e.placeholder,
|
|
298
299
|
e.options,
|
|
299
300
|
e.legacyBehavior
|
|
300
|
-
]),
|
|
301
|
+
]), r = c.useMemo(() => {
|
|
301
302
|
var o;
|
|
302
303
|
if (T(e.value))
|
|
303
304
|
return e.clearable && e.value;
|
|
304
305
|
if (k(e.value))
|
|
305
306
|
return e.clearable && ((o = e.value) == null ? void 0 : o.length) > 0;
|
|
306
|
-
}, [e.clearable, e.value]),
|
|
307
|
+
}, [e.clearable, e.value]), i = () => {
|
|
307
308
|
var o, n;
|
|
308
309
|
if (k(e.value)) {
|
|
309
|
-
const
|
|
310
|
-
|
|
310
|
+
const s = e.onValueChange;
|
|
311
|
+
s == null || s([]);
|
|
311
312
|
}
|
|
312
313
|
if (T(e.value)) {
|
|
313
|
-
const
|
|
314
|
-
|
|
314
|
+
const s = e.onValueChange;
|
|
315
|
+
s == null || s(void 0);
|
|
315
316
|
}
|
|
316
317
|
(n = (o = e.triggerRef) == null ? void 0 : o.current) == null || n.focus();
|
|
317
318
|
};
|
|
318
|
-
return /* @__PURE__ */
|
|
319
|
+
return /* @__PURE__ */ u(
|
|
319
320
|
Q.Trigger,
|
|
320
321
|
{
|
|
321
|
-
...
|
|
322
|
+
...a,
|
|
322
323
|
asChild: !0,
|
|
323
324
|
onClick: (o) => {
|
|
324
|
-
var n,
|
|
325
|
-
o.preventDefault(), e.onOpenToggle(), (
|
|
325
|
+
var n, s;
|
|
326
|
+
o.preventDefault(), e.onOpenToggle(), (s = (n = e.triggerRef) == null ? void 0 : n.current) == null || s.focus();
|
|
326
327
|
},
|
|
327
328
|
onKeyDown: (o) => {
|
|
328
329
|
if (o.key === "Tab") {
|
|
@@ -363,9 +364,9 @@ const oe = {
|
|
|
363
364
|
"data-tgph-comobox-trigger-open": e.open,
|
|
364
365
|
disabled: e.disabled,
|
|
365
366
|
children: [
|
|
366
|
-
/* @__PURE__ */
|
|
367
|
+
/* @__PURE__ */ u(le, {}),
|
|
367
368
|
/* @__PURE__ */ S(I, { align: "center", gap: "1", children: [
|
|
368
|
-
|
|
369
|
+
r && /* @__PURE__ */ u(te, { label: "Clear field", children: /* @__PURE__ */ u(
|
|
369
370
|
E,
|
|
370
371
|
{
|
|
371
372
|
type: "button",
|
|
@@ -373,10 +374,10 @@ const oe = {
|
|
|
373
374
|
size: "1",
|
|
374
375
|
variant: "ghost",
|
|
375
376
|
onClick: (o) => {
|
|
376
|
-
e.value && (o.stopPropagation(),
|
|
377
|
+
e.value && (o.stopPropagation(), i());
|
|
377
378
|
},
|
|
378
379
|
onKeyDown: (o) => {
|
|
379
|
-
(o.key === "Enter" || o.key === " ") && (o.stopPropagation(),
|
|
380
|
+
(o.key === "Enter" || o.key === " ") && (o.stopPropagation(), i());
|
|
380
381
|
},
|
|
381
382
|
"data-tgph-combobox-clear": !0,
|
|
382
383
|
style: {
|
|
@@ -387,10 +388,10 @@ const oe = {
|
|
|
387
388
|
}
|
|
388
389
|
}
|
|
389
390
|
) }),
|
|
390
|
-
/* @__PURE__ */
|
|
391
|
+
/* @__PURE__ */ u(
|
|
391
392
|
E.Icon,
|
|
392
393
|
{
|
|
393
|
-
as:
|
|
394
|
+
as: A.span,
|
|
394
395
|
animate: { rotate: e.open ? 180 : 0 },
|
|
395
396
|
transition: { duration: 150, type: "spring" },
|
|
396
397
|
icon: w.ChevronDown,
|
|
@@ -405,52 +406,52 @@ const oe = {
|
|
|
405
406
|
);
|
|
406
407
|
}, pe = ({
|
|
407
408
|
style: t,
|
|
408
|
-
children:
|
|
409
|
+
children: a,
|
|
409
410
|
tgphRef: e,
|
|
410
411
|
...p
|
|
411
412
|
}) => {
|
|
412
|
-
const
|
|
413
|
-
(
|
|
414
|
-
const g =
|
|
413
|
+
const r = c.useContext(x), i = c.useRef(!1), o = j(e, r.contentRef), n = c.useRef(null), [s, f] = c.useState(0), [y, v] = c.useState(!1), d = c.useCallback(
|
|
414
|
+
(l) => {
|
|
415
|
+
const g = l == null ? void 0 : l.getBoundingClientRect();
|
|
415
416
|
g && f(g.height), y || v(!0);
|
|
416
417
|
},
|
|
417
418
|
[y]
|
|
418
419
|
);
|
|
419
|
-
return
|
|
420
|
-
const
|
|
420
|
+
return c.useEffect(() => {
|
|
421
|
+
const l = new ResizeObserver((g) => {
|
|
421
422
|
for (const m of g) {
|
|
422
423
|
const b = m.target;
|
|
423
424
|
d(b);
|
|
424
425
|
}
|
|
425
426
|
});
|
|
426
|
-
return n.current && y &&
|
|
427
|
-
}, [y, d]),
|
|
428
|
-
y === !0 &&
|
|
429
|
-
}, [
|
|
430
|
-
let
|
|
431
|
-
return
|
|
427
|
+
return n.current && y && l.observe(n.current), () => l.disconnect();
|
|
428
|
+
}, [y, d]), c.useEffect(() => {
|
|
429
|
+
y === !0 && r.open === !1 && v(!1);
|
|
430
|
+
}, [r.open, y]), c.useEffect(() => {
|
|
431
|
+
let l;
|
|
432
|
+
return r.open && (l = setTimeout(() => {
|
|
432
433
|
d(n.current);
|
|
433
|
-
}, 10)), () =>
|
|
434
|
-
}, [
|
|
434
|
+
}, 10)), () => l && clearTimeout(l);
|
|
435
|
+
}, [r.open, d]), /* @__PURE__ */ u(U.Root, { asChild: !0, children: /* @__PURE__ */ u(
|
|
435
436
|
q,
|
|
436
437
|
{
|
|
437
|
-
onEscapeKeyDown: (
|
|
438
|
-
|
|
438
|
+
onEscapeKeyDown: (l) => {
|
|
439
|
+
r.open && (l.stopPropagation(), l.preventDefault(), r.setOpen(!1));
|
|
439
440
|
},
|
|
440
|
-
children: /* @__PURE__ */
|
|
441
|
+
children: /* @__PURE__ */ u(
|
|
441
442
|
Q.Content,
|
|
442
443
|
{
|
|
443
444
|
className: "tgph",
|
|
444
445
|
mt: "1",
|
|
445
|
-
onCloseAutoFocus: (
|
|
446
|
+
onCloseAutoFocus: (l) => {
|
|
446
447
|
var g, m;
|
|
447
|
-
|
|
448
|
+
i.current || (m = (g = r.triggerRef) == null ? void 0 : g.current) == null || m.focus(), i.current = !1, l.preventDefault();
|
|
448
449
|
},
|
|
449
450
|
bg: "surface-1",
|
|
450
451
|
style: {
|
|
451
452
|
width: "var(--tgph-comobobox-trigger-width)",
|
|
452
453
|
transition: "min-height 200ms ease-in-out",
|
|
453
|
-
minHeight:
|
|
454
|
+
minHeight: s ? `${s}px` : "0",
|
|
454
455
|
...t,
|
|
455
456
|
"--tgph-comobobox-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
456
457
|
"--tgph-combobox-content-available-width": "var(--radix-popper-available-width)",
|
|
@@ -461,28 +462,28 @@ const oe = {
|
|
|
461
462
|
...p,
|
|
462
463
|
tgphRef: o,
|
|
463
464
|
"data-tgph-combobox-content": !0,
|
|
464
|
-
"data-tgph-combobox-content-open":
|
|
465
|
+
"data-tgph-combobox-content-open": r.open,
|
|
465
466
|
role: void 0,
|
|
466
467
|
"aria-orientation": void 0,
|
|
467
|
-
onKeyDown: (
|
|
468
|
+
onKeyDown: (l) => {
|
|
468
469
|
var m, b, h, R;
|
|
469
|
-
|
|
470
|
-
const g = (b = (m =
|
|
470
|
+
l.stopPropagation();
|
|
471
|
+
const g = (b = (m = r.contentRef) == null ? void 0 : m.current) == null ? void 0 : b.querySelectorAll(
|
|
471
472
|
"[data-tgph-combobox-option]"
|
|
472
473
|
);
|
|
473
|
-
document.activeElement === (g == null ? void 0 : g[0]) && ie.includes(
|
|
474
|
+
document.activeElement === (g == null ? void 0 : g[0]) && ie.includes(l.key) && ((R = (h = r.searchRef) == null ? void 0 : h.current) == null || R.focus());
|
|
474
475
|
},
|
|
475
|
-
children: /* @__PURE__ */
|
|
476
|
+
children: /* @__PURE__ */ u(I, { direction: "column", gap: "1", tgphRef: n, children: a })
|
|
476
477
|
}
|
|
477
478
|
)
|
|
478
479
|
}
|
|
479
480
|
) });
|
|
480
481
|
}, fe = ({ ...t }) => {
|
|
481
|
-
const
|
|
482
|
-
return /* @__PURE__ */
|
|
482
|
+
const a = c.useContext(x);
|
|
483
|
+
return /* @__PURE__ */ u(
|
|
483
484
|
I,
|
|
484
485
|
{
|
|
485
|
-
id:
|
|
486
|
+
id: a.contentId,
|
|
486
487
|
direction: "column",
|
|
487
488
|
gap: "1",
|
|
488
489
|
style: {
|
|
@@ -496,35 +497,35 @@ const oe = {
|
|
|
496
497
|
);
|
|
497
498
|
}, G = ({
|
|
498
499
|
value: t,
|
|
499
|
-
label:
|
|
500
|
+
label: a,
|
|
500
501
|
selected: e,
|
|
501
502
|
onSelect: p,
|
|
502
|
-
children:
|
|
503
|
-
...
|
|
503
|
+
children: r,
|
|
504
|
+
...i
|
|
504
505
|
}) => {
|
|
505
|
-
const o =
|
|
506
|
-
label: (
|
|
506
|
+
const o = c.useContext(x), [n, s] = c.useState(!1), f = o.value, y = !o.searchQuery || re({
|
|
507
|
+
label: (a == null ? void 0 : a.toString()) || (r == null ? void 0 : r.toString()),
|
|
507
508
|
value: t,
|
|
508
509
|
searchQuery: o.searchQuery
|
|
509
510
|
}), v = k(f) ? f.some(
|
|
510
|
-
(
|
|
511
|
-
) : C(f, o.legacyBehavior) === t, d = (
|
|
511
|
+
(l) => C(l, o.legacyBehavior) === t
|
|
512
|
+
) : C(f, o.legacyBehavior) === t, d = (l) => {
|
|
512
513
|
var m, b;
|
|
513
|
-
|
|
514
|
-
const g =
|
|
514
|
+
l.stopPropagation();
|
|
515
|
+
const g = l;
|
|
515
516
|
if (!(g.key && !z.includes(g.key))) {
|
|
516
|
-
if (
|
|
517
|
-
return p(
|
|
517
|
+
if (l.preventDefault(), o.closeOnSelect === !0 && o.setOpen(!1), p)
|
|
518
|
+
return p(l);
|
|
518
519
|
if (T(f)) {
|
|
519
520
|
const h = o.onValueChange;
|
|
520
|
-
o.legacyBehavior === !0 ? h == null || h({ value: t, label:
|
|
521
|
+
o.legacyBehavior === !0 ? h == null || h({ value: t, label: a }) : h == null || h(t);
|
|
521
522
|
} else if (k(f)) {
|
|
522
523
|
const h = o.onValueChange, R = o.value, D = v ? R.filter(
|
|
523
524
|
(V) => C(V, o.legacyBehavior) !== t
|
|
524
525
|
) : [
|
|
525
526
|
...R,
|
|
526
527
|
// TODO: Remove this once { value, label } option is deprecated
|
|
527
|
-
o.legacyBehavior === !0 ? { value: t, label:
|
|
528
|
+
o.legacyBehavior === !0 ? { value: t, label: a } : t
|
|
528
529
|
];
|
|
529
530
|
h == null || h(D);
|
|
530
531
|
}
|
|
@@ -532,59 +533,59 @@ const oe = {
|
|
|
532
533
|
}
|
|
533
534
|
};
|
|
534
535
|
if (y)
|
|
535
|
-
return /* @__PURE__ */
|
|
536
|
+
return /* @__PURE__ */ u(
|
|
536
537
|
Q.Button,
|
|
537
538
|
{
|
|
538
539
|
type: "button",
|
|
539
540
|
onSelect: d,
|
|
540
541
|
onKeyDown: d,
|
|
541
542
|
selected: e === null ? null : e ?? v,
|
|
542
|
-
onFocus: () =>
|
|
543
|
-
onBlur: () =>
|
|
543
|
+
onFocus: () => s(!0),
|
|
544
|
+
onBlur: () => s(!1),
|
|
544
545
|
role: "option",
|
|
545
546
|
"aria-selected": v ? "true" : "false",
|
|
546
547
|
"data-tgph-combobox-option": !0,
|
|
547
548
|
"data-tgph-combobox-option-focused": n,
|
|
548
549
|
"data-tgph-combobox-option-value": t,
|
|
549
|
-
"data-tgph-combobox-option-label":
|
|
550
|
-
...
|
|
551
|
-
children:
|
|
550
|
+
"data-tgph-combobox-option-label": a,
|
|
551
|
+
...i,
|
|
552
|
+
children: a || r || t
|
|
552
553
|
}
|
|
553
554
|
);
|
|
554
555
|
}, ge = ({
|
|
555
556
|
label: t = "Search",
|
|
556
|
-
placeholder:
|
|
557
|
+
placeholder: a = "Search",
|
|
557
558
|
tgphRef: e,
|
|
558
559
|
value: p,
|
|
559
|
-
onValueChange:
|
|
560
|
-
...
|
|
560
|
+
onValueChange: r,
|
|
561
|
+
...i
|
|
561
562
|
}) => {
|
|
562
563
|
var v;
|
|
563
|
-
const o =
|
|
564
|
-
return
|
|
564
|
+
const o = c.useId(), n = c.useContext(x), s = j(e, n.searchRef), f = p ?? n.searchQuery, y = r ?? n.setSearchQuery;
|
|
565
|
+
return c.useEffect(() => {
|
|
565
566
|
var g;
|
|
566
567
|
const d = (m) => {
|
|
567
568
|
var b, h;
|
|
568
569
|
ae.includes(m.key) && ((h = (b = n.contentRef) == null ? void 0 : b.current) == null || h.focus({ preventScroll: !0 })), m.key === "Escape" && n.setOpen(!1), m.stopPropagation();
|
|
569
|
-
},
|
|
570
|
-
if (
|
|
571
|
-
return
|
|
572
|
-
|
|
570
|
+
}, l = (g = n.searchRef) == null ? void 0 : g.current;
|
|
571
|
+
if (l)
|
|
572
|
+
return l.addEventListener("keydown", d), () => {
|
|
573
|
+
l.removeEventListener("keydown", d);
|
|
573
574
|
};
|
|
574
575
|
}, [n]), /* @__PURE__ */ S($, { borderBottom: "px", px: "1", pb: "1", children: [
|
|
575
|
-
/* @__PURE__ */
|
|
576
|
-
/* @__PURE__ */
|
|
576
|
+
/* @__PURE__ */ u(J.Root, { children: /* @__PURE__ */ u(M, { as: "label", htmlFor: o, children: t }) }),
|
|
577
|
+
/* @__PURE__ */ u(
|
|
577
578
|
ee,
|
|
578
579
|
{
|
|
579
580
|
id: o,
|
|
580
581
|
variant: "ghost",
|
|
581
|
-
placeholder:
|
|
582
|
+
placeholder: a,
|
|
582
583
|
value: f,
|
|
583
584
|
onChange: (d) => {
|
|
584
585
|
y(d.target.value);
|
|
585
586
|
},
|
|
586
|
-
LeadingComponent: /* @__PURE__ */
|
|
587
|
-
TrailingComponent: n != null && n.searchQuery && ((v = n == null ? void 0 : n.searchQuery) == null ? void 0 : v.length) > 0 ? /* @__PURE__ */
|
|
587
|
+
LeadingComponent: /* @__PURE__ */ u(_, { icon: w.Search, alt: "Search Icon" }),
|
|
588
|
+
TrailingComponent: n != null && n.searchQuery && ((v = n == null ? void 0 : n.searchQuery) == null ? void 0 : v.length) > 0 ? /* @__PURE__ */ u(
|
|
588
589
|
E,
|
|
589
590
|
{
|
|
590
591
|
variant: "ghost",
|
|
@@ -599,25 +600,25 @@ const oe = {
|
|
|
599
600
|
autoFocus: !0,
|
|
600
601
|
"data-tgph-combobox-search": !0,
|
|
601
602
|
"aria-controls": n.contentId,
|
|
602
|
-
...
|
|
603
|
-
tgphRef:
|
|
603
|
+
...i,
|
|
604
|
+
tgphRef: s
|
|
604
605
|
}
|
|
605
606
|
)
|
|
606
607
|
] });
|
|
607
608
|
}, he = ({
|
|
608
609
|
icon: t = { icon: w.Search, alt: "Search Icon" },
|
|
609
|
-
message:
|
|
610
|
+
message: a = "No results found",
|
|
610
611
|
children: e,
|
|
611
612
|
...p
|
|
612
613
|
}) => {
|
|
613
|
-
const
|
|
614
|
-
if (
|
|
615
|
-
var
|
|
616
|
-
const n = (f = (
|
|
614
|
+
const r = c.useContext(x), [i, o] = c.useState(!1);
|
|
615
|
+
if (c.useEffect(() => {
|
|
616
|
+
var s, f;
|
|
617
|
+
const n = (f = (s = r.contentRef) == null ? void 0 : s.current) == null ? void 0 : f.querySelectorAll(
|
|
617
618
|
"[data-tgph-combobox-option]"
|
|
618
619
|
);
|
|
619
620
|
(n == null ? void 0 : n.length) === 0 ? o(!0) : o(!1);
|
|
620
|
-
}, [
|
|
621
|
+
}, [r.searchQuery, r.contentRef, e]), i)
|
|
621
622
|
return /* @__PURE__ */ S(
|
|
622
623
|
I,
|
|
623
624
|
{
|
|
@@ -629,27 +630,27 @@ const oe = {
|
|
|
629
630
|
"data-tgph-combobox-empty": !0,
|
|
630
631
|
...p,
|
|
631
632
|
children: [
|
|
632
|
-
t === null ? /* @__PURE__ */
|
|
633
|
-
|
|
633
|
+
t === null ? /* @__PURE__ */ u(K, {}) : /* @__PURE__ */ u(_, { ...t }),
|
|
634
|
+
a === null ? /* @__PURE__ */ u(K, {}) : /* @__PURE__ */ u(M, { as: "span", children: a })
|
|
634
635
|
]
|
|
635
636
|
}
|
|
636
637
|
);
|
|
637
638
|
}, de = ({
|
|
638
639
|
leadingText: t = "Create",
|
|
639
|
-
values:
|
|
640
|
+
values: a,
|
|
640
641
|
onCreate: e,
|
|
641
642
|
selected: p = null,
|
|
642
|
-
legacyBehavior:
|
|
643
|
-
...
|
|
643
|
+
legacyBehavior: r = !1,
|
|
644
|
+
...i
|
|
644
645
|
}) => {
|
|
645
|
-
const o =
|
|
646
|
-
(
|
|
647
|
-
(f) => C(f,
|
|
646
|
+
const o = c.useContext(x), n = c.useCallback(
|
|
647
|
+
(s) => !a || (a == null ? void 0 : a.length) === 0 ? !1 : a.some(
|
|
648
|
+
(f) => C(f, r) === s
|
|
648
649
|
),
|
|
649
|
-
[
|
|
650
|
+
[a, r]
|
|
650
651
|
);
|
|
651
652
|
if (o.searchQuery && !n(o.searchQuery))
|
|
652
|
-
return /* @__PURE__ */
|
|
653
|
+
return /* @__PURE__ */ u(
|
|
653
654
|
G,
|
|
654
655
|
{
|
|
655
656
|
leadingIcon: { icon: w.Plus, "aria-hidden": !0 },
|
|
@@ -658,13 +659,13 @@ const oe = {
|
|
|
658
659
|
label: `${t} "${o.searchQuery}"`,
|
|
659
660
|
selected: p,
|
|
660
661
|
onSelect: () => {
|
|
661
|
-
var
|
|
662
|
+
var s;
|
|
662
663
|
if (e && o.value && o.searchQuery) {
|
|
663
|
-
const f =
|
|
664
|
-
e(f), (
|
|
664
|
+
const f = r === !0 ? { value: o.searchQuery } : o.searchQuery;
|
|
665
|
+
e(f), (s = o.setSearchQuery) == null || s.call(o, "");
|
|
665
666
|
}
|
|
666
667
|
},
|
|
667
|
-
...
|
|
668
|
+
...i
|
|
668
669
|
}
|
|
669
670
|
);
|
|
670
671
|
}, me = {};
|