@brightlocal/ui-components 3.0.0 → 3.1.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 (105) hide show
  1. package/README.md +2 -1
  2. package/component-meta.json +90 -19
  3. package/deprecations.json +113 -3
  4. package/dist/accordion.cjs +1 -1
  5. package/dist/accordion.d.ts +36 -0
  6. package/dist/accordion.d.ts.map +1 -1
  7. package/dist/accordion.js +74 -61
  8. package/dist/blocks/empty-state.cjs +1 -1
  9. package/dist/blocks/empty-state.d.ts.map +1 -1
  10. package/dist/blocks/empty-state.js +41 -49
  11. package/dist/button-group.cjs +1 -0
  12. package/dist/button-group.d.ts +36 -0
  13. package/dist/button-group.d.ts.map +1 -0
  14. package/dist/button-group.js +47 -0
  15. package/dist/button.cjs +1 -1
  16. package/dist/button.js +1 -1
  17. package/dist/card.cjs +1 -1
  18. package/dist/card.d.ts +20 -2
  19. package/dist/card.d.ts.map +1 -1
  20. package/dist/card.js +83 -75
  21. package/dist/chart.cjs +2 -2
  22. package/dist/chart.d.ts +40 -12
  23. package/dist/chart.d.ts.map +1 -1
  24. package/dist/chart.js +86 -71
  25. package/dist/chip.cjs +1 -1
  26. package/dist/chip.d.ts +38 -4
  27. package/dist/chip.d.ts.map +1 -1
  28. package/dist/chip.js +95 -81
  29. package/dist/command.cjs +1 -1
  30. package/dist/command.d.ts +23 -1
  31. package/dist/command.d.ts.map +1 -1
  32. package/dist/command.js +250 -224
  33. package/dist/data-table.cjs +1 -1
  34. package/dist/data-table.d.ts +32 -1
  35. package/dist/data-table.d.ts.map +1 -1
  36. package/dist/data-table.js +340 -330
  37. package/dist/date-picker.cjs +1 -1
  38. package/dist/date-picker.d.ts +13 -5
  39. package/dist/date-picker.d.ts.map +1 -1
  40. package/dist/date-picker.js +54 -53
  41. package/dist/field.cjs +1 -1
  42. package/dist/field.d.ts +8 -1
  43. package/dist/field.d.ts.map +1 -1
  44. package/dist/field.js +79 -52
  45. package/dist/global-layout.cjs +1 -1
  46. package/dist/global-layout.d.ts +105 -13
  47. package/dist/global-layout.d.ts.map +1 -1
  48. package/dist/global-layout.js +146 -129
  49. package/dist/grid.d.ts +2 -2
  50. package/dist/hooks/use-mobile.cjs +1 -0
  51. package/dist/hooks/use-mobile.js +8 -0
  52. package/dist/index.cjs +1 -1
  53. package/dist/index.d.ts +1 -0
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +547 -538
  56. package/dist/input-password.cjs +1 -1
  57. package/dist/input-password.d.ts +17 -9
  58. package/dist/input-password.d.ts.map +1 -1
  59. package/dist/input-password.js +26 -25
  60. package/dist/lib/empty-chip.cjs +1 -0
  61. package/dist/lib/empty-chip.d.ts +4 -0
  62. package/dist/lib/empty-chip.d.ts.map +1 -0
  63. package/dist/lib/empty-chip.js +13 -0
  64. package/dist/pagination.cjs +1 -1
  65. package/dist/pagination.d.ts +3 -0
  66. package/dist/pagination.d.ts.map +1 -1
  67. package/dist/pagination.js +57 -57
  68. package/dist/scroll-area.cjs +1 -1
  69. package/dist/scroll-area.d.ts +15 -6
  70. package/dist/scroll-area.d.ts.map +1 -1
  71. package/dist/scroll-area.js +38 -36
  72. package/dist/select.cjs +2 -2
  73. package/dist/select.d.ts +13 -2
  74. package/dist/select.d.ts.map +1 -1
  75. package/dist/select.js +87 -83
  76. package/dist/typography-heading.cjs +1 -1
  77. package/dist/typography-heading.d.ts +13 -0
  78. package/dist/typography-heading.d.ts.map +1 -1
  79. package/dist/typography-heading.js +32 -21
  80. package/dist/typography-text.cjs +1 -1
  81. package/dist/typography-text.d.ts +14 -0
  82. package/dist/typography-text.d.ts.map +1 -1
  83. package/dist/typography-text.js +35 -24
  84. package/package.json +1 -1
  85. package/src/blocks/empty-state.tsx +9 -21
  86. package/src/components/accordion.tsx +82 -27
  87. package/src/components/button-group.tsx +112 -0
  88. package/src/components/button.tsx +1 -1
  89. package/src/components/card.tsx +38 -3
  90. package/src/components/chart.tsx +63 -18
  91. package/src/components/chip.tsx +83 -10
  92. package/src/components/command.tsx +55 -3
  93. package/src/components/data-table.tsx +67 -7
  94. package/src/components/date-picker.tsx +18 -7
  95. package/src/components/field.tsx +81 -12
  96. package/src/components/global-layout.tsx +176 -38
  97. package/src/components/grid.tsx +2 -2
  98. package/src/components/input-password.tsx +23 -11
  99. package/src/components/pagination.tsx +10 -3
  100. package/src/components/scroll-area.tsx +23 -10
  101. package/src/components/select.tsx +30 -6
  102. package/src/components/typography-heading.tsx +24 -0
  103. package/src/components/typography-text.tsx +26 -1
  104. package/src/index.ts +1 -0
  105. package/src/lib/empty-chip.ts +24 -0
