@brightlocal/ui-components 3.4.0 → 3.5.0

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.
Files changed (196) hide show
  1. package/AI_USAGE.md +22 -3
  2. package/README.md +177 -109
  3. package/component-meta.json +1061 -102
  4. package/dist/alert-dialog.cjs +1 -1
  5. package/dist/alert-dialog.d.ts +13 -2
  6. package/dist/alert-dialog.d.ts.map +1 -1
  7. package/dist/alert-dialog.js +4 -3
  8. package/dist/banner.cjs +1 -1
  9. package/dist/banner.d.ts +47 -11
  10. package/dist/banner.d.ts.map +1 -1
  11. package/dist/banner.js +156 -79
  12. package/dist/blocks/empty-state.cjs +1 -1
  13. package/dist/blocks/empty-state.d.ts +40 -5
  14. package/dist/blocks/empty-state.d.ts.map +1 -1
  15. package/dist/blocks/empty-state.js +59 -52
  16. package/dist/blocks/input-list.d.ts +1 -0
  17. package/dist/blocks/input-list.d.ts.map +1 -1
  18. package/dist/blocks/sidebar.cjs +1 -1
  19. package/dist/blocks/sidebar.d.ts +12 -6
  20. package/dist/blocks/sidebar.d.ts.map +1 -1
  21. package/dist/blocks/sidebar.js +64 -63
  22. package/dist/button.cjs +1 -1
  23. package/dist/button.d.ts.map +1 -1
  24. package/dist/button.js +47 -43
  25. package/dist/card.cjs +1 -1
  26. package/dist/card.d.ts +12 -0
  27. package/dist/card.d.ts.map +1 -1
  28. package/dist/card.js +115 -97
  29. package/dist/chart.cjs +6 -6
  30. package/dist/chart.d.ts +6 -10
  31. package/dist/chart.d.ts.map +1 -1
  32. package/dist/chart.js +281 -296
  33. package/dist/combobox.cjs +3 -3
  34. package/dist/combobox.d.ts.map +1 -1
  35. package/dist/combobox.js +430 -343
  36. package/dist/command.cjs +1 -1
  37. package/dist/command.d.ts +23 -2
  38. package/dist/command.d.ts.map +1 -1
  39. package/dist/command.js +212 -207
  40. package/dist/count-indicator.cjs +1 -0
  41. package/dist/count-indicator.d.ts +85 -0
  42. package/dist/count-indicator.d.ts.map +1 -0
  43. package/dist/count-indicator.js +72 -0
  44. package/dist/data-table.cjs +1 -1
  45. package/dist/data-table.d.ts +101 -11
  46. package/dist/data-table.d.ts.map +1 -1
  47. package/dist/data-table.js +593 -523
  48. package/dist/dialog.cjs +1 -1
  49. package/dist/dialog.d.ts +26 -3
  50. package/dist/dialog.d.ts.map +1 -1
  51. package/dist/dialog.js +62 -47
  52. package/dist/drawer.cjs +1 -1
  53. package/dist/drawer.d.ts +8 -4
  54. package/dist/drawer.d.ts.map +1 -1
  55. package/dist/drawer.js +37 -38
  56. package/dist/file-upload.cjs +1 -0
  57. package/dist/file-upload.d.ts +546 -0
  58. package/dist/file-upload.d.ts.map +1 -0
  59. package/dist/file-upload.js +1103 -0
  60. package/dist/global-layout.cjs +1 -1
  61. package/dist/global-layout.d.ts +7 -2
  62. package/dist/global-layout.d.ts.map +1 -1
  63. package/dist/global-layout.js +52 -52
  64. package/dist/hooks/use-file-dropzone.cjs +1 -0
  65. package/dist/hooks/use-file-dropzone.d.ts +75 -0
  66. package/dist/hooks/use-file-dropzone.d.ts.map +1 -0
  67. package/dist/hooks/use-file-dropzone.js +133 -0
  68. package/dist/hover-card.cjs +1 -1
  69. package/dist/hover-card.d.ts +29 -16
  70. package/dist/hover-card.d.ts.map +1 -1
  71. package/dist/hover-card.js +153 -36
  72. package/dist/index.cjs +1 -1
  73. package/dist/index.d.ts +3 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +676 -640
  76. package/dist/input-chip.cjs +1 -1
  77. package/dist/input-chip.d.ts +30 -1
  78. package/dist/input-chip.d.ts.map +1 -1
  79. package/dist/input-chip.js +131 -115
  80. package/dist/input-group.cjs +1 -1
  81. package/dist/input-group.d.ts +37 -2
  82. package/dist/input-group.d.ts.map +1 -1
  83. package/dist/input-group.js +131 -114
  84. package/dist/input-password.cjs +1 -1
  85. package/dist/input-password.js +6 -6
  86. package/dist/lib/empty-canvas.cjs +1 -1
  87. package/dist/lib/empty-canvas.d.ts +27 -1
  88. package/dist/lib/empty-canvas.d.ts.map +1 -1
  89. package/dist/lib/empty-canvas.js +27 -23
  90. package/dist/lib/empty-chip.cjs +1 -1
  91. package/dist/lib/empty-chip.d.ts +19 -2
  92. package/dist/lib/empty-chip.d.ts.map +1 -1
  93. package/dist/lib/empty-chip.js +14 -9
  94. package/dist/lib/field-aria.cjs +1 -1
  95. package/dist/lib/field-aria.d.ts +4 -4
  96. package/dist/lib/field-aria.d.ts.map +1 -1
  97. package/dist/lib/field-aria.js +7 -5
  98. package/dist/lib/media-viewer-content.cjs +1 -1
  99. package/dist/lib/media-viewer-content.js +1 -1
  100. package/dist/lib/table-internal.cjs +1 -1
  101. package/dist/lib/table-internal.d.ts +19 -0
  102. package/dist/lib/table-internal.d.ts.map +1 -1
  103. package/dist/lib/table-internal.js +22 -7
  104. package/dist/list.cjs +1 -1
  105. package/dist/list.d.ts +13 -0
  106. package/dist/list.d.ts.map +1 -1
  107. package/dist/list.js +103 -82
  108. package/dist/logo-mark.cjs +1 -1
  109. package/dist/logo-mark.d.ts +18 -2
  110. package/dist/logo-mark.d.ts.map +1 -1
  111. package/dist/logo-mark.js +159 -79
  112. package/dist/media-empty.cjs +1 -1
  113. package/dist/media-empty.d.ts +50 -7
  114. package/dist/media-empty.d.ts.map +1 -1
  115. package/dist/media-empty.js +14 -13
  116. package/dist/media-viewer.cjs +1 -1
  117. package/dist/media-viewer.js +6 -6
  118. package/dist/multi-select-filter.cjs +1 -1
  119. package/dist/multi-select-filter.d.ts.map +1 -1
  120. package/dist/multi-select-filter.js +92 -101
  121. package/dist/pagination.cjs +1 -1
  122. package/dist/pagination.d.ts +11 -0
  123. package/dist/pagination.d.ts.map +1 -1
  124. package/dist/pagination.js +17 -17
  125. package/dist/relative-date.d.ts +6 -0
  126. package/dist/relative-date.d.ts.map +1 -1
  127. package/dist/resizable.d.ts +1 -1
  128. package/dist/result-count.cjs +1 -1
  129. package/dist/result-count.d.ts +13 -16
  130. package/dist/result-count.d.ts.map +1 -1
  131. package/dist/result-count.js +24 -33
  132. package/dist/sheet.cjs +1 -1
  133. package/dist/sheet.d.ts +22 -3
  134. package/dist/sheet.d.ts.map +1 -1
  135. package/dist/sheet.js +152 -125
  136. package/dist/single-select-filter.cjs +1 -1
  137. package/dist/single-select-filter.d.ts.map +1 -1
  138. package/dist/single-select-filter.js +67 -76
  139. package/dist/table.cjs +1 -1
  140. package/dist/table.d.ts.map +1 -1
  141. package/dist/table.js +77 -76
  142. package/dist/tabs.cjs +1 -1
  143. package/dist/tabs.d.ts +39 -3
  144. package/dist/tabs.d.ts.map +1 -1
  145. package/dist/tabs.js +127 -76
  146. package/dist/textarea.cjs +1 -1
  147. package/dist/textarea.d.ts +34 -0
  148. package/dist/textarea.d.ts.map +1 -1
  149. package/dist/textarea.js +115 -19
  150. package/dist/tooltip.cjs +1 -1
  151. package/dist/tooltip.d.ts.map +1 -1
  152. package/dist/tooltip.js +137 -131
  153. package/dist/typography-text.cjs +1 -1
  154. package/dist/typography-text.d.ts +6 -2
  155. package/dist/typography-text.d.ts.map +1 -1
  156. package/dist/typography-text.js +14 -13
  157. package/package.json +3 -4
  158. package/src/blocks/empty-state.tsx +108 -48
  159. package/src/blocks/input-list.tsx +1 -0
  160. package/src/blocks/sidebar.tsx +39 -16
  161. package/src/components/alert-dialog.tsx +18 -2
  162. package/src/components/banner.tsx +247 -68
  163. package/src/components/button.tsx +27 -10
  164. package/src/components/card.tsx +89 -7
  165. package/src/components/chart.tsx +47 -67
  166. package/src/components/combobox.tsx +221 -12
  167. package/src/components/command.tsx +83 -37
  168. package/src/components/count-indicator.tsx +188 -0
  169. package/src/components/data-table.tsx +506 -159
  170. package/src/components/dialog.tsx +74 -5
  171. package/src/components/drawer.tsx +52 -32
  172. package/src/components/file-upload.tsx +2574 -0
  173. package/src/components/global-layout.tsx +18 -5
  174. package/src/components/hover-card.tsx +395 -65
  175. package/src/components/input-chip.tsx +67 -2
  176. package/src/components/input-group.tsx +89 -6
  177. package/src/components/list.tsx +40 -3
  178. package/src/components/logo-mark.tsx +109 -25
  179. package/src/components/media-empty.tsx +62 -7
  180. package/src/components/multi-select-filter.tsx +9 -16
  181. package/src/components/pagination.tsx +15 -2
  182. package/src/components/relative-date.tsx +6 -0
  183. package/src/components/result-count.tsx +27 -54
  184. package/src/components/sheet.tsx +86 -8
  185. package/src/components/single-select-filter.tsx +9 -16
  186. package/src/components/table.tsx +16 -1
  187. package/src/components/tabs.tsx +223 -41
  188. package/src/components/textarea.tsx +271 -4
  189. package/src/components/tooltip.tsx +29 -2
  190. package/src/components/typography-text.tsx +7 -2
  191. package/src/hooks/use-file-dropzone.ts +325 -0
  192. package/src/index.ts +3 -0
  193. package/src/lib/empty-canvas.tsx +47 -20
  194. package/src/lib/empty-chip.tsx +38 -3
  195. package/src/lib/field-aria.tsx +11 -6
  196. package/src/lib/table-internal.ts +38 -0
