@telegraph/combobox 0.0.78 → 0.0.80
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 +21 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +185 -175
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/Combobox/Combobox.primitives.d.ts.map +1 -1
- package/package.json +6 -5
package/dist/esm/index.mjs
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { DismissableLayer as
|
|
3
|
-
import * as
|
|
4
|
-
import { useControllableState as
|
|
5
|
-
import * as
|
|
6
|
-
import { Button as
|
|
1
|
+
import { jsx as s, jsxs as w, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
+
import { DismissableLayer as ee } from "@radix-ui/react-dismissable-layer";
|
|
3
|
+
import * as te from "@radix-ui/react-portal";
|
|
4
|
+
import { useControllableState as oe } from "@radix-ui/react-use-controllable-state";
|
|
5
|
+
import * as re from "@radix-ui/react-visually-hidden";
|
|
6
|
+
import { Button as O } from "@telegraph/button";
|
|
7
7
|
import { useComposedRefs as $ } from "@telegraph/compose-refs";
|
|
8
|
-
import { RefToTgphRef as
|
|
8
|
+
import { RefToTgphRef as ne } from "@telegraph/helpers";
|
|
9
9
|
import { Lucide as E, Icon as z } from "@telegraph/icon";
|
|
10
|
-
import { Input as
|
|
11
|
-
import { Stack as
|
|
10
|
+
import { Input as ae } from "@telegraph/input";
|
|
11
|
+
import { Stack as k, Box as G } from "@telegraph/layout";
|
|
12
12
|
import { Menu as Q } from "@telegraph/menu";
|
|
13
13
|
import { Text as H } from "@telegraph/typography";
|
|
14
|
-
import
|
|
14
|
+
import l from "react";
|
|
15
15
|
import { motion as P, AnimatePresence as M } from "@telegraph/motion";
|
|
16
16
|
import { Tag as K } from "@telegraph/tag";
|
|
17
|
-
import { Tooltip as
|
|
18
|
-
|
|
17
|
+
import { Tooltip as ie } from "@telegraph/tooltip";
|
|
18
|
+
import { TooltipIfTruncated as Y } from "@telegraph/truncate";
|
|
19
|
+
const ce = {
|
|
19
20
|
0: "5",
|
|
20
21
|
1: "6",
|
|
21
22
|
2: "8",
|
|
22
23
|
3: "10"
|
|
23
|
-
},
|
|
24
|
-
const o = (a, c = []) => (
|
|
25
|
-
|
|
24
|
+
}, R = (t) => Array.isArray(t), I = (t) => typeof t == "object" && !Array.isArray(t) || typeof t == "string" || !t, le = (t) => {
|
|
25
|
+
const o = (a, c = []) => (l.Children.toArray(a).forEach((i) => {
|
|
26
|
+
l.isValidElement(i) && (i.props.value ? c.push(i) : i.props.children && o(i.props.children, c));
|
|
26
27
|
}), c);
|
|
27
28
|
return o(t).map((a) => {
|
|
28
29
|
var n;
|
|
@@ -47,23 +48,23 @@ const ie = {
|
|
|
47
48
|
value: o,
|
|
48
49
|
searchQuery: e
|
|
49
50
|
}) => {
|
|
50
|
-
const r =
|
|
51
|
+
const r = X(t);
|
|
51
52
|
return (o == null ? void 0 : o.toLowerCase().includes(e.toLowerCase())) || r.some(
|
|
52
53
|
(a) => a.toLowerCase().includes(e.toLowerCase())
|
|
53
54
|
);
|
|
54
|
-
},
|
|
55
|
-
const o =
|
|
55
|
+
}, X = (t) => {
|
|
56
|
+
const o = l.Children.toArray(t), e = [];
|
|
56
57
|
return o.forEach((r) => {
|
|
57
|
-
typeof r == "string" && e.push(r),
|
|
58
|
+
typeof r == "string" && e.push(r), l.isValidElement(r) && r.props.children && e.push(...X(r.props.children));
|
|
58
59
|
}), e;
|
|
59
|
-
},
|
|
60
|
+
}, ue = ({
|
|
60
61
|
icon: t = E.ChevronDown,
|
|
61
62
|
"aria-hidden": o = !0,
|
|
62
63
|
...e
|
|
63
64
|
}) => {
|
|
64
|
-
const r =
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
-
|
|
65
|
+
const r = l.useContext(y);
|
|
66
|
+
return /* @__PURE__ */ s(
|
|
67
|
+
O.Icon,
|
|
67
68
|
{
|
|
68
69
|
as: P.span,
|
|
69
70
|
animate: { rotate: r.open ? 180 : 0 },
|
|
@@ -73,30 +74,30 @@ const ie = {
|
|
|
73
74
|
...e
|
|
74
75
|
}
|
|
75
76
|
);
|
|
76
|
-
},
|
|
77
|
+
}, pe = ({
|
|
77
78
|
tooltipProps: t,
|
|
78
79
|
...o
|
|
79
80
|
}) => {
|
|
80
|
-
const e =
|
|
81
|
+
const e = l.useContext(y), r = () => {
|
|
81
82
|
var c, n;
|
|
82
|
-
if (
|
|
83
|
+
if (R(e.value)) {
|
|
83
84
|
const i = e.onValueChange;
|
|
84
85
|
i == null || i([]);
|
|
85
86
|
}
|
|
86
|
-
if (
|
|
87
|
+
if (I(e.value)) {
|
|
87
88
|
const i = e.onValueChange;
|
|
88
89
|
i == null || i(void 0);
|
|
89
90
|
}
|
|
90
91
|
(n = (c = e.triggerRef) == null ? void 0 : c.current) == null || n.focus();
|
|
91
92
|
};
|
|
92
|
-
return
|
|
93
|
+
return l.useMemo(() => {
|
|
93
94
|
var c;
|
|
94
|
-
if (
|
|
95
|
+
if (I(e.value))
|
|
95
96
|
return e.clearable && e.value;
|
|
96
|
-
if (
|
|
97
|
+
if (R(e.value))
|
|
97
98
|
return e.clearable && ((c = e.value) == null ? void 0 : c.length) > 0;
|
|
98
|
-
}, [e.clearable, e.value]) ? /* @__PURE__ */
|
|
99
|
-
|
|
99
|
+
}, [e.clearable, e.value]) ? /* @__PURE__ */ s(ie, { label: "Clear field", ...t, children: /* @__PURE__ */ s(
|
|
100
|
+
O,
|
|
100
101
|
{
|
|
101
102
|
type: "button",
|
|
102
103
|
icon: { icon: E.X, alt: "Clear field" },
|
|
@@ -118,13 +119,13 @@ const ie = {
|
|
|
118
119
|
...o
|
|
119
120
|
}
|
|
120
121
|
) }) : null;
|
|
121
|
-
},
|
|
122
|
+
}, ge = ({
|
|
122
123
|
children: t,
|
|
123
124
|
...o
|
|
124
125
|
}) => {
|
|
125
|
-
const e =
|
|
126
|
+
const e = l.useContext(y), r = l.useMemo(() => {
|
|
126
127
|
var i;
|
|
127
|
-
if (!
|
|
128
|
+
if (!I(e.value)) return;
|
|
128
129
|
const a = F(
|
|
129
130
|
e.value,
|
|
130
131
|
e.options,
|
|
@@ -137,8 +138,8 @@ const ie = {
|
|
|
137
138
|
e.legacyBehavior,
|
|
138
139
|
e.placeholder
|
|
139
140
|
]);
|
|
140
|
-
return /* @__PURE__ */
|
|
141
|
-
|
|
141
|
+
return /* @__PURE__ */ s(Y, { children: /* @__PURE__ */ s(
|
|
142
|
+
O.Text,
|
|
142
143
|
{
|
|
143
144
|
color: e.value ? "default" : "gray",
|
|
144
145
|
textOverflow: "ellipsis",
|
|
@@ -146,19 +147,28 @@ const ie = {
|
|
|
146
147
|
...o,
|
|
147
148
|
children: t || r
|
|
148
149
|
}
|
|
149
|
-
);
|
|
150
|
-
},
|
|
150
|
+
) });
|
|
151
|
+
}, fe = ({
|
|
151
152
|
children: t,
|
|
152
153
|
...o
|
|
153
154
|
}) => {
|
|
154
|
-
const e =
|
|
155
|
-
return /* @__PURE__ */
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
const e = l.useContext(y);
|
|
156
|
+
return /* @__PURE__ */ s(Y, { children: /* @__PURE__ */ s(
|
|
157
|
+
O.Text,
|
|
158
|
+
{
|
|
159
|
+
color: "gray",
|
|
160
|
+
textOverflow: "ellipsis",
|
|
161
|
+
overflow: "hidden",
|
|
162
|
+
...o,
|
|
163
|
+
children: t || e.placeholder
|
|
164
|
+
}
|
|
165
|
+
) });
|
|
166
|
+
}, he = ({ children: t }) => {
|
|
167
|
+
const o = l.useContext(y);
|
|
168
|
+
if (!R(o.value)) return null;
|
|
159
169
|
const e = o.layout || "truncate", a = (o.value.length - 2).toString().split("");
|
|
160
|
-
return /* @__PURE__ */
|
|
161
|
-
|
|
170
|
+
return /* @__PURE__ */ w(
|
|
171
|
+
k,
|
|
162
172
|
{
|
|
163
173
|
gap: "1",
|
|
164
174
|
w: "full",
|
|
@@ -169,7 +179,7 @@ const ie = {
|
|
|
169
179
|
flexGrow: 1
|
|
170
180
|
},
|
|
171
181
|
children: [
|
|
172
|
-
/* @__PURE__ */
|
|
182
|
+
/* @__PURE__ */ s(
|
|
173
183
|
M,
|
|
174
184
|
{
|
|
175
185
|
presenceMap: o.value.map((c) => ({
|
|
@@ -179,7 +189,7 @@ const ie = {
|
|
|
179
189
|
children: t
|
|
180
190
|
}
|
|
181
191
|
),
|
|
182
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ s(
|
|
183
193
|
M,
|
|
184
194
|
{
|
|
185
195
|
presenceMap: [
|
|
@@ -188,8 +198,8 @@ const ie = {
|
|
|
188
198
|
value: !0
|
|
189
199
|
}
|
|
190
200
|
],
|
|
191
|
-
children: e === "truncate" && o.value.length > 2 && /* @__PURE__ */
|
|
192
|
-
|
|
201
|
+
children: e === "truncate" && o.value.length > 2 && /* @__PURE__ */ s(
|
|
202
|
+
k,
|
|
193
203
|
{
|
|
194
204
|
as: P.div,
|
|
195
205
|
initial: { opacity: 0 },
|
|
@@ -206,9 +216,9 @@ const ie = {
|
|
|
206
216
|
style: {
|
|
207
217
|
backgroundImage: "linear-gradient(to left, var(--tgph-surface-1) 0 60%, transparent 90% 100%)"
|
|
208
218
|
},
|
|
209
|
-
children: /* @__PURE__ */
|
|
219
|
+
children: /* @__PURE__ */ w(H, { as: "span", size: "1", style: { whiteSpace: "nowrap" }, children: [
|
|
210
220
|
"+",
|
|
211
|
-
/* @__PURE__ */
|
|
221
|
+
/* @__PURE__ */ w(
|
|
212
222
|
M,
|
|
213
223
|
{
|
|
214
224
|
presenceMap: a.map((c) => ({
|
|
@@ -216,7 +226,7 @@ const ie = {
|
|
|
216
226
|
value: !0
|
|
217
227
|
})),
|
|
218
228
|
children: [
|
|
219
|
-
a.map((c) => /* @__PURE__ */
|
|
229
|
+
a.map((c) => /* @__PURE__ */ s(
|
|
220
230
|
G,
|
|
221
231
|
{
|
|
222
232
|
as: P.span,
|
|
@@ -244,13 +254,13 @@ const ie = {
|
|
|
244
254
|
]
|
|
245
255
|
}
|
|
246
256
|
);
|
|
247
|
-
}, j =
|
|
257
|
+
}, j = l.createContext({
|
|
248
258
|
value: ""
|
|
249
|
-
}),
|
|
259
|
+
}), de = ({
|
|
250
260
|
value: t,
|
|
251
261
|
children: o,
|
|
252
262
|
...e
|
|
253
|
-
}) => /* @__PURE__ */
|
|
263
|
+
}) => /* @__PURE__ */ s(j.Provider, { value: { value: t }, children: /* @__PURE__ */ s(
|
|
254
264
|
K.Root,
|
|
255
265
|
{
|
|
256
266
|
as: P.span,
|
|
@@ -265,11 +275,11 @@ const ie = {
|
|
|
265
275
|
...e,
|
|
266
276
|
children: o
|
|
267
277
|
}
|
|
268
|
-
) }),
|
|
278
|
+
) }), me = ({
|
|
269
279
|
children: t,
|
|
270
280
|
...o
|
|
271
281
|
}) => {
|
|
272
|
-
const e =
|
|
282
|
+
const e = l.useContext(y), r = l.useContext(j), a = l.useMemo(() => {
|
|
273
283
|
const c = e.options.find(
|
|
274
284
|
(p) => p.value === r.value
|
|
275
285
|
);
|
|
@@ -286,13 +296,13 @@ const ie = {
|
|
|
286
296
|
r.value,
|
|
287
297
|
e.legacyBehavior
|
|
288
298
|
]);
|
|
289
|
-
return /* @__PURE__ */
|
|
290
|
-
},
|
|
299
|
+
return /* @__PURE__ */ s(K.Text, { ...o, children: t || a });
|
|
300
|
+
}, ye = ({
|
|
291
301
|
children: t,
|
|
292
302
|
...o
|
|
293
303
|
}) => {
|
|
294
|
-
const e =
|
|
295
|
-
return /* @__PURE__ */
|
|
304
|
+
const e = l.useContext(y), r = l.useContext(j);
|
|
305
|
+
return /* @__PURE__ */ s(
|
|
296
306
|
K.Button,
|
|
297
307
|
{
|
|
298
308
|
icon: { icon: E.X, alt: `Remove ${r.value}` },
|
|
@@ -305,26 +315,26 @@ const ie = {
|
|
|
305
315
|
children: t
|
|
306
316
|
}
|
|
307
317
|
);
|
|
308
|
-
},
|
|
318
|
+
}, be = ({
|
|
309
319
|
value: t,
|
|
310
320
|
children: o,
|
|
311
321
|
...e
|
|
312
|
-
}) => /* @__PURE__ */
|
|
313
|
-
/* @__PURE__ */
|
|
314
|
-
/* @__PURE__ */
|
|
322
|
+
}) => /* @__PURE__ */ w(D.Root, { value: t, ...e, children: [
|
|
323
|
+
/* @__PURE__ */ s(D.Text, { children: o }),
|
|
324
|
+
/* @__PURE__ */ s(D.Button, {})
|
|
315
325
|
] }), D = {
|
|
316
|
-
Root:
|
|
317
|
-
Text:
|
|
318
|
-
Button:
|
|
319
|
-
Default:
|
|
326
|
+
Root: de,
|
|
327
|
+
Text: me,
|
|
328
|
+
Button: ye,
|
|
329
|
+
Default: be
|
|
320
330
|
}, T = {
|
|
321
|
-
TriggerIndicator:
|
|
322
|
-
TriggerClear:
|
|
323
|
-
TriggerText:
|
|
324
|
-
TriggerPlaceholder:
|
|
325
|
-
TriggerTagsContainer:
|
|
331
|
+
TriggerIndicator: ue,
|
|
332
|
+
TriggerClear: pe,
|
|
333
|
+
TriggerText: ge,
|
|
334
|
+
TriggerPlaceholder: fe,
|
|
335
|
+
TriggerTagsContainer: he,
|
|
326
336
|
TriggerTag: D
|
|
327
|
-
},
|
|
337
|
+
}, ve = ["ArrowDown", "PageUp", "Home"], xe = ["ArrowUp", "PageDown", "End"], q = ["Enter", " "], y = l.createContext({
|
|
328
338
|
value: void 0,
|
|
329
339
|
onValueChange: () => {
|
|
330
340
|
},
|
|
@@ -339,7 +349,7 @@ const ie = {
|
|
|
339
349
|
disabled: !1,
|
|
340
350
|
options: [],
|
|
341
351
|
legacyBehavior: !1
|
|
342
|
-
}),
|
|
352
|
+
}), Ce = ({
|
|
343
353
|
modal: t = !0,
|
|
344
354
|
closeOnSelect: o = !0,
|
|
345
355
|
clearable: e = !1,
|
|
@@ -351,52 +361,52 @@ const ie = {
|
|
|
351
361
|
value: p,
|
|
352
362
|
onValueChange: g,
|
|
353
363
|
errored: b,
|
|
354
|
-
placeholder:
|
|
364
|
+
placeholder: x,
|
|
355
365
|
layout: d,
|
|
356
366
|
children: u,
|
|
357
367
|
...f
|
|
358
368
|
}) => {
|
|
359
|
-
const m =
|
|
369
|
+
const m = l.useId(), v = l.useId(), h = l.useRef(null), S = l.useRef(null), L = l.useRef(null), V = l.useMemo(() => le(u), [u]), [W, N] = l.useState(""), [B = !1, A] = oe({
|
|
360
370
|
prop: c,
|
|
361
371
|
defaultProp: i,
|
|
362
372
|
onChange: n
|
|
363
|
-
}),
|
|
364
|
-
A((
|
|
373
|
+
}), J = l.useCallback(() => {
|
|
374
|
+
A((Z) => !Z);
|
|
365
375
|
}, [A]);
|
|
366
|
-
return
|
|
367
|
-
|
|
368
|
-
}, [
|
|
376
|
+
return l.useEffect(() => {
|
|
377
|
+
B || N("");
|
|
378
|
+
}, [B]), /* @__PURE__ */ s(
|
|
369
379
|
y.Provider,
|
|
370
380
|
{
|
|
371
381
|
value: {
|
|
372
382
|
contentId: m,
|
|
373
|
-
triggerId:
|
|
383
|
+
triggerId: v,
|
|
374
384
|
value: p,
|
|
375
385
|
// Need to cast this to avoid type errors
|
|
376
386
|
// because the type of onValueChange is not
|
|
377
387
|
// consistent with the value type
|
|
378
388
|
onValueChange: g,
|
|
379
|
-
placeholder:
|
|
380
|
-
open:
|
|
389
|
+
placeholder: x,
|
|
390
|
+
open: B,
|
|
381
391
|
setOpen: A,
|
|
382
|
-
onOpenToggle:
|
|
392
|
+
onOpenToggle: J,
|
|
383
393
|
closeOnSelect: o,
|
|
384
394
|
clearable: e,
|
|
385
395
|
disabled: r,
|
|
386
|
-
searchQuery:
|
|
396
|
+
searchQuery: W,
|
|
387
397
|
setSearchQuery: N,
|
|
388
398
|
triggerRef: h,
|
|
389
|
-
searchRef:
|
|
399
|
+
searchRef: S,
|
|
390
400
|
contentRef: L,
|
|
391
401
|
errored: b,
|
|
392
402
|
layout: d,
|
|
393
403
|
options: V,
|
|
394
404
|
legacyBehavior: a
|
|
395
405
|
},
|
|
396
|
-
children: /* @__PURE__ */
|
|
406
|
+
children: /* @__PURE__ */ s(
|
|
397
407
|
Q.Root,
|
|
398
408
|
{
|
|
399
|
-
open:
|
|
409
|
+
open: B,
|
|
400
410
|
onOpenChange: A,
|
|
401
411
|
modal: t,
|
|
402
412
|
...f,
|
|
@@ -405,38 +415,38 @@ const ie = {
|
|
|
405
415
|
)
|
|
406
416
|
}
|
|
407
417
|
);
|
|
408
|
-
},
|
|
409
|
-
const t =
|
|
410
|
-
if (t.value &&
|
|
418
|
+
}, Te = () => {
|
|
419
|
+
const t = l.useContext(y);
|
|
420
|
+
if (t.value && R(t.value)) {
|
|
411
421
|
const o = t.layout || "truncate";
|
|
412
|
-
return t.value.length === 0 ? /* @__PURE__ */
|
|
422
|
+
return t.value.length === 0 ? /* @__PURE__ */ s(T.TriggerPlaceholder, {}) : /* @__PURE__ */ s(T.TriggerTagsContainer, { children: t.value.map((e, r) => {
|
|
413
423
|
const a = C(e, t.legacyBehavior);
|
|
414
424
|
if (a && (o === "truncate" && r <= 1 || o === "wrap"))
|
|
415
|
-
return /* @__PURE__ */
|
|
425
|
+
return /* @__PURE__ */ s(ne, { children: /* @__PURE__ */ s(T.TriggerTag.Default, { value: a }) }, a);
|
|
416
426
|
}) });
|
|
417
427
|
}
|
|
418
|
-
if (t &&
|
|
419
|
-
return t.value ? /* @__PURE__ */
|
|
420
|
-
},
|
|
428
|
+
if (t && I(t.value))
|
|
429
|
+
return t.value ? /* @__PURE__ */ s(T.TriggerText, {}) : /* @__PURE__ */ s(T.TriggerPlaceholder, {});
|
|
430
|
+
}, we = ({
|
|
421
431
|
size: t = "2",
|
|
422
432
|
children: o,
|
|
423
433
|
...e
|
|
424
434
|
}) => {
|
|
425
|
-
const r =
|
|
435
|
+
const r = l.useContext(y), a = l.useMemo(() => {
|
|
426
436
|
if (r.value) {
|
|
427
|
-
if (
|
|
437
|
+
if (I(r.value))
|
|
428
438
|
return F(
|
|
429
439
|
r.value,
|
|
430
440
|
r.options,
|
|
431
441
|
r.legacyBehavior
|
|
432
442
|
);
|
|
433
|
-
if (
|
|
443
|
+
if (R(r.value))
|
|
434
444
|
return r.value.map(
|
|
435
445
|
(n) => F(n, r.options, r.legacyBehavior)
|
|
436
446
|
);
|
|
437
447
|
}
|
|
438
|
-
}, [r.value, r.options, r.legacyBehavior]), c =
|
|
439
|
-
return /* @__PURE__ */
|
|
448
|
+
}, [r.value, r.options, r.legacyBehavior]), c = l.useCallback(() => a ? I(a) ? (a == null ? void 0 : a.label) || (a == null ? void 0 : a.value) || r.placeholder : R(a) && a.map((n) => (n == null ? void 0 : n.label) || (n == null ? void 0 : n.value)).join(", ") || r.placeholder : r.placeholder, [a, r.placeholder]);
|
|
449
|
+
return /* @__PURE__ */ s(
|
|
440
450
|
Q.Trigger,
|
|
441
451
|
{
|
|
442
452
|
...e,
|
|
@@ -450,7 +460,7 @@ const ie = {
|
|
|
450
460
|
n.stopPropagation();
|
|
451
461
|
return;
|
|
452
462
|
}
|
|
453
|
-
if (
|
|
463
|
+
if (q.includes(n.key)) {
|
|
454
464
|
n.preventDefault();
|
|
455
465
|
return;
|
|
456
466
|
}
|
|
@@ -460,15 +470,15 @@ const ie = {
|
|
|
460
470
|
}
|
|
461
471
|
},
|
|
462
472
|
tgphRef: r.triggerRef,
|
|
463
|
-
children: /* @__PURE__ */
|
|
464
|
-
|
|
473
|
+
children: /* @__PURE__ */ w(
|
|
474
|
+
O.Root,
|
|
465
475
|
{
|
|
466
476
|
id: r.triggerId,
|
|
467
477
|
type: "button",
|
|
468
478
|
bg: "surface-1",
|
|
469
479
|
variant: "outline",
|
|
470
480
|
align: "center",
|
|
471
|
-
minH:
|
|
481
|
+
minH: ce[t],
|
|
472
482
|
h: "full",
|
|
473
483
|
w: "full",
|
|
474
484
|
py: "1",
|
|
@@ -485,10 +495,10 @@ const ie = {
|
|
|
485
495
|
disabled: r.disabled,
|
|
486
496
|
...e,
|
|
487
497
|
children: [
|
|
488
|
-
o ? typeof o == "function" ? o({ value: a }) : o : /* @__PURE__ */
|
|
489
|
-
/* @__PURE__ */
|
|
490
|
-
/* @__PURE__ */
|
|
491
|
-
/* @__PURE__ */
|
|
498
|
+
o ? typeof o == "function" ? o({ value: a }) : o : /* @__PURE__ */ s(Te, {}),
|
|
499
|
+
/* @__PURE__ */ w(k, { align: "center", gap: "1", children: [
|
|
500
|
+
/* @__PURE__ */ s(T.TriggerClear, {}),
|
|
501
|
+
/* @__PURE__ */ s(T.TriggerIndicator, {})
|
|
492
502
|
] })
|
|
493
503
|
]
|
|
494
504
|
}
|
|
@@ -501,35 +511,35 @@ const ie = {
|
|
|
501
511
|
tgphRef: e,
|
|
502
512
|
...r
|
|
503
513
|
}) => {
|
|
504
|
-
const a =
|
|
514
|
+
const a = l.useContext(y), c = l.useRef(!1), n = $(e, a.contentRef), i = l.useRef(null), [p, g] = l.useState(0), [b, x] = l.useState(!1), d = l.useCallback(
|
|
505
515
|
(u) => {
|
|
506
516
|
const f = u == null ? void 0 : u.getBoundingClientRect();
|
|
507
|
-
f && g(f.height), b ||
|
|
517
|
+
f && g(f.height), b || x(!0);
|
|
508
518
|
},
|
|
509
519
|
[b]
|
|
510
520
|
);
|
|
511
|
-
return
|
|
521
|
+
return l.useEffect(() => {
|
|
512
522
|
const u = new ResizeObserver((f) => {
|
|
513
523
|
for (const m of f) {
|
|
514
|
-
const
|
|
515
|
-
d(
|
|
524
|
+
const v = m.target;
|
|
525
|
+
d(v);
|
|
516
526
|
}
|
|
517
527
|
});
|
|
518
528
|
return i.current && b && u.observe(i.current), () => u.disconnect();
|
|
519
|
-
}, [b, d]),
|
|
520
|
-
b === !0 && a.open === !1 &&
|
|
521
|
-
}, [a.open, b]),
|
|
529
|
+
}, [b, d]), l.useEffect(() => {
|
|
530
|
+
b === !0 && a.open === !1 && x(!1);
|
|
531
|
+
}, [a.open, b]), l.useEffect(() => {
|
|
522
532
|
let u;
|
|
523
533
|
return a.open && (u = setTimeout(() => {
|
|
524
534
|
d(i.current);
|
|
525
535
|
}, 10)), () => u && clearTimeout(u);
|
|
526
|
-
}, [a.open, d]), /* @__PURE__ */
|
|
527
|
-
|
|
536
|
+
}, [a.open, d]), /* @__PURE__ */ s(te.Root, { asChild: !0, children: /* @__PURE__ */ s(
|
|
537
|
+
ee,
|
|
528
538
|
{
|
|
529
539
|
onEscapeKeyDown: (u) => {
|
|
530
540
|
a.open && (u.stopPropagation(), u.preventDefault(), a.setOpen(!1));
|
|
531
541
|
},
|
|
532
|
-
children: /* @__PURE__ */
|
|
542
|
+
children: /* @__PURE__ */ s(
|
|
533
543
|
Q.Content,
|
|
534
544
|
{
|
|
535
545
|
className: "tgph",
|
|
@@ -557,22 +567,22 @@ const ie = {
|
|
|
557
567
|
role: void 0,
|
|
558
568
|
"aria-orientation": void 0,
|
|
559
569
|
onKeyDown: (u) => {
|
|
560
|
-
var m,
|
|
570
|
+
var m, v, h, S;
|
|
561
571
|
u.stopPropagation();
|
|
562
|
-
const f = (
|
|
572
|
+
const f = (v = (m = a.contentRef) == null ? void 0 : m.current) == null ? void 0 : v.querySelectorAll(
|
|
563
573
|
"[data-tgph-combobox-option]"
|
|
564
574
|
);
|
|
565
|
-
document.activeElement === (f == null ? void 0 : f[0]) && xe.includes(u.key) && ((
|
|
575
|
+
document.activeElement === (f == null ? void 0 : f[0]) && xe.includes(u.key) && ((S = (h = a.searchRef) == null ? void 0 : h.current) == null || S.focus());
|
|
566
576
|
},
|
|
567
|
-
children: /* @__PURE__ */
|
|
577
|
+
children: /* @__PURE__ */ s(k, { direction: "column", gap: "1", tgphRef: i, children: o })
|
|
568
578
|
}
|
|
569
579
|
)
|
|
570
580
|
}
|
|
571
581
|
) });
|
|
572
582
|
}, Se = ({ ...t }) => {
|
|
573
|
-
const o =
|
|
574
|
-
return /* @__PURE__ */
|
|
575
|
-
|
|
583
|
+
const o = l.useContext(y);
|
|
584
|
+
return /* @__PURE__ */ s(
|
|
585
|
+
k,
|
|
576
586
|
{
|
|
577
587
|
id: o.contentId,
|
|
578
588
|
direction: "column",
|
|
@@ -586,7 +596,7 @@ const ie = {
|
|
|
586
596
|
...t
|
|
587
597
|
}
|
|
588
598
|
);
|
|
589
|
-
},
|
|
599
|
+
}, U = ({
|
|
590
600
|
value: t,
|
|
591
601
|
label: o,
|
|
592
602
|
selected: e,
|
|
@@ -594,47 +604,47 @@ const ie = {
|
|
|
594
604
|
children: a,
|
|
595
605
|
...c
|
|
596
606
|
}) => {
|
|
597
|
-
const n =
|
|
607
|
+
const n = l.useContext(y), [i, p] = l.useState(!1), g = n.value, b = !n.searchQuery || se({
|
|
598
608
|
children: o || a,
|
|
599
609
|
value: t,
|
|
600
610
|
searchQuery: n.searchQuery
|
|
601
|
-
}),
|
|
611
|
+
}), x = R(g) ? g.some(
|
|
602
612
|
(u) => C(u, n.legacyBehavior) === t
|
|
603
613
|
) : C(g, n.legacyBehavior) === t, d = (u) => {
|
|
604
|
-
var m,
|
|
614
|
+
var m, v;
|
|
605
615
|
u.stopPropagation();
|
|
606
616
|
const f = u;
|
|
607
|
-
if (!(f.key && !
|
|
617
|
+
if (!(f.key && !q.includes(f.key))) {
|
|
608
618
|
if (u.preventDefault(), n.closeOnSelect === !0 && n.setOpen(!1), r)
|
|
609
619
|
return r(u);
|
|
610
|
-
if (
|
|
620
|
+
if (I(g)) {
|
|
611
621
|
const h = n.onValueChange;
|
|
612
622
|
n.legacyBehavior === !0 ? h == null || h({ value: t, label: o }) : h == null || h(t);
|
|
613
|
-
} else if (
|
|
614
|
-
const h = n.onValueChange,
|
|
623
|
+
} else if (R(g)) {
|
|
624
|
+
const h = n.onValueChange, S = n.value, L = x ? S.filter(
|
|
615
625
|
(V) => C(V, n.legacyBehavior) !== t
|
|
616
626
|
) : [
|
|
617
|
-
...
|
|
627
|
+
...S,
|
|
618
628
|
// TODO: Remove this once { value, label } option is deprecated
|
|
619
629
|
n.legacyBehavior === !0 ? { value: t, label: o } : t
|
|
620
630
|
];
|
|
621
631
|
h == null || h(L);
|
|
622
632
|
}
|
|
623
|
-
(
|
|
633
|
+
(v = (m = n.triggerRef) == null ? void 0 : m.current) == null || v.focus();
|
|
624
634
|
}
|
|
625
635
|
};
|
|
626
636
|
if (b)
|
|
627
|
-
return /* @__PURE__ */
|
|
637
|
+
return /* @__PURE__ */ s(
|
|
628
638
|
Q.Button,
|
|
629
639
|
{
|
|
630
640
|
type: "button",
|
|
631
641
|
onSelect: d,
|
|
632
642
|
onKeyDown: d,
|
|
633
|
-
selected: e === null ? null : e ??
|
|
643
|
+
selected: e === null ? null : e ?? x,
|
|
634
644
|
onFocus: () => p(!0),
|
|
635
645
|
onBlur: () => p(!1),
|
|
636
646
|
role: "option",
|
|
637
|
-
"aria-selected":
|
|
647
|
+
"aria-selected": x ? "true" : "false",
|
|
638
648
|
"data-tgph-combobox-option": !0,
|
|
639
649
|
"data-tgph-combobox-option-focused": i,
|
|
640
650
|
"data-tgph-combobox-option-value": t,
|
|
@@ -643,7 +653,7 @@ const ie = {
|
|
|
643
653
|
children: o || a || t
|
|
644
654
|
}
|
|
645
655
|
);
|
|
646
|
-
},
|
|
656
|
+
}, Ee = ({
|
|
647
657
|
label: t = "Search",
|
|
648
658
|
placeholder: o = "Search",
|
|
649
659
|
tgphRef: e,
|
|
@@ -651,22 +661,22 @@ const ie = {
|
|
|
651
661
|
onValueChange: a,
|
|
652
662
|
...c
|
|
653
663
|
}) => {
|
|
654
|
-
var
|
|
655
|
-
const n =
|
|
656
|
-
return
|
|
664
|
+
var x;
|
|
665
|
+
const n = l.useId(), i = l.useContext(y), p = $(e, i.searchRef), g = r ?? i.searchQuery, b = a ?? i.setSearchQuery;
|
|
666
|
+
return l.useEffect(() => {
|
|
657
667
|
var f;
|
|
658
668
|
const d = (m) => {
|
|
659
|
-
var
|
|
660
|
-
|
|
669
|
+
var v, h;
|
|
670
|
+
ve.includes(m.key) && ((h = (v = i.contentRef) == null ? void 0 : v.current) == null || h.focus({ preventScroll: !0 })), m.key === "Escape" && i.setOpen(!1), m.stopPropagation();
|
|
661
671
|
}, u = (f = i.searchRef) == null ? void 0 : f.current;
|
|
662
672
|
if (u)
|
|
663
673
|
return u.addEventListener("keydown", d), () => {
|
|
664
674
|
u.removeEventListener("keydown", d);
|
|
665
675
|
};
|
|
666
|
-
}, [i]), /* @__PURE__ */
|
|
667
|
-
/* @__PURE__ */
|
|
668
|
-
/* @__PURE__ */
|
|
669
|
-
|
|
676
|
+
}, [i]), /* @__PURE__ */ w(G, { borderBottom: "px", px: "1", pb: "1", children: [
|
|
677
|
+
/* @__PURE__ */ s(re.Root, { children: /* @__PURE__ */ s(H, { as: "label", htmlFor: n, children: t }) }),
|
|
678
|
+
/* @__PURE__ */ s(
|
|
679
|
+
ae,
|
|
670
680
|
{
|
|
671
681
|
id: n,
|
|
672
682
|
variant: "ghost",
|
|
@@ -675,9 +685,9 @@ const ie = {
|
|
|
675
685
|
onChange: (d) => {
|
|
676
686
|
b(d.target.value);
|
|
677
687
|
},
|
|
678
|
-
LeadingComponent: /* @__PURE__ */
|
|
679
|
-
TrailingComponent: i != null && i.searchQuery && ((
|
|
680
|
-
|
|
688
|
+
LeadingComponent: /* @__PURE__ */ s(z, { icon: E.Search, alt: "Search Icon" }),
|
|
689
|
+
TrailingComponent: i != null && i.searchQuery && ((x = i == null ? void 0 : i.searchQuery) == null ? void 0 : x.length) > 0 ? /* @__PURE__ */ s(
|
|
690
|
+
O,
|
|
681
691
|
{
|
|
682
692
|
variant: "ghost",
|
|
683
693
|
color: "gray",
|
|
@@ -696,22 +706,22 @@ const ie = {
|
|
|
696
706
|
}
|
|
697
707
|
)
|
|
698
708
|
] });
|
|
699
|
-
},
|
|
709
|
+
}, Ie = ({
|
|
700
710
|
icon: t = { icon: E.Search, alt: "Search Icon" },
|
|
701
711
|
message: o = "No results found",
|
|
702
712
|
children: e,
|
|
703
713
|
...r
|
|
704
714
|
}) => {
|
|
705
|
-
const a =
|
|
706
|
-
if (
|
|
715
|
+
const a = l.useContext(y), [c, n] = l.useState(!1);
|
|
716
|
+
if (l.useEffect(() => {
|
|
707
717
|
var p, g;
|
|
708
718
|
const i = (g = (p = a.contentRef) == null ? void 0 : p.current) == null ? void 0 : g.querySelectorAll(
|
|
709
719
|
"[data-tgph-combobox-option]"
|
|
710
720
|
);
|
|
711
721
|
(i == null ? void 0 : i.length) === 0 ? n(!0) : n(!1);
|
|
712
722
|
}, [a.searchQuery, a.contentRef, e]), c)
|
|
713
|
-
return /* @__PURE__ */
|
|
714
|
-
|
|
723
|
+
return /* @__PURE__ */ w(
|
|
724
|
+
k,
|
|
715
725
|
{
|
|
716
726
|
gap: "1",
|
|
717
727
|
align: "center",
|
|
@@ -721,8 +731,8 @@ const ie = {
|
|
|
721
731
|
"data-tgph-combobox-empty": !0,
|
|
722
732
|
...r,
|
|
723
733
|
children: [
|
|
724
|
-
t === null ? /* @__PURE__ */
|
|
725
|
-
o === null ? /* @__PURE__ */
|
|
734
|
+
t === null ? /* @__PURE__ */ s(_, {}) : /* @__PURE__ */ s(z, { ...t }),
|
|
735
|
+
o === null ? /* @__PURE__ */ s(_, {}) : /* @__PURE__ */ s(H, { as: "span", children: o })
|
|
726
736
|
]
|
|
727
737
|
}
|
|
728
738
|
);
|
|
@@ -734,15 +744,15 @@ const ie = {
|
|
|
734
744
|
legacyBehavior: a = !1,
|
|
735
745
|
...c
|
|
736
746
|
}) => {
|
|
737
|
-
const n =
|
|
747
|
+
const n = l.useContext(y), i = l.useCallback(
|
|
738
748
|
(p) => !o || (o == null ? void 0 : o.length) === 0 ? !1 : o.some(
|
|
739
749
|
(g) => C(g, a) === p
|
|
740
750
|
),
|
|
741
751
|
[o, a]
|
|
742
752
|
);
|
|
743
753
|
if (n.searchQuery && !i(n.searchQuery))
|
|
744
|
-
return /* @__PURE__ */
|
|
745
|
-
|
|
754
|
+
return /* @__PURE__ */ s(
|
|
755
|
+
U,
|
|
746
756
|
{
|
|
747
757
|
leadingIcon: { icon: E.Plus, "aria-hidden": !0 },
|
|
748
758
|
mx: "1",
|
|
@@ -759,19 +769,19 @@ const ie = {
|
|
|
759
769
|
...c
|
|
760
770
|
}
|
|
761
771
|
);
|
|
762
|
-
},
|
|
763
|
-
Object.assign(
|
|
764
|
-
Root:
|
|
765
|
-
Trigger:
|
|
772
|
+
}, Oe = {};
|
|
773
|
+
Object.assign(Oe, {
|
|
774
|
+
Root: Ce,
|
|
775
|
+
Trigger: we,
|
|
766
776
|
Content: Re,
|
|
767
777
|
Options: Se,
|
|
768
|
-
Option:
|
|
769
|
-
Search:
|
|
770
|
-
Empty:
|
|
778
|
+
Option: U,
|
|
779
|
+
Search: Ee,
|
|
780
|
+
Empty: Ie,
|
|
771
781
|
Create: ke,
|
|
772
782
|
Primitives: T
|
|
773
783
|
});
|
|
774
784
|
export {
|
|
775
|
-
|
|
785
|
+
Oe as Combobox
|
|
776
786
|
};
|
|
777
787
|
//# sourceMappingURL=index.mjs.map
|