@lumx/react 4.3.2-alpha.10 → 4.3.2-alpha.11

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.js CHANGED
@@ -16,7 +16,7 @@ import concat from 'lodash/concat';
16
16
  import dropRight from 'lodash/dropRight';
17
17
  import partition from 'lodash/partition';
18
18
  import reduce from 'lodash/reduce';
19
- import { u as useDisabledStateContext, M as MovingFocusContext, a as useVirtualFocusParent, b as useVirtualFocus, A as A11YLiveMessage, c as MovingFocusProvider, P as Portal, C as ClickAwayProvider } from './_internal/BcRzrT9Y.js';
19
+ import { u as useDisabledStateContext, a as useVirtualFocusParent, M as MovingFocusContext, i as isComboboxValue, b as useComboboxRefs, c as useCombobox, S as SectionContext, g as generateOptionId, d as useVirtualFocus, A as A11YLiveMessage, C as ComboboxContext, e as MovingFocusProvider, r as reducer$1, f as initialState, h as ComboboxRefsProvider, P as Portal, j as ClickAwayProvider } from './_internal/BCgo9dYV.js';
20
20
  import isEmpty from 'lodash/isEmpty';
21
21
  import { getDisabledState } from '@lumx/core/js/utils/disabledState';
22
22
  import { mdiCloseCircle } from '@lumx/icons/esm/close-circle';
@@ -24,15 +24,14 @@ import memoize from 'lodash/memoize';
24
24
  import { mdiClose } from '@lumx/icons/esm/close';
25
25
  import isFunction from 'lodash/isFunction';
26
26
  import { mdiImageBroken } from '@lumx/icons/esm/image-broken';
27
+ import noop from 'lodash/noop';
28
+ import castArray from 'lodash/castArray';
27
29
  import { mdiCheck } from '@lumx/icons/esm/check';
28
30
  import { mdiMinus } from '@lumx/icons/esm/minus';
29
31
  import { visuallyHidden, bem as bem$1 } from '@lumx/core/js/utils/classNames';
30
- import noop from 'lodash/noop';
31
- import uniqueId from 'lodash/uniqueId';
32
32
  import debounce$1 from 'lodash/debounce';
33
33
  import { mdiChevronDown } from '@lumx/icons/esm/chevron-down';
34
34
  import { mdiChevronUp } from '@lumx/icons/esm/chevron-up';
35
- import castArray from 'lodash/castArray';
36
35
  import { mdiInformationOutline } from '@lumx/icons/esm/information-outline';
37
36
  import { mdiChevronLeft } from '@lumx/icons/esm/chevron-left';
38
37
  import { mdiChevronRight } from '@lumx/icons/esm/chevron-right';
@@ -105,10 +104,10 @@ const COMPONENT_NAME$1l = 'AlertDialog';
105
104
  /**
106
105
  * Component default class name and class prefix.
107
106
  */
108
- const CLASSNAME$1o = 'lumx-alert-dialog';
107
+ const CLASSNAME$1n = 'lumx-alert-dialog';
109
108
  const {
110
109
  block: block$19
111
- } = classNames.bem(CLASSNAME$1o);
110
+ } = classNames.bem(CLASSNAME$1n);
112
111
 
113
112
  /**
114
113
  * Component default props.
@@ -222,7 +221,7 @@ const AlertDialog = forwardRef((props, ref) => {
222
221
  });
223
222
  });
224
223
  AlertDialog.displayName = COMPONENT_NAME$1l;
225
- AlertDialog.className = CLASSNAME$1o;
224
+ AlertDialog.className = CLASSNAME$1n;
226
225
  AlertDialog.defaultProps = DEFAULT_PROPS$1b;
227
226
 
228
227
  /**
@@ -320,7 +319,7 @@ const COMPONENT_NAME$1k = 'Autocomplete';
320
319
  /**
321
320
  * Component default class name and class prefix.
322
321
  */
323
- const CLASSNAME$1n = 'lumx-autocomplete';
322
+ const CLASSNAME$1m = 'lumx-autocomplete';
324
323
 
