@lumx/react 4.27.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.
- package/index.d.ts +37 -34
- package/index.js +805 -662
- package/index.js.map +1 -1
- package/package.json +9 -8
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,
|
|
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$
|
|
568
|
+
const CLASSNAME$1G = 'lumx-alert-dialog';
|
|
569
569
|
const {
|
|
570
570
|
block: block$1e
|
|
571
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
1082
|
+
const CLASSNAME$1D = 'lumx-avatar';
|
|
1083
1083
|
const {
|
|
1084
1084
|
block: block$1d,
|
|
1085
1085
|
element: element$U
|
|
1086
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
1189
|
+
const CLASSNAME$1C = 'lumx-badge';
|
|
1190
1190
|
const {
|
|
1191
1191
|
block: block$1c
|
|
1192
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
1250
|
+
const CLASSNAME$1B = 'lumx-badge-wrapper';
|
|
1251
1251
|
const {
|
|
1252
1252
|
block: block$1b,
|
|
1253
1253
|
element: element$T
|
|
1254
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
1444
|
+
const CLASSNAME$1A = 'lumx-button';
|
|
1445
1445
|
const {
|
|
1446
1446
|
modifier
|
|
1447
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
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$
|
|
1570
|
+
const CLASSNAME$1z = IconClassName;
|
|
1571
1571
|
const {
|
|
1572
1572
|
block: block$1a
|
|
1573
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
1820
|
+
const CLASSNAME$1w = 'lumx-card';
|
|
1821
1821
|
const {
|
|
1822
1822
|
block: block$19
|
|
1823
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
1886
|
+
const CLASSNAME$1v = InputLabelClassName;
|
|
1887
1887
|
const {
|
|
1888
1888
|
block: block$18
|
|
1889
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
1943
|
+
const CLASSNAME$1u = InputHelperClassName;
|
|
1944
1944
|
const {
|
|
1945
1945
|
block: block$17
|
|
1946
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
1998
|
+
const CLASSNAME$1t = 'lumx-checkbox';
|
|
1999
1999
|
const {
|
|
2000
2000
|
block: block$16,
|
|
2001
2001
|
element: element$S
|
|
2002
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
2185
|
+
const CLASSNAME$1s = 'lumx-chip';
|
|
2186
2186
|
const {
|
|
2187
2187
|
block: block$15,
|
|
2188
2188
|
element: element$R
|
|
2189
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
2469
|
+
const CLASSNAME$1q = 'lumx-selection-chip-group';
|
|
2470
2470
|
const {
|
|
2471
2471
|
block: block$14,
|
|
2472
2472
|
element: element$Q
|
|
2473
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
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$
|
|
2818
|
+
const CLASSNAME$1p = 'lumx-text';
|
|
2819
2819
|
const {
|
|
2820
2820
|
block: block$13
|
|
2821
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
5010
|
+
const CLASSNAME$1o = 'lumx-tooltip';
|
|
5011
5011
|
const {
|
|
5012
5012
|
block: block$12,
|
|
5013
5013
|
element: element$P
|
|
5014
|
-
} = bem(CLASSNAME$
|
|
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$
|
|
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$
|
|
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$
|
|
6298
|
-
itemDisabledSelector: `.${CLASSNAME$
|
|
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$
|
|
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$
|
|
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$
|
|
6373
|
+
className: classnames(className, CLASSNAME$1n)
|
|
6374
6374
|
});
|
|
6375
6375
|
};
|
|
6376
6376
|
ListDivider$1.displayName = COMPONENT_NAME$1p;
|
|
6377
|
-
ListDivider$1.className = CLASSNAME$
|
|
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$
|
|
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$
|
|
6410
|
+
const CLASSNAME$1m = 'lumx-list';
|
|
6411
6411
|
const {
|
|
6412
6412
|
block: block$11
|
|
6413
|
-
} = bem(CLASSNAME$
|
|
6413
|
+
} = bem(CLASSNAME$1m);
|
|
6414
6414
|
|
|
6415
6415
|
/**
|
|
6416
6416
|
* Component default props.
|
|
@@ -6425,13 +6425,14 @@ const DEFAULT_PROPS$13 = {};
|
|
|
6425
6425
|
*/
|
|
6426
6426
|
const List$1 = props => {
|
|
6427
6427
|
const {
|
|
6428
|
+
as: Element = 'ul',
|
|
6428
6429
|
children,
|
|
6429
6430
|
className,
|
|
6430
6431
|
itemPadding,
|
|
6431
6432
|
ref,
|
|
6432
6433
|
...forwardedProps
|
|
6433
6434
|
} = props;
|
|
6434
|
-
return /*#__PURE__*/jsx(
|
|
6435
|
+
return /*#__PURE__*/jsx(Element, {
|
|
6435
6436
|
...forwardedProps,
|
|
6436
6437
|
className: classnames(className, block$11({
|
|
6437
6438
|
[`item-padding-${itemPadding}`]: Boolean(itemPadding)
|
|
@@ -6441,7 +6442,7 @@ const List$1 = props => {
|
|
|
6441
6442
|
});
|
|
6442
6443
|
};
|
|
6443
6444
|
List$1.displayName = COMPONENT_NAME$1o;
|
|
6444
|
-
List$1.className = CLASSNAME$
|
|
6445
|
+
List$1.className = CLASSNAME$1m;
|
|
6445
6446
|
List$1.defaultProps = DEFAULT_PROPS$13;
|
|
6446
6447
|
|
|
6447
6448
|
/**
|
|
@@ -6462,7 +6463,7 @@ const COMPONENT_NAME$1n = 'ListboxList';
|
|
|
6462
6463
|
/**
|
|
6463
6464
|
* Component default class name and class prefix.
|
|
6464
6465
|
*/
|
|
6465
|
-
const CLASSNAME$
|
|
6466
|
+
const CLASSNAME$1l = 'lumx-listbox-list';
|
|
6466
6467
|
/**
|
|
6467
6468
|
* Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
|
|
6468
6469
|
*
|
|
@@ -6490,7 +6491,7 @@ const ListboxList$1 = props => {
|
|
|
6490
6491
|
} = props;
|
|
6491
6492
|
return List$1({
|
|
6492
6493
|
...forwardedProps,
|
|
6493
|
-
className: classnames(className, CLASSNAME$
|
|
6494
|
+
className: classnames(className, CLASSNAME$1l, LEGACY_CLASSNAME$6),
|
|
6494
6495
|
ref,
|
|
6495
6496
|
itemPadding: 'big',
|
|
6496
6497
|
id,
|
|
@@ -6501,6 +6502,33 @@ const ListboxList$1 = props => {
|
|
|
6501
6502
|
});
|
|
6502
6503
|
};
|
|
6503
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
|
+
|
|
6504
6532
|
var shim = {exports: {}};
|
|
6505
6533
|
|
|
6506
6534
|
var useSyncExternalStoreShim_production = {};
|
|
@@ -6699,7 +6727,7 @@ function requireShim () {
|
|
|
6699
6727
|
var shimExports = requireShim();
|
|
6700
6728
|
|
|
6701
6729
|
/**
|
|
6702
|
-
* Subscribe to a
|
|
6730
|
+
* Subscribe to an event of an event source (a composite handle) via `useSyncExternalStore`.
|
|
6703
6731
|
*
|
|
6704
6732
|
* Reads the handle's synchronous `getSnapshot` — the correct pattern for an external (non-React) store.
|
|
6705
6733
|
* It reads the current value during commit, so a consumer doesn't miss changes that happened between
|
|
@@ -6710,10 +6738,10 @@ var shimExports = requireShim();
|
|
|
6710
6738
|
* The handle dispatches synchronously, so the store update fires within the triggering render/event
|
|
6711
6739
|
* (inside React's `act` in tests) rather than a deferred microtask.
|
|
6712
6740
|
*
|
|
6713
|
-
* Re-subscribes when the handle changes (e.g. trigger mount/unmount). Returns `initialValue`
|
|
6714
|
-
* 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.
|
|
6715
6743
|
*/
|
|
6716
|
-
function
|
|
6744
|
+
function useCompositeEvent(handle, event, initialValue) {
|
|
6717
6745
|
// Stable fallback used until the event has fired at least once (or while there is no handle).
|
|
6718
6746
|
const initialValueRef = useRef(initialValue);
|
|
6719
6747
|
const subscribe = useCallback(onStoreChange => handle?.subscribe(event, onStoreChange) ?? (() => undefined), [handle, event]);
|
|
@@ -6724,25 +6752,24 @@ function useListboxEvent(handle, event, initialValue) {
|
|
|
6724
6752
|
return shimExports.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
6725
6753
|
}
|
|
6726
6754
|
|
|
6727
|
-
/**
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
* then re-provided by the list with its `type`.
|
|
6732
|
-
*/
|
|
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
|
+
}
|
|
6733
6759
|
|
|
6734
|
-
|
|
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
|
+
}
|
|
6735
6766
|
|
|
6736
|
-
/**
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
if (!context) {
|
|
6743
|
-
throw new Error('Listbox sub-components must be used within a Combobox or a standalone listbox');
|
|
6744
|
-
}
|
|
6745
|
-
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;
|
|
6746
6773
|
}
|
|
6747
6774
|
|
|
6748
6775
|
/**
|
|
@@ -6768,24 +6795,25 @@ const ListboxList = forwardRef((props, ref) => {
|
|
|
6768
6795
|
...forwardedProps
|
|
6769
6796
|
} = props;
|
|
6770
6797
|
const {
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6798
|
+
id: listboxId
|
|
6799
|
+
} = useCompositeContext();
|
|
6800
|
+
const list = useListboxHandle();
|
|
6774
6801
|
const internalRef = useRef(null);
|
|
6775
6802
|
const mergedRef = useMergeRefs(ref, internalRef);
|
|
6776
6803
|
const selectionType = String(forwardedProps['aria-multiselectable']) === 'true' ? 'multiple' : 'single';
|
|
6777
6804
|
const contextValue = useMemo(() => ({
|
|
6778
|
-
list,
|
|
6779
|
-
listboxId,
|
|
6805
|
+
handle: list,
|
|
6806
|
+
id: listboxId,
|
|
6780
6807
|
type,
|
|
6781
|
-
selectionType
|
|
6808
|
+
selectionType,
|
|
6809
|
+
level: 0
|
|
6782
6810
|
}), [list, listboxId, type, selectionType]);
|
|
6783
6811
|
|
|
6784
6812
|
// Options are rendered only while visible (standalone: always; combobox: while open).
|
|
6785
|
-
const isOpen =
|
|
6786
|
-
const options =
|
|
6813
|
+
const isOpen = useCompositeEvent(list, 'open', false);
|
|
6814
|
+
const options = useCompositeEvent(list, 'optionsChange', undefined);
|
|
6787
6815
|
const visibleCount = options?.optionsLength ?? 0;
|
|
6788
|
-
const isLoading =
|
|
6816
|
+
const isLoading = useCompositeEvent(list, 'loadingChange', false);
|
|
6789
6817
|
|
|
6790
6818
|
// Mount the list element on the handle.
|
|
6791
6819
|
useEffect(() => {
|
|
@@ -6798,7 +6826,7 @@ const ListboxList = forwardRef((props, ref) => {
|
|
|
6798
6826
|
useEffect(() => {
|
|
6799
6827
|
if (isOpen) list?.flushPendingNavigation();
|
|
6800
6828
|
}, [isOpen, visibleCount, list]);
|
|
6801
|
-
return /*#__PURE__*/jsx(
|
|
6829
|
+
return /*#__PURE__*/jsx(CompositeContext.Provider, {
|
|
6802
6830
|
value: contextValue,
|
|
6803
6831
|
children: ListboxList$1({
|
|
6804
6832
|
...forwardedProps,
|
|
@@ -6817,7 +6845,7 @@ const ListboxList = forwardRef((props, ref) => {
|
|
|
6817
6845
|
});
|
|
6818
6846
|
});
|
|
6819
6847
|
ListboxList.displayName = COMPONENT_NAME$1n;
|
|
6820
|
-
ListboxList.className = CLASSNAME$
|
|
6848
|
+
ListboxList.className = CLASSNAME$1l;
|
|
6821
6849
|
|
|
6822
6850
|
/**
|
|
6823
6851
|
* Component display name.
|
|
@@ -6827,11 +6855,11 @@ const COMPONENT_NAME$1m = 'ListItem';
|
|
|
6827
6855
|
/**
|
|
6828
6856
|
* Component default class name and class prefix.
|
|
6829
6857
|
*/
|
|
6830
|
-
const CLASSNAME$
|
|
6858
|
+
const CLASSNAME$1k = 'lumx-list-item';
|
|
6831
6859
|
const {
|
|
6832
6860
|
block: block$10,
|
|
6833
6861
|
element: element$O
|
|
6834
|
-
} = bem(CLASSNAME$
|
|
6862
|
+
} = bem(CLASSNAME$1k);
|
|
6835
6863
|
|
|
6836
6864
|
/**
|
|
6837
6865
|
* Component default props.
|
|
@@ -6848,6 +6876,7 @@ const DEFAULT_PROPS$12 = {
|
|
|
6848
6876
|
*/
|
|
6849
6877
|
const ListItem$1 = props => {
|
|
6850
6878
|
const {
|
|
6879
|
+
as: Element = 'li',
|
|
6851
6880
|
after,
|
|
6852
6881
|
before,
|
|
6853
6882
|
children,
|
|
@@ -6865,7 +6894,7 @@ const ListItem$1 = props => {
|
|
|
6865
6894
|
...forwardedProps
|
|
6866
6895
|
} = props;
|
|
6867
6896
|
const clickable = !!linkAs || linkProps?.href || handleClick;
|
|
6868
|
-
return /*#__PURE__*/jsx(
|
|
6897
|
+
return /*#__PURE__*/jsx(Element, {
|
|
6869
6898
|
ref: ref,
|
|
6870
6899
|
...forwardedProps,
|
|
6871
6900
|
className: classnames(className, block$10({
|
|
@@ -6899,7 +6928,7 @@ const ListItem$1 = props => {
|
|
|
6899
6928
|
});
|
|
6900
6929
|
};
|
|
6901
6930
|
ListItem$1.displayName = COMPONENT_NAME$1m;
|
|
6902
|
-
ListItem$1.className = CLASSNAME$
|
|
6931
|
+
ListItem$1.className = CLASSNAME$1k;
|
|
6903
6932
|
ListItem$1.defaultProps = DEFAULT_PROPS$12;
|
|
6904
6933
|
|
|
6905
6934
|
/**
|
|
@@ -6914,7 +6943,7 @@ const COMPONENT_NAME$1l = 'ListItemAction';
|
|
|
6914
6943
|
/**
|
|
6915
6944
|
* Component classname (used by action area CSS pattern).
|
|
6916
6945
|
*/
|
|
6917
|
-
const CLASSNAME$
|
|
6946
|
+
const CLASSNAME$1j = 'lumx-action-area__action';
|
|
6918
6947
|
const DEFAULT_PROPS$11 = {};
|
|
6919
6948
|
|
|
6920
6949
|
/**
|
|
@@ -6945,6 +6974,28 @@ const ListItemAction$1 = props => {
|
|
|
6945
6974
|
});
|
|
6946
6975
|
};
|
|
6947
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
|
+
|
|
6948
6999
|
/**
|
|
6949
7000
|
* Component display name.
|
|
6950
7001
|
*/
|
|
@@ -6953,7 +7004,7 @@ const COMPONENT_NAME$1k = 'ListboxOption';
|
|
|
6953
7004
|
/**
|
|
6954
7005
|
* Component default class name and class prefix.
|
|
6955
7006
|
*/
|
|
6956
|
-
const CLASSNAME$
|
|
7007
|
+
const CLASSNAME$1i = 'lumx-listbox-option';
|
|
6957
7008
|
/**
|
|
6958
7009
|
* Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
|
|
6959
7010
|
*
|
|
@@ -6963,7 +7014,7 @@ const LEGACY_CLASSNAME$5 = 'lumx-combobox-option';
|
|
|
6963
7014
|
const {
|
|
6964
7015
|
block: block$$,
|
|
6965
7016
|
element: element$N
|
|
6966
|
-
} = bem(CLASSNAME$
|
|
7017
|
+
} = bem(CLASSNAME$1i);
|
|
6967
7018
|
const legacy$1 = bem(LEGACY_CLASSNAME$5);
|
|
6968
7019
|
|
|
6969
7020
|
/**
|
|
@@ -7033,13 +7084,9 @@ const ListboxOption$1 = (props, {
|
|
|
7033
7084
|
after,
|
|
7034
7085
|
role: itemRole,
|
|
7035
7086
|
children: /*#__PURE__*/jsxs(Fragment, {
|
|
7036
|
-
children: [wrappedAction, description &&
|
|
7087
|
+
children: [wrappedAction, description && CompositeItemDescription({
|
|
7037
7088
|
id: descriptionId,
|
|
7038
|
-
|
|
7039
|
-
className: classnames(element$N('description'), legacy$1.element('description')),
|
|
7040
|
-
typography: 'caption',
|
|
7041
|
-
color: 'dark-L2'
|
|
7042
|
-
}),
|
|
7089
|
+
className: classnames(element$N('description'), legacy$1.element('description')),
|
|
7043
7090
|
children: description
|
|
7044
7091
|
})]
|
|
7045
7092
|
})
|
|
@@ -7047,21 +7094,25 @@ const ListboxOption$1 = (props, {
|
|
|
7047
7094
|
};
|
|
7048
7095
|
|
|
7049
7096
|
const OPTION_ACTIVE_EVENT_PREFIX = 'optionActive:';
|
|
7097
|
+
|
|
7098
|
+
/** The active state event of one item (see {@link OptionActiveEvent}). */
|
|
7050
7099
|
const optionActiveEvent = optionId => `${OPTION_ACTIVE_EVENT_PREFIX}${optionId}`;
|
|
7051
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);
|
|
7052
7103
|
|
|
7053
|
-
/** 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. */
|
|
7054
7105
|
|
|
7055
|
-
const
|
|
7106
|
+
const CompositeItemContext = /*#__PURE__*/createContext(undefined);
|
|
7056
7107
|
|
|
7057
7108
|
/**
|
|
7058
|
-
*
|
|
7059
|
-
* Must be used within a Combobox.Option
|
|
7060
|
-
* @throws Error if used outside of a Combobox.Option
|
|
7061
|
-
* @returns The
|
|
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.
|
|
7062
7113
|
*/
|
|
7063
|
-
function
|
|
7064
|
-
const context = useContext(
|
|
7114
|
+
function useCompositeItemContext() {
|
|
7115
|
+
const context = useContext(CompositeItemContext);
|
|
7065
7116
|
if (!context) {
|
|
7066
7117
|
throw new Error('Combobox.Option sub-components must be used within a Combobox.Option `after` slot');
|
|
7067
7118
|
}
|
|
@@ -7100,9 +7151,9 @@ const ListboxOption = forwardRef((props, ref) => {
|
|
|
7100
7151
|
...forwardedProps
|
|
7101
7152
|
} = props;
|
|
7102
7153
|
const {
|
|
7103
|
-
type
|
|
7104
|
-
|
|
7105
|
-
|
|
7154
|
+
type
|
|
7155
|
+
} = useCompositeContext();
|
|
7156
|
+
const list = useListboxHandle();
|
|
7106
7157
|
const isGrid = type === 'grid';
|
|
7107
7158
|
const optionId = useId();
|
|
7108
7159
|
const descriptionId = useId();
|
|
@@ -7111,7 +7162,7 @@ const ListboxOption = forwardRef((props, ref) => {
|
|
|
7111
7162
|
const [isFiltered, setIsFiltered] = useState(false);
|
|
7112
7163
|
|
|
7113
7164
|
// Force the tooltip open while the option is the active descendant (keyboard highlight).
|
|
7114
|
-
const isActive =
|
|
7165
|
+
const isActive = useCompositeEvent(list, optionActiveEvent(optionId), false);
|
|
7115
7166
|
useEffect(() => {
|
|
7116
7167
|
const element = internalRef.current;
|
|
7117
7168
|
if (!element || !list) return undefined;
|
|
@@ -7125,42 +7176,41 @@ const ListboxOption = forwardRef((props, ref) => {
|
|
|
7125
7176
|
list.refilterOption(element);
|
|
7126
7177
|
}, [list, value]);
|
|
7127
7178
|
|
|
7128
|
-
//
|
|
7129
|
-
// can
|
|
7130
|
-
const
|
|
7131
|
-
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,
|
|
7132
7183
|
isSelected: Boolean(isSelected)
|
|
7133
7184
|
}), [optionId, isSelected]);
|
|
7134
|
-
|
|
7135
|
-
value:
|
|
7136
|
-
children:
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
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
|
+
})
|
|
7160
7210
|
});
|
|
7161
7211
|
});
|
|
7162
7212
|
ListboxOption.displayName = COMPONENT_NAME$1k;
|
|
7163
|
-
ListboxOption.className = CLASSNAME$
|
|
7213
|
+
ListboxOption.className = CLASSNAME$1i;
|
|
7164
7214
|
|
|
7165
7215
|
/**
|
|
7166
7216
|
* Defines the props for the core ListboxOptionAction template.
|
|
@@ -7174,7 +7224,7 @@ const COMPONENT_NAME$1j = 'ListboxOptionAction';
|
|
|
7174
7224
|
/**
|
|
7175
7225
|
* Component default class name and class prefix.
|
|
7176
7226
|
*/
|
|
7177
|
-
const CLASSNAME$
|
|
7227
|
+
const CLASSNAME$1h = 'lumx-listbox-option-action';
|
|
7178
7228
|
/**
|
|
7179
7229
|
* Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
|
|
7180
7230
|
*
|
|
@@ -7203,7 +7253,7 @@ const ListboxOptionAction$1 = props => {
|
|
|
7203
7253
|
as: Element,
|
|
7204
7254
|
...forwardedProps,
|
|
7205
7255
|
role: 'gridcell',
|
|
7206
|
-
className: classnames(className, CLASSNAME$
|
|
7256
|
+
className: classnames(className, CLASSNAME$1h, LEGACY_CLASSNAME$4),
|
|
7207
7257
|
handleClick,
|
|
7208
7258
|
children
|
|
7209
7259
|
});
|
|
@@ -7247,7 +7297,7 @@ const ListboxOptionAction = Object.assign(forwardRefPolymorphic((props, ref) =>
|
|
|
7247
7297
|
const actionId = useId();
|
|
7248
7298
|
const {
|
|
7249
7299
|
type
|
|
7250
|
-
} =
|
|
7300
|
+
} = useCompositeContext();
|
|
7251
7301
|
const isGrid = type === 'grid';
|
|
7252
7302
|
useEffect(() => {
|
|
7253
7303
|
if (!isGrid) {
|
|
@@ -7267,7 +7317,7 @@ const ListboxOptionAction = Object.assign(forwardRefPolymorphic((props, ref) =>
|
|
|
7267
7317
|
});
|
|
7268
7318
|
}), {
|
|
7269
7319
|
displayName: COMPONENT_NAME$1j,
|
|
7270
|
-
className: CLASSNAME$
|
|
7320
|
+
className: CLASSNAME$1h
|
|
7271
7321
|
});
|
|
7272
7322
|
|
|
7273
7323
|
/**
|
|
@@ -7278,7 +7328,7 @@ const COMPONENT_NAME$1i = 'ListboxOptionMoreInfo';
|
|
|
7278
7328
|
/**
|
|
7279
7329
|
* Component default class name and class prefix.
|
|
7280
7330
|
*/
|
|
7281
|
-
const CLASSNAME$
|
|
7331
|
+
const CLASSNAME$1g = 'lumx-listbox-option-more-info';
|
|
7282
7332
|
/**
|
|
7283
7333
|
* Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
|
|
7284
7334
|
*
|
|
@@ -7288,7 +7338,7 @@ const LEGACY_CLASSNAME$3 = 'lumx-combobox-option-more-info';
|
|
|
7288
7338
|
const {
|
|
7289
7339
|
block: block$_,
|
|
7290
7340
|
element: element$M
|
|
7291
|
-
} = bem(CLASSNAME$
|
|
7341
|
+
} = bem(CLASSNAME$1g);
|
|
7292
7342
|
const legacy = bem(LEGACY_CLASSNAME$3);
|
|
7293
7343
|
|
|
7294
7344
|
/**
|
|
@@ -7623,11 +7673,11 @@ const COMPONENT_NAME$1h = 'Popover';
|
|
|
7623
7673
|
/**
|
|
7624
7674
|
* Component default class name and class prefix.
|
|
7625
7675
|
*/
|
|
7626
|
-
const CLASSNAME$
|
|
7676
|
+
const CLASSNAME$1f = 'lumx-popover';
|
|
7627
7677
|
const {
|
|
7628
7678
|
block: block$Z,
|
|
7629
7679
|
element: element$L
|
|
7630
|
-
} = bem(CLASSNAME$
|
|
7680
|
+
} = bem(CLASSNAME$1f);
|
|
7631
7681
|
|
|
7632
7682
|
/**
|
|
7633
7683
|
* Component default props (used by framework wrappers).
|
|
@@ -8166,7 +8216,7 @@ const Popover = skipRender(
|
|
|
8166
8216
|
// Skip render in SSR
|
|
8167
8217
|
() => Boolean(DOCUMENT), _InnerPopover);
|
|
8168
8218
|
Popover.displayName = COMPONENT_NAME$1h;
|
|
8169
|
-
Popover.className = CLASSNAME$
|
|
8219
|
+
Popover.className = CLASSNAME$1f;
|
|
8170
8220
|
Popover.defaultProps = DEFAULT_PROPS$10;
|
|
8171
8221
|
|
|
8172
8222
|
/**
|
|
@@ -8196,17 +8246,17 @@ const ListboxOptionMoreInfo = props => {
|
|
|
8196
8246
|
const ref = useRef(null);
|
|
8197
8247
|
const [isHovered, setIsHovered] = useState(false);
|
|
8198
8248
|
|
|
8199
|
-
// Get the parent option ID from the
|
|
8249
|
+
// Get the parent option ID from the item context (provided by Combobox.Option).
|
|
8200
8250
|
const {
|
|
8201
|
-
optionId
|
|
8202
|
-
} =
|
|
8251
|
+
itemId: optionId
|
|
8252
|
+
} = useCompositeItemContext();
|
|
8203
8253
|
|
|
8204
8254
|
// Subscribe to active descendant changes to detect keyboard highlight.
|
|
8205
8255
|
const {
|
|
8206
|
-
|
|
8207
|
-
} =
|
|
8208
|
-
|
|
8209
|
-
const isKeyboardHighlighted =
|
|
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);
|
|
8210
8260
|
|
|
8211
8261
|
// Open on mouse hover or keyboard highlight.
|
|
8212
8262
|
const isOpen = isHovered || isKeyboardHighlighted;
|
|
@@ -8234,7 +8284,7 @@ const ListboxOptionMoreInfo = props => {
|
|
|
8234
8284
|
});
|
|
8235
8285
|
};
|
|
8236
8286
|
ListboxOptionMoreInfo.displayName = COMPONENT_NAME$1i;
|
|
8237
|
-
ListboxOptionMoreInfo.className = CLASSNAME$
|
|
8287
|
+
ListboxOptionMoreInfo.className = CLASSNAME$1g;
|
|
8238
8288
|
|
|
8239
8289
|
/**
|
|
8240
8290
|
* Component display name.
|
|
@@ -8244,11 +8294,11 @@ const COMPONENT_NAME$1g = 'SkeletonTypography';
|
|
|
8244
8294
|
/**
|
|
8245
8295
|
* Component default class name and class prefix.
|
|
8246
8296
|
*/
|
|
8247
|
-
const CLASSNAME$
|
|
8297
|
+
const CLASSNAME$1e = 'lumx-skeleton-typography';
|
|
8248
8298
|
const {
|
|
8249
8299
|
block: block$Y,
|
|
8250
8300
|
element: element$K
|
|
8251
|
-
} = bem(CLASSNAME$
|
|
8301
|
+
} = bem(CLASSNAME$1e);
|
|
8252
8302
|
|
|
8253
8303
|
/**
|
|
8254
8304
|
* SkeletonTypography component.
|
|
@@ -8292,7 +8342,7 @@ const COMPONENT_NAME$1f = 'ListboxOptionSkeleton';
|
|
|
8292
8342
|
/**
|
|
8293
8343
|
* Component default class name and class prefix.
|
|
8294
8344
|
*/
|
|
8295
|
-
const CLASSNAME$
|
|
8345
|
+
const CLASSNAME$1d = 'lumx-listbox-option-skeleton';
|
|
8296
8346
|
/**
|
|
8297
8347
|
* Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
|
|
8298
8348
|
*
|
|
@@ -8325,7 +8375,7 @@ const ListboxOptionSkeleton$1 = props => {
|
|
|
8325
8375
|
size: 'tiny',
|
|
8326
8376
|
role: 'none',
|
|
8327
8377
|
...forwardedProps,
|
|
8328
|
-
className: classnames(className, CLASSNAME$
|
|
8378
|
+
className: classnames(className, CLASSNAME$1d, LEGACY_CLASSNAME$2),
|
|
8329
8379
|
children: children || /*#__PURE__*/jsxs(Fragment, {
|
|
8330
8380
|
children: [/*#__PURE__*/jsx(SkeletonTypography$1, {
|
|
8331
8381
|
typography: "body1",
|
|
@@ -8371,25 +8421,35 @@ const ListboxOptionSkeleton$1 = props => {
|
|
|
8371
8421
|
*/
|
|
8372
8422
|
const ListboxOptionSkeleton = props => {
|
|
8373
8423
|
const {
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
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]);
|
|
8377
8432
|
return /*#__PURE__*/jsx(ListboxOptionSkeleton$1, {
|
|
8378
8433
|
...props
|
|
8379
8434
|
});
|
|
8380
8435
|
};
|
|
8381
8436
|
ListboxOptionSkeleton.displayName = COMPONENT_NAME$1f;
|
|
8382
|
-
ListboxOptionSkeleton.className = CLASSNAME$
|
|
8437
|
+
ListboxOptionSkeleton.className = CLASSNAME$1d;
|
|
8383
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';
|
|
8384
8443
|
/**
|
|
8385
|
-
* 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.
|
|
8386
8445
|
*
|
|
8387
8446
|
* - `single`: a check circle icon when selected, a blank radio icon otherwise.
|
|
8388
8447
|
* - `multiple`: a checkbox icon, marked or blank.
|
|
8389
8448
|
*/
|
|
8390
|
-
const
|
|
8449
|
+
const CompositeSelectionIcon = ({
|
|
8391
8450
|
selectionType,
|
|
8392
|
-
isSelected
|
|
8451
|
+
isSelected,
|
|
8452
|
+
className
|
|
8393
8453
|
}) => {
|
|
8394
8454
|
let icon;
|
|
8395
8455
|
if (selectionType === 'multiple') {
|
|
@@ -8402,20 +8462,21 @@ const ListboxOptionSelectionIcon$1 = ({
|
|
|
8402
8462
|
return /*#__PURE__*/jsx(Icon$1, {
|
|
8403
8463
|
icon: icon,
|
|
8404
8464
|
color: isSelected ? 'primary' : undefined,
|
|
8405
|
-
className:
|
|
8465
|
+
className: classnames(CLASSNAME$1c, className)
|
|
8406
8466
|
});
|
|
8407
8467
|
};
|
|
8408
8468
|
|
|
8409
8469
|
const ListboxOptionSelectionIcon = () => {
|
|
8410
8470
|
const {
|
|
8411
8471
|
isSelected
|
|
8412
|
-
} =
|
|
8472
|
+
} = useCompositeItemContext();
|
|
8413
8473
|
const {
|
|
8414
8474
|
selectionType
|
|
8415
|
-
} =
|
|
8416
|
-
return /*#__PURE__*/jsx(
|
|
8475
|
+
} = useCompositeContext();
|
|
8476
|
+
return /*#__PURE__*/jsx(CompositeSelectionIcon, {
|
|
8417
8477
|
selectionType: selectionType,
|
|
8418
|
-
isSelected: isSelected
|
|
8478
|
+
isSelected: isSelected,
|
|
8479
|
+
className: LEGACY_OPTION_CLASSNAME
|
|
8419
8480
|
});
|
|
8420
8481
|
};
|
|
8421
8482
|
ListboxOptionSelectionIcon.displayName = 'ComboboxSelectionIcon';
|
|
@@ -8577,9 +8638,7 @@ ListSection.defaultProps = DEFAULT_PROPS$$;
|
|
|
8577
8638
|
* @return React element.
|
|
8578
8639
|
*/
|
|
8579
8640
|
const ListboxSection = forwardRef((props, ref) => {
|
|
8580
|
-
const
|
|
8581
|
-
list
|
|
8582
|
-
} = useListboxContext();
|
|
8641
|
+
const list = useListboxHandle();
|
|
8583
8642
|
const internalRef = useRef(null);
|
|
8584
8643
|
const mergedRef = useMergeRefs(ref, internalRef);
|
|
8585
8644
|
const [sectionState, setSectionState] = useState({
|
|
@@ -8606,27 +8665,21 @@ const ListboxSection = forwardRef((props, ref) => {
|
|
|
8606
8665
|
ListboxSection.displayName = COMPONENT_NAME$1e;
|
|
8607
8666
|
ListboxSection.className = CLASSNAME$1b;
|
|
8608
8667
|
|
|
8609
|
-
|
|
8610
|
-
* Component display name.
|
|
8611
|
-
*/
|
|
8612
|
-
const COMPONENT_NAME$1c = 'ListboxState';
|
|
8668
|
+
const COMPONENT_NAME$1c = 'CompositeStatus';
|
|
8613
8669
|
|
|
8614
8670
|
/**
|
|
8615
8671
|
* Component default class name and class prefix.
|
|
8616
8672
|
*/
|
|
8617
|
-
const CLASSNAME$19 = 'lumx-
|
|
8618
|
-
/**
|
|
8619
|
-
* Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
|
|
8620
|
-
*
|
|
8621
|
-
* @deprecated Use `CLASSNAME` (`lumx-listbox-*`). The legacy `lumx-combobox-*` class will be removed in the next major version.
|
|
8622
|
-
*/
|
|
8623
|
-
const LEGACY_CLASSNAME = 'lumx-combobox-state';
|
|
8673
|
+
const CLASSNAME$19 = 'lumx-composite-status';
|
|
8624
8674
|
const {
|
|
8625
8675
|
block: block$W
|
|
8626
8676
|
} = bem(CLASSNAME$19);
|
|
8627
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
|
+
|
|
8628
8681
|
/**
|
|
8629
|
-
* Defines the props for the core
|
|
8682
|
+
* Defines the props for the core CompositeStatus template.
|
|
8630
8683
|
*/
|
|
8631
8684
|
|
|
8632
8685
|
/**
|
|
@@ -8634,20 +8687,21 @@ const {
|
|
|
8634
8687
|
*/
|
|
8635
8688
|
|
|
8636
8689
|
/**
|
|
8637
|
-
*
|
|
8638
|
-
* Renders empty
|
|
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).
|
|
8639
8692
|
* The block itself acts as a screen reader live region (`role="status" aria-live="polite"`).
|
|
8640
8693
|
*
|
|
8641
8694
|
* Activation rules:
|
|
8642
8695
|
* - Error state: active when `errorMessage` is provided (presence-based).
|
|
8643
|
-
* - Empty state: active when `optionsLength` is 0 and `emptyMessage` is provided, and there is
|
|
8644
|
-
*
|
|
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.
|
|
8645
8699
|
*
|
|
8646
8700
|
* @param props Component props.
|
|
8647
8701
|
* @param components Injected framework-specific components.
|
|
8648
8702
|
* @return JSX element or null when no state is active.
|
|
8649
8703
|
*/
|
|
8650
|
-
const
|
|
8704
|
+
const CompositeStatus$1 = (props, {
|
|
8651
8705
|
GenericBlock,
|
|
8652
8706
|
Text
|
|
8653
8707
|
}) => {
|
|
@@ -8670,7 +8724,7 @@ const ListboxState$1 = (props, {
|
|
|
8670
8724
|
// The framework wrapper gates `loadingMessage` via the debounced `loadingAnnouncement` event,
|
|
8671
8725
|
// passing `undefined` until the 500ms threshold is reached.
|
|
8672
8726
|
const showLoading = !showError && !!loadingMessage;
|
|
8673
|
-
// Show
|
|
8727
|
+
// Show the item count message when the composite is open, not empty, not loading, and not in error.
|
|
8674
8728
|
const resolvedNbOptionMessage = !isEmpty && !showError && !state?.isLoading && nbOptionMessage ? nbOptionMessage(optionsLength) : undefined;
|
|
8675
8729
|
const show = showEmpty || showError;
|
|
8676
8730
|
const alignProps = {
|
|
@@ -8734,10 +8788,10 @@ const OPEN_ANNOUNCEMENT_DELAY = 100;
|
|
|
8734
8788
|
/** Setters invoked by `subscribeListboxState` when handle events fire. */
|
|
8735
8789
|
|
|
8736
8790
|
/**
|
|
8737
|
-
* Subscribe to the listbox handle events needed by `
|
|
8791
|
+
* Subscribe to the listbox handle events needed by `CompositeStatus`.
|
|
8738
8792
|
*
|
|
8739
8793
|
* Manages three subscriptions:
|
|
8740
|
-
* - `loadingChange` → `setIsLoading` (+ synchronous initial read of `
|
|
8794
|
+
* - `loadingChange` → `setIsLoading` (+ synchronous initial read of the `loadingChange` snapshot)
|
|
8741
8795
|
* - `loadingAnnouncement` → `setShouldAnnounce`
|
|
8742
8796
|
* - `open` → `setIsOpen` (deferred by {@link OPEN_ANNOUNCEMENT_DELAY}ms when shown, immediate when hidden)
|
|
8743
8797
|
* (a standalone listbox is always visible: `setIsOpen(true)` once, no subscription)
|
|
@@ -8754,7 +8808,7 @@ function subscribeListboxState(list, setters) {
|
|
|
8754
8808
|
} = setters;
|
|
8755
8809
|
|
|
8756
8810
|
// Read current loading state synchronously
|
|
8757
|
-
setIsLoading(list.
|
|
8811
|
+
setIsLoading(list.getSnapshot('loadingChange') ?? false);
|
|
8758
8812
|
const unsubLoadingChange = list.subscribe('loadingChange', setIsLoading);
|
|
8759
8813
|
const unsubLoadingAnnouncement = list.subscribe('loadingAnnouncement', setShouldAnnounce);
|
|
8760
8814
|
|
|
@@ -8972,13 +9026,14 @@ const GenericBlock = Object.assign(BaseGenericBlock, {
|
|
|
8972
9026
|
const GenericBlockGapSize = pick(Size, ['tiny', 'regular', 'medium', 'big', 'huge']);
|
|
8973
9027
|
|
|
8974
9028
|
/**
|
|
8975
|
-
* Props
|
|
9029
|
+
* Props of the composite status (`Combobox.State`, `Listbox.State`).
|
|
8976
9030
|
*/
|
|
8977
9031
|
|
|
8978
9032
|
/**
|
|
8979
|
-
*
|
|
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.
|
|
8980
9035
|
*
|
|
8981
|
-
* 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):
|
|
8982
9037
|
*
|
|
8983
9038
|
* ```tsx
|
|
8984
9039
|
* <Combobox.Popover>
|
|
@@ -8996,19 +9051,19 @@ const GenericBlockGapSize = pick(Size, ['tiny', 'regular', 'medium', 'big', 'hug
|
|
|
8996
9051
|
* Takes priority over all other states.
|
|
8997
9052
|
* - **Loading state**: active when `loadingMessage` is provided and skeletons have been
|
|
8998
9053
|
* mounted for at least 500ms. Suppresses the empty state while loading.
|
|
8999
|
-
* - **Empty state**: active when `emptyMessage` is provided and the
|
|
9054
|
+
* - **Empty state**: active when `emptyMessage` is provided and the composite has no visible items
|
|
9000
9055
|
* and is not loading.
|
|
9001
|
-
* - **
|
|
9056
|
+
* - **Item count**: active when `nbOptionMessage` is provided and the composite is not empty,
|
|
9002
9057
|
* not loading, and not in error.
|
|
9003
9058
|
*
|
|
9004
9059
|
* @param props Component props.
|
|
9005
9060
|
* @return React element.
|
|
9006
9061
|
*/
|
|
9007
|
-
const
|
|
9062
|
+
const CompositeStatus = props => {
|
|
9008
9063
|
const {
|
|
9009
|
-
list
|
|
9010
|
-
} =
|
|
9011
|
-
const optionsState =
|
|
9064
|
+
handle: list
|
|
9065
|
+
} = useCompositeContext();
|
|
9066
|
+
const optionsState = useCompositeEvent(list, 'optionsChange', undefined);
|
|
9012
9067
|
const [isLoading, setIsLoading] = useState(false);
|
|
9013
9068
|
const [shouldAnnounce, setShouldAnnounce] = useState(false);
|
|
9014
9069
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -9028,7 +9083,7 @@ const ListboxState = props => {
|
|
|
9028
9083
|
|
|
9029
9084
|
// Only pass loadingMessage to core after the 500ms debounce threshold
|
|
9030
9085
|
const loadingMessage = shouldAnnounce ? props.loadingMessage : undefined;
|
|
9031
|
-
return
|
|
9086
|
+
return CompositeStatus$1({
|
|
9032
9087
|
...props,
|
|
9033
9088
|
loadingMessage,
|
|
9034
9089
|
state
|
|
@@ -9037,75 +9092,8 @@ const ListboxState = props => {
|
|
|
9037
9092
|
Text
|
|
9038
9093
|
});
|
|
9039
9094
|
};
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
/**
|
|
9044
|
-
* Get the value for an option element.
|
|
9045
|
-
* Uses `data-value` when set; falls back to the element's trimmed `textContent`.
|
|
9046
|
-
*
|
|
9047
|
-
* This is the *selection* value , which may differ from the visible label
|
|
9048
|
-
*/
|
|
9049
|
-
function getOptionValue(option) {
|
|
9050
|
-
if (option.dataset.value !== undefined) return option.dataset.value;
|
|
9051
|
-
return option.textContent?.trim() ?? '';
|
|
9052
|
-
}
|
|
9053
|
-
|
|
9054
|
-
/**
|
|
9055
|
-
* Get the visible label for an option element (its trimmed `textContent`).
|
|
9056
|
-
*
|
|
9057
|
-
* Used for typeahead matching: the user types the characters they see, which is the
|
|
9058
|
-
* option's label — not its `data-value` (which can be an unrelated id).
|
|
9059
|
-
*/
|
|
9060
|
-
function getOptionLabel(option) {
|
|
9061
|
-
return option.textContent?.trim() ?? '';
|
|
9062
|
-
}
|
|
9063
|
-
|
|
9064
|
-
/** Returns true when an option carries aria-disabled="true". */
|
|
9065
|
-
function isOptionDisabled(option) {
|
|
9066
|
-
return option.getAttribute('aria-disabled') === 'true';
|
|
9067
|
-
}
|
|
9068
|
-
|
|
9069
|
-
/** Returns true when the cell is NOT the first gridcell in its row (i.e., it's an action cell). */
|
|
9070
|
-
function isActionCell(cell) {
|
|
9071
|
-
const row = cell.closest('[role="row"]');
|
|
9072
|
-
if (!row) return false;
|
|
9073
|
-
return row.querySelector('[role="gridcell"]') !== cell;
|
|
9074
|
-
}
|
|
9075
|
-
const isSelected = el => el.getAttribute('aria-selected') === 'true';
|
|
9076
|
-
|
|
9077
|
-
/**
|
|
9078
|
-
* Compute the current state of a section and notify when it changed.
|
|
9079
|
-
*
|
|
9080
|
-
* Section state:
|
|
9081
|
-
* - `hidden`: true when the section has registered options but all are filtered out.
|
|
9082
|
-
* - `aria-hidden`: true when the section has no registered options at all (skeleton-only).
|
|
9083
|
-
*
|
|
9084
|
-
* At most one of `hidden` / `aria-hidden` is true at a time.
|
|
9085
|
-
*/
|
|
9086
|
-
function notifySection(sectionElement, sectionRegistrations, optionRegistrations, force) {
|
|
9087
|
-
const reg = sectionRegistrations.get(sectionElement);
|
|
9088
|
-
if (!reg) return;
|
|
9089
|
-
let hasOptions = false;
|
|
9090
|
-
let hasVisibleOption = false;
|
|
9091
|
-
for (const [optionElement, optionReg] of optionRegistrations) {
|
|
9092
|
-
if (sectionElement.contains(optionElement)) {
|
|
9093
|
-
hasOptions = true;
|
|
9094
|
-
if (!optionReg.lastFiltered) {
|
|
9095
|
-
hasVisibleOption = true;
|
|
9096
|
-
break;
|
|
9097
|
-
}
|
|
9098
|
-
}
|
|
9099
|
-
}
|
|
9100
|
-
const state = {
|
|
9101
|
-
hidden: hasOptions && !hasVisibleOption,
|
|
9102
|
-
'aria-hidden': !hasOptions
|
|
9103
|
-
};
|
|
9104
|
-
if (force || state.hidden !== reg.last.hidden || state['aria-hidden'] !== reg.last['aria-hidden']) {
|
|
9105
|
-
reg.last = state;
|
|
9106
|
-
reg.callback(state);
|
|
9107
|
-
}
|
|
9108
|
-
}
|
|
9095
|
+
CompositeStatus.displayName = COMPONENT_NAME$1c;
|
|
9096
|
+
CompositeStatus.className = CLASSNAME$19;
|
|
9109
9097
|
|
|
9110
9098
|
/** Typeahead interface. */
|
|
9111
9099
|
|
|
@@ -9247,214 +9235,186 @@ function isPrintableKey({
|
|
|
9247
9235
|
return key.length === 1 && key !== ' ' && !altKey && !ctrlKey && !metaKey;
|
|
9248
9236
|
}
|
|
9249
9237
|
|
|
9250
|
-
/** Options shared by the list and grid navigation modules. */
|
|
9251
|
-
|
|
9252
9238
|
/**
|
|
9253
|
-
*
|
|
9254
|
-
*
|
|
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).
|
|
9255
9243
|
*/
|
|
9244
|
+
function getOptionLabel(option) {
|
|
9245
|
+
return option.textContent?.trim() ?? '';
|
|
9246
|
+
}
|
|
9256
9247
|
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
signal,
|
|
9266
|
-
getActiveItem,
|
|
9267
|
-
wrap
|
|
9268
|
-
} = options;
|
|
9269
|
-
const focusNav = createListFocusNavigation({
|
|
9270
|
-
container,
|
|
9271
|
-
itemSelector: OPTION_SELECTOR,
|
|
9272
|
-
wrap,
|
|
9273
|
-
getActiveItem
|
|
9274
|
-
}, callbacks, signal);
|
|
9275
|
-
return {
|
|
9276
|
-
type: 'listbox',
|
|
9277
|
-
focusNav,
|
|
9278
|
-
cellSelector: OPTION_SELECTOR,
|
|
9279
|
-
isOptionCell: () => true,
|
|
9280
|
-
scrollIntoView(item) {
|
|
9281
|
-
// Last option: find the last child containing an option (not followed by another one).
|
|
9282
|
-
const lastItem = container.querySelector(`:scope > :has(${OPTION_SELECTOR}):not(:has(~ * ${OPTION_SELECTOR})) ${OPTION_SELECTOR}`);
|
|
9283
|
-
if (item === lastItem) {
|
|
9284
|
-
// Scroll to the end of the listbox (snaps to the end of the scroll container via CSS scroll snap)
|
|
9285
|
-
container.lastElementChild?.scrollIntoView({
|
|
9286
|
-
block: 'nearest'
|
|
9287
|
-
});
|
|
9288
|
-
} else {
|
|
9289
|
-
const toScrollTo = item.closest('[role=listbox] > *') || item;
|
|
9290
|
-
toScrollTo.scrollIntoView({
|
|
9291
|
-
block: 'nearest'
|
|
9292
|
-
});
|
|
9293
|
-
}
|
|
9294
|
-
},
|
|
9295
|
-
navigateHorizontal: () => false
|
|
9296
|
-
};
|
|
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);
|
|
9297
9256
|
}
|
|
9298
9257
|
|
|
9299
|
-
/**
|
|
9300
|
-
function
|
|
9301
|
-
|
|
9302
|
-
container,
|
|
9303
|
-
callbacks,
|
|
9304
|
-
signal
|
|
9305
|
-
} = options;
|
|
9306
|
-
const focusNav = createGridFocusNavigation({
|
|
9307
|
-
container,
|
|
9308
|
-
rowSelector: '[role="row"]',
|
|
9309
|
-
cellSelector: GRID_CELL_SELECTOR,
|
|
9310
|
-
wrap: true
|
|
9311
|
-
}, callbacks, signal);
|
|
9312
|
-
return {
|
|
9313
|
-
type: 'grid',
|
|
9314
|
-
focusNav,
|
|
9315
|
-
cellSelector: GRID_CELL_SELECTOR,
|
|
9316
|
-
isOptionCell: cell => !isActionCell(cell),
|
|
9317
|
-
scrollIntoView(item) {
|
|
9318
|
-
item.scrollIntoView({
|
|
9319
|
-
block: 'nearest'
|
|
9320
|
-
});
|
|
9321
|
-
},
|
|
9322
|
-
navigateHorizontal(key) {
|
|
9323
|
-
if (!focusNav.selectors.activeItem) return false;
|
|
9324
|
-
if (key === 'ArrowLeft') focusNav.goLeft();else focusNav.goRight();
|
|
9325
|
-
return true;
|
|
9326
|
-
}
|
|
9327
|
-
};
|
|
9258
|
+
/** Returns true when an item carries aria-disabled="true". */
|
|
9259
|
+
function isOptionDisabled(option) {
|
|
9260
|
+
return option.getAttribute('aria-disabled') === 'true';
|
|
9328
9261
|
}
|
|
9262
|
+
const isSelected = el => el.getAttribute('aria-selected') === 'true';
|
|
9329
9263
|
|
|
9330
9264
|
/** Delay before announcing loading in the live region (ms). */
|
|
9331
9265
|
const LOADING_ANNOUNCEMENT_DELAY = 500;
|
|
9332
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
|
+
|
|
9333
9286
|
/**
|
|
9334
|
-
* Set up
|
|
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.
|
|
9335
9289
|
*
|
|
9336
|
-
* The
|
|
9337
|
-
*
|
|
9338
|
-
*
|
|
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}).
|
|
9339
9294
|
*
|
|
9340
|
-
* - Standalone (no `focusOwner` option): the
|
|
9295
|
+
* - Standalone (no `focusOwner` option): the composite element owns DOM focus and
|
|
9341
9296
|
* `aria-activedescendant`, and handles its own keyboard navigation.
|
|
9342
9297
|
* - Linked (`focusOwner` option, e.g. a combobox trigger): the parent owns focus and the keyboard;
|
|
9343
|
-
* the
|
|
9344
|
-
*
|
|
9345
|
-
* @see https://www.w3.org/WAI/ARIA/apg/patterns/listbox/
|
|
9346
|
-
* @see https://www.w3.org/WAI/ARIA/apg/patterns/grid/
|
|
9298
|
+
* the composite writes `aria-activedescendant` on the parent focus owner.
|
|
9347
9299
|
*/
|
|
9348
|
-
function
|
|
9300
|
+
function setupComposite(options, specialization) {
|
|
9349
9301
|
const {
|
|
9350
9302
|
onSelect,
|
|
9351
9303
|
wrapNavigation = false,
|
|
9352
9304
|
focusOwner: link
|
|
9353
9305
|
} = options;
|
|
9354
9306
|
const isStandalone = !link;
|
|
9355
|
-
let element = null;
|
|
9356
|
-
let navigation = null;
|
|
9357
|
-
/** AbortController for the listeners attached on mount. */
|
|
9358
|
-
let mountController = null;
|
|
9359
|
-
/** Typeahead controller (created on mount, needs the listbox element). */
|
|
9360
|
-
let typeaheadController = null;
|
|
9361
|
-
|
|
9362
|
-
/** Current filter value (empty string = no filtering). */
|
|
9363
|
-
let filterValue = '';
|
|
9364
|
-
const optionRegistrations = new Map();
|
|
9365
|
-
const sectionRegistrations = new Map();
|
|
9366
|
-
let lastOptionsLength = 0;
|
|
9367
|
-
let lastInputValue = '';
|
|
9368
|
-
let lastLoadingState = false;
|
|
9369
|
-
let skeletonCount = 0;
|
|
9370
9307
|
|
|
9371
|
-
/**
|
|
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). */
|
|
9372
9324
|
let isOpen = isStandalone;
|
|
9373
9325
|
/** Timer for the debounced loading announcement. */
|
|
9374
9326
|
let loadingTimer;
|
|
9375
|
-
/** Whether a loading announcement has been sent since the
|
|
9327
|
+
/** Whether a loading announcement has been sent since the items became visible. */
|
|
9376
9328
|
let announcementSent = false;
|
|
9329
|
+
const isLoading = () => rootSkeletons.size > 0;
|
|
9377
9330
|
|
|
9378
|
-
/**
|
|
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`). */
|
|
9379
9334
|
|
|
9380
|
-
const subscribers = {
|
|
9381
|
-
activeDescendantChange: new Set(),
|
|
9382
|
-
optionsChange: new Set(),
|
|
9383
|
-
loadingChange: new Set(),
|
|
9384
|
-
loadingAnnouncement: new Set(),
|
|
9385
|
-
open: new Set()
|
|
9386
|
-
};
|
|
9387
9335
|
// `open` has a value from creation so pull-based subscribers read it before any change.
|
|
9388
|
-
const
|
|
9336
|
+
const initialValues = () => ({
|
|
9389
9337
|
open: isOpen
|
|
9390
|
-
};
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9338
|
+
});
|
|
9339
|
+
let latestValues = initialValues();
|
|
9340
|
+
function emit(event, value) {
|
|
9341
|
+
subscribers.get(event)?.forEach(cb => cb(value));
|
|
9342
|
+
}
|
|
9394
9343
|
function notify(event, value) {
|
|
9395
|
-
const previous = latestValues.activeDescendantChange ?? null;
|
|
9396
9344
|
latestValues[event] = value;
|
|
9397
|
-
|
|
9398
|
-
|
|
9345
|
+
emit(event, value);
|
|
9346
|
+
}
|
|
9399
9347
|
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
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);
|
|
9405
9355
|
}
|
|
9406
9356
|
|
|
9407
9357
|
// Forward-declared so the DOM listeners can reference `handle` (via closure) before it is constructed.
|
|
9408
9358
|
let handle;
|
|
9409
9359
|
|
|
9410
9360
|
/** The element that holds DOM focus and `aria-activedescendant`. */
|
|
9411
|
-
const getFocusOwner = () => link ? link.getFocusOwner() : element;
|
|
9412
|
-
function getVisibleOptionCount() {
|
|
9413
|
-
let count = 0;
|
|
9414
|
-
for (const reg of optionRegistrations.values()) {
|
|
9415
|
-
if (!reg.lastFiltered) count += 1;
|
|
9416
|
-
}
|
|
9417
|
-
return count;
|
|
9418
|
-
}
|
|
9419
|
-
function isFilteredOut(option) {
|
|
9420
|
-
const filterLower = filterValue.toLowerCase();
|
|
9421
|
-
return filterLower.length > 0 && !getOptionValue(option).toLowerCase().includes(filterLower);
|
|
9422
|
-
}
|
|
9361
|
+
const getFocusOwner = () => link ? link.getFocusOwner() : mounted?.element ?? null;
|
|
9423
9362
|
|
|
9424
9363
|
/**
|
|
9425
|
-
*
|
|
9426
|
-
*
|
|
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.
|
|
9427
9366
|
*/
|
|
9428
|
-
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9367
|
+
const hasVisibleContent = () => specialization.getVisibleCount(filter) > 0 || isLoading();
|
|
9368
|
+
|
|
9369
|
+
/**
|
|
9370
|
+
* Whether the mounted element holds a status (the live region, e.g. a `Combobox.State` inside the list),
|
|
9371
|
+
* outside of a hidden subtree. The status is always rendered (visually hidden when it shows no message), so
|
|
9372
|
+
* that the live region stays in the accessibility tree: the element must not hide it. (Read when the items
|
|
9373
|
+
* or the skeletons change: a status is rendered with the list, not later.)
|
|
9374
|
+
*/
|
|
9375
|
+
function hasStatus(container) {
|
|
9376
|
+
return Array.from(container.querySelectorAll(`.${CLASSNAME$19}`)).some(status => {
|
|
9377
|
+
const hiddenAncestor = status.parentElement?.closest('[hidden]');
|
|
9378
|
+
return !hiddenAncestor || hiddenAncestor === container || !container.contains(hiddenAncestor);
|
|
9379
|
+
});
|
|
9380
|
+
}
|
|
9381
|
+
|
|
9382
|
+
/** Hide the mounted element (`hidden`) when it has no visible content and no status. */
|
|
9383
|
+
function syncHidden() {
|
|
9384
|
+
const element = mounted?.element;
|
|
9385
|
+
if (!element) return;
|
|
9386
|
+
element.toggleAttribute('hidden', !hasVisibleContent() && !hasStatus(element));
|
|
9387
|
+
}
|
|
9388
|
+
function notifyOptionsChange() {
|
|
9389
|
+
syncHidden();
|
|
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);
|
|
9442
9399
|
}
|
|
9443
9400
|
}
|
|
9444
9401
|
|
|
9445
9402
|
// ── Loading announcement ──────────────────────────────────
|
|
9446
9403
|
|
|
9447
|
-
/**
|
|
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
|
+
*/
|
|
9448
9411
|
function startLoadingAnnouncementTimer() {
|
|
9449
9412
|
clearTimeout(loadingTimer);
|
|
9450
|
-
if (
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
}
|
|
9456
|
-
}, LOADING_ANNOUNCEMENT_DELAY);
|
|
9457
|
-
}
|
|
9413
|
+
if (!hasSkeleton() || !isOpen) return;
|
|
9414
|
+
loadingTimer = setTimeout(() => {
|
|
9415
|
+
announcementSent = true;
|
|
9416
|
+
notify('loadingAnnouncement', true);
|
|
9417
|
+
}, LOADING_ANNOUNCEMENT_DELAY);
|
|
9458
9418
|
}
|
|
9459
9419
|
|
|
9460
9420
|
/** Cancel the pending loading announcement and retract the sent one. */
|
|
@@ -9466,77 +9426,85 @@ function setupListbox(options = {}) {
|
|
|
9466
9426
|
}
|
|
9467
9427
|
}
|
|
9468
9428
|
|
|
9469
|
-
/**
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
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) {
|
|
9434
|
+
syncHidden();
|
|
9435
|
+
if (isLoading() !== wasLoading) {
|
|
9436
|
+
notify('loadingChange', isLoading());
|
|
9437
|
+
}
|
|
9438
|
+
if (hasSkeleton() === hadSkeleton) return;
|
|
9439
|
+
if (hadSkeleton) resetLoadingAnnouncement();else startLoadingAnnouncementTimer();
|
|
9475
9440
|
}
|
|
9476
9441
|
|
|
9477
9442
|
// ── Mount (DOM) ───────────────────────────────────────────
|
|
9478
9443
|
|
|
9479
9444
|
function unmount() {
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
navigation = null;
|
|
9483
|
-
typeaheadController = null;
|
|
9484
|
-
element = null;
|
|
9445
|
+
mounted?.controller.abort();
|
|
9446
|
+
mounted = null;
|
|
9485
9447
|
}
|
|
9486
|
-
function mount(
|
|
9487
|
-
if (element ===
|
|
9448
|
+
function mount(container) {
|
|
9449
|
+
if (mounted?.element === container) return () => {};
|
|
9488
9450
|
unmount();
|
|
9489
|
-
|
|
9490
|
-
mountController = new AbortController();
|
|
9451
|
+
const controller = new AbortController();
|
|
9491
9452
|
const {
|
|
9492
9453
|
signal
|
|
9493
|
-
} =
|
|
9494
|
-
const listbox = newElement;
|
|
9454
|
+
} = controller;
|
|
9495
9455
|
|
|
9496
9456
|
/**
|
|
9497
|
-
* Standalone only: true after a pointer press on the
|
|
9498
|
-
* In pointer mode, the active
|
|
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,
|
|
9499
9459
|
* so that the ring only shows for keyboard interaction.
|
|
9500
9460
|
*/
|
|
9501
9461
|
let isPointerModality = false;
|
|
9502
9462
|
|
|
9503
|
-
//
|
|
9504
|
-
const
|
|
9505
|
-
|
|
9506
|
-
container: listbox,
|
|
9463
|
+
// The specialization selects the navigation module (pattern) from the element.
|
|
9464
|
+
const nav = specialization.createNavigation({
|
|
9465
|
+
container,
|
|
9507
9466
|
wrap: wrapNavigation,
|
|
9508
9467
|
signal,
|
|
9509
9468
|
getActiveItem: () => {
|
|
9510
9469
|
const id = getFocusOwner()?.getAttribute('aria-activedescendant');
|
|
9511
|
-
return id &&
|
|
9470
|
+
return id && container.querySelector(`#${CSS.escape(id)}`) || null;
|
|
9512
9471
|
},
|
|
9513
9472
|
callbacks: {
|
|
9514
9473
|
onActivate(item) {
|
|
9515
9474
|
if (!isPointerModality) item.setAttribute('data-focus-visible-added', 'true');
|
|
9516
9475
|
getFocusOwner()?.setAttribute('aria-activedescendant', item.id);
|
|
9517
|
-
|
|
9518
|
-
requestAnimationFrame(() =>
|
|
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
|
+
});
|
|
9519
9481
|
},
|
|
9520
9482
|
onDeactivate(item) {
|
|
9521
9483
|
item.removeAttribute('data-focus-visible-added');
|
|
9522
9484
|
},
|
|
9523
9485
|
onClear() {
|
|
9524
9486
|
getFocusOwner()?.setAttribute('aria-activedescendant', '');
|
|
9525
|
-
|
|
9487
|
+
setActiveDescendant(null);
|
|
9526
9488
|
}
|
|
9527
9489
|
}
|
|
9528
9490
|
});
|
|
9529
|
-
navigation = nav;
|
|
9530
9491
|
const {
|
|
9531
9492
|
focusNav,
|
|
9532
9493
|
cellSelector
|
|
9533
9494
|
} = nav;
|
|
9534
|
-
|
|
9535
|
-
|
|
9495
|
+
const typeahead = createTypeahead(() => createSelectorTreeWalker(container, cellSelector), getOptionLabel, signal);
|
|
9496
|
+
mounted = {
|
|
9497
|
+
element: container,
|
|
9498
|
+
navigation: nav,
|
|
9499
|
+
typeahead,
|
|
9500
|
+
controller
|
|
9501
|
+
};
|
|
9502
|
+
syncHidden();
|
|
9503
|
+
link?.onMount?.(container);
|
|
9536
9504
|
|
|
9537
|
-
// ── Delegated
|
|
9505
|
+
// ── Delegated listeners ───────────────────────────────
|
|
9538
9506
|
|
|
9539
|
-
|
|
9507
|
+
container.addEventListener('click', event => {
|
|
9540
9508
|
const cell = event.target.closest(cellSelector);
|
|
9541
9509
|
if (!cell) return;
|
|
9542
9510
|
// Do not select disabled cells.
|
|
@@ -9544,29 +9512,30 @@ function setupListbox(options = {}) {
|
|
|
9544
9512
|
event.stopPropagation();
|
|
9545
9513
|
return;
|
|
9546
9514
|
}
|
|
9547
|
-
//
|
|
9515
|
+
// Not an option cell (e.g. grid action cell) — skip the selection, let its own handler fire.
|
|
9548
9516
|
if (!nav.isOptionCell(cell)) return;
|
|
9549
9517
|
handle.select(cell);
|
|
9550
9518
|
getFocusOwner()?.focus();
|
|
9551
|
-
// Standalone: the clicked
|
|
9519
|
+
// Standalone: the clicked item becomes the active item.
|
|
9552
9520
|
if (isStandalone) focusNav.goTo(() => cell);
|
|
9553
9521
|
}, {
|
|
9554
9522
|
signal
|
|
9555
9523
|
});
|
|
9556
9524
|
|
|
9557
9525
|
// Prevent mousedown on cells to avoid moving focus away from the focus owner before click fires.
|
|
9558
|
-
|
|
9526
|
+
container.addEventListener('mousedown', event => {
|
|
9559
9527
|
// Standalone: pointer interaction hides the focus ring (until the next key press).
|
|
9560
9528
|
if (isStandalone) isPointerModality = true;
|
|
9561
9529
|
if (event.target.closest(cellSelector)) event.preventDefault();
|
|
9562
9530
|
}, {
|
|
9563
9531
|
signal
|
|
9564
9532
|
});
|
|
9533
|
+
specialization.onMount?.(container, signal);
|
|
9565
9534
|
|
|
9566
9535
|
// ── Standalone focus owner listeners ──────────────────
|
|
9567
9536
|
if (isStandalone) {
|
|
9568
|
-
|
|
9569
|
-
// Keyboard interaction: show the focus ring on the active
|
|
9537
|
+
container.addEventListener('keydown', event => {
|
|
9538
|
+
// Keyboard interaction: show the focus ring on the active item.
|
|
9570
9539
|
if (isPointerModality) {
|
|
9571
9540
|
isPointerModality = false;
|
|
9572
9541
|
focusNav.selectors.activeItem?.setAttribute('data-focus-visible-added', 'true');
|
|
@@ -9578,16 +9547,14 @@ function setupListbox(options = {}) {
|
|
|
9578
9547
|
}, {
|
|
9579
9548
|
signal
|
|
9580
9549
|
});
|
|
9581
|
-
// On focus: show the visual focus on the selected
|
|
9582
|
-
|
|
9583
|
-
if (!focusNav.selectors.activeItem)
|
|
9584
|
-
focusNav.goTo(s => s.getMatching(isSelected) ?? s.getFirst());
|
|
9585
|
-
}
|
|
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');
|
|
9586
9553
|
}, {
|
|
9587
9554
|
signal
|
|
9588
9555
|
});
|
|
9589
9556
|
// On blur: hide the visual focus and reset the interaction mode (a later Tab shows the ring).
|
|
9590
|
-
|
|
9557
|
+
container.addEventListener('focusout', () => {
|
|
9591
9558
|
focusNav.clear();
|
|
9592
9559
|
isPointerModality = false;
|
|
9593
9560
|
}, {
|
|
@@ -9595,18 +9562,18 @@ function setupListbox(options = {}) {
|
|
|
9595
9562
|
});
|
|
9596
9563
|
}
|
|
9597
9564
|
return () => {
|
|
9598
|
-
if (element ===
|
|
9565
|
+
if (mounted?.element === container) unmount();
|
|
9599
9566
|
};
|
|
9600
9567
|
}
|
|
9601
9568
|
handle = {
|
|
9602
9569
|
get element() {
|
|
9603
|
-
return element;
|
|
9570
|
+
return mounted?.element ?? null;
|
|
9604
9571
|
},
|
|
9605
9572
|
get type() {
|
|
9606
|
-
return navigation
|
|
9573
|
+
return mounted?.navigation.type ?? null;
|
|
9607
9574
|
},
|
|
9608
|
-
get
|
|
9609
|
-
return navigation
|
|
9575
|
+
get activeItem() {
|
|
9576
|
+
return mounted?.navigation.focusNav.selectors.activeItem ?? null;
|
|
9610
9577
|
},
|
|
9611
9578
|
get isStandalone() {
|
|
9612
9579
|
return isStandalone;
|
|
@@ -9615,13 +9582,10 @@ function setupListbox(options = {}) {
|
|
|
9615
9582
|
return isOpen;
|
|
9616
9583
|
},
|
|
9617
9584
|
get isMultiSelect() {
|
|
9618
|
-
return element
|
|
9619
|
-
},
|
|
9620
|
-
get isLoading() {
|
|
9621
|
-
return skeletonCount > 0;
|
|
9585
|
+
return mounted?.element.getAttribute('aria-multiselectable') === 'true';
|
|
9622
9586
|
},
|
|
9623
9587
|
get hasVisibleContent() {
|
|
9624
|
-
return
|
|
9588
|
+
return hasVisibleContent();
|
|
9625
9589
|
},
|
|
9626
9590
|
mount,
|
|
9627
9591
|
setOpen(open) {
|
|
@@ -9635,12 +9599,13 @@ function setupListbox(options = {}) {
|
|
|
9635
9599
|
value: option ? getOptionValue(option) : ''
|
|
9636
9600
|
}, option);
|
|
9637
9601
|
},
|
|
9638
|
-
navigateHorizontal(key) {
|
|
9639
|
-
return navigation?.navigateHorizontal(key) ?? false;
|
|
9640
|
-
},
|
|
9641
9602
|
handleKeydown(event) {
|
|
9642
|
-
|
|
9643
|
-
|
|
9603
|
+
if (!mounted) return false;
|
|
9604
|
+
const {
|
|
9605
|
+
navigation,
|
|
9606
|
+
typeahead
|
|
9607
|
+
} = mounted;
|
|
9608
|
+
const nav = navigation.focusNav;
|
|
9644
9609
|
const {
|
|
9645
9610
|
activeItem,
|
|
9646
9611
|
hasNavigableItems
|
|
@@ -9648,17 +9613,17 @@ function setupListbox(options = {}) {
|
|
|
9648
9613
|
switch (event.key) {
|
|
9649
9614
|
// Arrows: consume the key even without navigable items (nothing to move to, no pending intent).
|
|
9650
9615
|
case 'ArrowDown':
|
|
9651
|
-
if (activeItem) nav.goDown();else if (hasNavigableItems)
|
|
9616
|
+
if (activeItem) nav.goDown();else if (hasNavigableItems) handle.activateDefaultItem('first');
|
|
9652
9617
|
return true;
|
|
9653
9618
|
case 'ArrowUp':
|
|
9654
|
-
if (activeItem) nav.goUp();else if (hasNavigableItems)
|
|
9619
|
+
if (activeItem) nav.goUp();else if (hasNavigableItems) handle.activateDefaultItem('last');
|
|
9655
9620
|
return true;
|
|
9656
9621
|
case 'ArrowLeft':
|
|
9657
9622
|
case 'ArrowRight':
|
|
9658
|
-
//
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
return
|
|
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;
|
|
9662
9627
|
case 'Home':
|
|
9663
9628
|
nav.goTo(s => s.getFirst());
|
|
9664
9629
|
return true;
|
|
@@ -9666,7 +9631,7 @@ function setupListbox(options = {}) {
|
|
|
9666
9631
|
nav.goTo(s => s.getLast());
|
|
9667
9632
|
return true;
|
|
9668
9633
|
case 'PageUp':
|
|
9669
|
-
// Without an active
|
|
9634
|
+
// Without an active item, let the page scroll.
|
|
9670
9635
|
if (!activeItem) return false;
|
|
9671
9636
|
nav.goToOffset(-10);
|
|
9672
9637
|
return true;
|
|
@@ -9676,15 +9641,13 @@ function setupListbox(options = {}) {
|
|
|
9676
9641
|
return true;
|
|
9677
9642
|
case 'Enter':
|
|
9678
9643
|
case ' ':
|
|
9679
|
-
// Select (single) or toggle (multi) the active
|
|
9644
|
+
// Select (single) or toggle (multi) the active item. Without an active item the key
|
|
9680
9645
|
// is not handled (a combobox lets Enter submit a surrounding form).
|
|
9681
9646
|
if (!activeItem) return false;
|
|
9682
9647
|
if (!isOptionDisabled(activeItem)) activeItem.click();
|
|
9683
9648
|
return true;
|
|
9684
9649
|
default:
|
|
9685
9650
|
if (isPrintableKey(event)) {
|
|
9686
|
-
const typeahead = typeaheadController;
|
|
9687
|
-
if (!typeahead) return false;
|
|
9688
9651
|
typeahead.handle(event.key, activeItem);
|
|
9689
9652
|
nav.goTo(n => typeahead.rematch(n.activeItem));
|
|
9690
9653
|
return true;
|
|
@@ -9693,10 +9656,267 @@ function setupListbox(options = {}) {
|
|
|
9693
9656
|
}
|
|
9694
9657
|
},
|
|
9695
9658
|
flushPendingNavigation() {
|
|
9696
|
-
navigation
|
|
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
|
+
}
|
|
9697
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();
|
|
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, {
|
|
9698
9918
|
registerOption(optionElement, callback) {
|
|
9699
|
-
const isFiltered = isFilteredOut(optionElement);
|
|
9919
|
+
const isFiltered = isFilteredOut(optionElement, getFilter());
|
|
9700
9920
|
optionRegistrations.set(optionElement, {
|
|
9701
9921
|
callback,
|
|
9702
9922
|
lastFiltered: isFiltered
|
|
@@ -9709,27 +9929,8 @@ function setupListbox(options = {}) {
|
|
|
9709
9929
|
notifyVisibilityChange();
|
|
9710
9930
|
};
|
|
9711
9931
|
},
|
|
9712
|
-
setFilter(newFilter) {
|
|
9713
|
-
filterValue = newFilter;
|
|
9714
|
-
for (const [optionElement, reg] of optionRegistrations) {
|
|
9715
|
-
const isFiltered = isFilteredOut(optionElement);
|
|
9716
|
-
// Only notify when state actually changes to avoid unnecessary re-renders.
|
|
9717
|
-
if (isFiltered !== reg.lastFiltered) {
|
|
9718
|
-
reg.lastFiltered = isFiltered;
|
|
9719
|
-
reg.callback(isFiltered);
|
|
9720
|
-
}
|
|
9721
|
-
}
|
|
9722
|
-
notifyVisibilityChange();
|
|
9723
|
-
},
|
|
9724
9932
|
refilterOption(optionElement) {
|
|
9725
|
-
|
|
9726
|
-
if (!reg) return;
|
|
9727
|
-
const isFiltered = isFilteredOut(optionElement);
|
|
9728
|
-
if (isFiltered !== reg.lastFiltered) {
|
|
9729
|
-
reg.lastFiltered = isFiltered;
|
|
9730
|
-
reg.callback(isFiltered);
|
|
9731
|
-
notifyVisibilityChange();
|
|
9732
|
-
}
|
|
9933
|
+
if (updateFilterState(optionElement, getFilter())) notifyVisibilityChange();
|
|
9733
9934
|
},
|
|
9734
9935
|
registerSection(sectionElement, callback) {
|
|
9735
9936
|
sectionRegistrations.set(sectionElement, {
|
|
@@ -9740,73 +9941,12 @@ function setupListbox(options = {}) {
|
|
|
9740
9941
|
}
|
|
9741
9942
|
});
|
|
9742
9943
|
// Compute and notify initial state immediately (force to ensure callback fires).
|
|
9743
|
-
notifySection(sectionElement,
|
|
9944
|
+
notifySection(sectionElement, true);
|
|
9744
9945
|
return () => {
|
|
9745
9946
|
sectionRegistrations.delete(sectionElement);
|
|
9746
9947
|
};
|
|
9747
|
-
},
|
|
9748
|
-
registerSkeleton() {
|
|
9749
|
-
const wasLoading = skeletonCount > 0;
|
|
9750
|
-
skeletonCount += 1;
|
|
9751
|
-
if (!wasLoading) onSkeletonCountChange();
|
|
9752
|
-
return () => {
|
|
9753
|
-
skeletonCount -= 1;
|
|
9754
|
-
if (skeletonCount === 0) onSkeletonCountChange();
|
|
9755
|
-
};
|
|
9756
|
-
},
|
|
9757
|
-
subscribe(event, callback) {
|
|
9758
|
-
if (isOptionActiveEvent(event)) {
|
|
9759
|
-
const optionCallback = callback;
|
|
9760
|
-
const set = optionActiveSubscribers.get(event) ?? new Set();
|
|
9761
|
-
optionActiveSubscribers.set(event, set);
|
|
9762
|
-
set.add(optionCallback);
|
|
9763
|
-
// Replay (same as open): Vue subscribes after mount and can miss the activation.
|
|
9764
|
-
if (latestValues.activeDescendantChange === event.slice(OPTION_ACTIVE_EVENT_PREFIX.length)) {
|
|
9765
|
-
optionCallback(true);
|
|
9766
|
-
}
|
|
9767
|
-
return () => {
|
|
9768
|
-
set.delete(optionCallback);
|
|
9769
|
-
if (!set.size) optionActiveSubscribers.delete(event);
|
|
9770
|
-
};
|
|
9771
|
-
}
|
|
9772
|
-
const staticEvent = event;
|
|
9773
|
-
subscribers[staticEvent].add(callback);
|
|
9774
|
-
// Replay current loading/visible state to late subscribers (e.g. async Vue watchers).
|
|
9775
|
-
if (event === 'loadingChange' && lastLoadingState || event === 'open' && isOpen) {
|
|
9776
|
-
callback(true);
|
|
9777
|
-
}
|
|
9778
|
-
return () => {
|
|
9779
|
-
subscribers[staticEvent].delete(callback);
|
|
9780
|
-
};
|
|
9781
|
-
},
|
|
9782
|
-
getSnapshot(event) {
|
|
9783
|
-
if (isOptionActiveEvent(event)) {
|
|
9784
|
-
// Derived value. No per-id value is stored.
|
|
9785
|
-
return latestValues.activeDescendantChange === event.slice(OPTION_ACTIVE_EVENT_PREFIX.length);
|
|
9786
|
-
}
|
|
9787
|
-
return latestValues[event];
|
|
9788
|
-
},
|
|
9789
|
-
destroy() {
|
|
9790
|
-
unmount();
|
|
9791
|
-
clearTimeout(loadingTimer);
|
|
9792
|
-
announcementSent = false;
|
|
9793
|
-
filterValue = '';
|
|
9794
|
-
lastOptionsLength = 0;
|
|
9795
|
-
lastInputValue = '';
|
|
9796
|
-
lastLoadingState = false;
|
|
9797
|
-
for (const key of Object.keys(latestValues)) {
|
|
9798
|
-
delete latestValues[key];
|
|
9799
|
-
}
|
|
9800
|
-
isOpen = isStandalone;
|
|
9801
|
-
latestValues.open = isOpen;
|
|
9802
|
-
optionRegistrations.clear();
|
|
9803
|
-
sectionRegistrations.clear();
|
|
9804
|
-
skeletonCount = 0;
|
|
9805
|
-
optionActiveSubscribers.clear();
|
|
9806
|
-
for (const set of Object.values(subscribers)) set.clear();
|
|
9807
9948
|
}
|
|
9808
|
-
};
|
|
9809
|
-
return handle;
|
|
9949
|
+
});
|
|
9810
9950
|
}
|
|
9811
9951
|
|
|
9812
9952
|
const DEFAULT_COMBOBOX_POPOVER_MAX_HEIGHT = '80vh';
|
|
@@ -9874,7 +10014,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
9874
10014
|
callbacks.onSelect?.(option);
|
|
9875
10015
|
// Close on selection (when not multiselectable)
|
|
9876
10016
|
if (element && !list.isMultiSelect) {
|
|
9877
|
-
list.
|
|
10017
|
+
list.clearActiveItem();
|
|
9878
10018
|
// Defer the close to the next frame (to make sure all other click handler resolve).
|
|
9879
10019
|
requestAnimationFrame(() => {
|
|
9880
10020
|
handle.setIsOpen(false);
|
|
@@ -9907,7 +10047,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
9907
10047
|
/** Detach everything (abort all listeners, clear state). */
|
|
9908
10048
|
function detach() {
|
|
9909
10049
|
// Clear the active option while the old trigger is still the focus owner.
|
|
9910
|
-
list.
|
|
10050
|
+
list.clearActiveItem();
|
|
9911
10051
|
abortController?.abort();
|
|
9912
10052
|
abortController = null;
|
|
9913
10053
|
}
|
|
@@ -9932,7 +10072,6 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
9932
10072
|
const {
|
|
9933
10073
|
altKey
|
|
9934
10074
|
} = event;
|
|
9935
|
-
const nav = list.focusNav;
|
|
9936
10075
|
switch (event.key) {
|
|
9937
10076
|
case 'Enter':
|
|
9938
10077
|
// Open with an active option: "click" it (handled by the listbox).
|
|
@@ -9952,7 +10091,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
9952
10091
|
if (!handle.isOpen) {
|
|
9953
10092
|
handle.setIsOpen(true);
|
|
9954
10093
|
// Focus first or selected item on open (deferred until the options commit).
|
|
9955
|
-
if (!altKey)
|
|
10094
|
+
if (!altKey) list.activateDefaultItem('first');
|
|
9956
10095
|
} else if (!altKey) {
|
|
9957
10096
|
list.handleKeydown(event);
|
|
9958
10097
|
}
|
|
@@ -9964,8 +10103,8 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
9964
10103
|
if (!handle.isOpen && !altKey) {
|
|
9965
10104
|
handle.setIsOpen(true);
|
|
9966
10105
|
// Focus last or selected item on open (deferred until the options commit).
|
|
9967
|
-
|
|
9968
|
-
} else if (handle.isOpen && (
|
|
10106
|
+
list.activateDefaultItem('last');
|
|
10107
|
+
} else if (handle.isOpen && (list.activeItem || !altKey)) {
|
|
9969
10108
|
// Alt+ArrowUp only moves when there is an active option.
|
|
9970
10109
|
list.handleKeydown(event);
|
|
9971
10110
|
}
|
|
@@ -9977,8 +10116,8 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
9977
10116
|
// When there is nothing to close or clear, let Escape propagate
|
|
9978
10117
|
// (ex: so a surrounding dialog can close).
|
|
9979
10118
|
if (alwaysOpen) {
|
|
9980
|
-
if (
|
|
9981
|
-
|
|
10119
|
+
if (list.activeItem) {
|
|
10120
|
+
list.clearActiveItem();
|
|
9982
10121
|
flag = true;
|
|
9983
10122
|
}
|
|
9984
10123
|
} else if (handle.isOpen) {
|
|
@@ -10051,11 +10190,11 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
10051
10190
|
setIsOpen(isOpen) {
|
|
10052
10191
|
// Always open: a close request only clears the active option.
|
|
10053
10192
|
if (alwaysOpen && !isOpen) {
|
|
10054
|
-
list.
|
|
10193
|
+
list.clearActiveItem();
|
|
10055
10194
|
return;
|
|
10056
10195
|
}
|
|
10057
10196
|
if (list.isOpen === isOpen) return;
|
|
10058
|
-
if (!isOpen) list.
|
|
10197
|
+
if (!isOpen) list.clearActiveItem();
|
|
10059
10198
|
// Update aria-expanded on trigger (false when no visible options or skeletons)
|
|
10060
10199
|
trigger?.setAttribute('aria-expanded', String(isOpen && list.hasVisibleContent));
|
|
10061
10200
|
// Last: the listbox dispatches `open` to the subscribers, which must see the trigger in its final state.
|
|
@@ -10110,23 +10249,28 @@ function setupComboboxButton(button, callbacks) {
|
|
|
10110
10249
|
signal
|
|
10111
10250
|
});
|
|
10112
10251
|
return event => {
|
|
10113
|
-
const
|
|
10252
|
+
const {
|
|
10253
|
+
list
|
|
10254
|
+
} = combobox;
|
|
10255
|
+
const {
|
|
10256
|
+
activeItem
|
|
10257
|
+
} = list;
|
|
10114
10258
|
switch (event.key) {
|
|
10115
10259
|
case 'Tab':
|
|
10116
10260
|
// Selects the focused option
|
|
10117
|
-
if (combobox.isOpen &&
|
|
10118
|
-
|
|
10261
|
+
if (combobox.isOpen && activeItem) {
|
|
10262
|
+
list.select(activeItem);
|
|
10119
10263
|
}
|
|
10120
10264
|
// Return false to continue normal 'Tab' behavior (focus next).
|
|
10121
10265
|
return false;
|
|
10122
10266
|
case ' ':
|
|
10123
10267
|
// Space acts like Enter in button mode: open, or "click" the active option (listbox).
|
|
10124
|
-
if (combobox.isOpen)
|
|
10268
|
+
if (combobox.isOpen) list.handleKeydown(event);else combobox.setIsOpen(true);
|
|
10125
10269
|
return true;
|
|
10126
10270
|
case 'ArrowUp':
|
|
10127
10271
|
// Alt+ArrowUp: select the focused option and close.
|
|
10128
|
-
if (event.altKey && combobox.isOpen &&
|
|
10129
|
-
|
|
10272
|
+
if (event.altKey && combobox.isOpen && activeItem) {
|
|
10273
|
+
list.select(activeItem);
|
|
10130
10274
|
combobox.setIsOpen(false);
|
|
10131
10275
|
return true;
|
|
10132
10276
|
}
|
|
@@ -10136,12 +10280,12 @@ function setupComboboxButton(button, callbacks) {
|
|
|
10136
10280
|
case 'End':
|
|
10137
10281
|
// Open, then jump (the listbox defers the jump until the options commit when opening from closed).
|
|
10138
10282
|
combobox.setIsOpen(true);
|
|
10139
|
-
|
|
10283
|
+
list.handleKeydown(event);
|
|
10140
10284
|
return true;
|
|
10141
10285
|
case 'ArrowLeft':
|
|
10142
10286
|
case 'ArrowRight':
|
|
10143
10287
|
// Grid pattern: navigate to the previous/next cell (listbox).
|
|
10144
|
-
return combobox.isOpen &&
|
|
10288
|
+
return combobox.isOpen && list.handleKeydown(event);
|
|
10145
10289
|
case 'Escape':
|
|
10146
10290
|
// Close if open; never clear selection (button-mode has no text input).
|
|
10147
10291
|
if (combobox.isOpen) {
|
|
@@ -10155,7 +10299,7 @@ function setupComboboxButton(button, callbacks) {
|
|
|
10155
10299
|
// Printable characters: open, then typeahead (listbox).
|
|
10156
10300
|
if (!isPrintableKey(event)) return false;
|
|
10157
10301
|
combobox.setIsOpen(true);
|
|
10158
|
-
|
|
10302
|
+
list.handleKeydown(event);
|
|
10159
10303
|
return true;
|
|
10160
10304
|
}
|
|
10161
10305
|
};
|
|
@@ -10253,13 +10397,13 @@ function useComboboxContext() {
|
|
|
10253
10397
|
* Hook to subscribe to a combobox event (`open`, `optionsChange`, `loadingChange`,
|
|
10254
10398
|
* `activeDescendantChange`, …). Must be used within a `Combobox.Provider`.
|
|
10255
10399
|
*
|
|
10256
|
-
* The events are dispatched by the listbox handle of the combobox (see {@link
|
|
10400
|
+
* The events are dispatched by the listbox handle of the combobox (see {@link useCompositeEvent}).
|
|
10257
10401
|
*/
|
|
10258
10402
|
function useComboboxEvent(event, initialValue) {
|
|
10259
10403
|
const {
|
|
10260
10404
|
handle
|
|
10261
10405
|
} = useComboboxContext();
|
|
10262
|
-
return
|
|
10406
|
+
return useCompositeEvent(handle?.list ?? null, event, initialValue);
|
|
10263
10407
|
}
|
|
10264
10408
|
|
|
10265
10409
|
/**
|
|
@@ -10299,13 +10443,10 @@ const ComboboxButton = Object.assign(forwardRefPolymorphic((props, ref) => {
|
|
|
10299
10443
|
setHandle
|
|
10300
10444
|
} = useComboboxContext();
|
|
10301
10445
|
const [isOpen] = useComboboxOpen();
|
|
10302
|
-
const {
|
|
10303
|
-
list
|
|
10304
|
-
} = useListboxContext();
|
|
10305
|
-
const state = useListboxEvent(list, 'optionsChange', {
|
|
10446
|
+
const state = useComboboxEvent('optionsChange', {
|
|
10306
10447
|
optionsLength: 0
|
|
10307
10448
|
});
|
|
10308
|
-
const isLoading =
|
|
10449
|
+
const isLoading = useComboboxEvent('loadingChange', false);
|
|
10309
10450
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10310
10451
|
const {
|
|
10311
10452
|
as,
|
|
@@ -10425,7 +10566,7 @@ function setupComboboxInput(input, options) {
|
|
|
10425
10566
|
input.addEventListener('input', event => {
|
|
10426
10567
|
if (!(event instanceof InputEvent)) return;
|
|
10427
10568
|
if (isDisabled()) return;
|
|
10428
|
-
combobox.list.
|
|
10569
|
+
combobox.list.clearActiveItem();
|
|
10429
10570
|
userHasTyped = true;
|
|
10430
10571
|
|
|
10431
10572
|
// Notify the framework wrapper of the new input value synchronously.
|
|
@@ -10441,7 +10582,7 @@ function setupComboboxInput(input, options) {
|
|
|
10441
10582
|
// Open on focus (only when openOnFocus is enabled).
|
|
10442
10583
|
input.addEventListener('focus', () => {
|
|
10443
10584
|
if (isDisabled()) return;
|
|
10444
|
-
combobox.list.
|
|
10585
|
+
combobox.list.clearActiveItem();
|
|
10445
10586
|
if (openOnFocus) {
|
|
10446
10587
|
combobox.setIsOpen(true);
|
|
10447
10588
|
}
|
|
@@ -10477,25 +10618,27 @@ function setupComboboxInput(input, options) {
|
|
|
10477
10618
|
});
|
|
10478
10619
|
signal.addEventListener('abort', unsubscribeOpen);
|
|
10479
10620
|
return event => {
|
|
10480
|
-
const
|
|
10621
|
+
const {
|
|
10622
|
+
list
|
|
10623
|
+
} = combobox;
|
|
10481
10624
|
switch (event.key) {
|
|
10482
10625
|
case 'Home':
|
|
10483
10626
|
input.setSelectionRange(0, 0);
|
|
10484
|
-
|
|
10627
|
+
list.clearActiveItem();
|
|
10485
10628
|
return true;
|
|
10486
10629
|
case 'End':
|
|
10487
10630
|
{
|
|
10488
10631
|
const len = input.value.length;
|
|
10489
10632
|
input.setSelectionRange(len, len);
|
|
10490
|
-
|
|
10633
|
+
list.clearActiveItem();
|
|
10491
10634
|
return true;
|
|
10492
10635
|
}
|
|
10493
10636
|
case 'ArrowLeft':
|
|
10494
10637
|
case 'ArrowRight':
|
|
10495
10638
|
// Grid pattern: navigate cells when an active cell exists.
|
|
10496
|
-
if (
|
|
10639
|
+
if (list.handleKeydown(event)) return true;
|
|
10497
10640
|
// Otherwise: clear active item, allow caret movement.
|
|
10498
|
-
|
|
10641
|
+
list.clearActiveItem();
|
|
10499
10642
|
return false;
|
|
10500
10643
|
default:
|
|
10501
10644
|
return false;
|
|
@@ -11175,13 +11318,10 @@ const ComboboxInput = forwardRef((props, ref) => {
|
|
|
11175
11318
|
selectionMode,
|
|
11176
11319
|
...otherProps
|
|
11177
11320
|
} = props;
|
|
11178
|
-
const {
|
|
11179
|
-
list
|
|
11180
|
-
} = useListboxContext();
|
|
11181
|
-
const state = useListboxEvent(list, 'optionsChange', {
|
|
11321
|
+
const state = useComboboxEvent('optionsChange', {
|
|
11182
11322
|
optionsLength: 0
|
|
11183
11323
|
});
|
|
11184
|
-
const isLoading =
|
|
11324
|
+
const isLoading = useComboboxEvent('loadingChange', false);
|
|
11185
11325
|
const internalInputRef = useRef(null);
|
|
11186
11326
|
const mergedInputRef = useMergeRefs(externalInputRef, internalInputRef);
|
|
11187
11327
|
|
|
@@ -11461,11 +11601,10 @@ function ComboboxProvider(props) {
|
|
|
11461
11601
|
listboxId,
|
|
11462
11602
|
anchorRef
|
|
11463
11603
|
}), [handle, listboxId]);
|
|
11464
|
-
// The listbox of the combobox: shared with the list, the options and the state through the
|
|
11465
|
-
const
|
|
11466
|
-
|
|
11467
|
-
listboxId
|
|
11468
|
-
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
|
|
11469
11608
|
}), [handle, listboxId]);
|
|
11470
11609
|
|
|
11471
11610
|
// Force the always open state (`undefined`: the core detects the inline listbox).
|
|
@@ -11484,8 +11623,8 @@ function ComboboxProvider(props) {
|
|
|
11484
11623
|
}, [handle]);
|
|
11485
11624
|
return /*#__PURE__*/jsx(ComboboxContext.Provider, {
|
|
11486
11625
|
value: contextValue,
|
|
11487
|
-
children: /*#__PURE__*/jsx(
|
|
11488
|
-
value:
|
|
11626
|
+
children: /*#__PURE__*/jsx(CompositeContext.Provider, {
|
|
11627
|
+
value: compositeContextValue,
|
|
11489
11628
|
children: children
|
|
11490
11629
|
})
|
|
11491
11630
|
});
|
|
@@ -11521,7 +11660,7 @@ const Combobox = {
|
|
|
11521
11660
|
/** Labelled group of options that auto-hides when all its child options are filtered out. */
|
|
11522
11661
|
Section: ListboxSection,
|
|
11523
11662
|
/** Displays empty, error, and loading state messages for the combobox list. */
|
|
11524
|
-
State:
|
|
11663
|
+
State: CompositeStatus,
|
|
11525
11664
|
/** Visual separator between option groups (alias for ListDivider). Purely decorative — invisible to screen readers. */
|
|
11526
11665
|
Divider: ListDivider,
|
|
11527
11666
|
/** Hook to subscribe to combobox events. Must be used within a Combobox.Provider. */
|
|
@@ -13556,7 +13695,9 @@ const useKeyboardListNavigation = (items, ref, onListItemSelected, onListItemNav
|
|
|
13556
13695
|
* @return React element.
|
|
13557
13696
|
*/
|
|
13558
13697
|
const InternalList = forwardRef((props, ref) => {
|
|
13698
|
+
// `as` is a core-only prop (not exposed by the React component).
|
|
13559
13699
|
const {
|
|
13700
|
+
as: _as,
|
|
13560
13701
|
children,
|
|
13561
13702
|
isClickable,
|
|
13562
13703
|
onListItemSelected,
|
|
@@ -13572,7 +13713,7 @@ const InternalList = forwardRef((props, ref) => {
|
|
|
13572
13713
|
});
|
|
13573
13714
|
});
|
|
13574
13715
|
InternalList.displayName = COMPONENT_NAME$1o;
|
|
13575
|
-
InternalList.className = CLASSNAME$
|
|
13716
|
+
InternalList.className = CLASSNAME$1m;
|
|
13576
13717
|
InternalList.defaultProps = DEFAULT_PROPS$13;
|
|
13577
13718
|
const List = Object.assign(InternalList, {
|
|
13578
13719
|
useKeyboardListNavigation
|
|
@@ -15831,7 +15972,7 @@ const ListItemAction = Object.assign(forwardRefPolymorphic((props, ref) => {
|
|
|
15831
15972
|
});
|
|
15832
15973
|
}), {
|
|
15833
15974
|
displayName: COMPONENT_NAME$1l,
|
|
15834
|
-
className: CLASSNAME$
|
|
15975
|
+
className: CLASSNAME$1j,
|
|
15835
15976
|
defaultProps: DEFAULT_PROPS$11
|
|
15836
15977
|
});
|
|
15837
15978
|
|
|
@@ -15851,7 +15992,9 @@ const _ListItem = forwardRef((props, ref) => {
|
|
|
15851
15992
|
disabledStateProps,
|
|
15852
15993
|
otherProps
|
|
15853
15994
|
} = useDisableStateProps(props);
|
|
15995
|
+
// `as` is a core-only prop (not exposed by the React component).
|
|
15854
15996
|
const {
|
|
15997
|
+
as: _as,
|
|
15855
15998
|
onItemSelected,
|
|
15856
15999
|
onClick,
|
|
15857
16000
|
linkRef,
|
|
@@ -15871,7 +16014,7 @@ const _ListItem = forwardRef((props, ref) => {
|
|
|
15871
16014
|
});
|
|
15872
16015
|
});
|
|
15873
16016
|
_ListItem.displayName = COMPONENT_NAME$1m;
|
|
15874
|
-
_ListItem.className = CLASSNAME$
|
|
16017
|
+
_ListItem.className = CLASSNAME$1k;
|
|
15875
16018
|
_ListItem.defaultProps = DEFAULT_PROPS$12;
|
|
15876
16019
|
|
|
15877
16020
|
/**
|
|
@@ -20092,7 +20235,7 @@ const SkeletonTypography = forwardRef((props, ref) => {
|
|
|
20092
20235
|
});
|
|
20093
20236
|
SkeletonTypography.displayName = COMPONENT_NAME$1g;
|
|
20094
20237
|
SkeletonTypography.defaultProps = DEFAULT_PROPS$j;
|
|
20095
|
-
SkeletonTypography.className = CLASSNAME$
|
|
20238
|
+
SkeletonTypography.className = CLASSNAME$1e;
|
|
20096
20239
|
|
|
20097
20240
|
/**
|
|
20098
20241
|
* Clamp value in range.
|
|
@@ -23785,5 +23928,5 @@ UserBlock.displayName = COMPONENT_NAME;
|
|
|
23785
23928
|
UserBlock.className = CLASSNAME;
|
|
23786
23929
|
UserBlock.defaultProps = DEFAULT_PROPS;
|
|
23787
23930
|
|
|
23788
|
-
export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonGroup, CLASSNAME$
|
|
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 };
|
|
23789
23932
|
//# sourceMappingURL=index.js.map
|