@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.
@@ -1,4 +1,4 @@
1
- import { jsx as l, jsxs as S, Fragment as K } from "react/jsx-runtime";
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 B, AnimatePresence as P } from "@telegraph/motion";
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 i from "react";
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 r = (a, u = []) => (i.Children.toArray(a).forEach((n) => {
25
- i.isValidElement(n) && (n.props.value ? u.push(n) : n.props.children && r(n.props.children, u));
26
- }), u);
27
- return r(t).map((a) => {
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 u = a;
29
+ const i = r;
30
30
  return {
31
- value: u.props.value,
32
- label: ((o = u.props) == null ? void 0 : o.label) || u.props.children || u.props.value
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, r) => {
35
+ }, C = (t, a) => {
36
36
  if (t)
37
- return r === !0 ? t == null ? void 0 : t.value : t;
38
- }, F = (t, r, e) => {
39
- if (!t || !r || r.length === 0) return;
40
- const p = r.find(
41
- (a) => a.value === C(t, e)
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: r,
47
+ value: a,
48
48
  searchQuery: e
49
- }) => (r == null ? void 0 : r.toLowerCase().includes(e.toLowerCase())) || (t == null ? void 0 : t.toLowerCase().includes(e.toLowerCase())), ae = ["ArrowDown", "PageUp", "Home"], ie = ["ArrowUp", "PageDown", "End"], z = ["Enter", " "], x = i.createContext({
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: r = !0,
66
+ closeOnSelect: a = !0,
67
67
  clearable: e = !1,
68
68
  disabled: p = !1,
69
- legacyBehavior: a = !1,
70
- open: u,
69
+ legacyBehavior: r = !1,
70
+ open: i,
71
71
  onOpenChange: o,
72
72
  defaultOpen: n,
73
- value: c,
73
+ value: s,
74
74
  onValueChange: f,
75
75
  errored: y,
76
76
  placeholder: v,
77
77
  layout: d,
78
- children: s,
78
+ children: l,
79
79
  ...g
80
80
  }) => {
81
- const m = i.useId(), b = i.useId(), h = i.useRef(null), R = i.useRef(null), D = i.useRef(null), V = i.useMemo(() => ne(s), [s]), [Y, H] = i.useState(""), [O = !1, A] = W({
82
- prop: u,
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 = i.useCallback(() => {
86
- A((X) => !X);
87
- }, [A]);
88
- return i.useEffect(() => {
85
+ }), N = c.useCallback(() => {
86
+ B((X) => !X);
87
+ }, [B]);
88
+ return c.useEffect(() => {
89
89
  O || H("");
90
- }, [O]), /* @__PURE__ */ l(
90
+ }, [O]), /* @__PURE__ */ u(
91
91
  x.Provider,
92
92
  {
93
93
  value: {
94
94
  contentId: m,
95
95
  triggerId: b,
96
- value: c,
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: A,
103
+ setOpen: B,
104
104
  onOpenToggle: N,
105
- closeOnSelect: r,
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: a
116
+ legacyBehavior: r
117
117
  },
118
- children: /* @__PURE__ */ l(
118
+ children: /* @__PURE__ */ u(
119
119
  Q.Root,
120
120
  {
121
121
  open: O,
122
- onOpenChange: A,
122
+ onOpenChange: B,
123
123
  modal: t,
124
124
  ...g,
125
- children: s
125
+ children: l
126
126
  }
127
127
  )
128
128
  }
129
129
  );
130
- }, se = ({ value: t, ...r }) => {
131
- const e = i.useContext(x), p = i.useMemo(() => {
132
- const a = e.options.find((n) => n.value === t);
133
- if (a) return a.label || a.value;
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: B.span,
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
- ...r,
153
+ ...a,
154
154
  children: [
155
- /* @__PURE__ */ l(L.Text, { children: p }),
156
- /* @__PURE__ */ l(
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: (a) => {
160
+ onClick: (r) => {
161
161
  if (!e.onValueChange) return;
162
- const u = e.onValueChange, n = e.value.filter((c) => C(c, e.legacyBehavior) !== t);
163
- u == null || u(n), a.stopPropagation(), a.preventDefault();
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
- const t = i.useContext(x);
171
+ var a;
172
+ const t = c.useContext(x);
172
173
  if (t.value && k(t.value)) {
173
- const r = t.layout || "truncate", e = t.value.length - 2, p = e.toString().split("");
174
- return t.value.length === 0 ? /* @__PURE__ */ l(E.Text, { color: "gray", children: t.placeholder }) : /* @__PURE__ */ S(
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: r === "wrap" ? "wrap" : "nowrap",
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__ */ l(
187
+ /* @__PURE__ */ u(
187
188
  P,
188
189
  {
189
- presenceMap: t.value.map((a) => ({
190
- "tgph-motion-key": C(a, t.legacyBehavior) || "",
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((a, u) => {
194
- const o = C(a, t.legacyBehavior);
195
- if (o && (r === "truncate" && u <= 1 || r === "wrap"))
196
- return /* @__PURE__ */ l(Z, { children: /* @__PURE__ */ l(se, { value: o }) }, o);
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__ */ l(
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: r === "truncate" && t.value.length > 2 && /* @__PURE__ */ l(
210
+ children: e === "truncate" && t.value.length > 2 && /* @__PURE__ */ u(
210
211
  I,
211
212
  {
212
- as: B.div,
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": `${e} more selected`,
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: p.map((a) => ({
233
- "tgph-motion-key": a,
233
+ presenceMap: r.map((i) => ({
234
+ "tgph-motion-key": i,
234
235
  value: !0
235
236
  })),
236
237
  children: [
237
- p.map((a) => /* @__PURE__ */ l(
238
+ r.map((i) => /* @__PURE__ */ u(
238
239
  $,
239
240
  {
240
- as: B.span,
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": a,
248
- children: a
248
+ "tgph-motion-key": i,
249
+ children: i
249
250
  },
250
- a
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 r = F(
268
+ const e = F(
268
269
  t.value,
269
270
  t.options,
270
271
  t.legacyBehavior
271
- );
272
- return /* @__PURE__ */ l(E.Text, { color: t.value ? "default" : "gray", children: (r == null ? void 0 : r.label) || (r == null ? void 0 : r.value) || t.placeholder });
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", ...r }) => {
275
- const e = i.useContext(x), p = i.useCallback(() => {
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 c = F(
289
+ const s = F(
289
290
  n,
290
291
  e.options,
291
292
  e.legacyBehavior
292
293
  );
293
- return c == null ? void 0 : c.label;
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
- ]), a = i.useMemo(() => {
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]), u = () => {
307
+ }, [e.clearable, e.value]), i = () => {
307
308
  var o, n;
308
309
  if (k(e.value)) {
309
- const c = e.onValueChange;
310
- c == null || c([]);
310
+ const s = e.onValueChange;
311
+ s == null || s([]);
311
312
  }
312
313
  if (T(e.value)) {
313
- const c = e.onValueChange;
314
- c == null || c(void 0);
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__ */ l(
319
+ return /* @__PURE__ */ u(
319
320
  Q.Trigger,
320
321
  {
321
- ...r,
322
+ ...a,
322
323
  asChild: !0,
323
324
  onClick: (o) => {
324
- var n, c;
325
- o.preventDefault(), e.onOpenToggle(), (c = (n = e.triggerRef) == null ? void 0 : n.current) == null || c.focus();
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__ */ l(le, {}),
367
+ /* @__PURE__ */ u(le, {}),
367
368
  /* @__PURE__ */ S(I, { align: "center", gap: "1", children: [
368
- a && /* @__PURE__ */ l(te, { label: "Clear field", children: /* @__PURE__ */ l(
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(), u());
377
+ e.value && (o.stopPropagation(), i());
377
378
  },
378
379
  onKeyDown: (o) => {
379
- (o.key === "Enter" || o.key === " ") && (o.stopPropagation(), u());
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__ */ l(
391
+ /* @__PURE__ */ u(
391
392
  E.Icon,
392
393
  {
393
- as: B.span,
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: r,
409
+ children: a,
409
410
  tgphRef: e,
410
411
  ...p
411
412
  }) => {
412
- const a = i.useContext(x), u = i.useRef(!1), o = j(e, a.contentRef), n = i.useRef(null), [c, f] = i.useState(0), [y, v] = i.useState(!1), d = i.useCallback(
413
- (s) => {
414
- const g = s == null ? void 0 : s.getBoundingClientRect();
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 i.useEffect(() => {
420
- const s = new ResizeObserver((g) => {
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 && s.observe(n.current), () => s.disconnect();
427
- }, [y, d]), i.useEffect(() => {
428
- y === !0 && a.open === !1 && v(!1);
429
- }, [a.open, y]), i.useEffect(() => {
430
- let s;
431
- return a.open && (s = setTimeout(() => {
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)), () => s && clearTimeout(s);
434
- }, [a.open, d]), /* @__PURE__ */ l(U.Root, { asChild: !0, children: /* @__PURE__ */ l(
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: (s) => {
438
- a.open && (s.stopPropagation(), s.preventDefault(), a.setOpen(!1));
438
+ onEscapeKeyDown: (l) => {
439
+ r.open && (l.stopPropagation(), l.preventDefault(), r.setOpen(!1));
439
440
  },
440
- children: /* @__PURE__ */ l(
441
+ children: /* @__PURE__ */ u(
441
442
  Q.Content,
442
443
  {
443
444
  className: "tgph",
444
445
  mt: "1",
445
- onCloseAutoFocus: (s) => {
446
+ onCloseAutoFocus: (l) => {
446
447
  var g, m;
447
- u.current || (m = (g = a.triggerRef) == null ? void 0 : g.current) == null || m.focus(), u.current = !1, s.preventDefault();
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: c ? `${c}px` : "0",
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": a.open,
465
+ "data-tgph-combobox-content-open": r.open,
465
466
  role: void 0,
466
467
  "aria-orientation": void 0,
467
- onKeyDown: (s) => {
468
+ onKeyDown: (l) => {
468
469
  var m, b, h, R;
469
- s.stopPropagation();
470
- const g = (b = (m = a.contentRef) == null ? void 0 : m.current) == null ? void 0 : b.querySelectorAll(
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(s.key) && ((R = (h = a.searchRef) == null ? void 0 : h.current) == null || R.focus());
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__ */ l(I, { direction: "column", gap: "1", tgphRef: n, children: r })
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 r = i.useContext(x);
482
- return /* @__PURE__ */ l(
482
+ const a = c.useContext(x);
483
+ return /* @__PURE__ */ u(
483
484
  I,
484
485
  {
485
- id: r.contentId,
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: r,
500
+ label: a,
500
501
  selected: e,
501
502
  onSelect: p,
502
- children: a,
503
- ...u
503
+ children: r,
504
+ ...i
504
505
  }) => {
505
- const o = i.useContext(x), [n, c] = i.useState(!1), f = o.value, y = !o.searchQuery || re({
506
- label: (r == null ? void 0 : r.toString()) || (a == null ? void 0 : a.toString()),
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
- (s) => C(s, o.legacyBehavior) === t
511
- ) : C(f, o.legacyBehavior) === t, d = (s) => {
511
+ (l) => C(l, o.legacyBehavior) === t
512
+ ) : C(f, o.legacyBehavior) === t, d = (l) => {
512
513
  var m, b;
513
- s.stopPropagation();
514
- const g = s;
514
+ l.stopPropagation();
515
+ const g = l;
515
516
  if (!(g.key && !z.includes(g.key))) {
516
- if (s.preventDefault(), o.closeOnSelect === !0 && o.setOpen(!1), p)
517
- return p(s);
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: r }) : h == null || h(t);
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: r } : t
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__ */ l(
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: () => c(!0),
543
- onBlur: () => c(!1),
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": r,
550
- ...u,
551
- children: r || a || t
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: r = "Search",
557
+ placeholder: a = "Search",
557
558
  tgphRef: e,
558
559
  value: p,
559
- onValueChange: a,
560
- ...u
560
+ onValueChange: r,
561
+ ...i
561
562
  }) => {
562
563
  var v;
563
- const o = i.useId(), n = i.useContext(x), c = j(e, n.searchRef), f = p ?? n.searchQuery, y = a ?? n.setSearchQuery;
564
- return i.useEffect(() => {
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
- }, s = (g = n.searchRef) == null ? void 0 : g.current;
570
- if (s)
571
- return s.addEventListener("keydown", d), () => {
572
- s.removeEventListener("keydown", d);
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__ */ l(J.Root, { children: /* @__PURE__ */ l(M, { as: "label", htmlFor: o, children: t }) }),
576
- /* @__PURE__ */ l(
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: r,
582
+ placeholder: a,
582
583
  value: f,
583
584
  onChange: (d) => {
584
585
  y(d.target.value);
585
586
  },
586
- LeadingComponent: /* @__PURE__ */ l(_, { icon: w.Search, alt: "Search Icon" }),
587
- TrailingComponent: n != null && n.searchQuery && ((v = n == null ? void 0 : n.searchQuery) == null ? void 0 : v.length) > 0 ? /* @__PURE__ */ l(
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
- ...u,
603
- tgphRef: c
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: r = "No results found",
610
+ message: a = "No results found",
610
611
  children: e,
611
612
  ...p
612
613
  }) => {
613
- const a = i.useContext(x), [u, o] = i.useState(!1);
614
- if (i.useEffect(() => {
615
- var c, f;
616
- const n = (f = (c = a.contentRef) == null ? void 0 : c.current) == null ? void 0 : f.querySelectorAll(
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
- }, [a.searchQuery, a.contentRef, e]), u)
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__ */ l(K, {}) : /* @__PURE__ */ l(_, { ...t }),
633
- r === null ? /* @__PURE__ */ l(K, {}) : /* @__PURE__ */ l(M, { as: "span", children: r })
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: r,
640
+ values: a,
640
641
  onCreate: e,
641
642
  selected: p = null,
642
- legacyBehavior: a = !1,
643
- ...u
643
+ legacyBehavior: r = !1,
644
+ ...i
644
645
  }) => {
645
- const o = i.useContext(x), n = i.useCallback(
646
- (c) => !r || (r == null ? void 0 : r.length) === 0 ? !1 : r.some(
647
- (f) => C(f, a) === c
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
- [r, a]
650
+ [a, r]
650
651
  );
651
652
  if (o.searchQuery && !n(o.searchQuery))
652
- return /* @__PURE__ */ l(
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 c;
662
+ var s;
662
663
  if (e && o.value && o.searchQuery) {
663
- const f = a === !0 ? { value: o.searchQuery } : o.searchQuery;
664
- e(f), (c = o.setSearchQuery) == null || c.call(o, "");
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
- ...u
668
+ ...i
668
669
  }
669
670
  );
670
671
  }, me = {};