325
324
  /**
326
325
  * Component default props.
@@ -387,7 +386,7 @@ const Autocomplete = forwardRef((props, ref) => {
387
386
  return /*#__PURE__*/jsxs("div", {
388
387
  ref: ref,
389
388
  ...forwardedProps,
390
- className: classNames.join(className, CLASSNAME$1n),
389
+ className: classNames.join(className, CLASSNAME$1m),
391
390
  children: [/*#__PURE__*/jsx(TextField, {
392
391
  ...textFieldProps,
393
392
  chips: chips,
@@ -428,7 +427,7 @@ const Autocomplete = forwardRef((props, ref) => {
428
427
  });
429
428
  });
430
429
  Autocomplete.displayName = COMPONENT_NAME$1k;
431
- Autocomplete.className = CLASSNAME$1n;
430
+ Autocomplete.className = CLASSNAME$1m;
432
431
  Autocomplete.defaultProps = DEFAULT_PROPS$1a;
433
432
 
434
433
  /**
@@ -439,7 +438,7 @@ const COMPONENT_NAME$1j = 'AutocompleteMultiple';
439
438
  /**
440
439
  * Component default class name and class prefix.
441
440
  */
442
- const CLASSNAME$1m = 'lumx-autocomplete-multiple';
441
+ const CLASSNAME$1l = 'lumx-autocomplete-multiple';
443
442
 
444
443
  /**
445
444
  * Component default props.
@@ -519,7 +518,7 @@ const AutocompleteMultiple = forwardRef((props, ref) => {
519
518
  ref: ref,
520
519
  ...forwardedProps,
521
520
  anchorToInput: anchorToInput,
522
- className: classNames.join(className, CLASSNAME$1m),
521
+ className: classNames.join(className, CLASSNAME$1l),
523
522
  name: name,
524
523
  value: value,
525
524
  onChange: onChange,
@@ -553,7 +552,7 @@ const AutocompleteMultiple = forwardRef((props, ref) => {
553
552
  });
554
553
  });
555
554
  AutocompleteMultiple.displayName = COMPONENT_NAME$1j;
556
- AutocompleteMultiple.className = CLASSNAME$1m;
555
+ AutocompleteMultiple.className = CLASSNAME$1l;
557
556
  AutocompleteMultiple.defaultProps = DEFAULT_PROPS$19;
558
557
 
559
558
  /**
@@ -564,11 +563,11 @@ const COMPONENT_NAME$1i = 'Avatar';
564
563
  /**
565
564
  * Component default class name and class prefix.
566
565
  */
567
- const CLASSNAME$1l = 'lumx-avatar';
566
+ const CLASSNAME$1k = 'lumx-avatar';
568
567
  const {
569
568
  block: block$18,
570
569
  element: element$S
571
- } = classNames.bem(CLASSNAME$1l);
570
+ } = classNames.bem(CLASSNAME$1k);
572
571
 
573
572
  /**
574
573
  * Component default props.
@@ -630,7 +629,7 @@ const Avatar = forwardRef((props, ref) => {
630
629
  });
631
630
  });
632
631
  Avatar.displayName = COMPONENT_NAME$1i;
633
- Avatar.className = CLASSNAME$1l;
632
+ Avatar.className = CLASSNAME$1k;
634
633
  Avatar.defaultProps = DEFAULT_PROPS$18;
635
634
 
636
635
  /**
@@ -932,10 +931,10 @@ const COMPONENT_NAME$1h = 'Badge';
932
931
  /**
933
932
  * Component default class name and class prefix.
934
933
  */
935
- const CLASSNAME$1k = 'lumx-badge';
934
+ const CLASSNAME$1j = 'lumx-badge';
936
935
  const {
937
936
  block: block$16
938
- } = bem(CLASSNAME$1k);
937
+ } = bem(CLASSNAME$1j);
939
938
 
940
939
  /**
941
940
  * Component default props.
@@ -968,7 +967,7 @@ const Badge$1 = props => {
968
967
  });
969
968
  };
970
969
  Badge$1.displayName = COMPONENT_NAME$1h;
971
- Badge$1.className = CLASSNAME$1k;
970
+ Badge$1.className = CLASSNAME$1j;
972
971
  Badge$1.defaultProps = DEFAULT_PROPS$17;
973
972
 
974
973
  /**
@@ -993,11 +992,11 @@ Badge.className = Badge$1.className;
993
992
  Badge.defaultProps = Badge$1.defaultProps;
994
993
 
995
994
  const COMPONENT_NAME$1g = 'BadgeWrapper';
996
- const CLASSNAME$1j = 'lumx-badge-wrapper';
995
+ const CLASSNAME$1i = 'lumx-badge-wrapper';
997
996
  const {
998
997
  block: block$15,
999
998
  element: element$Q
1000
- } = bem(CLASSNAME$1j);
999
+ } = bem(CLASSNAME$1i);
1001
1000
  const BadgeWrapper$1 = props => {
1002
1001
  const {
1003
1002
  badge,
@@ -1024,7 +1023,7 @@ const BadgeWrapper = forwardRef((props, ref) => {
1024
1023
  });
1025
1024
  });
1026
1025
  BadgeWrapper.displayName = COMPONENT_NAME$1g;
1027
- BadgeWrapper.className = CLASSNAME$1j;
1026
+ BadgeWrapper.className = CLASSNAME$1i;
1028
1027
 
1029
1028
  /**
1030
1029
  * Render clickable element (link, button or custom element)
@@ -1185,10 +1184,10 @@ const COMPONENT_NAME$1e = 'Button';
1185
1184
  /**
1186
1185
  * Component default class name and class prefix.
1187
1186
  */
1188
- const CLASSNAME$1i = 'lumx-button';
1187
+ const CLASSNAME$1h = 'lumx-button';
1189
1188
  const {
1190
1189
  modifier
1191
- } = bem(CLASSNAME$1i);
1190
+ } = bem(CLASSNAME$1h);
1192
1191
 
