@brightlocal/ui-components 2.9.2 → 2.11.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 (67) hide show
  1. package/README.md +3 -1
  2. package/component-meta.json +41 -9
  3. package/dist/badge.cjs +1 -1
  4. package/dist/badge.d.ts.map +1 -1
  5. package/dist/badge.js +42 -25
  6. package/dist/blocks/sidebar.cjs +1 -1
  7. package/dist/blocks/sidebar.d.ts +1 -3
  8. package/dist/blocks/sidebar.d.ts.map +1 -1
  9. package/dist/blocks/sidebar.js +46 -49
  10. package/dist/browser-entry.d.ts +17 -0
  11. package/dist/browser-entry.d.ts.map +1 -0
  12. package/dist/button.cjs +1 -1
  13. package/dist/button.js +25 -25
  14. package/dist/card.cjs +1 -1
  15. package/dist/card.d.ts +10 -1
  16. package/dist/card.d.ts.map +1 -1
  17. package/dist/card.js +85 -82
  18. package/dist/carousel.cjs +1 -1
  19. package/dist/carousel.d.ts +13 -1
  20. package/dist/carousel.d.ts.map +1 -1
  21. package/dist/carousel.js +196 -150
  22. package/dist/combobox.cjs +3 -3
  23. package/dist/combobox.d.ts +3 -3
  24. package/dist/combobox.d.ts.map +1 -1
  25. package/dist/combobox.js +480 -440
  26. package/dist/command.cjs +1 -1
  27. package/dist/command.d.ts +101 -1
  28. package/dist/command.d.ts.map +1 -1
  29. package/dist/command.js +383 -119
  30. package/dist/hooks/use-breakpoint.cjs +1 -1
  31. package/dist/hooks/use-breakpoint.d.ts.map +1 -1
  32. package/dist/hooks/use-breakpoint.js +10 -10
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +402 -391
  37. package/dist/input-chip.cjs +1 -1
  38. package/dist/input-chip.d.ts +1 -4
  39. package/dist/input-chip.d.ts.map +1 -1
  40. package/dist/input-chip.js +163 -170
  41. package/dist/map.cjs +1 -0
  42. package/dist/map.d.ts +192 -0
  43. package/dist/map.d.ts.map +1 -0
  44. package/dist/map.js +250 -0
  45. package/dist/sonner.cjs +1 -1
  46. package/dist/sonner.d.ts.map +1 -1
  47. package/dist/sonner.js +32 -30
  48. package/dist/tabs.cjs +1 -1
  49. package/dist/tabs.d.ts +4 -0
  50. package/dist/tabs.d.ts.map +1 -1
  51. package/dist/tabs.js +101 -52
  52. package/package.json +4 -1
  53. package/src/blocks/sidebar.tsx +21 -26
  54. package/src/browser-entry.ts +89 -0
  55. package/src/browser-tokens.css +1 -0
  56. package/src/components/badge.tsx +22 -5
  57. package/src/components/button.tsx +13 -13
  58. package/src/components/card.tsx +35 -19
  59. package/src/components/carousel.tsx +101 -9
  60. package/src/components/combobox.tsx +106 -28
  61. package/src/components/command.tsx +637 -16
  62. package/src/components/input-chip.tsx +102 -65
  63. package/src/components/map.tsx +574 -0
  64. package/src/components/sonner.tsx +9 -3
  65. package/src/components/tabs.tsx +118 -22
  66. package/src/hooks/use-breakpoint.ts +2 -3
  67. package/src/index.ts +1 -0
@@ -8,21 +8,25 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
8
8
  */
9
9
  type CardVariant = "filled" | "transparent" | "border" | "transparent-flush";
10
10
 
11
+ /**
12
+ * Card density type
13
+ */
14
+ type CardDensity = "default" | "condensed";
15
+
11
16
  /**
12
17
  * Context to pass variant information to sub-components
13
18
  */
14
- const CardContext = React.createContext<{ flush: boolean }>({ flush: false });
19
+ const CardContext = React.createContext<{
20
+ flush: boolean;
21
+ density: CardDensity;
22
+ }>({ flush: false, density: "default" });
23
+
24
+ function subPadding(flush: boolean, density: CardDensity): string | false {
25
+ return !flush && (density === "condensed" ? "px-3" : "px-section-md");
26
+ }
15
27
 