package/dist/command.js CHANGED
@@ -1,11 +1,12 @@
1
- import { jsx as i, jsxs as _ } from "react/jsx-runtime";
1
+ import { jsx as s, jsxs as _ } from "react/jsx-runtime";
2
2
  import * as e from "react";
3
3
  import { Command as P, defaultFilter as B } from "cmdk";
4
4
  import { useVirtualizer as U } from "@tanstack/react-virtual";
5
5
  import { Search as W, X, Check as F } from "@brightlocal/icons";
6
6
  import { Button as Y } from "@brightlocal/ui-components/button";
7
- import { cn as w } from "@brightlocal/ui-components/lib/utils";
7
+ import { cn as y } from "@brightlocal/ui-components/lib/utils";
8
8
  import { useDevWarning as q } from "@brightlocal/ui-components/lib/use-dev-warning";
9
+ import { emptyChipStyles as J } from "./lib/empty-chip.js";
9
10
  const T = e.createContext({
10
11
  searchValue: "",
11
12
  setSearchValue: () => {
@@ -16,103 +17,103 @@ const T = e.createContext({
16
17
  listboxId: void 0,
17
18
  setListboxId: () => {
18
19
  }
19
- }), J = e.forwardRef(({ className: t, dataHook: o, trackingEl: a, trackingLabel: n, ...r }, c) => {
20
- const [x, h] = e.useState(""), [y, R] = e.useState(void 0), [I, k] = e.useState(
20
+ }), Q = e.forwardRef(({ className: t, dataHook: a, trackingEl: r, trackingLabel: o, ...c }, n) => {
21
+ const [p, m] = e.useState(""), [I, R] = e.useState(void 0), [w, C] = e.useState(
21
22
  void 0
22
23
  ), v = e.useMemo(
23
24
  () => ({
24
- searchValue: x,
25
- setSearchValue: h,
26
- activeDescendantId: y,
25
+ searchValue: p,
26
+ setSearchValue: m,
27
+ activeDescendantId: I,
27
28
  setActiveDescendantId: R,
28
- listboxId: I,
29
- setListboxId: k
29
+ listboxId: w,
30
+ setListboxId: C
30
31
  }),
31
- [x, y, I]
32
+ [p, I, w]
32
33
  );
33
- return /* @__PURE__ */ i(T.Provider, { value: v, children: /* @__PURE__ */ i(
34
+ return /* @__PURE__ */ s(T.Provider, { value: v, children: /* @__PURE__ */ s(
34
35
  P,
35
36
  {
36
- ref: c,
37
- className: w(
37
+ ref: n,
38
+ className: y(
38
39
  "bg-popover text-popover-foreground flex w-full flex-col overflow-hidden rounded-lg border shadow-md",
39
40
  t
40
41
  ),
41
- "data-hook": o,
42
+ "data-hook": a,
42
43
  "data-slot": "command",
43
- "data-tracking-el": a,
44
- "data-tracking-label": n,
45
- ...r
44
+ "data-tracking-el": r,
45
+ "data-tracking-label": o,
46
+ ...c
46
47
  }
47
48
  ) });
48
49
  });
49
- J.displayName = "Command";
50
- const Q = e.forwardRef(
50
+ Q.displayName = "Command";
51
+ const Z = e.forwardRef(
51
52
  ({
52
53
  className: t,
53
- dataHook: o,
54
- trackingEl: a,
55
- trackingLabel: n,
56
- value: r,
57
- onValueChange: c,
58
- onClear: x,
59
- debounceMs: h,
60
- clearSearchAriaLabel: y,
54
+ dataHook: a,
55
+ trackingEl: r,
56
+ trackingLabel: o,
57
+ value: c,
58
+ onValueChange: n,
59
+ onClear: p,
60
+ debounceMs: m,
61
+ clearSearchAriaLabel: I,
61
62
  ...R
62
- }, I) => {
63
- const k = e.useRef(null), [v, b] = e.useState(""), s = e.useRef(
63
+ }, w) => {
64
+ const C = e.useRef(null), [v, b] = e.useState(""), l = e.useRef(
64
65
  void 0
65
66
  ), { setSearchValue: N, activeDescendantId: g, listboxId: u } = e.useContext(T);
66
- e.useImperativeHandle(I, () => k.current, []), q(
67
- () => !!(h && h > 0 && r !== void 0),
67
+ e.useImperativeHandle(w, () => C.current, []), q(
68
+ () => !!(m && m > 0 && c !== void 0),
68
69
  "debounceMs is set on <CommandInput> 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.",
69
- [h, r]
70
+ [m, c]
70
71
  ), e.useEffect(() => () => {
71
- s.current && clearTimeout(s.current);
72
+ l.current && clearTimeout(l.current);
72
73
  }, []), e.useEffect(() => {
73
- const f = k.current;
74
- f && (u && f.setAttribute("aria-controls", u), g ? f.setAttribute("aria-activedescendant", g) : f.removeAttribute("aria-activedescendant"));
74
+ const h = C.current;
75
+ h && (u && h.setAttribute("aria-controls", u), g ? h.setAttribute("aria-activedescendant", g) : h.removeAttribute("aria-activedescendant"));
75
76
  });
76
- const E = r !== void 0, S = E ? r : v, A = String(S).length > 0, M = (f) => {
77
- E || b(f), N(f), h && h > 0 ? (clearTimeout(s.current), s.current = setTimeout(() => {
78
- c?.(f);
79
- }, h)) : c?.(f);
80
- }, m = () => {
81
- E || b(""), N(""), clearTimeout(s.current), c?.(""), x?.(), k.current?.focus();
77
+ const S = c !== void 0, E = S ? c : v, A = String(E).length > 0, M = (h) => {
78
+ S || b(h), N(h), m && m > 0 ? (clearTimeout(l.current), l.current = setTimeout(() => {
79
+ n?.(h);
80
+ }, m)) : n?.(h);
81
+ }, f = () => {
82
+ S || b(""), N(""), clearTimeout(l.current), n?.(""), p?.(), C.current?.focus();
82
83
  };
83
84
  return /* @__PURE__ */ _(
84
85
  "div",
85
86
  {
86
87
  className: "border-base-border flex h-12 items-center gap-2 self-stretch border-b px-3",
87
- "data-hook": o,
88
+ "data-hook": a,
88
89
  "data-slot": "command-input-wrapper",
89
90
  children: [
90
- /* @__PURE__ */ i(W, { className: "shrink-0 opacity-50" }),
91
- /* @__PURE__ */ i(
91
+ /* @__PURE__ */ s(W, { className: "shrink-0 opacity-50" }),
92
+ /* @__PURE__ */ s(
92
93
  P.Input,
93
94
  {
94
- ref: k,
95
- className: w(
95
+ ref: C,
96
+ className: y(
96
97
  "placeholder:text-muted-foreground text-body flex w-full bg-transparent outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
97
98
  t
98
99
  ),
99
100
  "data-slot": "command-input",
100
- "data-tracking-el": a,
101
- "data-tracking-label": n,
102
- value: S,
101
+ "data-tracking-el": r,
102
+ "data-tracking-label": o,
103
+ value: E,
103
104
  onValueChange: M,
104
105
  ...R
105
106
  }
106
107
  ),
107
- A && /* @__PURE__ */ i(
108
+ A && /* @__PURE__ */ s(
108
109
  Y,
109
110
  {
110
- "aria-label": y ?? "Clear search",
111
+ "aria-label": I ?? "Clear search",
111
112
  className: "text-muted-foreground hover:text-foreground size-6 p-0",
112
113
  dataHook: "command-input-clear",
113
114
  variant: "ghost",
114
- onClick: m,
115
- children: /* @__PURE__ */ i(X, {})
115
+ onClick: f,
116
+ children: /* @__PURE__ */ s(X, {})
116
117
  }
117
118
  )
118
119
  ]
@@ -120,254 +121,279 @@ const Q = e.forwardRef(
120
121
  );
121
122
  }
122
123
  );
123
- Q.displayName = "CommandInput";
124
- const Z = e.forwardRef(({ className: t, dataHook: o, ...a }, n) => /* @__PURE__ */ i(
124
+ Z.displayName = "CommandInput";
125
+ const ee = e.forwardRef(({ className: t, dataHook: a, ...r }, o) => /* @__PURE__ */ s(
125
126
  P.List,
126
127
  {
127
- ref: n,
128
- className: w(
128
+ ref: o,
129
+ className: y(
129
130
  "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
130
131
  t
131
132
  ),
132
- "data-hook": o,
133
+ "data-hook": a,
133
134
  "data-slot": "command-list",
134
- ...a
135
+ ...r
135
136
  }
136
137
  ));
137
- Z.displayName = "CommandList";
138
- const ee = e.forwardRef(({ dataHook: t, ...o }, a) => {
139
- const n = e.useCallback(
140
- (r) => {
141
- r?.setAttribute("role", "option"), typeof a == "function" ? a(r) : a && (a.current = r);
138
+ ee.displayName = "CommandList";
139
+ const te = e.forwardRef(({ children: t, dataHook: a, description: r, icon: o, ...c }, n) => {
140
+ const p = e.useCallback(
141
+ (m) => {
142
+ m?.setAttribute("role", "option"), typeof n == "function" ? n(m) : n && (n.current = m);
142
143
  },
143
- [a]
144
+ [n]
144
145
  );
145
- return /* @__PURE__ */ i(
146
+ return /* @__PURE__ */ s(
146
147
  P.Empty,
147
148
  {
148
- ref: n,
149
+ ref: p,
149
150
  "aria-disabled": "true",
150
151
  "aria-selected": "false",
151
152
  className: "text-body-sm py-6 text-center",
152
- "data-hook": t,
153
+ "data-hook": a,
153
154
  "data-slot": "command-empty",
154
- ...o
155
+ ...c,
156
+ children: o || r ? (
157
+ /* The compact form. Inside role="option" the content is
158
+ presentational, so the message stays a plain line — never a
159
+ heading — and the chip is aria-hidden. */
160
+ /* @__PURE__ */ _("div", { className: "flex flex-col items-center gap-1 px-4", children: [
161
+ o ? /* @__PURE__ */ s(
162
+ "span",
163
+ {
164
+ "aria-hidden": "true",
165
+ className: y(J(), "mb-1"),
166
+ "data-slot": "command-empty-icon",
167
+ children: o
168
+ }
169
+ ) : null,
170
+ /* @__PURE__ */ s("p", { "data-slot": "command-empty-message", children: t }),
171
+ r ? /* @__PURE__ */ s(
172
+ "p",
173
+ {
174
+ className: "text-muted-foreground",
175
+ "data-slot": "command-empty-description",
176
+ children: r
177
+ }
178
+ ) : null
179
+ ] })
180
+ ) : t
155
181
  }
156
182
  );
157
183
  });
158
- ee.displayName = "CommandEmpty";
159
- const te = e.forwardRef(({ className: t, dataHook: o, ...a }, n) => /* @__PURE__ */ i(
184
+ te.displayName = "CommandEmpty";
185
+ const ae = e.forwardRef(({ className: t, dataHook: a, ...r }, o) => /* @__PURE__ */ s(
160
186
  P.Group,
161
187
  {
162
- ref: n,
163
- className: w(
188
+ ref: o,
189
+ className: y(
164
190
  "text-foreground [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-label-sm overflow-hidden px-2 py-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5",
165
191
  t
166
192
  ),
167
- "data-hook": o,
193
+ "data-hook": a,
168
194
  "data-slot": "command-group",
169
- ...a
195
+ ...r
170
196
  }
171
197
  ));
172
- te.displayName = "CommandGroup";
173
- const ae = e.forwardRef(({ className: t, dataHook: o, ...a }, n) => /* @__PURE__ */ i(
198
+ ae.displayName = "CommandGroup";
199
+ const oe = e.forwardRef(({ className: t, dataHook: a, ...r }, o) => /* @__PURE__ */ s(
174
200
  P.Separator,
175
201
  {
176
- ref: n,
177
- className: w("bg-border -mx-1 h-px", t),
178
- "data-hook": o,
202
+ ref: o,
203
+ className: y("bg-border -mx-1 h-px", t),
204
+ "data-hook": a,
179
205
  "data-slot": "command-separator",
180
- ...a
206
+ ...r
181
207
  }
182
208
  ));
183
- ae.displayName = "CommandSeparator";
184
- const oe = e.forwardRef(
209
+ oe.displayName = "CommandSeparator";
210
+ const ne = e.forwardRef(
185
211
  ({
186
212
  className: t,
187
- dataHook: o,
188
- trackingEl: a,
189
- trackingLabel: n,
190
- selected: r,
191
- children: c,
192
- ...x
193
- }, h) => /* @__PURE__ */ _(
213
+ dataHook: a,
214
+ trackingEl: r,
215
+ trackingLabel: o,
216
+ selected: c,
217
+ children: n,
218
+ ...p
219
+ }, m) => /* @__PURE__ */ _(
194
220
  P.Item,
195
221
  {
196
- ref: h,
197
- className: w(
222
+ ref: m,
223
+ className: y(
198
224
  "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:text-muted-foreground text-label relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
199
225
  t
200
226
  ),
201
- "data-hook": o,
202
- "data-selected-item": r || void 0,
227
+ "data-hook": a,
228
+ "data-selected-item": c || void 0,
203
229
  "data-slot": "command-item",
204
- "data-tracking-el": a,
205
- "data-tracking-label": n,
206
- ...x,
230
+ "data-tracking-el": r,
231
+ "data-tracking-label": o,
232
+ ...p,
207
233
  children: [
208
- c,
209
- r && /* @__PURE__ */ i(F, { className: "text-foreground ml-auto" })
234
+ n,
235
+ c && /* @__PURE__ */ s(F, { className: "text-foreground ml-auto" })
210
236
  ]
211
237
  }
212
238
  )
213
239
  );
214
- oe.displayName = "CommandItem";
215
- const ne = e.forwardRef(
216
- ({ className: t, dataHook: o, trackingEl: a, trackingLabel: n, ...r }, c) => /* @__PURE__ */ i(
240
+ ne.displayName = "CommandItem";
241
+ const re = e.forwardRef(
242
+ ({ className: t, dataHook: a, trackingEl: r, trackingLabel: o, ...c }, n) => /* @__PURE__ */ s(
217
243
  "span",
218
244
  {
219
- ref: c,
220
- className: w("text-muted-foreground text-body-xs ml-auto", t),
221
- "data-hook": o,
245
+ ref: n,
246
+ className: y("text-muted-foreground text-body-xs ml-auto", t),
247
+ "data-hook": a,
222
248
  "data-slot": "command-shortcut",
223
- "data-tracking-el": a,
224
- "data-tracking-label": n,
225
- ...r
249
+ "data-tracking-el": r,
250
+ "data-tracking-label": o,
251
+ ...c
226
252
  }
227
253
  )
228
254
  );
229
- ne.displayName = "CommandShortcut";
255
+ re.displayName = "CommandShortcut";
230
256
  const K = e.createContext(null);
231
- function re({
257
+ function se({
232
258
  items: t,
233
- getItemValue: o,
234
- getItemLabel: a,
235
- getItemKeywords: n,
236
- estimateSize: r = 44,
237
- overscan: c = 5,
238
- children: x,
239
- renderEmpty: h,
240
- "aria-label": y,
259
+ getItemValue: a,
260
+ getItemLabel: r,
261
+ getItemKeywords: o,
262
+ estimateSize: c = 44,
263
+ overscan: n = 5,
264
+ children: p,
265
+ renderEmpty: m,
266
+ "aria-label": I,
241
267
  className: R,
242
- dataHook: I
243
- }, k) {
244
- const v = e.useRef(null), { searchValue: b, setActiveDescendantId: s, setListboxId: N } = e.useContext(T), [g, u] = e.useState(0), E = e.useId(), S = e.useId(), A = e.useRef(/* @__PURE__ */ new Map());
245
- e.useImperativeHandle(k, () => v.current, []);
268
+ dataHook: w
269
+ }, C) {
270
+ const v = e.useRef(null), { searchValue: b, setActiveDescendantId: l, setListboxId: N } = e.useContext(T), [g, u] = e.useState(0), S = e.useId(), E = e.useId(), A = e.useRef(/* @__PURE__ */ new Map());
271
+ e.useImperativeHandle(C, () => v.current, []);
246
272
  const M = e.useMemo(
247
- () => a ?? o,
248
- [a, o]
249
- ), m = e.useMemo(() => {
273
+ () => r ?? a,
274
+ [r, a]
275
+ ), f = e.useMemo(() => {
250
276
  if (!b.trim()) return t;
251
277
  const d = [];
252
- for (const p of t) {
253
- let l = B(M(p), b);
254
- if (n)
255
- for (const C of n(p))
256
- l = Math.max(l, B(C, b));
257
- l > 0 && d.push({ item: p, score: l });
278
+ for (const x of t) {
279
+ let i = B(M(x), b);
280
+ if (o)
281
+ for (const k of o(x))
282
+ i = Math.max(i, B(k, b));
283
+ i > 0 && d.push({ item: x, score: i });
258
284
  }
259
- return d.sort((p, l) => l.score - p.score), d.map((p) => p.item);
260
- }, [t, b, M, n]), f = U({
261
- count: m.length,
285
+ return d.sort((x, i) => i.score - x.score), d.map((x) => x.item);
286
+ }, [t, b, M, o]), h = U({
287
+ count: f.length,
262
288
  getScrollElement: () => v.current,
263
- estimateSize: () => r,
264
- overscan: c
265
- }), D = g >= 0 && g < m.length ? o(m[g]) : null;
289
+ estimateSize: () => c,
290
+ overscan: n
291
+ }), D = g >= 0 && g < f.length ? a(f[g]) : null;
266
292
  e.useEffect(() => {
267
293
  u(0);
268
- }, [b, m.length]);
294
+ }, [b, f.length]);
269
295
  const L = e.useRef(!1);
270
296
  e.useEffect(() => {
271
- L.current && g >= 0 && g < m.length && f.scrollToIndex(g, { align: "auto" }), L.current = !1;
272
- }, [g, m.length, f]), e.useEffect(() => {
297
+ L.current && g >= 0 && g < f.length && h.scrollToIndex(g, { align: "auto" }), L.current = !1;
298
+ }, [g, f.length, h]), e.useEffect(() => {
273
299
  const d = v.current?.closest(
274
300
  '[data-slot="command"]'
275
301
  );
276
302
  if (!d) return;
277
- const p = (l) => {
278
- switch (l.key) {
303
+ const x = (i) => {
304
+ switch (i.key) {
279
305
  case "ArrowDown":
280
- l.preventDefault(), l.stopPropagation(), L.current = !0, u(
281
- (C) => C < m.length - 1 ? C + 1 : C
306
+ i.preventDefault(), i.stopPropagation(), L.current = !0, u(
307
+ (k) => k < f.length - 1 ? k + 1 : k
282
308
  );
283
309
  break;
284
310
  case "ArrowUp":
285
- l.preventDefault(), l.stopPropagation(), L.current = !0, u((C) => C > 0 ? C - 1 : C);
311
+ i.preventDefault(), i.stopPropagation(), L.current = !0, u((k) => k > 0 ? k - 1 : k);
286
312
  break;
287
313
  case "Enter": {
288
- l.preventDefault(), l.stopPropagation(), D != null && A.current.get(D)?.();
314
+ i.preventDefault(), i.stopPropagation(), D != null && A.current.get(D)?.();
289
315
  break;
290
316
  }
291
317
  case "Home":
292
- l.preventDefault(), l.stopPropagation(), L.current = !0, u(0);
318
+ i.preventDefault(), i.stopPropagation(), L.current = !0, u(0);
293
319
  break;
294
320
  case "End":
295
- l.preventDefault(), l.stopPropagation(), L.current = !0, u(m.length - 1);
321
+ i.preventDefault(), i.stopPropagation(), L.current = !0, u(f.length - 1);
296
322
  break;
297
323
  }
298
324
  };
299
- return d.addEventListener("keydown", p, { capture: !0 }), () => d.removeEventListener("keydown", p, { capture: !0 });
300
- }, [m, D]);
325
+ return d.addEventListener("keydown", x, { capture: !0 }), () => d.removeEventListener("keydown", x, { capture: !0 });
326
+ }, [f, D]);
301
327
  const V = e.useMemo(() => {
302
328
  const d = /* @__PURE__ */ new Map();
303
- return m.forEach((p, l) => {
304
- d.set(o(p), l);
329
+ return f.forEach((x, i) => {
330
+ d.set(a(x), i);
305
331
  }), d;
306
- }, [m, o]), $ = e.useCallback(
332
+ }, [f, a]), $ = e.useCallback(
307
333
  (d) => {
308
- const p = V.get(d);
309
- p !== void 0 && u(p);
334
+ const x = V.get(d);
335
+ x !== void 0 && u(x);
310
336
  },
311
337
  [V]
312
338
  ), z = e.useCallback(
313
339
  (d) => (V.get(d) ?? 0) + 1,
314
340
  [V]
315
- ), H = m.length, O = e.useMemo(
341
+ ), H = f.length, O = e.useMemo(
316
342
  () => ({
317
343
  activeValue: D,
318
344
  onItemPointerMove: $,
319
- idPrefix: E,
345
+ idPrefix: S,
320
346
  filteredCount: H,
321
347
  getItemPosition: z,
322
348
  onSelectCallbacks: A
323
349
  }),
324
- [D, $, E, H, z]
325
- ), G = D != null ? `${E}item-${D}` : void 0;
326
- e.useEffect(() => (s(G), () => s(void 0)), [G, s]), e.useEffect(() => (N(S), () => N(void 0)), [S, N]);
327
- const j = w(
350
+ [D, $, S, H, z]
351
+ ), G = D != null ? `${S}item-${D}` : void 0;
352
+ e.useEffect(() => (l(G), () => l(void 0)), [G, l]), e.useEffect(() => (N(E), () => N(void 0)), [E, N]);
353
+ const j = y(
328
354
  "scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
329
355
  R
330
356
  );
331
- return m.length === 0 ? /* @__PURE__ */ i(
357
+ return f.length === 0 ? /* @__PURE__ */ s(
332
358
  "div",
333
359
  {
334
360
  ref: v,
335
- "aria-label": y,
361
+ "aria-label": I,
336
362
  className: j,
337
- "data-hook": I,
363
+ "data-hook": w,
338
364
  "data-slot": "command-virtual-list",
339
- id: S,
365
+ id: E,
340
366
  role: "listbox",
341
367
  tabIndex: -1,
342
- children: h
368
+ children: m
343
369
  }
344
- ) : /* @__PURE__ */ i(K.Provider, { value: O, children: /* @__PURE__ */ i(
370
+ ) : /* @__PURE__ */ s(K.Provider, { value: O, children: /* @__PURE__ */ s(
345
371
  "div",
346
372
  {
347
373
  ref: v,
348
- "aria-label": y,
374
+ "aria-label": I,
349
375
  className: j,
350
- "data-hook": I,
376
+ "data-hook": w,
351
377
  "data-slot": "command-virtual-list",
352
- id: S,
378
+ id: E,
353
379
  role: "listbox",
354
380
  tabIndex: -1,
355
- children: /* @__PURE__ */ i(
381
+ children: /* @__PURE__ */ s(
356
382
  "div",
357
383
  {
358
384
  className: "relative w-full",
359
- style: { height: `${f.getTotalSize()}px` },
360
- children: f.getVirtualItems().map((d) => /* @__PURE__ */ i(
385
+ style: { height: `${h.getTotalSize()}px` },
386
+ children: h.getVirtualItems().map((d) => /* @__PURE__ */ s(
361
387
  "div",
362
388
  {
363
- ref: f.measureElement,
389
+ ref: h.measureElement,
364
390
  className: "absolute top-0 left-0 w-full px-2",
365
391
  "data-index": d.index,
366
392
  style: {
367
393
  transform: `translateY(${d.start}px)`
368
394
  },
369
- children: x(
370
- m[d.index],
395
+ children: p(
396
+ f[d.index],
371
397
  d.index,
372
398
  b
373
399
  )
@@ -379,84 +405,84 @@ function re({
379
405
  }
380
406
  ) });
381
407
  }
382
- const pe = e.forwardRef(re), se = e.forwardRef(
408
+ const xe = e.forwardRef(se), le = e.forwardRef(
383
409
  ({
384
410
  value: t,
385
- dataHook: o,
386
- trackingEl: a,
387
- trackingLabel: n,
388
- selected: r,
389
- disabled: c,
390
- onSelect: x,
391
- children: h,
392
- className: y,
411
+ dataHook: a,
412
+ trackingEl: r,
413
+ trackingLabel: o,
414
+ selected: c,
415
+ disabled: n,
416
+ onSelect: p,
417
+ children: m,
418
+ className: I,
393
419
  onClick: R,
394
- onKeyDown: I,
395
- onPointerMove: k,
420
+ onKeyDown: w,
421
+ onPointerMove: C,
396
422
  ...v
397
423
  }, b) => {
398
- const s = e.useContext(K), N = s?.activeValue === t, g = e.useRef(x);
424
+ const l = e.useContext(K), N = l?.activeValue === t, g = e.useRef(p);
399
425
  return e.useEffect(() => {
400
- g.current = x;
426
+ g.current = p;
401
427
  }), e.useEffect(() => {
402
- if (s)
403
- return s.onSelectCallbacks.current.set(
428
+ if (l)
429
+ return l.onSelectCallbacks.current.set(
404
430
  t,
405
431
  () => g.current?.()
406
432
  ), () => {
407
- s.onSelectCallbacks.current.delete(t);
433
+ l.onSelectCallbacks.current.delete(t);
408
434
  };
409
- }, [t, s]), /* @__PURE__ */ _(
435
+ }, [t, l]), /* @__PURE__ */ _(
410
436
  "div",
411
437
  {
412
438
  ref: b,
413
439
  ...v,
414
- "aria-disabled": c || void 0,
415
- "aria-posinset": s?.getItemPosition(t),
416
- "aria-selected": r || void 0,
417
- "aria-setsize": s?.filteredCount,
418
- className: w(
440
+ "aria-disabled": n || void 0,
441
+ "aria-posinset": l?.getItemPosition(t),
442
+ "aria-selected": c || void 0,
443
+ "aria-setsize": l?.filteredCount,
444
+ className: y(
419
445
  "data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 outline-hidden select-none",
420
446
  "[&_svg]:pointer-events-none [&_svg]:shrink-0",
421
- c && "pointer-events-none opacity-50",
422
- y
447
+ n && "pointer-events-none opacity-50",
448
+ I
423
449
  ),
424
450
  "data-highlighted": N || void 0,
425
- "data-hook": o,
426
- "data-selected-item": r || void 0,
451
+ "data-hook": a,
452
+ "data-selected-item": c || void 0,
427
453
  "data-slot": "command-virtual-item",
428
- "data-tracking-el": a,
429
- "data-tracking-label": n,
430
- id: s ? `${s.idPrefix}item-${t}` : void 0,
454
+ "data-tracking-el": r,
455
+ "data-tracking-label": o,
456
+ id: l ? `${l.idPrefix}item-${t}` : void 0,
431
457
  role: "option",
432
458
  tabIndex: -1,
433
- onClick: c ? void 0 : (u) => {
434
- x?.(), R?.(u);
459
+ onClick: n ? void 0 : (u) => {
460
+ p?.(), R?.(u);
435
461
  },
436
- onKeyDown: c ? void 0 : (u) => {
437
- (u.key === "Enter" || u.key === " ") && x?.(), I?.(u);
462
+ onKeyDown: n ? void 0 : (u) => {
463
+ (u.key === "Enter" || u.key === " ") && p?.(), w?.(u);
438
464
  },
439
- onPointerMove: c ? void 0 : (u) => {
440
- s?.onItemPointerMove(t), k?.(u);
465
+ onPointerMove: n ? void 0 : (u) => {
466
+ l?.onItemPointerMove(t), C?.(u);
441
467
  },
442
468
  children: [
443
- h,
444
- r && /* @__PURE__ */ i(F, { className: "text-foreground ml-auto" })
469
+ m,
470
+ c && /* @__PURE__ */ s(F, { className: "text-foreground ml-auto" })
445
471
  ]
446
472
  }
447
473
  );
448
474
  }
449
475
  );
450
- se.displayName = "CommandVirtualItem";
476
+ le.displayName = "CommandVirtualItem";
451
477
  export {
452
- J as Command,
453
- ee as CommandEmpty,
454
- te as CommandGroup,
455
- Q as CommandInput,
456
- oe as CommandItem,
457
- Z as CommandList,
458
- ae as CommandSeparator,
459
- ne as CommandShortcut,
460
- se as CommandVirtualItem,
461
- pe as CommandVirtualList
478
+ Q as Command,
479
+ te as CommandEmpty,
480
+ ae as CommandGroup,
481
+ Z as CommandInput,
482
+ ne as CommandItem,
483
+ ee as CommandList,
484
+ oe as CommandSeparator,
485
+ re as CommandShortcut,
486
+ le as CommandVirtualItem,
487
+ xe as CommandVirtualList
462
488
  };