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