1193
1192
  /**
1194
1193
  * Component default props.
@@ -1226,7 +1225,7 @@ const Button$1 = props => {
1226
1225
  });
1227
1226
  };
1228
1227
  Button$1.displayName = COMPONENT_NAME$1e;
1229
- Button$1.className = CLASSNAME$1i;
1228
+ Button$1.className = CLASSNAME$1h;
1230
1229
  Button$1.defaultProps = DEFAULT_PROPS$16;
1231
1230
 
1232
1231
  /**
@@ -1294,7 +1293,7 @@ const Button = forwardRef((props, ref) => {
1294
1293
  });
1295
1294
  });
1296
1295
  Button.displayName = COMPONENT_NAME$1e;
1297
- Button.className = CLASSNAME$1i;
1296
+ Button.className = CLASSNAME$1h;
1298
1297
  Button.defaultProps = DEFAULT_PROPS$16;
1299
1298
 
1300
1299
  const COMPONENT_NAME$1d = 'Icon';
@@ -1304,10 +1303,10 @@ const IconClassName = 'lumx-icon';
1304
1303
  * Defines the props of the component.
1305
1304
  */
1306
1305
 
1307
- const CLASSNAME$1h = IconClassName;
1306
+ const CLASSNAME$1g = IconClassName;
1308
1307
  const {
1309
1308
  block: block$14
1310
- } = bem(CLASSNAME$1h);
1309
+ } = bem(CLASSNAME$1g);
1311
1310
 
1312
1311
  /**
1313
1312
  * Component default props.
@@ -1391,7 +1390,7 @@ const Icon$1 = props => {
1391
1390
  });
1392
1391
  };
1393
1392
  Icon$1.displayName = COMPONENT_NAME$1d;
1394
- Icon$1.className = CLASSNAME$1h;
1393
+ Icon$1.className = CLASSNAME$1g;
1395
1394
  Icon$1.defaultProps = DEFAULT_PROPS$15;
1396
1395
 
1397
1396
  /**
@@ -1402,7 +1401,7 @@ const COMPONENT_NAME$1c = 'IconButton';
1402
1401
  /**
1403
1402
  * Component default class name and class prefix.
1404
1403
  */
1405
- const CLASSNAME$1g = 'lumx-icon-button';
1404
+ const CLASSNAME$1f = 'lumx-icon-button';
1406
1405
 
1407
1406
  /**
1408
1407
  * Component default props.
@@ -1444,7 +1443,7 @@ const IconButton$1 = props => {
1444
1443
  });
1445
1444
  };
1446
1445
  IconButton$1.displayName = COMPONENT_NAME$1c;
1447
- IconButton$1.className = CLASSNAME$1g;
1446
+ IconButton$1.className = CLASSNAME$1f;
1448
1447
  IconButton$1.defaultProps = DEFAULT_PROPS$14;
1449
1448
 
1450
1449
  /**
@@ -1481,7 +1480,7 @@ const IconButton = forwardRef((props, ref) => {
1481
1480
  });
1482
1481
  });
1483
1482
  IconButton.displayName = COMPONENT_NAME$1c;
1484
- IconButton.className = CLASSNAME$1g;
1483
+ IconButton.className = CLASSNAME$1f;
1485
1484
  IconButton.defaultProps = DEFAULT_PROPS$14;
1486
1485
 
1487
1486
  /**
@@ -1492,7 +1491,7 @@ const COMPONENT_NAME$1b = 'ButtonGroup';
1492
1491
  /**
1493
1492
  * Component default class name and class prefix.
1494
1493
  */
1495
- const CLASSNAME$1f = 'lumx-button-group';
1494
+ const CLASSNAME$1e = 'lumx-button-group';
1496
1495
 
1497
1496
  /**
1498
1497
  * Component default props.
@@ -1513,12 +1512,12 @@ const ButtonGroup$1 = props => {
1513
1512
  } = props;
1514
1513
  return /*#__PURE__*/jsx("div", {
1515
1514
  ...forwardedProps,
1516
- className: classnames(className, CLASSNAME$1f),
1515
+ className: classnames(className, CLASSNAME$1e),
1517
1516
  children: children
1518
1517
  });
1519
1518
  };
1520
1519
  ButtonGroup$1.displayName = COMPONENT_NAME$1b;
1521
- ButtonGroup$1.className = CLASSNAME$1f;
1520
+ ButtonGroup$1.className = CLASSNAME$1e;
1522
1521
  ButtonGroup$1.defaultProps = DEFAULT_PROPS$13;
1523
1522
 
