@aircall/ds 0.37.1 → 0.38.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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as Button, D as _objectWithoutProperties, E as _objectSpread2, O as cn, S as registerI18nNamespace, T as linkStyle, _ as ActionBarHeight, a as TableFooter, b as detectInitialLanguage, c as TableRow, d as Checkbox, f as Spinner, g as ActionBarContext, h as ActionBarButton, i as TableCell, l as useFetchMoreSentinel, m as ActionBar, n as Table, o as TableHead, p as spinnerVariants, r as TableBody, s as TableHeader, t as DataTable, u as Skeleton, v as useDsTranslation, w as buttonVariants, x as dsI18n, y as SUPPORTED_LANGUAGES } from "./data-table-DZ2FDkmw.js";
1
+ import { C as Button, D as _objectWithoutProperties, E as _objectSpread2, O as cn, S as registerI18nNamespace, T as linkStyle, _ as ActionBarHeight, a as TableFooter, b as detectInitialLanguage, c as TableRow, d as Checkbox, f as Spinner, g as ActionBarContext, h as ActionBarButton, i as TableCell, l as useFetchMoreSentinel, m as ActionBar, n as Table, o as TableHead, p as spinnerVariants, r as TableBody, s as TableHeader, t as DataTable, u as Skeleton, v as useDsTranslation, w as buttonVariants, x as dsI18n, y as SUPPORTED_LANGUAGES } from "./data-table-fPncHG6B.js";
2
2
  import * as React from "react";
3
3
  import { createContext, useContext, useSyncExternalStore } from "react";
4
4
  import { Accordion as Accordion$1 } from "@base-ui/react/accordion";
@@ -18,10 +18,10 @@ import useEmblaCarousel from "embla-carousel-react";
18
18
  import { Checkbox as Checkbox$1 } from "@base-ui/react/checkbox";
19
19
  import { Collapsible as Collapsible$1 } from "@base-ui/react/collapsible";
20
20
  import { Combobox as Combobox$1 } from "@base-ui/react";
21
- import { useVirtualizer } from "@tanstack/react-virtual";
22
- import { useControllableState } from "@aircall/hooks";
23
21
  import { Command as Command$1 } from "cmdk";
24
22
  import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
23
+ import { useVirtualizer } from "@tanstack/react-virtual";
24
+ import { useControllableState } from "@aircall/hooks";
25
25
  import { checkboxesFeature, hotkeysCoreFeature, selectionFeature, syncDataLoaderFeature } from "@headless-tree/core";
26
26
  import { useTree } from "@headless-tree/react";
27
27
  import { endOfDay, format, getDaysInMonth, startOfDay } from "date-fns";
