@brightlocal/ui-components 2.25.0 → 2.27.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 (98) hide show
  1. package/README.md +4 -2
  2. package/component-meta.json +3809 -182
  3. package/dist/alert.cjs +1 -1
  4. package/dist/alert.d.ts +23 -9
  5. package/dist/alert.d.ts.map +1 -1
  6. package/dist/alert.js +95 -87
  7. package/dist/blocks/progress-screen.cjs +1 -0
  8. package/dist/blocks/progress-screen.d.ts +109 -0
  9. package/dist/blocks/progress-screen.d.ts.map +1 -0
  10. package/dist/blocks/progress-screen.js +339 -0
  11. package/dist/blocks/sidebar.cjs +1 -1
  12. package/dist/blocks/sidebar.d.ts.map +1 -1
  13. package/dist/blocks/sidebar.js +155 -153
  14. package/dist/brand-illustration-motif.d.ts +1 -1
  15. package/dist/breadcrumb.cjs +1 -1
  16. package/dist/breadcrumb.d.ts.map +1 -1
  17. package/dist/breadcrumb.js +44 -40
  18. package/dist/button.cjs +1 -1
  19. package/dist/button.d.ts.map +1 -1
  20. package/dist/button.js +28 -28
  21. package/dist/chip.cjs +1 -1
  22. package/dist/chip.d.ts +1 -1
  23. package/dist/chip.d.ts.map +1 -1
  24. package/dist/chip.js +42 -41
  25. package/dist/combobox.cjs +3 -3
  26. package/dist/combobox.d.ts +4 -2
  27. package/dist/combobox.d.ts.map +1 -1
  28. package/dist/combobox.js +161 -161
  29. package/dist/data-table.cjs +1 -1
  30. package/dist/data-table.d.ts +155 -4
  31. package/dist/data-table.d.ts.map +1 -1
  32. package/dist/data-table.js +462 -309
  33. package/dist/global-layout.cjs +1 -1
  34. package/dist/global-layout.d.ts +31 -5
  35. package/dist/global-layout.d.ts.map +1 -1
  36. package/dist/global-layout.js +276 -194
  37. package/dist/index.cjs +1 -1
  38. package/dist/index.d.ts +3 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +462 -451
  41. package/dist/lib/motion.cjs +1 -1
  42. package/dist/lib/motion.js +10 -8
  43. package/dist/link.cjs +1 -1
  44. package/dist/link.d.ts +5 -2
  45. package/dist/link.d.ts.map +1 -1
  46. package/dist/link.js +97 -91
  47. package/dist/list.cjs +1 -1
  48. package/dist/list.js +65 -63
  49. package/dist/progress.cjs +1 -1
  50. package/dist/progress.d.ts +61 -3
  51. package/dist/progress.d.ts.map +1 -1
  52. package/dist/progress.js +142 -65
  53. package/dist/route-progress.cjs +1 -0
  54. package/dist/route-progress.d.ts +103 -0
  55. package/dist/route-progress.d.ts.map +1 -0
  56. package/dist/route-progress.js +106 -0
  57. package/dist/sheet.cjs +1 -1
  58. package/dist/sheet.d.ts +35 -2
  59. package/dist/sheet.d.ts.map +1 -1
  60. package/dist/sheet.js +102 -65
  61. package/dist/sonner.cjs +1 -1
  62. package/dist/sonner.d.ts.map +1 -1
  63. package/dist/sonner.js +11 -15
  64. package/dist/spinner.cjs +1 -0
  65. package/dist/spinner.d.ts +57 -0
  66. package/dist/spinner.d.ts.map +1 -0
  67. package/dist/spinner.js +35 -0
  68. package/dist/stepper.cjs +1 -1
  69. package/dist/stepper.d.ts.map +1 -1
  70. package/dist/stepper.js +26 -25
  71. package/dist/table.cjs +1 -1
  72. package/dist/table.d.ts +1 -1
  73. package/dist/table.d.ts.map +1 -1
  74. package/dist/table.js +6 -2
  75. package/package.json +15 -6
  76. package/src/blocks/progress-screen.tsx +481 -0
  77. package/src/blocks/sidebar.tsx +22 -15
  78. package/src/components/alert.tsx +68 -33
  79. package/src/components/breadcrumb.tsx +9 -4
  80. package/src/components/button.tsx +2 -5
  81. package/src/components/chip.tsx +4 -3
  82. package/src/components/combobox.tsx +15 -8
  83. package/src/components/data-table.tsx +358 -16
  84. package/src/components/global-layout.tsx +228 -62
  85. package/src/components/link.tsx +88 -63
  86. package/src/components/list.tsx +5 -5
  87. package/src/components/progress.tsx +217 -30
  88. package/src/components/route-progress.tsx +354 -0
  89. package/src/components/sheet.tsx +87 -5
  90. package/src/components/sonner.tsx +3 -12
  91. package/src/components/spinner.tsx +94 -0
  92. package/src/components/stepper.tsx +3 -4
  93. package/src/components/table.tsx +6 -2
  94. package/src/index.ts +3 -0
  95. package/dist/browser-entry.d.ts +0 -19
  96. package/dist/browser-entry.d.ts.map +0 -1
  97. package/src/browser-entry.ts +0 -99
  98. package/src/browser-tokens.css +0 -1