1524
1523
  /**
@@ -1535,15 +1534,15 @@ const ButtonGroup = forwardRef((props, ref) => {
1535
1534
  });
1536
1535
  });
1537
1536
  ButtonGroup.displayName = COMPONENT_NAME$1b;
1538
- ButtonGroup.className = CLASSNAME$1f;
1537
+ ButtonGroup.className = CLASSNAME$1e;
1539
1538
  ButtonGroup.defaultProps = DEFAULT_PROPS$13;
1540
1539
 
1541
1540
  const COMPONENT_NAME$1a = 'InputLabel';
1542
1541
  const InputLabelClassName = 'lumx-input-label';
1543
- const CLASSNAME$1e = InputLabelClassName;
1542
+ const CLASSNAME$1d = InputLabelClassName;
1544
1543
  const {
1545
1544
  block: block$13
1546
- } = bem(CLASSNAME$1e);
1545
+ } = bem(CLASSNAME$1d);
1547
1546
  const DEFAULT_PROPS$12 = {};
1548
1547
 
1549
1548
  /**
@@ -1573,7 +1572,7 @@ function InputLabel$1(props) {
1573
1572
  });
1574
1573
  }
1575
1574
  InputLabel$1.displayName = COMPONENT_NAME$1a;
1576
- InputLabel$1.className = CLASSNAME$1e;
1575
+ InputLabel$1.className = CLASSNAME$1d;
1577
1576
  InputLabel$1.defaultProps = DEFAULT_PROPS$12;
1578
1577
 
1579
1578
  const INPUT_HELPER_CONFIGURATION = {
@@ -1595,10 +1594,10 @@ const InputHelperClassName = 'lumx-input-helper';
1595
1594
  * Defines the props of the component.
1596
1595
  */
1597
1596
 
1598
- const CLASSNAME$1d = InputHelperClassName;
1597
+ const CLASSNAME$1c = InputHelperClassName;
1599
1598
  const {
1600
1599
  block: block$12
1601
- } = bem(CLASSNAME$1d);
1600
+ } = bem(CLASSNAME$1c);
1602
1601
 
1603
1602
  /**
1604
1603
  * Component default props.
@@ -1633,7 +1632,7 @@ function InputHelper$1(props) {
1633
1632
  });
1634
1633
  }
1635
1634
  InputHelper$1.displayName = COMPONENT_NAME$19;
1636
- InputHelper$1.className = CLASSNAME$1d;
1635
+ InputHelper$1.className = CLASSNAME$1c;
1637
1636
  InputHelper$1.defaultProps = DEFAULT_PROPS$11;
1638
1637
 
1639
1638
  const INTERMEDIATE_STATE = 'intermediate';
@@ -1650,11 +1649,11 @@ const COMPONENT_NAME$18 = 'Checkbox';
1650
1649
  /**
1651
1650
  * Component default class name and class prefix.
1652
1651
  */
1653
- const CLASSNAME$1c = 'lumx-checkbox';
1652
+ const CLASSNAME$1b = 'lumx-checkbox';
1654
1653
  const {
1655
1654
  block: block$11,
1656
1655
  element: element$P
1657
- } = bem(CLASSNAME$1c);
1656
+ } = bem(CLASSNAME$1b);
1658
1657
 
1659
1658
  /**
1660
1659
  * Checkbox component.
@@ -1810,7 +1809,7 @@ const Checkbox = forwardRef((props, ref) => {
1810
1809
  });
1811
1810
  });
1812
1811
  Checkbox.displayName = COMPONENT_NAME$18;
1813
- Checkbox.className = CLASSNAME$1c;
1812
+ Checkbox.className = CLASSNAME$1b;
1814
1813
  Checkbox.defaultProps = DEFAULT_PROPS$10;
1815
1814
 
1816
1815
  /**
@@ -1837,11 +1836,11 @@ const COMPONENT_NAME$17 = 'Chip';
1837
1836
  /**
1838
1837
  * Component default class name and class prefix.
1839
1838
  */
1840
- const CLASSNAME$1b = 'lumx-chip';
1839
+ const CLASSNAME$1a = 'lumx-chip';
1841
1840
  const {
1842
1841
  block: block$10,
1843
1842
  element: element$O
1844
- } = classNames.bem(CLASSNAME$1b);
1843
+ } = classNames.bem(CLASSNAME$1a);
1845
1844
 
1846
1845
  /**
1847
1846
  * Component default props.
@@ -1947,7 +1946,7 @@ const Chip = forwardRef((props, ref) => {
1947
1946
  );
1948
1947
  });
1949
1948
  Chip.displayName = COMPONENT_NAME$17;
1950
- Chip.className = CLASSNAME$1b;
1949
+ Chip.className = CLASSNAME$1a;
1951
1950
  Chip.defaultProps = DEFAULT_PROPS$$;
1952
1951
 
1953
1952
  const INITIAL_STATE_ACTIVE_CHIP = -1;
@@ -2014,7 +2013,7 @@ const COMPONENT_NAME$16 = 'ChipGroup';
2014
2013
  /**
2015
2014
  * Component default class name and class prefix.
2016
2015
  */
2017
- const CLASSNAME$1a = 'lumx-chip-group';
2016
+ const CLASSNAME$19 = 'lumx-chip-group';
2018
2017
 