16
28
  const cardVariants = cva(
17
- [
18
- "flex",
19
- "flex-col",
20
- "gap-8",
21
- "rounded-xl",
22
- "py-section-md",
23
- "transition-colors",
24
- "w-full",
25
- ],
29
+ ["flex", "flex-col", "rounded-xl", "transition-colors", "w-full"],
26
30
  {
27
31
  variants: {
28
32
  variant: {
@@ -41,9 +45,14 @@ const cardVariants = cva(
41
45
  ],
42
46
  "transparent-flush": ["bg-transparent", "text-foreground"],
43
47
  },
48
+ density: {
49
+ default: ["gap-8", "py-section-md"],
50
+ condensed: ["gap-3", "py-3"],
51
+ },
44
52
  },
45
53
  defaultVariants: {
46
54
  variant: "filled",
55
+ density: "default",
47
56
  },
48
57
  }
49
58
  );
@@ -57,6 +66,11 @@ type CardProps = React.ComponentProps<"div"> & {
57
66
  * @default "filled"
58
67
  */
59
68
  variant?: CardVariant;
69
+ /**
70
+ * Spacing density of the card
71
+ * @default "default"
72
+ */
73
+ density?: CardDensity;
60
74
  /**
61
75
  * Data hook for automated testing (required)
62
76
  */
@@ -85,6 +99,7 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
85
99
  {
86
100
  className,
87
101
  variant = "filled",
102
+ density = "default",
88
103
  dataHook,
89
104
  trackingEl,
90
105
  trackingLabel,
@@ -105,10 +120,11 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
105
120
  : undefined;
106
121
 
107
122
  return (
108
- <CardContext.Provider value={{ flush }}>
123
+ <CardContext.Provider value={{ flush, density }}>
109
124
  <div
110
125
  ref={ref}
111
- className={cn(cardVariants({ variant }), className)}
126
+ className={cn(cardVariants({ variant, density }), className)}
127
+ data-density={density}
112
128
  data-hook={dataHook}
113
129
  data-slot="card"
114
130
  data-tracking-el={trackingEl || `card-${variant}`}
@@ -144,13 +160,13 @@ type CardSubComponentProps = React.ComponentProps<"div"> & {
144
160
  */
145
161
  const CardHeader = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
146
162
  ({ className, ...props }, ref) => {
147
- const { flush } = React.useContext(CardContext);
163
+ const { flush, density } = React.useContext(CardContext);
148
164
  return (
149
165
  <div
150
166
  ref={ref}
151
167
  className={cn(
152
168
  "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 has-data-[slot=card-action]:grid-cols-[1fr_auto]",
153
- !flush && "px-section-md",
169
+ subPadding(flush, density),
154
170
  className
155
171
  )}
156
172
  data-slot="card-header"
@@ -217,11 +233,11 @@ CardAction.displayName = "CardAction";
217
233
  */
218
234
  const CardContent = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
219
235
  ({ className, ...props }, ref) => {
220
- const { flush } = React.useContext(CardContext);
236
+ const { flush, density } = React.useContext(CardContext);
221
237
  return (
222
238
  <div
223
239
  ref={ref}
224
- className={cn(!flush && "px-section-md", className)}
240
+ className={cn(subPadding(flush, density), className)}
225
241
  data-slot="card-content"
226
242
  {...props}
227
243
  />
@@ -235,13 +251,13 @@ CardContent.displayName = "CardContent";
235
251
  */
236
252
  const CardFooter = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
237
253
  ({ className, ...props }, ref) => {
238
- const { flush } = React.useContext(CardContext);
254
+ const { flush, density } = React.useContext(CardContext);
239
255
  return (
240
256
  <div
241
257
  ref={ref}
242
258
  className={cn(
243
259
  "flex items-center",
244
- !flush && "px-section-md",
260
+ subPadding(flush, density),
245
261
  className
246
262
  )}
247
263
  data-slot="card-footer"
@@ -262,4 +278,4 @@ export {
262
278
  CardContent,
263
279
  };
264
280
 
265
- export type { CardProps, CardSubComponentProps, CardVariant };
281
+ export type { CardProps, CardSubComponentProps, CardVariant, CardDensity };
@@ -47,6 +47,18 @@ interface CarouselProps extends React.ComponentProps<"div"> {
47
47
  * Callback to receive the carousel API instance
48
48
  */
49
49
  setApi?: (api: CarouselApi) => void;
50
+ /**
51
+ * Enable lazy loading to only mount slides near the viewport.
52
+ * Off-screen slide children are not rendered until they scroll into view.
53
+ * @default false
54
+ */
55
+ lazyLoad?: boolean;
56
+ /**
57
+ * Number of off-screen slides to pre-render on each side of the viewport.
58
+ * Only applies when `lazyLoad` is enabled.
59
+ * @default 1
60
+ */
61
+ overscan?: number;
50
62
  }
51
63
 
52
64
  type CarouselContextProps = {
@@ -60,6 +72,8 @@ type CarouselContextProps = {
60
72
  plugins?: CarouselPlugin;
61
73
  orientation?: "horizontal" | "vertical";
62
74
  setApi?: (api: CarouselApi) => void;
75
+ lazyLoad: boolean;
76
+ loadedSlides: Set<number>;
63
77
  };
64
78
 
65
79
  const CarouselContext = React.createContext<CarouselContextProps | null>(null);
@@ -90,6 +104,8 @@ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
90
104
  dataHook,
91
105
  trackingEl,
92
106
  trackingLabel,
107
+ lazyLoad = false,
108
+ overscan = 1,
93
109
  ...props
94
110
  },
95
111
  ref
@@ -103,6 +119,20 @@ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
103
119
  );
104
120
  const [canScrollPrev, setCanScrollPrev] = React.useState(false);
105
121
  const [canScrollNext, setCanScrollNext] = React.useState(false);
122
+ const safeOverscan = Math.max(0, Math.floor(overscan));
123
+ const [loadedSlides, setLoadedSlides] = React.useState<Set<number>>(() => {
124
+ if (!lazyLoad) return new Set<number>();
125
+ const startIndex = opts?.startIndex ?? 0;
126
+ const initial = new Set<number>();
127
+ for (
128
+ let i = Math.max(0, startIndex - safeOverscan);
129
+ i <= startIndex + safeOverscan;
130
+ i++
131
+ ) {
132
+ initial.add(i);
133
+ }
134
+ return initial;
135
+ });
106
136
 
107
137
  const onSelect = React.useCallback((api: CarouselApi) => {
108
138
  if (!api) return;
@@ -152,6 +182,40 @@ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
152
182
  };
153
183
  }, [api, onSelect]);
154
184
 
185
+ const updateLoadedSlides = React.useCallback(
186
+ (emblaApi: CarouselApi) => {
187
+ if (!emblaApi || !lazyLoad) return;
188
+ const inView = emblaApi.slidesInView();
189
+ const slideCount = emblaApi.slideNodes().length;
190
+ setLoadedSlides((prev) => {
191
+ const next = new Set(prev);
192
+ for (const index of inView) {
193
+ const lo = Math.max(0, index - safeOverscan);
194
+ const hi = Math.min(slideCount - 1, index + safeOverscan);
195
+ for (let i = lo; i <= hi; i++) {
196
+ next.add(i);
197
+ }
198
+ }
199
+ if (next.size === prev.size) return prev;
200
+ return next;
201
+ });
202
+ },
203
+ [lazyLoad, safeOverscan]
204
+ );
205
+
206
+ React.useEffect(() => {
207
+ if (!api || !lazyLoad) return;
208
+ updateLoadedSlides(api);
209
+ api.on("slidesInView", updateLoadedSlides);
210
+ api.on("select", updateLoadedSlides);
211
+ api.on("reInit", updateLoadedSlides);
212
+ return () => {
213
+ api.off("slidesInView", updateLoadedSlides);
214
+ api.off("select", updateLoadedSlides);
215
+ api.off("reInit", updateLoadedSlides);
216
+ };
217
+ }, [api, lazyLoad, updateLoadedSlides]);
218
+
155
219
  return (
156
220
  <CarouselContext.Provider
157
221
  value={{
@@ -164,6 +228,8 @@ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
164
228
  scrollNext,
165
229
  canScrollPrev,
166
230
  canScrollNext,
231
+ lazyLoad,
232
+ loadedSlides,
167
233
  }}
168
234
  >
169
235
  <div
@@ -193,17 +259,30 @@ Carousel.displayName = "Carousel";
193
259
  const CarouselContent = React.forwardRef<
194
260
  HTMLDivElement,
195
261
  React.ComponentProps<"div">
196
- >(({ className, ...props }, ref) => {
197
- const { carouselRef, orientation } = useCarousel();
262
+ >(({ className, children, ...props }, ref) => {
263
+ const { carouselRef, orientation, lazyLoad } = useCarousel();
198
264
  const isVertical = orientation === "vertical";
199
265
 
266
+ let slideIndex = 0;
267
+ const processedChildren = lazyLoad
268
+ ? React.Children.map(children, (child) => {
269
+ if (React.isValidElement(child) && child.type === CarouselItem) {
270
+ const idx = slideIndex++;
271
+ return React.cloneElement(
272
+ child as React.ReactElement<{ _lazyIndex?: number }>,
273
+ { _lazyIndex: idx }
274
+ );
275
+ }
276
+ return child;
277
+ })
278
+ : children;
279
+
200
280
  return (
201
281
  <div
202
282
  ref={carouselRef}
203
283
  className={cn("overflow-hidden", isVertical && "w-full", className)}
204
284
  data-slot="carousel-content"
205
285
  >
206
- {/* Negative margins offset the positive padding on CarouselItem children (pt-4/pl-4) to create consistent gaps */}
207
286
  <div
208
287
  ref={ref}
209
288
  className={cn(
@@ -211,21 +290,29 @@ const CarouselContent = React.forwardRef<
211
290
  isVertical ? "-mt-4 h-full w-full flex-col" : "-ml-4"
212
291
  )}
213
292
  {...props}
214
- />
293
+ >
294
+ {processedChildren}
295
+ </div>
215
296
  </div>
216
297
  );
217
298
  });
218
299
 
219
300
  CarouselContent.displayName = "CarouselContent";
220
301
 
302
+ type CarouselItemInternalProps = React.ComponentProps<"div"> & {
303
+ _lazyIndex?: number;
304
+ };
305
+
221
306
  /**
222
307
  * Individual slide item within the carousel.
223
308
  */
224
309
  const CarouselItem = React.forwardRef<
225
310
  HTMLDivElement,
226
- React.ComponentProps<"div">
227
- >(({ className, ...props }, ref) => {
228
- const { orientation } = useCarousel();
311
+ CarouselItemInternalProps
312
+ >(({ className, children, _lazyIndex, ...props }, ref) => {
313
+ const { orientation, lazyLoad, loadedSlides } = useCarousel();
314
+ const isLoaded =
315
+ !lazyLoad || _lazyIndex === undefined || loadedSlides.has(_lazyIndex);
229
316
 
230
317
  return (
231
318
  <div
@@ -236,12 +323,17 @@ const CarouselItem = React.forwardRef<
236
323
  orientation === "horizontal" ? "pl-4" : "w-full pt-4",
237
324
  className
238
325
  )}
326
+ data-lazy-loaded={lazyLoad ? String(isLoaded) : undefined}
239
327
  data-slot="carousel-item"
240
328
  role="group"
241
329
  {...props}
242
- />
330
+ >
331
+ {isLoaded ? children : null}
332
+ </div>
243
333
  );
244
- });
334
+ }) as React.ForwardRefExoticComponent<
335
+ React.ComponentPropsWithoutRef<"div"> & React.RefAttributes<HTMLDivElement>
336
+ >;
245
337
 
246
338
  CarouselItem.displayName = "CarouselItem";
247
339
 
@@ -436,6 +436,57 @@ const ComboboxTrigger = React.forwardRef<
436
436
  );
437
437
  ComboboxTrigger.displayName = "ComboboxTrigger";
438
438
 
439
+ /* -------------------------------------------------------------------------------------------------
440
+ * Accessor inference
441
+ * -----------------------------------------------------------------------------------------------*/
442
+
443
+ type ValueLabelItem = { value: string; label?: string };
444
+
445
+ function hasValueKey(item: unknown): item is ValueLabelItem {
446
+ return (
447
+ item != null &&
448
+ typeof item === "object" &&
449
+ "value" in item &&
450
+ typeof (item as ValueLabelItem).value === "string"
451
+ );
452
+ }
453
+
454
+ function resolveAccessors<T>(
455
+ items: readonly T[],
456
+ getItemValue: ((item: T) => string) | undefined,
457
+ getItemLabel: ((item: T) => string) | undefined
458
+ ): {
459
+ getValue: (item: T) => string;
460
+ getLabel: (item: T) => string;
461
+ hasDistinctLabel: boolean;
462
+ } | null {
463
+ if (getItemValue) {
464
+ return {
465
+ getValue: getItemValue,
466
+ getLabel: getItemLabel ?? getItemValue,
467
+ hasDistinctLabel: !!getItemLabel,
468
+ };
469
+ }
470
+
471
+ const sample = items[0];
472
+ if (!hasValueKey(sample)) return null;
473
+
474
+ const getValue = (item: T) => (item as unknown as ValueLabelItem).value;
475
+
476
+ const hasLabel =
477
+ "label" in sample &&
478
+ typeof (sample as { label?: unknown }).label === "string";
479
+ const getLabel = hasLabel
480
+ ? (item: T) => String((item as unknown as { label: string }).label)
481
+ : getValue;
482
+
483
+ return {
484
+ getValue,
485
+ getLabel: getItemLabel ?? getLabel,
486
+ hasDistinctLabel: hasLabel || !!getItemLabel,
487
+ };
488
+ }
489
+
439
490
  /* -------------------------------------------------------------------------------------------------
440
491
  * Combobox Value
441
492
  * -----------------------------------------------------------------------------------------------*/
@@ -476,7 +527,7 @@ export interface ComboboxValueProps<T = unknown> {
476
527
  * ```
477
528
  */
478
529
  items?: readonly T[];
479
- /** Extract the value string from an item. Required when `items` is provided. */
530
+ /** Extract the value string from an item. Auto-inferred for items with a `value` string property. */
480
531
  getItemValue?: (item: T) => string;
481
532
  /** Extract the display label from an item. Falls back to `getItemValue` when not provided. */
482
533
  getItemLabel?: (item: T) => string;
@@ -492,20 +543,24 @@ function ComboboxValue<T>({
492
543
  }: ComboboxValueProps<T>) {
493
544
  const { value, itemLabels } = useComboboxContext();
494
545
 
546
+ const accessors = React.useMemo(
547
+ () => (items ? resolveAccessors(items, getItemValue, getItemLabel) : null),
548
+ [items, getItemValue, getItemLabel]
549
+ );
550
+
495
551
  useDevWarning(
496
- () => !!items && !getItemValue,
497
- "ComboboxValue: `items` was provided without `getItemValue`. " +
498
- "Pass `getItemValue` (and optionally `getItemLabel`) to enable item-based label resolution.",
499
- [items, getItemValue]
552
+ () => !!items && items.length > 0 && !accessors,
553
+ "ComboboxValue: could not infer `getItemValue` from item shape. " +
554
+ "Pass `getItemValue` explicitly, or use items with a `value` string property.",
555
+ [items, accessors]
500
556
  );
501
557
 
502
558
  const itemsMap = React.useMemo(() => {
503
- if (!items || !getItemValue) return null;
504
- const resolveLabel = getItemLabel ?? getItemValue;
559
+ if (!items || !accessors) return null;
505
560
  return new Map(
506
- items.map((item) => [getItemValue(item), resolveLabel(item)])
561
+ items.map((item) => [accessors.getValue(item), accessors.getLabel(item)])
507
562
  );
508
- }, [items, getItemValue, getItemLabel]);
563
+ }, [items, accessors]);
509
564
 
510
565
  const displayText = value
511
566
  ? itemsMap?.get(value) ||
@@ -801,7 +856,7 @@ const ComboboxList = React.forwardRef<
801
856
  return (
802
857
  <CommandList
803
858
  ref={ref}
804
- className={cn("min-h-0 flex-1", className)}
859
+ className={cn("scrollbar min-h-0 flex-1", className)}
805
860
  data-slot="combobox-list"
806
861
  {...props}
807
862
  />
@@ -816,8 +871,8 @@ ComboboxList.displayName = "ComboboxList";
816
871
  export interface ComboboxVirtualListProps<T> {
817
872
  /** Array of items to virtualise. Memoize with useMemo to avoid re-registering labels on every render. */
818
873
  items: readonly T[];
819
- /** Extract the string value for each item (used for selection and keyboard navigation) */
820
- getItemValue: (item: T) => string;
874
+ /** Extract the string value for each item (used for selection and keyboard navigation). Auto-inferred for items with a `value` string property. */
875
+ getItemValue?: (item: T) => string;
821
876
  /**
822
877
  * Extract a display label for filtering and trigger display. Defaults to `getItemValue`.
823
878
  * Only used when `shouldFilter` is true on the parent Combobox.
@@ -859,8 +914,8 @@ export interface ComboboxVirtualListProps<T> {
859
914
  function ComboboxVirtualListInner<T>(
860
915
  {
861
916
  items,
862
- getItemValue,
863
- getItemLabel,
917
+ getItemValue: getItemValueProp,
918
+ getItemLabel: getItemLabelProp,
864
919
  getItemKeywords,
865
920
  estimateSize = 36,
866
921
  overscan = 5,
@@ -871,6 +926,35 @@ function ComboboxVirtualListInner<T>(
871
926
  }: ComboboxVirtualListProps<T>,
872
927
  ref: React.ForwardedRef<HTMLDivElement>
873
928
  ) {
929
+ const accessors = React.useMemo(
930
+ () => resolveAccessors(items, getItemValueProp, getItemLabelProp),
931
+ [items, getItemValueProp, getItemLabelProp]
932
+ );
933
+
934
+ const getItemValue = React.useMemo(
935
+ () =>
936
+ accessors?.getValue ??
937
+ ((item: T) => {
938
+ if (typeof item === "string" || typeof item === "number")
939
+ return String(item);
940
+ throw new Error(
941
+ "[BrightLocal DS] ComboboxVirtualList: `getItemValue` is required for non-primitive items without a `value` property."
942
+ );
943
+ }),
944
+ [accessors]
945
+ );
946
+ const getItemLabel = React.useMemo(
947
+ () => accessors?.getLabel ?? getItemValue,
948
+ [accessors, getItemValue]
949
+ );
950
+
951
+ useDevWarning(
952
+ () => !accessors && items.length > 0,
953
+ "ComboboxVirtualList: could not infer `getItemValue` from item shape. " +
954
+ "Pass `getItemValue` explicitly, or use items with a `value` string property.",
955
+ [accessors, items.length]
956
+ );
957
+
874
958
  const parentRef = React.useRef<HTMLDivElement>(null);
875
959
  const {
876
960
  value,
@@ -889,18 +973,10 @@ function ComboboxVirtualListInner<T>(
889
973
  // Merge forwarded ref with internal ref
890
974
  React.useImperativeHandle(ref, () => parentRef.current!, []);
891
975
 
892
- // Bulk-register all item labels upfront so ComboboxValue can always resolve
893
- // the display label — even for items outside the virtualised viewport.
894
- // Uses useLayoutEffect + synchronous flush so labels are available before
895
- // the browser paints (no flash of raw values when a value is pre-selected).
896
- // Cleanup unregisters stale labels when `items` changes (e.g. server-driven
897
- // filtering/pagination). The selected value's label survives because
898
- // unregisterItem has a guard that preserves the currently selected value.
899
976
  React.useLayoutEffect(() => {
900
- const resolveLabel = getItemLabel ?? getItemValue;
901
977
  const entries: [string, string][] = items.map((item) => [
902
978
  getItemValue(item),
903
- resolveLabel(item),
979
+ getItemLabel(item),
904
980
  ]);
905
981
  registerItemsSync(entries);
906
982
  return () => {
@@ -918,9 +994,10 @@ function ComboboxVirtualListInner<T>(
918
994
 
919
995
  const scored: { item: T; score: number }[] = [];
920
996
  for (const item of items) {
921
- // getItemLabel is a virtual-list-specific override; otherwise delegate
922
- // to the shared filterFn which already respects itemToStringValue.
923
- let score = getItemLabel
997
+ // When a distinct label accessor exists (explicit getItemLabel or
998
+ // inferred `label` key), filter by label text. Otherwise delegate to
999
+ // the shared filterFn which respects itemToStringValue.
1000
+ let score = accessors?.hasDistinctLabel
924
1001
  ? defaultFilter(getItemLabel(item), searchValue)
925
1002
  : filterFn(getItemValue(item), searchValue);
926
1003
 
@@ -946,6 +1023,7 @@ function ComboboxVirtualListInner<T>(
946
1023
  getItemLabel,
947
1024
  getItemKeywords,
948
1025
  filterFn,
1026
+ accessors?.hasDistinctLabel,
949
1027
  ]);
950
1028
 
951
1029
  // eslint-disable-next-line react-hooks/incompatible-library -- compiler already skips this component; virtualizer is not passed to memoized consumers
@@ -1104,7 +1182,7 @@ function ComboboxVirtualListInner<T>(
1104
1182
  <div
1105
1183
  ref={parentRef}
1106
1184
  className={cn(
1107
- "max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
1185
+ "scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
1108
1186
  className
1109
1187
  )}
1110
1188
  data-hook={dataHook}
@@ -1121,7 +1199,7 @@ function ComboboxVirtualListInner<T>(
1121
1199
  <div
1122
1200
  ref={parentRef}
1123
1201
  className={cn(
1124
- "max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
1202
+ "scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
1125
1203
  className
1126
1204
  )}
1127
1205
  data-hook={dataHook}