package/dist/combobox.js CHANGED
@@ -7,7 +7,8 @@ import { defaultFilter as K } from "cmdk";
7
7
  import { cn as T } from "@brightlocal/ui-components/lib/utils";
8
8
  import { useDevWarning as H } from "@brightlocal/ui-components/lib/use-dev-warning";
9
9
  import { Popover as re, PopoverContent as ne, PopoverTrigger as ae } from "@brightlocal/ui-components/popover";
10
- import { Command as se, CommandEmpty as ie, CommandGroup as le, CommandInput as ue, CommandItem as ce, CommandList as de, CommandSeparator as fe } from "@brightlocal/ui-components/command";
10
+ import { Command as se, CommandEmpty as ie, CommandGroup as le, CommandInput as ce, CommandItem as ue, CommandList as de, CommandSeparator as fe } from "@brightlocal/ui-components/command";
11
+ import { Spinner as me } from "@brightlocal/ui-components/spinner";
11
12
  const J = e.createContext(null), Q = e.createContext(null);
12
13
  function _() {
13
14
  const t = e.useContext(J);
@@ -15,7 +16,7 @@ function _() {
15
16
  throw new Error("Combobox components must be used within a <Combobox>");
16
17
  return t;
17
18
  }
18
- function Fe({
19
+ function Te({
19
20
  value: t,
20
21
  onValueChange: r,
21
22
  open: a,
@@ -23,21 +24,21 @@ function Fe({
23
24
  onClose: s,
24
25
  shouldFilter: f = !0,
25
26
  disabled: l = !1,
26
- itemToStringValue: c,
27
- children: m
27
+ itemToStringValue: u,
28
+ children: b
28
29
  }) {
29
- const [v, D] = e.useState(""), [x, b] = e.useState(!1), [S, E] = e.useState(
30
+ const [v, D] = e.useState(""), [g, m] = e.useState(!1), [S, E] = e.useState(
30
31
  () => /* @__PURE__ */ new Map()
31
- ), [C, L] = e.useState(""), [V, y] = e.useState(void 0), w = t !== void 0, M = a !== void 0, R = w ? t : v, k = M ? a : x, N = e.useCallback(
32
- (h) => {
33
- h || L(""), M || b(h), o?.(h);
32
+ ), [C, L] = e.useState(""), [V, w] = e.useState(void 0), y = t !== void 0, M = a !== void 0, R = y ? t : v, k = M ? a : g, N = e.useCallback(
33
+ (x) => {
34
+ x || L(""), M || m(x), o?.(x);
34
35
  },
35
36
  [M, o]
36
37
  ), p = e.useCallback(
37
- (h) => {
38
- w || D(h), r?.(h);
38
+ (x) => {
39
+ y || D(x), r?.(x);
39
40
  },
40
- [w, r]
41
+ [y, r]
41
42
  ), I = e.useRef(s);
42
43
  e.useEffect(() => {
43
44
  I.current = s;
@@ -48,24 +49,24 @@ function Fe({
48
49
  }, [k]), e.useEffect(() => () => {
49
50
  A.current && I.current?.();
50
51
  }, []);
51
- const u = e.useRef(/* @__PURE__ */ new Map()), F = e.useRef(!1), O = e.useRef(!0);
52
+ const c = e.useRef(/* @__PURE__ */ new Map()), F = e.useRef(!1), O = e.useRef(!0);
52
53
  e.useEffect(() => () => {
53
54
  O.current = !1;
54
55
  }, []);
55
56
  const j = e.useCallback(() => {
56
57
  F.current || (F.current = !0, queueMicrotask(() => {
57
- F.current = !1, O.current && E(new Map(u.current));
58
+ F.current = !1, O.current && E(new Map(c.current));
58
59
  }));
59
60
  }, []), $ = e.useCallback(
60
- (h, n) => {
61
- u.current.get(h) !== n && (u.current.set(h, n), j());
61
+ (x, n) => {
62
+ c.current.get(x) !== n && (c.current.set(x, n), j());
62
63
  },
63
64
  [j]
64
65
  ), z = e.useCallback(
65
- (h) => {
66
- for (const [n, i] of h)
67
- u.current.set(n, i);
68
- E(new Map(u.current));
66
+ (x) => {
67
+ for (const [n, i] of x)
68
+ c.current.set(n, i);
69
+ E(new Map(c.current));
69
70
  },
70
71
  []
71
72
  ), q = e.useRef(R);
@@ -73,13 +74,13 @@ function Fe({
73
74
  q.current = R;
74
75
  }, [R]);
75
76
  const U = e.useCallback(
76
- (h) => {
77
- h !== q.current && u.current.has(h) && (u.current.delete(h), j());
77
+ (x) => {
78
+ x !== q.current && c.current.has(x) && (c.current.delete(x), j());
78
79
  },
79
80
  [j]
80
81
  ), G = e.useMemo(
81
- () => c ? (h, n, i) => K(c(h), n, i) : K,
82
- [c]
82
+ () => u ? (x, n, i) => K(u(x), n, i) : K,
83
+ [u]
83
84
  ), W = e.useMemo(
84
85
  () => ({
85
86
  open: k,
@@ -92,12 +93,12 @@ function Fe({
92
93
  registerItem: $,
93
94
  registerItemsSync: z,
94
95
  unregisterItem: U,
95
- itemToStringValue: c,
96
+ itemToStringValue: u,
96
97
  filterFn: G,
97
98
  searchValue: C,
98
99
  setSearchValue: L,
99
100
  activeDescendantId: V,
100
- setActiveDescendantId: y
101
+ setActiveDescendantId: w
101
102
  }),
102
103
  [
103
104
  k,
@@ -110,14 +111,14 @@ function Fe({
110
111
  $,
111
112
  z,
112
113
  U,
113
- c,
114
+ u,
114
115
  G,
115
116
  C,
116
117
  V,
117
- y
118
+ w
118
119
  ]
119
120
  );
120
- return /* @__PURE__ */ d(J.Provider, { value: W, children: /* @__PURE__ */ d(re, { open: k, onOpenChange: N, children: m }) });
121
+ return /* @__PURE__ */ d(J.Provider, { value: W, children: /* @__PURE__ */ d(re, { open: k, onOpenChange: N, children: b }) });
121
122
  }
122
123
  const be = oe([
123
124
  // Base layout
@@ -142,7 +143,7 @@ const be = oe([
142
143
  "transition-[background-color,border-color,box-shadow] duration-fast ease-out",
143
144
  // Icon styles
144
145
  "[&_svg]:pointer-events-none [&_svg]:shrink-0"
145
- ]), me = e.forwardRef(
146
+ ]), pe = e.forwardRef(
146
147
  ({
147
148
  className: t,
148
149
  dataHook: r,
@@ -151,14 +152,14 @@ const be = oe([
151
152
  trackingLabel: s,
152
153
  children: f,
153
154
  ...l
154
- }, c) => {
155
- const { open: m, disabled: v, value: D } = _(), x = e.useId(), b = !D, S = a || l["aria-invalid"] === !0 || l["aria-invalid"] === "true";
155
+ }, u) => {
156
+ const { open: b, disabled: v, value: D } = _(), g = e.useId(), m = !D, S = a || l["aria-invalid"] === !0 || l["aria-invalid"] === "true";
156
157
  return /* @__PURE__ */ d(ae, { asChild: !0, children: /* @__PURE__ */ B(
157
158
  "button",
158
159
  {
159
- ref: c,
160
- "aria-controls": m ? x : void 0,
161
- "aria-expanded": m,
160
+ ref: u,
161
+ "aria-controls": b ? g : void 0,
162
+ "aria-expanded": b,
162
163
  "aria-haspopup": "listbox",
163
164
  "aria-invalid": S ? "true" : void 0,
164
165
  className: T(
@@ -167,9 +168,9 @@ const be = oe([
167
168
  t
168
169
  ),
169
170
  "data-hook": r,
170
- "data-placeholder": b,
171
+ "data-placeholder": m,
171
172
  "data-slot": "combobox-trigger",
172
- "data-state": m ? "open" : "closed",
173
+ "data-state": b ? "open" : "closed",
173
174
  "data-tracking-el": o || "combobox-trigger",
174
175
  "data-tracking-label": s,
175
176
  disabled: v || l.disabled,
@@ -190,8 +191,8 @@ const be = oe([
190
191
  ) });
191
192
  }
192
193
  );
193
- me.displayName = "ComboboxTrigger";
194
- function pe(t) {
194
+ pe.displayName = "ComboboxTrigger";
195
+ function ge(t) {
195
196
  return t != null && typeof t == "object" && "value" in t && typeof t.value == "string";
196
197
  }
197
198
  function X(t, r, a) {
@@ -202,15 +203,15 @@ function X(t, r, a) {
202
203
  hasDistinctLabel: !!a
203
204
  };
204
205
  const o = t[0];
205
- if (!pe(o)) return null;
206
- const s = (c) => c.value, f = "label" in o && typeof o.label == "string";
206
+ if (!ge(o)) return null;
207
+ const s = (u) => u.value, f = "label" in o && typeof o.label == "string";
207
208
  return {
208
209
  getValue: s,
209
- getLabel: a ?? (f ? (c) => String(c.label) : s),
210
+ getLabel: a ?? (f ? (u) => String(u.label) : s),
210
211
  hasDistinctLabel: f || !!a
211
212
  };
212
213
  }
213
- function Ae({
214
+ function $e({
214
215
  placeholder: t,
215
216
  className: r,
216
217
  displayValue: a,
@@ -218,18 +219,18 @@ function Ae({
218
219
  getItemValue: s,
219
220
  getItemLabel: f
220
221
  }) {
221
- const { value: l, itemLabels: c } = _(), m = e.useMemo(
222
+ const { value: l, itemLabels: u } = _(), b = e.useMemo(
222
223
  () => o ? X(o, s, f) : null,
223
224
  [o, s, f]
224
225
  );
225
226
  H(
226
- () => !!o && o.length > 0 && !m,
227
+ () => !!o && o.length > 0 && !b,
227
228
  "ComboboxValue: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",
228
- [o, m]
229
+ [o, b]
229
230
  );
230
- const v = e.useMemo(() => !o || !m ? null : new Map(
231
- o.map((x) => [m.getValue(x), m.getLabel(x)])
232
- ), [o, m]), D = l ? v?.get(l) || c.get(l) || a?.(l) || l : t;
231
+ const v = e.useMemo(() => !o || !b ? null : new Map(
232
+ o.map((g) => [b.getValue(g), b.getLabel(g)])
233
+ ), [o, b]), D = l ? v?.get(l) || u.get(l) || a?.(l) || l : t;
233
234
  return /* @__PURE__ */ d(
234
235
  "span",
235
236
  {
@@ -242,7 +243,7 @@ function Ae({
242
243
  }
243
244
  );
244
245
  }
245
- function Te({
246
+ function Oe({
246
247
  dataHook: t,
247
248
  className: r,
248
249
  children: a,
@@ -250,46 +251,46 @@ function Te({
250
251
  side: s = "bottom",
251
252
  sideOffset: f,
252
253
  avoidCollisions: l,
253
- hideList: c = !1,
254
- ariaLabel: m
254
+ hideList: u = !1,
255
+ ariaLabel: b
255
256
  }) {
256
- const { open: v, shouldFilter: D, filterFn: x, itemToStringValue: b } = _(), [S, E] = e.useState(
257
+ const { open: v, shouldFilter: D, filterFn: g, itemToStringValue: m } = _(), [S, E] = e.useState(
257
258
  null
258
- ), C = e.useRef(null), L = e.useCallback((y) => {
259
- if (C.current?.(), C.current = null, !y) return;
260
- let w = !1;
259
+ ), C = e.useRef(null), L = e.useCallback((w) => {
260
+ if (C.current?.(), C.current = null, !w) return;
261
+ let y = !1;
261
262
  const M = (p) => {
262
- w || (p === "top" || p === "bottom") && (w = !0, R.disconnect(), E(p));
263
+ y || (p === "top" || p === "bottom") && (y = !0, R.disconnect(), E(p));
263
264
  }, R = new MutationObserver(() => {
264
- M(y.getAttribute("data-side"));
265
+ M(w.getAttribute("data-side"));
265
266
  });
266
- R.observe(y, {
267
+ R.observe(w, {
267
268
  attributes: !0,
268
269
  attributeFilter: ["data-side"]
269
270
  });
270
271
  let k = 0, N = 0;
271
272
  k = requestAnimationFrame(() => {
272
273
  N = requestAnimationFrame(() => {
273
- M(y.getAttribute("data-side"));
274
+ M(w.getAttribute("data-side"));
274
275
  });
275
276
  }), C.current = () => {
276
- w = !0, R.disconnect(), cancelAnimationFrame(k), cancelAnimationFrame(N);
277
+ y = !0, R.disconnect(), cancelAnimationFrame(k), cancelAnimationFrame(N);
277
278
  };
278
279
  }, []);
279
280
  e.useEffect(() => {
280
281
  if (!v) {
281
282
  C.current?.(), C.current = null;
282
- const y = setTimeout(() => E(null), 150);
283
- return () => clearTimeout(y);
283
+ const w = setTimeout(() => E(null), 150);
284
+ return () => clearTimeout(w);
284
285
  }
285
286
  }, [v]);
286
- const V = b ? x : void 0;
287
+ const V = m ? g : void 0;
287
288
  return /* @__PURE__ */ d(
288
289
  ne,
289
290
  {
290
291
  ref: L,
291
292
  align: o,
292
- "aria-label": m ?? "Options",
293
+ "aria-label": b ?? "Options",
293
294
  avoidCollisions: l,
294
295
  className: T(
295
296
  "flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",
@@ -305,7 +306,7 @@ function Te({
305
306
  className: T(
306
307
  "min-h-0 flex-1 border-0 shadow-none",
307
308
  "[&_[data-slot='command-input-wrapper']]:shrink-0",
308
- c && "[&_[data-slot='command-input-wrapper']]:border-b-0"
309
+ u && "[&_[data-slot='command-input-wrapper']]:border-b-0"
309
310
  ),
310
311
  "data-slot": "combobox-command",
311
312
  dataHook: t || "combobox-command",
@@ -318,7 +319,7 @@ function Te({
318
319
  );
319
320
  }
320
321
  const xe = e.forwardRef(({ debounceMs: t, onValueChange: r, ...a }, o) => {
321
- const { setSearchValue: s, shouldFilter: f, activeDescendantId: l } = _(), c = e.useRef(
322
+ const { setSearchValue: s, shouldFilter: f, activeDescendantId: l } = _(), u = e.useRef(
322
323
  void 0
323
324
  );
324
325
  H(
@@ -332,23 +333,23 @@ Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs fo
332
333
  "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.",
333
334
  [t, a.value]
334
335
  ), e.useEffect(() => () => {
335
- c.current && clearTimeout(c.current);
336
+ u.current && clearTimeout(u.current);
336
337
  }, []);
337
- const m = e.useCallback(
338
+ const b = e.useCallback(
338
339
  (v) => {
339
- s(v), t && t > 0 ? (clearTimeout(c.current), c.current = setTimeout(() => {
340
+ s(v), t && t > 0 ? (clearTimeout(u.current), u.current = setTimeout(() => {
340
341
  r?.(v);
341
342
  }, t)) : r?.(v);
342
343
  },
343
344
  [t, r, s]
344
345
  );
345
346
  return /* @__PURE__ */ d(
346
- ue,
347
+ ce,
347
348
  {
348
349
  ref: o,
349
350
  "aria-activedescendant": l,
350
351
  "data-slot": "combobox-input",
351
- onValueChange: m,
352
+ onValueChange: b,
352
353
  ...a
353
354
  }
354
355
  );
@@ -364,7 +365,7 @@ const he = e.forwardRef(({ className: t, ...r }, a) => /* @__PURE__ */ d(
364
365
  }
365
366
  ));
366
367
  he.displayName = "ComboboxList";
367
- function ge({
368
+ function ve({
368
369
  items: t,
369
370
  getItemValue: r,
370
371
  getItemLabel: a,
@@ -372,37 +373,37 @@ function ge({
372
373
  estimateSize: s = 36,
373
374
  overscan: f = 5,
374
375
  children: l,
375
- renderEmpty: c,
376
- className: m,
376
+ renderEmpty: u,
377
+ className: b,
377
378
  dataHook: v
378
379
  }, D) {
379
- const x = e.useMemo(
380
+ const g = e.useMemo(
380
381
  () => X(t, r, a),
381
382
  [t, r, a]
382
- ), b = e.useMemo(
383
- () => x?.getValue ?? ((n) => {
383
+ ), m = e.useMemo(
384
+ () => g?.getValue ?? ((n) => {
384
385
  if (typeof n == "string" || typeof n == "number")
385
386
  return String(n);
386
387
  throw new Error(
387
388
  "[BrightLocal DS] ComboboxVirtualList: `getItemValue` is required for non-primitive items without a `value` property."
388
389
  );
389
390
  }),
390
- [x]
391
+ [g]
391
392
  ), S = e.useMemo(
392
- () => x?.getLabel ?? b,
393
- [x, b]
393
+ () => g?.getLabel ?? m,
394
+ [g, m]
394
395
  );
395
396
  H(
396
- () => !x && t.length > 0,
397
+ () => !g && t.length > 0,
397
398
  "ComboboxVirtualList: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",
398
- [x, t.length]
399
+ [g, t.length]
399
400
  );
400
401
  const E = e.useRef(null), {
401
402
  value: C,
402
403
  onValueChange: L,
403
404
  setOpen: V,
404
- shouldFilter: y,
405
- searchValue: w,
405
+ shouldFilter: w,
406
+ searchValue: y,
406
407
  filterFn: M,
407
408
  setActiveDescendantId: R,
408
409
  registerItemsSync: k,
@@ -410,89 +411,89 @@ function ge({
410
411
  } = _(), [p, I] = e.useState(0), A = e.useId();
411
412
  e.useImperativeHandle(D, () => E.current, []), e.useLayoutEffect(() => {
412
413
  const n = t.map((i) => [
413
- b(i),
414
+ m(i),
414
415
  S(i)
415
416
  ]);
416
417
  return k(n), () => {
417
418
  for (const i of t)
418
- N(b(i));
419
+ N(m(i));
419
420
  };
420
- }, [t, b, S, k, N]);
421
- const u = e.useMemo(() => {
422
- if (!y || !w.trim()) return t;
421
+ }, [t, m, S, k, N]);
422
+ const c = e.useMemo(() => {
423
+ if (!w || !y.trim()) return t;
423
424
  const n = [];
424
425
  for (const i of t) {
425
- let g = x?.hasDistinctLabel ? K(S(i), w) : M(b(i), w);
426
+ let h = g?.hasDistinctLabel ? K(S(i), y) : M(m(i), y);
426
427
  if (o)
427
428
  for (const P of o(i))
428
- g = Math.max(g, K(P, w));
429
- g > 0 && n.push({ item: i, score: g });
429
+ h = Math.max(h, K(P, y));
430
+ h > 0 && n.push({ item: i, score: h });
430
431
  }
431
- return n.sort((i, g) => g.score - i.score), n.map((i) => i.item);
432
+ return n.sort((i, h) => h.score - i.score), n.map((i) => i.item);
432
433
  }, [
433
434
  t,
434
- y,
435
435
  w,
436
- b,
436
+ y,
437
+ m,
437
438
  S,
438
439
  o,
439
440
  M,
440
- x?.hasDistinctLabel
441
+ g?.hasDistinctLabel
441
442
  ]), F = te({
442
- count: u.length,
443
+ count: c.length,
443
444
  getScrollElement: () => E.current,
444
445
  estimateSize: () => s,
445
446
  overscan: f
446
- }), O = p >= 0 && p < u.length ? b(u[p]) : null;
447
+ }), O = p >= 0 && p < c.length ? m(c[p]) : null;
447
448
  e.useEffect(() => {
448
449
  I(0);
449
- }, [w, u.length]);
450
+ }, [y, c.length]);
450
451
  const j = e.useRef(!1);
451
452
  e.useEffect(() => {
452
453
  if (j.current || !C) return;
453
- const n = u.findIndex((i) => b(i) === C);
454
+ const n = c.findIndex((i) => m(i) === C);
454
455
  n >= 0 && (I(n), F.scrollToIndex(n, { align: "center" }), j.current = !0);
455
- }, [C, u, b, F]);
456
+ }, [C, c, m, F]);
456
457
  const $ = e.useRef(!1);
457
458
  e.useEffect(() => {
458
- $.current && p >= 0 && p < u.length && F.scrollToIndex(p, { align: "auto" }), $.current = !1;
459
- }, [p, u.length, F]), e.useEffect(() => {
459
+ $.current && p >= 0 && p < c.length && F.scrollToIndex(p, { align: "auto" }), $.current = !1;
460
+ }, [p, c.length, F]), e.useEffect(() => {
460
461
  const n = E.current?.closest(
461
462
  '[data-slot="combobox-command"]'
462
463
  );
463
464
  if (!n) return;
464
- const i = (g) => {
465
- switch (g.key) {
465
+ const i = (h) => {
466
+ switch (h.key) {
466
467
  case "ArrowDown":
467
- g.preventDefault(), g.stopPropagation(), $.current = !0, I(
468
- (P) => P < u.length - 1 ? P + 1 : P
468
+ h.preventDefault(), h.stopPropagation(), $.current = !0, I(
469
+ (P) => P < c.length - 1 ? P + 1 : P
469
470
  );
470
471
  break;
471
472
  case "ArrowUp":
472
- g.preventDefault(), g.stopPropagation(), $.current = !0, I((P) => P > 0 ? P - 1 : P);
473
+ h.preventDefault(), h.stopPropagation(), $.current = !0, I((P) => P > 0 ? P - 1 : P);
473
474
  break;
474
475
  case "Enter":
475
- if (g.preventDefault(), g.stopPropagation(), p >= 0 && p < u.length) {
476
- const P = b(u[p]);
476
+ if (h.preventDefault(), h.stopPropagation(), p >= 0 && p < c.length) {
477
+ const P = m(c[p]);
477
478
  L(P === C ? "" : P), V(!1);
478
479
  }
479
480
  break;
480
481
  case "Home":
481
- g.preventDefault(), g.stopPropagation(), $.current = !0, I(0);
482
+ h.preventDefault(), h.stopPropagation(), $.current = !0, I(0);
482
483
  break;
483
484
  case "End":
484
- g.preventDefault(), g.stopPropagation(), $.current = !0, I(u.length - 1);
485
+ h.preventDefault(), h.stopPropagation(), $.current = !0, I(c.length - 1);
485
486
  break;
486
487
  }
487
488
  };
488
489
  return n.addEventListener("keydown", i, { capture: !0 }), () => n.removeEventListener("keydown", i, { capture: !0 });
489
- }, [u, p, C, L, V, b]);
490
+ }, [c, p, C, L, V, m]);
490
491
  const z = e.useMemo(() => {
491
492
  const n = /* @__PURE__ */ new Map();
492
- return u.forEach((i, g) => {
493
- n.set(b(i), g);
493
+ return c.forEach((i, h) => {
494
+ n.set(m(i), h);
494
495
  }), n;
495
- }, [u, b]), q = e.useCallback(
496
+ }, [c, m]), q = e.useCallback(
496
497
  (n) => {
497
498
  const i = z.get(n);
498
499
  i !== void 0 && I(i);
@@ -501,7 +502,7 @@ function ge({
501
502
  ), U = e.useCallback(
502
503
  (n) => (z.get(n) ?? 0) + 1,
503
504
  [z]
504
- ), G = u.length, W = e.useMemo(
505
+ ), G = c.length, W = e.useMemo(
505
506
  () => ({
506
507
  activeValue: O,
507
508
  onItemPointerMove: q,
@@ -510,19 +511,19 @@ function ge({
510
511
  getItemPosition: U
511
512
  }),
512
513
  [O, q, A, G, U]
513
- ), h = O != null ? `${A}item-${O}` : void 0;
514
- return e.useEffect(() => (R(h), () => R(void 0)), [h, R]), u.length === 0 ? /* @__PURE__ */ d(
514
+ ), x = O != null ? `${A}item-${O}` : void 0;
515
+ return e.useEffect(() => (R(x), () => R(void 0)), [x, R]), c.length === 0 ? /* @__PURE__ */ d(
515
516
  "div",
516
517
  {
517
518
  ref: E,
518
519
  className: T(
519
520
  "scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
520
- m
521
+ b
521
522
  ),
522
523
  "data-hook": v,
523
524
  "data-slot": "combobox-virtual-list",
524
525
  role: "listbox",
525
- children: c
526
+ children: u
526
527
  }
527
528
  ) : /* @__PURE__ */ d(Q.Provider, { value: W, children: /* @__PURE__ */ d(
528
529
  "div",
@@ -530,7 +531,7 @@ function ge({
530
531
  ref: E,
531
532
  className: T(
532
533
  "scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
533
- m
534
+ b
534
535
  ),
535
536
  "data-hook": v,
536
537
  "data-slot": "combobox-virtual-list",
@@ -550,9 +551,9 @@ function ge({
550
551
  transform: `translateY(${n.start}px)`
551
552
  },
552
553
  children: l(
553
- u[n.index],
554
+ c[n.index],
554
555
  n.index,
555
- w
556
+ y
556
557
  )
557
558
  },
558
559
  n.key
@@ -562,9 +563,9 @@ function ge({
562
563
  }
563
564
  ) });
564
565
  }
565
- const $e = e.forwardRef(ge), ve = e.forwardRef((t, r) => /* @__PURE__ */ d(ie, { ref: r, "data-slot": "combobox-empty", ...t }));
566
- ve.displayName = "ComboboxEmpty";
567
- const Ce = e.forwardRef(({ children: t, ...r }, a) => {
566
+ const je = e.forwardRef(ve), Ce = e.forwardRef((t, r) => /* @__PURE__ */ d(ie, { ref: r, "data-slot": "combobox-empty", ...t }));
567
+ Ce.displayName = "ComboboxEmpty";
568
+ const ye = e.forwardRef(({ children: t, ...r }, a) => {
568
569
  const o = e.useRef(null);
569
570
  return H(
570
571
  () => o.current ? o.current.querySelectorAll('[data-slot="combobox-item"]').length >= 100 : !1,
@@ -583,7 +584,7 @@ Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox
583
584
  }
584
585
  );
585
586
  });
586
- Ce.displayName = "ComboboxGroup";
587
+ ye.displayName = "ComboboxGroup";
587
588
  function we(t, r, a) {
588
589
  if (!r || !r.trim())
589
590
  return t;
@@ -595,7 +596,7 @@ function we(t, r, a) {
595
596
  (f, l) => l % 2 === 1 ? /* @__PURE__ */ d("span", { className: a, children: f }, l) : /* @__PURE__ */ d(e.Fragment, { children: f }, l)
596
597
  ) });
597
598
  }
598
- const ye = e.forwardRef(
599
+ const ke = e.forwardRef(
599
600
  ({
600
601
  value: t,
601
602
  label: r,
@@ -604,21 +605,21 @@ const ye = e.forwardRef(
604
605
  className: s,
605
606
  highlight: f,
606
607
  highlightClassName: l,
607
- keywords: c,
608
- onSelect: m,
608
+ keywords: u,
609
+ onSelect: b,
609
610
  ...v
610
611
  }, D) => {
611
- const { value: x, onValueChange: b, setOpen: S, registerItem: E, unregisterItem: C } = _(), L = e.useContext(Q), V = x === t, y = e.useMemo(() => r || (typeof o == "string" ? o : typeof o == "number" ? String(o) : t), [r, o, t]), w = e.useRef(E), M = e.useRef(C);
612
+ const { value: g, onValueChange: m, setOpen: S, registerItem: E, unregisterItem: C } = _(), L = e.useContext(Q), V = g === t, w = e.useMemo(() => r || (typeof o == "string" ? o : typeof o == "number" ? String(o) : t), [r, o, t]), y = e.useRef(E), M = e.useRef(C);
612
613
  e.useEffect(() => {
613
- w.current = E, M.current = C;
614
+ y.current = E, M.current = C;
614
615
  }, [E, C]);
615
616
  const R = !!L;
616
617
  e.useEffect(() => {
617
618
  if (!R)
618
- return w.current(t, y), () => M.current(t);
619
- }, [t, y, R]);
619
+ return y.current(t, w), () => M.current(t);
620
+ }, [t, w, R]);
620
621
  const k = () => {
621
- b(t === x ? "" : t), S(!1), m?.(t);
622
+ m(t === g ? "" : t), S(!1), b?.(t);
622
623
  }, N = () => f && typeof o == "string" ? we(
623
624
  o,
624
625
  f,
@@ -665,13 +666,13 @@ const ye = e.forwardRef(
665
666
  );
666
667
  }
667
668
  return /* @__PURE__ */ B(
668
- ce,
669
+ ue,
669
670
  {
670
671
  ref: D,
671
672
  className: T("justify-between", s),
672
673
  "data-slot": "combobox-item",
673
674
  dataHook: a,
674
- keywords: c ? [y, ...c] : [y],
675
+ keywords: u ? [w, ...u] : [w],
675
676
  value: t,
676
677
  onSelect: k,
677
678
  ...v,
@@ -689,10 +690,10 @@ const ye = e.forwardRef(
689
690
  );
690
691
  }
691
692
  );
692
- ye.displayName = "ComboboxItem";
693
- const ke = e.forwardRef((t, r) => /* @__PURE__ */ d(fe, { ref: r, "data-slot": "combobox-separator", ...t }));
694
- ke.displayName = "ComboboxSeparator";
695
- function Oe({
693
+ ke.displayName = "ComboboxItem";
694
+ const Ie = e.forwardRef((t, r) => /* @__PURE__ */ d(fe, { ref: r, "data-slot": "combobox-separator", ...t }));
695
+ Ie.displayName = "ComboboxSeparator";
696
+ function ze({
696
697
  className: t,
697
698
  children: r,
698
699
  loadingText: a
@@ -702,35 +703,34 @@ function Oe({
702
703
  {
703
704
  "aria-live": "polite",
704
705
  className: T(
705
- "text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",
706
+ // The entrance fade doubles as a ~150ms appearance delay (`both`
707
+ // holds the hidden start): a fetch that resolves faster than the
708
+ // delay never flashes a spinner, which would read slower than no
709
+ // indicator at all.
710
+ "text-muted-foreground relative flex items-center justify-center gap-2 py-6 text-sm",
711
+ "animate-entrance-fade entrance-delay-1",
706
712
  t
707
713
  ),
708
714
  "data-slot": "combobox-loading",
709
715
  role: "status",
710
716
  children: r || /* @__PURE__ */ B(Z, { children: [
711
- /* @__PURE__ */ d(
712
- "div",
713
- {
714
- "aria-hidden": "true",
715
- className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent [animation-duration:0.6s]"
716
- }
717
- ),
718
- a ?? "Loading..."
717
+ /* @__PURE__ */ d(me, { size: "md" }),
718
+ /* @__PURE__ */ d("span", { className: "sr-only", children: a ?? "Loading suggestions" })
719
719
  ] })
720
720
  }
721
721
  );
722
722
  }
723
723
  export {
724
- Fe as Combobox,
725
- Te as ComboboxContent,
726
- ve as ComboboxEmpty,
727
- Ce as ComboboxGroup,
724
+ Te as Combobox,
725
+ Oe as ComboboxContent,
726
+ Ce as ComboboxEmpty,
727
+ ye as ComboboxGroup,
728
728
  xe as ComboboxInput,
729
- ye as ComboboxItem,
729
+ ke as ComboboxItem,
730
730
  he as ComboboxList,
731
- Oe as ComboboxLoading,
732
- ke as ComboboxSeparator,
733
- me as ComboboxTrigger,
734
- Ae as ComboboxValue,
735
- $e as ComboboxVirtualList
731
+ ze as ComboboxLoading,
732
+ Ie as ComboboxSeparator,
733
+ pe as ComboboxTrigger,
734
+ $e as ComboboxValue,
735
+ je as ComboboxVirtualList
736
736
  };