@lumx/react 4.27.1-alpha.0 → 4.27.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/index.d.ts +37 -34
  2. package/index.js +777 -665
  3. package/index.js.map +1 -1
  4. package/package.json +3 -3
package/index.js CHANGED
@@ -3,7 +3,7 @@ export * from '@lumx/core/js/constants';
3
3
  export * from '@lumx/core/js/types';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
  import * as React from 'react';
6
- import React__default, { useState, useEffect, useMemo, useRef, useCallback, Children, useLayoutEffect, cloneElement, useContext, createContext, useReducer } from 'react';
6
+ import React__default, { useState, useEffect, useMemo, useRef, useCallback, Children, useLayoutEffect, cloneElement, createContext, useContext, useReducer } from 'react';
7
7
  import * as ReactDOM from 'react-dom';
8
8
  import ReactDOM__default from 'react-dom';
9
9
  import { classNames, onEscapePressed, onEnterPressed as onEnterPressed$1, detectHorizontalSwipe } from '@lumx/core/js/utils';
@@ -565,10 +565,10 @@ const COMPONENT_NAME$1J = 'AlertDialog';
565
565
  /**
566
566
  * Component default class name and class prefix.
567
567
  */
568
- const CLASSNAME$1F = 'lumx-alert-dialog';
568
+ const CLASSNAME$1G = 'lumx-alert-dialog';
569
569
  const {
570
570
  block: block$1e
571
- } = bem(CLASSNAME$1F);
571
+ } = bem(CLASSNAME$1G);
572
572
 
573
573
  /**
574
574
  * Component default props.
@@ -735,7 +735,7 @@ const AlertDialog = forwardRef((props, ref) => {
735
735
  });
736
736
  });
737
737
  AlertDialog.displayName = COMPONENT_NAME$1J;
738
- AlertDialog.className = CLASSNAME$1F;
738
+ AlertDialog.className = CLASSNAME$1G;
739
739
  AlertDialog.defaultProps = DEFAULT_PROPS$1l;
740
740
 
741
741
  /**
@@ -833,7 +833,7 @@ const COMPONENT_NAME$1I = 'Autocomplete';
833
833
  /**
834
834
  * Component default class name and class prefix.
835
835
  */
836
- const CLASSNAME$1E = 'lumx-autocomplete';
836
+ const CLASSNAME$1F = 'lumx-autocomplete';
837
837
 
838
838
  /**
839
839
  * Component default props.
@@ -901,7 +901,7 @@ const Autocomplete = forwardRef((props, ref) => {
901
901
  return /*#__PURE__*/jsxs("div", {
902
902
  ref: ref,
903
903
  ...forwardedProps,
904
- className: classNames.join(className, CLASSNAME$1E),
904
+ className: classNames.join(className, CLASSNAME$1F),
905
905
  children: [/*#__PURE__*/jsx(TextField, {
906
906
  ...textFieldProps,
907
907
  chips: chips,
@@ -942,7 +942,7 @@ const Autocomplete = forwardRef((props, ref) => {
942
942
  });
943
943
  });
944
944
  Autocomplete.displayName = COMPONENT_NAME$1I;
945
- Autocomplete.className = CLASSNAME$1E;
945
+ Autocomplete.className = CLASSNAME$1F;
946
946
  Autocomplete.defaultProps = DEFAULT_PROPS$1k;
947
947
 
948
948
  /**
@@ -953,7 +953,7 @@ const COMPONENT_NAME$1H = 'AutocompleteMultiple';
953
953
  /**
954
954
  * Component default class name and class prefix.
955
955
  */
956
- const CLASSNAME$1D = 'lumx-autocomplete-multiple';
956
+ const CLASSNAME$1E = 'lumx-autocomplete-multiple';
957
957
 
958
958
  /**
959
959
  * Component default props.
@@ -1034,7 +1034,7 @@ const AutocompleteMultiple = forwardRef((props, ref) => {
1034
1034
  ref: ref,
1035
1035
  ...forwardedProps,
1036
1036
  anchorToInput: anchorToInput,
1037
- className: classNames.join(className, CLASSNAME$1D),
1037
+ className: classNames.join(className, CLASSNAME$1E),
1038
1038
  name: name,
1039
1039
  value: value,
1040
1040
  onChange: onChange,
@@ -1068,7 +1068,7 @@ const AutocompleteMultiple = forwardRef((props, ref) => {
1068
1068
  });
1069
1069
  });
1070
1070
  AutocompleteMultiple.displayName = COMPONENT_NAME$1H;
1071
- AutocompleteMultiple.className = CLASSNAME$1D;
1071
+ AutocompleteMultiple.className = CLASSNAME$1E;
1072
1072
  AutocompleteMultiple.defaultProps = DEFAULT_PROPS$1j;
1073
1073
 
1074
1074
  /**
@@ -1079,11 +1079,11 @@ const COMPONENT_NAME$1G = 'Avatar';
1079
1079
  /**
1080
1080
  * Component default class name and class prefix.
1081
1081
  */
1082
- const CLASSNAME$1C = 'lumx-avatar';
1082
+ const CLASSNAME$1D = 'lumx-avatar';
1083
1083
  const {
1084
1084
  block: block$1d,
1085
1085
  element: element$U
1086
- } = bem(CLASSNAME$1C);
1086
+ } = bem(CLASSNAME$1D);
1087
1087
 
1088
1088
  /**
1089
1089
  * Component default props.
@@ -1175,7 +1175,7 @@ const Avatar = forwardRef((props, ref) => {
1175
1175
  });
1176
1176
  });
1177
1177
  Avatar.displayName = COMPONENT_NAME$1G;
1178
- Avatar.className = CLASSNAME$1C;
1178
+ Avatar.className = CLASSNAME$1D;
1179
1179
  Avatar.defaultProps = DEFAULT_PROPS$1i;
1180
1180
 
1181
1181
  /**
@@ -1186,10 +1186,10 @@ const COMPONENT_NAME$1F = 'Badge';
1186
1186
  /**
1187
1187
  * Component default class name and class prefix.
1188
1188
  */
1189
- const CLASSNAME$1B = 'lumx-badge';
1189
+ const CLASSNAME$1C = 'lumx-badge';
1190
1190
  const {
1191
1191
  block: block$1c
1192
- } = bem(CLASSNAME$1B);
1192
+ } = bem(CLASSNAME$1C);
1193
1193
 
1194
1194
  /**
1195
1195
  * Component default props.
@@ -1222,7 +1222,7 @@ const Badge$1 = props => {
1222
1222
  });
1223
1223
  };
1224
1224
  Badge$1.displayName = COMPONENT_NAME$1F;
1225
- Badge$1.className = CLASSNAME$1B;
1225
+ Badge$1.className = CLASSNAME$1C;
1226
1226
  Badge$1.defaultProps = DEFAULT_PROPS$1h;
1227
1227
 
1228
1228
  /**
@@ -1247,11 +1247,11 @@ Badge.className = Badge$1.className;
1247
1247
  Badge.defaultProps = Badge$1.defaultProps;
1248
1248
 
1249
1249
  const COMPONENT_NAME$1E = 'BadgeWrapper';
1250
- const CLASSNAME$1A = 'lumx-badge-wrapper';
1250
+ const CLASSNAME$1B = 'lumx-badge-wrapper';
1251
1251
  const {
1252
1252
  block: block$1b,
1253
1253
  element: element$T
1254
- } = bem(CLASSNAME$1A);
1254
+ } = bem(CLASSNAME$1B);
1255
1255
  const BadgeWrapper$1 = props => {
1256
1256
  const {
1257
1257
  badge,
@@ -1278,7 +1278,7 @@ const BadgeWrapper = forwardRef((props, ref) => {
1278
1278
  });
1279
1279
  });
1280
1280
  BadgeWrapper.displayName = COMPONENT_NAME$1E;
1281
- BadgeWrapper.className = CLASSNAME$1A;
1281
+ BadgeWrapper.className = CLASSNAME$1B;
1282
1282
 
1283
1283
  /**
1284
1284
  * Render clickable element (link, button or custom element)
@@ -1441,10 +1441,10 @@ const COMPONENT_NAME$1C = 'Button';
1441
1441
  /**
1442
1442
  * Component default class name and class prefix.
1443
1443
  */
1444
- const CLASSNAME$1z = 'lumx-button';
1444
+ const CLASSNAME$1A = 'lumx-button';
1445
1445
  const {
1446
1446
  modifier
1447
- } = bem(CLASSNAME$1z);
1447
+ } = bem(CLASSNAME$1A);
1448
1448
 
1449
1449
  /**
1450
1450
  * Component default props.
@@ -1482,7 +1482,7 @@ const Button$1 = props => {
1482
1482
  });
1483
1483
  };
1484
1484
  Button$1.displayName = COMPONENT_NAME$1C;
1485
- Button$1.className = CLASSNAME$1z;
1485
+ Button$1.className = CLASSNAME$1A;
1486
1486
  Button$1.defaultProps = DEFAULT_PROPS$1g;
1487
1487
 
1488
1488
  /**
@@ -1557,7 +1557,7 @@ const Button = forwardRef((props, ref) => {
1557
1557
  });
1558
1558
  });
1559
1559
  Button.displayName = COMPONENT_NAME$1C;
1560
- Button.className = CLASSNAME$1z;
1560
+ Button.className = CLASSNAME$1A;
1561
1561
  Button.defaultProps = DEFAULT_PROPS$1g;
1562
1562
 
1563
1563
  const COMPONENT_NAME$1B = 'Icon';
@@ -1567,10 +1567,10 @@ const IconClassName = 'lumx-icon';
1567
1567
  * Defines the props of the component.
1568
1568
  */
1569
1569
 
1570
- const CLASSNAME$1y = IconClassName;
1570
+ const CLASSNAME$1z = IconClassName;
1571
1571
  const {
1572
1572
  block: block$1a
1573
- } = bem(CLASSNAME$1y);
1573
+ } = bem(CLASSNAME$1z);
1574
1574
 
1575
1575
  /**
1576
1576
  * Component default props.
@@ -1654,7 +1654,7 @@ const Icon$1 = props => {
1654
1654
  });
1655
1655
  };
1656
1656
  Icon$1.displayName = COMPONENT_NAME$1B;
1657
- Icon$1.className = CLASSNAME$1y;
1657
+ Icon$1.className = CLASSNAME$1z;
1658
1658
  Icon$1.defaultProps = DEFAULT_PROPS$1f;
1659
1659
 
1660
1660
  /**
@@ -1665,7 +1665,7 @@ const COMPONENT_NAME$1A = 'IconButton';
1665
1665
  /**
1666
1666
  * Component default class name and class prefix.
1667
1667
  */
1668
- const CLASSNAME$1x = 'lumx-icon-button';
1668
+ const CLASSNAME$1y = 'lumx-icon-button';
1669
1669
 
1670
1670
  /**
1671
1671
  * Component default props.
@@ -1707,7 +1707,7 @@ const IconButton$1 = props => {
1707
1707
  });
1708
1708
  };
1709
1709
  IconButton$1.displayName = COMPONENT_NAME$1A;
1710
- IconButton$1.className = CLASSNAME$1x;
1710
+ IconButton$1.className = CLASSNAME$1y;
1711
1711
  IconButton$1.defaultProps = DEFAULT_PROPS$1e;
1712
1712
 
1713
1713
  /**
@@ -1752,7 +1752,7 @@ const IconButton = forwardRef((props, ref) => {
1752
1752
  });
1753
1753
  });
1754
1754
  IconButton.displayName = COMPONENT_NAME$1A;
1755
- IconButton.className = CLASSNAME$1x;
1755
+ IconButton.className = CLASSNAME$1y;
1756
1756
  IconButton.defaultProps = DEFAULT_PROPS$1e;
1757
1757
 
1758
1758
  /**
@@ -1763,7 +1763,7 @@ const COMPONENT_NAME$1z = 'ButtonGroup';
1763
1763
  /**
1764
1764
  * Component default class name and class prefix.
1765
1765
  */
1766
- const CLASSNAME$1w = 'lumx-button-group';
1766
+ const CLASSNAME$1x = 'lumx-button-group';
1767
1767
 
1768
1768
  /**
1769
1769
  * Component default props.
@@ -1784,12 +1784,12 @@ const ButtonGroup$1 = props => {
1784
1784
  } = props;
1785
1785
  return /*#__PURE__*/jsx("div", {
1786
1786
  ...forwardedProps,
1787
- className: classnames(className, CLASSNAME$1w),
1787
+ className: classnames(className, CLASSNAME$1x),
1788
1788
  children: children
1789
1789
  });
1790
1790
  };
1791
1791
  ButtonGroup$1.displayName = COMPONENT_NAME$1z;
1792
- ButtonGroup$1.className = CLASSNAME$1w;
1792
+ ButtonGroup$1.className = CLASSNAME$1x;
1793
1793
  ButtonGroup$1.defaultProps = DEFAULT_PROPS$1d;
1794
1794
 
1795
1795
  /**
@@ -1806,7 +1806,7 @@ const ButtonGroup = forwardRef((props, ref) => {
1806
1806
  });
1807
1807
  });
1808
1808
  ButtonGroup.displayName = COMPONENT_NAME$1z;
1809
- ButtonGroup.className = CLASSNAME$1w;
1809
+ ButtonGroup.className = CLASSNAME$1x;
1810
1810
  ButtonGroup.defaultProps = DEFAULT_PROPS$1d;
1811
1811
 
1812
1812
  /**
@@ -1817,10 +1817,10 @@ const COMPONENT_NAME$1y = 'Card';
1817
1817
  /**
1818
1818
  * Component default class name and class prefix.
1819
1819
  */
1820
- const CLASSNAME$1v = 'lumx-card';
1820
+ const CLASSNAME$1w = 'lumx-card';
1821
1821
  const {
1822
1822
  block: block$19
1823
- } = bem(CLASSNAME$1v);
1823
+ } = bem(CLASSNAME$1w);
1824
1824
 
1825
1825
  /**
1826
1826
  * Component default props.
@@ -1877,16 +1877,16 @@ const Card = Object.assign(forwardRefPolymorphic((props, ref) => {
1877
1877
  });
1878
1878
  }), {
1879
1879
  displayName: COMPONENT_NAME$1y,
1880
- className: CLASSNAME$1v,
1880
+ className: CLASSNAME$1w,
1881
1881
  defaultProps: DEFAULT_PROPS$1c
1882
1882
  });
1883
1883
 
1884
1884
  const COMPONENT_NAME$1x = 'InputLabel';
1885
1885
  const InputLabelClassName = 'lumx-input-label';
1886
- const CLASSNAME$1u = InputLabelClassName;
1886
+ const CLASSNAME$1v = InputLabelClassName;
1887
1887
  const {
1888
1888
  block: block$18
1889
- } = bem(CLASSNAME$1u);
1889
+ } = bem(CLASSNAME$1v);
1890
1890
  const DEFAULT_PROPS$1b = {};
1891
1891
 
1892
1892
  /**
@@ -1918,7 +1918,7 @@ function InputLabel$1(props) {
1918
1918
  });
1919
1919
  }
1920
1920
  InputLabel$1.displayName = COMPONENT_NAME$1x;
1921
- InputLabel$1.className = CLASSNAME$1u;
1921
+ InputLabel$1.className = CLASSNAME$1v;
1922
1922
  InputLabel$1.defaultProps = DEFAULT_PROPS$1b;
1923
1923
 
1924
1924
  const INPUT_HELPER_CONFIGURATION = {
@@ -1940,10 +1940,10 @@ const InputHelperClassName = 'lumx-input-helper';
1940
1940
  * Defines the props of the component.
1941
1941
  */
1942
1942
 
1943
- const CLASSNAME$1t = InputHelperClassName;
1943
+ const CLASSNAME$1u = InputHelperClassName;
1944
1944
  const {
1945
1945
  block: block$17
1946
- } = bem(CLASSNAME$1t);
1946
+ } = bem(CLASSNAME$1u);
1947
1947
 
1948
1948
  /**
1949
1949
  * Component default props.
@@ -1978,7 +1978,7 @@ function InputHelper$1(props) {
1978
1978
  });
1979
1979
  }
1980
1980
  InputHelper$1.displayName = COMPONENT_NAME$1w;
1981
- InputHelper$1.className = CLASSNAME$1t;
1981
+ InputHelper$1.className = CLASSNAME$1u;
1982
1982
  InputHelper$1.defaultProps = DEFAULT_PROPS$1a;
1983
1983
 
1984
1984
  const INTERMEDIATE_STATE = 'intermediate';
@@ -1995,11 +1995,11 @@ const COMPONENT_NAME$1v = 'Checkbox';
1995
1995
  /**
1996
1996
  * Component default class name and class prefix.
1997
1997
  */
1998
- const CLASSNAME$1s = 'lumx-checkbox';
1998
+ const CLASSNAME$1t = 'lumx-checkbox';
1999
1999
  const {
2000
2000
  block: block$16,
2001
2001
  element: element$S
2002
- } = bem(CLASSNAME$1s);
2002
+ } = bem(CLASSNAME$1t);
2003
2003
 