@@ -1762,11 +1762,11 @@ const BadgeGroupCount = React.forwardRef((componentProps, forwardRef) => {
1762
1762
  BadgeGroupCount.displayName = "BadgeGroupCount";
1763
1763
  /** Design-approved mapping from a legacy stored tag hex (lowercased) to a DS `color` + `tone`. */
1764
1764
  const LEGACY_TAG_COLOR_MAP = {
1765
- "#003d4b": {
1765
+ "#003d4c": {
1766
1766
  color: "charcoal",
1767
1767
  tone: "dark"
1768
1768
  },
1769
- "#bb2001": {
1769
+ "#bb2100": {
1770
1770
  color: "red",
1771
1771
  tone: "dark"
1772
1772
  },
@@ -1774,7 +1774,7 @@ const LEGACY_TAG_COLOR_MAP = {
1774
1774
  color: "red",
1775
1775
  tone: "medium-dark"
1776
1776
  },
1777
- "#0761b5": {
1777
+ "#0662b5": {
1778
1778
  color: "blue",
1779
1779
  tone: "dark"
1780
1780
  },
@@ -1782,6 +1782,10 @@ const LEGACY_TAG_COLOR_MAP = {
1782
1782
  color: "green",
1783
1783
  tone: "medium-dark"
1784
1784
  },
1785
+ "#29c8ff": {
1786
+ color: "blue",
1787
+ tone: "medium-dark"
1788
+ },
1785
1789
  "#b285d1": {
1786
1790
  color: "purple",
1787
1791
  tone: "medium-light"
@@ -1790,31 +1794,47 @@ const LEGACY_TAG_COLOR_MAP = {
1790
1794
  color: "yellow",
1791
1795
  tone: "medium-light"
1792
1796
  },
1793
- "#fe9d88": {
1797
+ "#ff9d88": {
1794
1798
  color: "red",
1795
1799
  tone: "light"
1796
1800
  },
1797
- "#ff844c": {
1801
+ "#ff854c": {
1798
1802
  color: "red",
1799
1803
  tone: "medium-light"
1800
1804
  },
1801
- "#abccf2": {
1805
+ "#acccf3": {
1802
1806
  color: "blue",
1803
1807
  tone: "light"
1804
1808
  },
1805
- "#49a0ff": {
1809
+ "#48a0ff": {
1806
1810
  color: "blue",
1807
1811
  tone: "medium-light"
1808
1812
  },
1809
- "#66d188": {
1813
+ "#65d289": {
1810
1814
  color: "green",
1811
1815
  tone: "medium-light"
1812
- },
1813
- "#2ac8ff": {
1814
- color: "blue",
1815
- tone: "medium-dark"
1816
1816
  }
1817
1817
  };
1818
+ /**
1819
+ * Near-miss hexes that earlier DS versions carried instead of the palette
1820
+ * values above, each off by 1-2 RGB units (`#0761b5` for `#0662b5`, and so
1821
+ * on). No picker ever wrote them, but DS docs, stories and the dashboard
1822
+ * migration skill advertised them, so a consumer may have hardcoded one.
1823
+ * Aliased to the value they were meant to be, so those call sites keep their
1824
+ * color instead of dropping to the fallback. Removable once no consumer
1825
+ * passes them.
1826
+ */
1827
+ const LEGACY_TAG_COLOR_ALIASES = {
1828
+ "#003d4b": "#003d4c",
1829
+ "#bb2001": "#bb2100",
1830
+ "#0761b5": "#0662b5",
1831
+ "#2ac8ff": "#29c8ff",
1832
+ "#fe9d88": "#ff9d88",
1833
+ "#ff844c": "#ff854c",
1834
+ "#abccf2": "#acccf3",
1835
+ "#49a0ff": "#48a0ff",
1836
+ "#66d188": "#65d289"
1837
+ };
1818
1838
  /** Charcoal/dark — used when a stored hex is outside the known legacy palette. */
1819
1839
  const FALLBACK_TAG_COLOR = {
1820
1840
  color: "charcoal",
@@ -1822,8 +1842,10 @@ const FALLBACK_TAG_COLOR = {
1822
1842
  };
1823
1843
  /** Resolve a legacy hard-coded tag hex to `color` + `tone`; unknown → charcoal/dark. */
1824
1844
  function resolveTagColor(hex) {
1825
- var _LEGACY_TAG_COLOR_MAP;
1826
- return (_LEGACY_TAG_COLOR_MAP = LEGACY_TAG_COLOR_MAP[hex.trim().toLowerCase()]) !== null && _LEGACY_TAG_COLOR_MAP !== void 0 ? _LEGACY_TAG_COLOR_MAP : FALLBACK_TAG_COLOR;
1845
+ var _LEGACY_TAG_COLOR_ALI, _LEGACY_TAG_COLOR_MAP;
1846
+ const key = hex.trim().toLowerCase();
1847
+ const canonical = (_LEGACY_TAG_COLOR_ALI = LEGACY_TAG_COLOR_ALIASES[key]) !== null && _LEGACY_TAG_COLOR_ALI !== void 0 ? _LEGACY_TAG_COLOR_ALI : key;
1848
+ return (_LEGACY_TAG_COLOR_MAP = LEGACY_TAG_COLOR_MAP[canonical]) !== null && _LEGACY_TAG_COLOR_MAP !== void 0 ? _LEGACY_TAG_COLOR_MAP : FALLBACK_TAG_COLOR;
1827
1849
  }
1828
1850
  //#endregion
1829
1851
  //#region src/components/banner.tsx
@@ -3205,8 +3227,12 @@ const InputGroupTextarea = React.forwardRef((componentProps, forwardRef) => {
3205
3227
  InputGroupTextarea.displayName = "InputGroupTextarea";
3206
3228
  //#endregion
3207
3229
  //#region src/components/combobox.tsx
3208
- const _excluded$42 = ["className", "children"];
3209
- const _excluded2$29 = ["className"];
3230
+ const _excluded$42 = [
3231
+ "className",
3232
+ "children",
3233
+ "aria-label"
3234
+ ];
3235
+ const _excluded2$29 = ["className", "aria-label"];
3210
3236
  const _excluded3$22 = [
3211
3237
  "className",
3212
3238
  "children",
@@ -3228,7 +3254,11 @@ const _excluded7$6 = ["className"];
3228
3254
  const _excluded8$6 = ["className"];
3229
3255
  const _excluded9$5 = ["className"];
3230
3256
  const _excluded10$5 = ["className"];
3231
- const _excluded11$3 = ["className"];
3257
+ const _excluded11$3 = [
3258
+ "className",
3259
+ "children",
3260
+ "showTrigger"
3261
+ ];
3232
3262
  const _excluded12$3 = [
3233
3263
  "className",
3234
3264
  "children",
@@ -3268,9 +3298,12 @@ function ComboboxValue(componentProps) {
3268
3298
  * trailing chevron icon.
3269
3299
  */
3270
3300
  const ComboboxTrigger = React.forwardRef((componentProps, forwardRef) => {
3271
- const { className, children } = componentProps, props = _objectWithoutProperties(componentProps, _excluded$42);
3301
+ const { className, children, "aria-label": ariaLabel } = componentProps, props = _objectWithoutProperties(componentProps, _excluded$42);
3302
+ const t = useDsTranslation("ds");
3303
+ const resolvedAriaLabel = ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : children == null ? t("combobox.toggleOptions") : void 0;
3272
3304
  return /* @__PURE__ */ jsxs(Combobox$1.Trigger, _objectSpread2(_objectSpread2({
3273
3305
  ref: forwardRef,
3306
+ "aria-label": resolvedAriaLabel,
3274
3307
  "data-slot": "combobox-trigger",
3275
3308
  className: cn("[&_svg:not([class*='size-'])]:size-4", className)
3276
3309
  }, props), {}, { children: [children, /* @__PURE__ */ jsx(ChevronDownIcon, { className: "pointer-events-none size-4 text-muted-foreground" })] }));
@@ -3281,9 +3314,11 @@ ComboboxTrigger.displayName = "ComboboxTrigger";
3281
3314
  * `<button>` with an X icon.
3282
3315
  */
3283
3316
  const ComboboxClear = React.forwardRef((componentProps, forwardRef) => {
3284
- const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded2$29);
3317
+ const { className, "aria-label": ariaLabel } = componentProps, props = _objectWithoutProperties(componentProps, _excluded2$29);
3318
+ const t = useDsTranslation("ds");
3285
3319
  return /* @__PURE__ */ jsx(Combobox$1.Clear, _objectSpread2(_objectSpread2({
3286
3320
  ref: forwardRef,
3321
+ "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : t("combobox.clear"),
3287
3322
  "data-slot": "combobox-clear",
3288
3323
  render: /* @__PURE__ */ jsx(InputGroupButton, {
3289
3324
  variant: "ghost",
@@ -3299,9 +3334,12 @@ ComboboxClear.displayName = "ComboboxClear";
3299
3334
  */
3300
3335
  const ComboboxInput = React.forwardRef((componentProps, forwardRef) => {
3301
3336
  const { className, children, disabled = false, showTrigger = true, showClear = false } = componentProps, props = _objectWithoutProperties(componentProps, _excluded3$22);
3302
- return /* @__PURE__ */ jsxs(InputGroup, {
3303
- ref: forwardRef,
3304
- className: cn("w-auto", className),
3337
+ const t = useDsTranslation("ds");
3338
+ return /* @__PURE__ */ jsxs(Combobox$1.InputGroup, {
3339
+ render: /* @__PURE__ */ jsx(InputGroup, {
3340
+ ref: forwardRef,
3341
+ className: cn("w-auto", className)
3342
+ }),
3305
3343
  children: [
3306
3344
  /* @__PURE__ */ jsx(Combobox$1.Input, _objectSpread2({ render: /* @__PURE__ */ jsx(InputGroupInput, { disabled }) }, props)),
3307
3345
  /* @__PURE__ */ jsxs(InputGroupAddon, {
@@ -3310,6 +3348,7 @@ const ComboboxInput = React.forwardRef((componentProps, forwardRef) => {
3310
3348
  size: "icon-sm",
3311
3349
  variant: "ghost",
3312
3350
  render: /* @__PURE__ */ jsx(ComboboxTrigger, {}),
3351
+ "aria-label": t("combobox.showOptions"),
3313
3352
  "data-slot": "input-group-button",
3314
3353
  className: "group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent",
3315
3354
  disabled
@@ -3338,7 +3377,7 @@ const ComboboxContent = React.forwardRef((componentProps, forwardRef) => {
3338
3377
  ref: forwardRef,
3339
3378
  "data-slot": "combobox-content",
3340
3379
  "data-chips": !!anchor,
3341
- className: cn("group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className)
3380
+ className: cn("group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", anchor && "min-w-(--anchor-width)", className)
3342
3381
  }, props))
3343
3382
  }) });
3344
3383
  });
@@ -3434,15 +3473,29 @@ const ComboboxSeparator = React.forwardRef((componentProps, forwardRef) => {
3434
3473
  ComboboxSeparator.displayName = "ComboboxSeparator";
3435
3474
  /**
3436
3475
  * Container for the selected chips in a multi-select combobox, wrapping Base UI's
3437
- * `Combobox.Chips`. Renders a bordered, wrapping `<div>` that also holds the chip input.
3476
+ * `Combobox.Chips`. Renders a bordered, wrapping `<div>` that holds the chips, the chip input
3477
+ * and a trailing chevron.
3478
+ *
3479
+ * The chevron is what makes a collapsed field read as a SELECT rather than as a text input that
3480
+ * happens to be empty. An empty chips field is otherwise a bare bordered box: nothing in it says
3481
+ * a list of options is one click away, which is exactly how a filter drawer full of untouched
3482
+ * multi-select fields looked. `ComboboxInput` has always drawn one; this is the same affordance
3483
+ * on the other field shape.
3484
+ *
3485
+ * Pass `showTrigger={false}` for a field that should not advertise a popup.
3438
3486
  */
3439
3487
  const ComboboxChips = React.forwardRef((componentProps, forwardRef) => {
3440
- const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded11$3);
3441
- return /* @__PURE__ */ jsx(Combobox$1.Chips, _objectSpread2({
3488
+ const { className, children, showTrigger = true } = componentProps, props = _objectWithoutProperties(componentProps, _excluded11$3);
3489
+ const t = useDsTranslation("ds");
3490
+ return /* @__PURE__ */ jsxs(Combobox$1.Chips, _objectSpread2(_objectSpread2({
3442
3491
  ref: forwardRef,
3443
3492
  "data-slot": "combobox-chips",
3444
- className: cn("flex min-h-10 flex-wrap items-center gap-1 rounded-md border border-input bg-background bg-clip-padding py-2 pl-3 pr-2 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40", className)
3445
- }, props));
3493
+ className: cn("flex min-h-10 flex-wrap items-center gap-1 rounded-md border border-input bg-background bg-clip-padding py-2 pl-3 pr-1 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40", className)
3494
+ }, props), {}, { children: [children, showTrigger && /* @__PURE__ */ jsx(ComboboxTrigger, {
3495
+ "data-slot": "combobox-chips-trigger",
3496
+ "aria-label": t("combobox.showOptions"),
3497
+ className: "ml-auto shrink-0 rounded-sm p-1 text-muted-foreground"
3498
+ })] }));
3446
3499
  });
3447
3500
  ComboboxChips.displayName = "ComboboxChips";
3448
3501
  /**
@@ -3483,511 +3536,63 @@ function useComboboxAnchor() {
3483
3536
  return React.useRef(null);
3484
3537
  }
3485
3538
  //#endregion
3486
- //#region src/components/combobox-rows.tsx
3487
- const DEFAULT_SKELETON_COUNT = 5;
3488
- const DEFAULT_ROW_HEIGHT = 36;
3489
- const VIRTUAL_ROW_OVERSCAN = 8;
3539
+ //#region src/components/dialog.tsx
3540
+ const _excluded$41 = ["className"];
3541
+ const _excluded2$28 = [
3542
+ "className",
3543
+ "children",
3544
+ "showCloseButton"
3545
+ ];
3546
+ const _excluded3$21 = ["className"];
3547
+ const _excluded4$18 = [
3548
+ "className",
3549
+ "showCloseButton",
3550
+ "children"
3551
+ ];
3552
+ const _excluded5$13 = ["className"];
3553
+ const _excluded6$11 = ["className"];
3490
3554
  /**
3491
- * Buckets a flat `items` array into groups for a combobox list, preserving
3492
- * first-seen group order. Returns `null` when `getGroupKey` is omitted (the flat
3493
- * list path).
3555
+ * Root of the dialog, wrapping Base UI's `Dialog.Root`. Manages open/close state and renders no DOM
3556
+ * element — place `DialogTrigger` and `DialogContent` inside it.
3494
3557
  *
3495
- * Lives above the Combobox root rather than inside `ComboboxRows` because the
3496
- * root's `items` prop must receive the GROUPED shape — Base UI derives its
3497
- * collection, `data-empty`, keyboard nav and client-side filtering from it.
3498
- * Internal to the package: not exported from `src/index.ts`.
3558
+ * @example
3559
+ * ```tsx
3560
+ * <Dialog>
3561
+ * <DialogTrigger render={<Button />}>Open</DialogTrigger>
3562
+ * <DialogContent>
3563
+ * <DialogHeader>
3564
+ * <DialogTitle>Title</DialogTitle>
3565
+ * <DialogDescription>Description</DialogDescription>
3566
+ * </DialogHeader>
3567
+ * </DialogContent>
3568
+ * </Dialog>
3569
+ * ```
3499
3570
  */
3500
- function useComboboxItemGroups(items, getGroupKey, getGroupLabel) {
3501
- return React.useMemo(() => {
3502
- if (!getGroupKey) return null;
3503
- const byKey = /* @__PURE__ */ new Map();
3504
- for (const item of items) {
3505
- const gk = getGroupKey(item);
3506
- const bucket = byKey.get(gk);
3507
- if (bucket) bucket.push(item);
3508
- else byKey.set(gk, [item]);
3509
- }
3510
- return Array.from(byKey, ([groupKey, groupItems]) => ({
3511
- groupKey,
3512
- label: getGroupLabel ? getGroupLabel(groupKey) : groupKey,
3513
- items: groupItems
3514
- }));
3515
- }, [
3516
- items,
3517
- getGroupKey,
3518
- getGroupLabel
3519
- ]);
3571
+ function Dialog(componentProps) {
3572
+ return /* @__PURE__ */ jsx(Dialog$1.Root, _objectSpread2({ "data-slot": "dialog" }, componentProps));
3520
3573
  }
3521
3574
  /**
3522
- * The scrollable rows region shared by every `DataCombobox` layout and by
3523
- * `ComboboxBody`: the rows (flat or grouped), the infinite-scroll sentinel, the
3524
- * skeleton rows, the filtering dim-overlay, the empty state, and the load-more
3525
- * spinner row. It stops at the rows: the search input and any popup chrome
3526
- * belong to whichever root renders this.
3527
- *
3528
- * Must be rendered inside a `Combobox` root whose `items` is `groups ?? items`.
3529
- * Internal to the package: not exported from `src/index.ts`.
3575
+ * Button that opens the dialog, wrapping Base UI's `Dialog.Trigger`. Renders a `<button>` by
3576
+ * default (override with `render`).
3530
3577
  */
3531
- function ComboboxRows(componentProps) {
3532
- var _groups$at$items, _groups$at;
3533
- const { items, groups, getItemValue, getItemLabel, renderItem, disabledKeys, loadingState = "idle", skeletonCount = DEFAULT_SKELETON_COUNT, onFetchMore, hasMore = false, emptyState, listClassName, listTabIndex, virtualizeRows = false, estimateRowHeight = DEFAULT_ROW_HEIGHT, scrollRowIntoViewRef, "aria-label": ariaLabel } = componentProps;
3534
- const isInitialLoading = loadingState === "loading";
3535
- const isFiltering = loadingState === "filtering";
3536
- const isLoadingMore = loadingState === "loadingMore";
3537
- const sentinelRef = useFetchMoreSentinel(onFetchMore, (node) => node.closest("[data-slot=\"combobox-list\"]"), items.length);
3538
- const showFetchSentinel = !!onFetchMore && hasMore;
3539
- const lastRenderedItem = ((_groups$at$items = groups === null || groups === void 0 || (_groups$at = groups.at(-1)) === null || _groups$at === void 0 ? void 0 : _groups$at.items) !== null && _groups$at$items !== void 0 ? _groups$at$items : items).at(-1);
3540
- const lastItemKey = lastRenderedItem ? getItemValue(lastRenderedItem) : void 0;
3541
- const renderRow = (item) => {
3542
- var _disabledKeys$has;
3543
- const key = getItemValue(item);
3544
- const attachSentinel = showFetchSentinel && !virtualizeRows && key === lastItemKey;
3545
- return /* @__PURE__ */ jsx(ComboboxItem, {
3546
- value: item,
3547
- disabled: (_disabledKeys$has = disabledKeys === null || disabledKeys === void 0 ? void 0 : disabledKeys.has(key)) !== null && _disabledKeys$has !== void 0 ? _disabledKeys$has : false,
3548
- ref: attachSentinel ? sentinelRef : void 0,
3549
- "data-test": attachSentinel ? "fetch-sentinel" : void 0,
3550
- children: renderItem ? renderItem(item) : getItemLabel(item)
3551
- }, key);
3552
- };
3553
- const hasRows = items.length > 0;
3554
- const virtualRows = virtualizeRows ? /* @__PURE__ */ jsx(ComboboxVirtualRows, {
3555
- getItemValue,
3556
- getItemLabel,
3557
- renderItem,
3558
- disabledKeys,
3559
- estimateRowHeight,
3560
- sentinelRef,
3561
- showFetchSentinel,
3562
- scrollRowIntoViewRef
3563
- }) : null;
3564
- return /* @__PURE__ */ jsxs("div", {
3565
- "data-slot": "combobox-rows",
3566
- className: cn("relative", isFiltering && !hasRows && "min-h-24"),
3567
- children: [isInitialLoading ? /* @__PURE__ */ jsx(ComboboxSkeletonRows, { count: skeletonCount }) : /* @__PURE__ */ jsx(ComboboxLoadedRows, {
3568
- groups,
3569
- renderRow,
3570
- virtualRows,
3571
- isFiltering,
3572
- isLoadingMore,
3573
- emptyState,
3574
- listClassName,
3575
- listTabIndex,
3576
- "aria-label": ariaLabel
3577
- }), isFiltering ? /* @__PURE__ */ jsx(ComboboxFilteringOverlay, {}) : null]
3578
- });
3579
- }
3580
- /** The loaded rows region: the list itself, the empty state, and the load-more spinner row. */
3581
- function ComboboxLoadedRows(componentProps) {
3582
- const { groups, renderRow, virtualRows, isFiltering, isLoadingMore, emptyState, listClassName, listTabIndex, "aria-label": ariaLabel } = componentProps;
3583
- const t = useDsTranslation("ds");
3584
- const listChildren = virtualRows !== null && virtualRows !== void 0 ? virtualRows : groups === null ? renderRow : renderGroupSection(renderRow);
3585
- return /* @__PURE__ */ jsxs(Fragment, { children: [
3586
- /* @__PURE__ */ jsx(ComboboxList, _objectSpread2(_objectSpread2({
3587
- "aria-label": ariaLabel,
3588
- className: listClassName
3589
- }, listTabIndex === void 0 ? {} : { tabIndex: listTabIndex }), {}, { children: listChildren })),
3590
- isFiltering ? null : /* @__PURE__ */ jsx(ComboboxEmpty, {
3591
- className: "flex empty:hidden",
3592
- children: emptyState !== null && emptyState !== void 0 ? emptyState : t("dataCombobox.noResults")
3593
- }),
3594
- isLoadingMore ? /* @__PURE__ */ jsx(SpinnerRow, {}) : null
3595
- ] });
3596
- }
3578
+ const DialogTrigger = React.forwardRef((componentProps, forwardRef) => {
3579
+ const props = _extends({}, (_objectDestructuringEmpty(componentProps), componentProps));
3580
+ return /* @__PURE__ */ jsx(Dialog$1.Trigger, _objectSpread2({
3581
+ ref: forwardRef,
3582
+ "data-slot": "dialog-trigger"
3583
+ }, props));
3584
+ });
3585
+ DialogTrigger.displayName = "DialogTrigger";
3597
3586
  /**
3598
- * Renders only the rows inside the scrolled window of a FLAT combobox list, at
3599
- * absolute offsets inside a full-height spacer, so a 244-item list keeps roughly
3600
- * twenty rows in the DOM.
3601
- *
3602
- * Reads the rows from Base UI's `useFilteredItems` rather than from the `items`
3603
- * prop: with client-side filtering on, the window must slide over the FILTERED
3604
- * rows, and the flat index of a filtered row is exactly what Base UI's keyboard
3605
- * navigation, `aria-activedescendant` and Enter-to-select are indexed by. That
3606
- * index is passed to every row explicitly — the automatic DOM-order index is
3607
- * meaningless when only a window is mounted.
3587
+ * Portals dialog content into the document body, wrapping Base UI's `Dialog.Portal`. Renders no DOM
3588
+ * element of its own.
3608
3589
  */
3609
- function ComboboxVirtualRows(componentProps) {
3610
- "use no memo";
3611
- var _spacerElement$closes;
3612
- const { getItemValue, getItemLabel, renderItem, disabledKeys, estimateRowHeight, sentinelRef, showFetchSentinel, scrollRowIntoViewRef } = componentProps;
3613
- const filteredItems = Combobox$1.useFilteredItems();
3614
- const [spacerElement, setSpacerElement] = React.useState(null);
3615
- const scrollElement = (_spacerElement$closes = spacerElement === null || spacerElement === void 0 ? void 0 : spacerElement.closest("[data-slot=\"combobox-list\"]")) !== null && _spacerElement$closes !== void 0 ? _spacerElement$closes : null;
3616
- const rowVirtualizer = useVirtualizer({
3617
- count: filteredItems.length,
3618
- getScrollElement: () => scrollElement,
3619
- estimateSize: () => estimateRowHeight,
3620
- overscan: VIRTUAL_ROW_OVERSCAN
3621
- });
3622
- React.useEffect(() => {
3623
- if (!scrollRowIntoViewRef) return void 0;
3624
- scrollRowIntoViewRef.current = (index) => rowVirtualizer.scrollToIndex(index, { align: "auto" });
3625
- return () => {
3626
- scrollRowIntoViewRef.current = null;
3627
- };
3628
- }, [rowVirtualizer, scrollRowIntoViewRef]);
3629
- return /* @__PURE__ */ jsxs("div", {
3630
- ref: setSpacerElement,
3631
- "data-slot": "combobox-virtual-rows",
3632
- className: "relative w-full",
3633
- style: { height: rowVirtualizer.getTotalSize() },
3634
- children: [rowVirtualizer.getVirtualItems().map((virtualRow) => {
3635
- var _disabledKeys$has2;
3636
- const item = filteredItems[virtualRow.index];
3637
- if (item === void 0) return null;
3638
- const key = getItemValue(item);
3639
- return /* @__PURE__ */ jsx(ComboboxItem, {
3640
- index: virtualRow.index,
3641
- value: item,
3642
- disabled: (_disabledKeys$has2 = disabledKeys === null || disabledKeys === void 0 ? void 0 : disabledKeys.has(key)) !== null && _disabledKeys$has2 !== void 0 ? _disabledKeys$has2 : false,
3643
- ref: rowVirtualizer.measureElement,
3644
- "data-index": virtualRow.index,
3645
- style: {
3646
- position: "absolute",
3647
- top: 0,
3648
- left: 0,
3649
- width: "100%",
3650
- transform: `translateY(${virtualRow.start}px)`
3651
- },
3652
- children: renderItem ? renderItem(item) : getItemLabel(item)
3653
- }, key);
3654
- }), showFetchSentinel && filteredItems.length > 0 ? /* @__PURE__ */ jsx("div", {
3655
- ref: sentinelRef,
3656
- "aria-hidden": true,
3657
- "data-test": "fetch-sentinel",
3658
- "data-slot": "combobox-fetch-sentinel",
3659
- className: "absolute bottom-0 h-px w-full"
3660
- }) : null]
3661
- });
3590
+ function DialogPortal(componentProps) {
3591
+ return /* @__PURE__ */ jsx(Dialog$1.Portal, _objectSpread2({ "data-slot": "dialog-portal" }, componentProps));
3662
3592
  }
3663
3593
  /**
3664
- * Builds `ComboboxList`'s render-prop for a GROUPED list: one `ComboboxGroup`
3665
- * per section, each header plus a collection of leaf rows. Base UI calls the
3666
- * returned function once per group from the Root's grouped `items`.
3667
- */
3668
- function renderGroupSection(renderRow) {
3669
- return (group) => /* @__PURE__ */ jsxs(ComboboxGroup, {
3670
- items: group.items,
3671
- children: [/* @__PURE__ */ jsx(ComboboxLabel, { children: group.label }), /* @__PURE__ */ jsx(ComboboxCollection, { children: renderRow })]
3672
- }, group.groupKey);
3673
- }
3674
- /** The dimmed spinner overlay covering the list while a re-query is in flight. */
3675
- function ComboboxFilteringOverlay() {
3676
- return /* @__PURE__ */ jsx("div", {
3677
- "data-slot": "combobox-loading-overlay",
3678
- className: "bg-popover/60 absolute inset-0 z-10 flex items-center justify-center",
3679
- children: /* @__PURE__ */ jsx(Spinner, {})
3680
- });
3681
- }
3682
- /**
3683
- * A centered spinner row for the filtering and load-more states. Not
3684
- * `aria-hidden` — the `Spinner`'s `role="status"` announces loading to screen
3685
- * readers (that's the point of a loading indicator).
3686
- */
3687
- function SpinnerRow() {
3688
- return /* @__PURE__ */ jsx("div", {
3689
- "data-slot": "combobox-spinner-row",
3690
- className: "flex justify-center py-2 text-muted-foreground",
3691
- children: /* @__PURE__ */ jsx(Spinner, {})
3692
- });
3693
- }
3694
- /** Skeleton rows, padded like the list, shown while the initial page loads. */
3695
- function ComboboxSkeletonRows({ count }) {
3696
- return /* @__PURE__ */ jsx("div", {
3697
- "data-slot": "combobox-skeleton-rows",
3698
- className: "p-1",
3699
- children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx("div", {
3700
- "aria-hidden": true,
3701
- "data-test": "loading-item",
3702
- "data-slot": "combobox-skeleton-row",
3703
- className: "flex items-center gap-2 rounded-md p-2",
3704
- children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" })
3705
- }, `skeleton-${i}`))
3706
- });
3707
- }
3708
- //#endregion
3709
- //#region src/lib/use-combobox-item-selection.ts
3710
- const EMPTY_KEYS = /* @__PURE__ */ new Set();
3711
- /**
3712
- * The `onInputValueChange` reasons a POPUP combobox forwards to `onSearch`
3713
- * (`DataCombobox`'s three layouts):
3714
- * - `input-change` — real typing/paste.
3715
- * - `input-clear` — Base UI clears the field itself after a selection.
3716
- * - `clear-press` — the input's clear (x) button.
3717
- *
3718
- * `escape-key` is deliberately absent: with a popup, Escape CLOSES it rather
3719
- * than clearing the query, so forwarding it would refetch on every dismissal.
3720
- */
3721
- const POPUP_SEARCH_TRIGGER_REASONS = /* @__PURE__ */ new Set([
3722
- "input-change",
3723
- "input-clear",
3724
- "clear-press"
3725
- ]);
3726
- /**
3727
- * The `onInputValueChange` reasons an INLINE combobox forwards to `onSearch`
3728
- * (`ComboboxBody`). Same as the popup set plus `escape-key`.
3729
- *
3730
- * With no popup, Escape is the inline list's RESET: Base UI empties the query and
3731
- * clears the selection under that reason. Forwarding it keeps the consumer's data
3732
- * in step with the reset it just performed — otherwise the component presents
3733
- * itself as reset while the caller keeps serving the previous query's page.
3734
- */
3735
- const INLINE_SEARCH_TRIGGER_REASONS = /* @__PURE__ */ new Set([
3736
- "input-change",
3737
- "input-clear",
3738
- "clear-press",
3739
- "escape-key"
3740
- ]);
3741
- /**
3742
- * Bridges a `Set<string>` of selected keys to the item objects Base UI's
3743
- * Combobox root wants for `value` / `onValueChange`, and gates the input's
3744
- * value changes down to real search queries.
3745
- *
3746
- * Shared by `DataCombobox` and `ComboboxBody` — both own a Combobox root and
3747
- * need the identical selection semantics. Internal to the package: not exported
3748
- * from `src/index.ts`.
3749
- *
3750
- * @example
3751
- * ```tsx
3752
- * const { keys, selectedObjects, commit, handleInputValueChange } =
3753
- * useComboboxItemSelection({ items, getItemValue, selectedKeys, onSelectionChange });
3754
- * ```
3755
- */
3756
- function useComboboxItemSelection(options) {
3757
- const { items, getItemValue, selectedItems, selectedKeys, defaultSelectedKeys, onSelectionChange, onSearch, searchTriggerReasons = POPUP_SEARCH_TRIGGER_REASONS } = options;
3758
- const itemCacheRef = React.useRef(/* @__PURE__ */ new Map());
3759
- if (selectedItems) for (const item of selectedItems) itemCacheRef.current.set(getItemValue(item), item);
3760
- for (const item of items) itemCacheRef.current.set(getItemValue(item), item);
3761
- const itemCache = itemCacheRef.current;
3762
- const [selectionSet, setSelectionSet] = useControllableState({
3763
- prop: selectedKeys,
3764
- defaultProp: defaultSelectedKeys
3765
- });
3766
- const keys = selectionSet !== null && selectionSet !== void 0 ? selectionSet : EMPTY_KEYS;
3767
- const selectedObjects = [];
3768
- for (const key of keys) {
3769
- const item = itemCache.get(key);
3770
- if (item) selectedObjects.push(item);
3771
- }
3772
- return {
3773
- keys,
3774
- selectedObjects,
3775
- commit: React.useCallback((objs, details) => {
3776
- const next = new Set(objs.map(getItemValue));
3777
- setSelectionSet(next);
3778
- onSelectionChange === null || onSelectionChange === void 0 || onSelectionChange(next, details);
3779
- }, [
3780
- setSelectionSet,
3781
- getItemValue,
3782
- onSelectionChange
3783
- ]),
3784
- handleInputValueChange: onSearch ? (value, details) => {
3785
- if (searchTriggerReasons.has(details.reason)) onSearch(value);
3786
- } : void 0
3787
- };
3788
- }
3789
- //#endregion
3790
- //#region src/components/combobox-body.tsx
3791
- const LIST_MAX_HEIGHT = "max-h-63";
3792
- const INPUT_IN_LIST_CLASSES = "m-1 mb-0 border-input/30 bg-input/30 shadow-none";
3793
- const FOCUSABLE_LIST_CLASSES = "focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-inset";
3794
- /**
3795
- * Row count at which `ComboboxBody` virtualises its rows on its own, when `virtualizeRows` was not
3796
- * passed either way. Exported so it can be asserted against and tuned in ONE place.
3797
- *
3798
- * Crossing it LATCHES virtualisation on for the life of the component - see the `virtualizeRows`
3799
- * prop doc. A list that declares `onFetchMore` can grow without bound, so it starts out virtualised
3800
- * regardless of this number rather than waiting to cross it.
3801
- *
3802
- * A STARTING POINT, not a measured optimum. The two real data points behind it: 244 countries with
3803
- * a flag per row was visibly laggy unvirtualised, and the user lists are server-capped at 10 rows
3804
- * today, so both known cases sit far from this line and the exact value is not load-bearing yet.
3805
- * Measure before tuning it - the honest cost driver is how expensive `renderItem` is, not the row
3806
- * count alone, and a threshold cannot see that.
3807
- */
3808
- const COMBOBOX_AUTO_VIRTUALIZE_THRESHOLD = 100;
3809
- /**
3810
- * Scrolls a keyboard-highlighted row into view while rows are virtualised.
3811
- * A no-op without virtualisation (nothing fills the ref), for a pointer-driven
3812
- * highlight (the row is already under the cursor, so already mounted), and when
3813
- * the highlight was cleared (index `-1`).
3814
- */
3815
- function scrollHighlightedRowIntoView(scrollRowIntoViewRef, index, reason) {
3816
- var _scrollRowIntoViewRef;
3817
- if (reason === "pointer" || index < 0) return;
3818
- (_scrollRowIntoViewRef = scrollRowIntoViewRef.current) === null || _scrollRowIntoViewRef === void 0 || _scrollRowIntoViewRef.call(scrollRowIntoViewRef, index);
3819
- }
3820
- /**
3821
- * A data-driven combobox list with NO trigger and NO popup of its own: an
3822
- * optional search input above a selectable list, ready to be dropped into a
3823
- * surface the caller owns (a `Filter` popover, a panel, a dialog). Driven by an
3824
- * `items` array plus `getItemValue`/`getItemLabel`, with opt-in server-side
3825
- * search, grouping, infinite scroll, and loading/empty states.
3826
- *
3827
- * Use `DataCombobox` instead when you want the field-plus-popup combobox. This
3828
- * is the same rows region plus an optional search input, without the field or the
3829
- * popup around them, so the host controls open state, dismissal and positioning.
3830
- * The name pairs with `ComboboxContent`, which is the popup this deliberately
3831
- * does not have.
3832
- *
3833
- * Dismissal note: with no popup of its own, this holds no dismiss layer, so an
3834
- * outside press or Escape always reaches the host. Escape ALSO resets the list —
3835
- * clearing the query and the selection, the combobox convention for a list with
3836
- * nothing open — but only while the search box is untouched; once the user has
3837
- * clicked or typed in it, Base UI treats the list as open and Escape just
3838
- * dismisses. The reset is forwarded to `onSearch('')` so a server-driven list
3839
- * comes back unfiltered instead of stranding the previous query's page. Dismiss
3840
- * via an outside press (or the host's own close affordance) when the selection
3841
- * must survive.
3842
- *
3843
- * @example
3844
- * ```tsx
3845
- * <ComboboxBody
3846
- * items={statuses}
3847
- * getItemValue={status => status.id}
3848
- * getItemLabel={status => status.label}
3849
- * selectionMode="multiple"
3850
- * selectedKeys={selectedKeys}
3851
- * onSelectionChange={setSelectedKeys}
3852
- * />
3853
- * ```
3854
- */
3855
- function ComboboxBody(componentProps) {
3856
- var _componentProps$virtu, _selectedObjects$;
3857
- const { items, getItemValue, getItemLabel, renderItem, getGroupKey, getGroupLabel, selectionMode = "single", selectedKeys, defaultSelectedKeys, onSelectionChange, selectedItems, disabledKeys, loadingState = "idle", skeletonCount, onSearch, onFetchMore, hasMore = false, emptyState, estimateRowHeight, searchable = true, placeholder, className, "aria-label": ariaLabel } = componentProps;
3858
- const multiple = selectionMode === "multiple";
3859
- const autoVirtualizeLatch = React.useRef(false);
3860
- if (!autoVirtualizeLatch.current) autoVirtualizeLatch.current = !!onFetchMore || items.length >= 100;
3861
- const virtualizeRows = ((_componentProps$virtu = componentProps.virtualizeRows) !== null && _componentProps$virtu !== void 0 ? _componentProps$virtu : autoVirtualizeLatch.current) && !getGroupKey;
3862
- const scrollRowIntoViewRef = React.useRef(null);
3863
- const { selectedObjects, commit, handleInputValueChange } = useComboboxItemSelection({
3864
- items,
3865
- getItemValue,
3866
- selectedItems,
3867
- selectedKeys,
3868
- defaultSelectedKeys,
3869
- onSelectionChange,
3870
- onSearch,
3871
- searchTriggerReasons: INLINE_SEARCH_TRIGGER_REASONS
3872
- });
3873
- const groups = useComboboxItemGroups(items, getGroupKey, getGroupLabel);
3874
- const body = /* @__PURE__ */ jsxs("div", {
3875
- "data-slot": "combobox-body",
3876
- className: cn("flex w-full flex-col", className),
3877
- children: [searchable ? /* @__PURE__ */ jsx(ComboboxInput, {
3878
- showTrigger: false,
3879
- placeholder,
3880
- className: INPUT_IN_LIST_CLASSES
3881
- }) : null, /* @__PURE__ */ jsx(ComboboxRows, {
3882
- items,
3883
- groups,
3884
- getItemValue,
3885
- getItemLabel,
3886
- renderItem,
3887
- disabledKeys,
3888
- loadingState,
3889
- skeletonCount,
3890
- onFetchMore,
3891
- hasMore,
3892
- emptyState,
3893
- listClassName: cn(LIST_MAX_HEIGHT, !searchable && FOCUSABLE_LIST_CLASSES),
3894
- listTabIndex: searchable ? void 0 : 0,
3895
- virtualizeRows,
3896
- estimateRowHeight,
3897
- scrollRowIntoViewRef,
3898
- "aria-label": ariaLabel
3899
- })]
3900
- });
3901
- if (multiple) return /* @__PURE__ */ jsx(Combobox, {
3902
- multiple: true,
3903
- inline: true,
3904
- autoHighlight: true,
3905
- virtualized: virtualizeRows,
3906
- onItemHighlighted: (_item, details) => scrollHighlightedRowIntoView(scrollRowIntoViewRef, details.index, details.reason),
3907
- items: groups !== null && groups !== void 0 ? groups : items,
3908
- filter: onSearch || onFetchMore && hasMore ? null : void 0,
3909
- value: selectedObjects,
3910
- onValueChange: commit,
3911
- itemToStringValue: getItemValue,
3912
- itemToStringLabel: getItemLabel,
3913
- isItemEqualToValue: (a, b) => getItemValue(a) === getItemValue(b),
3914
- onInputValueChange: handleInputValueChange,
3915
- children: body
3916
- }, selectionMode);
3917
- return /* @__PURE__ */ jsx(Combobox, {
3918
- inline: true,
3919
- autoHighlight: true,
3920
- virtualized: virtualizeRows,
3921
- onItemHighlighted: (_item, details) => scrollHighlightedRowIntoView(scrollRowIntoViewRef, details.index, details.reason),
3922
- items: groups !== null && groups !== void 0 ? groups : items,
3923
- filter: onSearch || onFetchMore && hasMore ? null : void 0,
3924
- value: (_selectedObjects$ = selectedObjects[0]) !== null && _selectedObjects$ !== void 0 ? _selectedObjects$ : null,
3925
- onValueChange: (next, details) => commit(next == null ? [] : [next], details),
3926
- itemToStringValue: getItemValue,
3927
- itemToStringLabel: getItemLabel,
3928
- isItemEqualToValue: (a, b) => getItemValue(a) === getItemValue(b),
3929
- onInputValueChange: handleInputValueChange,
3930
- children: body
3931
- }, selectionMode);
3932
- }
3933
- //#endregion
3934
- //#region src/components/dialog.tsx
3935
- const _excluded$41 = ["className"];
3936
- const _excluded2$28 = [
3937
- "className",
3938
- "children",
3939
- "showCloseButton"
3940
- ];
3941
- const _excluded3$21 = ["className"];
3942
- const _excluded4$18 = [
3943
- "className",
3944
- "showCloseButton",
3945
- "children"
3946
- ];
3947
- const _excluded5$13 = ["className"];
3948
- const _excluded6$11 = ["className"];
3949
- /**
3950
- * Root of the dialog, wrapping Base UI's `Dialog.Root`. Manages open/close state and renders no DOM
3951
- * element — place `DialogTrigger` and `DialogContent` inside it.
3952
- *
3953
- * @example
3954
- * ```tsx
3955
- * <Dialog>
3956
- * <DialogTrigger render={<Button />}>Open</DialogTrigger>
3957
- * <DialogContent>
3958
- * <DialogHeader>
3959
- * <DialogTitle>Title</DialogTitle>
3960
- * <DialogDescription>Description</DialogDescription>
3961
- * </DialogHeader>
3962
- * </DialogContent>
3963
- * </Dialog>
3964
- * ```
3965
- */
3966
- function Dialog(componentProps) {
3967
- return /* @__PURE__ */ jsx(Dialog$1.Root, _objectSpread2({ "data-slot": "dialog" }, componentProps));
3968
- }
3969
- /**
3970
- * Button that opens the dialog, wrapping Base UI's `Dialog.Trigger`. Renders a `<button>` by
3971
- * default (override with `render`).
3972
- */
3973
- const DialogTrigger = React.forwardRef((componentProps, forwardRef) => {
3974
- const props = _extends({}, (_objectDestructuringEmpty(componentProps), componentProps));
3975
- return /* @__PURE__ */ jsx(Dialog$1.Trigger, _objectSpread2({
3976
- ref: forwardRef,
3977
- "data-slot": "dialog-trigger"
3978
- }, props));
3979
- });
3980
- DialogTrigger.displayName = "DialogTrigger";
3981
- /**
3982
- * Portals dialog content into the document body, wrapping Base UI's `Dialog.Portal`. Renders no DOM
3983
- * element of its own.
3984
- */
3985
- function DialogPortal(componentProps) {
3986
- return /* @__PURE__ */ jsx(Dialog$1.Portal, _objectSpread2({ "data-slot": "dialog-portal" }, componentProps));
3987
- }
3988
- /**
3989
- * Button that closes the dialog, wrapping Base UI's `Dialog.Close`. Renders a `<button>` by default
3990
- * (override with `render`).
3594
+ * Button that closes the dialog, wrapping Base UI's `Dialog.Close`. Renders a `<button>` by default
3595
+ * (override with `render`).
3991
3596
  */
3992
3597
  const DialogClose = React.forwardRef((componentProps, forwardRef) => {
3993
3598
  const props = _extends({}, (_objectDestructuringEmpty(componentProps), componentProps));
@@ -4130,169 +3735,565 @@ const Command = React.forwardRef((componentProps, forwardRef) => {
4130
3735
  });
4131
3736
  Command.displayName = "Command";
4132
3737
  /**
4133
- * A `Command` menu rendered inside a modal `Dialog` — the command-palette
4134
- * pattern. Renders no DOM element of its own; the visually hidden title and
4135
- * description keep it accessible.
3738
+ * A `Command` menu rendered inside a modal `Dialog` — the command-palette
3739
+ * pattern. Renders no DOM element of its own; the visually hidden title and
3740
+ * description keep it accessible.
3741
+ *
3742
+ * @prop title - Screen-reader-only dialog title. Default: `'Command Palette'`.
3743
+ * @prop description - Screen-reader-only dialog description.
3744
+ * Default: `'Search for a command to run...'`.
3745
+ *
3746
+ * @example
3747
+ * ```tsx
3748
+ * <CommandDialog open={open} onOpenChange={setOpen}>
3749
+ * <CommandInput placeholder="Type a command..." />
3750
+ * <CommandList>
3751
+ * <CommandItem>Profile</CommandItem>
3752
+ * </CommandList>
3753
+ * </CommandDialog>
3754
+ * ```
3755
+ */
3756
+ function CommandDialog(componentProps) {
3757
+ const { title = "Command Palette", description = "Search for a command to run...", children } = componentProps, props = _objectWithoutProperties(componentProps, _excluded2$27);
3758
+ return /* @__PURE__ */ jsxs(Dialog, _objectSpread2(_objectSpread2({}, props), {}, { children: [/* @__PURE__ */ jsxs(DialogHeader, {
3759
+ className: "sr-only",
3760
+ children: [/* @__PURE__ */ jsx(DialogTitle, { children: title }), /* @__PURE__ */ jsx(DialogDescription, { children: description })]
3761
+ }), /* @__PURE__ */ jsx(DialogContent, {
3762
+ className: "overflow-hidden p-0",
3763
+ children: /* @__PURE__ */ jsx(Command, {
3764
+ className: "[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",
3765
+ children
3766
+ })
3767
+ })] }));
3768
+ }
3769
+ /**
3770
+ * The search field that filters the command list as the user types. Renders an
3771
+ * `<input>` inside a `<div>` wrapper with a leading search icon.
3772
+ */
3773
+ const CommandInput = React.forwardRef((componentProps, forwardRef) => {
3774
+ const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded3$20);
3775
+ return /* @__PURE__ */ jsxs("div", {
3776
+ "data-slot": "command-input-wrapper",
3777
+ className: "flex h-9 items-center gap-2 border-b px-3",
3778
+ children: [/* @__PURE__ */ jsx(Search, { className: "size-4 shrink-0 opacity-50" }), /* @__PURE__ */ jsx(Command$1.Input, _objectSpread2({
3779
+ ref: forwardRef,
3780
+ "data-slot": "command-input",
3781
+ className: cn("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50", className)
3782
+ }, props))]
3783
+ });
3784
+ });
3785
+ CommandInput.displayName = "CommandInput";
3786
+ /**
3787
+ * Scrollable container holding the command groups, items, and empty state.
3788
+ * Renders a `<div>` that scrolls vertically when content overflows.
3789
+ */
3790
+ const CommandList = React.forwardRef((componentProps, forwardRef) => {
3791
+ const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded4$17);
3792
+ return /* @__PURE__ */ jsx(Command$1.List, _objectSpread2({
3793
+ ref: forwardRef,
3794
+ "data-slot": "command-list",
3795
+ className: cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto", className)
3796
+ }, props));
3797
+ });
3798
+ CommandList.displayName = "CommandList";
3799
+ /**
3800
+ * Message shown when the current search matches no items. Renders a centered
3801
+ * `<div>` that is only visible when the list is empty.
3802
+ */
3803
+ const CommandEmpty = React.forwardRef((componentProps, forwardRef) => {
3804
+ const props = _extends({}, (_objectDestructuringEmpty(componentProps), componentProps));
3805
+ return /* @__PURE__ */ jsx(Command$1.Empty, _objectSpread2({
3806
+ ref: forwardRef,
3807
+ "data-slot": "command-empty",
3808
+ className: "py-6 text-center text-sm"
3809
+ }, props));
3810
+ });
3811
+ CommandEmpty.displayName = "CommandEmpty";
3812
+ /**
3813
+ * Groups related command items under an optional `heading`. Renders a `<div>`
3814
+ * that hides itself when none of its items match the search.
3815
+ */
3816
+ const CommandGroup = React.forwardRef((componentProps, forwardRef) => {
3817
+ const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded5$12);
3818
+ return /* @__PURE__ */ jsx(Command$1.Group, _objectSpread2({
3819
+ ref: forwardRef,
3820
+ "data-slot": "command-group",
3821
+ className: cn("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium", className)
3822
+ }, props));
3823
+ });
3824
+ CommandGroup.displayName = "CommandGroup";
3825
+ /**
3826
+ * A thin horizontal divider between command groups or items. Renders a `<div>`
3827
+ * one pixel tall.
3828
+ */
3829
+ const CommandSeparator = React.forwardRef((componentProps, forwardRef) => {
3830
+ const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded6$10);
3831
+ return /* @__PURE__ */ jsx(Command$1.Separator, _objectSpread2({
3832
+ ref: forwardRef,
3833
+ "data-slot": "command-separator",
3834
+ className: cn("bg-border -mx-1 h-px", className)
3835
+ }, props));
3836
+ });
3837
+ CommandSeparator.displayName = "CommandSeparator";
3838
+ /**
3839
+ * A single selectable command in the list. Renders a `<div>` that highlights on
3840
+ * hover/keyboard selection and can be disabled.
3841
+ */
3842
+ const CommandItem = React.forwardRef((componentProps, forwardRef) => {
3843
+ const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded7$5);
3844
+ return /* @__PURE__ */ jsx(Command$1.Item, _objectSpread2({
3845
+ ref: forwardRef,
3846
+ "data-slot": "command-item",
3847
+ className: cn("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className)
3848
+ }, props));
3849
+ });
3850
+ CommandItem.displayName = "CommandItem";
3851
+ /**
3852
+ * Right-aligned hint displaying an item's keyboard shortcut. Renders a `<span>`
3853
+ * with muted, spaced-out text.
3854
+ */
3855
+ const CommandShortcut = React.forwardRef((componentProps, forwardRef) => {
3856
+ const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded8$5);
3857
+ return /* @__PURE__ */ jsx("span", _objectSpread2({
3858
+ ref: forwardRef,
3859
+ "data-slot": "command-shortcut",
3860
+ className: cn("text-muted-foreground ml-auto text-xs tracking-widest", className)
3861
+ }, props));
3862
+ });
3863
+ CommandShortcut.displayName = "CommandShortcut";
3864
+ //#endregion
3865
+ //#region src/components/country-flag.tsx
3866
+ const _excluded$39 = [
3867
+ "countryIsoCode",
3868
+ "size",
3869
+ "className"
3870
+ ];
3871
+ const sizeMap = {
3872
+ sm: "size-3",
3873
+ md: "size-4",
3874
+ lg: "size-5",
3875
+ xl: "size-6"
3876
+ };
3877
+ /**
3878
+ * Renders the flag icon for a given country as an inline `<svg>`.
3879
+ * Falls back to the US flag when the ISO code has no matching flag.
3880
+ *
3881
+ * @prop countryIsoCode - ISO country code selecting the flag to render.
3882
+ * @prop size - Flag dimensions: `sm` (12px) | `md` (16px) | `lg` (20px) | `xl` (24px). Default: `'xl'`.
3883
+ *
3884
+ * @example
3885
+ * ```tsx
3886
+ * <CountryFlag countryIsoCode="FR" size="md" />
3887
+ * ```
3888
+ */
3889
+ const CountryFlag = React.forwardRef((componentProps, forwardRef) => {
3890
+ var _FLAGS$countryIsoCode;
3891
+ const { countryIsoCode, size = "xl", className } = componentProps, otherProps = _objectWithoutProperties(componentProps, _excluded$39);
3892
+ const CurrentFlag = (_FLAGS$countryIsoCode = FLAGS[countryIsoCode.toLowerCase()]) !== null && _FLAGS$countryIsoCode !== void 0 ? _FLAGS$countryIsoCode : FlagUs;
3893
+ return /* @__PURE__ */ jsx(CurrentFlag, _objectSpread2({
3894
+ ref: forwardRef,
3895
+ className: cn("flex-none", sizeMap[size], className)
3896
+ }, otherProps));
3897
+ });
3898
+ CountryFlag.displayName = "CountryFlag";
3899
+ //#endregion
3900
+ //#region src/components/combobox-rows.tsx
3901
+ const DEFAULT_SKELETON_COUNT = 5;
3902
+ const DEFAULT_ROW_HEIGHT = 36;
3903
+ const VIRTUAL_ROW_OVERSCAN = 8;
3904
+ /**
3905
+ * Buckets a flat `items` array into groups for a combobox list, preserving
3906
+ * first-seen group order. Returns `null` when `getGroupKey` is omitted (the flat
3907
+ * list path).
3908
+ *
3909
+ * Lives above the Combobox root rather than inside `ComboboxRows` because the
3910
+ * root's `items` prop must receive the GROUPED shape — Base UI derives its
3911
+ * collection, `data-empty`, keyboard nav and client-side filtering from it.
3912
+ * Internal to the package: not exported from `src/index.ts`.
3913
+ */
3914
+ function useComboboxItemGroups(items, getGroupKey, getGroupLabel) {
3915
+ return React.useMemo(() => {
3916
+ if (!getGroupKey) return null;
3917
+ const byKey = /* @__PURE__ */ new Map();
3918
+ for (const item of items) {
3919
+ const gk = getGroupKey(item);
3920
+ const bucket = byKey.get(gk);
3921
+ if (bucket) bucket.push(item);
3922
+ else byKey.set(gk, [item]);
3923
+ }
3924
+ return Array.from(byKey, ([groupKey, groupItems]) => ({
3925
+ groupKey,
3926
+ label: getGroupLabel ? getGroupLabel(groupKey) : groupKey,
3927
+ items: groupItems
3928
+ }));
3929
+ }, [
3930
+ items,
3931
+ getGroupKey,
3932
+ getGroupLabel
3933
+ ]);
3934
+ }
3935
+ /**
3936
+ * The scrollable rows region shared by every `DataCombobox` layout: the rows
3937
+ * (flat or grouped), the infinite-scroll sentinel, the
3938
+ * skeleton rows, the filtering dim-overlay, the empty state, and the load-more
3939
+ * spinner row. It stops at the rows: the search input and any popup chrome
3940
+ * belong to whichever root renders this.
3941
+ *
3942
+ * Must be rendered inside a `Combobox` root whose `items` is `groups ?? items`.
3943
+ * Internal to the package: not exported from `src/index.ts`.
3944
+ */
3945
+ function ComboboxRows(componentProps) {
3946
+ var _groups$at$items, _groups$at;
3947
+ const { items, groups, getItemValue, getItemLabel, renderItem, disabledKeys, loadingState = "idle", skeletonCount = DEFAULT_SKELETON_COUNT, onFetchMore, hasMore = false, emptyState, listClassName, listTabIndex, virtualizeRows = false, estimateRowHeight = DEFAULT_ROW_HEIGHT, scrollRowIntoViewRef, "aria-label": ariaLabel } = componentProps;
3948
+ const isInitialLoading = loadingState === "loading";
3949
+ const isFiltering = loadingState === "filtering";
3950
+ const isLoadingMore = loadingState === "loadingMore";
3951
+ const sentinelRef = useFetchMoreSentinel(onFetchMore, (node) => node.closest("[data-slot=\"combobox-list\"]"), items.length);
3952
+ const showFetchSentinel = !!onFetchMore && hasMore;
3953
+ const lastRenderedItem = ((_groups$at$items = groups === null || groups === void 0 || (_groups$at = groups.at(-1)) === null || _groups$at === void 0 ? void 0 : _groups$at.items) !== null && _groups$at$items !== void 0 ? _groups$at$items : items).at(-1);
3954
+ const lastItemKey = lastRenderedItem ? getItemValue(lastRenderedItem) : void 0;
3955
+ const renderRow = (item) => {
3956
+ var _disabledKeys$has;
3957
+ const key = getItemValue(item);
3958
+ const attachSentinel = showFetchSentinel && !virtualizeRows && key === lastItemKey;
3959
+ return /* @__PURE__ */ jsx(ComboboxItem, {
3960
+ value: item,
3961
+ disabled: (_disabledKeys$has = disabledKeys === null || disabledKeys === void 0 ? void 0 : disabledKeys.has(key)) !== null && _disabledKeys$has !== void 0 ? _disabledKeys$has : false,
3962
+ ref: attachSentinel ? sentinelRef : void 0,
3963
+ "data-test": attachSentinel ? "fetch-sentinel" : void 0,
3964
+ children: renderItem ? renderItem(item) : getItemLabel(item)
3965
+ }, key);
3966
+ };
3967
+ const hasRows = items.length > 0;
3968
+ const virtualRows = virtualizeRows ? /* @__PURE__ */ jsx(ComboboxVirtualRows, {
3969
+ getItemValue,
3970
+ getItemLabel,
3971
+ renderItem,
3972
+ disabledKeys,
3973
+ estimateRowHeight,
3974
+ sentinelRef,
3975
+ showFetchSentinel,
3976
+ scrollRowIntoViewRef
3977
+ }) : null;
3978
+ return /* @__PURE__ */ jsxs("div", {
3979
+ "data-slot": "combobox-rows",
3980
+ className: cn("relative", isFiltering && !hasRows && "min-h-24"),
3981
+ children: [/* @__PURE__ */ jsx(ComboboxLoadedRows, {
3982
+ isInitialLoading,
3983
+ skeletonCount,
3984
+ groups,
3985
+ renderRow,
3986
+ virtualRows,
3987
+ isFiltering,
3988
+ isLoadingMore,
3989
+ emptyState,
3990
+ listClassName,
3991
+ listTabIndex,
3992
+ "aria-label": ariaLabel
3993
+ }), isFiltering ? /* @__PURE__ */ jsx(ComboboxFilteringOverlay, {}) : null]
3994
+ });
3995
+ }
3996
+ /** The loaded rows region: the list itself, the empty state, and the load-more spinner row. */
3997
+ function ComboboxLoadedRows(componentProps) {
3998
+ const { isInitialLoading, skeletonCount, groups, renderRow, virtualRows, isFiltering, isLoadingMore, emptyState, listClassName, listTabIndex, "aria-label": ariaLabel } = componentProps;
3999
+ const t = useDsTranslation("ds");
4000
+ const listChildren = isInitialLoading ? /* @__PURE__ */ jsx(ComboboxSkeletonRows, { count: skeletonCount }) : virtualRows !== null && virtualRows !== void 0 ? virtualRows : groups === null ? renderRow : renderGroupSection(renderRow);
4001
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4002
+ /* @__PURE__ */ jsx(ComboboxList, _objectSpread2(_objectSpread2({
4003
+ "aria-label": ariaLabel,
4004
+ className: listClassName
4005
+ }, listTabIndex === void 0 ? {} : { tabIndex: listTabIndex }), {}, { children: listChildren })),
4006
+ /* @__PURE__ */ jsx(ComboboxEmpty, {
4007
+ className: "flex empty:hidden",
4008
+ children: isFiltering || isInitialLoading ? null : emptyState !== null && emptyState !== void 0 ? emptyState : t("dataCombobox.noResults")
4009
+ }),
4010
+ isLoadingMore ? /* @__PURE__ */ jsx(SpinnerRow, {}) : null
4011
+ ] });
4012
+ }
4013
+ /**
4014
+ * Renders only the rows inside the scrolled window of a FLAT combobox list, at
4015
+ * absolute offsets inside a full-height spacer, so a 244-item list keeps roughly
4016
+ * twenty rows in the DOM.
4017
+ *
4018
+ * Reads the rows from Base UI's `useFilteredItems` rather than from the `items`
4019
+ * prop: with client-side filtering on, the window must slide over the FILTERED
4020
+ * rows, and the flat index of a filtered row is exactly what Base UI's keyboard
4021
+ * navigation, `aria-activedescendant` and Enter-to-select are indexed by. That
4022
+ * index is passed to every row explicitly — the automatic DOM-order index is
4023
+ * meaningless when only a window is mounted.
4024
+ */
4025
+ function ComboboxVirtualRows(componentProps) {
4026
+ "use no memo";
4027
+ var _spacerElement$closes;
4028
+ const { getItemValue, getItemLabel, renderItem, disabledKeys, estimateRowHeight, sentinelRef, showFetchSentinel, scrollRowIntoViewRef } = componentProps;
4029
+ const filteredItems = Combobox$1.useFilteredItems();
4030
+ const [spacerElement, setSpacerElement] = React.useState(null);
4031
+ const scrollElement = (_spacerElement$closes = spacerElement === null || spacerElement === void 0 ? void 0 : spacerElement.closest("[data-slot=\"combobox-list\"]")) !== null && _spacerElement$closes !== void 0 ? _spacerElement$closes : null;
4032
+ const rowVirtualizer = useVirtualizer({
4033
+ count: filteredItems.length,
4034
+ getScrollElement: () => scrollElement,
4035
+ estimateSize: () => estimateRowHeight,
4036
+ overscan: VIRTUAL_ROW_OVERSCAN
4037
+ });
4038
+ React.useEffect(() => {
4039
+ if (!scrollRowIntoViewRef) return void 0;
4040
+ scrollRowIntoViewRef.current = (index) => rowVirtualizer.scrollToIndex(index, { align: "auto" });
4041
+ return () => {
4042
+ scrollRowIntoViewRef.current = null;
4043
+ };
4044
+ }, [rowVirtualizer, scrollRowIntoViewRef]);
4045
+ return /* @__PURE__ */ jsxs("div", {
4046
+ ref: setSpacerElement,
4047
+ "data-slot": "combobox-virtual-rows",
4048
+ className: "relative w-full",
4049
+ style: { height: rowVirtualizer.getTotalSize() },
4050
+ children: [rowVirtualizer.getVirtualItems().map((virtualRow) => {
4051
+ var _disabledKeys$has2;
4052
+ const item = filteredItems[virtualRow.index];
4053
+ if (item === void 0) return null;
4054
+ const key = getItemValue(item);
4055
+ return /* @__PURE__ */ jsx(ComboboxItem, {
4056
+ index: virtualRow.index,
4057
+ value: item,
4058
+ disabled: (_disabledKeys$has2 = disabledKeys === null || disabledKeys === void 0 ? void 0 : disabledKeys.has(key)) !== null && _disabledKeys$has2 !== void 0 ? _disabledKeys$has2 : false,
4059
+ ref: rowVirtualizer.measureElement,
4060
+ "data-index": virtualRow.index,
4061
+ style: {
4062
+ position: "absolute",
4063
+ top: 0,
4064
+ left: 0,
4065
+ width: "100%",
4066
+ transform: `translateY(${virtualRow.start}px)`
4067
+ },
4068
+ children: renderItem ? renderItem(item) : getItemLabel(item)
4069
+ }, key);
4070
+ }), showFetchSentinel && filteredItems.length > 0 ? /* @__PURE__ */ jsx("div", {
4071
+ ref: sentinelRef,
4072
+ "aria-hidden": true,
4073
+ "data-test": "fetch-sentinel",
4074
+ "data-slot": "combobox-fetch-sentinel",
4075
+ className: "absolute bottom-0 h-px w-full"
4076
+ }) : null]
4077
+ });
4078
+ }
4079
+ /**
4080
+ * Builds `ComboboxList`'s render-prop for a GROUPED list: one `ComboboxGroup`
4081
+ * per section, each header plus a collection of leaf rows. Base UI calls the
4082
+ * returned function once per group from the Root's grouped `items`.
4083
+ */
4084
+ function renderGroupSection(renderRow) {
4085
+ return (group) => /* @__PURE__ */ jsxs(ComboboxGroup, {
4086
+ items: group.items,
4087
+ children: [/* @__PURE__ */ jsx(ComboboxLabel, { children: group.label }), /* @__PURE__ */ jsx(ComboboxCollection, { children: renderRow })]
4088
+ }, group.groupKey);
4089
+ }
4090
+ /** The dimmed spinner overlay covering the list while a re-query is in flight. */
4091
+ function ComboboxFilteringOverlay() {
4092
+ return /* @__PURE__ */ jsx("div", {
4093
+ "data-slot": "combobox-loading-overlay",
4094
+ className: "bg-popover/60 absolute inset-0 z-10 flex items-center justify-center",
4095
+ children: /* @__PURE__ */ jsx(Spinner, {})
4096
+ });
4097
+ }
4098
+ /**
4099
+ * A centered spinner row for the filtering and load-more states. Not
4100
+ * `aria-hidden` — the `Spinner`'s `role="status"` announces loading to screen
4101
+ * readers (that's the point of a loading indicator).
4102
+ */
4103
+ function SpinnerRow() {
4104
+ return /* @__PURE__ */ jsx("div", {
4105
+ "data-slot": "combobox-spinner-row",
4106
+ className: "flex justify-center py-2 text-muted-foreground",
4107
+ children: /* @__PURE__ */ jsx(Spinner, {})
4108
+ });
4109
+ }
4110
+ /** Skeleton rows, padded like the list, shown while the initial page loads. */
4111
+ function ComboboxSkeletonRows({ count }) {
4112
+ return /* @__PURE__ */ jsx("div", {
4113
+ "data-slot": "combobox-skeleton-rows",
4114
+ className: "p-1",
4115
+ children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx("div", {
4116
+ "aria-hidden": true,
4117
+ "data-test": "loading-item",
4118
+ "data-slot": "combobox-skeleton-row",
4119
+ className: "flex items-center gap-2 rounded-md p-2",
4120
+ children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" })
4121
+ }, `skeleton-${i}`))
4122
+ });
4123
+ }
4124
+ //#endregion
4125
+ //#region src/lib/use-combobox-item-selection.ts
4126
+ const EMPTY_KEYS = /* @__PURE__ */ new Set();
4127
+ /**
4128
+ * The `onInputValueChange` reasons that forward the new query to `onSearch`:
4129
+ * - `input-change` — real typing/paste.
4130
+ * - `input-clear` — Base UI clears the field itself after a selection.
4131
+ * - `clear-press` — the input's clear (x) button.
4132
+ *
4133
+ * `escape-key` is deliberately absent. Every combobox that uses this hook owns a
4134
+ * popup, so Escape CLOSES that popup rather than clearing the query, and
4135
+ * forwarding it would refetch on every dismissal.
4136
+ *
4137
+ * There used to be a second, INLINE set that added `escape-key`, for a list
4138
+ * rendered with no popup of its own — where Escape was the list's reset rather
4139
+ * than a dismissal. Nothing renders that way any more, so the layout-dependent
4140
+ * choice and the option that selected between the two are both gone.
4141
+ */
4142
+ const SEARCH_TRIGGER_REASONS = /* @__PURE__ */ new Set([
4143
+ "input-change",
4144
+ "input-clear",
4145
+ "clear-press"
4146
+ ]);
4147
+ /**
4148
+ * Bridges a `Set<string>` of selected keys to the item objects Base UI's
4149
+ * Combobox root wants for `value` / `onValueChange`, and gates the input's
4150
+ * value changes down to real search queries.
4136
4151
  *
4137
- * @prop title - Screen-reader-only dialog title. Default: `'Command Palette'`.
4138
- * @prop description - Screen-reader-only dialog description.
4139
- * Default: `'Search for a command to run...'`.
4152
+ * Used by `DataCombobox`, whose three layouts all own a Combobox root and need
4153
+ * the identical selection semantics. Internal to the package: not exported
4154
+ * from `src/index.ts`.
4140
4155
  *
4141
4156
  * @example
4142
4157
  * ```tsx
4143
- * <CommandDialog open={open} onOpenChange={setOpen}>
4144
- * <CommandInput placeholder="Type a command..." />
4145
- * <CommandList>
4146
- * <CommandItem>Profile</CommandItem>
4147
- * </CommandList>
4148
- * </CommandDialog>
4158
+ * const { keys, selectedObjects, commit, handleInputValueChange } =
4159
+ * useComboboxItemSelection({ items, getItemValue, selectedKeys, onSelectionChange });
4149
4160
  * ```
4150
4161
  */
4151
- function CommandDialog(componentProps) {
4152
- const { title = "Command Palette", description = "Search for a command to run...", children } = componentProps, props = _objectWithoutProperties(componentProps, _excluded2$27);
4153
- return /* @__PURE__ */ jsxs(Dialog, _objectSpread2(_objectSpread2({}, props), {}, { children: [/* @__PURE__ */ jsxs(DialogHeader, {
4154
- className: "sr-only",
4155
- children: [/* @__PURE__ */ jsx(DialogTitle, { children: title }), /* @__PURE__ */ jsx(DialogDescription, { children: description })]
4156
- }), /* @__PURE__ */ jsx(DialogContent, {
4157
- className: "overflow-hidden p-0",
4158
- children: /* @__PURE__ */ jsx(Command, {
4159
- className: "[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",
4160
- children
4161
- })
4162
- })] }));
4163
- }
4164
- /**
4165
- * The search field that filters the command list as the user types. Renders an
4166
- * `<input>` inside a `<div>` wrapper with a leading search icon.
4167
- */
4168
- const CommandInput = React.forwardRef((componentProps, forwardRef) => {
4169
- const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded3$20);
4170
- return /* @__PURE__ */ jsxs("div", {
4171
- "data-slot": "command-input-wrapper",
4172
- className: "flex h-9 items-center gap-2 border-b px-3",
4173
- children: [/* @__PURE__ */ jsx(Search, { className: "size-4 shrink-0 opacity-50" }), /* @__PURE__ */ jsx(Command$1.Input, _objectSpread2({
4174
- ref: forwardRef,
4175
- "data-slot": "command-input",
4176
- className: cn("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50", className)
4177
- }, props))]
4162
+ function useComboboxItemSelection(options) {
4163
+ const { items, getItemValue, selectedItems, selectedKeys, defaultSelectedKeys, onSelectionChange, onSearch } = options;
4164
+ const itemCacheRef = React.useRef(/* @__PURE__ */ new Map());
4165
+ if (selectedItems) for (const item of selectedItems) itemCacheRef.current.set(getItemValue(item), item);
4166
+ for (const item of items) itemCacheRef.current.set(getItemValue(item), item);
4167
+ const itemCache = itemCacheRef.current;
4168
+ const [selectionSet, setSelectionSet] = useControllableState({
4169
+ prop: selectedKeys,
4170
+ defaultProp: defaultSelectedKeys
4178
4171
  });
4179
- });
4180
- CommandInput.displayName = "CommandInput";
4181
- /**
4182
- * Scrollable container holding the command groups, items, and empty state.
4183
- * Renders a `<div>` that scrolls vertically when content overflows.
4184
- */
4185
- const CommandList = React.forwardRef((componentProps, forwardRef) => {
4186
- const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded4$17);
4187
- return /* @__PURE__ */ jsx(Command$1.List, _objectSpread2({
4188
- ref: forwardRef,
4189
- "data-slot": "command-list",
4190
- className: cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto", className)
4191
- }, props));
4192
- });
4193
- CommandList.displayName = "CommandList";
4194
- /**
4195
- * Message shown when the current search matches no items. Renders a centered
4196
- * `<div>` that is only visible when the list is empty.
4197
- */
4198
- const CommandEmpty = React.forwardRef((componentProps, forwardRef) => {
4199
- const props = _extends({}, (_objectDestructuringEmpty(componentProps), componentProps));
4200
- return /* @__PURE__ */ jsx(Command$1.Empty, _objectSpread2({
4201
- ref: forwardRef,
4202
- "data-slot": "command-empty",
4203
- className: "py-6 text-center text-sm"
4204
- }, props));
4205
- });
4206
- CommandEmpty.displayName = "CommandEmpty";
4172
+ const keys = selectionSet !== null && selectionSet !== void 0 ? selectionSet : EMPTY_KEYS;
4173
+ const selectedObjects = [];
4174
+ for (const key of keys) {
4175
+ const item = itemCache.get(key);
4176
+ if (item) selectedObjects.push(item);
4177
+ }
4178
+ const commit = React.useCallback((objs, details) => {
4179
+ const next = new Set(objs.map(getItemValue));
4180
+ setSelectionSet(next);
4181
+ onSelectionChange === null || onSelectionChange === void 0 || onSelectionChange(next, details);
4182
+ }, [
4183
+ setSelectionSet,
4184
+ getItemValue,
4185
+ onSelectionChange
4186
+ ]);
4187
+ const lastQueryRef = React.useRef("");
4188
+ return {
4189
+ keys,
4190
+ selectedObjects,
4191
+ commit,
4192
+ handleInputValueChange: onSearch ? (value, details) => {
4193
+ if (SEARCH_TRIGGER_REASONS.has(details.reason)) {
4194
+ lastQueryRef.current = value;
4195
+ onSearch(value);
4196
+ }
4197
+ } : void 0,
4198
+ resetSearch: React.useCallback(() => {
4199
+ if (!onSearch || lastQueryRef.current === "") return;
4200
+ lastQueryRef.current = "";
4201
+ onSearch("");
4202
+ }, [onSearch])
4203
+ };
4204
+ }
4205
+ //#endregion
4206
+ //#region src/components/data-combobox.tsx
4207
4207
  /**
4208
- * Groups related command items under an optional `heading`. Renders a `<div>`
4209
- * that hides itself when none of its items match the search.
4208
+ * Row count at which `DataCombobox` virtualises its rows on its own, when `virtualizeRows` was not
4209
+ * passed either way. Exported so it can be asserted against and tuned in ONE place.
4210
+ *
4211
+ * Crossing it LATCHES virtualisation on for the life of the component - see the `virtualizeRows`
4212
+ * prop doc. A list that declares `onFetchMore` can grow without bound, so it starts out virtualised
4213
+ * regardless of this number rather than waiting to cross it.
4214
+ *
4215
+ * A STARTING POINT, not a measured optimum. The two real data points behind it: 244 countries with
4216
+ * a flag per row was visibly laggy unvirtualised, and the user lists are server-capped at 10 rows
4217
+ * today, so both known cases sit far from this line and the exact value is not load-bearing yet.
4218
+ * Measure before tuning it - the honest cost driver is how expensive `renderItem` is, not the row
4219
+ * count alone, and a threshold cannot see that.
4210
4220
  */
4211
- const CommandGroup = React.forwardRef((componentProps, forwardRef) => {
4212
- const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded5$12);
4213
- return /* @__PURE__ */ jsx(Command$1.Group, _objectSpread2({
4214
- ref: forwardRef,
4215
- "data-slot": "command-group",
4216
- className: cn("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium", className)
4217
- }, props));
4218
- });
4219
- CommandGroup.displayName = "CommandGroup";
4221
+ const COMBOBOX_AUTO_VIRTUALIZE_THRESHOLD = 100;
4220
4222
  /**
4221
- * A thin horizontal divider between command groups or items. Renders a `<div>`
4222
- * one pixel tall.
4223
+ * Row count at which `searchable="auto"` decides a list is long enough to need a search input.
4224
+ *
4225
+ * Exported so a consumer can reason about the boundary rather than re-deriving it, and so the
4226
+ * number lives in ONE place. Comes from the dashboard filter design (Figma node 7959:10798), which
4227
+ * annotates every drawer field as "Combobox - with search if 15+ items".
4228
+ *
4229
+ * Only consulted for `searchable="auto"`. An explicit `true` or `false` always wins, and the
4230
+ * default is still `true`, so no list changes behaviour without asking.
4223
4231
  */
4224
- const CommandSeparator = React.forwardRef((componentProps, forwardRef) => {
4225
- const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded6$10);
4226
- return /* @__PURE__ */ jsx(Command$1.Separator, _objectSpread2({
4227
- ref: forwardRef,
4228
- "data-slot": "command-separator",
4229
- className: cn("bg-border -mx-1 h-px", className)
4230
- }, props));
4231
- });
4232
- CommandSeparator.displayName = "CommandSeparator";
4232
+ const COMBOBOX_AUTO_SEARCH_THRESHOLD = 15;
4233
4233
  /**
4234
- * A single selectable command in the list. Renders a `<div>` that highlights on
4235
- * hover/keyboard selection and can be disabled.
4234
+ * Resolves the tri-state `searchable` prop to the single boolean every layout below reads.
4235
+ *
4236
+ * The `hasServerSearch` disjunct is not a nicety: a server-driven list's `items` is one page, so
4237
+ * its length says nothing about how much data exists. Counting it alone would strip the search box
4238
+ * off a 10-row first page of thousands - the one list that cannot function without one.
4239
+ *
4240
+ * Internal to the package (not exported from `src/index.ts`); exported from this module only so
4241
+ * `data-combobox.test.ts` can assert the predicate without a browser.
4242
+ *
4243
+ * @param searchable The `searchable` prop as passed - `true`, `false`, or `'auto'`.
4244
+ * @param hasServerSearch Whether an `onSearch` handler was provided.
4245
+ * @param itemCount `items.length` for this render.
4236
4246
  */
4237
- const CommandItem = React.forwardRef((componentProps, forwardRef) => {
4238
- const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded7$5);
4239
- return /* @__PURE__ */ jsx(Command$1.Item, _objectSpread2({
4240
- ref: forwardRef,
4241
- "data-slot": "command-item",
4242
- className: cn("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className)
4243
- }, props));
4244
- });
4245
- CommandItem.displayName = "CommandItem";
4247
+ function resolveSearchable(searchable, hasServerSearch, itemCount) {
4248
+ return searchable === "auto" ? hasServerSearch || itemCount >= 15 : searchable;
4249
+ }
4246
4250
  /**
4247
- * Right-aligned hint displaying an item's keyboard shortcut. Renders a `<span>`
4248
- * with muted, spaced-out text.
4251
+ * Whether the auto-virtualisation LATCH should be raised on this render.
4252
+ *
4253
+ * Only ever consulted while the latch is still down - raising it is one-way, so this answering
4254
+ * `false` later never lowers it. A list that can grow without bound (one declaring `onFetchMore`)
4255
+ * says `true` on its very first render rather than waiting to cross the threshold, because it WILL
4256
+ * cross it and the crossing is the expensive part.
4257
+ *
4258
+ * Internal to the package (not exported from `src/index.ts`); exported from this module only so
4259
+ * `data-combobox.test.ts` can assert the predicate without a browser.
4260
+ *
4261
+ * @param hasFetchMore Whether an `onFetchMore` handler was provided.
4262
+ * @param itemCount `items.length` for this render.
4249
4263
  */
4250
- const CommandShortcut = React.forwardRef((componentProps, forwardRef) => {
4251
- const { className } = componentProps, props = _objectWithoutProperties(componentProps, _excluded8$5);
4252
- return /* @__PURE__ */ jsx("span", _objectSpread2({
4253
- ref: forwardRef,
4254
- "data-slot": "command-shortcut",
4255
- className: cn("text-muted-foreground ml-auto text-xs tracking-widest", className)
4256
- }, props));
4257
- });
4258
- CommandShortcut.displayName = "CommandShortcut";
4259
- //#endregion
4260
- //#region src/components/country-flag.tsx
4261
- const _excluded$39 = [
4262
- "countryIsoCode",
4263
- "size",
4264
- "className"
4265
- ];
4266
- const sizeMap = {
4267
- sm: "size-3",
4268
- md: "size-4",
4269
- lg: "size-5",
4270
- xl: "size-6"
4271
- };
4264
+ function shouldAutoVirtualize(hasFetchMore, itemCount) {
4265
+ return hasFetchMore || itemCount >= 100;
4266
+ }
4272
4267
  /**
4273
- * Renders the flag icon for a given country as an inline `<svg>`.
4274
- * Falls back to the US flag when the ISO code has no matching flag.
4268
+ * Resolves the tri-state `virtualizeRows` prop plus the latch into the boolean handed to Base UI.
4275
4269
  *
4276
- * @prop countryIsoCode - ISO country code selecting the flag to render.
4277
- * @prop size - Flag dimensions: `sm` (12px) | `md` (16px) | `lg` (20px) | `xl` (24px). Default: `'xl'`.
4270
+ * Explicit wins over the heuristic, both ways: `true` forces it on below the threshold, `false`
4271
+ * forces it off above one. `'auto'` and omitted resolve the same way, so only an explicit boolean
4272
+ * overrides the latch. A GROUPED list opts out either way - group headers would need a second,
4273
+ * variable-height index space on top of the row one, so grouping means the prerequisite is missing
4274
+ * rather than that virtualisation is merely unwanted.
4278
4275
  *
4279
- * @example
4280
- * ```tsx
4281
- * <CountryFlag countryIsoCode="FR" size="md" />
4282
- * ```
4276
+ * Internal to the package (not exported from `src/index.ts`); exported from this module only so
4277
+ * `data-combobox.test.ts` can assert the precedence without a browser.
4278
+ *
4279
+ * @param requested The `virtualizeRows` prop as passed - `true`, `false`, `'auto'`, or omitted.
4280
+ * @param latched Whether the auto-virtualisation latch is up (see {@link shouldAutoVirtualize}).
4281
+ * @param isGrouped Whether a `getGroupKey` was provided.
4283
4282
  */
4284
- const CountryFlag = React.forwardRef((componentProps, forwardRef) => {
4285
- var _FLAGS$countryIsoCode;
4286
- const { countryIsoCode, size = "xl", className } = componentProps, otherProps = _objectWithoutProperties(componentProps, _excluded$39);
4287
- const CurrentFlag = (_FLAGS$countryIsoCode = FLAGS[countryIsoCode.toLowerCase()]) !== null && _FLAGS$countryIsoCode !== void 0 ? _FLAGS$countryIsoCode : FlagUs;
4288
- return /* @__PURE__ */ jsx(CurrentFlag, _objectSpread2({
4289
- ref: forwardRef,
4290
- className: cn("flex-none", sizeMap[size], className)
4291
- }, otherProps));
4292
- });
4293
- CountryFlag.displayName = "CountryFlag";
4294
- //#endregion
4295
- //#region src/components/data-combobox.tsx
4283
+ function resolveVirtualizeRows(requested, latched, isGrouped) {
4284
+ return (typeof requested === "boolean" ? requested : latched) && !isGrouped;
4285
+ }
4286
+ /**
4287
+ * Scrolls a keyboard-highlighted row into view while rows are virtualised.
4288
+ * A no-op without virtualisation (nothing fills the ref), for a pointer-driven
4289
+ * highlight (the row is already under the cursor, so already mounted), and when
4290
+ * the highlight was cleared (index `-1`).
4291
+ */
4292
+ function scrollHighlightedRowIntoView(scrollRowIntoViewRef, index, reason) {
4293
+ var _scrollRowIntoViewRef;
4294
+ if (reason === "pointer" || index < 0) return;
4295
+ (_scrollRowIntoViewRef = scrollRowIntoViewRef.current) === null || _scrollRowIntoViewRef === void 0 || _scrollRowIntoViewRef.call(scrollRowIntoViewRef, index);
4296
+ }
4296
4297
  /**
4297
4298
  * Searchable dropdown built on the DS Combobox primitives, driven by an `items`
4298
4299
  * array plus `getItemValue`/`getItemLabel`. Renders an inline input (single) or
@@ -4312,9 +4313,14 @@ CountryFlag.displayName = "CountryFlag";
4312
4313
  */
4313
4314
  function DataCombobox(componentProps) {
4314
4315
  var _selectedObjects$;
4315
- const { items, getItemValue, getItemLabel, renderItem, renderChip, getGroupKey, getGroupLabel, selectionMode = "single", selectedKeys, defaultSelectedKeys, onSelectionChange, onOpenChange, selectedItems, disabledKeys, loadingState, skeletonCount, onSearch, onFetchMore, hasMore = false, emptyState, trigger, searchable = true, placeholder, disabled = false, className, contentClassName, "aria-label": ariaLabel, showClear = true } = componentProps;
4316
+ const { items, getItemValue, getItemLabel, renderItem, renderChip, getGroupKey, getGroupLabel, selectionMode = "single", selectedKeys, defaultSelectedKeys, onSelectionChange, onOpenChange, open, selectedItems, disabledKeys, loadingState, skeletonCount, onSearch, onFetchMore, hasMore = false, emptyState, trigger, searchable = true, placeholder, disabled = false, className, contentClassName, anchor, "aria-label": ariaLabel, listAriaLabel, showClear = true, estimateRowHeight } = componentProps;
4316
4317
  const multiple = selectionMode === "multiple";
4317
- const { keys, selectedObjects, commit, handleInputValueChange } = useComboboxItemSelection({
4318
+ const isSearchable = resolveSearchable(searchable, !!onSearch, items.length);
4319
+ const autoVirtualizeLatch = React.useRef(false);
4320
+ if (!autoVirtualizeLatch.current) autoVirtualizeLatch.current = shouldAutoVirtualize(!!onFetchMore, items.length);
4321
+ const virtualizeRows = resolveVirtualizeRows(componentProps.virtualizeRows, autoVirtualizeLatch.current, !!getGroupKey);
4322
+ const scrollRowIntoViewRef = React.useRef(null);
4323
+ const { keys, selectedObjects, commit, handleInputValueChange, resetSearch } = useComboboxItemSelection({
4318
4324
  items,
4319
4325
  getItemValue,
4320
4326
  selectedItems,
@@ -4323,6 +4329,10 @@ function DataCombobox(componentProps) {
4323
4329
  onSelectionChange,
4324
4330
  onSearch
4325
4331
  });
4332
+ const handleOpenChange = (nextOpen, details) => {
4333
+ if (!nextOpen) resetSearch();
4334
+ onOpenChange === null || onOpenChange === void 0 || onOpenChange(nextOpen, details);
4335
+ };
4326
4336
  const groups = useComboboxItemGroups(items, getGroupKey, getGroupLabel);
4327
4337
  const popupRows = /* @__PURE__ */ jsx(ComboboxRows, {
4328
4338
  items,
@@ -4336,12 +4346,20 @@ function DataCombobox(componentProps) {
4336
4346
  onFetchMore,
4337
4347
  hasMore,
4338
4348
  emptyState,
4339
- "aria-label": ariaLabel
4349
+ virtualizeRows,
4350
+ estimateRowHeight,
4351
+ scrollRowIntoViewRef,
4352
+ "aria-label": listAriaLabel !== null && listAriaLabel !== void 0 ? listAriaLabel : ariaLabel
4340
4353
  });
4341
4354
  const chipsAnchor = useComboboxAnchor();
4342
- const overlayLayout = trigger ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Combobox$1.Trigger, { render: trigger }), /* @__PURE__ */ jsxs(ComboboxContent, {
4355
+ const overlayLayout = trigger ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Combobox$1.Trigger, {
4356
+ render: trigger,
4357
+ children: trigger.props.children
4358
+ }), /* @__PURE__ */ jsxs(ComboboxContent, {
4359
+ "aria-label": ariaLabel,
4360
+ anchor,
4343
4361
  className: cn("min-w-50", contentClassName),
4344
- children: [searchable ? /* @__PURE__ */ jsx(ComboboxInput, {
4362
+ children: [isSearchable ? /* @__PURE__ */ jsx(ComboboxInput, {
4345
4363
  showTrigger: false,
4346
4364
  placeholder
4347
4365
  }) : null, popupRows]
@@ -4349,6 +4367,8 @@ function DataCombobox(componentProps) {
4349
4367
  if (multiple) return /* @__PURE__ */ jsx(Combobox, {
4350
4368
  multiple: true,
4351
4369
  autoHighlight: true,
4370
+ virtualized: virtualizeRows,
4371
+ onItemHighlighted: (_item, details) => scrollHighlightedRowIntoView(scrollRowIntoViewRef, details.index, details.reason),
4352
4372
  items: groups !== null && groups !== void 0 ? groups : items,
4353
4373
  disabled,
4354
4374
  filter: onSearch || onFetchMore && hasMore ? null : void 0,
@@ -4358,19 +4378,26 @@ function DataCombobox(componentProps) {
4358
4378
  itemToStringLabel: getItemLabel,
4359
4379
  isItemEqualToValue: (a, b) => getItemValue(a) === getItemValue(b),
4360
4380
  onInputValueChange: handleInputValueChange,
4361
- onOpenChange,
4381
+ open,
4382
+ onOpenChange: handleOpenChange,
4362
4383
  children: trigger ? overlayLayout : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ComboboxChips, {
4363
4384
  ref: chipsAnchor,
4364
4385
  className,
4365
- children: /* @__PURE__ */ jsx(ComboboxValue, { children: (values) => /* @__PURE__ */ jsxs(Fragment, { children: [values.map((item) => renderChip ? /* @__PURE__ */ jsx(React.Fragment, { children: renderChip(item) }, getItemValue(item)) : /* @__PURE__ */ jsx(ComboboxChip, { children: getItemLabel(item) }, getItemValue(item))), /* @__PURE__ */ jsx(ComboboxChipsInput, { placeholder: keys.size === 0 ? placeholder : "" })] }) })
4386
+ children: /* @__PURE__ */ jsx(ComboboxValue, { children: (values) => /* @__PURE__ */ jsxs(Fragment, { children: [values.map((item) => renderChip ? /* @__PURE__ */ jsx(React.Fragment, { children: renderChip(item) }, getItemValue(item)) : /* @__PURE__ */ jsx(ComboboxChip, { children: getItemLabel(item) }, getItemValue(item))), /* @__PURE__ */ jsx(ComboboxChipsInput, {
4387
+ "aria-label": ariaLabel,
4388
+ placeholder: keys.size === 0 ? placeholder : "",
4389
+ readOnly: !isSearchable
4390
+ })] }) })
4366
4391
  }), /* @__PURE__ */ jsx(ComboboxContent, {
4367
- anchor: chipsAnchor,
4392
+ anchor: anchor !== null && anchor !== void 0 ? anchor : chipsAnchor,
4368
4393
  className: cn("min-w-50", contentClassName),
4369
4394
  children: popupRows
4370
4395
  })] })
4371
4396
  }, selectionMode);
4372
4397
  return /* @__PURE__ */ jsx(Combobox, {
4373
4398
  autoHighlight: true,
4399
+ virtualized: virtualizeRows,
4400
+ onItemHighlighted: (_item, details) => scrollHighlightedRowIntoView(scrollRowIntoViewRef, details.index, details.reason),
4374
4401
  items: groups !== null && groups !== void 0 ? groups : items,
4375
4402
  disabled,
4376
4403
  filter: onSearch || onFetchMore && hasMore ? null : void 0,
@@ -4380,13 +4407,17 @@ function DataCombobox(componentProps) {
4380
4407
  itemToStringLabel: getItemLabel,
4381
4408
  isItemEqualToValue: (a, b) => getItemValue(a) === getItemValue(b),
4382
4409
  onInputValueChange: handleInputValueChange,
4383
- onOpenChange,
4410
+ open,
4411
+ onOpenChange: handleOpenChange,
4384
4412
  children: trigger ? overlayLayout : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ComboboxInput, {
4385
4413
  className,
4414
+ "aria-label": ariaLabel,
4386
4415
  placeholder,
4387
4416
  disabled,
4388
- showClear
4417
+ showClear,
4418
+ readOnly: !isSearchable
4389
4419
  }), /* @__PURE__ */ jsx(ComboboxContent, {
4420
+ anchor,
4390
4421
  className: cn("min-w-50", contentClassName),
4391
4422
  children: popupRows
4392
4423
  })] })
@@ -6571,6 +6602,14 @@ function DatePickerFooter({ footer }) {
6571
6602
  children: footer
6572
6603
  });
6573
6604
  }
6605
+ /**
6606
+ * @internal
6607
+ * Coerces an unknown prop value into a `Date`, or `undefined` when it cannot
6608
+ * represent one. Storybook's `control: 'date'` hands back a millisecond number
6609
+ * rather than a `Date`, so `minDate`/`maxDate` must tolerate that shape.
6610
+ *
6611
+ * Exported for `date-picker.test.ts` only. NOT re-exported from `src/index.ts`.
6612
+ */
6574
6613
  const toDateOrUndefined = (v) => {
6575
6614
  if (v == null) return void 0;
6576
6615
  if (v instanceof Date) return isNaN(v.getTime()) ? void 0 : v;
@@ -6579,11 +6618,28 @@ const toDateOrUndefined = (v) => {
6579
6618
  return isNaN(d.getTime()) ? void 0 : d;
6580
6619
  }
6581
6620
  };
6621
+ /**
6622
+ * @internal
6623
+ * Builds the react-day-picker `Matcher[]` that blocks a date. The two bound
6624
+ * matchers are day-exact on purpose: `startOfDay(minDate)` / `endOfDay(maxDate)`
6625
+ * so a `minDate` carrying a time component (`new Date()` mid-afternoon) does not
6626
+ * reject a same-day selection, whose committed value is always local midnight.
6627
+ *
6628
+ * Exported for `date-picker.test.ts` only. NOT re-exported from `src/index.ts`.
6629
+ */
6582
6630
  function buildConstraintMatchers(minDate, maxDate, disabledDates) {
6583
6631
  const base = [{ before: startOfDay(minDate) }, { after: endOfDay(maxDate) }];
6584
6632
  if (!disabledDates) return base;
6585
6633
  return base.concat(Array.isArray(disabledDates) ? disabledDates : [disabledDates]);
6586
6634
  }
6635
+ /**
6636
+ * @internal
6637
+ * Normalises two loose endpoints into a `DateRange` whose `from` is never after
6638
+ * its `to`. A lone `to` is promoted to `from` because react-day-picker cannot
6639
+ * render a range that has no start.
6640
+ *
6641
+ * Exported for `date-picker.test.ts` only. NOT re-exported from `src/index.ts`.
6642
+ */
6587
6643
  function sortRange(a, b) {
6588
6644
  if (!a && !b) return void 0;
6589
6645
  if (!a) return { from: b };
@@ -6607,6 +6663,14 @@ function formatDateForAnnouncement(date, locale) {
6607
6663
  return date.toDateString();
6608
6664
  }
6609
6665
  }
6666
+ /**
6667
+ * @internal
6668
+ * Formats the min/max bound interpolated into the out-of-bounds hint, in the
6669
+ * picker's own locale. Falls back to `toDateString()` when the locale tag is
6670
+ * not one `Intl.DateTimeFormat` accepts.
6671
+ *
6672
+ * Exported for `date-picker.test.ts` only. NOT re-exported from `src/index.ts`.
6673
+ */
6610
6674
  function formatBoundDate(date, locale) {
6611
6675
  try {
6612
6676
  return getCachedDateTimeFormat(locale, {
@@ -6619,8 +6683,11 @@ function formatBoundDate(date, locale) {
6619
6683
  }
6620
6684
  }
6621
6685
  /**
6686
+ * @internal
6622
6687
  * Formats a `Date` as a `yyyy-MM-dd` string using local time (not UTC).
6623
6688
  * Used for hidden form inputs so the submitted value matches the displayed date.
6689
+ *
6690
+ * Exported for `date-picker.test.ts` only. NOT re-exported from `src/index.ts`.
6624
6691
  */
6625
6692
  function formatDateForInput(date) {
6626
6693
  return format(date, "yyyy-MM-dd");
@@ -8956,7 +9023,7 @@ const InlineEditInput = React.forwardRef((componentProps, forwardRef) => {
8956
9023
  });
8957
9024
  InlineEditInput.displayName = "InlineEditInput";
8958
9025
  //#endregion
8959
- //#region src/components/inline-edit-multiselect.tsx
9026
+ //#region src/components/inline-edit-multi-combobox.tsx
8960
9027
  const _excluded$22 = [
8961
9028
  "className",
8962
9029
  "children",
@@ -8971,8 +9038,8 @@ const _excluded2$15 = [
8971
9038
  "emptyMessage",
8972
9039
  "children"
8973
9040
  ];
8974
- /** Context shared between the `InlineEditMultiselect` root and its compound sub-parts. */
8975
- const InlineEditMultiselectContext = React.createContext({});
9041
+ /** Context shared between the `InlineEditMultiCombobox` root and its compound sub-parts. */
9042
+ const InlineEditMultiComboboxContext = React.createContext({});
8976
9043
  /**
8977
9044
  * Wires a commit-on-blur callback that fires once when focus truly leaves the
8978
9045
  * component - the chips row **and** the portaled popup/listbox. Returns handlers to
@@ -9019,24 +9086,24 @@ function useCommitOnBlur(rootRef, getValues, onBlur) {
9019
9086
  };
9020
9087
  }
9021
9088
  /**
9022
- * The chips row of an `InlineEditMultiselect`. Wraps the inline-edit chrome (hover/focus
9089
+ * The chips row of an `InlineEditMultiCombobox`. Wraps the inline-edit chrome (hover/focus
9023
9090
  * affordance) around a Base UI `Combobox.Chips` container that lays out the selected
9024
- * chips and the trailing `InlineEditMultiselectTrigger` in a wrapping flex row.
9091
+ * chips and the trailing `InlineEditMultiComboboxTrigger` in a wrapping flex row.
9025
9092
  *
9026
9093
  * @example
9027
9094
  * ```tsx
9028
- * <InlineEditMultiselectChips>
9029
- * <InlineEditMultiselectValue>{…}</InlineEditMultiselectValue>
9030
- * <InlineEditMultiselectTrigger />
9031
- * </InlineEditMultiselectChips>
9095
+ * <InlineEditMultiComboboxChips>
9096
+ * <InlineEditMultiComboboxValue>{…}</InlineEditMultiComboboxValue>
9097
+ * <InlineEditMultiComboboxTrigger />
9098
+ * </InlineEditMultiComboboxChips>
9032
9099
  * ```
9033
9100
  */
9034
- const InlineEditMultiselectChips = React.forwardRef((componentProps, forwardRef) => {
9101
+ const InlineEditMultiComboboxChips = React.forwardRef((componentProps, forwardRef) => {
9035
9102
  const { "aria-invalid": ariaInvalid, className, id, children } = componentProps;
9036
- const { readOnly } = React.useContext(InlineEditMultiselectContext);
9103
+ const { readOnly } = React.useContext(InlineEditMultiComboboxContext);
9037
9104
  const handleEmptyAreaClick = (e) => {
9038
9105
  if (readOnly || e.target !== e.currentTarget) return;
9039
- const trigger = e.currentTarget.querySelector("[data-slot=\"inline-edit-multiselect-trigger\"]");
9106
+ const trigger = e.currentTarget.querySelector("[data-slot=\"inline-edit-multi-combobox-trigger\"]");
9040
9107
  if (trigger && trigger.getAttribute("aria-expanded") !== "true") trigger.click();
9041
9108
  };
9042
9109
  return /* @__PURE__ */ jsx(InlineEditChrome, {
@@ -9046,7 +9113,7 @@ const InlineEditMultiselectChips = React.forwardRef((componentProps, forwardRef)
9046
9113
  className: cn("items-start", readOnly && "cursor-default", className),
9047
9114
  children: /* @__PURE__ */ jsx(Combobox$1.Chips, {
9048
9115
  ref: forwardRef,
9049
- "data-slot": "inline-edit-multiselect-chips",
9116
+ "data-slot": "inline-edit-multi-combobox-chips",
9050
9117
  id,
9051
9118
  onClick: handleEmptyAreaClick,
9052
9119
  className: cn("relative flex flex-1 min-w-0 flex-wrap items-center gap-1", !readOnly && "cursor-pointer"),
@@ -9054,24 +9121,24 @@ const InlineEditMultiselectChips = React.forwardRef((componentProps, forwardRef)
9054
9121
  })
9055
9122
  });
9056
9123
  });
9057
- InlineEditMultiselectChips.displayName = "InlineEditMultiselectChips";
9124
+ InlineEditMultiComboboxChips.displayName = "InlineEditMultiComboboxChips";
9058
9125
  /**
9059
- * Renders the selected values of an `InlineEditMultiselect`. Pass a render function
9060
- * that maps the array of selected keys to `InlineEditMultiselectChip`s.
9126
+ * Renders the selected values of an `InlineEditMultiCombobox`. Pass a render function
9127
+ * that maps the array of selected keys to `InlineEditMultiComboboxChip`s.
9061
9128
  *
9062
9129
  * @example
9063
9130
  * ```tsx
9064
- * <InlineEditMultiselectValue>
9131
+ * <InlineEditMultiComboboxValue>
9065
9132
  * {(keys: string[]) =>
9066
- * keys.map(key => <InlineEditMultiselectChip key={key}>{labelOf(key)}</InlineEditMultiselectChip>)}
9067
- * </InlineEditMultiselectValue>
9133
+ * keys.map(key => <InlineEditMultiComboboxChip key={key}>{labelOf(key)}</InlineEditMultiComboboxChip>)}
9134
+ * </InlineEditMultiComboboxValue>
9068
9135
  * ```
9069
9136
  */
9070
- function InlineEditMultiselectValue(componentProps) {
9071
- return /* @__PURE__ */ jsx(ComboboxValue, _objectSpread2({ "data-slot": "inline-edit-multiselect-value" }, componentProps));
9137
+ function InlineEditMultiComboboxValue(componentProps) {
9138
+ return /* @__PURE__ */ jsx(ComboboxValue, _objectSpread2({ "data-slot": "inline-edit-multi-combobox-value" }, componentProps));
9072
9139
  }
9073
9140
  /**
9074
- * A single selected-value chip inside `InlineEditMultiselectValue`. Composes the DS
9141
+ * A single selected-value chip inside `InlineEditMultiComboboxValue`. Composes the DS
9075
9142
  * `Chip` with a trailing remove (X) button that unselects the value via Base UI. The
9076
9143
  * remove button is hidden in `readOnly` mode.
9077
9144
  *
@@ -9080,17 +9147,17 @@ function InlineEditMultiselectValue(componentProps) {
9080
9147
  *
9081
9148
  * @example
9082
9149
  * ```tsx
9083
- * <InlineEditMultiselectChip color="blue" tone="medium-light">Urgent</InlineEditMultiselectChip>
9084
- * <InlineEditMultiselectChip legacyColor="#0761B5">Sales</InlineEditMultiselectChip>
9150
+ * <InlineEditMultiComboboxChip color="blue" tone="medium-light">Urgent</InlineEditMultiComboboxChip>
9151
+ * <InlineEditMultiComboboxChip legacyColor="#0761B5">Sales</InlineEditMultiComboboxChip>
9085
9152
  * ```
9086
9153
  */
9087
- const InlineEditMultiselectChip = React.forwardRef((componentProps, forwardRef) => {
9154
+ const InlineEditMultiComboboxChip = React.forwardRef((componentProps, forwardRef) => {
9088
9155
  const { className, children, color, tone, legacyColor, glow } = componentProps, props = _objectWithoutProperties(componentProps, _excluded$22);
9089
- const { readOnly } = React.useContext(InlineEditMultiselectContext);
9156
+ const { readOnly } = React.useContext(InlineEditMultiComboboxContext);
9090
9157
  const t = useDsTranslation("ds");
9091
9158
  return /* @__PURE__ */ jsxs(Combobox$1.Chip, _objectSpread2(_objectSpread2({
9092
9159
  ref: forwardRef,
9093
- "data-slot": "inline-edit-multiselect-chip",
9160
+ "data-slot": "inline-edit-multi-combobox-chip",
9094
9161
  render: /* @__PURE__ */ jsx(Chip, {
9095
9162
  color,
9096
9163
  tone,
@@ -9103,27 +9170,27 @@ const InlineEditMultiselectChip = React.forwardRef((componentProps, forwardRef)
9103
9170
  children
9104
9171
  }), !readOnly && /* @__PURE__ */ jsx(Combobox$1.ChipRemove, { render: /* @__PURE__ */ jsx(ChipRemove, { "aria-label": t("multiselect.remove") }) })] }));
9105
9172
  });
9106
- InlineEditMultiselectChip.displayName = "InlineEditMultiselectChip";
9173
+ InlineEditMultiComboboxChip.displayName = "InlineEditMultiComboboxChip";
9107
9174
  /**
9108
- * The "Add item" trigger of an `InlineEditMultiselect`. Renders an outline `Button`
9175
+ * The "Add item" trigger of an `InlineEditMultiCombobox`. Renders an outline `Button`
9109
9176
  * with a leading plus icon that opens the searchable dropdown. Renders nothing in
9110
9177
  * `readOnly` mode.
9111
9178
  *
9112
9179
  * @example
9113
9180
  * ```tsx
9114
- * <InlineEditMultiselectTrigger>Add label</InlineEditMultiselectTrigger>
9181
+ * <InlineEditMultiComboboxTrigger>Add label</InlineEditMultiComboboxTrigger>
9115
9182
  * ```
9116
9183
  */
9117
- const InlineEditMultiselectTrigger = React.forwardRef((componentProps, forwardRef) => {
9184
+ const InlineEditMultiComboboxTrigger = React.forwardRef((componentProps, forwardRef) => {
9118
9185
  const { children, "aria-label": ariaLabel, id, className } = componentProps;
9119
- const { readOnly } = React.useContext(InlineEditMultiselectContext);
9186
+ const { readOnly } = React.useContext(InlineEditMultiComboboxContext);
9120
9187
  const t = useDsTranslation("ds");
9121
9188
  if (readOnly) return null;
9122
9189
  const label = children !== null && children !== void 0 ? children : t("multiselect.addItem");
9123
9190
  const accessibleLabel = ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : typeof label === "string" ? label : void 0;
9124
9191
  return /* @__PURE__ */ jsxs(Combobox$1.Trigger, {
9125
9192
  ref: forwardRef,
9126
- "data-slot": "inline-edit-multiselect-trigger",
9193
+ "data-slot": "inline-edit-multi-combobox-trigger",
9127
9194
  id,
9128
9195
  "aria-label": accessibleLabel,
9129
9196
  render: /* @__PURE__ */ jsx(Button, {
@@ -9134,28 +9201,28 @@ const InlineEditMultiselectTrigger = React.forwardRef((componentProps, forwardRe
9134
9201
  children: [/* @__PURE__ */ jsx(PlusIcon, {}), label]
9135
9202
  });
9136
9203
  });
9137
- InlineEditMultiselectTrigger.displayName = "InlineEditMultiselectTrigger";
9204
+ InlineEditMultiComboboxTrigger.displayName = "InlineEditMultiComboboxTrigger";
9138
9205
  /**
9139
- * The floating dropdown of an `InlineEditMultiselect`: a search input, an empty-state
9206
+ * The floating dropdown of an `InlineEditMultiCombobox`: a search input, an empty-state
9140
9207
  * message, and the scrollable option list. Portal-rendered and anchored to the
9141
- * `InlineEditMultiselectTrigger`.
9208
+ * `InlineEditMultiComboboxTrigger`.
9142
9209
  *
9143
9210
  * Pass a render function as `children` so the built-in search filters the options (a
9144
9211
  * static list is rendered unfiltered — see the `children` prop note).
9145
9212
  *
9146
9213
  * @example
9147
9214
  * ```tsx
9148
- * <InlineEditMultiselectContent>
9149
- * {(key: string) => <InlineEditMultiselectItem key={key} value={key}>{labelOf(key)}</InlineEditMultiselectItem>}
9150
- * </InlineEditMultiselectContent>
9215
+ * <InlineEditMultiComboboxContent>
9216
+ * {(key: string) => <InlineEditMultiComboboxItem key={key} value={key}>{labelOf(key)}</InlineEditMultiComboboxItem>}
9217
+ * </InlineEditMultiComboboxContent>
9151
9218
  * ```
9152
9219
  */
9153
- const InlineEditMultiselectContent = React.forwardRef((componentProps, forwardRef) => {
9220
+ const InlineEditMultiComboboxContent = React.forwardRef((componentProps, forwardRef) => {
9154
9221
  const { className, searchPlaceholder, emptyMessage, children } = componentProps, props = _objectWithoutProperties(componentProps, _excluded2$15);
9155
9222
  const t = useDsTranslation("ds");
9156
9223
  return /* @__PURE__ */ jsxs(ComboboxContent, _objectSpread2(_objectSpread2({
9157
9224
  ref: forwardRef,
9158
- "data-slot": "inline-edit-multiselect-content",
9225
+ "data-slot": "inline-edit-multi-combobox-content",
9159
9226
  className: cn("w-80", className)
9160
9227
  }, props), {}, { children: [
9161
9228
  /* @__PURE__ */ jsx(ComboboxInput, {
@@ -9166,24 +9233,24 @@ const InlineEditMultiselectContent = React.forwardRef((componentProps, forwardRe
9166
9233
  /* @__PURE__ */ jsx(ComboboxList, { children })
9167
9234
  ] }));
9168
9235
  });
9169
- InlineEditMultiselectContent.displayName = "InlineEditMultiselectContent";
9236
+ InlineEditMultiComboboxContent.displayName = "InlineEditMultiComboboxContent";
9170
9237
  /**
9171
- * A single option row inside `InlineEditMultiselectContent`. Shows a checkmark when
9238
+ * A single option row inside `InlineEditMultiComboboxContent`. Shows a checkmark when
9172
9239
  * selected and toggles selection on click (the dropdown stays open for multi-picking).
9173
9240
  *
9174
9241
  * @example
9175
9242
  * ```tsx
9176
- * <InlineEditMultiselectItem value="urgent">Urgent</InlineEditMultiselectItem>
9243
+ * <InlineEditMultiComboboxItem value="urgent">Urgent</InlineEditMultiComboboxItem>
9177
9244
  * ```
9178
9245
  */
9179
- const InlineEditMultiselectItem = React.forwardRef((componentProps, forwardRef) => {
9246
+ const InlineEditMultiComboboxItem = React.forwardRef((componentProps, forwardRef) => {
9180
9247
  return /* @__PURE__ */ jsx(ComboboxItem, _objectSpread2({
9181
9248
  ref: forwardRef,
9182
- "data-slot": "inline-edit-multiselect-item"
9249
+ "data-slot": "inline-edit-multi-combobox-item"
9183
9250
  }, componentProps));
9184
9251
  });
9185
- InlineEditMultiselectItem.displayName = "InlineEditMultiselectItem";
9186
- function InlineEditMultiselectDataDriven(props) {
9252
+ InlineEditMultiComboboxItem.displayName = "InlineEditMultiComboboxItem";
9253
+ function InlineEditMultiComboboxDataDriven(props) {
9187
9254
  var _ref;
9188
9255
  const { value, defaultValue, onValueChange, onBlur, readOnly, items, getItemValue, getItemLabel, renderItem, renderChip, disabledKeys, placeholder, emptyMessage, addLabel, defaultOpen, "aria-invalid": ariaInvalid, "aria-label": ariaLabel, id, className } = props;
9189
9256
  const contextValue = React.useMemo(() => ({ readOnly }), [readOnly]);
@@ -9202,7 +9269,7 @@ function InlineEditMultiselectDataDriven(props) {
9202
9269
  const item = itemByKey.get(key);
9203
9270
  return item ? getItemLabel(item) : key;
9204
9271
  }, [itemByKey, getItemLabel]);
9205
- return /* @__PURE__ */ jsx(InlineEditMultiselectContext.Provider, {
9272
+ return /* @__PURE__ */ jsx(InlineEditMultiComboboxContext.Provider, {
9206
9273
  value: contextValue,
9207
9274
  children: /* @__PURE__ */ jsx("div", {
9208
9275
  ref: rootRef,
@@ -9219,22 +9286,22 @@ function InlineEditMultiselectDataDriven(props) {
9219
9286
  itemToStringLabel: labelOf,
9220
9287
  readOnly,
9221
9288
  defaultOpen,
9222
- children: [/* @__PURE__ */ jsxs(InlineEditMultiselectChips, {
9289
+ children: [/* @__PURE__ */ jsxs(InlineEditMultiComboboxChips, {
9223
9290
  "aria-invalid": ariaInvalid,
9224
9291
  className,
9225
9292
  id: readOnly ? id : void 0,
9226
- children: [/* @__PURE__ */ jsx(InlineEditMultiselectValue, { children: (selectedKeys) => selectedKeys.map((key) => {
9293
+ children: [/* @__PURE__ */ jsx(InlineEditMultiComboboxValue, { children: (selectedKeys) => selectedKeys.map((key) => {
9227
9294
  const item = itemByKey.get(key);
9228
- return renderChip && item ? /* @__PURE__ */ jsx(React.Fragment, { children: renderChip(item) }, key) : /* @__PURE__ */ jsx(InlineEditMultiselectChip, { children: labelOf(key) }, key);
9229
- }) }), /* @__PURE__ */ jsx(InlineEditMultiselectTrigger, {
9295
+ return renderChip && item ? /* @__PURE__ */ jsx(React.Fragment, { children: renderChip(item) }, key) : /* @__PURE__ */ jsx(InlineEditMultiComboboxChip, { children: labelOf(key) }, key);
9296
+ }) }), /* @__PURE__ */ jsx(InlineEditMultiComboboxTrigger, {
9230
9297
  "aria-label": ariaLabel,
9231
9298
  id,
9232
9299
  children: addLabel
9233
9300
  })]
9234
- }), /* @__PURE__ */ jsx(InlineEditMultiselectContent, {
9301
+ }), /* @__PURE__ */ jsx(InlineEditMultiComboboxContent, {
9235
9302
  searchPlaceholder: placeholder,
9236
9303
  emptyMessage,
9237
- children: (key) => /* @__PURE__ */ jsx(InlineEditMultiselectItem, {
9304
+ children: (key) => /* @__PURE__ */ jsx(InlineEditMultiComboboxItem, {
9238
9305
  value: key,
9239
9306
  disabled: disabledKeys === null || disabledKeys === void 0 ? void 0 : disabledKeys.has(key),
9240
9307
  children: renderItem ? renderItem(itemByKey.get(key)) : labelOf(key)
@@ -9244,7 +9311,7 @@ function InlineEditMultiselectDataDriven(props) {
9244
9311
  })
9245
9312
  });
9246
9313
  }
9247
- function InlineEditMultiselectCompound(props) {
9314
+ function InlineEditMultiComboboxCompound(props) {
9248
9315
  var _ref2;
9249
9316
  const { value, defaultValue, onValueChange, onBlur, readOnly, defaultOpen, children, items, itemToStringLabel } = props;
9250
9317
  const contextValue = React.useMemo(() => ({ readOnly }), [readOnly]);
@@ -9257,7 +9324,7 @@ function InlineEditMultiselectCompound(props) {
9257
9324
  onValueChange === null || onValueChange === void 0 || onValueChange(next);
9258
9325
  }, [onValueChange]);
9259
9326
  const blurHandlers = useCommitOnBlur(rootRef, getValues, onBlur);
9260
- return /* @__PURE__ */ jsx(InlineEditMultiselectContext.Provider, {
9327
+ return /* @__PURE__ */ jsx(InlineEditMultiComboboxContext.Provider, {
9261
9328
  value: contextValue,
9262
9329
  children: /* @__PURE__ */ jsx("div", {
9263
9330
  ref: rootRef,
@@ -9279,9 +9346,9 @@ function InlineEditMultiselectCompound(props) {
9279
9346
  })
9280
9347
  });
9281
9348
  }
9282
- function InlineEditMultiselect(componentProps) {
9283
- if ("getItemValue" in componentProps && componentProps.getItemValue !== void 0) return /* @__PURE__ */ jsx(InlineEditMultiselectDataDriven, _objectSpread2({}, componentProps));
9284
- return /* @__PURE__ */ jsx(InlineEditMultiselectCompound, _objectSpread2({}, componentProps));
9349
+ function InlineEditMultiCombobox(componentProps) {
9350
+ if ("getItemValue" in componentProps && componentProps.getItemValue !== void 0) return /* @__PURE__ */ jsx(InlineEditMultiComboboxDataDriven, _objectSpread2({}, componentProps));
9351
+ return /* @__PURE__ */ jsx(InlineEditMultiComboboxCompound, _objectSpread2({}, componentProps));
9285
9352
  }
9286
9353
  //#endregion
9287
9354
  //#region src/components/inline-edit-select.tsx
@@ -11090,6 +11157,10 @@ function normalizeOptionList(prop) {
11090
11157
  * Mirrors what buildPayload emits (`#value` / `@value`), so a persisted `plainText` note
11091
11158
  * reloads with its pills intact. Text and pills are interleaved so inline void nodes always
11092
11159
  * have text siblings (valid Slate structure).
11160
+ *
11161
+ * @internal Exported for `rich-textarea.test.ts` only - deliberately absent from `src/index.ts`.
11162
+ * It is still reachable as `@aircall/ds/components/rich-textarea` via the `./components/*`
11163
+ * subpath, so treat it as private and do not rely on it from a consumer.
11093
11164
  */
11094
11165
  function parseInlineTokens(line, mentions, tags) {
11095
11166
  const byTrigger = {
@@ -11130,6 +11201,8 @@ function parseInlineTokens(line, mentions, tags) {
11130
11201
  * Builds the initial editor `Value` from the `value` prop. A plain-text string is split on
11131
11202
  * newlines into paragraph blocks, with `#tag`/`@mention` tokens reparsed into pills (see
11132
11203
  * parseInlineTokens); a JSON AST is used as-is.
11204
+ *
11205
+ * @internal Exported for `rich-textarea.test.ts` only - deliberately absent from `src/index.ts`.
11133
11206
  */
11134
11207
  function toInitialValue(value, mentions, tags) {
11135
11208
  if (value === void 0) return [{
@@ -11523,6 +11596,8 @@ const SAFE_LINK_SCHEME = /^(https?|mailto|tel):/i;
11523
11596
  * has - including dangerous ones like `javascript:` - and prepend `http://`. This makes
11524
11597
  * the form forgiving (`google.com`, `example` and typo'd schemes all become links) while
11525
11598
  * never emitting an unsafe href. Empty input stays empty.
11599
+ *
11600
+ * @internal Exported for `rich-textarea.test.ts` only - deliberately absent from `src/index.ts`.
11526
11601
  */
11527
11602
  function normalizeLinkInput(url) {
11528
11603
  const trimmed = (url !== null && url !== void 0 ? url : "").trim();
@@ -12990,7 +13065,7 @@ const Tabs = React.forwardRef((componentProps, forwardRef) => {
12990
13065
  ref: forwardRef,
12991
13066
  "data-slot": "tabs",
12992
13067
  orientation,
12993
- className: cn("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col", className)
13068
+ className: cn("group/tabs flex data-[orientation=horizontal]:flex-col", className)
12994
13069
  }, props));
12995
13070
  });
12996
13071
  Tabs.displayName = "Tabs";
@@ -13231,4 +13306,4 @@ function useAudioGauge(options = {}) {
13231
13306
  };
13232
13307
  }
13233
13308
  //#endregion
13234
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionBar, ActionBarButton, ActionBarContext, ActionBarHeight, Alert, AlertAction, AlertAction as BannerAction, AlertDescription, AlertDescription as BannerDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AlertTitle as BannerTitle, Anchor, Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, AttachmentTrigger, Audio, AudioPlayerBar, AudioPlayerButton, AudioPlayerCurrentTime, AudioPlayerDuration, AudioPlayerManager, AudioPlayerRow, AudioPlayerSkip, AudioPlayerSpeed, AudioPlayerTime, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BadgeGroup, BadgeGroupCount, Banner, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, COMBOBOX_AUTO_VIRTUALIZE_THRESHOLD, Calendar, CalendarDayButton, CalendarDropdown, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Chip, ChipRemove, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxBody, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CounterBadge, CountryFlag, DataCombobox, DataTable, DataTree, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBackdrop, DrawerBar, DrawerClose, DrawerContent, DrawerCreateHandle, DrawerDescription, DrawerFooter, DrawerHeader, DrawerMenu, DrawerMenuCheckboxItem, DrawerMenuGroup, DrawerMenuGroupLabel, DrawerMenuItem, DrawerMenuRadioGroup, DrawerMenuRadioItem, DrawerMenuSeparator, DrawerMenuTrigger, DrawerPanel, DrawerPopup, DrawerPortal, DrawerPrimitive, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerViewport, DropdownMenu, DropdownMenuAddon, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Dropzone, DropzoneActions, DropzoneContent, DropzoneDescription, DropzoneIcon, DropzoneTitle, DropzoneTrigger, DsI18nProvider, EmojiPicker, EmojiPickerCategories, EmojiPickerContent, EmojiPickerTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FAB, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLabelAside, FieldLabelInfo, FieldLabelRow, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Gauge, HoverCard, HoverCardContent, HoverCardTrigger, InlineEditInput, InlineEditMultiselect, InlineEditMultiselectChip, InlineEditMultiselectChips, InlineEditMultiselectContent, InlineEditMultiselectItem, InlineEditMultiselectTrigger, InlineEditMultiselectValue, InlineEditSelect, InlineEditSelectContent, InlineEditSelectItem, InlineEditSelectTrigger, InlineEditSelectValue, InlineEditTextarea, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupRichTextarea, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Label, List, ListCol, ListRow, NotificationQueueProvider, NotificationSlot, NumericInput, NumericInputControl, NumericInputDecrement, NumericInputIncrement, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RadioGroup, RadioGroupItem, RichTextarea, RichTextareaContent, RichTextareaRoot, RichTextareaToolbar, SUPPORTED_LANGUAGES, ScrollArea, ScrollAreaPrimitive, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Stepper, StepperContent, StepperCounter, StepperPanel, StepperProgress, Switch, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Tree, TreeDragLine, TreeItem, TreeItemLabel, alertVariants, anchorVariants, bannerVariants, buttonGroupVariants, buttonVariants, cn, counterBadgeVariants, detectInitialLanguage, fabVariants, isInsideCalendarDropdown, registerI18nNamespace, selectTriggerVariants, spinnerVariants, syncDsLanguage, toast, toggleVariants, useAudioGauge, useAudioPlayer, useAudioPlayerTime, useComboboxAnchor, useDsLocale, useDsTranslation, useNotification, useNotificationQueue, useSidebar, useStepper, useTheme };
13309
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionBar, ActionBarButton, ActionBarContext, ActionBarHeight, Alert, AlertAction, AlertAction as BannerAction, AlertDescription, AlertDescription as BannerDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AlertTitle as BannerTitle, Anchor, Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, AttachmentTrigger, Audio, AudioPlayerBar, AudioPlayerButton, AudioPlayerCurrentTime, AudioPlayerDuration, AudioPlayerManager, AudioPlayerRow, AudioPlayerSkip, AudioPlayerSpeed, AudioPlayerTime, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BadgeGroup, BadgeGroupCount, Banner, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, COMBOBOX_AUTO_SEARCH_THRESHOLD, COMBOBOX_AUTO_VIRTUALIZE_THRESHOLD, Calendar, CalendarDayButton, CalendarDropdown, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Chip, ChipRemove, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CounterBadge, CountryFlag, DataCombobox, DataTable, DataTree, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBackdrop, DrawerBar, DrawerClose, DrawerContent, DrawerCreateHandle, DrawerDescription, DrawerFooter, DrawerHeader, DrawerMenu, DrawerMenuCheckboxItem, DrawerMenuGroup, DrawerMenuGroupLabel, DrawerMenuItem, DrawerMenuRadioGroup, DrawerMenuRadioItem, DrawerMenuSeparator, DrawerMenuTrigger, DrawerPanel, DrawerPopup, DrawerPortal, DrawerPrimitive, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerViewport, DropdownMenu, DropdownMenuAddon, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Dropzone, DropzoneActions, DropzoneContent, DropzoneDescription, DropzoneIcon, DropzoneTitle, DropzoneTrigger, DsI18nProvider, EmojiPicker, EmojiPickerCategories, EmojiPickerContent, EmojiPickerTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FAB, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLabelAside, FieldLabelInfo, FieldLabelRow, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Gauge, HoverCard, HoverCardContent, HoverCardTrigger, InlineEditInput, InlineEditMultiCombobox, InlineEditMultiComboboxChip, InlineEditMultiComboboxChips, InlineEditMultiComboboxContent, InlineEditMultiComboboxItem, InlineEditMultiComboboxTrigger, InlineEditMultiComboboxValue, InlineEditSelect, InlineEditSelectContent, InlineEditSelectItem, InlineEditSelectTrigger, InlineEditSelectValue, InlineEditTextarea, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupRichTextarea, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Label, List, ListCol, ListRow, NotificationQueueProvider, NotificationSlot, NumericInput, NumericInputControl, NumericInputDecrement, NumericInputIncrement, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RadioGroup, RadioGroupItem, RichTextarea, RichTextareaContent, RichTextareaRoot, RichTextareaToolbar, SUPPORTED_LANGUAGES, ScrollArea, ScrollAreaPrimitive, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Stepper, StepperContent, StepperCounter, StepperPanel, StepperProgress, Switch, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Tree, TreeDragLine, TreeItem, TreeItemLabel, alertVariants, anchorVariants, bannerVariants, buttonGroupVariants, buttonVariants, cn, counterBadgeVariants, detectInitialLanguage, fabVariants, isInsideCalendarDropdown, registerI18nNamespace, selectTriggerVariants, spinnerVariants, syncDsLanguage, toast, toggleVariants, useAudioGauge, useAudioPlayer, useAudioPlayerTime, useComboboxAnchor, useDsLocale, useDsTranslation, useNotification, useNotificationQueue, useSidebar, useStepper, useTheme };