package/dist/combobox.js CHANGED
@@ -1,99 +1,102 @@
1
1
  "use client";
2
2
  import * as e from "react";
3
- import { Check as Y, ChevronsUpDown as Z } from "@brightlocal/icons";
4
- import { cn as T } from "@brightlocal/ui-components/lib/utils";
5
- import { Fragment as ee, jsx as c, jsxs as H } from "react/jsx-runtime";
6
- import { cva as te } from "class-variance-authority";
7
- import { useDevWarning as B } from "@brightlocal/ui-components/lib/use-dev-warning";
8
- import { Spinner as oe } from "@brightlocal/ui-components/spinner";
9
- import { useVirtualizer as re } from "@tanstack/react-virtual";
10
- import { defaultFilter as K } from "cmdk";
11
- import { Popover as ne, PopoverContent as ae, PopoverTrigger as se } from "@brightlocal/ui-components/popover";
12
- import { Command as ie, CommandEmpty as le, CommandGroup as ce, CommandInput as ue, CommandItem as de, CommandList as fe, CommandSeparator as me } from "@brightlocal/ui-components/command";
13
- var J = e.createContext(null), Q = e.createContext(null);
14
- function _() {
15
- const t = e.useContext(J);
3
+ import { Check as X, ChevronsUpDown as re } from "@brightlocal/icons";
4
+ import { cn as O } from "@brightlocal/ui-components/lib/utils";
5
+ import { Fragment as ne, jsx as l, jsxs as K } from "react/jsx-runtime";
6
+ import { cva as ae } from "class-variance-authority";
7
+ import { useDevWarning as Y } from "@brightlocal/ui-components/lib/use-dev-warning";
8
+ import { Spinner as se } from "@brightlocal/ui-components/spinner";
9
+ import { useVirtualizer as ie } from "@tanstack/react-virtual";
10
+ import { defaultFilter as J } from "cmdk";
11
+ import { Popover as ce, PopoverContent as ue, PopoverTrigger as le } from "@brightlocal/ui-components/popover";
12
+ import { Command as de, CommandEmpty as fe, CommandGroup as me, CommandInput as be, CommandItem as pe, CommandList as ve, CommandSeparator as ge } from "@brightlocal/ui-components/command";
13
+ var ee = e.createContext(null), te = e.createContext(null);
14
+ function B() {
15
+ const t = e.useContext(ee);
16
16
  if (!t) throw new Error("Combobox components must be used within a <Combobox>");
17
17
  return t;
18
18
  }
19
- function Ae({ value: t, onValueChange: r, open: a, onOpenChange: o, onClose: s, shouldFilter: d = !0, disabled: i = !1, itemToStringValue: f, children: C }) {
20
- const [b, N] = e.useState(""), [p, m] = e.useState(!1), [S, y] = e.useState(() => /* @__PURE__ */ new Map()), [v, k] = e.useState(""), [F, I] = e.useState(void 0), w = t !== void 0, D = a !== void 0, L = w ? t : b, R = D ? a : p, M = e.useCallback((x) => {
21
- x || k(""), D || m(x), o?.(x);
22
- }, [D, o]), h = e.useCallback((x) => {
23
- w || N(x), r?.(x);
24
- }, [w, r]), E = e.useRef(s);
19
+ function He({ value: t, onValueChange: r, open: n, onOpenChange: o, onClose: i, shouldFilter: u = !0, disabled: s = !1, itemToStringValue: d, children: f }) {
20
+ const [v, p] = e.useState(""), [m, a] = e.useState(!1), [y, w] = e.useState(() => /* @__PURE__ */ new Map()), [k, h] = e.useState(""), [P, R] = e.useState(void 0), [M, I] = e.useState(void 0), N = t !== void 0, A = n !== void 0, L = N ? t : v, E = A ? n : m, D = e.useCallback((x) => {
21
+ x || h(""), A || a(x), o?.(x);
22
+ }, [A, o]), S = e.useCallback((x) => {
23
+ N || p(x), r?.(x);
24
+ }, [N, r]), T = e.useRef(i);
25
25
  e.useEffect(() => {
26
- E.current = s;
27
- }, [s]);
28
- const A = e.useRef(R);
26
+ T.current = i;
27
+ }, [i]);
28
+ const z = e.useRef(E);
29
29
  e.useEffect(() => {
30
- A.current && !R && E.current?.(), A.current = R;
31
- }, [R]), e.useEffect(() => () => {
32
- A.current && E.current?.();
30
+ z.current && !E && T.current?.(), z.current = E;
31
+ }, [E]), e.useEffect(() => () => {
32
+ z.current && T.current?.();
33
33
  }, []);
34
- const u = e.useRef(/* @__PURE__ */ new Map()), V = e.useRef(!1), O = e.useRef(!0);
34
+ const b = e.useRef(/* @__PURE__ */ new Map()), V = e.useRef(!1), H = e.useRef(!0);
35
35
  e.useEffect(() => () => {
36
- O.current = !1;
36
+ H.current = !1;
37
37
  }, []);
38
- const j = e.useCallback(() => {
38
+ const q = e.useCallback(() => {
39
39
  V.current || (V.current = !0, queueMicrotask(() => {
40
- V.current = !1, O.current && y(new Map(u.current));
40
+ V.current = !1, H.current && w(new Map(b.current));
41
41
  }));
42
- }, []), $ = e.useCallback((x, n) => {
43
- u.current.get(x) !== n && (u.current.set(x, n), j());
44
- }, [j]), z = e.useCallback((x) => {
45
- for (const [n, l] of x) u.current.set(n, l);
46
- y(new Map(u.current));
47
- }, []), q = e.useRef(L);
42
+ }, []), j = e.useCallback((x, $) => {
43
+ b.current.get(x) !== $ && (b.current.set(x, $), q());
44
+ }, [q]), _ = e.useCallback((x) => {
45
+ for (const [$, c] of x) b.current.set($, c);
46
+ w(new Map(b.current));
47
+ }, []), U = e.useRef(L);
48
48
  e.useLayoutEffect(() => {
49
- q.current = L;
49
+ U.current = L;
50
50
  }, [L]);
51
- const U = e.useCallback((x) => {
52
- x !== q.current && u.current.has(x) && (u.current.delete(x), j());
53
- }, [j]), G = e.useMemo(() => f ? (x, n, l) => K(f(x), n, l) : K, [f]), W = e.useMemo(() => ({
54
- open: R,
55
- setOpen: M,
51
+ const G = e.useCallback((x) => {
52
+ x !== U.current && b.current.has(x) && (b.current.delete(x), q());
53
+ }, [q]), W = e.useMemo(() => d ? (x, $, c) => J(d(x), $, c) : J, [d]), Q = e.useMemo(() => ({
54
+ open: E,
55
+ setOpen: D,
56
56
  value: L,
57
- onValueChange: h,
58
- shouldFilter: d,
59
- disabled: i,
60
- itemLabels: S,
61
- registerItem: $,
62
- registerItemsSync: z,
63
- unregisterItem: U,
64
- itemToStringValue: f,
65
- filterFn: G,
66
- searchValue: v,
67
- setSearchValue: k,
68
- activeDescendantId: F,
69
- setActiveDescendantId: I
57
+ onValueChange: S,
58
+ shouldFilter: u,
59
+ disabled: s,
60
+ itemLabels: y,
61
+ registerItem: j,
62
+ registerItemsSync: _,
63
+ unregisterItem: G,
64
+ itemToStringValue: d,
65
+ filterFn: W,
66
+ searchValue: k,
67
+ setSearchValue: h,
68
+ activeDescendantId: P,
69
+ setActiveDescendantId: R,
70
+ listboxId: M,
71
+ setListboxId: I
70
72
  }), [
71
- R,
72
- M,
73
+ E,
74
+ D,
73
75
  L,
74
- h,
75
- d,
76
- i,
77
76
  S,
78
- $,
79
- z,
80
- U,
81
- f,
77
+ u,
78
+ s,
79
+ y,
80
+ j,
81
+ _,
82
82
  G,
83
- v,
84
- F,
85
- I
83
+ d,
84
+ W,
85
+ k,
86
+ P,
87
+ R,
88
+ M
86
89
  ]);
87
- return /* @__PURE__ */ c(J.Provider, {
88
- value: W,
89
- children: /* @__PURE__ */ c(ne, {
90
- open: R,
91
- onOpenChange: M,
92
- children: C
90
+ return /* @__PURE__ */ l(ee.Provider, {
91
+ value: Q,
92
+ children: /* @__PURE__ */ l(ce, {
93
+ open: E,
94
+ onOpenChange: D,
95
+ children: f
93
96
  })
94
97
  });
95
98
  }
96
- var be = te([
99
+ var he = ae([
97
100
  "relative flex w-full items-center justify-between gap-2",
98
101
  "px-3 py-2 h-9",
99
102
  "border border-border rounded-sm outline-none",
@@ -107,433 +110,517 @@ var be = te([
107
110
  "cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
108
111
  "transition-[background-color,border-color,box-shadow] duration-fast ease-out",
109
112
  "[&_svg]:pointer-events-none [&_svg]:shrink-0"
110
- ]), pe = e.forwardRef(({ className: t, dataHook: r, error: a, trackingEl: o, trackingLabel: s, reserveValues: d, children: i, ...f }, C) => {
111
- const { open: b, disabled: N, value: p } = _(), m = e.useId(), S = !p, y = a || f["aria-invalid"] === !0 || f["aria-invalid"] === "true";
112
- return /* @__PURE__ */ c(se, {
113
+ ]), xe = e.forwardRef(({ className: t, dataHook: r, error: n, trackingEl: o, trackingLabel: i, reserveValues: u, children: s, ...d }, f) => {
114
+ const { open: v, disabled: p, value: m } = B(), a = e.useId(), y = !m, w = n || d["aria-invalid"] === !0 || d["aria-invalid"] === "true";
115
+ return /* @__PURE__ */ l(le, {
113
116
  asChild: !0,
114
- children: /* @__PURE__ */ H("button", {
115
- ref: C,
116
- "aria-controls": b ? m : void 0,
117
- "aria-expanded": b,
117
+ children: /* @__PURE__ */ K("button", {
118
+ ref: f,
119
+ "aria-controls": v ? a : void 0,
120
+ "aria-expanded": v,
118
121
  "aria-haspopup": "listbox",
119
- "aria-invalid": y ? "true" : void 0,
120
- className: T(be(), y && "border-destructive-40 dark:border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive", t),
122
+ "aria-invalid": w ? "true" : void 0,
123
+ className: O(he(), w && "border-destructive-40 dark:border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive", t),
121
124
  "data-hook": r,
122
- "data-placeholder": S,
125
+ "data-placeholder": y,
123
126
  "data-slot": "combobox-trigger",
124
- "data-state": b ? "open" : "closed",
127
+ "data-state": v ? "open" : "closed",
125
128
  "data-tracking-el": o || "combobox-trigger",
126
- "data-tracking-label": s,
127
- disabled: N || f.disabled,
129
+ "data-tracking-label": i,
130
+ disabled: p || d.disabled,
128
131
  role: "combobox",
129
132
  type: "button",
130
- ...f,
131
- children: [d?.length ? /* @__PURE__ */ H("span", {
133
+ ...d,
134
+ children: [u?.length ? /* @__PURE__ */ K("span", {
132
135
  className: "grid min-w-0 text-left",
133
136
  "data-slot": "combobox-reserve",
134
- children: [d.map((v, k) => /* @__PURE__ */ c("span", {
137
+ children: [u.map((k, h) => /* @__PURE__ */ l("span", {
135
138
  "aria-hidden": "true",
136
139
  className: "invisible col-start-1 row-start-1 truncate",
137
- children: v
138
- }, k)), /* @__PURE__ */ c("span", {
140
+ children: k
141
+ }, h)), /* @__PURE__ */ l("span", {
139
142
  className: "col-start-1 row-start-1 truncate",
140
- children: i
143
+ children: s
141
144
  })]
142
- }) : i, /* @__PURE__ */ c(Z, {
145
+ }) : s, /* @__PURE__ */ l(re, {
143
146
  "aria-hidden": "true",
144
147
  className: "text-muted-foreground ml-auto shrink-0"
145
148
  })]
146
149
  })
147
150
  });
148
151
  });
149
- pe.displayName = "ComboboxTrigger";
150
- function ve(t) {
152
+ xe.displayName = "ComboboxTrigger";
153
+ function Ce(t) {
151
154
  return t != null && typeof t == "object" && "value" in t && typeof t.value == "string";
152
155
  }
153
- function X(t, r, a) {
156
+ function oe(t, r, n) {
154
157
  if (r) return {
155
158
  getValue: r,
156
- getLabel: a ?? r,
157
- hasDistinctLabel: !!a
159
+ getLabel: n ?? r,
160
+ hasDistinctLabel: !!n
158
161
  };
159
162
  const o = t[0];
160
- if (!ve(o)) return null;
161
- const s = (i) => i.value, d = "label" in o && typeof o.label == "string";
163
+ if (!Ce(o)) return null;
164
+ const i = (s) => s.value, u = "label" in o && typeof o.label == "string";
162
165
  return {
163
- getValue: s,
164
- getLabel: a ?? (d ? (i) => String(i.label) : s),
165
- hasDistinctLabel: d || !!a
166
+ getValue: i,
167
+ getLabel: n ?? (u ? (s) => String(s.label) : i),
168
+ hasDistinctLabel: u || !!n
166
169
  };
167
170
  }
168
- function Te({ placeholder: t, className: r, displayValue: a, items: o, getItemValue: s, getItemLabel: d }) {
169
- const { value: i, itemLabels: f } = _(), C = e.useMemo(() => o ? X(o, s, d) : null, [
171
+ function _e({ placeholder: t, className: r, displayValue: n, items: o, getItemValue: i, getItemLabel: u }) {
172
+ const { value: s, itemLabels: d } = B(), f = e.useMemo(() => o ? oe(o, i, u) : null, [
170
173
  o,
171
- s,
172
- d
174
+ i,
175
+ u
173
176
  ]);
174
- B(() => !!o && o.length > 0 && !C, "ComboboxValue: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.", [o, C]);
175
- const b = e.useMemo(() => !o || !C ? null : new Map(o.map((p) => [C.getValue(p), C.getLabel(p)])), [o, C]), N = i ? b?.get(i) || f.get(i) || a?.(i) || i : t;
176
- return /* @__PURE__ */ c("span", {
177
- className: T("text-field overflow-hidden text-ellipsis whitespace-nowrap", r),
177
+ Y(() => !!o && o.length > 0 && !f, "ComboboxValue: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.", [o, f]);
178
+ const v = e.useMemo(() => !o || !f ? null : new Map(o.map((m) => [f.getValue(m), f.getLabel(m)])), [o, f]), p = s ? v?.get(s) || d.get(s) || n?.(s) || s : t;
179
+ return /* @__PURE__ */ l("span", {
180
+ className: O("text-field overflow-hidden text-ellipsis whitespace-nowrap", r),
178
181
  "data-slot": "combobox-value",
179
- children: N
182
+ children: p
180
183
  });
181
184
  }
182
- function $e({ dataHook: t, className: r, children: a, align: o = "start", side: s = "bottom", sideOffset: d, avoidCollisions: i, hideList: f = !1, ariaLabel: C }) {
183
- const { open: b, shouldFilter: N, filterFn: p, itemToStringValue: m } = _(), [S, y] = e.useState(null), v = e.useRef(null), k = e.useCallback((I) => {
184
- if (v.current?.(), v.current = null, !I) return;
185
- let w = !1;
186
- const D = (h) => {
187
- w || (h === "top" || h === "bottom") && (w = !0, L.disconnect(), y(h));
188
- }, L = new MutationObserver(() => {
189
- D(I.getAttribute("data-side"));
185
+ function Be({ dataHook: t, className: r, children: n, align: o = "start", side: i = "bottom", sideOffset: u, avoidCollisions: s, hideList: d = !1, ariaLabel: f }) {
186
+ const { open: v, shouldFilter: p, filterFn: m, itemToStringValue: a } = B(), [y, w] = e.useState(null), k = e.useRef(null), h = e.useCallback((R) => {
187
+ if (k.current?.(), k.current = null, !R) return;
188
+ let M = !1;
189
+ const I = (E) => {
190
+ M || (E === "top" || E === "bottom") && (M = !0, N.disconnect(), w(E));
191
+ }, N = new MutationObserver(() => {
192
+ I(R.getAttribute("data-side"));
190
193
  });
191
- L.observe(I, {
194
+ N.observe(R, {
192
195
  attributes: !0,
193
196
  attributeFilter: ["data-side"]
194
197
  });
195
- let R = 0, M = 0;
196
- R = requestAnimationFrame(() => {
197
- M = requestAnimationFrame(() => {
198
- D(I.getAttribute("data-side"));
198
+ let A = 0, L = 0;
199
+ A = requestAnimationFrame(() => {
200
+ L = requestAnimationFrame(() => {
201
+ I(R.getAttribute("data-side"));
199
202
  });
200
- }), v.current = () => {
201
- w = !0, L.disconnect(), cancelAnimationFrame(R), cancelAnimationFrame(M);
203
+ }), k.current = () => {
204
+ M = !0, N.disconnect(), cancelAnimationFrame(A), cancelAnimationFrame(L);
202
205
  };
203
206
  }, []);
204
207
  e.useEffect(() => {
205
- if (!b) {
206
- v.current?.(), v.current = null;
207
- const I = setTimeout(() => y(null), 150);
208
- return () => clearTimeout(I);
208
+ if (!v) {
209
+ k.current?.(), k.current = null;
210
+ const R = setTimeout(() => w(null), 150);
211
+ return () => clearTimeout(R);
209
212
  }
210
- }, [b]);
211
- const F = m ? p : void 0;
212
- return /* @__PURE__ */ c(ae, {
213
- ref: k,
213
+ }, [v]);
214
+ const P = a ? m : void 0;
215
+ return /* @__PURE__ */ l(ue, {
216
+ ref: h,
214
217
  align: o,
215
- "aria-label": C ?? "Options",
216
- avoidCollisions: i,
217
- className: T("flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0", r),
218
+ "aria-label": f ?? "Options",
219
+ avoidCollisions: s,
220
+ className: O("flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0", r),
218
221
  collisionPadding: 4,
219
222
  "data-slot": "combobox-popover",
220
- side: S ?? s,
221
- sideOffset: d,
222
- children: /* @__PURE__ */ c(ie, {
223
- className: T("min-h-0 flex-1 border-0 shadow-none", "[&_[data-slot='command-input-wrapper']]:shrink-0", f && "[&_[data-slot='command-input-wrapper']]:border-b-0"),
224
- "data-slot": "combobox-command",
223
+ side: y ?? i,
224
+ sideOffset: u,
225
+ children: /* @__PURE__ */ l(ke, {
226
+ className: O("min-h-0 flex-1 border-0 shadow-none", "[&_[data-slot='command-input-wrapper']]:shrink-0", d && "[&_[data-slot='command-input-wrapper']]:border-b-0"),
225
227
  dataHook: t || "combobox-command",
226
- filter: F,
227
- shouldFilter: N,
228
- children: a
228
+ filter: P,
229
+ shouldFilter: p,
230
+ children: n
229
231
  })
230
232
  });
231
233
  }
232
- var he = e.forwardRef(({ debounceMs: t, onValueChange: r, ...a }, o) => {
233
- const { setSearchValue: s, shouldFilter: d, activeDescendantId: i } = _(), f = e.useRef(void 0);
234
- B(() => !!(t && t > 0 && d), `debounceMs is set on <ComboboxInput> but shouldFilter is true (default).
234
+ function ye(t) {
235
+ return typeof CSS < "u" && CSS.escape ? CSS.escape(t) : t.replace(/["\\]/g, "\\$&");
236
+ }
237
+ function Z(t) {
238
+ const r = t.closest("[cmdk-list]");
239
+ if (!r || r.offsetHeight === 0) return;
240
+ const n = r.getBoundingClientRect(), o = t.getBoundingClientRect(), i = n.height / r.offsetHeight || 1, u = (o.top - n.top) / i + r.scrollTop, s = o.height / i;
241
+ r.scrollTop = u - (r.clientHeight - s) / 2;
242
+ }
243
+ function we(t) {
244
+ const r = t.closest("[cmdk-list]");
245
+ if (!r) return !0;
246
+ const n = r.getBoundingClientRect(), o = t.getBoundingClientRect();
247
+ return o.top >= n.top && o.bottom <= n.bottom;
248
+ }
249
+ function ke({ children: t, ...r }) {
250
+ const { open: n, value: o } = B(), i = e.useRef(null), [u, s] = e.useState(() => o || void 0), d = e.useRef(0), f = e.useRef(!1);
251
+ return e.useLayoutEffect(() => {
252
+ if (!n) {
253
+ f.current = !0;
254
+ return;
255
+ }
256
+ f.current && (f.current = !1, s(o || i.current?.querySelector('[cmdk-item]:not([aria-disabled="true"])')?.getAttribute("data-value") || void 0));
257
+ }, [n, o]), e.useLayoutEffect(() => {
258
+ const v = i.current;
259
+ if (u === void 0 || !v) return;
260
+ if (u === "") {
261
+ s(void 0);
262
+ return;
263
+ }
264
+ const p = v.querySelector(`[cmdk-item][data-value="${ye(u)}"]:not([aria-disabled="true"])`);
265
+ if (!p) {
266
+ const m = v.querySelector('[cmdk-item]:not([aria-disabled="true"])')?.getAttribute("data-value");
267
+ s(m ?? "");
268
+ return;
269
+ }
270
+ for (const m of v.querySelectorAll("[cmdk-input], [cmdk-list]")) m.setAttribute("aria-activedescendant", p.id);
271
+ Z(p), s(void 0), d.current = requestAnimationFrame(() => {
272
+ p.isConnected && !we(p) && Z(p);
273
+ });
274
+ }, [u]), e.useEffect(() => () => cancelAnimationFrame(d.current), []), /* @__PURE__ */ l(de, {
275
+ ...r,
276
+ ref: i,
277
+ "data-slot": "combobox-command",
278
+ value: u,
279
+ children: t
280
+ });
281
+ }
282
+ var Re = e.forwardRef(({ debounceMs: t, onValueChange: r, ...n }, o) => {
283
+ const { setSearchValue: i, shouldFilter: u, activeDescendantId: s, listboxId: d } = B(), f = e.useRef(void 0);
284
+ Y(() => !!(t && t > 0 && u), `debounceMs is set on <ComboboxInput> but shouldFilter is true (default).
235
285
  Debounce is designed for async/server-driven search where the consumer controls the items list.
236
- Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs for client-side filtering.`, [t, d]), B(() => !!(t && t > 0 && a.value !== void 0), "debounceMs is set on <ComboboxInput> together with a controlled `value` prop.\nThe debounced onValueChange callback cannot update the controlled value synchronously, so the input will appear to lag behind typing.\nRemove `value` to let the input manage its own display, or remove debounceMs if you need a controlled input.", [t, a.value]), e.useEffect(() => () => {
286
+ Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs for client-side filtering.`, [t, u]), Y(() => !!(t && t > 0 && n.value !== void 0), "debounceMs is set on <ComboboxInput> together with a controlled `value` prop.\nThe debounced onValueChange callback cannot update the controlled value synchronously, so the input will appear to lag behind typing.\nRemove `value` to let the input manage its own display, or remove debounceMs if you need a controlled input.", [t, n.value]), e.useEffect(() => () => {
237
287
  f.current && clearTimeout(f.current);
238
288
  }, []);
239
- const C = e.useCallback((b) => {
240
- s(b), t && t > 0 ? (clearTimeout(f.current), f.current = setTimeout(() => {
241
- r?.(b);
242
- }, t)) : r?.(b);
289
+ const v = e.useCallback((a) => {
290
+ i(a), t && t > 0 ? (clearTimeout(f.current), f.current = setTimeout(() => {
291
+ r?.(a);
292
+ }, t)) : r?.(a);
243
293
  }, [
244
294
  t,
245
295
  r,
246
- s
247
- ]);
248
- return /* @__PURE__ */ c(ue, {
249
- ref: o,
250
- "aria-activedescendant": i,
296
+ i
297
+ ]), p = e.useRef(null), m = e.useCallback((a) => {
298
+ if (p.current = a, typeof o != "function") {
299
+ o && (o.current = a);
300
+ return;
301
+ }
302
+ const y = o(a);
303
+ if (typeof y == "function")
304
+ return () => {
305
+ p.current = null, y();
306
+ };
307
+ }, [o]);
308
+ return e.useLayoutEffect(() => {
309
+ const a = p.current;
310
+ if (!(!a || s === void 0))
311
+ return a.setAttribute("aria-activedescendant", s), () => a.removeAttribute("aria-activedescendant");
312
+ }, [s]), e.useLayoutEffect(() => {
313
+ const a = p.current;
314
+ if (!a || d === void 0) return;
315
+ const y = a.getAttribute("aria-controls");
316
+ return a.setAttribute("aria-controls", d), () => {
317
+ y ? a.setAttribute("aria-controls", y) : a.removeAttribute("aria-controls");
318
+ };
319
+ }, [d]), /* @__PURE__ */ l(be, {
320
+ ref: m,
321
+ "aria-activedescendant": s,
251
322
  "data-slot": "combobox-input",
252
- onValueChange: C,
253
- ...a
323
+ onValueChange: v,
324
+ ...n
254
325
  });
255
326
  });
256
- he.displayName = "ComboboxInput";
257
- var xe = e.forwardRef(({ className: t, ...r }, a) => /* @__PURE__ */ c(fe, {
258
- ref: a,
259
- className: T("scrollbar min-h-0 flex-1", t),
327
+ Re.displayName = "ComboboxInput";
328
+ var Ie = e.forwardRef(({ className: t, ...r }, n) => /* @__PURE__ */ l(ve, {
329
+ ref: n,
330
+ className: O("scrollbar min-h-0 flex-1", t),
260
331
  "data-slot": "combobox-list",
261
332
  ...r
262
333
  }));
263
- xe.displayName = "ComboboxList";
264
- function ge({ items: t, getItemValue: r, getItemLabel: a, getItemKeywords: o, estimateSize: s = 36, overscan: d = 5, children: i, renderEmpty: f, className: C, dataHook: b }, N) {
265
- const p = e.useMemo(() => X(t, r, a), [
334
+ Ie.displayName = "ComboboxList";
335
+ function Se({ items: t, getItemValue: r, getItemLabel: n, getItemKeywords: o, estimateSize: i = 36, overscan: u = 5, children: s, renderEmpty: d, className: f, dataHook: v }, p) {
336
+ const m = e.useMemo(() => oe(t, r, n), [
266
337
  t,
267
338
  r,
268
- a
269
- ]), m = e.useMemo(() => p?.getValue ?? ((n) => {
270
- if (typeof n == "string" || typeof n == "number") return String(n);
339
+ n
340
+ ]), a = e.useMemo(() => m?.getValue ?? ((c) => {
341
+ if (typeof c == "string" || typeof c == "number") return String(c);
271
342
  throw new Error("[BrightLocal DS] ComboboxVirtualList: `getItemValue` is required for non-primitive items without a `value` property.");
272
- }), [p]), S = e.useMemo(() => p?.getLabel ?? m, [p, m]);
273
- B(() => !p && t.length > 0, "ComboboxVirtualList: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.", [p, t.length]);
274
- const y = e.useRef(null), { value: v, onValueChange: k, setOpen: F, shouldFilter: I, searchValue: w, filterFn: D, setActiveDescendantId: L, registerItemsSync: R, unregisterItem: M } = _(), [h, E] = e.useState(0), A = e.useId();
275
- e.useImperativeHandle(N, () => y.current, []), e.useLayoutEffect(() => {
276
- const n = t.map((l) => [m(l), S(l)]);
277
- return R(n), () => {
278
- for (const l of t) M(m(l));
343
+ }), [m]), y = e.useMemo(() => m?.getLabel ?? a, [m, a]);
344
+ Y(() => !m && t.length > 0, "ComboboxVirtualList: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.", [m, t.length]);
345
+ const w = e.useRef(null), { open: k, value: h, onValueChange: P, setOpen: R, shouldFilter: M, searchValue: I, filterFn: N, setActiveDescendantId: A, setListboxId: L, registerItemsSync: E, unregisterItem: D } = B(), [S, T] = e.useState(0), z = e.useId();
346
+ e.useImperativeHandle(p, () => w.current, []), e.useLayoutEffect(() => {
347
+ const c = t.map((g) => [a(g), y(g)]);
348
+ return E(c), () => {
349
+ for (const g of t) D(a(g));
279
350
  };
280
351
  }, [
281
352
  t,
282
- m,
283
- S,
284
- R,
285
- M
353
+ a,
354
+ y,
355
+ E,
356
+ D
286
357
  ]);
287
- const u = e.useMemo(() => {
288
- if (!I || !w.trim()) return t;
289
- const n = [];
290
- for (const l of t) {
291
- let g = p?.hasDistinctLabel ? K(S(l), w) : D(m(l), w);
292
- if (o) for (const P of o(l)) g = Math.max(g, K(P, w));
293
- g > 0 && n.push({
294
- item: l,
295
- score: g
358
+ const b = e.useMemo(() => {
359
+ if (!M || !I.trim()) return t;
360
+ const c = [];
361
+ for (const g of t) {
362
+ let C = m?.hasDistinctLabel ? J(y(g), I) : N(a(g), I);
363
+ if (o) for (const F of o(g)) C = Math.max(C, J(F, I));
364
+ C > 0 && c.push({
365
+ item: g,
366
+ score: C
296
367
  });
297
368
  }
298
- return n.sort((l, g) => g.score - l.score), n.map((l) => l.item);
369
+ return c.sort((g, C) => C.score - g.score), c.map((g) => g.item);
299
370
  }, [
300
371
  t,
372
+ M,
301
373
  I,
302
- w,
303
- m,
304
- S,
374
+ a,
375
+ y,
305
376
  o,
306
- D,
307
- p?.hasDistinctLabel
308
- ]), V = re({
309
- count: u.length,
310
- getScrollElement: () => y.current,
311
- estimateSize: () => s,
312
- overscan: d
313
- }), O = h >= 0 && h < u.length ? m(u[h]) : null;
314
- e.useEffect(() => {
315
- E(0);
316
- }, [w, u.length]);
317
- const j = e.useRef(!1);
377
+ N,
378
+ m?.hasDistinctLabel
379
+ ]), V = ie({
380
+ count: b.length,
381
+ getScrollElement: () => w.current,
382
+ estimateSize: () => i,
383
+ overscan: u
384
+ }), H = S >= 0 && S < b.length ? a(b[S]) : null;
318
385
  e.useEffect(() => {
319
- if (j.current || !v) return;
320
- const n = u.findIndex((l) => m(l) === v);
321
- n >= 0 && (E(n), V.scrollToIndex(n, { align: "center" }), j.current = !0);
386
+ T(0);
387
+ }, [I, b.length]);
388
+ const q = e.useRef(!0);
389
+ e.useEffect(() => () => {
390
+ q.current = !0;
391
+ }, []), e.useEffect(() => {
392
+ if (!k) {
393
+ q.current = !0;
394
+ return;
395
+ }
396
+ if (!q.current || !h) return;
397
+ if (I) {
398
+ q.current = !1;
399
+ return;
400
+ }
401
+ const c = b.findIndex((g) => a(g) === h);
402
+ c >= 0 && (q.current = !1, T(c), V.scrollToIndex(c, { align: "center" }));
322
403
  }, [
323
- v,
324
- u,
325
- m,
404
+ k,
405
+ h,
406
+ I,
407
+ b,
408
+ a,
326
409
  V
327
410
  ]);
328
- const $ = e.useRef(!1);
411
+ const j = e.useRef(!1);
329
412
  e.useEffect(() => {
330
- $.current && h >= 0 && h < u.length && V.scrollToIndex(h, { align: "auto" }), $.current = !1;
413
+ j.current && S >= 0 && S < b.length && V.scrollToIndex(S, { align: "auto" }), j.current = !1;
331
414
  }, [
332
- h,
333
- u.length,
415
+ S,
416
+ b.length,
334
417
  V
335
418
  ]), e.useEffect(() => {
336
- const n = y.current?.closest('[data-slot="combobox-command"]');
337
- if (!n) return;
338
- const l = (g) => {
339
- switch (g.key) {
419
+ const c = w.current?.closest('[data-slot="combobox-command"]');
420
+ if (!c) return;
421
+ const g = (C) => {
422
+ switch (C.key) {
340
423
  case "ArrowDown":
341
- g.preventDefault(), g.stopPropagation(), $.current = !0, E((P) => P < u.length - 1 ? P + 1 : P);
424
+ C.preventDefault(), C.stopPropagation(), j.current = !0, T((F) => F < b.length - 1 ? F + 1 : F);
342
425
  break;
343
426
  case "ArrowUp":
344
- g.preventDefault(), g.stopPropagation(), $.current = !0, E((P) => P > 0 ? P - 1 : P);
427
+ C.preventDefault(), C.stopPropagation(), j.current = !0, T((F) => F > 0 ? F - 1 : F);
345
428
  break;
346
429
  case "Enter":
347
- if (g.preventDefault(), g.stopPropagation(), h >= 0 && h < u.length) {
348
- const P = m(u[h]);
349
- k(P === v ? "" : P), F(!1);
430
+ if (C.preventDefault(), C.stopPropagation(), S >= 0 && S < b.length) {
431
+ const F = a(b[S]);
432
+ P(F === h ? "" : F), R(!1);
350
433
  }
351
434
  break;
352
435
  case "Home":
353
- g.preventDefault(), g.stopPropagation(), $.current = !0, E(0);
436
+ C.preventDefault(), C.stopPropagation(), j.current = !0, T(0);
354
437
  break;
355
438
  case "End":
356
- g.preventDefault(), g.stopPropagation(), $.current = !0, E(u.length - 1);
439
+ C.preventDefault(), C.stopPropagation(), j.current = !0, T(b.length - 1);
357
440
  }
358
441
  };
359
- return n.addEventListener("keydown", l, { capture: !0 }), () => n.removeEventListener("keydown", l, { capture: !0 });
442
+ return c.addEventListener("keydown", g, { capture: !0 }), () => c.removeEventListener("keydown", g, { capture: !0 });
360
443
  }, [
361
- u,
444
+ b,
445
+ S,
362
446
  h,
363
- v,
364
- k,
365
- F,
366
- m
447
+ P,
448
+ R,
449
+ a
367
450
  ]);
368
- const z = e.useMemo(() => {
369
- const n = /* @__PURE__ */ new Map();
370
- return u.forEach((l, g) => {
371
- n.set(m(l), g);
372
- }), n;
373
- }, [u, m]), q = e.useCallback((n) => {
374
- const l = z.get(n);
375
- l !== void 0 && E(l);
376
- }, [z]), U = e.useCallback((n) => (z.get(n) ?? 0) + 1, [z]), G = u.length, W = e.useMemo(() => ({
377
- activeValue: O,
378
- onItemPointerMove: q,
379
- idPrefix: A,
380
- filteredCount: G,
381
- getItemPosition: U
451
+ const _ = e.useMemo(() => {
452
+ const c = /* @__PURE__ */ new Map();
453
+ return b.forEach((g, C) => {
454
+ c.set(a(g), C);
455
+ }), c;
456
+ }, [b, a]), U = e.useCallback((c) => {
457
+ const g = _.get(c);
458
+ g !== void 0 && T(g);
459
+ }, [_]), G = e.useCallback((c) => (_.get(c) ?? 0) + 1, [_]), W = b.length, Q = e.useMemo(() => ({
460
+ activeValue: H,
461
+ onItemPointerMove: U,
462
+ idPrefix: z,
463
+ filteredCount: W,
464
+ getItemPosition: G
382
465
  }), [
383
- O,
384
- q,
385
- A,
386
- G,
387
- U
388
- ]), x = O != null ? `${A}item-${O}` : void 0;
389
- return e.useEffect(() => (L(x), () => L(void 0)), [x, L]), u.length === 0 ? /* @__PURE__ */ c("div", {
390
- ref: y,
391
- className: T("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1", C),
392
- "data-hook": b,
466
+ H,
467
+ U,
468
+ z,
469
+ W,
470
+ G
471
+ ]), x = H != null ? `${z}item-${H}` : void 0;
472
+ e.useEffect(() => (A(x), () => A(void 0)), [x, A]);
473
+ const $ = `${z}listbox`;
474
+ return e.useEffect(() => (L($), () => L(void 0)), [$, L]), b.length === 0 ? /* @__PURE__ */ l("div", {
475
+ ref: w,
476
+ className: O("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1", f),
477
+ "data-hook": v,
393
478
  "data-slot": "combobox-virtual-list",
479
+ id: $,
394
480
  role: "listbox",
395
- children: f
396
- }) : /* @__PURE__ */ c(Q.Provider, {
397
- value: W,
398
- children: /* @__PURE__ */ c("div", {
399
- ref: y,
400
- className: T("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1", C),
401
- "data-hook": b,
481
+ children: d
482
+ }) : /* @__PURE__ */ l(te.Provider, {
483
+ value: Q,
484
+ children: /* @__PURE__ */ l("div", {
485
+ ref: w,
486
+ className: O("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1", f),
487
+ "data-hook": v,
402
488
  "data-slot": "combobox-virtual-list",
489
+ id: $,
403
490
  role: "listbox",
404
- children: /* @__PURE__ */ c("div", {
491
+ children: /* @__PURE__ */ l("div", {
405
492
  className: "relative w-full",
406
493
  style: { height: `${V.getTotalSize()}px` },
407
- children: V.getVirtualItems().map((n) => /* @__PURE__ */ c("div", {
494
+ children: V.getVirtualItems().map((c) => /* @__PURE__ */ l("div", {
408
495
  ref: V.measureElement,
409
496
  className: "absolute top-0 left-0 w-full px-2",
410
- "data-index": n.index,
411
- style: { transform: `translateY(${n.start}px)` },
412
- children: i(u[n.index], n.index, w)
413
- }, n.key))
497
+ "data-index": c.index,
498
+ style: { transform: `translateY(${c.start}px)` },
499
+ children: s(b[c.index], c.index, I)
500
+ }, c.key))
414
501
  })
415
502
  })
416
503
  });
417
504
  }
418
- var Oe = e.forwardRef(ge), Ce = e.forwardRef((t, r) => /* @__PURE__ */ c(le, {
505
+ var Ue = e.forwardRef(Se), Ee = e.forwardRef((t, r) => /* @__PURE__ */ l(fe, {
419
506
  ref: r,
420
507
  "data-slot": "combobox-empty",
421
508
  ...t
422
509
  }));
423
- Ce.displayName = "ComboboxEmpty";
424
- var ye = e.forwardRef(({ children: t, ...r }, a) => {
510
+ Ee.displayName = "ComboboxEmpty";
511
+ var Le = e.forwardRef(({ children: t, ...r }, n) => {
425
512
  const o = e.useRef(null);
426
- return B(() => o.current ? o.current.querySelectorAll('[data-slot="combobox-item"]').length >= 100 : !1, `ComboboxGroup contains 100+ items. Use <ComboboxVirtualList> for large datasets to avoid DOM bloat and slow renders.
427
- Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox"`, [t]), /* @__PURE__ */ c(ce, {
428
- ref: (s) => {
429
- o.current = s, typeof a == "function" ? a(s) : a && (a.current = s);
513
+ return Y(() => o.current ? o.current.querySelectorAll('[data-slot="combobox-item"]').length >= 100 : !1, `ComboboxGroup contains 100+ items. Use <ComboboxVirtualList> for large datasets to avoid DOM bloat and slow renders.
514
+ Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox"`, [t]), /* @__PURE__ */ l(me, {
515
+ ref: (i) => {
516
+ o.current = i, typeof n == "function" ? n(i) : n && (n.current = i);
430
517
  },
431
518
  "data-slot": "combobox-group",
432
519
  ...r,
433
520
  children: t
434
521
  });
435
522
  });
436
- ye.displayName = "ComboboxGroup";
437
- function we(t, r, a) {
523
+ Le.displayName = "ComboboxGroup";
524
+ function Ae(t, r, n) {
438
525
  if (!r || !r.trim()) return t;
439
- const o = new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi"), s = t.split(o);
440
- return /* @__PURE__ */ c("span", { children: s.map((d, i) => i % 2 === 1 ? /* @__PURE__ */ c("span", {
441
- className: a,
442
- children: d
443
- }, i) : /* @__PURE__ */ c(e.Fragment, { children: d }, i)) });
526
+ const o = new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi"), i = t.split(o);
527
+ return /* @__PURE__ */ l("span", { children: i.map((u, s) => s % 2 === 1 ? /* @__PURE__ */ l("span", {
528
+ className: n,
529
+ children: u
530
+ }, s) : /* @__PURE__ */ l(e.Fragment, { children: u }, s)) });
444
531
  }
445
- var ke = e.forwardRef(({ value: t, label: r, dataHook: a, children: o, className: s, highlight: d, highlightClassName: i, keywords: f, onSelect: C, ...b }, N) => {
446
- const { value: p, onValueChange: m, setOpen: S, registerItem: y, unregisterItem: v } = _(), k = e.useContext(Q), F = p === t, I = e.useMemo(() => r || (typeof o == "string" ? o : typeof o == "number" ? String(o) : t), [
532
+ var Ne = e.forwardRef(({ value: t, label: r, dataHook: n, children: o, className: i, highlight: u, highlightClassName: s, keywords: d, onSelect: f, ...v }, p) => {
533
+ const { value: m, onValueChange: a, setOpen: y, registerItem: w, unregisterItem: k } = B(), h = e.useContext(te), P = m === t, R = e.useMemo(() => r || (typeof o == "string" ? o : typeof o == "number" ? String(o) : t), [
447
534
  r,
448
535
  o,
449
536
  t
450
- ]), w = e.useRef(y), D = e.useRef(v);
537
+ ]), M = e.useRef(w), I = e.useRef(k);
451
538
  e.useEffect(() => {
452
- w.current = y, D.current = v;
453
- }, [y, v]);
454
- const L = !!k;
539
+ M.current = w, I.current = k;
540
+ }, [w, k]);
541
+ const N = !!h;
455
542
  e.useEffect(() => {
456
- if (!L)
457
- return w.current(t, I), () => D.current(t);
543
+ if (!N)
544
+ return M.current(t, R), () => I.current(t);
458
545
  }, [
459
546
  t,
460
- I,
461
- L
547
+ R,
548
+ N
462
549
  ]);
463
- const R = () => {
464
- m(t === p ? "" : t), S(!1), C?.(t);
465
- }, M = () => d && typeof o == "string" ? we(o, d, i || "text-label font-semibold") : o;
466
- if (k) {
467
- const h = k.activeValue === t, E = !!b.disabled;
468
- return /* @__PURE__ */ H("div", {
469
- ref: N,
470
- "aria-disabled": E || void 0,
471
- "aria-posinset": k.getItemPosition(t),
472
- "aria-selected": F,
473
- "aria-setsize": k.filteredCount,
474
- className: T("data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-pointer items-center justify-between gap-2 rounded-sm px-2 py-3 outline-hidden select-none", "[&_svg]:pointer-events-none [&_svg]:shrink-0", E && "pointer-events-none opacity-50", s),
475
- "data-highlighted": h || void 0,
476
- "data-hook": a,
550
+ const A = () => {
551
+ a(t === m ? "" : t), y(!1), f?.(t);
552
+ }, L = () => u && typeof o == "string" ? Ae(o, u, s || "text-label font-semibold") : o;
553
+ if (h) {
554
+ const E = h.activeValue === t, D = !!v.disabled;
555
+ return /* @__PURE__ */ K("div", {
556
+ ref: p,
557
+ "aria-disabled": D || void 0,
558
+ "aria-posinset": h.getItemPosition(t),
559
+ "aria-selected": P,
560
+ "aria-setsize": h.filteredCount,
561
+ className: O("data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-pointer items-center justify-between gap-2 rounded-sm px-2 py-3 outline-hidden select-none", "[&_svg]:pointer-events-none [&_svg]:shrink-0", D && "pointer-events-none opacity-50", i),
562
+ "data-highlighted": E || void 0,
563
+ "data-hook": n,
477
564
  "data-slot": "combobox-item",
478
- id: `${k.idPrefix}item-${t}`,
565
+ id: `${h.idPrefix}item-${t}`,
479
566
  role: "option",
480
567
  tabIndex: -1,
481
- onClick: E ? void 0 : R,
482
- onKeyDown: E ? void 0 : (A) => {
483
- (A.key === "Enter" || A.key === " ") && R();
568
+ onClick: D ? void 0 : A,
569
+ onKeyDown: D ? void 0 : (S) => {
570
+ (S.key === "Enter" || S.key === " ") && A();
484
571
  },
485
- onPointerMove: E ? void 0 : () => k.onItemPointerMove(t),
486
- children: [M(), F && /* @__PURE__ */ c(Y, {
572
+ onPointerMove: D ? void 0 : () => h.onItemPointerMove(t),
573
+ children: [L(), P && /* @__PURE__ */ l(X, {
487
574
  "aria-hidden": "true",
488
575
  className: "text-muted-foreground shrink-0"
489
576
  })]
490
577
  });
491
578
  }
492
- return /* @__PURE__ */ H(de, {
493
- ref: N,
494
- className: T("justify-between", s),
579
+ return /* @__PURE__ */ K(pe, {
580
+ ref: p,
581
+ className: O("justify-between", i),
495
582
  "data-slot": "combobox-item",
496
- dataHook: a,
497
- keywords: f ? [I, ...f] : [I],
583
+ dataHook: n,
584
+ keywords: d ? [R, ...d] : [R],
498
585
  value: t,
499
- onSelect: R,
500
- ...b,
501
- children: [M(), F && /* @__PURE__ */ c(Y, {
586
+ onSelect: A,
587
+ ...v,
588
+ children: [L(), P && /* @__PURE__ */ l(X, {
502
589
  "aria-hidden": "true",
503
590
  className: "text-muted-foreground shrink-0"
504
591
  })]
505
592
  });
506
593
  });
507
- ke.displayName = "ComboboxItem";
508
- var Ie = e.forwardRef((t, r) => /* @__PURE__ */ c(me, {
594
+ Ne.displayName = "ComboboxItem";
595
+ var Me = e.forwardRef((t, r) => /* @__PURE__ */ l(ge, {
509
596
  ref: r,
510
597
  "data-slot": "combobox-separator",
511
598
  ...t
512
599
  }));
513
- Ie.displayName = "ComboboxSeparator";
514
- function je({ className: t, children: r, loadingText: a }) {
515
- return /* @__PURE__ */ c("div", {
600
+ Me.displayName = "ComboboxSeparator";
601
+ function Ge({ className: t, children: r, loadingText: n }) {
602
+ return /* @__PURE__ */ l("div", {
516
603
  "aria-live": "polite",
517
- className: T("text-body-sm text-muted-foreground relative flex items-center justify-center gap-2 py-6", "animate-entrance-fade flash-delay", t),
604
+ className: O("text-body-sm text-muted-foreground relative flex items-center justify-center gap-2 py-6", "animate-entrance-fade flash-delay", t),
518
605
  "data-slot": "combobox-loading",
519
606
  role: "status",
520
- children: r || /* @__PURE__ */ H(ee, { children: [/* @__PURE__ */ c(oe, { size: "md" }), /* @__PURE__ */ c("span", {
607
+ children: r || /* @__PURE__ */ K(ne, { children: [/* @__PURE__ */ l(se, { size: "md" }), /* @__PURE__ */ l("span", {
521
608
  className: "sr-only",
522
- children: a ?? "Loading suggestions"
609
+ children: n ?? "Loading suggestions"
523
610
  })] })
524
611
  });
525
612
  }
526
613
  export {
527
- Ae as Combobox,
528
- $e as ComboboxContent,
529
- Ce as ComboboxEmpty,
530
- ye as ComboboxGroup,
531
- he as ComboboxInput,
532
- ke as ComboboxItem,
533
- xe as ComboboxList,
534
- je as ComboboxLoading,
535
- Ie as ComboboxSeparator,
536
- pe as ComboboxTrigger,
537
- Te as ComboboxValue,
538
- Oe as ComboboxVirtualList
614
+ He as Combobox,
615
+ Be as ComboboxContent,
616
+ Ee as ComboboxEmpty,
617
+ Le as ComboboxGroup,
618
+ Re as ComboboxInput,
619
+ Ne as ComboboxItem,
620
+ Ie as ComboboxList,
621
+ Ge as ComboboxLoading,
622
+ Me as ComboboxSeparator,
623
+ xe as ComboboxTrigger,
624
+ _e as ComboboxValue,
625
+ Ue as ComboboxVirtualList
539
626
  };