2004
2004
  /**
2005
2005
  * Checkbox component.
@@ -2155,7 +2155,7 @@ const Checkbox = forwardRef((props, ref) => {
2155
2155
  });
2156
2156
  });
2157
2157
  Checkbox.displayName = COMPONENT_NAME$1v;
2158
- Checkbox.className = CLASSNAME$1s;
2158
+ Checkbox.className = CLASSNAME$1t;
2159
2159
  Checkbox.defaultProps = DEFAULT_PROPS$19;
2160
2160
 
2161
2161
  /**
@@ -2182,11 +2182,11 @@ const COMPONENT_NAME$1u = 'Chip';
2182
2182
  /**
2183
2183
  * Component default class name and class prefix.
2184
2184
  */
2185
- const CLASSNAME$1r = 'lumx-chip';
2185
+ const CLASSNAME$1s = 'lumx-chip';
2186
2186
  const {
2187
2187
  block: block$15,
2188
2188
  element: element$R
2189
- } = bem(CLASSNAME$1r);
2189
+ } = bem(CLASSNAME$1s);
2190
2190
 
2191
2191
  /**
2192
2192
  * Component default props.
@@ -2339,7 +2339,7 @@ const Chip = forwardRef((props, ref) => {
2339
2339
  });
2340
2340
  });
2341
2341
  Chip.displayName = COMPONENT_NAME$1u;
2342
- Chip.className = CLASSNAME$1r;
2342
+ Chip.className = CLASSNAME$1s;
2343
2343
  Chip.defaultProps = DEFAULT_PROPS$18;
2344
2344
 
2345
2345
  /**
@@ -2350,7 +2350,7 @@ const COMPONENT_NAME$1t = 'ChipGroup';
2350
2350
  /**
2351
2351
  * Component default class name and class prefix.
2352
2352
  */
2353
- const CLASSNAME$1q = 'lumx-chip-group';
2353
+ const CLASSNAME$1r = 'lumx-chip-group';
2354
2354
 
2355
2355
  /**
2356
2356
  * Component default props.
@@ -2373,7 +2373,7 @@ const ChipGroup$1 = props => {
2373
2373
  return /*#__PURE__*/jsx("div", {
2374
2374
  ref: ref,
2375
2375
  ...forwardedProps,
2376
- className: classnames(className, CLASSNAME$1q),
2376
+ className: classnames(className, CLASSNAME$1r),
2377
2377
  children: children
2378
2378
  });
2379
2379
  };
@@ -2452,7 +2452,7 @@ const InternalChipGroup = forwardRef((props, ref) => {
2452
2452
  });
2453
2453
  });
2454
2454
  InternalChipGroup.displayName = COMPONENT_NAME$1t;
2455
- InternalChipGroup.className = CLASSNAME$1q;
2455
+ InternalChipGroup.className = CLASSNAME$1r;
2456
2456
  InternalChipGroup.defaultProps = DEFAULT_PROPS$17;
2457
2457
  const ChipGroup = Object.assign(InternalChipGroup, {
2458
2458
  useChipGroupNavigation
@@ -2466,11 +2466,11 @@ const COMPONENT_NAME$1s = 'SelectionChipGroup';
2466
2466
  /**
2467
2467
  * Component default class name and class prefix.
2468
2468
  */
2469
- const CLASSNAME$1p = 'lumx-selection-chip-group';
2469
+ const CLASSNAME$1q = 'lumx-selection-chip-group';
2470
2470
  const {
2471
2471
  block: block$14,
2472
2472
  element: element$Q
2473
- } = bem(CLASSNAME$1p);
2473
+ } = bem(CLASSNAME$1q);
2474
2474
 
2475
2475
  /**
2476
2476
  * SelectionChipGroup component.
@@ -2566,10 +2566,10 @@ function createSelectorTreeWalker(container, selector) {
2566
2566
  }
2567
2567
 
2568
2568
  /** CSS selector for enabled chips (not aria-disabled). */
2569
- const ENABLED_CHIP_SELECTOR = `.${CLASSNAME$1r}:not([aria-disabled="true"])`;
2569
+ const ENABLED_CHIP_SELECTOR = `.${CLASSNAME$1s}:not([aria-disabled="true"])`;
2570
2570
 
2571
2571
  /** Find the closest chip element from an event target. */
2572
- const getChip = target => target?.closest?.(`.${CLASSNAME$1r}`) || null;
2572
+ const getChip = target => target?.closest?.(`.${CLASSNAME$1s}`) || null;
2573
2573
 
2574
2574
  /** Whether the chip is marked as disabled via aria-disabled. */
2575
2575
  const isChipDisabled = chip => chip?.getAttribute('aria-disabled') === 'true';
@@ -2815,10 +2815,10 @@ const COMPONENT_NAME$1r = 'Text';
2815
2815
  /**
2816
2816
  * Component default class name and class prefix.
2817
2817
  */
2818
- const CLASSNAME$1o = 'lumx-text';
2818
+ const CLASSNAME$1p = 'lumx-text';
2819
2819
  const {
2820
2820
  block: block$13
2821
- } = bem(CLASSNAME$1o);
2821
+ } = bem(CLASSNAME$1p);
2822
2822
 
2823
2823
  /**
2824
2824
  * Component default props.
@@ -2909,7 +2909,7 @@ const Text = forwardRef((props, ref) => {
2909
2909
  });
2910
2910
  });
2911
2911
  Text.displayName = COMPONENT_NAME$1r;
2912
- Text.className = CLASSNAME$1o;
2912
+ Text.className = CLASSNAME$1p;
2913
2913
  Text.defaultProps = DEFAULT_PROPS$16;
2914
2914
 
2915
2915
  /**
@@ -5007,11 +5007,11 @@ const COMPONENT_NAME$1q = 'Tooltip';
5007
5007
  /**
5008
5008
  * Component default class name and class prefix.
5009
5009
  */
5010
- const CLASSNAME$1n = 'lumx-tooltip';
5010
+ const CLASSNAME$1o = 'lumx-tooltip';
5011
5011
  const {
5012
5012
  block: block$12,
5013
5013
  element: element$P
5014
- } = bem(CLASSNAME$1n);
5014
+ } = bem(CLASSNAME$1o);
5015
5015
 
5016
5016
  /**
5017
5017
  * Props for the TooltipPopup rendering component.
@@ -5061,7 +5061,7 @@ const TooltipPopup = props => {
5061
5061
  });
5062
5062
  };
5063
5063
  TooltipPopup.displayName = COMPONENT_NAME$1q;
5064
- TooltipPopup.className = CLASSNAME$1n;
5064
+ TooltipPopup.className = CLASSNAME$1o;
5065
5065
 
5066
5066
  /**
5067
5067
  * Add ref and ARIA attribute(s) in tooltip children or wrapped children.
@@ -5424,7 +5424,7 @@ const Tooltip = forwardRef((props, ref) => {
5424
5424
  });
5425
5425
  });
5426
5426
  Tooltip.displayName = COMPONENT_NAME$1q;
5427
- Tooltip.className = CLASSNAME$1n;
5427
+ Tooltip.className = CLASSNAME$1o;
5428
5428
  Tooltip.defaultProps = DEFAULT_PROPS$15;
5429
5429
 
5430
5430
  /** Create a pending navigation store; discards intent on abort. */