2019
2018
  /**
2020
2019
  * ChipGroup component.
@@ -2033,12 +2032,12 @@ const InternalChipGroup = forwardRef((props, ref) => {
2033
2032
  return /*#__PURE__*/jsx("div", {
2034
2033
  ref: ref,
2035
2034
  ...forwardedProps,
2036
- className: classNames.join(className, CLASSNAME$1a),
2035
+ className: classNames.join(className, CLASSNAME$19),
2037
2036
  children: children
2038
2037
  });
2039
2038
  });
2040
2039
  InternalChipGroup.displayName = COMPONENT_NAME$16;
2041
- InternalChipGroup.className = CLASSNAME$1a;
2040
+ InternalChipGroup.className = CLASSNAME$19;
2042
2041
  InternalChipGroup.defaultProps = DEFAULT_PROPS$_;
2043
2042
  const ChipGroup = Object.assign(InternalChipGroup, {
2044
2043
  useChipGroupNavigation
@@ -2129,11 +2128,11 @@ function useFocusLastChipOnBackspace(chipRefs, inputRef) {
2129
2128
  /**
2130
2129
  * Component default class name and class prefix.
2131
2130
  */
2132
- const CLASSNAME$19 = 'lumx-selection-chip-group';
2131
+ const CLASSNAME$18 = 'lumx-selection-chip-group';
2133
2132
  const {
2134
2133
  block: block$$,
2135
2134
  element: element$N
2136
- } = classNames.bem(CLASSNAME$19);
2135
+ } = classNames.bem(CLASSNAME$18);
2137
2136
 
2138
2137
  /**
2139
2138
  * SelectionChipGroup component.
@@ -2222,330 +2221,6 @@ const SelectionChipGroup = ({
2222
2221
  });
2223
2222
  };
2224
2223
 
2225
- /** Context to store the refs of the combobox elements */
2226
- const ComboboxRefsContext = /*#__PURE__*/createContext({
2227
- triggerRef: {
2228
- current: null
2229
- },
2230
- anchorRef: {
2231
- current: null
2232
- }
2233
- });
2234
- /** Provider to store the required refs for the Combobox */
2235
- const ComboboxRefsProvider = ({
2236
- triggerRef,
2237
- anchorRef,
2238
- children
2239
- }) => {
2240
- const value = useMemo(() => ({
2241
- triggerRef,
2242
- anchorRef
2243
- }), [triggerRef, anchorRef]);
2244
- return /*#__PURE__*/jsx(ComboboxRefsContext.Provider, {
2245
- value: value,
2246
- children: children
2247
- });
2248
- };
2249
-
2250
- /** Retrieves the combobox elements references from context */
2251
- const useComboboxRefs = () => {
2252
- const refs = useContext(ComboboxRefsContext);
2253
- if (!refs) {
2254
- throw new Error('The useComboboxRefs hook must be called within a ComboboxRefsProvider');
2255
- }
2256
- return refs;
2257
- };
2258
-
2259
- /** Generate the combobox option id from the combobox id and the given id */
2260
- const generateOptionId = (comboboxId, optionId) => `${comboboxId}-option-${optionId}`;
2261
-
2262
- /** Verifies that the combobox registered option is an action */
2263
- const isComboboxAction = option => Boolean(option?.isAction);
2264
-
2265
- /** Verifies that the combobox registered option is the option's value */
2266
- const isComboboxValue = option => {
2267
- return !isComboboxAction(option);
2268
- };
2269
-
2270
- const comboboxId = `combobox-${uniqueId()}`;
2271
- const initialState = {
2272
- comboboxId,
2273
- listboxId: `${comboboxId}-popover`,
2274
- status: 'idle',
2275
- isOpen: false,
2276
- inputValue: '',
2277
- showAll: true,
2278
- options: {},
2279
- type: 'listbox',
2280
- optionsLength: 0
2281
- };
2282
-
2283
- /** Actions when the combobox opens. */
2284
- const OPEN_COMBOBOX = (state, action) => {
2285
- const {
2286
- manual
2287
- } = action.payload || {};
2288
- // If the combobox was manually opened, show all suggestions
2289
- return {
2290
- ...state,
2291
- showAll: Boolean(manual),
2292
- isOpen: true
2293
- };
2294
- };
2295
-
2296
- /** Actions when the combobox closes */
2297
- const CLOSE_COMBOBOX = state => {
2298
- return {
2299
- ...state,
2300
- showAll: true,
2301
- isOpen: false
2302
- };
2303
- };
2304
-
2305
- /** Actions on input update. */
2306
- const SET_INPUT_VALUE = (state, action) => {
2307
- return {
2308
- ...state,
2309
- inputValue: action.payload,
2310
- // When the user is changing the value, show only values that are related to the input value.
2311
- showAll: false,
2312
- isOpen: true
2313
- };
2314
- };
2315
-
2316
- /** Register an option to the state */
2317
- const ADD_OPTION = (state, action) => {
2318
- const {
2319
- id,
2320
- option
2321
- } = action.payload;
2322
- const {
2323
- options
2324
- } = state;
2325
- if (options[id]) {
2326
- // Option already exists, return state unchanged
2327
- return state;
2328
- }
2329
- const newOptions = {
2330
- ...options,
2331
- [id]: option
2332
- };
2333
- let newType = state.type;
2334
- if (isComboboxAction(option)) {
2335
- newType = 'grid';
2336
- }
2337
- let newOptionsLength = state.optionsLength;
2338
- if (isComboboxValue(option)) {
2339
- newOptionsLength += 1;
2340
- }
2341
- return {
2342
- ...state,
2343
- options: newOptions,
2344
- type: newType,
2345
- optionsLength: newOptionsLength
2346
- };
2347
- };
2348
-
2349
- /** Remove an option from the state */
2350
- const REMOVE_OPTION = (state, action) => {
2351
- const {
2352
- id
2353
- } = action.payload;
2354
- const {
2355
- options
2356
- } = state;
2357
- const option = options[id];
2358
- if (!options[id]) {
2359
- // Option doesn't exist, return state unchanged
2360
- return state;
2361
- }
2362
- const newOptions = {
2363
- ...options
2364
- };
2365
- delete newOptions[id];
2366
- let newOptionsLength = state.optionsLength;
2367
- if (isComboboxValue(option)) {
2368
- newOptionsLength -= 1;
2369
- }
2370
- return {
2371
- ...state,
2372
- options: newOptions,
2373
- optionsLength: newOptionsLength
2374
- };
2375
- };
2376
-
2377
- /** Reducers for each action type: */
2378
- const REDUCERS = {
2379
- OPEN_COMBOBOX,
2380
- CLOSE_COMBOBOX,
2381
- SET_INPUT_VALUE,
2382
- ADD_OPTION,
2383
- REMOVE_OPTION
2384
- };
2385
-
2386
- /** Main reducer */
2387
- const reducer$1 = (state, action) => {
2388
- return REDUCERS[action.type]?.(state, action) || state;
2389
- };
2390
-
2391
- /** Dispatch for the combobox component */
2392
-
2393
- /** Context for the Combobox component */
2394
- const ComboboxContext = /*#__PURE__*/React__default.createContext({
2395
- ...initialState,
2396
- openOnFocus: false,
2397
- openOnClick: false,
2398
- selectionType: 'single',
2399
- optionsLength: 0,
2400
- onSelect: noop,
2401
- onInputChange: noop,
2402
- onOpen: noop,
2403
- dispatch: noop,
2404
- translations: {
2405
- clearLabel: '',
2406
- tryReloadLabel: '',
2407
- showSuggestionsLabel: '',
2408
- noResultsForInputLabel: input => input || '',
2409
- loadingLabel: '',
2410
- serviceUnavailableLabel: '',
2411
- nbOptionsLabel: options => `${options}`
2412
- }
2413
- });
2414
-
2415
- /** Context for a combobox section to store its unique id */
2416
- const SectionContext = /*#__PURE__*/React__default.createContext({
2417
- sectionId: ''
2418
- });
2419
-
2420
- /** Retrieve the current combobox state and actions */
2421
- const useCombobox = () => {
2422
- const comboboxContext = React__default.useContext(ComboboxContext);
2423
- const {
2424
- dispatch: movingFocusDispatch
2425
- } = React__default.useContext(MovingFocusContext);
2426
- const {
2427
- onSelect,
2428
- onInputChange,
2429
- onOpen,
2430
- dispatch,
2431
- inputValue,
2432
- ...contextValues
2433
- } = comboboxContext;
2434
- const {
2435
- triggerRef
2436
- } = useComboboxRefs();
2437
-
2438
- /** Action triggered when the listBox is closed without selecting any option */
2439
- const handleClose = React__default.useCallback(() => {
2440
- dispatch({
2441
- type: 'CLOSE_COMBOBOX'
2442
- });
2443
- // Reset visual focus
2444
- movingFocusDispatch({
2445
- type: 'RESET_SELECTED_TAB_STOP'
2446
- });
2447
- }, [dispatch, movingFocusDispatch]);
2448
-
2449
- // Handle callbacks on options mounted
2450
- const [optionsMountedCallbacks, setOptionsMountedCallback] = React__default.useState();
2451
- React__default.useEffect(() => {
2452
- if (comboboxContext.optionsLength > 0 && optionsMountedCallbacks?.length) {
2453
- const optionsArray = Object.values(comboboxContext.options);
2454
- // Execute callbacks
2455
- for (const callback of optionsMountedCallbacks) {
2456
- callback(optionsArray);
2457
- }
2458
- setOptionsMountedCallback(undefined);
2459
- }
2460
- }, [comboboxContext.options, comboboxContext.optionsLength, optionsMountedCallbacks]);
2461
-
2462
- /** Callback for when an option is selected */
2463
- const handleSelected = React__default.useCallback((option, source) => {
2464
- if (option?.isDisabled) {
2465
- return;
2466
- }
2467
- if (isComboboxValue(option)) {
2468
- /**
2469
- * We only close the list if the selection type is single.
2470
- * If it is multiple, we want to allow the user to continue
2471
- * selecting multiple options.
2472
- */
2473
- if (comboboxContext.selectionType !== 'multiple') {
2474
- handleClose();
2475
- }
2476
- /** Call parent onSelect callback */
2477
- if (onSelect) {
2478
- onSelect(option);
2479
- }
2480
- }
2481
-
2482
- /** If the option itself has a custom action, also call it */
2483
- if (option?.onSelect) {
2484
- option.onSelect(option, source);
2485
- }
2486
-
2487
- /** Reset focus on input */
2488
- if (triggerRef?.current) {
2489
- triggerRef.current?.focus();
2490
- }
2491
- }, [comboboxContext.selectionType, handleClose, onSelect, triggerRef]);
2492
-
2493
- /** Callback for when the input must be updated */
2494
- const handleInputChange = React__default.useCallback((value, ...args) => {
2495
- // Update the local state
2496
- dispatch({
2497
- type: 'SET_INPUT_VALUE',
2498
- payload: value
2499
- });
2500
- // If a callback if given, call it with the value
2501
- if (onInputChange) {
2502
- onInputChange(value, ...args);
2503
- }
2504
- // Reset visual focus
2505
- movingFocusDispatch({
2506
- type: 'RESET_SELECTED_TAB_STOP'
2507
- });
2508
- }, [dispatch, movingFocusDispatch, onInputChange]);
2509
-
2510
- /**
2511
- * Open the popover
2512
- *
2513
- * @returns a promise with the updated context once all options are mounted
2514
- */
2515
- const handleOpen = React__default.useCallback(params => {
2516
- /** update the local state */
2517
- dispatch({
2518
- type: 'OPEN_COMBOBOX',
2519
- payload: params
2520
- });
2521
- /** If a parent callback was given, trigger it with state information */
2522
- if (onOpen) {
2523
- onOpen({
2524
- currentValue: inputValue,
2525
- manual: Boolean(params?.manual)
2526
- });
2527
- }
2528
-
2529
- // Promise resolving options on mount
2530
- return new Promise(resolve => {
2531
- // Append to the list of callback on options mounted
2532
- setOptionsMountedCallback((callbacks = []) => {
2533
- callbacks.push(resolve);
2534
- return callbacks;
2535
- });
2536
- });
2537
- }, [dispatch, inputValue, onOpen]);
2538
- return React__default.useMemo(() => ({
2539
- handleClose,
2540
- handleOpen,
2541
- handleInputChange,
2542
- handleSelected,
2543
- dispatch,
2544
- inputValue,
2545
- ...contextValues
2546
- }), [contextValues, dispatch, handleClose, handleInputChange, handleOpen, handleSelected, inputValue]);
2547
- };
2548
-
2549
2224
  /**
2550
2225
  * Provide props for the semantic and behaviors the combobox trigger.
2551
2226
  *
@@ -2889,12 +2564,12 @@ const ComboboxButton = forwardRef((props, ref) => {
2889
2564
  });
2890
2565
  });
2891
2566
 
2892
- const CLASSNAME$18 = 'lumx-combobox-divider';
2567
+ const CLASSNAME$17 = 'lumx-combobox-divider';
2893
2568
 
2894
2569
  /** Combobox option divider */
2895
2570
  function ComboboxDivider() {
2896
2571
  return /*#__PURE__*/jsx(ListDivider, {
2897
- className: CLASSNAME$18,
2572
+ className: CLASSNAME$17,
2898
2573
  role: "presentation"
2899
2574
  });
2900
2575
  }
@@ -3094,12 +2769,12 @@ const useRegisterOption = (registerId, option, shouldRegister) => {
3094
2769
  };
3095
2770
 
3096
2771
  /* eslint-disable jsx-a11y/click-events-have-key-events */
3097
- const CLASSNAME$17 = 'lumx-combobox-option';
2772
+ const COMBOBOX_OPTION_CLASSNAME = 'lumx-combobox-option';
3098
2773
  const LUMX_CLASSNAME = 'lumx-list-item';
3099
2774
  const {
3100
2775
  block: block$_,
3101
2776
  element: element$M
3102
- } = classNames.bem(CLASSNAME$17);
2777
+ } = classNames.bem(COMBOBOX_OPTION_CLASSNAME);
3103
2778
  const lumxListItem = classNames.bem(LUMX_CLASSNAME);
3104
2779
 
3105
2780
  /**
@@ -3298,7 +2973,7 @@ const defaultWidths = [REAL_SIZE_FOR_LUMX_SIZE.xxl, REAL_SIZE_FOR_LUMX_SIZE.xl,
3298
2973
  const {
3299
2974
  block: block$Z,
3300
2975
  element: element$L
3301
- } = classNames.bem(CLASSNAME$17);
2976
+ } = classNames.bem(COMBOBOX_OPTION_CLASSNAME);
3302
2977
 
3303
2978
  /**
3304
2979
  * Skeleton for a combobox option.
@@ -17002,5 +16677,5 @@ UserBlock.displayName = COMPONENT_NAME;
17002
16677
  UserBlock.className = CLASSNAME;
17003
16678
  UserBlock.defaultProps = DEFAULT_PROPS;
17004
16679
 
17005
- export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonGroup, COMPONENT_NAME$1e as COMPONENT_NAME, Checkbox, Chip, ChipGroup, Combobox, ComboboxButton, ComboboxDivider, ComboboxInput, ComboboxListBox, ComboboxOption, ComboboxOptionAction, ComboboxOptionMoreInfo, ComboboxOptionSkeleton, ComboboxSection, CommentBlock, CommentBlockVariant, DEFAULT_PROPS$16 as DEFAULT_PROPS, DatePicker, DatePickerControlled, DatePickerField, Dialog, Divider, DragHandle, Dropdown, ExpansionPanel, Flag, FlexBox, GenericBlock, GenericBlockGapSize, Grid, GridColumn, GridItem, Heading, HeadingLevelProvider, Icon, IconButton, ImageBlock, ImageBlockCaptionPosition, ImageLightbox, InlineList, InputHelper, InputLabel, LUMX_CLASSNAME, Lightbox, Link, LinkPreview, List, ListDivider, ListItem, ListSubheader, Message, Mosaic, Navigation, Notification, Placement, Popover, PopoverDialog, PostBlock, Progress, ProgressCircular, ProgressLinear, ProgressTracker, ProgressTrackerProvider, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressVariant, RadioButton, RadioGroup, RawInputText, RawInputTextarea, SUB_COMPONENTS, Select, SelectMultiple, SelectMultipleField, SelectVariant, SelectionChipGroup, SideNavigation, SideNavigationItem, SkeletonCircle, SkeletonRectangle, SkeletonRectangleVariant, SkeletonTypography, Slider, Slides, Slideshow, SlideshowControls, SlideshowItem, Switch, Tab, TabList, TabListLayout, TabPanel, TabProvider, Table, TableBody, TableCell, TableCellVariant, TableHeader, TableRow, Text, TextField, ThOrder, ThemeProvider, Thumbnail, ThumbnailAspectRatio, ThumbnailObjectFit, ThumbnailVariant, Toolbar, Tooltip, Uploader, UploaderVariant, UserBlock, clamp, isClickable, useFocusPointStyle, useHeadingLevel, useTheme };
16680
+ export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonGroup, CLASSNAME$1h as CLASSNAME, COMBOBOX_OPTION_CLASSNAME, COMPONENT_NAME$1e as COMPONENT_NAME, Checkbox, Chip, ChipGroup, Combobox, ComboboxButton, ComboboxDivider, ComboboxInput, ComboboxListBox, ComboboxOption, ComboboxOptionAction, ComboboxOptionMoreInfo, ComboboxOptionSkeleton, ComboboxSection, CommentBlock, CommentBlockVariant, DEFAULT_PROPS$16 as DEFAULT_PROPS, DatePicker, DatePickerControlled, DatePickerField, Dialog, Divider, DragHandle, Dropdown, ExpansionPanel, Flag, FlexBox, GenericBlock, GenericBlockGapSize, Grid, GridColumn, GridItem, Heading, HeadingLevelProvider, Icon, IconButton, ImageBlock, ImageBlockCaptionPosition, ImageLightbox, InlineList, InputHelper, InputLabel, LUMX_CLASSNAME, Lightbox, Link, LinkPreview, List, ListDivider, ListItem, ListSubheader, Message, Mosaic, Navigation, Notification, Placement, Popover, PopoverDialog, PostBlock, Progress, ProgressCircular, ProgressLinear, ProgressTracker, ProgressTrackerProvider, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressVariant, RadioButton, RadioGroup, RawInputText, RawInputTextarea, SUB_COMPONENTS, Select, SelectMultiple, SelectMultipleField, SelectVariant, SelectionChipGroup, SideNavigation, SideNavigationItem, SkeletonCircle, SkeletonRectangle, SkeletonRectangleVariant, SkeletonTypography, Slider, Slides, Slideshow, SlideshowControls, SlideshowItem, Switch, Tab, TabList, TabListLayout, TabPanel, TabProvider, Table, TableBody, TableCell, TableCellVariant, TableHeader, TableRow, Text, TextField, ThOrder, ThemeProvider, Thumbnail, ThumbnailAspectRatio, ThumbnailObjectFit, ThumbnailVariant, Toolbar, Tooltip, Uploader, UploaderVariant, UserBlock, clamp, isClickable, useFocusPointStyle, useHeadingLevel, useTheme };
17006
16681
  //# sourceMappingURL=index.js.map