@@ -5651,7 +5651,7 @@ function createListFocusNavigation(options, callbacks, signal) {
5651
5651
  * @param initialItem Optional item to silently pre-select on creation (no callbacks fired).
5652
5652
  */
5653
5653
  function createActiveItemState(callbacks, signal, initialItem) {
5654
- let activeItem = null;
5654
+ let activeItem = initialItem ?? null;
5655
5655
  function clear() {
5656
5656
  if (activeItem) {
5657
5657
  callbacks.onDeactivate(activeItem);
@@ -6294,8 +6294,8 @@ const SelectionChipGroup = ({
6294
6294
  }, [container, inputRef, getOptionId]);
6295
6295
  useRovingTabIndexContainer({
6296
6296
  containerRef: container,
6297
- itemSelector: `.${CLASSNAME$1r}`,
6298
- itemDisabledSelector: `.${CLASSNAME$1r}[aria-disabled="true"]`
6297
+ itemSelector: `.${CLASSNAME$1s}`,
6298
+ itemDisabledSelector: `.${CLASSNAME$1s}[aria-disabled="true"]`
6299
6299
  });
6300
6300
 
6301
6301
  // Merge getChipProps and renderChip: getChipProps provides base props, renderChip overrides them,
@@ -6336,7 +6336,7 @@ const SelectionChipGroup = ({
6336
6336
  });
6337
6337
  };
6338
6338
  SelectionChipGroup.displayName = COMPONENT_NAME$1s;
6339
- SelectionChipGroup.className = CLASSNAME$1p;
6339
+ SelectionChipGroup.className = CLASSNAME$1q;
6340
6340
 
6341
6341
  /**
6342
6342
  * Component display name.
@@ -6346,7 +6346,7 @@ const COMPONENT_NAME$1p = 'ListDivider';
6346
6346
  /**
6347
6347
  * Component default class name and class prefix.
6348
6348
  */
6349
- const CLASSNAME$1m = 'lumx-list-divider';
6349
+ const CLASSNAME$1n = 'lumx-list-divider';
6350
6350
 
6351
6351
  /**
6352
6352
  * Component default props.
@@ -6370,11 +6370,11 @@ const ListDivider$1 = props => {
6370
6370
  ref: ref,
6371
6371
  role: "none",
6372
6372
  ...forwardedProps,
6373
- className: classnames(className, CLASSNAME$1m)
6373
+ className: classnames(className, CLASSNAME$1n)
6374
6374
  });
6375
6375
  };
6376
6376
  ListDivider$1.displayName = COMPONENT_NAME$1p;
6377
- ListDivider$1.className = CLASSNAME$1m;
6377
+ ListDivider$1.className = CLASSNAME$1n;
6378
6378
  ListDivider$1.defaultProps = DEFAULT_PROPS$14;
6379
6379
 
6380
6380
  /**
@@ -6396,7 +6396,7 @@ const ListDivider = forwardRef((props, ref) => {
6396
6396
  });
6397
6397
  });
6398
6398
  ListDivider.displayName = COMPONENT_NAME$1p;
6399
- ListDivider.className = CLASSNAME$1m;
6399
+ ListDivider.className = CLASSNAME$1n;
6400
6400
  ListDivider.defaultProps = DEFAULT_PROPS$14;
6401
6401
 
6402
6402
  /**
@@ -6407,10 +6407,10 @@ const COMPONENT_NAME$1o = 'List';
6407
6407
  /**
6408
6408
  * Component default class name and class prefix.
6409
6409
  */
6410
- const CLASSNAME$1l = 'lumx-list';
6410
+ const CLASSNAME$1m = 'lumx-list';
6411
6411
  const {
6412
6412
  block: block$11
6413
- } = bem(CLASSNAME$1l);
6413
+ } = bem(CLASSNAME$1m);
6414
6414
 
6415
6415
  /**
6416
6416
  * Component default props.
@@ -6442,7 +6442,7 @@ const List$1 = props => {
6442
6442
  });
6443
6443
  };
6444
6444
  List$1.displayName = COMPONENT_NAME$1o;
6445
- List$1.className = CLASSNAME$1l;
6445
+ List$1.className = CLASSNAME$1m;
6446
6446
  List$1.defaultProps = DEFAULT_PROPS$13;
6447
6447
 
6448
6448
  /**
@@ -6463,7 +6463,7 @@ const COMPONENT_NAME$1n = 'ListboxList';
6463
6463
  /**
6464
6464
  * Component default class name and class prefix.
6465
6465
  */
6466
- const CLASSNAME$1k = 'lumx-listbox-list';
6466
+ const CLASSNAME$1l = 'lumx-listbox-list';
6467
6467
  /**
6468
6468
  * Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
6469
6469
  *
@@ -6491,7 +6491,7 @@ const ListboxList$1 = props => {
6491
6491
  } = props;
6492
6492
  return List$1({
6493
6493
  ...forwardedProps,
6494
- className: classnames(className, CLASSNAME$1k, LEGACY_CLASSNAME$6),
6494
+ className: classnames(className, CLASSNAME$1l, LEGACY_CLASSNAME$6),
6495
6495
  ref,
6496
6496
  itemPadding: 'big',
6497
6497
  id,
@@ -6502,6 +6502,33 @@ const ListboxList$1 = props => {
6502
6502
  });
6503
6503
  };
6504
6504
 
6505
+ /**
6506
+ * Context value shared by the sub-components of a composite widget (a list, a grid, …): the list,
6507
+ * its items, sections, skeletons and state.
6508
+ *
6509
+ * Provided by `ListboxProvider` (standalone listbox) and by `Combobox.Provider` (listbox of a combobox),
6510
+ * then re-provided by the list with its `type`.
6511
+ */
6512
+
6513
+ const CompositeContext = /*#__PURE__*/createContext(undefined);
6514
+
6515
+ /** Access the composite context, if any (undefined outside a `ListboxProvider` or a `Combobox.Provider`). */
6516
+ function useOptionalCompositeContext() {
6517
+ return useContext(CompositeContext);
6518
+ }
6519
+
6520
+ /**
6521
+ * Access the composite context.
6522
+ * @throws Error outside a `ListboxProvider` or a `Combobox.Provider`.
6523
+ */
6524
+ function useCompositeContext() {
6525
+ const context = useOptionalCompositeContext();
6526
+ if (!context) {
6527
+ throw new Error('Composite sub-components must be used within a Combobox or a standalone composite');
6528
+ }
6529
+ return context;
6530
+ }
6531
+
6505
6532
  var shim = {exports: {}};
6506
6533
 
6507
6534
  var useSyncExternalStoreShim_production = {};
@@ -6700,7 +6727,7 @@ function requireShim () {
6700
6727
  var shimExports = requireShim();
6701
6728
 
6702
6729
  /**
6703
- * Subscribe to a listbox handle event via `useSyncExternalStore`.
6730
+ * Subscribe to an event of an event source (a composite handle) via `useSyncExternalStore`.
6704
6731
  *
6705
6732
  * Reads the handle's synchronous `getSnapshot` — the correct pattern for an external (non-React) store.
6706
6733
  * It reads the current value during commit, so a consumer doesn't miss changes that happened between
@@ -6711,10 +6738,10 @@ var shimExports = requireShim();
6711
6738
  * The handle dispatches synchronously, so the store update fires within the triggering render/event
6712
6739
  * (inside React's `act` in tests) rather than a deferred microtask.
6713
6740
  *
6714
- * Re-subscribes when the handle changes (e.g. trigger mount/unmount). Returns `initialValue` while
6715
- * there is no handle or until the event has fired at least once.
6741
+ * Re-subscribes when the handle changes (e.g. trigger mount/unmount). Returns `initialValue`
6742
+ * while there is no handle or until the event has fired at least once.
6716
6743
  */
6717
- function useListboxEvent(handle, event, initialValue) {
6744
+ function useCompositeEvent(handle, event, initialValue) {
6718
6745
  // Stable fallback used until the event has fired at least once (or while there is no handle).
6719
6746
  const initialValueRef = useRef(initialValue);
6720
6747
  const subscribe = useCallback(onStoreChange => handle?.subscribe(event, onStoreChange) ?? (() => undefined), [handle, event]);
@@ -6725,25 +6752,24 @@ function useListboxEvent(handle, event, initialValue) {
6725
6752
  return shimExports.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
6726
6753
  }
6727
6754
 
6728
- /**
6729
- * Context value shared by the listbox sub-components (list, options, sections, skeletons, state).
6730
- *
6731
- * Provided by `ListboxProvider` (standalone listbox) and by `Combobox.Provider` (listbox of a combobox),
6732
- * then re-provided by the list with its `type`.
6733
- */
6755
+ /** Whether a composite handle is a listbox handle (it has the option registry). */
6756
+ function isListboxHandle(handle) {
6757
+ return !!handle && 'registerOption' in handle;
6758
+ }
6734
6759
 
6735
- const ListboxContext = /*#__PURE__*/createContext(undefined);
6760
+ /** Returns true when the cell is NOT the first gridcell in its row (i.e., it's an action cell). */
6761
+ function isActionCell(cell) {
6762
+ const row = cell.closest('[role="row"]');
6763
+ if (!row) return false;
6764
+ return row.querySelector('[role="gridcell"]') !== cell;
6765
+ }
6736
6766
 
6737
- /**
6738
- * Access the listbox context.
6739
- * @throws Error outside a `ListboxProvider` or a `Combobox.Provider`.
6740
- */
6741
- function useListboxContext() {
6742
- const context = useContext(ListboxContext);
6743
- if (!context) {
6744
- throw new Error('Listbox sub-components must be used within a Combobox or a standalone listbox');
6745
- }
6746
- return context;
6767
+ /** The listbox handle of the composite context (null while there is none, or when it is not a listbox). */
6768
+ function useListboxHandle() {
6769
+ const {
6770
+ handle
6771
+ } = useCompositeContext();
6772
+ return isListboxHandle(handle) ? handle : null;
6747
6773
  }
6748
6774
 
6749
6775
  /**
@@ -6769,24 +6795,25 @@ const ListboxList = forwardRef((props, ref) => {
6769
6795
  ...forwardedProps
6770
6796
  } = props;
6771
6797
  const {
6772
- list,
6773
- listboxId
6774
- } = useListboxContext();
6798
+ id: listboxId
6799
+ } = useCompositeContext();
6800
+ const list = useListboxHandle();
6775
6801
  const internalRef = useRef(null);
6776
6802
  const mergedRef = useMergeRefs(ref, internalRef);
6777
6803
  const selectionType = String(forwardedProps['aria-multiselectable']) === 'true' ? 'multiple' : 'single';
6778
6804
  const contextValue = useMemo(() => ({
6779
- list,
6780
- listboxId,
6805
+ handle: list,
6806
+ id: listboxId,
6781
6807
  type,
6782
- selectionType
6808
+ selectionType,
6809
+ level: 0
6783
6810
  }), [list, listboxId, type, selectionType]);
6784
6811
 
6785
6812
  // Options are rendered only while visible (standalone: always; combobox: while open).
6786
- const isOpen = useListboxEvent(list, 'open', false);
6787
- const options = useListboxEvent(list, 'optionsChange', undefined);
6813
+ const isOpen = useCompositeEvent(list, 'open', false);
6814
+ const options = useCompositeEvent(list, 'optionsChange', undefined);
6788
6815
  const visibleCount = options?.optionsLength ?? 0;
6789
- const isLoading = useListboxEvent(list, 'loadingChange', false);
6816
+ const isLoading = useCompositeEvent(list, 'loadingChange', false);
6790
6817
 
6791
6818
  // Mount the list element on the handle.
6792
6819
  useEffect(() => {
@@ -6799,7 +6826,7 @@ const ListboxList = forwardRef((props, ref) => {
6799
6826
  useEffect(() => {
6800
6827
  if (isOpen) list?.flushPendingNavigation();
6801
6828
  }, [isOpen, visibleCount, list]);
6802
- return /*#__PURE__*/jsx(ListboxContext.Provider, {
6829
+ return /*#__PURE__*/jsx(CompositeContext.Provider, {
6803
6830
  value: contextValue,
6804
6831
  children: ListboxList$1({
6805
6832
  ...forwardedProps,
@@ -6818,7 +6845,7 @@ const ListboxList = forwardRef((props, ref) => {
6818
6845
  });
6819
6846
  });
6820
6847
  ListboxList.displayName = COMPONENT_NAME$1n;
6821
- ListboxList.className = CLASSNAME$1k;
6848
+ ListboxList.className = CLASSNAME$1l;
6822
6849
 
6823
6850
  /**
6824
6851
  * Component display name.
@@ -6828,11 +6855,11 @@ const COMPONENT_NAME$1m = 'ListItem';
6828
6855
  /**
6829
6856
  * Component default class name and class prefix.
6830
6857
  */
6831
- const CLASSNAME$1j = 'lumx-list-item';
6858
+ const CLASSNAME$1k = 'lumx-list-item';
6832
6859
  const {
6833
6860
  block: block$10,
6834
6861
  element: element$O
6835
- } = bem(CLASSNAME$1j);
6862
+ } = bem(CLASSNAME$1k);
6836
6863
 
6837
6864
  /**
6838
6865
  * Component default props.
@@ -6901,7 +6928,7 @@ const ListItem$1 = props => {
6901
6928
  });
6902
6929
  };
6903
6930
  ListItem$1.displayName = COMPONENT_NAME$1m;
6904
- ListItem$1.className = CLASSNAME$1j;
6931
+ ListItem$1.className = CLASSNAME$1k;
6905
6932
  ListItem$1.defaultProps = DEFAULT_PROPS$12;
6906
6933
 
6907
6934
  /**
@@ -6916,7 +6943,7 @@ const COMPONENT_NAME$1l = 'ListItemAction';
6916
6943
  /**
6917
6944
  * Component classname (used by action area CSS pattern).
6918
6945
  */
6919
- const CLASSNAME$1i = 'lumx-action-area__action';
6946
+ const CLASSNAME$1j = 'lumx-action-area__action';
6920
6947
  const DEFAULT_PROPS$11 = {};
6921
6948
 
6922
6949
  /**
@@ -6947,6 +6974,28 @@ const ListItemAction$1 = props => {
6947
6974
  });
6948
6975
  };
6949
6976
 
6977
+ /**
6978
+ * Helper description of a composite item (an option or a tree item), rendered after the item action.
6979
+ *
6980
+ * @param props Component props.
6981
+ * @return JSX element.
6982
+ */
6983
+ const CompositeItemDescription = ({
6984
+ id,
6985
+ className,
6986
+ children,
6987
+ ...attributes
6988
+ }) => /*#__PURE__*/jsx("p", {
6989
+ id: id,
6990
+ ...attributes,
6991
+ ...getTextProps({
6992
+ className,
6993
+ typography: 'caption',
6994
+ color: 'dark-L2'
6995
+ }),
6996
+ children: children
6997
+ });
6998
+
6950
6999
  /**
6951
7000
  * Component display name.
6952
7001
  */
@@ -6955,7 +7004,7 @@ const COMPONENT_NAME$1k = 'ListboxOption';
6955
7004
  /**
6956
7005
  * Component default class name and class prefix.
6957
7006
  */
6958
- const CLASSNAME$1h = 'lumx-listbox-option';
7007
+ const CLASSNAME$1i = 'lumx-listbox-option';
6959
7008
  /**
6960
7009
  * Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
6961
7010
  *
@@ -6965,7 +7014,7 @@ const LEGACY_CLASSNAME$5 = 'lumx-combobox-option';
6965
7014
  const {
6966
7015
  block: block$$,
6967
7016
  element: element$N
6968
- } = bem(CLASSNAME$1h);
7017
+ } = bem(CLASSNAME$1i);
6969
7018
  const legacy$1 = bem(LEGACY_CLASSNAME$5);
6970
7019
 
6971
7020
  /**
@@ -7035,13 +7084,9 @@ const ListboxOption$1 = (props, {
7035
7084
  after,
7036
7085
  role: itemRole,
7037
7086
  children: /*#__PURE__*/jsxs(Fragment, {
7038
- children: [wrappedAction, description && /*#__PURE__*/jsx("p", {
7087
+ children: [wrappedAction, description && CompositeItemDescription({
7039
7088
  id: descriptionId,
7040
- ...getTextProps({
7041
- className: classnames(element$N('description'), legacy$1.element('description')),
7042
- typography: 'caption',
7043
- color: 'dark-L2'
7044
- }),
7089
+ className: classnames(element$N('description'), legacy$1.element('description')),
7045
7090
  children: description
7046
7091
  })]
7047
7092
  })
@@ -7049,21 +7094,25 @@ const ListboxOption$1 = (props, {
7049
7094
  };
7050
7095
 
7051
7096
  const OPTION_ACTIVE_EVENT_PREFIX = 'optionActive:';
7097
+
7098
+ /** The active state event of one item (see {@link OptionActiveEvent}). */
7052
7099
  const optionActiveEvent = optionId => `${OPTION_ACTIVE_EVENT_PREFIX}${optionId}`;
7053
7100
  const isOptionActiveEvent = event => event.startsWith(OPTION_ACTIVE_EVENT_PREFIX);
7101
+ /** The item id of an active state event. */
7102
+ const getOptionActiveId = event => event.slice(OPTION_ACTIVE_EVENT_PREFIX.length);
7054
7103
 
7055
- /** Context value provided by Combobox.Option to its `after` slot children. */
7104
+ /** Context value provided by an item of a composite widget (a `Combobox.Option`) to its `after` slot children. */
7056
7105
 
7057
- const ListboxOptionContext = /*#__PURE__*/createContext(undefined);
7106
+ const CompositeItemContext = /*#__PURE__*/createContext(undefined);
7058
7107
 
7059
7108
  /**
7060
- * Hook to access the Combobox.Option context.
7061
- * Must be used within a Combobox.Option's `after` slot.
7062
- * @throws Error if used outside of a Combobox.Option.
7063
- * @returns The option context value.
7109
+ * Access the composite item context.
7110
+ * Must be used within a `Combobox.Option` `after` slot.
7111
+ * @throws Error if used outside of a `Combobox.Option`.
7112
+ * @returns The item context value.
7064
7113
  */
7065
- function useListboxOptionContext() {
7066
- const context = useContext(ListboxOptionContext);
7114
+ function useCompositeItemContext() {
7115
+ const context = useContext(CompositeItemContext);
7067
7116
  if (!context) {
7068
7117
  throw new Error('Combobox.Option sub-components must be used within a Combobox.Option `after` slot');
7069
7118
  }
@@ -7102,9 +7151,9 @@ const ListboxOption = forwardRef((props, ref) => {
7102
7151
  ...forwardedProps
7103
7152
  } = props;
7104
7153
  const {
7105
- type,
7106
- list
7107
- } = useListboxContext();
7154
+ type
7155
+ } = useCompositeContext();
7156
+ const list = useListboxHandle();
7108
7157
  const isGrid = type === 'grid';
7109
7158
  const optionId = useId();
7110
7159
  const descriptionId = useId();
@@ -7113,7 +7162,7 @@ const ListboxOption = forwardRef((props, ref) => {
7113
7162
  const [isFiltered, setIsFiltered] = useState(false);
7114
7163
 
7115
7164
  // Force the tooltip open while the option is the active descendant (keyboard highlight).
7116
- const isActive = useListboxEvent(list, optionActiveEvent(optionId), false);
7165
+ const isActive = useCompositeEvent(list, optionActiveEvent(optionId), false);
7117
7166
  useEffect(() => {
7118
7167
  const element = internalRef.current;
7119
7168
  if (!element || !list) return undefined;
@@ -7127,42 +7176,41 @@ const ListboxOption = forwardRef((props, ref) => {
7127
7176
  list.refilterOption(element);
7128
7177
  }, [list, value]);
7129
7178
 
7130
- // Wrap `after` content in an option context so sub-components (e.g. OptionMoreInfo)
7131
- // can access the parent option's ID for keyboard highlight detection.
7132
- const optionContextValue = useMemo(() => ({
7133
- optionId,
7179
+ // Provide the item context to the whole option, so sub-components (e.g. OptionMoreInfo, SelectionIcon)
7180
+ // can read the option ID (keyboard highlight detection) and its selected state from any slot.
7181
+ const itemContextValue = useMemo(() => ({
7182
+ itemId: optionId,
7134
7183
  isSelected: Boolean(isSelected)
7135
7184
  }), [optionId, isSelected]);
7136
- const wrappedAfter = after ? /*#__PURE__*/jsx(ListboxOptionContext.Provider, {
7137
- value: optionContextValue,
7138
- children: after
7139
- }) : undefined;
7140
- return ListboxOption$1({
7141
- ...forwardedProps,
7142
- ref: mergedRef,
7143
- actionProps,
7144
- hidden: isFiltered,
7145
- value,
7146
- description,
7147
- children,
7148
- isSelected,
7149
- isDisabled,
7150
- isGrid,
7151
- before,
7152
- after: wrappedAfter,
7153
- handleClick: onClick,
7154
- id: optionId,
7155
- descriptionId,
7156
- tooltipProps: tooltipProps && {
7157
- ...tooltipProps,
7158
- forceOpen: tooltipProps.forceOpen || isActive
7159
- }
7160
- }, {
7161
- Tooltip
7185
+ return /*#__PURE__*/jsx(CompositeItemContext.Provider, {
7186
+ value: itemContextValue,
7187
+ children: ListboxOption$1({
7188
+ ...forwardedProps,
7189
+ ref: mergedRef,
7190
+ actionProps,
7191
+ hidden: isFiltered,
7192
+ value,
7193
+ description,
7194
+ children,
7195
+ isSelected,
7196
+ isDisabled,
7197
+ isGrid,
7198
+ before,
7199
+ after,
7200
+ handleClick: onClick,
7201
+ id: optionId,
7202
+ descriptionId,
7203
+ tooltipProps: tooltipProps && {
7204
+ ...tooltipProps,
7205
+ forceOpen: tooltipProps.forceOpen || isActive
7206
+ }
7207
+ }, {
7208
+ Tooltip
7209
+ })
7162
7210
  });
7163
7211
  });
7164
7212
  ListboxOption.displayName = COMPONENT_NAME$1k;
7165
- ListboxOption.className = CLASSNAME$1h;
7213
+ ListboxOption.className = CLASSNAME$1i;
7166
7214
 
7167
7215
  /**
7168
7216
  * Defines the props for the core ListboxOptionAction template.
@@ -7176,7 +7224,7 @@ const COMPONENT_NAME$1j = 'ListboxOptionAction';
7176
7224
  /**
7177
7225
  * Component default class name and class prefix.
7178
7226
  */
7179
- const CLASSNAME$1g = 'lumx-listbox-option-action';
7227
+ const CLASSNAME$1h = 'lumx-listbox-option-action';
7180
7228
  /**
7181
7229
  * Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
7182
7230
  *
@@ -7205,7 +7253,7 @@ const ListboxOptionAction$1 = props => {
7205
7253
  as: Element,
7206
7254
  ...forwardedProps,
7207
7255
  role: 'gridcell',
7208
- className: classnames(className, CLASSNAME$1g, LEGACY_CLASSNAME$4),
7256
+ className: classnames(className, CLASSNAME$1h, LEGACY_CLASSNAME$4),
7209
7257
  handleClick,
7210
7258
  children
7211
7259
  });
@@ -7249,7 +7297,7 @@ const ListboxOptionAction = Object.assign(forwardRefPolymorphic((props, ref) =>
7249
7297
  const actionId = useId();
7250
7298
  const {
7251
7299
  type
7252
- } = useListboxContext();
7300
+ } = useCompositeContext();
7253
7301
  const isGrid = type === 'grid';
7254
7302
  useEffect(() => {
7255
7303
  if (!isGrid) {
@@ -7269,7 +7317,7 @@ const ListboxOptionAction = Object.assign(forwardRefPolymorphic((props, ref) =>
7269
7317
  });
7270
7318
  }), {
7271
7319
  displayName: COMPONENT_NAME$1j,
7272
- className: CLASSNAME$1g
7320
+ className: CLASSNAME$1h
7273
7321
  });
7274
7322
 
7275
7323
  /**
@@ -7280,7 +7328,7 @@ const COMPONENT_NAME$1i = 'ListboxOptionMoreInfo';
7280
7328
  /**
7281
7329
  * Component default class name and class prefix.
7282
7330
  */
7283
- const CLASSNAME$1f = 'lumx-listbox-option-more-info';
7331
+ const CLASSNAME$1g = 'lumx-listbox-option-more-info';
7284
7332
  /**
7285
7333
  * Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
7286
7334
  *
@@ -7290,7 +7338,7 @@ const LEGACY_CLASSNAME$3 = 'lumx-combobox-option-more-info';
7290
7338
  const {
7291
7339
  block: block$_,
7292
7340
  element: element$M
7293
- } = bem(CLASSNAME$1f);
7341
+ } = bem(CLASSNAME$1g);
7294
7342
  const legacy = bem(LEGACY_CLASSNAME$3);
7295
7343
 
7296
7344
  /**
@@ -7625,11 +7673,11 @@ const COMPONENT_NAME$1h = 'Popover';
7625
7673
  /**
7626
7674
  * Component default class name and class prefix.
7627
7675
  */
7628
- const CLASSNAME$1e = 'lumx-popover';
7676
+ const CLASSNAME$1f = 'lumx-popover';
7629
7677
  const {
7630
7678
  block: block$Z,
7631
7679
  element: element$L
7632
- } = bem(CLASSNAME$1e);
7680
+ } = bem(CLASSNAME$1f);
7633
7681
 
7634
7682
  /**
7635
7683
  * Component default props (used by framework wrappers).
@@ -8168,7 +8216,7 @@ const Popover = skipRender(
8168
8216
  // Skip render in SSR
8169
8217
  () => Boolean(DOCUMENT), _InnerPopover);
8170
8218
  Popover.displayName = COMPONENT_NAME$1h;
8171
- Popover.className = CLASSNAME$1e;
8219
+ Popover.className = CLASSNAME$1f;
8172
8220
  Popover.defaultProps = DEFAULT_PROPS$10;
8173
8221
 
8174
8222
  /**
@@ -8198,17 +8246,17 @@ const ListboxOptionMoreInfo = props => {
8198
8246
  const ref = useRef(null);
8199
8247
  const [isHovered, setIsHovered] = useState(false);
8200
8248
 
8201
- // Get the parent option ID from the option context (provided by Combobox.Option).
8249
+ // Get the parent option ID from the item context (provided by Combobox.Option).
8202
8250
  const {
8203
- optionId
8204
- } = useListboxOptionContext();
8251
+ itemId: optionId
8252
+ } = useCompositeItemContext();
8205
8253
 
8206
8254
  // Subscribe to active descendant changes to detect keyboard highlight.
8207
8255
  const {
8208
- list
8209
- } = useListboxContext();
8210
- const activeDescendantId = useListboxEvent(list, 'activeDescendantChange', null);
8211
- const isKeyboardHighlighted = activeDescendantId === optionId;
8256
+ handle
8257
+ } = useCompositeContext();
8258
+ // Only this option updates when the active item moves (the per-item active event).
8259
+ const isKeyboardHighlighted = useCompositeEvent(handle, optionActiveEvent(optionId), false);
8212
8260
 
8213
8261
  // Open on mouse hover or keyboard highlight.
8214
8262
  const isOpen = isHovered || isKeyboardHighlighted;
@@ -8236,7 +8284,7 @@ const ListboxOptionMoreInfo = props => {
8236
8284
  });
8237
8285
  };
8238
8286
  ListboxOptionMoreInfo.displayName = COMPONENT_NAME$1i;
8239
- ListboxOptionMoreInfo.className = CLASSNAME$1f;
8287
+ ListboxOptionMoreInfo.className = CLASSNAME$1g;
8240
8288
 
8241
8289
  /**
8242
8290
  * Component display name.
@@ -8246,11 +8294,11 @@ const COMPONENT_NAME$1g = 'SkeletonTypography';
8246
8294
  /**
8247
8295
  * Component default class name and class prefix.
8248
8296
  */
8249
- const CLASSNAME$1d = 'lumx-skeleton-typography';
8297
+ const CLASSNAME$1e = 'lumx-skeleton-typography';
8250
8298
  const {
8251
8299
  block: block$Y,
8252
8300
  element: element$K
8253
- } = bem(CLASSNAME$1d);
8301
+ } = bem(CLASSNAME$1e);
8254
8302
 
8255
8303
  /**
8256
8304
  * SkeletonTypography component.
@@ -8294,7 +8342,7 @@ const COMPONENT_NAME$1f = 'ListboxOptionSkeleton';
8294
8342
  /**
8295
8343
  * Component default class name and class prefix.
8296
8344
  */
8297
- const CLASSNAME$1c = 'lumx-listbox-option-skeleton';
8345
+ const CLASSNAME$1d = 'lumx-listbox-option-skeleton';
8298
8346
  /**
8299
8347
  * Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
8300
8348
  *
@@ -8327,7 +8375,7 @@ const ListboxOptionSkeleton$1 = props => {
8327
8375
  size: 'tiny',
8328
8376
  role: 'none',
8329
8377
  ...forwardedProps,
8330
- className: classnames(className, CLASSNAME$1c, LEGACY_CLASSNAME$2),
8378
+ className: classnames(className, CLASSNAME$1d, LEGACY_CLASSNAME$2),
8331
8379
  children: children || /*#__PURE__*/jsxs(Fragment, {
8332
8380
  children: [/*#__PURE__*/jsx(SkeletonTypography$1, {
8333
8381
  typography: "body1",
@@ -8373,25 +8421,35 @@ const ListboxOptionSkeleton$1 = props => {
8373
8421
  */
8374
8422
  const ListboxOptionSkeleton = props => {
8375
8423
  const {
8376
- list
8377
- } = useListboxContext();
8378
- useEffect(() => list?.registerSkeleton(), [list]);
8424
+ handle,
8425
+ level = 0
8426
+ } = useCompositeContext();
8427
+ // A skeleton in a nested level of items does not make the whole list busy.
8428
+ const isNested = level > 0;
8429
+ useEffect(() => handle?.registerSkeleton({
8430
+ isNested
8431
+ }), [handle, isNested]);
8379
8432
  return /*#__PURE__*/jsx(ListboxOptionSkeleton$1, {
8380
8433
  ...props
8381
8434
  });
8382
8435
  };
8383
8436
  ListboxOptionSkeleton.displayName = COMPONENT_NAME$1f;
8384
- ListboxOptionSkeleton.className = CLASSNAME$1c;
8437
+ ListboxOptionSkeleton.className = CLASSNAME$1d;
8385
8438
 
8439
+ const CLASSNAME$1c = 'lumx-composite-item__selection-icon';
8440
+
8441
+ /** Class names of the previous versions on a listbox option, kept for compatibility (set by the option icon). */
8442
+ const LEGACY_OPTION_CLASSNAME = 'lumx-listbox-option__selection-icon lumx-combobox-option__selection-icon';
8386
8443
  /**
8387
- * Selection state icon of an option. The icon is always rendered after the label.
8444
+ * Selection state icon of a composite item (an option or a tree item). The icon is always rendered after the label.
8388
8445
  *
8389
8446
  * - `single`: a check circle icon when selected, a blank radio icon otherwise.
8390
8447
  * - `multiple`: a checkbox icon, marked or blank.
8391
8448
  */
8392
- const ListboxOptionSelectionIcon$1 = ({
8449
+ const CompositeSelectionIcon = ({
8393
8450
  selectionType,
8394
- isSelected
8451
+ isSelected,
8452
+ className
8395
8453
  }) => {
8396
8454
  let icon;
8397
8455
  if (selectionType === 'multiple') {
@@ -8404,20 +8462,21 @@ const ListboxOptionSelectionIcon$1 = ({
8404
8462
  return /*#__PURE__*/jsx(Icon$1, {
8405
8463
  icon: icon,
8406
8464
  color: isSelected ? 'primary' : undefined,
8407
- className: "lumx-listbox-option__selection-icon lumx-combobox-option__selection-icon"
8465
+ className: classnames(CLASSNAME$1c, className)
8408
8466
  });
8409
8467
  };
8410
8468
 
8411
8469
  const ListboxOptionSelectionIcon = () => {
8412
8470
  const {
8413
8471
  isSelected
8414
- } = useListboxOptionContext();
8472
+ } = useCompositeItemContext();
8415
8473
  const {
8416
8474
  selectionType
8417
- } = useListboxContext();
8418
- return /*#__PURE__*/jsx(ListboxOptionSelectionIcon$1, {
8475
+ } = useCompositeContext();
8476
+ return /*#__PURE__*/jsx(CompositeSelectionIcon, {
8419
8477
  selectionType: selectionType,
8420
- isSelected: isSelected
8478
+ isSelected: isSelected,
8479
+ className: LEGACY_OPTION_CLASSNAME
8421
8480
  });
8422
8481
  };
8423
8482
  ListboxOptionSelectionIcon.displayName = 'ComboboxSelectionIcon';
@@ -8579,9 +8638,7 @@ ListSection.defaultProps = DEFAULT_PROPS$$;
8579
8638
  * @return React element.
8580
8639
  */
8581
8640
  const ListboxSection = forwardRef((props, ref) => {
8582
- const {
8583
- list
8584
- } = useListboxContext();
8641
+ const list = useListboxHandle();
8585
8642
  const internalRef = useRef(null);
8586
8643
  const mergedRef = useMergeRefs(ref, internalRef);
8587
8644
  const [sectionState, setSectionState] = useState({
@@ -8608,27 +8665,21 @@ const ListboxSection = forwardRef((props, ref) => {
8608
8665
  ListboxSection.displayName = COMPONENT_NAME$1e;
8609
8666
  ListboxSection.className = CLASSNAME$1b;
8610
8667
 
8611
- /**
8612
- * Component display name.
8613
- */
8614
- const COMPONENT_NAME$1c = 'ListboxState';
8668
+ const COMPONENT_NAME$1c = 'CompositeStatus';
8615
8669
 
8616
8670
  /**
8617
8671
  * Component default class name and class prefix.
8618
8672
  */
8619
- const CLASSNAME$19 = 'lumx-listbox-state';
8620
- /**
8621
- * Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
8622
- *
8623
- * @deprecated Use `CLASSNAME` (`lumx-listbox-*`). The legacy `lumx-combobox-*` class will be removed in the next major version.
8624
- */
8625
- const LEGACY_CLASSNAME = 'lumx-combobox-state';
8673
+ const CLASSNAME$19 = 'lumx-composite-status';
8626
8674
  const {
8627
8675
  block: block$W
8628
8676
  } = bem(CLASSNAME$19);
8629
8677
 
8678
+ /** Class names of the previous versions (`Combobox.State` was the listbox state), kept for compatibility. */
8679
+ const LEGACY_CLASSNAME = 'lumx-listbox-state lumx-combobox-state';
8680
+
8630
8681
  /**
8631
- * Defines the props for the core ListboxState template.
8682
+ * Defines the props for the core CompositeStatus template.
8632
8683
  */
8633
8684
 
8634
8685
  /**
@@ -8636,20 +8687,21 @@ const {
8636
8687
  */
8637
8688
 
8638
8689
  /**
8639
- * ListboxState core template.
8640
- * Renders empty/error/option-count state messages inside the combobox popover.
8690
+ * CompositeStatus core template: the live region of a composite (listbox, grid or tree).
8691
+ * Renders the empty, loading, error and item count messages (e.g. in the combobox popover).
8641
8692
  * The block itself acts as a screen reader live region (`role="status" aria-live="polite"`).
8642
8693
  *
8643
8694
  * Activation rules:
8644
8695
  * - Error state: active when `errorMessage` is provided (presence-based).
8645
- * - Empty state: active when `optionsLength` is 0 and `emptyMessage` is provided, and there is no error.
8646
- * - Option count: active when `nbOptionMessage` is provided, the list is not empty, not loading, and not in error.
8696
+ * - Empty state: active when the item count (`optionsLength`) is 0 and `emptyMessage` is provided, and there is
8697
+ * no error.
8698
+ * - Item count: active when `nbOptionMessage` is provided, the composite is not empty, not loading, and not in error.
8647
8699
  *
8648
8700
  * @param props Component props.
8649
8701
  * @param components Injected framework-specific components.
8650
8702
  * @return JSX element or null when no state is active.
8651
8703
  */
8652
- const ListboxState$1 = (props, {
8704
+ const CompositeStatus$1 = (props, {
8653
8705
  GenericBlock,
8654
8706
  Text
8655
8707
  }) => {
@@ -8672,7 +8724,7 @@ const ListboxState$1 = (props, {
8672
8724
  // The framework wrapper gates `loadingMessage` via the debounced `loadingAnnouncement` event,
8673
8725
  // passing `undefined` until the 500ms threshold is reached.
8674
8726
  const showLoading = !showError && !!loadingMessage;
8675
- // Show option count message when the list is open, not empty, not loading, and not in error.
8727
+ // Show the item count message when the composite is open, not empty, not loading, and not in error.
8676
8728
  const resolvedNbOptionMessage = !isEmpty && !showError && !state?.isLoading && nbOptionMessage ? nbOptionMessage(optionsLength) : undefined;
8677
8729
  const show = showEmpty || showError;
8678
8730
  const alignProps = {
@@ -8736,10 +8788,10 @@ const OPEN_ANNOUNCEMENT_DELAY = 100;
8736
8788
  /** Setters invoked by `subscribeListboxState` when handle events fire. */
8737
8789
 
8738
8790
  /**
8739
- * Subscribe to the listbox handle events needed by `ListboxState`.
8791
+ * Subscribe to the listbox handle events needed by `CompositeStatus`.
8740
8792
  *
8741
8793
  * Manages three subscriptions:
8742
- * - `loadingChange` → `setIsLoading` (+ synchronous initial read of `list.isLoading`)
8794
+ * - `loadingChange` → `setIsLoading` (+ synchronous initial read of the `loadingChange` snapshot)
8743
8795
  * - `loadingAnnouncement` → `setShouldAnnounce`
8744
8796
  * - `open` → `setIsOpen` (deferred by {@link OPEN_ANNOUNCEMENT_DELAY}ms when shown, immediate when hidden)
8745
8797
  * (a standalone listbox is always visible: `setIsOpen(true)` once, no subscription)
@@ -8756,7 +8808,7 @@ function subscribeListboxState(list, setters) {
8756
8808
  } = setters;
8757
8809
 
8758
8810
  // Read current loading state synchronously
8759
- setIsLoading(list.isLoading);
8811
+ setIsLoading(list.getSnapshot('loadingChange') ?? false);
8760
8812
  const unsubLoadingChange = list.subscribe('loadingChange', setIsLoading);
8761
8813
  const unsubLoadingAnnouncement = list.subscribe('loadingAnnouncement', setShouldAnnounce);
8762
8814
 
@@ -8974,13 +9026,14 @@ const GenericBlock = Object.assign(BaseGenericBlock, {
8974
9026
  const GenericBlockGapSize = pick(Size, ['tiny', 'regular', 'medium', 'big', 'huge']);
8975
9027
 
8976
9028
  /**
8977
- * Props for Combobox.State component.
9029
+ * Props of the composite status (`Combobox.State`, `Listbox.State`).
8978
9030
  */
8979
9031
 
8980
9032
  /**
8981
- * Combobox.State component - displays empty and error states for the combobox list.
9033
+ * CompositeStatus: the live region of a composite (list, grid or tree), exposed as `Combobox.State` and
9034
+ * `Listbox.State`. Displays the empty, loading, error and item count messages.
8982
9035
  *
8983
- * Place this component as a sibling to `Combobox.List` inside a `Combobox.Popover`:
9036
+ * Place this component as a sibling to `Combobox.List` inside a `Combobox.Popover` (or inside the list):
8984
9037
  *
8985
9038
  * ```tsx
8986
9039
  * <Combobox.Popover>
@@ -8998,19 +9051,19 @@ const GenericBlockGapSize = pick(Size, ['tiny', 'regular', 'medium', 'big', 'hug
8998
9051
  * Takes priority over all other states.
8999
9052
  * - **Loading state**: active when `loadingMessage` is provided and skeletons have been
9000
9053
  * mounted for at least 500ms. Suppresses the empty state while loading.
9001
- * - **Empty state**: active when `emptyMessage` is provided and the list has no visible options
9054
+ * - **Empty state**: active when `emptyMessage` is provided and the composite has no visible items
9002
9055
  * and is not loading.
9003
- * - **Option count**: active when `nbOptionMessage` is provided and the list is not empty,
9056
+ * - **Item count**: active when `nbOptionMessage` is provided and the composite is not empty,
9004
9057
  * not loading, and not in error.
9005
9058
  *
9006
9059
  * @param props Component props.
9007
9060
  * @return React element.
9008
9061
  */
9009
- const ListboxState = props => {
9062
+ const CompositeStatus = props => {
9010
9063
  const {
9011
- list
9012
- } = useListboxContext();
9013
- const optionsState = useListboxEvent(list, 'optionsChange', undefined);
9064
+ handle: list
9065
+ } = useCompositeContext();
9066
+ const optionsState = useCompositeEvent(list, 'optionsChange', undefined);
9014
9067
  const [isLoading, setIsLoading] = useState(false);
9015
9068
  const [shouldAnnounce, setShouldAnnounce] = useState(false);
9016
9069
  const [isOpen, setIsOpen] = useState(false);
@@ -9030,7 +9083,7 @@ const ListboxState = props => {
9030
9083
 
9031
9084
  // Only pass loadingMessage to core after the 500ms debounce threshold
9032
9085
  const loadingMessage = shouldAnnounce ? props.loadingMessage : undefined;
9033
- return ListboxState$1({
9086
+ return CompositeStatus$1({
9034
9087
  ...props,
9035
9088
  loadingMessage,
9036
9089
  state
@@ -9039,75 +9092,8 @@ const ListboxState = props => {
9039
9092
  Text
9040
9093
  });
9041
9094
  };
9042
- ListboxState.displayName = COMPONENT_NAME$1c;
9043
- ListboxState.className = CLASSNAME$19;
9044
-
9045
- /**
9046
- * Get the value for an option element.
9047
- * Uses `data-value` when set; falls back to the element's trimmed `textContent`.
9048
- *
9049
- * This is the *selection* value , which may differ from the visible label
9050
- */
9051
- function getOptionValue(option) {
9052
- if (option.dataset.value !== undefined) return option.dataset.value;
9053
- return option.textContent?.trim() ?? '';
9054
- }
9055
-
9056
- /**
9057
- * Get the visible label for an option element (its trimmed `textContent`).
9058
- *
9059
- * Used for typeahead matching: the user types the characters they see, which is the
9060
- * option's label — not its `data-value` (which can be an unrelated id).
9061
- */
9062
- function getOptionLabel(option) {
9063
- return option.textContent?.trim() ?? '';
9064
- }
9065
-
9066
- /** Returns true when an option carries aria-disabled="true". */
9067
- function isOptionDisabled(option) {
9068
- return option.getAttribute('aria-disabled') === 'true';
9069
- }
9070
-
9071
- /** Returns true when the cell is NOT the first gridcell in its row (i.e., it's an action cell). */
9072
- function isActionCell(cell) {
9073
- const row = cell.closest('[role="row"]');
9074
- if (!row) return false;
9075
- return row.querySelector('[role="gridcell"]') !== cell;
9076
- }
9077
- const isSelected = el => el.getAttribute('aria-selected') === 'true';
9078
-
9079
- /**
9080
- * Compute the current state of a section and notify when it changed.
9081
- *
9082
- * Section state:
9083
- * - `hidden`: true when the section has registered options but all are filtered out.
9084
- * - `aria-hidden`: true when the section has no registered options at all (skeleton-only).
9085
- *
9086
- * At most one of `hidden` / `aria-hidden` is true at a time.
9087
- */
9088
- function notifySection(sectionElement, sectionRegistrations, optionRegistrations, force) {
9089
- const reg = sectionRegistrations.get(sectionElement);
9090
- if (!reg) return;
9091
- let hasOptions = false;
9092
- let hasVisibleOption = false;
9093
- for (const [optionElement, optionReg] of optionRegistrations) {
9094
- if (sectionElement.contains(optionElement)) {
9095
- hasOptions = true;
9096
- if (!optionReg.lastFiltered) {
9097
- hasVisibleOption = true;
9098
- break;
9099
- }
9100
- }
9101
- }
9102
- const state = {
9103
- hidden: hasOptions && !hasVisibleOption,
9104
- 'aria-hidden': !hasOptions
9105
- };
9106
- if (force || state.hidden !== reg.last.hidden || state['aria-hidden'] !== reg.last['aria-hidden']) {
9107
- reg.last = state;
9108
- reg.callback(state);
9109
- }
9110
- }
9095
+ CompositeStatus.displayName = COMPONENT_NAME$1c;
9096
+ CompositeStatus.className = CLASSNAME$19;
9111
9097
 
9112
9098
  /** Typeahead interface. */
9113
9099
 
@@ -9249,187 +9235,141 @@ function isPrintableKey({
9249
9235
  return key.length === 1 && key !== ' ' && !altKey && !ctrlKey && !metaKey;
9250
9236
  }
9251
9237
 
9252
- /** Options shared by the list and grid navigation modules. */
9253
-
9254
9238
  /**
9255
- * Navigation module of a mounted listbox: everything that differs between
9256
- * the listbox pattern (`role="listbox"`) and the grid pattern (`role="grid"`).
9239
+ * Get the visible label for an item element (its trimmed `textContent`).
9240
+ *
9241
+ * Used for typeahead matching: the user types the characters they see, which is the
9242
+ * item's label — not its `data-value` (which can be an unrelated id).
9257
9243
  */
9244
+ function getOptionLabel(option) {
9245
+ return option.textContent?.trim() ?? '';
9246
+ }
9258
9247
 
9259
- const OPTION_SELECTOR = '[role="option"]';
9260
- const GRID_CELL_SELECTOR = '[role="gridcell"]';
9261
-
9262
- /** Navigation module for the listbox pattern (1D list of `role="option"`). */
9263
- function createListNavigation(options) {
9264
- const {
9265
- container,
9266
- callbacks,
9267
- signal,
9268
- getActiveItem,
9269
- wrap
9270
- } = options;
9271
- const focusNav = createListFocusNavigation({
9272
- container,
9273
- itemSelector: OPTION_SELECTOR,
9274
- wrap,
9275
- getActiveItem
9276
- }, callbacks, signal);
9277
- return {
9278
- type: 'listbox',
9279
- focusNav,
9280
- cellSelector: OPTION_SELECTOR,
9281
- isOptionCell: () => true,
9282
- scrollIntoView(item) {
9283
- // Last option: find the last child containing an option (not followed by another one).
9284
- const lastItem = container.querySelector(`:scope > :has(${OPTION_SELECTOR}):not(:has(~ * ${OPTION_SELECTOR})) ${OPTION_SELECTOR}`);
9285
- if (item === lastItem) {
9286
- // Scroll to the end of the listbox (snaps to the end of the scroll container via CSS scroll snap)
9287
- container.lastElementChild?.scrollIntoView({
9288
- block: 'nearest'
9289
- });
9290
- } else {
9291
- const toScrollTo = item.closest('[role=listbox] > *') || item;
9292
- toScrollTo.scrollIntoView({
9293
- block: 'nearest'
9294
- });
9295
- }
9296
- },
9297
- navigateHorizontal: () => false
9298
- };
9248
+ /**
9249
+ * Get the value for an item element.
9250
+ * Uses `data-value` when set; falls back to the item label (see {@link getOptionLabel}).
9251
+ *
9252
+ * This is the *selection* value, which may differ from the visible label.
9253
+ */
9254
+ function getOptionValue(option) {
9255
+ return option.dataset.value ?? getOptionLabel(option);
9299
9256
  }
9300
9257
 
9301
- /** Navigation module for the grid pattern (rows of `role="gridcell"`: option cell + action cells). */
9302
- function createGridNavigation(options) {
9303
- const {
9304
- container,
9305
- callbacks,
9306
- signal
9307
- } = options;
9308
- const focusNav = createGridFocusNavigation({
9309
- container,
9310
- rowSelector: '[role="row"]',
9311
- cellSelector: GRID_CELL_SELECTOR,
9312
- wrap: true
9313
- }, callbacks, signal);
9314
- return {
9315
- type: 'grid',
9316
- focusNav,
9317
- cellSelector: GRID_CELL_SELECTOR,
9318
- isOptionCell: cell => !isActionCell(cell),
9319
- scrollIntoView(item) {
9320
- item.scrollIntoView({
9321
- block: 'nearest'
9322
- });
9323
- },
9324
- navigateHorizontal(key) {
9325
- if (!focusNav.selectors.activeItem) return false;
9326
- if (key === 'ArrowLeft') focusNav.goLeft();else focusNav.goRight();
9327
- return true;
9328
- }
9329
- };
9258
+ /** Returns true when an item carries aria-disabled="true". */
9259
+ function isOptionDisabled(option) {
9260
+ return option.getAttribute('aria-disabled') === 'true';
9330
9261
  }
9262
+ const isSelected = el => el.getAttribute('aria-selected') === 'true';
9331
9263
 
9332
9264
  /** Delay before announcing loading in the live region (ms). */
9333
9265
  const LOADING_ANNOUNCEMENT_DELAY = 500;
9334
9266
 
9267
+ /** The `optionsChange` payload before any item registers. */
9268
+ const INITIAL_OPTIONS = {
9269
+ optionsLength: 0,
9270
+ inputValue: '',
9271
+ isCountHidden: false
9272
+ };
9273
+
9274
+ /** The filter before any `setFilter` (no filter). */
9275
+ const NO_FILTER = {
9276
+ value: '',
9277
+ mode: 'auto'
9278
+ };
9279
+
9280
+ /** Result of {@link setupComposite}: the handle, and the hooks the specialization calls. */
9281
+
9282
+ /** The DOM part of a composite, from `mount` to unmount. */
9283
+
9284
+ /** A subscriber callback (the payload type depends on the event). */
9285
+
9335
9286
  /**
9336
- * Set up listbox behavior (WAI-ARIA listbox or grid pattern) independent of any DOM element.
9287
+ * Set up the behavior shared by the composite widgets (one active item among many: WAI-ARIA listbox,
9288
+ * grid, …) independent of any DOM element.
9337
9289
  *
9338
- * The handle owns the option/section/skeleton registry, the filter state, the focus navigation
9339
- * (once an element is mounted), the selection, the loading announcement and the listbox events.
9340
- * The navigation module (listbox or grid pattern) is selected from the element role on mount.
9290
+ * The composite owns the focus owner link, the focus navigation (once an element is mounted, with the
9291
+ * navigation module of the specialization), the keyboard handling, the selection, the open state, the
9292
+ * filter, the skeleton registry, the loading announcement and the events. The specialization owns its item
9293
+ * registry, how it applies the filter and its navigation modules (see {@link CompositeSpecialization}).
9341
9294
  *
9342
- * - Standalone (no `focusOwner` option): the listbox element owns DOM focus and
9295
+ * - Standalone (no `focusOwner` option): the composite element owns DOM focus and
9343
9296
  * `aria-activedescendant`, and handles its own keyboard navigation.
9344
9297
  * - Linked (`focusOwner` option, e.g. a combobox trigger): the parent owns focus and the keyboard;
9345
- * the listbox writes `aria-activedescendant` on the parent focus owner.
9346
- *
9347
- * @see https://www.w3.org/WAI/ARIA/apg/patterns/listbox/
9348
- * @see https://www.w3.org/WAI/ARIA/apg/patterns/grid/
9298
+ * the composite writes `aria-activedescendant` on the parent focus owner.
9349
9299
  */
9350
- function setupListbox(options = {}) {
9300
+ function setupComposite(options, specialization) {
9351
9301
  const {
9352
9302
  onSelect,
9353
9303
  wrapNavigation = false,
9354
9304
  focusOwner: link
9355
9305
  } = options;
9356
9306
  const isStandalone = !link;
9357
- let element = null;
9358
- let navigation = null;
9359
- /** AbortController for the listeners attached on mount. */
9360
- let mountController = null;
9361
- /** Typeahead controller (created on mount, needs the listbox element). */
9362
- let typeaheadController = null;
9363
-
9364
- /** Current filter value (empty string = no filtering). */
9365
- let filterValue = '';
9366
- const optionRegistrations = new Map();
9367
- const sectionRegistrations = new Map();
9368
- let lastOptionsLength = 0;
9369
- let lastInputValue = '';
9370
- let lastLoadingState = false;
9371
- let skeletonCount = 0;
9372
9307
 
9373
- /** Whether the options are visible (standalone: always; combobox: set by the combobox open state). */
9308
+ /** The mounted element and what is created with it (null while not mounted). */
9309
+ let mounted = null;
9310
+
9311
+ /** The current filter (see {@link CompositeHandle.setFilter}). */
9312
+ let filter = NO_FILTER;
9313
+ /** The last `optionsChange` payload. */
9314
+ let lastOptions = INITIAL_OPTIONS;
9315
+ /**
9316
+ * Registered skeletons, one token per registration: a stale cleanup (e.g. after a destroy) finds no
9317
+ * token and changes nothing. Root skeletons make the composite busy, nested ones (inside a nested
9318
+ * level of items) only start the loading announcement.
9319
+ */
9320
+ const rootSkeletons = new Set();
9321
+ const nestedSkeletons = new Set();
9322
+
9323
+ /** Whether the items are visible (standalone: always; combobox: set by the combobox open state). */
9374
9324
  let isOpen = isStandalone;
9375
9325
  /** Timer for the debounced loading announcement. */
9376
9326
  let loadingTimer;
9377
- /** Whether a loading announcement has been sent since the options became visible. */
9327
+ /** Whether a loading announcement has been sent since the items became visible. */
9378
9328
  let announcementSent = false;
9329
+ const isLoading = () => rootSkeletons.size > 0;
9379
9330
 
9380
- /** Static listbox events (per-option active events are handled separately). */
9331
+ /** Subscribers, per event (also the per-item `optionActive:<id>` events). Sets are created on demand. */
9332
+ const subscribers = new Map();
9333
+ /** The last dispatched value of the static events (the per-item events are derived, see `getSnapshot`). */
9381
9334
 
9382
- const subscribers = {
9383
- activeDescendantChange: new Set(),
9384
- optionsChange: new Set(),
9385
- loadingChange: new Set(),
9386
- loadingAnnouncement: new Set(),
9387
- open: new Set()
9388
- };
9389
9335
  // `open` has a value from creation so pull-based subscribers read it before any change.
9390
- const latestValues = {
9336
+ const initialValues = () => ({
9391
9337
  open: isOpen
9392
- };
9393
-
9394
- /** Per-option subscribers, keyed by optionActive:<id>. Sets are created on demand. */
9395
- const optionActiveSubscribers = new Map();
9338
+ });
9339
+ let latestValues = initialValues();
9340
+ function emit(event, value) {
9341
+ subscribers.get(event)?.forEach(cb => cb(value));
9342
+ }
9396
9343
  function notify(event, value) {
9397
- const previous = latestValues.activeDescendantChange ?? null;
9398
9344
  latestValues[event] = value;
9399
- const eventSubscribers = subscribers[event];
9400
- for (const cb of eventSubscribers) cb(value);
9345
+ emit(event, value);
9346
+ }
9401
9347
 
9402
- // Fan out to the 2 affected options only: first the previous one, then the new one.
9403
- if (event === 'activeDescendantChange' && previous !== value) {
9404
- if (previous) optionActiveSubscribers.get(optionActiveEvent(previous))?.forEach(cb => cb(false));
9405
- if (value) optionActiveSubscribers.get(optionActiveEvent(value))?.forEach(cb => cb(true));
9406
- }
9348
+ /** Set the active descendant, then notify the 2 affected items only: first the previous one, then the new one. */
9349
+ function setActiveDescendant(id) {
9350
+ const previous = latestValues.activeDescendantChange ?? null;
9351
+ notify('activeDescendantChange', id);
9352
+ if (previous === id) return;
9353
+ if (previous) emit(optionActiveEvent(previous), false);
9354
+ if (id) emit(optionActiveEvent(id), true);
9407
9355
  }
9408
9356
 
9409
9357
  // Forward-declared so the DOM listeners can reference `handle` (via closure) before it is constructed.
9410
9358
  let handle;
9411
9359
 
9412
9360
  /** The element that holds DOM focus and `aria-activedescendant`. */
9413
- const getFocusOwner = () => link ? link.getFocusOwner() : element;
9414
- function getVisibleOptionCount() {
9415
- let count = 0;
9416
- for (const reg of optionRegistrations.values()) {
9417
- if (!reg.lastFiltered) count += 1;
9418
- }
9419
- return count;
9420
- }
9421
- function isFilteredOut(option) {
9422
- const filterLower = filterValue.toLowerCase();
9423
- return filterLower.length > 0 && !getOptionValue(option).toLowerCase().includes(filterLower);
9424
- }
9361
+ const getFocusOwner = () => link ? link.getFocusOwner() : mounted?.element ?? null;
9425
9362
 
9426
- /** Whether the listbox has visible options or skeletons (something to show). */
9427
- const hasVisibleContent = () => getVisibleOptionCount() > 0 || skeletonCount > 0;
9363
+ /**
9364
+ * Whether the composite has visible items or root skeletons. A nested skeleton is visible only when its
9365
+ * parent item is visible, and then the visible item count is not zero.
9366
+ */
9367
+ const hasVisibleContent = () => specialization.getVisibleCount(filter) > 0 || isLoading();
9428
9368
 
9429
9369
  /**
9430
9370
  * Whether the mounted element holds a status (the live region, e.g. a `Combobox.State` inside the list),
9431
9371
  * outside of a hidden subtree. The status is always rendered (visually hidden when it shows no message), so
9432
- * that the live region stays in the accessibility tree: the element must not hide it. (Read when the options
9372
+ * that the live region stays in the accessibility tree: the element must not hide it. (Read when the items
9433
9373
  * or the skeletons change: a status is rendered with the list, not later.)
9434
9374
  */
9435
9375
  function hasStatus(container) {
@@ -9441,45 +9381,40 @@ function setupListbox(options = {}) {
9441
9381
 
9442
9382
  /** Hide the mounted element (`hidden`) when it has no visible content and no status. */
9443
9383
  function syncHidden() {
9384
+ const element = mounted?.element;
9444
9385
  if (!element) return;
9445
9386
  element.toggleAttribute('hidden', !hasVisibleContent() && !hasStatus(element));
9446
9387
  }
9447
-
9448
- /**
9449
- * Notify sections, then fire `optionsChange` when the visible count changed (or when the input
9450
- * value changed while empty).
9451
- */
9452
- function notifyVisibilityChange() {
9453
- for (const [sectionElement] of sectionRegistrations) {
9454
- notifySection(sectionElement, sectionRegistrations, optionRegistrations);
9455
- }
9388
+ function notifyOptionsChange() {
9456
9389
  syncHidden();
9457
- const visibleCount = getVisibleOptionCount();
9458
- const inputValue = link?.getInputValue?.() ?? '';
9459
- const isEmpty = visibleCount === 0;
9460
- if (visibleCount !== lastOptionsLength || isEmpty && inputValue !== lastInputValue) {
9461
- lastOptionsLength = visibleCount;
9462
- lastInputValue = inputValue;
9463
- notify('optionsChange', {
9464
- optionsLength: visibleCount,
9465
- inputValue
9466
- });
9390
+ const next = {
9391
+ optionsLength: specialization.getVisibleCount(filter),
9392
+ inputValue: link?.getInputValue?.() ?? '',
9393
+ isCountHidden: specialization.isCountHidden?.(filter) ?? false
9394
+ };
9395
+ const isEmpty = next.optionsLength === 0;
9396
+ if (next.optionsLength !== lastOptions.optionsLength || next.isCountHidden !== lastOptions.isCountHidden || isEmpty && next.inputValue !== lastOptions.inputValue) {
9397
+ lastOptions = next;
9398
+ notify('optionsChange', next);
9467
9399
  }
9468
9400
  }
9469
9401
 
9470
9402
  // ── Loading announcement ──────────────────────────────────
9471
9403
 
9472
- /** Start or restart the debounced loading announcement timer if conditions are met. */
9404
+ /** Whether any skeleton is registered (at the root or in a nested level). */
9405
+ const hasSkeleton = () => rootSkeletons.size + nestedSkeletons.size > 0;
9406
+
9407
+ /**
9408
+ * Start the debounced loading announcement when the items are visible and a skeleton is registered.
9409
+ * Every change that makes it false (close, last skeleton removed, destroy) cancels the timer.
9410
+ */
9473
9411
  function startLoadingAnnouncementTimer() {
9474
9412
  clearTimeout(loadingTimer);
9475
- if (skeletonCount > 0 && isOpen) {
9476
- loadingTimer = setTimeout(() => {
9477
- if (skeletonCount > 0 && isOpen) {
9478
- announcementSent = true;
9479
- notify('loadingAnnouncement', true);
9480
- }
9481
- }, LOADING_ANNOUNCEMENT_DELAY);
9482
- }
9413
+ if (!hasSkeleton() || !isOpen) return;
9414
+ loadingTimer = setTimeout(() => {
9415
+ announcementSent = true;
9416
+ notify('loadingAnnouncement', true);
9417
+ }, LOADING_ANNOUNCEMENT_DELAY);
9483
9418
  }
9484
9419
 
9485
9420
  /** Cancel the pending loading announcement and retract the sent one. */
@@ -9491,79 +9426,85 @@ function setupListbox(options = {}) {
9491
9426
  }
9492
9427
  }
9493
9428
 
9494
- /** Called when the skeleton count transitions between 0 and >0 (or vice versa). */
9495
- function onSkeletonCountChange() {
9429
+ /**
9430
+ * Called when a skeleton is registered or unregistered: `loadingChange` follows the root skeletons
9431
+ * only; the loading announcement follows every skeleton.
9432
+ */
9433
+ function onSkeletonCountChange(wasLoading, hadSkeleton) {
9496
9434
  syncHidden();
9497
- const isLoading = skeletonCount > 0;
9498
- lastLoadingState = isLoading;
9499
- notify('loadingChange', isLoading);
9500
- if (isLoading) startLoadingAnnouncementTimer();else resetLoadingAnnouncement();
9435
+ if (isLoading() !== wasLoading) {
9436
+ notify('loadingChange', isLoading());
9437
+ }
9438
+ if (hasSkeleton() === hadSkeleton) return;
9439
+ if (hadSkeleton) resetLoadingAnnouncement();else startLoadingAnnouncementTimer();
9501
9440
  }
9502
9441
 
9503
9442
  // ── Mount (DOM) ───────────────────────────────────────────
9504
9443
 
9505
9444
  function unmount() {
9506
- mountController?.abort();
9507
- mountController = null;
9508
- navigation = null;
9509
- typeaheadController = null;
9510
- element = null;
9445
+ mounted?.controller.abort();
9446
+ mounted = null;
9511
9447
  }
9512
- function mount(newElement) {
9513
- if (element === newElement) return () => {};
9448
+ function mount(container) {
9449
+ if (mounted?.element === container) return () => {};
9514
9450
  unmount();
9515
- element = newElement;
9516
- mountController = new AbortController();
9451
+ const controller = new AbortController();
9517
9452
  const {
9518
9453
  signal
9519
- } = mountController;
9520
- const listbox = newElement;
9454
+ } = controller;
9521
9455
 
9522
9456
  /**
9523
- * Standalone only: true after a pointer press on the list, until the next key press or blur.
9524
- * In pointer mode, the active option is kept (`aria-activedescendant`) but the focus ring is hidden,
9457
+ * Standalone only: true after a pointer press on the composite, until the next key press or blur.
9458
+ * In pointer mode, the active item is kept (`aria-activedescendant`) but the focus ring is hidden,
9525
9459
  * so that the ring only shows for keyboard interaction.
9526
9460
  */
9527
9461
  let isPointerModality = false;
9528
9462
 
9529
- // Select the navigation module (listbox or grid pattern) from the element role.
9530
- const createNavigation = listbox.getAttribute('role') === 'grid' ? createGridNavigation : createListNavigation;
9531
- const nav = createNavigation({
9532
- container: listbox,
9463
+ // The specialization selects the navigation module (pattern) from the element.
9464
+ const nav = specialization.createNavigation({
9465
+ container,
9533
9466
  wrap: wrapNavigation,
9534
9467
  signal,
9535
9468
  getActiveItem: () => {
9536
9469
  const id = getFocusOwner()?.getAttribute('aria-activedescendant');
9537
- return id && listbox.querySelector(`#${CSS.escape(id)}`) || null;
9470
+ return id && container.querySelector(`#${CSS.escape(id)}`) || null;
9538
9471
  },
9539
9472
  callbacks: {
9540
9473
  onActivate(item) {
9541
9474
  if (!isPointerModality) item.setAttribute('data-focus-visible-added', 'true');
9542
9475
  getFocusOwner()?.setAttribute('aria-activedescendant', item.id);
9543
- notify('activeDescendantChange', item.id);
9544
- requestAnimationFrame(() => nav.scrollIntoView(item));
9476
+ setActiveDescendant(item.id);
9477
+ requestAnimationFrame(() => {
9478
+ // Skip the scroll when the composite unmounted in the meantime.
9479
+ if (!signal.aborted) nav.scrollIntoView(item);
9480
+ });
9545
9481
  },
9546
9482
  onDeactivate(item) {
9547
9483
  item.removeAttribute('data-focus-visible-added');
9548
9484
  },
9549
9485
  onClear() {
9550
9486
  getFocusOwner()?.setAttribute('aria-activedescendant', '');
9551
- notify('activeDescendantChange', null);
9487
+ setActiveDescendant(null);
9552
9488
  }
9553
9489
  }
9554
9490
  });
9555
- navigation = nav;
9556
9491
  const {
9557
9492
  focusNav,
9558
9493
  cellSelector
9559
9494
  } = nav;
9495
+ const typeahead = createTypeahead(() => createSelectorTreeWalker(container, cellSelector), getOptionLabel, signal);
9496
+ mounted = {
9497
+ element: container,
9498
+ navigation: nav,
9499
+ typeahead,
9500
+ controller
9501
+ };
9560
9502
  syncHidden();
9561
- link?.onMount?.(listbox);
9562
- typeaheadController = createTypeahead(() => createSelectorTreeWalker(listbox, cellSelector), getOptionLabel, signal);
9503
+ link?.onMount?.(container);
9563
9504
 
9564
- // ── Delegated listbox listeners ───────────────────────
9505
+ // ── Delegated listeners ───────────────────────────────
9565
9506
 
9566
- listbox.addEventListener('click', event => {
9507
+ container.addEventListener('click', event => {
9567
9508
  const cell = event.target.closest(cellSelector);
9568
9509
  if (!cell) return;
9569
9510
  // Do not select disabled cells.
@@ -9571,29 +9512,30 @@ function setupListbox(options = {}) {
9571
9512
  event.stopPropagation();
9572
9513
  return;
9573
9514
  }
9574
- // Action cell — skip option selection, let its own handler fire.
9515
+ // Not an option cell (e.g. grid action cell) — skip the selection, let its own handler fire.
9575
9516
  if (!nav.isOptionCell(cell)) return;
9576
9517
  handle.select(cell);
9577
9518
  getFocusOwner()?.focus();
9578
- // Standalone: the clicked option becomes the active option.
9519
+ // Standalone: the clicked item becomes the active item.
9579
9520
  if (isStandalone) focusNav.goTo(() => cell);
9580
9521
  }, {
9581
9522
  signal
9582
9523
  });
9583
9524
 
9584
9525
  // Prevent mousedown on cells to avoid moving focus away from the focus owner before click fires.
9585
- listbox.addEventListener('mousedown', event => {
9526
+ container.addEventListener('mousedown', event => {
9586
9527
  // Standalone: pointer interaction hides the focus ring (until the next key press).
9587
9528
  if (isStandalone) isPointerModality = true;
9588
9529
  if (event.target.closest(cellSelector)) event.preventDefault();
9589
9530
  }, {
9590
9531
  signal
9591
9532
  });
9533
+ specialization.onMount?.(container, signal);
9592
9534
 
9593
9535
  // ── Standalone focus owner listeners ──────────────────
9594
9536
  if (isStandalone) {
9595
- listbox.addEventListener('keydown', event => {
9596
- // Keyboard interaction: show the focus ring on the active option.
9537
+ container.addEventListener('keydown', event => {
9538
+ // Keyboard interaction: show the focus ring on the active item.
9597
9539
  if (isPointerModality) {
9598
9540
  isPointerModality = false;
9599
9541
  focusNav.selectors.activeItem?.setAttribute('data-focus-visible-added', 'true');
@@ -9605,16 +9547,14 @@ function setupListbox(options = {}) {
9605
9547
  }, {
9606
9548
  signal
9607
9549
  });
9608
- // On focus: show the visual focus on the selected option, or else on the first option.
9609
- listbox.addEventListener('focus', () => {
9610
- if (!focusNav.selectors.activeItem) {
9611
- focusNav.goTo(s => s.getMatching(isSelected) ?? s.getFirst());
9612
- }
9550
+ // On focus: show the visual focus on the selected item, or else on the first item.
9551
+ container.addEventListener('focus', () => {
9552
+ if (!focusNav.selectors.activeItem) handle.activateDefaultItem('first');
9613
9553
  }, {
9614
9554
  signal
9615
9555
  });
9616
9556
  // On blur: hide the visual focus and reset the interaction mode (a later Tab shows the ring).
9617
- listbox.addEventListener('focusout', () => {
9557
+ container.addEventListener('focusout', () => {
9618
9558
  focusNav.clear();
9619
9559
  isPointerModality = false;
9620
9560
  }, {
@@ -9622,18 +9562,18 @@ function setupListbox(options = {}) {
9622
9562
  });
9623
9563
  }
9624
9564
  return () => {
9625
- if (element === newElement) unmount();
9565
+ if (mounted?.element === container) unmount();
9626
9566
  };
9627
9567
  }
9628
9568
  handle = {
9629
9569
  get element() {
9630
- return element;
9570
+ return mounted?.element ?? null;
9631
9571
  },
9632
9572
  get type() {
9633
- return navigation?.type ?? null;
9573
+ return mounted?.navigation.type ?? null;
9634
9574
  },
9635
- get focusNav() {
9636
- return navigation?.focusNav ?? null;
9575
+ get activeItem() {
9576
+ return mounted?.navigation.focusNav.selectors.activeItem ?? null;
9637
9577
  },
9638
9578
  get isStandalone() {
9639
9579
  return isStandalone;
@@ -9642,10 +9582,7 @@ function setupListbox(options = {}) {
9642
9582
  return isOpen;
9643
9583
  },
9644
9584
  get isMultiSelect() {
9645
- return element?.getAttribute('aria-multiselectable') === 'true';
9646
- },
9647
- get isLoading() {
9648
- return skeletonCount > 0;
9585
+ return mounted?.element.getAttribute('aria-multiselectable') === 'true';
9649
9586
  },
9650
9587
  get hasVisibleContent() {
9651
9588
  return hasVisibleContent();
@@ -9662,12 +9599,13 @@ function setupListbox(options = {}) {
9662
9599
  value: option ? getOptionValue(option) : ''
9663
9600
  }, option);
9664
9601
  },
9665
- navigateHorizontal(key) {
9666
- return navigation?.navigateHorizontal(key) ?? false;
9667
- },
9668
9602
  handleKeydown(event) {
9669
- const nav = navigation?.focusNav;
9670
- if (!nav) return false;
9603
+ if (!mounted) return false;
9604
+ const {
9605
+ navigation,
9606
+ typeahead
9607
+ } = mounted;
9608
+ const nav = navigation.focusNav;
9671
9609
  const {
9672
9610
  activeItem,
9673
9611
  hasNavigableItems
@@ -9675,17 +9613,17 @@ function setupListbox(options = {}) {
9675
9613
  switch (event.key) {
9676
9614
  // Arrows: consume the key even without navigable items (nothing to move to, no pending intent).
9677
9615
  case 'ArrowDown':
9678
- if (activeItem) nav.goDown();else if (hasNavigableItems) nav.goTo(s => s.getMatching(isSelected) ?? s.getFirst());
9616
+ if (activeItem) nav.goDown();else if (hasNavigableItems) handle.activateDefaultItem('first');
9679
9617
  return true;
9680
9618
  case 'ArrowUp':
9681
- if (activeItem) nav.goUp();else if (hasNavigableItems) nav.goTo(s => s.getMatching(isSelected) ?? s.getLast());
9619
+ if (activeItem) nav.goUp();else if (hasNavigableItems) handle.activateDefaultItem('last');
9682
9620
  return true;
9683
9621
  case 'ArrowLeft':
9684
9622
  case 'ArrowRight':
9685
- // Grid: move between cells (consume the key even without an active cell).
9686
- if (navigation?.type !== 'grid') return false;
9687
- handle.navigateHorizontal(event.key);
9688
- return true;
9623
+ // Delegated to the navigation module (e.g. grid: move between cells, tree: open or close).
9624
+ // Standalone: consume the key even when nothing moved (like ArrowDown/ArrowUp, the arrow
9625
+ // keys never leak to the page). Linked: the combobox input moves its caret instead.
9626
+ return navigation.navigateHorizontal(event.key) || isStandalone;
9689
9627
  case 'Home':
9690
9628
  nav.goTo(s => s.getFirst());
9691
9629
  return true;
@@ -9693,7 +9631,7 @@ function setupListbox(options = {}) {
9693
9631
  nav.goTo(s => s.getLast());
9694
9632
  return true;
9695
9633
  case 'PageUp':
9696
- // Without an active option, let the page scroll.
9634
+ // Without an active item, let the page scroll.
9697
9635
  if (!activeItem) return false;
9698
9636
  nav.goToOffset(-10);
9699
9637
  return true;
@@ -9703,15 +9641,13 @@ function setupListbox(options = {}) {
9703
9641
  return true;
9704
9642
  case 'Enter':
9705
9643
  case ' ':
9706
- // Select (single) or toggle (multi) the active option. Without an active option the key
9644
+ // Select (single) or toggle (multi) the active item. Without an active item the key
9707
9645
  // is not handled (a combobox lets Enter submit a surrounding form).
9708
9646
  if (!activeItem) return false;
9709
9647
  if (!isOptionDisabled(activeItem)) activeItem.click();
9710
9648
  return true;
9711
9649
  default:
9712
9650
  if (isPrintableKey(event)) {
9713
- const typeahead = typeaheadController;
9714
- if (!typeahead) return false;
9715
9651
  typeahead.handle(event.key, activeItem);
9716
9652
  nav.goTo(n => typeahead.rematch(n.activeItem));
9717
9653
  return true;
@@ -9720,10 +9656,267 @@ function setupListbox(options = {}) {
9720
9656
  }
9721
9657
  },
9722
9658
  flushPendingNavigation() {
9723
- navigation?.focusNav.flushPendingNavigation();
9659
+ mounted?.navigation.focusNav.flushPendingNavigation();
9660
+ },
9661
+ clearActiveItem() {
9662
+ mounted?.navigation.focusNav.clear();
9663
+ },
9664
+ setActiveItem(item) {
9665
+ mounted?.navigation.focusNav.goTo(() => item);
9666
+ },
9667
+ activateDefaultItem(edge) {
9668
+ mounted?.navigation.focusNav.goTo(s => s.getMatching(isSelected) ?? (edge === 'first' ? s.getFirst() : s.getLast()));
9669
+ },
9670
+ setFilter(value, mode = 'auto') {
9671
+ filter = {
9672
+ value,
9673
+ mode
9674
+ };
9675
+ specialization.applyFilter(filter);
9676
+ notifyOptionsChange();
9677
+ },
9678
+ registerSkeleton({
9679
+ isNested = false
9680
+ } = {}) {
9681
+ const skeletons = isNested ? nestedSkeletons : rootSkeletons;
9682
+ const token = {};
9683
+ const update = change => {
9684
+ const wasLoading = isLoading();
9685
+ const hadSkeleton = hasSkeleton();
9686
+ change();
9687
+ onSkeletonCountChange(wasLoading, hadSkeleton);
9688
+ };
9689
+ update(() => skeletons.add(token));
9690
+ return () => {
9691
+ if (skeletons.has(token)) update(() => skeletons.delete(token));
9692
+ };
9693
+ },
9694
+ subscribe(event, callback) {
9695
+ let set = subscribers.get(event);
9696
+ if (!set) {
9697
+ set = new Set();
9698
+ subscribers.set(event, set);
9699
+ }
9700
+ const subscriber = callback;
9701
+ set.add(subscriber);
9702
+ return () => {
9703
+ set.delete(subscriber);
9704
+ if (!set.size && subscribers.get(event) === set) subscribers.delete(event);
9705
+ };
9706
+ },
9707
+ getSnapshot(event) {
9708
+ if (isOptionActiveEvent(event)) {
9709
+ // Derived value. No per-id value is stored.
9710
+ return latestValues.activeDescendantChange === getOptionActiveId(event);
9711
+ }
9712
+ return latestValues[event];
9713
+ },
9714
+ destroy() {
9715
+ unmount();
9716
+ clearTimeout(loadingTimer);
9717
+ announcementSent = false;
9718
+ filter = NO_FILTER;
9719
+ lastOptions = INITIAL_OPTIONS;
9720
+ isOpen = isStandalone;
9721
+ rootSkeletons.clear();
9722
+ nestedSkeletons.clear();
9723
+ // After the state reset: the initial values read it.
9724
+ latestValues = initialValues();
9725
+ specialization.destroy?.();
9726
+ subscribers.clear();
9727
+ }
9728
+ };
9729
+ return {
9730
+ handle,
9731
+ notifyOptionsChange,
9732
+ getFilter: () => filter
9733
+ };
9734
+ }
9735
+
9736
+ const OPTION_SELECTOR = '[role="option"]';
9737
+ const GRID_CELL_SELECTOR = '[role="gridcell"]';
9738
+
9739
+ /** Navigation module for the listbox pattern (1D list of `role="option"`). */
9740
+ function createListNavigation(options) {
9741
+ const {
9742
+ container,
9743
+ callbacks,
9744
+ signal,
9745
+ getActiveItem,
9746
+ wrap
9747
+ } = options;
9748
+ const focusNav = createListFocusNavigation({
9749
+ container,
9750
+ itemSelector: OPTION_SELECTOR,
9751
+ wrap,
9752
+ getActiveItem
9753
+ }, callbacks, signal);
9754
+ return {
9755
+ type: 'listbox',
9756
+ focusNav,
9757
+ cellSelector: OPTION_SELECTOR,
9758
+ isOptionCell: () => true,
9759
+ scrollIntoView(item) {
9760
+ // Last option: find the last child containing an option (not followed by another one).
9761
+ const lastItem = container.querySelector(`:scope > :has(${OPTION_SELECTOR}):not(:has(~ * ${OPTION_SELECTOR})) ${OPTION_SELECTOR}`);
9762
+ if (item === lastItem) {
9763
+ // Scroll to the end of the listbox (snaps to the end of the scroll container via CSS scroll snap)
9764
+ container.lastElementChild?.scrollIntoView({
9765
+ block: 'nearest'
9766
+ });
9767
+ } else {
9768
+ const toScrollTo = item.closest('[role=listbox] > *') || item;
9769
+ toScrollTo.scrollIntoView({
9770
+ block: 'nearest'
9771
+ });
9772
+ }
9773
+ },
9774
+ navigateHorizontal: () => false
9775
+ };
9776
+ }
9777
+
9778
+ /** Navigation module for the grid pattern (rows of `role="gridcell"`: option cell + action cells). */
9779
+ function createGridNavigation(options) {
9780
+ const {
9781
+ container,
9782
+ callbacks,
9783
+ signal
9784
+ } = options;
9785
+ const focusNav = createGridFocusNavigation({
9786
+ container,
9787
+ rowSelector: '[role="row"]',
9788
+ cellSelector: GRID_CELL_SELECTOR,
9789
+ wrap: true
9790
+ }, callbacks, signal);
9791
+ return {
9792
+ type: 'grid',
9793
+ focusNav,
9794
+ cellSelector: GRID_CELL_SELECTOR,
9795
+ isOptionCell: cell => !isActionCell(cell),
9796
+ scrollIntoView(item) {
9797
+ item.scrollIntoView({
9798
+ block: 'nearest'
9799
+ });
9800
+ },
9801
+ // Move the active cell left/right (only when there is an active cell).
9802
+ navigateHorizontal(key) {
9803
+ if (!focusNav.selectors.activeItem) return false;
9804
+ if (key === 'ArrowLeft') focusNav.goLeft();else focusNav.goRight();
9805
+ return true;
9806
+ }
9807
+ };
9808
+ }
9809
+
9810
+ /**
9811
+ * Set up listbox behavior (WAI-ARIA listbox or grid pattern) independent of any DOM element.
9812
+ *
9813
+ * Built on the composite base (see {@link setupComposite}: focus owner, focus navigation, keyboard,
9814
+ * selection, open state, skeletons, loading announcement and events). The listbox adds the
9815
+ * option/section registry, the option filter and the list and grid navigation modules.
9816
+ * The navigation module (listbox or grid pattern) is selected from the element role on mount.
9817
+ *
9818
+ * - Standalone (no `focusOwner` option): the listbox element owns DOM focus and
9819
+ * `aria-activedescendant`, and handles its own keyboard navigation.
9820
+ * - Linked (`focusOwner` option, e.g. a combobox trigger): the parent owns focus and the keyboard;
9821
+ * the listbox writes `aria-activedescendant` on the parent focus owner.
9822
+ *
9823
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/listbox/
9824
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/grid/
9825
+ */
9826
+ function setupListbox(options = {}) {
9827
+ const optionRegistrations = new Map();
9828
+ const sectionRegistrations = new Map();
9829
+ function getVisibleOptionCount() {
9830
+ let count = 0;
9831
+ for (const reg of optionRegistrations.values()) {
9832
+ if (!reg.lastFiltered) count += 1;
9833
+ }
9834
+ return count;
9835
+ }
9836
+ function isFilteredOut(option, {
9837
+ value,
9838
+ mode
9839
+ }) {
9840
+ // `'manual'`: the consumer filters the options, none is hidden.
9841
+ const filterLower = value.toLowerCase();
9842
+ return mode === 'auto' && filterLower.length > 0 && !getOptionValue(option).toLowerCase().includes(filterLower);
9843
+ }
9844
+
9845
+ /** Update the filter state of a registered option. Returns whether it changed (then notifies the option). */
9846
+ function updateFilterState(optionElement, filter) {
9847
+ const reg = optionRegistrations.get(optionElement);
9848
+ if (!reg) return false;
9849
+ const isFiltered = isFilteredOut(optionElement, filter);
9850
+ // Only notify when state actually changes to avoid unnecessary re-renders.
9851
+ if (isFiltered === reg.lastFiltered) return false;
9852
+ reg.lastFiltered = isFiltered;
9853
+ reg.callback(isFiltered);
9854
+ return true;
9855
+ }
9856
+
9857
+ /**
9858
+ * Compute the current state of a section and notify when it changed (or always, with `force`).
9859
+ *
9860
+ * Section state:
9861
+ * - `hidden`: true when the section has registered options but all are filtered out.
9862
+ * - `aria-hidden`: true when the section has no registered options at all (skeleton-only).
9863
+ *
9864
+ * At most one of `hidden` / `aria-hidden` is true at a time.
9865
+ */
9866
+ function notifySection(sectionElement, force) {
9867
+ const reg = sectionRegistrations.get(sectionElement);
9868
+ if (!reg) return;
9869
+ let hasOptions = false;
9870
+ let hasVisibleOption = false;
9871
+ for (const [optionElement, optionReg] of optionRegistrations) {
9872
+ if (sectionElement.contains(optionElement)) {
9873
+ hasOptions = true;
9874
+ if (!optionReg.lastFiltered) {
9875
+ hasVisibleOption = true;
9876
+ break;
9877
+ }
9878
+ }
9879
+ }
9880
+ const state = {
9881
+ hidden: hasOptions && !hasVisibleOption,
9882
+ 'aria-hidden': !hasOptions
9883
+ };
9884
+ if (force || state.hidden !== reg.last.hidden || state['aria-hidden'] !== reg.last['aria-hidden']) {
9885
+ reg.last = state;
9886
+ reg.callback(state);
9887
+ }
9888
+ }
9889
+ function notifySections() {
9890
+ for (const [sectionElement] of sectionRegistrations) notifySection(sectionElement);
9891
+ }
9892
+ const {
9893
+ handle: composite,
9894
+ notifyOptionsChange,
9895
+ getFilter
9896
+ } = setupComposite(options, {
9897
+ // Select the navigation module (listbox or grid pattern) from the element role.
9898
+ createNavigation: navigationOptions => navigationOptions.container.getAttribute('role') === 'grid' ? createGridNavigation(navigationOptions) : createListNavigation(navigationOptions),
9899
+ getVisibleCount: getVisibleOptionCount,
9900
+ applyFilter(filter) {
9901
+ for (const optionElement of optionRegistrations.keys()) updateFilterState(optionElement, filter);
9902
+ notifySections();
9724
9903
  },
9904
+ destroy() {
9905
+ optionRegistrations.clear();
9906
+ sectionRegistrations.clear();
9907
+ }
9908
+ });
9909
+
9910
+ /** Notify sections, then fire `optionsChange` when the visible count changed. */
9911
+ function notifyVisibilityChange() {
9912
+ notifySections();
9913
+ notifyOptionsChange();
9914
+ }
9915
+
9916
+ // Add the option/section registry to the composite handle (keeps its getters).
9917
+ return Object.assign(composite, {
9725
9918
  registerOption(optionElement, callback) {
9726
- const isFiltered = isFilteredOut(optionElement);
9919
+ const isFiltered = isFilteredOut(optionElement, getFilter());
9727
9920
  optionRegistrations.set(optionElement, {
9728
9921
  callback,
9729
9922
  lastFiltered: isFiltered
@@ -9736,27 +9929,8 @@ function setupListbox(options = {}) {
9736
9929
  notifyVisibilityChange();
9737
9930
  };
9738
9931
  },
9739
- setFilter(newFilter) {
9740
- filterValue = newFilter;
9741
- for (const [optionElement, reg] of optionRegistrations) {
9742
- const isFiltered = isFilteredOut(optionElement);
9743
- // Only notify when state actually changes to avoid unnecessary re-renders.
9744
- if (isFiltered !== reg.lastFiltered) {
9745
- reg.lastFiltered = isFiltered;
9746
- reg.callback(isFiltered);
9747
- }
9748
- }
9749
- notifyVisibilityChange();
9750
- },
9751
9932
  refilterOption(optionElement) {
9752
- const reg = optionRegistrations.get(optionElement);
9753
- if (!reg) return;
9754
- const isFiltered = isFilteredOut(optionElement);
9755
- if (isFiltered !== reg.lastFiltered) {
9756
- reg.lastFiltered = isFiltered;
9757
- reg.callback(isFiltered);
9758
- notifyVisibilityChange();
9759
- }
9933
+ if (updateFilterState(optionElement, getFilter())) notifyVisibilityChange();
9760
9934
  },
9761
9935
  registerSection(sectionElement, callback) {
9762
9936
  sectionRegistrations.set(sectionElement, {
@@ -9767,73 +9941,12 @@ function setupListbox(options = {}) {
9767
9941
  }
9768
9942
  });
9769
9943
  // Compute and notify initial state immediately (force to ensure callback fires).
9770
- notifySection(sectionElement, sectionRegistrations, optionRegistrations, true);
9944
+ notifySection(sectionElement, true);
9771
9945
  return () => {
9772
9946
  sectionRegistrations.delete(sectionElement);
9773
9947
  };
9774
- },
9775
- registerSkeleton() {
9776
- const wasLoading = skeletonCount > 0;
9777
- skeletonCount += 1;
9778
- if (!wasLoading) onSkeletonCountChange();
9779
- return () => {
9780
- skeletonCount -= 1;
9781
- if (skeletonCount === 0) onSkeletonCountChange();
9782
- };
9783
- },
9784
- subscribe(event, callback) {
9785
- if (isOptionActiveEvent(event)) {
9786
- const optionCallback = callback;
9787
- const set = optionActiveSubscribers.get(event) ?? new Set();
9788
- optionActiveSubscribers.set(event, set);
9789
- set.add(optionCallback);
9790
- // Replay (same as open): Vue subscribes after mount and can miss the activation.
9791
- if (latestValues.activeDescendantChange === event.slice(OPTION_ACTIVE_EVENT_PREFIX.length)) {
9792
- optionCallback(true);
9793
- }
9794
- return () => {
9795
- set.delete(optionCallback);
9796
- if (!set.size) optionActiveSubscribers.delete(event);
9797
- };
9798
- }
9799
- const staticEvent = event;
9800
- subscribers[staticEvent].add(callback);
9801
- // Replay current loading/visible state to late subscribers (e.g. async Vue watchers).
9802
- if (event === 'loadingChange' && lastLoadingState || event === 'open' && isOpen) {
9803
- callback(true);
9804
- }
9805
- return () => {
9806
- subscribers[staticEvent].delete(callback);
9807
- };
9808
- },
9809
- getSnapshot(event) {
9810
- if (isOptionActiveEvent(event)) {
9811
- // Derived value. No per-id value is stored.
9812
- return latestValues.activeDescendantChange === event.slice(OPTION_ACTIVE_EVENT_PREFIX.length);
9813
- }
9814
- return latestValues[event];
9815
- },
9816
- destroy() {
9817
- unmount();
9818
- clearTimeout(loadingTimer);
9819
- announcementSent = false;
9820
- filterValue = '';
9821
- lastOptionsLength = 0;
9822
- lastInputValue = '';
9823
- lastLoadingState = false;
9824
- for (const key of Object.keys(latestValues)) {
9825
- delete latestValues[key];
9826
- }
9827
- isOpen = isStandalone;
9828
- latestValues.open = isOpen;
9829
- optionRegistrations.clear();
9830
- sectionRegistrations.clear();
9831
- skeletonCount = 0;
9832
- optionActiveSubscribers.clear();
9833
- for (const set of Object.values(subscribers)) set.clear();
9834
9948
  }
9835
- };
9836
- return handle;
9949
+ });
9837
9950
  }
9838
9951
 
9839
9952
  const DEFAULT_COMBOBOX_POPOVER_MAX_HEIGHT = '80vh';
@@ -9901,7 +10014,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
9901
10014
  callbacks.onSelect?.(option);
9902
10015
  // Close on selection (when not multiselectable)
9903
10016
  if (element && !list.isMultiSelect) {
9904
- list.focusNav?.clear();
10017
+ list.clearActiveItem();
9905
10018
  // Defer the close to the next frame (to make sure all other click handler resolve).
9906
10019
  requestAnimationFrame(() => {
9907
10020
  handle.setIsOpen(false);
@@ -9934,7 +10047,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
9934
10047
  /** Detach everything (abort all listeners, clear state). */
9935
10048
  function detach() {
9936
10049
  // Clear the active option while the old trigger is still the focus owner.
9937
- list.focusNav?.clear();
10050
+ list.clearActiveItem();
9938
10051
  abortController?.abort();
9939
10052
  abortController = null;
9940
10053
  }
@@ -9959,7 +10072,6 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
9959
10072
  const {
9960
10073
  altKey
9961
10074
  } = event;
9962
- const nav = list.focusNav;
9963
10075
  switch (event.key) {
9964
10076
  case 'Enter':
9965
10077
  // Open with an active option: "click" it (handled by the listbox).
@@ -9979,7 +10091,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
9979
10091
  if (!handle.isOpen) {
9980
10092
  handle.setIsOpen(true);
9981
10093
  // Focus first or selected item on open (deferred until the options commit).
9982
- if (!altKey) nav?.goTo(s => s.getMatching(isSelected) ?? s.getFirst());
10094
+ if (!altKey) list.activateDefaultItem('first');
9983
10095
  } else if (!altKey) {
9984
10096
  list.handleKeydown(event);
9985
10097
  }
@@ -9991,8 +10103,8 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
9991
10103
  if (!handle.isOpen && !altKey) {
9992
10104
  handle.setIsOpen(true);
9993
10105
  // Focus last or selected item on open (deferred until the options commit).
9994
- nav?.goTo(s => s.getMatching(isSelected) ?? s.getLast());
9995
- } else if (handle.isOpen && (nav?.selectors.activeItem || !altKey)) {
10106
+ list.activateDefaultItem('last');
10107
+ } else if (handle.isOpen && (list.activeItem || !altKey)) {
9996
10108
  // Alt+ArrowUp only moves when there is an active option.
9997
10109
  list.handleKeydown(event);
9998
10110
  }
@@ -10004,8 +10116,8 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
10004
10116
  // When there is nothing to close or clear, let Escape propagate
10005
10117
  // (ex: so a surrounding dialog can close).
10006
10118
  if (alwaysOpen) {
10007
- if (nav?.selectors.activeItem) {
10008
- nav.clear();
10119
+ if (list.activeItem) {
10120
+ list.clearActiveItem();
10009
10121
  flag = true;
10010
10122
  }
10011
10123
  } else if (handle.isOpen) {
@@ -10078,11 +10190,11 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
10078
10190
  setIsOpen(isOpen) {
10079
10191
  // Always open: a close request only clears the active option.
10080
10192
  if (alwaysOpen && !isOpen) {
10081
- list.focusNav?.clear();
10193
+ list.clearActiveItem();
10082
10194
  return;
10083
10195
  }
10084
10196
  if (list.isOpen === isOpen) return;
10085
- if (!isOpen) list.focusNav?.clear();
10197
+ if (!isOpen) list.clearActiveItem();
10086
10198
  // Update aria-expanded on trigger (false when no visible options or skeletons)
10087
10199
  trigger?.setAttribute('aria-expanded', String(isOpen && list.hasVisibleContent));
10088
10200
  // Last: the listbox dispatches `open` to the subscribers, which must see the trigger in its final state.
@@ -10137,23 +10249,28 @@ function setupComboboxButton(button, callbacks) {
10137
10249
  signal
10138
10250
  });
10139
10251
  return event => {
10140
- const nav = combobox.list.focusNav;
10252
+ const {
10253
+ list
10254
+ } = combobox;
10255
+ const {
10256
+ activeItem
10257
+ } = list;
10141
10258
  switch (event.key) {
10142
10259
  case 'Tab':
10143
10260
  // Selects the focused option
10144
- if (combobox.isOpen && nav?.selectors.activeItem) {
10145
- combobox.list.select(nav.selectors.activeItem);
10261
+ if (combobox.isOpen && activeItem) {
10262
+ list.select(activeItem);
10146
10263
  }
10147
10264
  // Return false to continue normal 'Tab' behavior (focus next).
10148
10265
  return false;
10149
10266
  case ' ':
10150
10267
  // Space acts like Enter in button mode: open, or "click" the active option (listbox).
10151
- if (combobox.isOpen) combobox.list.handleKeydown(event);else combobox.setIsOpen(true);
10268
+ if (combobox.isOpen) list.handleKeydown(event);else combobox.setIsOpen(true);
10152
10269
  return true;
10153
10270
  case 'ArrowUp':
10154
10271
  // Alt+ArrowUp: select the focused option and close.
10155
- if (event.altKey && combobox.isOpen && nav?.selectors.activeItem) {
10156
- combobox.list.select(nav.selectors.activeItem);
10272
+ if (event.altKey && combobox.isOpen && activeItem) {
10273
+ list.select(activeItem);
10157
10274
  combobox.setIsOpen(false);
10158
10275
  return true;
10159
10276
  }
@@ -10163,12 +10280,12 @@ function setupComboboxButton(button, callbacks) {
10163
10280
  case 'End':
10164
10281
  // Open, then jump (the listbox defers the jump until the options commit when opening from closed).
10165
10282
  combobox.setIsOpen(true);
10166
- combobox.list.handleKeydown(event);
10283
+ list.handleKeydown(event);
10167
10284
  return true;
10168
10285
  case 'ArrowLeft':
10169
10286
  case 'ArrowRight':
10170
10287
  // Grid pattern: navigate to the previous/next cell (listbox).
10171
- return combobox.isOpen && combobox.list.handleKeydown(event);
10288
+ return combobox.isOpen && list.handleKeydown(event);
10172
10289
  case 'Escape':
10173
10290
  // Close if open; never clear selection (button-mode has no text input).
10174
10291
  if (combobox.isOpen) {
@@ -10182,7 +10299,7 @@ function setupComboboxButton(button, callbacks) {
10182
10299
  // Printable characters: open, then typeahead (listbox).
10183
10300
  if (!isPrintableKey(event)) return false;
10184
10301
  combobox.setIsOpen(true);
10185
- combobox.list.handleKeydown(event);
10302
+ list.handleKeydown(event);
10186
10303
  return true;
10187
10304
  }
10188
10305
  };
@@ -10280,13 +10397,13 @@ function useComboboxContext() {
10280
10397
  * Hook to subscribe to a combobox event (`open`, `optionsChange`, `loadingChange`,
10281
10398
  * `activeDescendantChange`, …). Must be used within a `Combobox.Provider`.
10282
10399
  *
10283
- * The events are dispatched by the listbox handle of the combobox (see {@link useListboxEvent}).
10400
+ * The events are dispatched by the listbox handle of the combobox (see {@link useCompositeEvent}).
10284
10401
  */
10285
10402
  function useComboboxEvent(event, initialValue) {
10286
10403
  const {
10287
10404
  handle
10288
10405
  } = useComboboxContext();
10289
- return useListboxEvent(handle?.list ?? null, event, initialValue);
10406
+ return useCompositeEvent(handle?.list ?? null, event, initialValue);
10290
10407
  }
10291
10408
 
10292
10409
  /**
@@ -10326,13 +10443,10 @@ const ComboboxButton = Object.assign(forwardRefPolymorphic((props, ref) => {
10326
10443
  setHandle
10327
10444
  } = useComboboxContext();
10328
10445
  const [isOpen] = useComboboxOpen();
10329
- const {
10330
- list
10331
- } = useListboxContext();
10332
- const state = useListboxEvent(list, 'optionsChange', {
10446
+ const state = useComboboxEvent('optionsChange', {
10333
10447
  optionsLength: 0
10334
10448
  });
10335
- const isLoading = useListboxEvent(list, 'loadingChange', false);
10449
+ const isLoading = useComboboxEvent('loadingChange', false);
10336
10450
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10337
10451
  const {
10338
10452
  as,
@@ -10452,7 +10566,7 @@ function setupComboboxInput(input, options) {
10452
10566
  input.addEventListener('input', event => {
10453
10567
  if (!(event instanceof InputEvent)) return;
10454
10568
  if (isDisabled()) return;
10455
- combobox.list.focusNav?.clear();
10569
+ combobox.list.clearActiveItem();
10456
10570
  userHasTyped = true;
10457
10571
 
10458
10572
  // Notify the framework wrapper of the new input value synchronously.
@@ -10468,7 +10582,7 @@ function setupComboboxInput(input, options) {
10468
10582
  // Open on focus (only when openOnFocus is enabled).
10469
10583
  input.addEventListener('focus', () => {
10470
10584
  if (isDisabled()) return;
10471
- combobox.list.focusNav?.clear();
10585
+ combobox.list.clearActiveItem();
10472
10586
  if (openOnFocus) {
10473
10587
  combobox.setIsOpen(true);
10474
10588
  }
@@ -10504,25 +10618,27 @@ function setupComboboxInput(input, options) {
10504
10618
  });
10505
10619
  signal.addEventListener('abort', unsubscribeOpen);
10506
10620
  return event => {
10507
- const nav = combobox.list.focusNav;
10621
+ const {
10622
+ list
10623
+ } = combobox;
10508
10624
  switch (event.key) {
10509
10625
  case 'Home':
10510
10626
  input.setSelectionRange(0, 0);
10511
- nav?.clear();
10627
+ list.clearActiveItem();
10512
10628
  return true;
10513
10629
  case 'End':
10514
10630
  {
10515
10631
  const len = input.value.length;
10516
10632
  input.setSelectionRange(len, len);
10517
- nav?.clear();
10633
+ list.clearActiveItem();
10518
10634
  return true;
10519
10635
  }
10520
10636
  case 'ArrowLeft':
10521
10637
  case 'ArrowRight':
10522
10638
  // Grid pattern: navigate cells when an active cell exists.
10523
- if (combobox.list.navigateHorizontal(event.key)) return true;
10639
+ if (list.handleKeydown(event)) return true;
10524
10640
  // Otherwise: clear active item, allow caret movement.
10525
- nav?.clear();
10641
+ list.clearActiveItem();
10526
10642
  return false;
10527
10643
  default:
10528
10644
  return false;
@@ -11202,13 +11318,10 @@ const ComboboxInput = forwardRef((props, ref) => {
11202
11318
  selectionMode,
11203
11319
  ...otherProps
11204
11320
  } = props;
11205
- const {
11206
- list
11207
- } = useListboxContext();
11208
- const state = useListboxEvent(list, 'optionsChange', {
11321
+ const state = useComboboxEvent('optionsChange', {
11209
11322
  optionsLength: 0
11210
11323
  });
11211
- const isLoading = useListboxEvent(list, 'loadingChange', false);
11324
+ const isLoading = useComboboxEvent('loadingChange', false);
11212
11325
  const internalInputRef = useRef(null);
11213
11326
  const mergedInputRef = useMergeRefs(externalInputRef, internalInputRef);
11214
11327
 
@@ -11488,11 +11601,10 @@ function ComboboxProvider(props) {
11488
11601
  listboxId,
11489
11602
  anchorRef
11490
11603
  }), [handle, listboxId]);
11491
- // The listbox of the combobox: shared with the list, the options and the state through the listbox context.
11492
- const listboxContextValue = useMemo(() => ({
11493
- list: handle?.list ?? null,
11494
- listboxId,
11495
- type: 'listbox'
11604
+ // The listbox of the combobox: shared with the list, the options and the state through the composite context.
11605
+ const compositeContextValue = useMemo(() => ({
11606
+ handle: handle?.list ?? null,
11607
+ id: listboxId
11496
11608
  }), [handle, listboxId]);
11497
11609
 
11498
11610
  // Force the always open state (`undefined`: the core detects the inline listbox).
@@ -11511,8 +11623,8 @@ function ComboboxProvider(props) {
11511
11623
  }, [handle]);
11512
11624
  return /*#__PURE__*/jsx(ComboboxContext.Provider, {
11513
11625
  value: contextValue,
11514
- children: /*#__PURE__*/jsx(ListboxContext.Provider, {
11515
- value: listboxContextValue,
11626
+ children: /*#__PURE__*/jsx(CompositeContext.Provider, {
11627
+ value: compositeContextValue,
11516
11628
  children: children
11517
11629
  })
11518
11630
  });
@@ -11548,7 +11660,7 @@ const Combobox = {
11548
11660
  /** Labelled group of options that auto-hides when all its child options are filtered out. */
11549
11661
  Section: ListboxSection,
11550
11662
  /** Displays empty, error, and loading state messages for the combobox list. */
11551
- State: ListboxState,
11663
+ State: CompositeStatus,
11552
11664
  /** Visual separator between option groups (alias for ListDivider). Purely decorative — invisible to screen readers. */
11553
11665
  Divider: ListDivider,
11554
11666
  /** Hook to subscribe to combobox events. Must be used within a Combobox.Provider. */
@@ -13601,7 +13713,7 @@ const InternalList = forwardRef((props, ref) => {
13601
13713
  });
13602
13714
  });
13603
13715
  InternalList.displayName = COMPONENT_NAME$1o;
13604
- InternalList.className = CLASSNAME$1l;
13716
+ InternalList.className = CLASSNAME$1m;
13605
13717
  InternalList.defaultProps = DEFAULT_PROPS$13;
13606
13718
  const List = Object.assign(InternalList, {
13607
13719
  useKeyboardListNavigation
@@ -15860,7 +15972,7 @@ const ListItemAction = Object.assign(forwardRefPolymorphic((props, ref) => {
15860
15972
  });
15861
15973
  }), {
15862
15974
  displayName: COMPONENT_NAME$1l,
15863
- className: CLASSNAME$1i,
15975
+ className: CLASSNAME$1j,
15864
15976
  defaultProps: DEFAULT_PROPS$11
15865
15977
  });
15866
15978
 
@@ -15902,7 +16014,7 @@ const _ListItem = forwardRef((props, ref) => {
15902
16014
  });
15903
16015
  });
15904
16016
  _ListItem.displayName = COMPONENT_NAME$1m;
15905
- _ListItem.className = CLASSNAME$1j;
16017
+ _ListItem.className = CLASSNAME$1k;
15906
16018
  _ListItem.defaultProps = DEFAULT_PROPS$12;
15907
16019
 
15908
16020
  /**
@@ -20123,7 +20235,7 @@ const SkeletonTypography = forwardRef((props, ref) => {
20123
20235
  });
20124
20236
  SkeletonTypography.displayName = COMPONENT_NAME$1g;
20125
20237
  SkeletonTypography.defaultProps = DEFAULT_PROPS$j;
20126
- SkeletonTypography.className = CLASSNAME$1d;
20238
+ SkeletonTypography.className = CLASSNAME$1e;
20127
20239
 
20128
20240
  /**
20129
20241
  * Clamp value in range.
@@ -23816,5 +23928,5 @@ UserBlock.displayName = COMPONENT_NAME;
23816
23928
  UserBlock.className = CLASSNAME;
23817
23929
  UserBlock.defaultProps = DEFAULT_PROPS;
23818
23930
 
23819
- export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonGroup, CLASSNAME$1z as CLASSNAME, COMPONENT_NAME$1C as COMPONENT_NAME, Card, Checkbox, Chip, ChipGroup, Combobox, CommentBlock, CommentBlockVariant, DEFAULT_PROPS$1g as DEFAULT_PROPS, DatePicker, DatePickerControlled, DatePickerField, Dialog, DialogHeading, Divider, DragHandle, Dropdown, ExpansionPanel, Flag, FlexBox, GenericBlock, GenericBlockGapSize, Grid, GridColumn, GridItem, Heading, HeadingLevelProvider, Icon, IconButton, ImageBlock, ImageBlockCaptionPosition, ImageLightbox, InlineList, InputHelper, InputLabel, InputRequiredLegend, Lightbox, Link, LinkPreview, List, ListDivider, ListItem, ListSection, ListSubheader, MenuButton, ListDivider as MenuDivider, MenuItem, Message, Mosaic, Navigation, Notification, Placement, Popover, PopoverDialog, PostBlock, Progress, ProgressCircular, ProgressLinear, ProgressTracker, ProgressTrackerProvider, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressVariant, RadioButton, RadioGroup, RawInputText, RawInputTextarea, Select, SelectButton, SelectMultiple, SelectMultipleField, SelectTextField, SelectVariant, SelectionChipGroup, SideNavigation, SideNavigationItem, SkeletonCircle, SkeletonRectangle, SkeletonRectangleVariant, SkeletonTypography, Slider, Slides, Slideshow, SlideshowControls, SlideshowItem, Switch, CLASSNAME$3 as TIME_PICKER_FIELD_CLASSNAME, COMPONENT_NAME$3 as TIME_PICKER_FIELD_COMPONENT_NAME, Tab, TabList, TabListLayout, TabPanel, TabProvider, Table, TableBody, TableCell, TableCellVariant, TableHeader, TableRow, Text, TextField, ThOrder, ThemeProvider, Thumbnail, ThumbnailAspectRatio, ThumbnailObjectFit, ThumbnailVariant, TimePickerField, Toolbar, Tooltip, Uploader, UploaderVariant, UserBlock, clamp, useFocusPointStyle, useHeadingLevel, useTheme };
23931
+ export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonGroup, CLASSNAME$1A as CLASSNAME, COMPONENT_NAME$1C as COMPONENT_NAME, Card, Checkbox, Chip, ChipGroup, Combobox, CommentBlock, CommentBlockVariant, DEFAULT_PROPS$1g as DEFAULT_PROPS, DatePicker, DatePickerControlled, DatePickerField, Dialog, DialogHeading, Divider, DragHandle, Dropdown, ExpansionPanel, Flag, FlexBox, GenericBlock, GenericBlockGapSize, Grid, GridColumn, GridItem, Heading, HeadingLevelProvider, Icon, IconButton, ImageBlock, ImageBlockCaptionPosition, ImageLightbox, InlineList, InputHelper, InputLabel, InputRequiredLegend, Lightbox, Link, LinkPreview, List, ListDivider, ListItem, ListSection, ListSubheader, MenuButton, ListDivider as MenuDivider, MenuItem, Message, Mosaic, Navigation, Notification, Placement, Popover, PopoverDialog, PostBlock, Progress, ProgressCircular, ProgressLinear, ProgressTracker, ProgressTrackerProvider, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressVariant, RadioButton, RadioGroup, RawInputText, RawInputTextarea, Select, SelectButton, SelectMultiple, SelectMultipleField, SelectTextField, SelectVariant, SelectionChipGroup, SideNavigation, SideNavigationItem, SkeletonCircle, SkeletonRectangle, SkeletonRectangleVariant, SkeletonTypography, Slider, Slides, Slideshow, SlideshowControls, SlideshowItem, Switch, CLASSNAME$3 as TIME_PICKER_FIELD_CLASSNAME, COMPONENT_NAME$3 as TIME_PICKER_FIELD_COMPONENT_NAME, Tab, TabList, TabListLayout, TabPanel, TabProvider, Table, TableBody, TableCell, TableCellVariant, TableHeader, TableRow, Text, TextField, ThOrder, ThemeProvider, Thumbnail, ThumbnailAspectRatio, ThumbnailObjectFit, ThumbnailVariant, TimePickerField, Toolbar, Tooltip, Uploader, UploaderVariant, UserBlock, clamp, useFocusPointStyle, useHeadingLevel, useTheme };
23820
23932
  //# sourceMappingURL=index.js.map