@lumx/react 4.3.2-alpha.5 → 4.3.2-alpha.7
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/_internal/BcRzrT9Y.js +1480 -0
- package/_internal/BcRzrT9Y.js.map +1 -0
- package/index.d.ts +521 -19
- package/index.js +2027 -329
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/utils/index.js +3 -1322
- package/utils/index.js.map +1 -1
- package/_internal/DpdvhbTO.js +0 -159
- package/_internal/DpdvhbTO.js.map +0 -1
package/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Kind as Kind$1, Size as Size$1, ColorPalette as ColorPalette$1, Emphasis as Emphasis$1, Theme as Theme$1, AspectRatio as AspectRatio$1, ColorVariant, DIALOG_TRANSITION_DURATION, Orientation as Orientation$1, Alignment, NOTIFICATION_TRANSITION_DURATION, TOOLTIP_LONG_PRESS_DELAY, TOOLTIP_HOVER_DELAY } from '@lumx/core/js/constants
|
|
2
|
-
export * from '@lumx/core/js/constants
|
|
3
|
-
export * from '@lumx/core/js/types
|
|
1
|
+
import { Kind as Kind$1, Size as Size$1, ColorPalette as ColorPalette$1, Emphasis as Emphasis$1, Theme as Theme$1, AspectRatio as AspectRatio$1, ColorVariant, REAL_SIZE_FOR_LUMX_SIZE, DIALOG_TRANSITION_DURATION, Orientation as Orientation$1, Alignment, NOTIFICATION_TRANSITION_DURATION, TOOLTIP_LONG_PRESS_DELAY, TOOLTIP_HOVER_DELAY } from '@lumx/core/js/constants';
|
|
2
|
+
export * from '@lumx/core/js/constants';
|
|
3
|
+
export * from '@lumx/core/js/types';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, { useState, useEffect, useMemo, useRef, useCallback,
|
|
6
|
-
import { mdiAlert } from '@lumx/icons/esm/alert
|
|
7
|
-
import { mdiAlertCircle } from '@lumx/icons/esm/alert-circle
|
|
8
|
-
import { mdiCheckCircle } from '@lumx/icons/esm/check-circle
|
|
9
|
-
import { mdiInformation } from '@lumx/icons/esm/information
|
|
10
|
-
import { classNames, onEnterPressed, onEscapePressed, onButtonPressed, detectHorizontalSwipe } from '@lumx/core/js/utils
|
|
5
|
+
import React__default, { useState, useEffect, useMemo, useRef, useCallback, useContext, createContext, useReducer, Children, useLayoutEffect, cloneElement, isValidElement } from 'react';
|
|
6
|
+
import { mdiAlert } from '@lumx/icons/esm/alert';
|
|
7
|
+
import { mdiAlertCircle } from '@lumx/icons/esm/alert-circle';
|
|
8
|
+
import { mdiCheckCircle } from '@lumx/icons/esm/check-circle';
|
|
9
|
+
import { mdiInformation } from '@lumx/icons/esm/information';
|
|
10
|
+
import { classNames, onEnterPressed, onEscapePressed, onButtonPressed, detectHorizontalSwipe } from '@lumx/core/js/utils';
|
|
11
11
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
12
12
|
import last from 'lodash/last';
|
|
13
13
|
import pull from 'lodash/pull';
|
|
@@ -16,40 +16,44 @@ 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, P as Portal, C as ClickAwayProvider } from './_internal/
|
|
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';
|
|
20
20
|
import isEmpty from 'lodash/isEmpty';
|
|
21
|
-
import { getDisabledState } from '@lumx/core/js/utils/disabledState
|
|
22
|
-
import { mdiCloseCircle } from '@lumx/icons/esm/close-circle
|
|
21
|
+
import { getDisabledState } from '@lumx/core/js/utils/disabledState';
|
|
22
|
+
import { mdiCloseCircle } from '@lumx/icons/esm/close-circle';
|
|
23
23
|
import memoize from 'lodash/memoize';
|
|
24
|
-
import { mdiClose } from '@lumx/icons/esm/close
|
|
24
|
+
import { mdiClose } from '@lumx/icons/esm/close';
|
|
25
25
|
import isFunction from 'lodash/isFunction';
|
|
26
|
-
import { mdiImageBroken } from '@lumx/icons/esm/image-broken
|
|
27
|
-
import { mdiCheck } from '@lumx/icons/esm/check
|
|
28
|
-
import { mdiMinus } from '@lumx/icons/esm/minus
|
|
29
|
-
import {
|
|
30
|
-
import { mdiChevronRight } from '@lumx/icons/esm/chevron-right.js';
|
|
31
|
-
import castArray from 'lodash/castArray';
|
|
32
|
-
import { mdiDragVertical } from '@lumx/icons/esm/drag-vertical.js';
|
|
33
|
-
import { mdiChevronDown } from '@lumx/icons/esm/chevron-down.js';
|
|
34
|
-
import { mdiChevronUp } from '@lumx/icons/esm/chevron-up.js';
|
|
26
|
+
import { mdiImageBroken } from '@lumx/icons/esm/image-broken';
|
|
27
|
+
import { mdiCheck } from '@lumx/icons/esm/check';
|
|
28
|
+
import { mdiMinus } from '@lumx/icons/esm/minus';
|
|
29
|
+
import { visuallyHidden, bem as bem$1 } from '@lumx/core/js/utils/classNames';
|
|
35
30
|
import noop from 'lodash/noop';
|
|
31
|
+
import uniqueId from 'lodash/uniqueId';
|
|
32
|
+
import debounce$1 from 'lodash/debounce';
|
|
33
|
+
import { mdiChevronDown } from '@lumx/icons/esm/chevron-down';
|
|
34
|
+
import { mdiChevronUp } from '@lumx/icons/esm/chevron-up';
|
|
35
|
+
import castArray from 'lodash/castArray';
|
|
36
|
+
import { mdiInformationOutline } from '@lumx/icons/esm/information-outline';
|
|
37
|
+
import { mdiChevronLeft } from '@lumx/icons/esm/chevron-left';
|
|
38
|
+
import { mdiChevronRight } from '@lumx/icons/esm/chevron-right';
|
|
39
|
+
import { mdiDragVertical } from '@lumx/icons/esm/drag-vertical';
|
|
36
40
|
import pick from 'lodash/pick';
|
|
37
41
|
import isInteger from 'lodash/isInteger';
|
|
38
|
-
import { mdiMagnifyMinusOutline } from '@lumx/icons/esm/magnify-minus-outline
|
|
39
|
-
import { mdiMagnifyPlusOutline } from '@lumx/icons/esm/magnify-plus-outline
|
|
42
|
+
import { mdiMagnifyMinusOutline } from '@lumx/icons/esm/magnify-minus-outline';
|
|
43
|
+
import { mdiMagnifyPlusOutline } from '@lumx/icons/esm/magnify-plus-outline';
|
|
40
44
|
import throttle from 'lodash/throttle';
|
|
41
45
|
import range from 'lodash/range';
|
|
42
|
-
import { mdiPlayCircleOutline } from '@lumx/icons/esm/play-circle-outline
|
|
43
|
-
import { mdiPauseCircleOutline } from '@lumx/icons/esm/pause-circle-outline
|
|
46
|
+
import { mdiPlayCircleOutline } from '@lumx/icons/esm/play-circle-outline';
|
|
47
|
+
import { mdiPauseCircleOutline } from '@lumx/icons/esm/pause-circle-outline';
|
|
44
48
|
import chunk from 'lodash/chunk';
|
|
45
49
|
import ReactDOM from 'react-dom';
|
|
46
50
|
import take from 'lodash/take';
|
|
47
|
-
import { mdiRadioboxBlank } from '@lumx/icons/esm/radiobox-blank
|
|
48
|
-
import { mdiRadioboxMarked } from '@lumx/icons/esm/radiobox-marked
|
|
49
|
-
import { mdiMenuDown } from '@lumx/icons/esm/menu-down
|
|
50
|
-
import { getWithSelector } from '@lumx/core/js/utils/selectors/getWithSelector
|
|
51
|
-
import { mdiArrowDown } from '@lumx/icons/esm/arrow-down
|
|
52
|
-
import { mdiArrowUp } from '@lumx/icons/esm/arrow-up
|
|
51
|
+
import { mdiRadioboxBlank } from '@lumx/icons/esm/radiobox-blank';
|
|
52
|
+
import { mdiRadioboxMarked } from '@lumx/icons/esm/radiobox-marked';
|
|
53
|
+
import { mdiMenuDown } from '@lumx/icons/esm/menu-down';
|
|
54
|
+
import { getWithSelector } from '@lumx/core/js/utils/selectors/getWithSelector';
|
|
55
|
+
import { mdiArrowDown } from '@lumx/icons/esm/arrow-down';
|
|
56
|
+
import { mdiArrowUp } from '@lumx/icons/esm/arrow-up';
|
|
53
57
|
import set from 'lodash/set';
|
|
54
58
|
|
|
55
59
|
let i = 0;
|
|
@@ -101,15 +105,15 @@ const COMPONENT_NAME$1l = 'AlertDialog';
|
|
|
101
105
|
/**
|
|
102
106
|
* Component default class name and class prefix.
|
|
103
107
|
*/
|
|
104
|
-
const CLASSNAME$
|
|
108
|
+
const CLASSNAME$1o = 'lumx-alert-dialog';
|
|
105
109
|
const {
|
|
106
|
-
block: block$
|
|
107
|
-
} = classNames.bem(CLASSNAME$
|
|
110
|
+
block: block$19
|
|
111
|
+
} = classNames.bem(CLASSNAME$1o);
|
|
108
112
|
|
|
109
113
|
/**
|
|
110
114
|
* Component default props.
|
|
111
115
|
*/
|
|
112
|
-
const DEFAULT_PROPS$
|
|
116
|
+
const DEFAULT_PROPS$1b = {
|
|
113
117
|
size: Size$1.tiny,
|
|
114
118
|
kind: Kind$1.info
|
|
115
119
|
};
|
|
@@ -130,8 +134,8 @@ const AlertDialog = forwardRef((props, ref) => {
|
|
|
130
134
|
className,
|
|
131
135
|
cancelProps,
|
|
132
136
|
confirmProps,
|
|
133
|
-
kind = DEFAULT_PROPS$
|
|
134
|
-
size = DEFAULT_PROPS$
|
|
137
|
+
kind = DEFAULT_PROPS$1b.kind,
|
|
138
|
+
size = DEFAULT_PROPS$1b.size,
|
|
135
139
|
dialogProps,
|
|
136
140
|
children,
|
|
137
141
|
...forwardedProps
|
|
@@ -172,7 +176,7 @@ const AlertDialog = forwardRef((props, ref) => {
|
|
|
172
176
|
'aria-describedby': descriptionId,
|
|
173
177
|
...dialogProps
|
|
174
178
|
},
|
|
175
|
-
className: classNames.join(className, block$
|
|
179
|
+
className: classNames.join(className, block$19({
|
|
176
180
|
[`kind-${kind}`]: Boolean(kind)
|
|
177
181
|
})),
|
|
178
182
|
...forwardedProps,
|
|
@@ -218,8 +222,8 @@ const AlertDialog = forwardRef((props, ref) => {
|
|
|
218
222
|
});
|
|
219
223
|
});
|
|
220
224
|
AlertDialog.displayName = COMPONENT_NAME$1l;
|
|
221
|
-
AlertDialog.className = CLASSNAME$
|
|
222
|
-
AlertDialog.defaultProps = DEFAULT_PROPS$
|
|
225
|
+
AlertDialog.className = CLASSNAME$1o;
|
|
226
|
+
AlertDialog.defaultProps = DEFAULT_PROPS$1b;
|
|
223
227
|
|
|
224
228
|
/**
|
|
225
229
|
* Hook focusing an element when defined and `focus` boolean `true`.
|
|
@@ -316,12 +320,12 @@ const COMPONENT_NAME$1k = 'Autocomplete';
|
|
|
316
320
|
/**
|
|
317
321
|
* Component default class name and class prefix.
|
|
318
322
|
*/
|
|
319
|
-
const CLASSNAME$
|
|
323
|
+
const CLASSNAME$1n = 'lumx-autocomplete';
|
|
320
324
|
|
|
321
325
|
/**
|
|
322
326
|
* Component default props.
|
|
323
327
|
*/
|
|
324
|
-
const DEFAULT_PROPS$
|
|
328
|
+
const DEFAULT_PROPS$1a = {
|
|
325
329
|
anchorToInput: false,
|
|
326
330
|
closeOnClick: false,
|
|
327
331
|
closeOnClickAway: true,
|
|
@@ -343,13 +347,13 @@ const Autocomplete = forwardRef((props, ref) => {
|
|
|
343
347
|
otherProps
|
|
344
348
|
} = useDisableStateProps(props);
|
|
345
349
|
const {
|
|
346
|
-
anchorToInput = DEFAULT_PROPS$
|
|
350
|
+
anchorToInput = DEFAULT_PROPS$1a.anchorToInput,
|
|
347
351
|
children,
|
|
348
352
|
chips,
|
|
349
353
|
className,
|
|
350
|
-
closeOnClick = DEFAULT_PROPS$
|
|
351
|
-
closeOnClickAway = DEFAULT_PROPS$
|
|
352
|
-
closeOnEscape = DEFAULT_PROPS$
|
|
354
|
+
closeOnClick = DEFAULT_PROPS$1a.closeOnClick,
|
|
355
|
+
closeOnClickAway = DEFAULT_PROPS$1a.closeOnClickAway,
|
|
356
|
+
closeOnEscape = DEFAULT_PROPS$1a.closeOnEscape,
|
|
353
357
|
error,
|
|
354
358
|
fitToAnchorWidth,
|
|
355
359
|
hasError,
|
|
@@ -370,7 +374,7 @@ const Autocomplete = forwardRef((props, ref) => {
|
|
|
370
374
|
onInfiniteScroll,
|
|
371
375
|
placeholder,
|
|
372
376
|
placement,
|
|
373
|
-
shouldFocusOnClose = DEFAULT_PROPS$
|
|
377
|
+
shouldFocusOnClose = DEFAULT_PROPS$1a.shouldFocusOnClose,
|
|
374
378
|
theme = defaultTheme,
|
|
375
379
|
value,
|
|
376
380
|
textFieldProps = {},
|
|
@@ -383,7 +387,7 @@ const Autocomplete = forwardRef((props, ref) => {
|
|
|
383
387
|
return /*#__PURE__*/jsxs("div", {
|
|
384
388
|
ref: ref,
|
|
385
389
|
...forwardedProps,
|
|
386
|
-
className: classNames.join(className, CLASSNAME$
|
|
390
|
+
className: classNames.join(className, CLASSNAME$1n),
|
|
387
391
|
children: [/*#__PURE__*/jsx(TextField, {
|
|
388
392
|
...textFieldProps,
|
|
389
393
|
chips: chips,
|
|
@@ -424,8 +428,8 @@ const Autocomplete = forwardRef((props, ref) => {
|
|
|
424
428
|
});
|
|
425
429
|
});
|
|
426
430
|
Autocomplete.displayName = COMPONENT_NAME$1k;
|
|
427
|
-
Autocomplete.className = CLASSNAME$
|
|
428
|
-
Autocomplete.defaultProps = DEFAULT_PROPS$
|
|
431
|
+
Autocomplete.className = CLASSNAME$1n;
|
|
432
|
+
Autocomplete.defaultProps = DEFAULT_PROPS$1a;
|
|
429
433
|
|
|
430
434
|
/**
|
|
431
435
|
* Component display name.
|
|
@@ -435,12 +439,12 @@ const COMPONENT_NAME$1j = 'AutocompleteMultiple';
|
|
|
435
439
|
/**
|
|
436
440
|
* Component default class name and class prefix.
|
|
437
441
|
*/
|
|
438
|
-
const CLASSNAME$
|
|
442
|
+
const CLASSNAME$1m = 'lumx-autocomplete-multiple';
|
|
439
443
|
|
|
440
444
|
/**
|
|
441
445
|
* Component default props.
|
|
442
446
|
*/
|
|
443
|
-
const DEFAULT_PROPS$
|
|
447
|
+
const DEFAULT_PROPS$19 = {
|
|
444
448
|
closeOnClickAway: true,
|
|
445
449
|
closeOnEscape: true,
|
|
446
450
|
selectedChipRender(choice, index, onClear, isDisabled) {
|
|
@@ -480,8 +484,8 @@ const AutocompleteMultiple = forwardRef((props, ref) => {
|
|
|
480
484
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
481
485
|
chipsAlignment,
|
|
482
486
|
className,
|
|
483
|
-
closeOnClickAway = DEFAULT_PROPS$
|
|
484
|
-
closeOnEscape = DEFAULT_PROPS$
|
|
487
|
+
closeOnClickAway = DEFAULT_PROPS$19.closeOnClickAway,
|
|
488
|
+
closeOnEscape = DEFAULT_PROPS$19.closeOnEscape,
|
|
485
489
|
fitToAnchorWidth,
|
|
486
490
|
hasError,
|
|
487
491
|
helper,
|
|
@@ -503,19 +507,19 @@ const AutocompleteMultiple = forwardRef((props, ref) => {
|
|
|
503
507
|
onKeyDown,
|
|
504
508
|
placeholder,
|
|
505
509
|
placement,
|
|
506
|
-
selectedChipRender = DEFAULT_PROPS$
|
|
510
|
+
selectedChipRender = DEFAULT_PROPS$19.selectedChipRender,
|
|
507
511
|
shouldFocusOnClose,
|
|
508
512
|
theme = defaultTheme,
|
|
509
513
|
type,
|
|
510
514
|
value,
|
|
511
|
-
values = DEFAULT_PROPS$
|
|
515
|
+
values = DEFAULT_PROPS$19.values,
|
|
512
516
|
...forwardedProps
|
|
513
517
|
} = otherProps;
|
|
514
518
|
return /*#__PURE__*/jsx(Autocomplete, {
|
|
515
519
|
ref: ref,
|
|
516
520
|
...forwardedProps,
|
|
517
521
|
anchorToInput: anchorToInput,
|
|
518
|
-
className: classNames.join(className, CLASSNAME$
|
|
522
|
+
className: classNames.join(className, CLASSNAME$1m),
|
|
519
523
|
name: name,
|
|
520
524
|
value: value,
|
|
521
525
|
onChange: onChange,
|
|
@@ -549,8 +553,8 @@ const AutocompleteMultiple = forwardRef((props, ref) => {
|
|
|
549
553
|
});
|
|
550
554
|
});
|
|
551
555
|
AutocompleteMultiple.displayName = COMPONENT_NAME$1j;
|
|
552
|
-
AutocompleteMultiple.className = CLASSNAME$
|
|
553
|
-
AutocompleteMultiple.defaultProps = DEFAULT_PROPS$
|
|
556
|
+
AutocompleteMultiple.className = CLASSNAME$1m;
|
|
557
|
+
AutocompleteMultiple.defaultProps = DEFAULT_PROPS$19;
|
|
554
558
|
|
|
555
559
|
/**
|
|
556
560
|
* Component display name.
|
|
@@ -560,16 +564,16 @@ const COMPONENT_NAME$1i = 'Avatar';
|
|
|
560
564
|
/**
|
|
561
565
|
* Component default class name and class prefix.
|
|
562
566
|
*/
|
|
563
|
-
const CLASSNAME$
|
|
567
|
+
const CLASSNAME$1l = 'lumx-avatar';
|
|
564
568
|
const {
|
|
565
|
-
block: block$
|
|
566
|
-
element: element$
|
|
567
|
-
} = classNames.bem(CLASSNAME$
|
|
569
|
+
block: block$18,
|
|
570
|
+
element: element$S
|
|
571
|
+
} = classNames.bem(CLASSNAME$1l);
|
|
568
572
|
|
|
569
573
|
/**
|
|
570
574
|
* Component default props.
|
|
571
575
|
*/
|
|
572
|
-
const DEFAULT_PROPS$
|
|
576
|
+
const DEFAULT_PROPS$18 = {
|
|
573
577
|
size: Size$1.m
|
|
574
578
|
};
|
|
575
579
|
|
|
@@ -592,7 +596,7 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
592
596
|
linkAs,
|
|
593
597
|
onClick,
|
|
594
598
|
onKeyPress,
|
|
595
|
-
size = DEFAULT_PROPS$
|
|
599
|
+
size = DEFAULT_PROPS$18.size,
|
|
596
600
|
theme = defaultTheme,
|
|
597
601
|
thumbnailProps,
|
|
598
602
|
...forwardedProps
|
|
@@ -600,14 +604,14 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
600
604
|
return /*#__PURE__*/jsxs("div", {
|
|
601
605
|
ref: ref,
|
|
602
606
|
...forwardedProps,
|
|
603
|
-
className: classNames.join(className, block$
|
|
607
|
+
className: classNames.join(className, block$18({
|
|
604
608
|
[`size-${size}`]: Boolean(size),
|
|
605
609
|
[`theme-${theme}`]: Boolean(theme)
|
|
606
610
|
})),
|
|
607
611
|
children: [/*#__PURE__*/jsx(Thumbnail, {
|
|
608
612
|
linkProps: linkProps,
|
|
609
613
|
linkAs: linkAs,
|
|
610
|
-
className: element$
|
|
614
|
+
className: element$S('thumbnail'),
|
|
611
615
|
onClick: onClick,
|
|
612
616
|
onKeyPress: onKeyPress,
|
|
613
617
|
...thumbnailProps,
|
|
@@ -617,17 +621,17 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
617
621
|
alt: alt,
|
|
618
622
|
theme: theme
|
|
619
623
|
}), actions && /*#__PURE__*/jsx("div", {
|
|
620
|
-
className: element$
|
|
624
|
+
className: element$S('actions'),
|
|
621
625
|
children: actions
|
|
622
626
|
}), badge && /*#__PURE__*/jsx("div", {
|
|
623
|
-
className: element$
|
|
627
|
+
className: element$S('badge'),
|
|
624
628
|
children: badge
|
|
625
629
|
})]
|
|
626
630
|
});
|
|
627
631
|
});
|
|
628
632
|
Avatar.displayName = COMPONENT_NAME$1i;
|
|
629
|
-
Avatar.className = CLASSNAME$
|
|
630
|
-
Avatar.defaultProps = DEFAULT_PROPS$
|
|
633
|
+
Avatar.className = CLASSNAME$1l;
|
|
634
|
+
Avatar.defaultProps = DEFAULT_PROPS$18;
|
|
631
635
|
|
|
632
636
|
/**
|
|
633
637
|
* Alignments.
|
|
@@ -695,8 +699,6 @@ const ColorPalette = {
|
|
|
695
699
|
red: 'red',
|
|
696
700
|
light: 'light'};
|
|
697
701
|
|
|
698
|
-
/** ColorPalette with all possible color variant combination */
|
|
699
|
-
|
|
700
702
|
function getDefaultExportFromCjs (x) {
|
|
701
703
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
702
704
|
}
|
|
@@ -857,7 +859,7 @@ function modifier$1(baseName, modifiers) {
|
|
|
857
859
|
* block('button', { active: true, disabled: false }); // 'button button--active'
|
|
858
860
|
*/
|
|
859
861
|
|
|
860
|
-
function block$
|
|
862
|
+
function block$17(baseName, modifiersOrAdditionalClasses, additionalClasses) {
|
|
861
863
|
let modifiers;
|
|
862
864
|
let classes;
|
|
863
865
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
@@ -892,11 +894,11 @@ function block$12(baseName, modifiersOrAdditionalClasses, additionalClasses) {
|
|
|
892
894
|
* element('my-button', 'icon', { active: true }); // 'my-button__icon my-button__icon--active'
|
|
893
895
|
*/
|
|
894
896
|
|
|
895
|
-
function element$
|
|
897
|
+
function element$R(baseClass, elem, modifiersOrAdditionalClasses, additionalClasses) {
|
|
896
898
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
897
|
-
return block$
|
|
899
|
+
return block$17(`${baseClass}__${elem}`, modifiersOrAdditionalClasses);
|
|
898
900
|
}
|
|
899
|
-
return block$
|
|
901
|
+
return block$17(`${baseClass}__${elem}`, modifiersOrAdditionalClasses, additionalClasses);
|
|
900
902
|
}
|
|
901
903
|
|
|
902
904
|
/**
|
|
@@ -905,15 +907,15 @@ function element$M(baseClass, elem, modifiersOrAdditionalClasses, additionalClas
|
|
|
905
907
|
function bem(baseName) {
|
|
906
908
|
function blockFn(modifiersOrAdditionalClasses, additionalClasses) {
|
|
907
909
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
908
|
-
return block$
|
|
910
|
+
return block$17(baseName, modifiersOrAdditionalClasses);
|
|
909
911
|
}
|
|
910
|
-
return block$
|
|
912
|
+
return block$17(baseName, modifiersOrAdditionalClasses, additionalClasses);
|
|
911
913
|
}
|
|
912
914
|
function elementFn(elem, modifiersOrAdditionalClasses, additionalClasses) {
|
|
913
915
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
914
|
-
return element$
|
|
916
|
+
return element$R(baseName, elem, modifiersOrAdditionalClasses);
|
|
915
917
|
}
|
|
916
|
-
return element$
|
|
918
|
+
return element$R(baseName, elem, modifiersOrAdditionalClasses, additionalClasses);
|
|
917
919
|
}
|
|
918
920
|
return {
|
|
919
921
|
block: blockFn,
|
|
@@ -930,15 +932,15 @@ const COMPONENT_NAME$1h = 'Badge';
|
|
|
930
932
|
/**
|
|
931
933
|
* Component default class name and class prefix.
|
|
932
934
|
*/
|
|
933
|
-
const CLASSNAME$
|
|
935
|
+
const CLASSNAME$1k = 'lumx-badge';
|
|
934
936
|
const {
|
|
935
|
-
block: block$
|
|
936
|
-
} = bem(CLASSNAME$
|
|
937
|
+
block: block$16
|
|
938
|
+
} = bem(CLASSNAME$1k);
|
|
937
939
|
|
|
938
940
|
/**
|
|
939
941
|
* Component default props.
|
|
940
942
|
*/
|
|
941
|
-
const DEFAULT_PROPS$
|
|
943
|
+
const DEFAULT_PROPS$17 = {
|
|
942
944
|
color: ColorPalette.primary
|
|
943
945
|
};
|
|
944
946
|
|
|
@@ -952,22 +954,22 @@ const Badge$1 = props => {
|
|
|
952
954
|
const {
|
|
953
955
|
children,
|
|
954
956
|
className,
|
|
955
|
-
color = DEFAULT_PROPS$
|
|
957
|
+
color = DEFAULT_PROPS$17.color,
|
|
956
958
|
ref,
|
|
957
959
|
...forwardedProps
|
|
958
960
|
} = props;
|
|
959
961
|
return /*#__PURE__*/jsx("div", {
|
|
960
962
|
ref: ref,
|
|
961
963
|
...forwardedProps,
|
|
962
|
-
className: classnames(className, block$
|
|
964
|
+
className: classnames(className, block$16({
|
|
963
965
|
[`color-${color}`]: Boolean(color)
|
|
964
966
|
})),
|
|
965
967
|
children: children
|
|
966
968
|
});
|
|
967
969
|
};
|
|
968
970
|
Badge$1.displayName = COMPONENT_NAME$1h;
|
|
969
|
-
Badge$1.className = CLASSNAME$
|
|
970
|
-
Badge$1.defaultProps = DEFAULT_PROPS$
|
|
971
|
+
Badge$1.className = CLASSNAME$1k;
|
|
972
|
+
Badge$1.defaultProps = DEFAULT_PROPS$17;
|
|
971
973
|
|
|
972
974
|
/**
|
|
973
975
|
* Defines the props of the component.
|
|
@@ -991,11 +993,11 @@ Badge.className = Badge$1.className;
|
|
|
991
993
|
Badge.defaultProps = Badge$1.defaultProps;
|
|
992
994
|
|
|
993
995
|
const COMPONENT_NAME$1g = 'BadgeWrapper';
|
|
994
|
-
const CLASSNAME$
|
|
996
|
+
const CLASSNAME$1j = 'lumx-badge-wrapper';
|
|
995
997
|
const {
|
|
996
|
-
block: block$
|
|
997
|
-
element: element$
|
|
998
|
-
} = bem(CLASSNAME$
|
|
998
|
+
block: block$15,
|
|
999
|
+
element: element$Q
|
|
1000
|
+
} = bem(CLASSNAME$1j);
|
|
999
1001
|
const BadgeWrapper$1 = props => {
|
|
1000
1002
|
const {
|
|
1001
1003
|
badge,
|
|
@@ -1007,9 +1009,9 @@ const BadgeWrapper$1 = props => {
|
|
|
1007
1009
|
return /*#__PURE__*/jsxs("div", {
|
|
1008
1010
|
ref: ref,
|
|
1009
1011
|
...forwardedProps,
|
|
1010
|
-
className: classnames(className, block$
|
|
1012
|
+
className: classnames(className, block$15()),
|
|
1011
1013
|
children: [children, badge && /*#__PURE__*/jsx("div", {
|
|
1012
|
-
className: element$
|
|
1014
|
+
className: element$Q('badge'),
|
|
1013
1015
|
children: badge
|
|
1014
1016
|
})]
|
|
1015
1017
|
});
|
|
@@ -1022,7 +1024,7 @@ const BadgeWrapper = forwardRef((props, ref) => {
|
|
|
1022
1024
|
});
|
|
1023
1025
|
});
|
|
1024
1026
|
BadgeWrapper.displayName = COMPONENT_NAME$1g;
|
|
1025
|
-
BadgeWrapper.className = CLASSNAME$
|
|
1027
|
+
BadgeWrapper.className = CLASSNAME$1j;
|
|
1026
1028
|
|
|
1027
1029
|
/**
|
|
1028
1030
|
* Render clickable element (link, button or custom element)
|
|
@@ -1183,15 +1185,15 @@ const COMPONENT_NAME$1e = 'Button';
|
|
|
1183
1185
|
/**
|
|
1184
1186
|
* Component default class name and class prefix.
|
|
1185
1187
|
*/
|
|
1186
|
-
const CLASSNAME$
|
|
1188
|
+
const CLASSNAME$1i = 'lumx-button';
|
|
1187
1189
|
const {
|
|
1188
1190
|
modifier
|
|
1189
|
-
} = bem(CLASSNAME$
|
|
1191
|
+
} = bem(CLASSNAME$1i);
|
|
1190
1192
|
|
|
1191
1193
|
/**
|
|
1192
1194
|
* Component default props.
|
|
1193
1195
|
*/
|
|
1194
|
-
const DEFAULT_PROPS$
|
|
1196
|
+
const DEFAULT_PROPS$16 = {
|
|
1195
1197
|
emphasis: Emphasis.high,
|
|
1196
1198
|
size: Size.m
|
|
1197
1199
|
};
|
|
@@ -1205,10 +1207,10 @@ const DEFAULT_PROPS$15 = {
|
|
|
1205
1207
|
const Button$1 = props => {
|
|
1206
1208
|
const {
|
|
1207
1209
|
className,
|
|
1208
|
-
emphasis = DEFAULT_PROPS$
|
|
1210
|
+
emphasis = DEFAULT_PROPS$16.emphasis,
|
|
1209
1211
|
leftIcon,
|
|
1210
1212
|
rightIcon,
|
|
1211
|
-
size = DEFAULT_PROPS$
|
|
1213
|
+
size = DEFAULT_PROPS$16.size,
|
|
1212
1214
|
...forwardedProps
|
|
1213
1215
|
} = props;
|
|
1214
1216
|
const buttonClassName = classnames(className, modifier({
|
|
@@ -1224,8 +1226,8 @@ const Button$1 = props => {
|
|
|
1224
1226
|
});
|
|
1225
1227
|
};
|
|
1226
1228
|
Button$1.displayName = COMPONENT_NAME$1e;
|
|
1227
|
-
Button$1.className = CLASSNAME$
|
|
1228
|
-
Button$1.defaultProps = DEFAULT_PROPS$
|
|
1229
|
+
Button$1.className = CLASSNAME$1i;
|
|
1230
|
+
Button$1.defaultProps = DEFAULT_PROPS$16;
|
|
1229
1231
|
|
|
1230
1232
|
/**
|
|
1231
1233
|
* Properties of a component to use to determine it's name.
|
|
@@ -1292,8 +1294,8 @@ const Button = forwardRef((props, ref) => {
|
|
|
1292
1294
|
});
|
|
1293
1295
|
});
|
|
1294
1296
|
Button.displayName = COMPONENT_NAME$1e;
|
|
1295
|
-
Button.className = CLASSNAME$
|
|
1296
|
-
Button.defaultProps = DEFAULT_PROPS$
|
|
1297
|
+
Button.className = CLASSNAME$1i;
|
|
1298
|
+
Button.defaultProps = DEFAULT_PROPS$16;
|
|
1297
1299
|
|
|
1298
1300
|
const COMPONENT_NAME$1d = 'Icon';
|
|
1299
1301
|
const IconClassName = 'lumx-icon';
|
|
@@ -1302,15 +1304,15 @@ const IconClassName = 'lumx-icon';
|
|
|
1302
1304
|
* Defines the props of the component.
|
|
1303
1305
|
*/
|
|
1304
1306
|
|
|
1305
|
-
const CLASSNAME$
|
|
1307
|
+
const CLASSNAME$1h = IconClassName;
|
|
1306
1308
|
const {
|
|
1307
|
-
block: block
|
|
1308
|
-
} = bem(CLASSNAME$
|
|
1309
|
+
block: block$14
|
|
1310
|
+
} = bem(CLASSNAME$1h);
|
|
1309
1311
|
|
|
1310
1312
|
/**
|
|
1311
1313
|
* Component default props.
|
|
1312
1314
|
*/
|
|
1313
|
-
const DEFAULT_PROPS$
|
|
1315
|
+
const DEFAULT_PROPS$15 = {};
|
|
1314
1316
|
|
|
1315
1317
|
/**
|
|
1316
1318
|
* Icon component.
|
|
@@ -1359,7 +1361,7 @@ const Icon$1 = props => {
|
|
|
1359
1361
|
return /*#__PURE__*/jsx("i", {
|
|
1360
1362
|
ref: ref,
|
|
1361
1363
|
...forwardedProps,
|
|
1362
|
-
className: classnames(className, block
|
|
1364
|
+
className: classnames(className, block$14({
|
|
1363
1365
|
[`color-${iconColor}`]: Boolean(iconColor),
|
|
1364
1366
|
[`color-variant-${iconColorVariant}`]: Boolean(iconColorVariant),
|
|
1365
1367
|
'has-shape': hasShape,
|
|
@@ -1389,8 +1391,8 @@ const Icon$1 = props => {
|
|
|
1389
1391
|
});
|
|
1390
1392
|
};
|
|
1391
1393
|
Icon$1.displayName = COMPONENT_NAME$1d;
|
|
1392
|
-
Icon$1.className = CLASSNAME$
|
|
1393
|
-
Icon$1.defaultProps = DEFAULT_PROPS$
|
|
1394
|
+
Icon$1.className = CLASSNAME$1h;
|
|
1395
|
+
Icon$1.defaultProps = DEFAULT_PROPS$15;
|
|
1394
1396
|
|
|
1395
1397
|
/**
|
|
1396
1398
|
* Component display name.
|
|
@@ -1400,12 +1402,12 @@ const COMPONENT_NAME$1c = 'IconButton';
|
|
|
1400
1402
|
/**
|
|
1401
1403
|
* Component default class name and class prefix.
|
|
1402
1404
|
*/
|
|
1403
|
-
const CLASSNAME$
|
|
1405
|
+
const CLASSNAME$1g = 'lumx-icon-button';
|
|
1404
1406
|
|
|
1405
1407
|
/**
|
|
1406
1408
|
* Component default props.
|
|
1407
1409
|
*/
|
|
1408
|
-
const DEFAULT_PROPS$
|
|
1410
|
+
const DEFAULT_PROPS$14 = {
|
|
1409
1411
|
emphasis: Emphasis.high,
|
|
1410
1412
|
size: Size.m
|
|
1411
1413
|
};
|
|
@@ -1418,11 +1420,11 @@ const DEFAULT_PROPS$13 = {
|
|
|
1418
1420
|
*/
|
|
1419
1421
|
const IconButton$1 = props => {
|
|
1420
1422
|
const {
|
|
1421
|
-
emphasis = DEFAULT_PROPS$
|
|
1423
|
+
emphasis = DEFAULT_PROPS$14.emphasis,
|
|
1422
1424
|
image,
|
|
1423
1425
|
icon,
|
|
1424
1426
|
label,
|
|
1425
|
-
size = DEFAULT_PROPS$
|
|
1427
|
+
size = DEFAULT_PROPS$14.size,
|
|
1426
1428
|
...forwardedProps
|
|
1427
1429
|
} = props;
|
|
1428
1430
|
const defaultChildren = image ? /*#__PURE__*/jsx("img", {
|
|
@@ -1442,8 +1444,8 @@ const IconButton$1 = props => {
|
|
|
1442
1444
|
});
|
|
1443
1445
|
};
|
|
1444
1446
|
IconButton$1.displayName = COMPONENT_NAME$1c;
|
|
1445
|
-
IconButton$1.className = CLASSNAME$
|
|
1446
|
-
IconButton$1.defaultProps = DEFAULT_PROPS$
|
|
1447
|
+
IconButton$1.className = CLASSNAME$1g;
|
|
1448
|
+
IconButton$1.defaultProps = DEFAULT_PROPS$14;
|
|
1447
1449
|
|
|
1448
1450
|
/**
|
|
1449
1451
|
* IconButton component.
|
|
@@ -1479,8 +1481,8 @@ const IconButton = forwardRef((props, ref) => {
|
|
|
1479
1481
|
});
|
|
1480
1482
|
});
|
|
1481
1483
|
IconButton.displayName = COMPONENT_NAME$1c;
|
|
1482
|
-
IconButton.className = CLASSNAME$
|
|
1483
|
-
IconButton.defaultProps = DEFAULT_PROPS$
|
|
1484
|
+
IconButton.className = CLASSNAME$1g;
|
|
1485
|
+
IconButton.defaultProps = DEFAULT_PROPS$14;
|
|
1484
1486
|
|
|
1485
1487
|
/**
|
|
1486
1488
|
* Component display name.
|
|
@@ -1490,12 +1492,12 @@ const COMPONENT_NAME$1b = 'ButtonGroup';
|
|
|
1490
1492
|
/**
|
|
1491
1493
|
* Component default class name and class prefix.
|
|
1492
1494
|
*/
|
|
1493
|
-
const CLASSNAME$
|
|
1495
|
+
const CLASSNAME$1f = 'lumx-button-group';
|
|
1494
1496
|
|
|
1495
1497
|
/**
|
|
1496
1498
|
* Component default props.
|
|
1497
1499
|
*/
|
|
1498
|
-
const DEFAULT_PROPS$
|
|
1500
|
+
const DEFAULT_PROPS$13 = {};
|
|
1499
1501
|
|
|
1500
1502
|
/**
|
|
1501
1503
|
* ButtonGroup component.
|
|
@@ -1511,13 +1513,13 @@ const ButtonGroup$1 = props => {
|
|
|
1511
1513
|
} = props;
|
|
1512
1514
|
return /*#__PURE__*/jsx("div", {
|
|
1513
1515
|
...forwardedProps,
|
|
1514
|
-
className: classnames(className, CLASSNAME$
|
|
1516
|
+
className: classnames(className, CLASSNAME$1f),
|
|
1515
1517
|
children: children
|
|
1516
1518
|
});
|
|
1517
1519
|
};
|
|
1518
1520
|
ButtonGroup$1.displayName = COMPONENT_NAME$1b;
|
|
1519
|
-
ButtonGroup$1.className = CLASSNAME$
|
|
1520
|
-
ButtonGroup$1.defaultProps = DEFAULT_PROPS$
|
|
1521
|
+
ButtonGroup$1.className = CLASSNAME$1f;
|
|
1522
|
+
ButtonGroup$1.defaultProps = DEFAULT_PROPS$13;
|
|
1521
1523
|
|
|
1522
1524
|
/**
|
|
1523
1525
|
* ButtonGroup component.
|
|
@@ -1533,16 +1535,16 @@ const ButtonGroup = forwardRef((props, ref) => {
|
|
|
1533
1535
|
});
|
|
1534
1536
|
});
|
|
1535
1537
|
ButtonGroup.displayName = COMPONENT_NAME$1b;
|
|
1536
|
-
ButtonGroup.className = CLASSNAME$
|
|
1537
|
-
ButtonGroup.defaultProps = DEFAULT_PROPS$
|
|
1538
|
+
ButtonGroup.className = CLASSNAME$1f;
|
|
1539
|
+
ButtonGroup.defaultProps = DEFAULT_PROPS$13;
|
|
1538
1540
|
|
|
1539
1541
|
const COMPONENT_NAME$1a = 'InputLabel';
|
|
1540
1542
|
const InputLabelClassName = 'lumx-input-label';
|
|
1541
|
-
const CLASSNAME$
|
|
1543
|
+
const CLASSNAME$1e = InputLabelClassName;
|
|
1542
1544
|
const {
|
|
1543
|
-
block: block$
|
|
1544
|
-
} = bem(CLASSNAME$
|
|
1545
|
-
const DEFAULT_PROPS$
|
|
1545
|
+
block: block$13
|
|
1546
|
+
} = bem(CLASSNAME$1e);
|
|
1547
|
+
const DEFAULT_PROPS$12 = {};
|
|
1546
1548
|
|
|
1547
1549
|
/**
|
|
1548
1550
|
* InputLabel component.
|
|
@@ -1562,7 +1564,7 @@ function InputLabel$1(props) {
|
|
|
1562
1564
|
ref: ref,
|
|
1563
1565
|
...forwardedProps,
|
|
1564
1566
|
htmlFor: htmlFor,
|
|
1565
|
-
className: classnames(className, block$
|
|
1567
|
+
className: classnames(className, block$13({
|
|
1566
1568
|
'is-required': isRequired,
|
|
1567
1569
|
[`theme-${theme}`]: Boolean(theme),
|
|
1568
1570
|
'has-custom-typography': Boolean(typography$1)
|
|
@@ -1571,8 +1573,8 @@ function InputLabel$1(props) {
|
|
|
1571
1573
|
});
|
|
1572
1574
|
}
|
|
1573
1575
|
InputLabel$1.displayName = COMPONENT_NAME$1a;
|
|
1574
|
-
InputLabel$1.className = CLASSNAME$
|
|
1575
|
-
InputLabel$1.defaultProps = DEFAULT_PROPS$
|
|
1576
|
+
InputLabel$1.className = CLASSNAME$1e;
|
|
1577
|
+
InputLabel$1.defaultProps = DEFAULT_PROPS$12;
|
|
1576
1578
|
|
|
1577
1579
|
const INPUT_HELPER_CONFIGURATION = {
|
|
1578
1580
|
[Kind.error]: {
|
|
@@ -1593,15 +1595,15 @@ const InputHelperClassName = 'lumx-input-helper';
|
|
|
1593
1595
|
* Defines the props of the component.
|
|
1594
1596
|
*/
|
|
1595
1597
|
|
|
1596
|
-
const CLASSNAME$
|
|
1598
|
+
const CLASSNAME$1d = InputHelperClassName;
|
|
1597
1599
|
const {
|
|
1598
|
-
block: block$
|
|
1599
|
-
} = bem(CLASSNAME$
|
|
1600
|
+
block: block$12
|
|
1601
|
+
} = bem(CLASSNAME$1d);
|
|
1600
1602
|
|
|
1601
1603
|
/**
|
|
1602
1604
|
* Component default props.
|
|
1603
1605
|
*/
|
|
1604
|
-
const DEFAULT_PROPS$
|
|
1606
|
+
const DEFAULT_PROPS$11 = {
|
|
1605
1607
|
kind: Kind.info
|
|
1606
1608
|
};
|
|
1607
1609
|
|
|
@@ -1612,7 +1614,7 @@ function InputHelper$1(props) {
|
|
|
1612
1614
|
const {
|
|
1613
1615
|
children,
|
|
1614
1616
|
className,
|
|
1615
|
-
kind = DEFAULT_PROPS$
|
|
1617
|
+
kind = DEFAULT_PROPS$11.kind,
|
|
1616
1618
|
theme,
|
|
1617
1619
|
ref,
|
|
1618
1620
|
...forwardedProps
|
|
@@ -1623,7 +1625,7 @@ function InputHelper$1(props) {
|
|
|
1623
1625
|
return /*#__PURE__*/jsx("p", {
|
|
1624
1626
|
ref: ref,
|
|
1625
1627
|
...forwardedProps,
|
|
1626
|
-
className: classnames(className, block$
|
|
1628
|
+
className: classnames(className, block$12({
|
|
1627
1629
|
[`color-${color}`]: Boolean(color),
|
|
1628
1630
|
[`theme-${theme}`]: Boolean(theme)
|
|
1629
1631
|
})),
|
|
@@ -1631,8 +1633,8 @@ function InputHelper$1(props) {
|
|
|
1631
1633
|
});
|
|
1632
1634
|
}
|
|
1633
1635
|
InputHelper$1.displayName = COMPONENT_NAME$19;
|
|
1634
|
-
InputHelper$1.className = CLASSNAME$
|
|
1635
|
-
InputHelper$1.defaultProps = DEFAULT_PROPS$
|
|
1636
|
+
InputHelper$1.className = CLASSNAME$1d;
|
|
1637
|
+
InputHelper$1.defaultProps = DEFAULT_PROPS$11;
|
|
1636
1638
|
|
|
1637
1639
|
const INTERMEDIATE_STATE = 'intermediate';
|
|
1638
1640
|
|
|
@@ -1648,11 +1650,11 @@ const COMPONENT_NAME$18 = 'Checkbox';
|
|
|
1648
1650
|
/**
|
|
1649
1651
|
* Component default class name and class prefix.
|
|
1650
1652
|
*/
|
|
1651
|
-
const CLASSNAME$
|
|
1653
|
+
const CLASSNAME$1c = 'lumx-checkbox';
|
|
1652
1654
|
const {
|
|
1653
|
-
block: block$
|
|
1654
|
-
element: element$
|
|
1655
|
-
} = bem(CLASSNAME$
|
|
1655
|
+
block: block$11,
|
|
1656
|
+
element: element$P
|
|
1657
|
+
} = bem(CLASSNAME$1c);
|
|
1656
1658
|
|
|
1657
1659
|
/**
|
|
1658
1660
|
* Checkbox component.
|
|
@@ -1688,7 +1690,7 @@ const Checkbox$1 = props => {
|
|
|
1688
1690
|
return /*#__PURE__*/jsxs("div", {
|
|
1689
1691
|
ref: ref,
|
|
1690
1692
|
...forwardedProps,
|
|
1691
|
-
className: classnames(className, block$
|
|
1693
|
+
className: classnames(className, block$11({
|
|
1692
1694
|
// Whether state is intermediate class name will "-checked"
|
|
1693
1695
|
'is-checked': intermediateState ? true : isChecked,
|
|
1694
1696
|
'is-disabled': isDisabled,
|
|
@@ -1696,12 +1698,12 @@ const Checkbox$1 = props => {
|
|
|
1696
1698
|
[`theme-${theme}`]: Boolean(theme)
|
|
1697
1699
|
})),
|
|
1698
1700
|
children: [/*#__PURE__*/jsxs("div", {
|
|
1699
|
-
className: element$
|
|
1701
|
+
className: element$P('input-wrapper'),
|
|
1700
1702
|
children: [/*#__PURE__*/jsx("input", {
|
|
1701
1703
|
ref: inputRef,
|
|
1702
1704
|
type: "checkbox",
|
|
1703
1705
|
id: inputId,
|
|
1704
|
-
className: element$
|
|
1706
|
+
className: element$P('input-native'),
|
|
1705
1707
|
name: name,
|
|
1706
1708
|
value: value,
|
|
1707
1709
|
checked: isChecked,
|
|
@@ -1713,26 +1715,26 @@ const Checkbox$1 = props => {
|
|
|
1713
1715
|
} : {}),
|
|
1714
1716
|
...inputProps
|
|
1715
1717
|
}), /*#__PURE__*/jsxs("div", {
|
|
1716
|
-
className: element$
|
|
1718
|
+
className: element$P('input-placeholder'),
|
|
1717
1719
|
children: [/*#__PURE__*/jsx("div", {
|
|
1718
|
-
className: element$
|
|
1720
|
+
className: element$P('input-background')
|
|
1719
1721
|
}), /*#__PURE__*/jsx("div", {
|
|
1720
|
-
className: element$
|
|
1722
|
+
className: element$P('input-indicator'),
|
|
1721
1723
|
children: Icon$1({
|
|
1722
1724
|
icon: intermediateState ? mdiMinus : mdiCheck
|
|
1723
1725
|
})
|
|
1724
1726
|
})]
|
|
1725
1727
|
})]
|
|
1726
1728
|
}), /*#__PURE__*/jsxs("div", {
|
|
1727
|
-
className: element$
|
|
1729
|
+
className: element$P('content'),
|
|
1728
1730
|
children: [label && InputLabel$1({
|
|
1729
1731
|
htmlFor: inputId,
|
|
1730
|
-
className: element$
|
|
1732
|
+
className: element$P('label'),
|
|
1731
1733
|
theme,
|
|
1732
1734
|
children: label
|
|
1733
1735
|
}), helper && InputHelper$1({
|
|
1734
1736
|
id: `${inputId}-helper`,
|
|
1735
|
-
className: element$
|
|
1737
|
+
className: element$P('helper'),
|
|
1736
1738
|
theme,
|
|
1737
1739
|
children: helper
|
|
1738
1740
|
})]
|
|
@@ -1747,7 +1749,7 @@ const Checkbox$1 = props => {
|
|
|
1747
1749
|
/**
|
|
1748
1750
|
* Component default props.
|
|
1749
1751
|
*/
|
|
1750
|
-
const DEFAULT_PROPS
|
|
1752
|
+
const DEFAULT_PROPS$10 = {};
|
|
1751
1753
|
|
|
1752
1754
|
/**
|
|
1753
1755
|
* Checkbox component.
|
|
@@ -1808,8 +1810,8 @@ const Checkbox = forwardRef((props, ref) => {
|
|
|
1808
1810
|
});
|
|
1809
1811
|
});
|
|
1810
1812
|
Checkbox.displayName = COMPONENT_NAME$18;
|
|
1811
|
-
Checkbox.className = CLASSNAME$
|
|
1812
|
-
Checkbox.defaultProps = DEFAULT_PROPS
|
|
1813
|
+
Checkbox.className = CLASSNAME$1c;
|
|
1814
|
+
Checkbox.defaultProps = DEFAULT_PROPS$10;
|
|
1813
1815
|
|
|
1814
1816
|
/**
|
|
1815
1817
|
* Wrap mouse event handler to stop event propagation.
|
|
@@ -1835,16 +1837,16 @@ const COMPONENT_NAME$17 = 'Chip';
|
|
|
1835
1837
|
/**
|
|
1836
1838
|
* Component default class name and class prefix.
|
|
1837
1839
|
*/
|
|
1838
|
-
const CLASSNAME$
|
|
1840
|
+
const CLASSNAME$1b = 'lumx-chip';
|
|
1839
1841
|
const {
|
|
1840
|
-
block: block$
|
|
1841
|
-
element: element$
|
|
1842
|
-
} = classNames.bem(CLASSNAME$
|
|
1842
|
+
block: block$10,
|
|
1843
|
+
element: element$O
|
|
1844
|
+
} = classNames.bem(CLASSNAME$1b);
|
|
1843
1845
|
|
|
1844
1846
|
/**
|
|
1845
1847
|
* Component default props.
|
|
1846
1848
|
*/
|
|
1847
|
-
const DEFAULT_PROPS
|
|
1849
|
+
const DEFAULT_PROPS$$ = {
|
|
1848
1850
|
size: Size$1.m
|
|
1849
1851
|
};
|
|
1850
1852
|
|
|
@@ -1874,7 +1876,7 @@ const Chip = forwardRef((props, ref) => {
|
|
|
1874
1876
|
onAfterClick,
|
|
1875
1877
|
onBeforeClick,
|
|
1876
1878
|
onClick,
|
|
1877
|
-
size = DEFAULT_PROPS
|
|
1879
|
+
size = DEFAULT_PROPS$$.size,
|
|
1878
1880
|
theme = defaultTheme,
|
|
1879
1881
|
href,
|
|
1880
1882
|
onKeyDown,
|
|
@@ -1905,7 +1907,7 @@ const Chip = forwardRef((props, ref) => {
|
|
|
1905
1907
|
...forwardedProps,
|
|
1906
1908
|
href: !disabledStateProps.disabled ? href : undefined,
|
|
1907
1909
|
ref: ref,
|
|
1908
|
-
className: classNames.join(className, block$
|
|
1910
|
+
className: classNames.join(className, block$10({
|
|
1909
1911
|
'is-clickable': isClickable,
|
|
1910
1912
|
[`color-${chipColor}`]: Boolean(chipColor),
|
|
1911
1913
|
'is-disabled': isAnyDisabled,
|
|
@@ -1923,19 +1925,19 @@ const Chip = forwardRef((props, ref) => {
|
|
|
1923
1925
|
/*#__PURE__*/
|
|
1924
1926
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
1925
1927
|
jsx("div", {
|
|
1926
|
-
className: element$
|
|
1928
|
+
className: element$O('before', {
|
|
1927
1929
|
'is-clickable': hasBeforeClick
|
|
1928
1930
|
}),
|
|
1929
1931
|
onClick: handleOnBeforeClick,
|
|
1930
1932
|
children: before
|
|
1931
1933
|
}), /*#__PURE__*/jsx("div", {
|
|
1932
|
-
className: element$
|
|
1934
|
+
className: element$O('label'),
|
|
1933
1935
|
children: children
|
|
1934
1936
|
}), after &&
|
|
1935
1937
|
/*#__PURE__*/
|
|
1936
1938
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
1937
1939
|
jsx("div", {
|
|
1938
|
-
className: element$
|
|
1940
|
+
className: element$O('after', {
|
|
1939
1941
|
'is-clickable': hasAfterClick
|
|
1940
1942
|
}),
|
|
1941
1943
|
onClick: handleOnAfterClick,
|
|
@@ -1945,8 +1947,8 @@ const Chip = forwardRef((props, ref) => {
|
|
|
1945
1947
|
);
|
|
1946
1948
|
});
|
|
1947
1949
|
Chip.displayName = COMPONENT_NAME$17;
|
|
1948
|
-
Chip.className = CLASSNAME$
|
|
1949
|
-
Chip.defaultProps = DEFAULT_PROPS
|
|
1950
|
+
Chip.className = CLASSNAME$1b;
|
|
1951
|
+
Chip.defaultProps = DEFAULT_PROPS$$;
|
|
1950
1952
|
|
|
1951
1953
|
const INITIAL_STATE_ACTIVE_CHIP = -1;
|
|
1952
1954
|
|
|
@@ -2002,7 +2004,7 @@ const useChipGroupNavigation = (chips, onChipDeleted, initialActiveChip = INITIA
|
|
|
2002
2004
|
/**
|
|
2003
2005
|
* Component default props.
|
|
2004
2006
|
*/
|
|
2005
|
-
const DEFAULT_PROPS$
|
|
2007
|
+
const DEFAULT_PROPS$_ = {};
|
|
2006
2008
|
|
|
2007
2009
|
/**
|
|
2008
2010
|
* Component display name.
|
|
@@ -2012,7 +2014,7 @@ const COMPONENT_NAME$16 = 'ChipGroup';
|
|
|
2012
2014
|
/**
|
|
2013
2015
|
* Component default class name and class prefix.
|
|
2014
2016
|
*/
|
|
2015
|
-
const CLASSNAME$
|
|
2017
|
+
const CLASSNAME$1a = 'lumx-chip-group';
|
|
2016
2018
|
|
|
2017
2019
|
/**
|
|
2018
2020
|
* ChipGroup component.
|
|
@@ -2031,13 +2033,13 @@ const InternalChipGroup = forwardRef((props, ref) => {
|
|
|
2031
2033
|
return /*#__PURE__*/jsx("div", {
|
|
2032
2034
|
ref: ref,
|
|
2033
2035
|
...forwardedProps,
|
|
2034
|
-
className: classNames.join(className, CLASSNAME$
|
|
2036
|
+
className: classNames.join(className, CLASSNAME$1a),
|
|
2035
2037
|
children: children
|
|
2036
2038
|
});
|
|
2037
2039
|
});
|
|
2038
2040
|
InternalChipGroup.displayName = COMPONENT_NAME$16;
|
|
2039
|
-
InternalChipGroup.className = CLASSNAME$
|
|
2040
|
-
InternalChipGroup.defaultProps = DEFAULT_PROPS$
|
|
2041
|
+
InternalChipGroup.className = CLASSNAME$1a;
|
|
2042
|
+
InternalChipGroup.defaultProps = DEFAULT_PROPS$_;
|
|
2041
2043
|
const ChipGroup = Object.assign(InternalChipGroup, {
|
|
2042
2044
|
useChipGroupNavigation
|
|
2043
2045
|
});
|
|
@@ -2111,115 +2113,1789 @@ function useFocusLastChipOnBackspace(chipRefs, inputRef) {
|
|
|
2111
2113
|
lastChip?.focus();
|
|
2112
2114
|
};
|
|
2113
2115
|
|
|
2114
|
-
// Attach keyboard event listener
|
|
2115
|
-
input.addEventListener('keydown', onKeyDown);
|
|
2116
|
+
// Attach keyboard event listener
|
|
2117
|
+
input.addEventListener('keydown', onKeyDown);
|
|
2118
|
+
|
|
2119
|
+
// Cleanup listener on unmount
|
|
2120
|
+
return () => {
|
|
2121
|
+
input.removeEventListener('keydown', onKeyDown);
|
|
2122
|
+
};
|
|
2123
|
+
}, [inputRef, findPreviousEnabledChip]);
|
|
2124
|
+
return {
|
|
2125
|
+
findPreviousEnabledChip
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
/**
|
|
2130
|
+
* Component default class name and class prefix.
|
|
2131
|
+
*/
|
|
2132
|
+
const CLASSNAME$19 = 'lumx-selection-chip-group';
|
|
2133
|
+
const {
|
|
2134
|
+
block: block$$,
|
|
2135
|
+
element: element$N
|
|
2136
|
+
} = classNames.bem(CLASSNAME$19);
|
|
2137
|
+
|
|
2138
|
+
/**
|
|
2139
|
+
* SelectionChipGroup component.
|
|
2140
|
+
*
|
|
2141
|
+
* @param props Component props.
|
|
2142
|
+
* @param ref Component ref.
|
|
2143
|
+
* @return React element.
|
|
2144
|
+
*/
|
|
2145
|
+
const SelectionChipGroup = ({
|
|
2146
|
+
onChange,
|
|
2147
|
+
value,
|
|
2148
|
+
getOptionId,
|
|
2149
|
+
getOptionName,
|
|
2150
|
+
inputRef,
|
|
2151
|
+
inputLabel,
|
|
2152
|
+
renderChip,
|
|
2153
|
+
theme,
|
|
2154
|
+
isDisabled,
|
|
2155
|
+
chipTooltipLabel,
|
|
2156
|
+
label,
|
|
2157
|
+
...forwardedProps
|
|
2158
|
+
}) => {
|
|
2159
|
+
const chipRefs = React__default.useRef([]);
|
|
2160
|
+
const {
|
|
2161
|
+
findPreviousEnabledChip
|
|
2162
|
+
} = useFocusLastChipOnBackspace(chipRefs, inputRef);
|
|
2163
|
+
return /*#__PURE__*/jsx(ChipGroup, {
|
|
2164
|
+
role: "group",
|
|
2165
|
+
"aria-label": label,
|
|
2166
|
+
className: block$$(),
|
|
2167
|
+
...forwardedProps,
|
|
2168
|
+
children: value?.map((v, index) => {
|
|
2169
|
+
const name = getWithSelector(getOptionName, v);
|
|
2170
|
+
const id = getWithSelector(getOptionId, v);
|
|
2171
|
+
const onClick = () => {
|
|
2172
|
+
const newValue = [...value];
|
|
2173
|
+
const existingIndex = value.findIndex(vi => getWithSelector(getOptionId, vi) === id);
|
|
2174
|
+
if (existingIndex === -1) {
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
// Remove value
|
|
2178
|
+
newValue.splice(existingIndex, 1);
|
|
2179
|
+
onChange?.(newValue);
|
|
2180
|
+
};
|
|
2181
|
+
const onKeyDown = evt => {
|
|
2182
|
+
if (evt.key !== 'Backspace') {
|
|
2183
|
+
return;
|
|
2184
|
+
}
|
|
2185
|
+
// Activate (remove value) on Backspace pressed
|
|
2186
|
+
onClick();
|
|
2187
|
+
const previousChip = findPreviousEnabledChip(index - 1);
|
|
2188
|
+
const input = inputRef?.current;
|
|
2189
|
+
// Focus the previous chip or the input
|
|
2190
|
+
(previousChip || input)?.focus();
|
|
2191
|
+
};
|
|
2192
|
+
if (!chipRefs.current[index]) {
|
|
2193
|
+
chipRefs.current[index] = /*#__PURE__*/React__default.createRef();
|
|
2194
|
+
}
|
|
2195
|
+
const ref = chipRefs.current[index];
|
|
2196
|
+
const customChip = renderChip?.(v);
|
|
2197
|
+
const props = isComponentType(Chip)(customChip) ? customChip.props : undefined;
|
|
2198
|
+
const chipIsDisabled = props?.isDisabled || isDisabled;
|
|
2199
|
+
const chipName = typeof props?.children === 'string' ? props.children : name;
|
|
2200
|
+
const tooltipLabel = chipTooltipLabel(chipName);
|
|
2201
|
+
return /*#__PURE__*/jsx(Tooltip, {
|
|
2202
|
+
label: !chipIsDisabled ? tooltipLabel : undefined,
|
|
2203
|
+
closeMode: "hide",
|
|
2204
|
+
ariaLinkMode: "aria-labelledby",
|
|
2205
|
+
children: /*#__PURE__*/jsx(Chip, {
|
|
2206
|
+
...props,
|
|
2207
|
+
after: /*#__PURE__*/jsx(Icon, {
|
|
2208
|
+
icon: mdiClose
|
|
2209
|
+
}),
|
|
2210
|
+
className: element$N('chip', [props?.className]),
|
|
2211
|
+
size: "s",
|
|
2212
|
+
ref: ref,
|
|
2213
|
+
onClick: onClick,
|
|
2214
|
+
onKeyDown: onKeyDown,
|
|
2215
|
+
theme: theme,
|
|
2216
|
+
isDisabled: chipIsDisabled,
|
|
2217
|
+
tabIndex: chipIsDisabled ? -1 : 0,
|
|
2218
|
+
children: props?.children || name
|
|
2219
|
+
})
|
|
2220
|
+
}, id);
|
|
2221
|
+
})
|
|
2222
|
+
});
|
|
2223
|
+
};
|
|
2224
|
+
|
|
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
|
+
/**
|
|
2550
|
+
* Provide props for the semantic and behaviors the combobox trigger.
|
|
2551
|
+
*
|
|
2552
|
+
*
|
|
2553
|
+
*/
|
|
2554
|
+
function useComboboxTrigger({
|
|
2555
|
+
context,
|
|
2556
|
+
refs,
|
|
2557
|
+
onBlur,
|
|
2558
|
+
onFocus,
|
|
2559
|
+
onKeyDown
|
|
2560
|
+
}) {
|
|
2561
|
+
const {
|
|
2562
|
+
comboboxId,
|
|
2563
|
+
listboxId,
|
|
2564
|
+
isOpen,
|
|
2565
|
+
options,
|
|
2566
|
+
optionsLength,
|
|
2567
|
+
selectedIds,
|
|
2568
|
+
openOnFocus,
|
|
2569
|
+
handleClose,
|
|
2570
|
+
handleOpen,
|
|
2571
|
+
handleSelected,
|
|
2572
|
+
showEmptyState = false,
|
|
2573
|
+
showErrorState = false,
|
|
2574
|
+
status
|
|
2575
|
+
} = context;
|
|
2576
|
+
const highlightedId = useVirtualFocusParent(refs.triggerRef);
|
|
2577
|
+
const {
|
|
2578
|
+
dispatch: movingFocusDispatch
|
|
2579
|
+
} = React__default.useContext(MovingFocusContext);
|
|
2580
|
+
const isErrorStateDisplayed = showErrorState && isOpen && status === 'error';
|
|
2581
|
+
const isEmptyStateDisplayed = showEmptyState && isOpen && status === 'idle' && optionsLength === 0;
|
|
2582
|
+
const showPopover = isOpen && optionsLength > 0 || isEmptyStateDisplayed || isErrorStateDisplayed;
|
|
2583
|
+
|
|
2584
|
+
/**
|
|
2585
|
+
* A debounce close to use to leave time for the
|
|
2586
|
+
* listbox to process things before closing.
|
|
2587
|
+
* This can be useful when clicking an option to leave time for the
|
|
2588
|
+
* event to be processed before closing the popover.
|
|
2589
|
+
*/
|
|
2590
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2591
|
+
const debouncedClose = React__default.useCallback(debounce$1(handleClose, 200), []);
|
|
2592
|
+
|
|
2593
|
+
/** Cleanup any ongoing cleanup */
|
|
2594
|
+
React__default.useEffect(() => {
|
|
2595
|
+
return () => {
|
|
2596
|
+
if (debouncedClose?.cancel) {
|
|
2597
|
+
debouncedClose.cancel();
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
}, [debouncedClose]);
|
|
2601
|
+
const handleBlur = React__default.useCallback(event => {
|
|
2602
|
+
debouncedClose();
|
|
2603
|
+
if (onBlur) {
|
|
2604
|
+
onBlur(event);
|
|
2605
|
+
}
|
|
2606
|
+
}, [debouncedClose, onBlur]);
|
|
2607
|
+
|
|
2608
|
+
/** Actions triggered when the input field is focused */
|
|
2609
|
+
const handleFocus = event => {
|
|
2610
|
+
// If the field is refocused in the process of closing, cancel close
|
|
2611
|
+
if (debouncedClose?.cancel) {
|
|
2612
|
+
debouncedClose.cancel();
|
|
2613
|
+
}
|
|
2614
|
+
if (onFocus) {
|
|
2615
|
+
onFocus(event);
|
|
2616
|
+
}
|
|
2617
|
+
/**
|
|
2618
|
+
* Only set the open on focus if the combobox isn't already opened.
|
|
2619
|
+
* This avoids the popover re-opening when an option is selected and the
|
|
2620
|
+
* field is refocused
|
|
2621
|
+
*/
|
|
2622
|
+
if (openOnFocus && !showPopover) {
|
|
2623
|
+
handleOpen({
|
|
2624
|
+
manual: true
|
|
2625
|
+
});
|
|
2626
|
+
}
|
|
2627
|
+
};
|
|
2628
|
+
const handleClick = () => {
|
|
2629
|
+
handleOpen({
|
|
2630
|
+
manual: true
|
|
2631
|
+
});
|
|
2632
|
+
};
|
|
2633
|
+
|
|
2634
|
+
/**
|
|
2635
|
+
* Keyboard shortcut management following the WAI APG pattern
|
|
2636
|
+
* https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-list/#kbd_label
|
|
2637
|
+
*/
|
|
2638
|
+
const handleKeyDown = React__default.useCallback(async event => {
|
|
2639
|
+
const {
|
|
2640
|
+
key,
|
|
2641
|
+
altKey
|
|
2642
|
+
} = event;
|
|
2643
|
+
|
|
2644
|
+
/**
|
|
2645
|
+
* On Enter key
|
|
2646
|
+
* * Select option that is currently highlighted, if any
|
|
2647
|
+
* * Close suggestions, event if none is highlighted
|
|
2648
|
+
*/
|
|
2649
|
+
if (event.key === 'Enter') {
|
|
2650
|
+
if (!showPopover) {
|
|
2651
|
+
return;
|
|
2652
|
+
}
|
|
2653
|
+
if (highlightedId) {
|
|
2654
|
+
// prevent any potential form submission
|
|
2655
|
+
event.preventDefault();
|
|
2656
|
+
const option = options[highlightedId];
|
|
2657
|
+
handleSelected(option, 'keyboard');
|
|
2658
|
+
} else {
|
|
2659
|
+
handleClose();
|
|
2660
|
+
}
|
|
2661
|
+
return;
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
/**
|
|
2665
|
+
* On arrow up/down
|
|
2666
|
+
* * If popover is already opened, do nothing
|
|
2667
|
+
* * If alt key pressed, show the listbox without focusing an option
|
|
2668
|
+
* * If arrow Up is pressed, select last option
|
|
2669
|
+
* * If arrow Down is pressed, select first option
|
|
2670
|
+
* */
|
|
2671
|
+
if (key === 'ArrowDown' || key === 'ArrowUp') {
|
|
2672
|
+
if (showPopover) {
|
|
2673
|
+
return;
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
/** Open the listbox */
|
|
2677
|
+
const listBoxOptions = await handleOpen({
|
|
2678
|
+
manual: true
|
|
2679
|
+
});
|
|
2680
|
+
if (!listBoxOptions) {
|
|
2681
|
+
return;
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
/**
|
|
2685
|
+
* If alt key is pressed, only open without changing visual focus
|
|
2686
|
+
* as per WAI Guidelines
|
|
2687
|
+
*/
|
|
2688
|
+
if (!altKey) {
|
|
2689
|
+
/** If a selected id is set, set it as current tabstop */
|
|
2690
|
+
if (selectedIds?.length) {
|
|
2691
|
+
movingFocusDispatch({
|
|
2692
|
+
type: 'SELECT_TAB_STOP',
|
|
2693
|
+
payload: {
|
|
2694
|
+
id: selectedIds?.[0],
|
|
2695
|
+
type: 'keyboard'
|
|
2696
|
+
}
|
|
2697
|
+
});
|
|
2698
|
+
} else {
|
|
2699
|
+
/** Focus either the first or last item depending on the keyboard arrow pressed */
|
|
2700
|
+
movingFocusDispatch({
|
|
2701
|
+
type: 'KEY_NAV',
|
|
2702
|
+
payload: {
|
|
2703
|
+
ctrlKey: false,
|
|
2704
|
+
key: key === 'ArrowUp' ? 'End' : 'Home'
|
|
2705
|
+
}
|
|
2706
|
+
});
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
return;
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
// Forward event
|
|
2713
|
+
onKeyDown?.(event);
|
|
2714
|
+
}, [onKeyDown, showPopover, highlightedId, options, handleSelected, handleClose, handleOpen, selectedIds, movingFocusDispatch]);
|
|
2715
|
+
return {
|
|
2716
|
+
id: comboboxId,
|
|
2717
|
+
role: 'combobox',
|
|
2718
|
+
'aria-activedescendant': showPopover && highlightedId ? highlightedId : '',
|
|
2719
|
+
'aria-controls': listboxId,
|
|
2720
|
+
'aria-owns': listboxId,
|
|
2721
|
+
'aria-expanded': showPopover,
|
|
2722
|
+
onFocus: handleFocus,
|
|
2723
|
+
onBlur: handleBlur,
|
|
2724
|
+
onClick: handleClick,
|
|
2725
|
+
onKeyDown: handleKeyDown
|
|
2726
|
+
};
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
/** Is printable character key press */
|
|
2730
|
+
const isTypeEvent = ({
|
|
2731
|
+
key,
|
|
2732
|
+
altKey,
|
|
2733
|
+
ctrlKey,
|
|
2734
|
+
metaKey
|
|
2735
|
+
}) => key.length === 1 && key !== ' ' && !altKey && !ctrlKey && !metaKey;
|
|
2736
|
+
|
|
2737
|
+
/**
|
|
2738
|
+
* Provide props for the semantic and behaviors the combobox button trigger
|
|
2739
|
+
*
|
|
2740
|
+
* Overrides the useComboboxTrigger() props & behavior to add a jump to option
|
|
2741
|
+
* on printable character key down.
|
|
2742
|
+
*/
|
|
2743
|
+
function useComboboxButton(args) {
|
|
2744
|
+
const {
|
|
2745
|
+
context: {
|
|
2746
|
+
handleOpen
|
|
2747
|
+
},
|
|
2748
|
+
onKeyDown: parentOnKeyDown
|
|
2749
|
+
} = args;
|
|
2750
|
+
const {
|
|
2751
|
+
dispatch: movingFocusDispatch,
|
|
2752
|
+
state: {
|
|
2753
|
+
selectedId: highlightedId
|
|
2754
|
+
}
|
|
2755
|
+
} = React__default.useContext(MovingFocusContext);
|
|
2756
|
+
const searchValueRef = React__default.useRef('');
|
|
2757
|
+
const searchTimeoutRef = React__default.useRef();
|
|
2758
|
+
const onKeyDown = React__default.useMemo(() => {
|
|
2759
|
+
function clearSearchTimeout() {
|
|
2760
|
+
const searchTimeout = searchTimeoutRef.current;
|
|
2761
|
+
if (!searchTimeout) {
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2764
|
+
clearTimeout(searchTimeout);
|
|
2765
|
+
searchTimeoutRef.current = undefined;
|
|
2766
|
+
}
|
|
2767
|
+
function clearSearch() {
|
|
2768
|
+
searchValueRef.current = '';
|
|
2769
|
+
clearSearchTimeout();
|
|
2770
|
+
}
|
|
2771
|
+
return async event => {
|
|
2772
|
+
if (!isTypeEvent(event)) {
|
|
2773
|
+
// Forward key down event
|
|
2774
|
+
parentOnKeyDown?.(event);
|
|
2775
|
+
return undefined;
|
|
2776
|
+
}
|
|
2777
|
+
event.stopPropagation();
|
|
2778
|
+
|
|
2779
|
+
// Clear current search timeout
|
|
2780
|
+
clearSearchTimeout();
|
|
2781
|
+
|
|
2782
|
+
// Open combobox and wait for options to mount
|
|
2783
|
+
const options = await handleOpen({
|
|
2784
|
+
manual: false
|
|
2785
|
+
});
|
|
2786
|
+
const optionArray = options && Object.values(options);
|
|
2787
|
+
if (!optionArray?.length) {
|
|
2788
|
+
return undefined;
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
// Append key to current search
|
|
2792
|
+
searchValueRef.current += event.key.toLowerCase();
|
|
2793
|
+
const searchValue = searchValueRef.current;
|
|
2794
|
+
|
|
2795
|
+
// Clear search after 500ms
|
|
2796
|
+
searchTimeoutRef.current = setTimeout(clearSearch, 500);
|
|
2797
|
+
|
|
2798
|
+
// Search is containing all the same letters (ex: aaaa)
|
|
2799
|
+
const allTheSameLetters = searchValue.split('').every(letter => letter === searchValue[0]);
|
|
2800
|
+
|
|
2801
|
+
// start from currently selected option
|
|
2802
|
+
let startIndex = optionArray.findIndex(option => option.generatedId === highlightedId);
|
|
2803
|
+
if (startIndex === -1) {
|
|
2804
|
+
startIndex = 0;
|
|
2805
|
+
}
|
|
2806
|
+
let index = startIndex;
|
|
2807
|
+
do {
|
|
2808
|
+
// Increment index and loop around to 0 if we get over the array length
|
|
2809
|
+
index = (index + 1) % optionArray.length;
|
|
2810
|
+
const option = optionArray[index];
|
|
2811
|
+
// Search by text value or fallback on id.
|
|
2812
|
+
const optionText = isComboboxValue(option) ? option?.textValue || option?.id : null;
|
|
2813
|
+
if (isComboboxValue(option) && optionText) {
|
|
2814
|
+
const optionTextValue = optionText.toLowerCase();
|
|
2815
|
+
|
|
2816
|
+
// Search on first letter if search is all the same letters
|
|
2817
|
+
const searchText = allTheSameLetters ? searchValue[0] : searchValue;
|
|
2818
|
+
|
|
2819
|
+
// Option text value starts with searched text
|
|
2820
|
+
if (optionTextValue.startsWith(searchText)) {
|
|
2821
|
+
movingFocusDispatch({
|
|
2822
|
+
type: 'SELECT_TAB_STOP',
|
|
2823
|
+
payload: {
|
|
2824
|
+
id: option.generatedId,
|
|
2825
|
+
type: 'keyboard'
|
|
2826
|
+
}
|
|
2827
|
+
});
|
|
2828
|
+
break;
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
} while (index !== startIndex);
|
|
2832
|
+
return clearSearchTimeout;
|
|
2833
|
+
};
|
|
2834
|
+
}, [handleOpen, parentOnKeyDown, highlightedId, movingFocusDispatch]);
|
|
2835
|
+
return useComboboxTrigger({
|
|
2836
|
+
...args,
|
|
2837
|
+
onKeyDown
|
|
2838
|
+
});
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
/**
|
|
2842
|
+
* Combobox button trigger.
|
|
2843
|
+
*
|
|
2844
|
+
* @family Combobox
|
|
2845
|
+
*/
|
|
2846
|
+
const ComboboxButton = forwardRef((props, ref) => {
|
|
2847
|
+
const {
|
|
2848
|
+
as,
|
|
2849
|
+
label,
|
|
2850
|
+
onFocus,
|
|
2851
|
+
onBlur,
|
|
2852
|
+
labelDisplayMode = 'show-selection',
|
|
2853
|
+
...forwardedProps
|
|
2854
|
+
} = props;
|
|
2855
|
+
const refs = useComboboxRefs();
|
|
2856
|
+
const context = useCombobox();
|
|
2857
|
+
const buttonProps = useComboboxButton({
|
|
2858
|
+
context,
|
|
2859
|
+
refs,
|
|
2860
|
+
onBlur,
|
|
2861
|
+
onFocus
|
|
2862
|
+
});
|
|
2863
|
+
const Element = as || Button;
|
|
2864
|
+
const showSelection = labelDisplayMode === 'show-selection';
|
|
2865
|
+
const tooltipOnly = labelDisplayMode === 'show-tooltip';
|
|
2866
|
+
const selectionLabel = showSelection && context.selectedIds?.length && context.inputValue;
|
|
2867
|
+
let content = null;
|
|
2868
|
+
if (!tooltipOnly) {
|
|
2869
|
+
// Display selection label or label
|
|
2870
|
+
content = selectionLabel || label;
|
|
2871
|
+
}
|
|
2872
|
+
const hideTooltip =
|
|
2873
|
+
// Hide tooltip if the displayed label and tooltip label are the same
|
|
2874
|
+
label === content ||
|
|
2875
|
+
// Hide tooltip when the combobox is open
|
|
2876
|
+
context.isOpen;
|
|
2877
|
+
const mergedRefs = useMergeRefs(ref, refs.triggerRef, refs.anchorRef);
|
|
2878
|
+
return /*#__PURE__*/jsx(Tooltip, {
|
|
2879
|
+
className: hideTooltip ? visuallyHidden() : undefined,
|
|
2880
|
+
label: label,
|
|
2881
|
+
closeMode: "hide",
|
|
2882
|
+
ariaLinkMode: "aria-labelledby",
|
|
2883
|
+
children: /*#__PURE__*/jsx(Element, {
|
|
2884
|
+
ref: mergedRefs,
|
|
2885
|
+
...forwardedProps,
|
|
2886
|
+
...buttonProps,
|
|
2887
|
+
children: content
|
|
2888
|
+
})
|
|
2889
|
+
});
|
|
2890
|
+
});
|
|
2891
|
+
|
|
2892
|
+
const CLASSNAME$18 = 'lumx-combobox-divider';
|
|
2893
|
+
|
|
2894
|
+
/** Combobox option divider */
|
|
2895
|
+
function ComboboxDivider() {
|
|
2896
|
+
return /*#__PURE__*/jsx(ListDivider, {
|
|
2897
|
+
className: CLASSNAME$18,
|
|
2898
|
+
role: "presentation"
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
/**
|
|
2903
|
+
* Provide props for the semantic and behaviors the combobox input trigger
|
|
2904
|
+
*
|
|
2905
|
+
* Overrides the useComboboxTrigger() props & behavior to prevent open on click
|
|
2906
|
+
* if `openOnFocus` is not enabled.
|
|
2907
|
+
*/
|
|
2908
|
+
function useComboboxInput({
|
|
2909
|
+
onKeyDown: propsOnKeyDown,
|
|
2910
|
+
...args
|
|
2911
|
+
}) {
|
|
2912
|
+
const triggerProps = useComboboxTrigger(args);
|
|
2913
|
+
const {
|
|
2914
|
+
onClick,
|
|
2915
|
+
onKeyDown,
|
|
2916
|
+
'aria-expanded': showPopover
|
|
2917
|
+
} = triggerProps;
|
|
2918
|
+
const handleClick = () => {
|
|
2919
|
+
if (!args.context.openOnFocus && !args.context.openOnClick) {
|
|
2920
|
+
// Skip if input should not opening on focus nor click
|
|
2921
|
+
return;
|
|
2922
|
+
}
|
|
2923
|
+
onClick();
|
|
2924
|
+
};
|
|
2925
|
+
const handleKeyDown = evt => {
|
|
2926
|
+
if (evt.key === 'Escape') {
|
|
2927
|
+
// Reset field if closed
|
|
2928
|
+
if (!showPopover) {
|
|
2929
|
+
args.context.handleInputChange('');
|
|
2930
|
+
}
|
|
2931
|
+
return;
|
|
2932
|
+
}
|
|
2933
|
+
onKeyDown(evt);
|
|
2934
|
+
if (propsOnKeyDown) {
|
|
2935
|
+
propsOnKeyDown(evt);
|
|
2936
|
+
}
|
|
2937
|
+
};
|
|
2938
|
+
return {
|
|
2939
|
+
...triggerProps,
|
|
2940
|
+
onClick: handleClick,
|
|
2941
|
+
onKeyDown: handleKeyDown
|
|
2942
|
+
};
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
/**
|
|
2946
|
+
* Combobox input trigger.
|
|
2947
|
+
*
|
|
2948
|
+
* @family Combobox
|
|
2949
|
+
*/
|
|
2950
|
+
const ComboboxInput = ({
|
|
2951
|
+
hideToggle,
|
|
2952
|
+
inputRef,
|
|
2953
|
+
textFieldRef,
|
|
2954
|
+
afterElement,
|
|
2955
|
+
onFocus,
|
|
2956
|
+
onBlur,
|
|
2957
|
+
onKeyDown,
|
|
2958
|
+
clearButtonProps,
|
|
2959
|
+
hasClearButton,
|
|
2960
|
+
theme,
|
|
2961
|
+
...textFieldProps
|
|
2962
|
+
}) => {
|
|
2963
|
+
const refs = useComboboxRefs();
|
|
2964
|
+
const context = useCombobox();
|
|
2965
|
+
const inputProps = useComboboxInput({
|
|
2966
|
+
refs,
|
|
2967
|
+
context,
|
|
2968
|
+
onBlur,
|
|
2969
|
+
onFocus,
|
|
2970
|
+
onKeyDown
|
|
2971
|
+
});
|
|
2972
|
+
const {
|
|
2973
|
+
listboxId,
|
|
2974
|
+
isOpen,
|
|
2975
|
+
handleOpen,
|
|
2976
|
+
handleClose,
|
|
2977
|
+
inputValue,
|
|
2978
|
+
handleInputChange
|
|
2979
|
+
} = context;
|
|
2980
|
+
|
|
2981
|
+
/** Callback for when the toggle button is trigged */
|
|
2982
|
+
const handleManualToggle = () => {
|
|
2983
|
+
if (isOpen) {
|
|
2984
|
+
handleClose();
|
|
2985
|
+
} else {
|
|
2986
|
+
handleOpen({
|
|
2987
|
+
manual: true
|
|
2988
|
+
});
|
|
2989
|
+
}
|
|
2990
|
+
refs.triggerRef?.current?.focus();
|
|
2991
|
+
};
|
|
2992
|
+
return /*#__PURE__*/jsx(TextField
|
|
2993
|
+
// Disable native autocomplete
|
|
2994
|
+
, {
|
|
2995
|
+
autoComplete: "off",
|
|
2996
|
+
...textFieldProps,
|
|
2997
|
+
inputRef: mergeRefs(refs.triggerRef, inputRef),
|
|
2998
|
+
textFieldRef: mergeRefs(refs.anchorRef, textFieldRef)
|
|
2999
|
+
// Combobox props
|
|
3000
|
+
,
|
|
3001
|
+
...inputProps,
|
|
3002
|
+
theme: theme,
|
|
3003
|
+
value: inputValue,
|
|
3004
|
+
onClear: () => handleInputChange(''),
|
|
3005
|
+
onChange: handleInputChange,
|
|
3006
|
+
clearButtonProps: hasClearButton ? {
|
|
3007
|
+
...clearButtonProps,
|
|
3008
|
+
label: context.translations.clearLabel
|
|
3009
|
+
} : undefined,
|
|
3010
|
+
afterElement: (!hideToggle || afterElement) && /*#__PURE__*/jsxs(Fragment, {
|
|
3011
|
+
children: [afterElement, !hideToggle && /*#__PURE__*/jsx(IconButton, {
|
|
3012
|
+
theme: theme,
|
|
3013
|
+
onClick: handleManualToggle,
|
|
3014
|
+
label: context.translations.showSuggestionsLabel,
|
|
3015
|
+
emphasis: Emphasis$1.low,
|
|
3016
|
+
size: Size$1.s,
|
|
3017
|
+
icon: inputProps['aria-expanded'] ? mdiChevronUp : mdiChevronDown,
|
|
3018
|
+
type: "button",
|
|
3019
|
+
tabIndex: -1,
|
|
3020
|
+
"aria-expanded": inputProps['aria-expanded'],
|
|
3021
|
+
"aria-haspopup": "listbox",
|
|
3022
|
+
"aria-controls": listboxId
|
|
3023
|
+
})]
|
|
3024
|
+
})
|
|
3025
|
+
});
|
|
3026
|
+
};
|
|
3027
|
+
|
|
3028
|
+
const ComboboxOptionContext = /*#__PURE__*/createContext({});
|
|
3029
|
+
/** Context Provider to store the current combobox option id. */
|
|
3030
|
+
const ComboboxOptionContextProvider = ({
|
|
3031
|
+
optionId,
|
|
3032
|
+
isKeyboardHighlighted,
|
|
3033
|
+
children
|
|
3034
|
+
}) => {
|
|
3035
|
+
const value = React__default.useMemo(() => ({
|
|
3036
|
+
optionId,
|
|
3037
|
+
isKeyboardHighlighted
|
|
3038
|
+
}), [optionId, isKeyboardHighlighted]);
|
|
3039
|
+
return /*#__PURE__*/jsx(ComboboxOptionContext.Provider, {
|
|
3040
|
+
value: value,
|
|
3041
|
+
children: children
|
|
3042
|
+
});
|
|
3043
|
+
};
|
|
3044
|
+
|
|
3045
|
+
/**
|
|
3046
|
+
* Retrieve the current combobox option id.
|
|
3047
|
+
* Must be used within a ComboboxOptionIdProvider
|
|
3048
|
+
*/
|
|
3049
|
+
const useComboboxOptionContext = () => {
|
|
3050
|
+
const comboboxOption = useContext(ComboboxOptionContext);
|
|
3051
|
+
if (!comboboxOption?.optionId) {
|
|
3052
|
+
throw new Error('This hook must be used within a ComboboxOptionIdProvider');
|
|
3053
|
+
}
|
|
3054
|
+
return comboboxOption;
|
|
3055
|
+
};
|
|
3056
|
+
|
|
3057
|
+
/** Retrieve the current combobox section id */
|
|
3058
|
+
const useComboboxSectionId = () => {
|
|
3059
|
+
return useContext(SectionContext);
|
|
3060
|
+
};
|
|
3061
|
+
|
|
3062
|
+
/**
|
|
3063
|
+
* Register the given option to the context
|
|
3064
|
+
*/
|
|
3065
|
+
const useRegisterOption = (registerId, option, shouldRegister) => {
|
|
3066
|
+
const {
|
|
3067
|
+
dispatch
|
|
3068
|
+
} = useCombobox();
|
|
3069
|
+
|
|
3070
|
+
/** Register the given options */
|
|
3071
|
+
React__default.useEffect(() => {
|
|
3072
|
+
if (option && shouldRegister) {
|
|
3073
|
+
dispatch({
|
|
3074
|
+
type: 'ADD_OPTION',
|
|
3075
|
+
payload: {
|
|
3076
|
+
id: registerId,
|
|
3077
|
+
option
|
|
3078
|
+
}
|
|
3079
|
+
});
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
// Unregister ids if/when the component unmounts or if option changes
|
|
3083
|
+
return () => {
|
|
3084
|
+
if (option) {
|
|
3085
|
+
dispatch({
|
|
3086
|
+
type: 'REMOVE_OPTION',
|
|
3087
|
+
payload: {
|
|
3088
|
+
id: registerId
|
|
3089
|
+
}
|
|
3090
|
+
});
|
|
3091
|
+
}
|
|
3092
|
+
};
|
|
3093
|
+
}, [dispatch, option, registerId, shouldRegister]);
|
|
3094
|
+
};
|
|
3095
|
+
|
|
3096
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3097
|
+
const CLASSNAME$17 = 'lumx-combobox-option';
|
|
3098
|
+
const LUMX_CLASSNAME = 'lumx-list-item';
|
|
3099
|
+
const {
|
|
3100
|
+
block: block$_,
|
|
3101
|
+
element: element$M
|
|
3102
|
+
} = classNames.bem(CLASSNAME$17);
|
|
3103
|
+
const lumxListItem = classNames.bem(LUMX_CLASSNAME);
|
|
3104
|
+
|
|
3105
|
+
/**
|
|
3106
|
+
* Content of the option.
|
|
3107
|
+
* This should only be rendered if the option is shown.
|
|
3108
|
+
*/
|
|
3109
|
+
const OptionContent = forwardRef((props, ref) => {
|
|
3110
|
+
const {
|
|
3111
|
+
id,
|
|
3112
|
+
onSelect,
|
|
3113
|
+
isSelected,
|
|
3114
|
+
isDisabled,
|
|
3115
|
+
children,
|
|
3116
|
+
className,
|
|
3117
|
+
before,
|
|
3118
|
+
after,
|
|
3119
|
+
as,
|
|
3120
|
+
size = Size$1.tiny,
|
|
3121
|
+
comboboxType,
|
|
3122
|
+
tooltipProps,
|
|
3123
|
+
description,
|
|
3124
|
+
'aria-hidden': ariaHidden,
|
|
3125
|
+
autofocus,
|
|
3126
|
+
...forwardedProps
|
|
3127
|
+
} = props;
|
|
3128
|
+
const itemRef = React__default.useRef(null);
|
|
3129
|
+
const {
|
|
3130
|
+
state
|
|
3131
|
+
} = React__default.useContext(MovingFocusContext);
|
|
3132
|
+
const {
|
|
3133
|
+
selectedIds
|
|
3134
|
+
} = useCombobox();
|
|
3135
|
+
const hasSelection = selectedIds !== undefined;
|
|
3136
|
+
const isHighlighted = useVirtualFocus(id, itemRef, false, comboboxType === 'grid' ? id : undefined, autofocus);
|
|
3137
|
+
const Element = as || 'span';
|
|
3138
|
+
const ariaSelected = isSelected ? 'true' : 'false';
|
|
3139
|
+
const ariaDescriptionId = description ? `${id}-description` : undefined;
|
|
3140
|
+
const isKeyboardHighlighted = state.isUsingKeyboard && isHighlighted;
|
|
3141
|
+
|
|
3142
|
+
/**
|
|
3143
|
+
* The DS `ListItem` component has a lot of behavior / default props we do not want here.
|
|
3144
|
+
* Notably the before/after items are within the interactive element, which we do not want.
|
|
3145
|
+
* So we use a native li tag.
|
|
3146
|
+
*/
|
|
3147
|
+
return /*#__PURE__*/jsx("li", {
|
|
3148
|
+
className: block$_(undefined, [className ?? '', lumxListItem.block({
|
|
3149
|
+
[`size-${size}`]: !!size
|
|
3150
|
+
})]),
|
|
3151
|
+
role: "presentation",
|
|
3152
|
+
ref: itemRef,
|
|
3153
|
+
"aria-hidden": ariaHidden,
|
|
3154
|
+
style: {
|
|
3155
|
+
display: ariaHidden ? 'none' : undefined
|
|
3156
|
+
},
|
|
3157
|
+
...forwardedProps,
|
|
3158
|
+
children: /*#__PURE__*/jsxs(GenericBlock, {
|
|
3159
|
+
as: "div",
|
|
3160
|
+
role: comboboxType === 'grid' ? 'row' : 'presentation',
|
|
3161
|
+
className: element$M('content', {
|
|
3162
|
+
// Not using the lumx list item disabled style as it blocks pointer events
|
|
3163
|
+
'is-disabled': !!isDisabled
|
|
3164
|
+
},
|
|
3165
|
+
// TODO: migrate away from using lumx-list-item styles https://lumapps.atlassian.net/browse/DSW-288
|
|
3166
|
+
[lumxListItem.element('link', {
|
|
3167
|
+
'is-selected': Boolean(isSelected),
|
|
3168
|
+
'is-highlighted': Boolean(isHighlighted)
|
|
3169
|
+
})]),
|
|
3170
|
+
"data-focus-visible-added": isKeyboardHighlighted ? 'true' : undefined,
|
|
3171
|
+
children: [before && /*#__PURE__*/jsx(GenericBlock.Figure, {
|
|
3172
|
+
as: "span",
|
|
3173
|
+
role: "presentation",
|
|
3174
|
+
className: element$M('before', undefined, [lumxListItem.element('before')]),
|
|
3175
|
+
children: before
|
|
3176
|
+
}), /*#__PURE__*/jsxs(GenericBlock.Content, {
|
|
3177
|
+
as: "span",
|
|
3178
|
+
role: "presentation",
|
|
3179
|
+
className: lumxListItem.element('content'),
|
|
3180
|
+
children: [/*#__PURE__*/jsx(Tooltip, {
|
|
3181
|
+
forceOpen: isKeyboardHighlighted,
|
|
3182
|
+
closeMode: "hide",
|
|
3183
|
+
...tooltipProps,
|
|
3184
|
+
children: /*#__PURE__*/jsx(Element, {
|
|
3185
|
+
id: id,
|
|
3186
|
+
className: element$M('trigger'),
|
|
3187
|
+
role: comboboxType === 'grid' ? 'gridcell' : 'option',
|
|
3188
|
+
"aria-selected": hasSelection ? ariaSelected : undefined,
|
|
3189
|
+
"aria-disabled": isDisabled,
|
|
3190
|
+
"aria-describedby": ariaDescriptionId,
|
|
3191
|
+
onClick: onSelect
|
|
3192
|
+
// Prevent mouse down to avoid blur before the click is activated
|
|
3193
|
+
,
|
|
3194
|
+
onMouseDown: event => event.preventDefault(),
|
|
3195
|
+
ref: ref,
|
|
3196
|
+
...forwardedProps,
|
|
3197
|
+
children: children
|
|
3198
|
+
})
|
|
3199
|
+
}), description && /*#__PURE__*/jsx(Text, {
|
|
3200
|
+
as: "span",
|
|
3201
|
+
id: ariaDescriptionId,
|
|
3202
|
+
role: "presentation",
|
|
3203
|
+
className: element$M('description'),
|
|
3204
|
+
typography: "caption",
|
|
3205
|
+
color: "dark",
|
|
3206
|
+
colorVariant: "L2",
|
|
3207
|
+
children: description
|
|
3208
|
+
})]
|
|
3209
|
+
}), after && /*#__PURE__*/jsx(GenericBlock.Actions, {
|
|
3210
|
+
as: "span",
|
|
3211
|
+
role: "presentation",
|
|
3212
|
+
className: element$M('after', undefined, [lumxListItem.element('after')]),
|
|
3213
|
+
children: /*#__PURE__*/jsx(ComboboxOptionContextProvider, {
|
|
3214
|
+
optionId: id,
|
|
3215
|
+
isKeyboardHighlighted: isKeyboardHighlighted,
|
|
3216
|
+
children: after
|
|
3217
|
+
})
|
|
3218
|
+
})]
|
|
3219
|
+
})
|
|
3220
|
+
});
|
|
3221
|
+
});
|
|
3222
|
+
|
|
3223
|
+
/**
|
|
3224
|
+
* Props for ComboboxOption with additional generic properties.
|
|
3225
|
+
*/
|
|
3226
|
+
|
|
3227
|
+
/**
|
|
3228
|
+
* Option to set within a combobox list.
|
|
3229
|
+
*
|
|
3230
|
+
* @family Combobox
|
|
3231
|
+
* @param ComboboxOptionProps
|
|
3232
|
+
* @returns ComboboxOption
|
|
3233
|
+
*/
|
|
3234
|
+
const ComboboxOption = forwardRef((props, ref) => {
|
|
3235
|
+
const {
|
|
3236
|
+
children,
|
|
3237
|
+
id,
|
|
3238
|
+
textValue,
|
|
3239
|
+
data,
|
|
3240
|
+
filterFromInput = true,
|
|
3241
|
+
onSelect: onOptionSelect,
|
|
3242
|
+
isDisabled,
|
|
3243
|
+
as = 'span',
|
|
3244
|
+
...optionProps
|
|
3245
|
+
} = props;
|
|
3246
|
+
|
|
3247
|
+
// Get the id of the current group, if any.
|
|
3248
|
+
const section = useComboboxSectionId();
|
|
3249
|
+
const {
|
|
3250
|
+
comboboxId,
|
|
3251
|
+
selectedIds,
|
|
3252
|
+
showAll,
|
|
3253
|
+
inputValue,
|
|
3254
|
+
handleSelected,
|
|
3255
|
+
type
|
|
3256
|
+
} = useCombobox();
|
|
3257
|
+
// Generate a unique id for this option.
|
|
3258
|
+
const generatedId = generateOptionId(comboboxId, id);
|
|
3259
|
+
const isSelected = selectedIds?.includes(generatedId);
|
|
3260
|
+
|
|
3261
|
+
// If no text value is set and the direct child is a simple string, use it as value.
|
|
3262
|
+
const isStringChild = typeof children === 'string' || typeof children === 'number';
|
|
3263
|
+
const value = children && !textValue && isStringChild ? children.toString() : textValue;
|
|
3264
|
+
const showOption = !filterFromInput || showAll || value?.toString()?.toLowerCase().includes(inputValue?.toLowerCase());
|
|
3265
|
+
const registeredOption = React__default.useMemo(() => ({
|
|
3266
|
+
id,
|
|
3267
|
+
generatedId,
|
|
3268
|
+
textValue: value,
|
|
3269
|
+
data,
|
|
3270
|
+
filter: filterFromInput,
|
|
3271
|
+
isDisabled: isDisabled || !showOption,
|
|
3272
|
+
sectionId: section.sectionId,
|
|
3273
|
+
onSelect: onOptionSelect
|
|
3274
|
+
}), [data, filterFromInput, generatedId, section.sectionId, id, isDisabled, onOptionSelect, showOption, value]);
|
|
3275
|
+
|
|
3276
|
+
// Register the option
|
|
3277
|
+
useRegisterOption(generatedId, registeredOption, showOption);
|
|
3278
|
+
const handleSelect = React__default.useCallback(() => handleSelected(registeredOption, 'click'), [handleSelected, registeredOption]);
|
|
3279
|
+
if (!id || !showOption) {
|
|
3280
|
+
return null;
|
|
3281
|
+
}
|
|
3282
|
+
return /*#__PURE__*/jsx(OptionContent, {
|
|
3283
|
+
id: generatedId,
|
|
3284
|
+
onSelect: handleSelect,
|
|
3285
|
+
isSelected: isSelected,
|
|
3286
|
+
isDisabled: isDisabled,
|
|
3287
|
+
as: as,
|
|
3288
|
+
ref: ref,
|
|
3289
|
+
comboboxType: type,
|
|
3290
|
+
"aria-hidden": section.isLoading,
|
|
3291
|
+
...optionProps,
|
|
3292
|
+
children: children || textValue
|
|
3293
|
+
});
|
|
3294
|
+
});
|
|
3295
|
+
|
|
3296
|
+
// Default widths the skeletons must have
|
|
3297
|
+
const defaultWidths = [REAL_SIZE_FOR_LUMX_SIZE.xxl, REAL_SIZE_FOR_LUMX_SIZE.xl, REAL_SIZE_FOR_LUMX_SIZE.l];
|
|
3298
|
+
const {
|
|
3299
|
+
block: block$Z,
|
|
3300
|
+
element: element$L
|
|
3301
|
+
} = classNames.bem(CLASSNAME$17);
|
|
3302
|
+
|
|
3303
|
+
/**
|
|
3304
|
+
* Skeleton for a combobox option.
|
|
3305
|
+
* A typography skeleton is rendered by default but can be overridden by passing children.
|
|
3306
|
+
*/
|
|
3307
|
+
const ComboboxOptionSkeleton = ({
|
|
3308
|
+
className,
|
|
3309
|
+
index,
|
|
3310
|
+
before,
|
|
3311
|
+
after,
|
|
3312
|
+
size = Size$1.tiny,
|
|
3313
|
+
children
|
|
3314
|
+
}) => {
|
|
3315
|
+
const renderedChildren = typeof children === 'function' ? children({
|
|
3316
|
+
index
|
|
3317
|
+
}) : children;
|
|
3318
|
+
const content = renderedChildren || /*#__PURE__*/jsx(SkeletonTypography, {
|
|
3319
|
+
typography: "body1",
|
|
3320
|
+
width: index !== undefined && defaultWidths[index] ? defaultWidths[index] : REAL_SIZE_FOR_LUMX_SIZE.xl
|
|
3321
|
+
});
|
|
3322
|
+
return /*#__PURE__*/jsxs("li", {
|
|
3323
|
+
role: "presentation",
|
|
3324
|
+
className: block$Z({
|
|
3325
|
+
skeleton: true
|
|
3326
|
+
}, ['lumx-list-item', `lumx-list-item--size-${size}`, className]),
|
|
3327
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
3328
|
+
role: "presentation",
|
|
3329
|
+
className: element$L('content', ['lumx-list-item__wrapper']),
|
|
3330
|
+
children: [before && /*#__PURE__*/jsx(Text, {
|
|
3331
|
+
as: "span",
|
|
3332
|
+
role: "presentation",
|
|
3333
|
+
className: element$L('before', ['lumx-list-item__before']),
|
|
3334
|
+
children: before
|
|
3335
|
+
}), content]
|
|
3336
|
+
}), after && /*#__PURE__*/jsx("div", {
|
|
3337
|
+
role: "presentation",
|
|
3338
|
+
className: element$L('after', ['lumx-list-item__after']),
|
|
3339
|
+
children: after
|
|
3340
|
+
})]
|
|
3341
|
+
});
|
|
3342
|
+
};
|
|
3343
|
+
|
|
3344
|
+
/** Default skeleton for the options list of the combobox */
|
|
3345
|
+
const ComboboxListSkeleton = ({
|
|
3346
|
+
isLoadingMore,
|
|
3347
|
+
children
|
|
3348
|
+
}) => /*#__PURE__*/jsx(Fragment, {
|
|
3349
|
+
children: Array.from({
|
|
3350
|
+
length: isLoadingMore ? 1 : 3
|
|
3351
|
+
}).map((_, index) => {
|
|
3352
|
+
const renderedChildren = typeof children === 'function' ? children({
|
|
3353
|
+
index
|
|
3354
|
+
}) : children || /*#__PURE__*/jsx(ComboboxOptionSkeleton, {
|
|
3355
|
+
index: index
|
|
3356
|
+
});
|
|
3357
|
+
return (
|
|
3358
|
+
/*#__PURE__*/
|
|
3359
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
3360
|
+
jsx(React__default.Fragment, {
|
|
3361
|
+
children: renderedChildren
|
|
3362
|
+
}, index)
|
|
3363
|
+
);
|
|
3364
|
+
})
|
|
3365
|
+
});
|
|
3366
|
+
|
|
3367
|
+
/** The states in which the full loading must be displayed */
|
|
3368
|
+
const FULL_LOADING_STATES = ['loading', 'debouncing', 'filtering'];
|
|
3369
|
+
const CLASSNAME$16 = 'lumx-combobox-listbox';
|
|
3370
|
+
const {
|
|
3371
|
+
block: block$Y,
|
|
3372
|
+
element: element$K
|
|
3373
|
+
} = bem$1(CLASSNAME$16);
|
|
3374
|
+
|
|
3375
|
+
/**
|
|
3376
|
+
* The listbox containing the combobox's options.
|
|
3377
|
+
*
|
|
3378
|
+
* @family Combobox
|
|
3379
|
+
* @param ComboboxListBoxProps
|
|
3380
|
+
* @returns ComboboxListBox
|
|
3381
|
+
*/
|
|
3382
|
+
const ComboboxListBox = ({
|
|
3383
|
+
children,
|
|
3384
|
+
renderItemSkeleton,
|
|
3385
|
+
label,
|
|
3386
|
+
popoverProps,
|
|
3387
|
+
footer,
|
|
3388
|
+
listRef,
|
|
3389
|
+
...forwardedProps
|
|
3390
|
+
}) => {
|
|
3391
|
+
const {
|
|
3392
|
+
status,
|
|
3393
|
+
listboxId,
|
|
3394
|
+
isOpen,
|
|
3395
|
+
optionsLength,
|
|
3396
|
+
handleClose: contextHandleClose,
|
|
3397
|
+
type,
|
|
3398
|
+
inputValue,
|
|
3399
|
+
showEmptyState,
|
|
3400
|
+
showErrorState,
|
|
3401
|
+
translations
|
|
3402
|
+
} = useCombobox();
|
|
3403
|
+
const {
|
|
3404
|
+
anchorRef
|
|
3405
|
+
} = useComboboxRefs();
|
|
3406
|
+
const {
|
|
3407
|
+
onClose,
|
|
3408
|
+
...otherPopoverProps
|
|
3409
|
+
} = popoverProps || {};
|
|
3410
|
+
const {
|
|
3411
|
+
style,
|
|
3412
|
+
className,
|
|
3413
|
+
...listProps
|
|
3414
|
+
} = forwardedProps;
|
|
3415
|
+
// The states to show a full skeleton instead of the options
|
|
3416
|
+
const showFullLoading = FULL_LOADING_STATES.includes(status);
|
|
3417
|
+
const isErrorStateDisplayed = showErrorState && isOpen && status === 'error';
|
|
3418
|
+
const isEmptyStateDisplayed = showEmptyState && isOpen && status === 'idle' && optionsLength === 0;
|
|
3419
|
+
|
|
3420
|
+
/**
|
|
3421
|
+
* The conditions in which we want to show the content of the popover
|
|
3422
|
+
* * The parent asked for the popover to be opened
|
|
3423
|
+
* * There is at least one option to displayed OR a skeleton
|
|
3424
|
+
*/
|
|
3425
|
+
const showPopover = isOpen && (optionsLength > 0 || showFullLoading) || isEmptyStateDisplayed || isErrorStateDisplayed;
|
|
3426
|
+
const handleClose = () => {
|
|
3427
|
+
if (isOpen) {
|
|
3428
|
+
contextHandleClose?.();
|
|
3429
|
+
onClose?.();
|
|
3430
|
+
}
|
|
3431
|
+
};
|
|
3432
|
+
const emptyMessage = translations.noResultsForInputLabel(inputValue);
|
|
3433
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
3434
|
+
children: [/*#__PURE__*/jsxs(Text, {
|
|
3435
|
+
as: "p",
|
|
3436
|
+
className: visuallyHidden(),
|
|
3437
|
+
role: "log",
|
|
3438
|
+
"aria-live": "assertive",
|
|
3439
|
+
children: [isOpen && !showFullLoading && !isEmptyStateDisplayed && !isErrorStateDisplayed && translations.nbOptionsLabel(optionsLength), isErrorStateDisplayed && `${translations.serviceUnavailableLabel} ${translations.tryReloadLabel}`, showFullLoading && translations.loadingLabel, isEmptyStateDisplayed && emptyMessage]
|
|
3440
|
+
}), /*#__PURE__*/jsx(Popover, {
|
|
3441
|
+
role: "none",
|
|
3442
|
+
onClose: handleClose,
|
|
3443
|
+
anchorRef: anchorRef,
|
|
3444
|
+
fitToAnchorWidth: true,
|
|
3445
|
+
fitWithinViewportHeight: true,
|
|
3446
|
+
closeOnEscape: true,
|
|
3447
|
+
closeOnClickAway: true,
|
|
3448
|
+
placement: Placement.BOTTOM,
|
|
3449
|
+
isOpen: isOpen,
|
|
3450
|
+
...otherPopoverProps,
|
|
3451
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
3452
|
+
style: {
|
|
3453
|
+
...style,
|
|
3454
|
+
overflowY: 'auto',
|
|
3455
|
+
display: showPopover ? 'flex' : 'none',
|
|
3456
|
+
flexDirection: 'column'
|
|
3457
|
+
},
|
|
3458
|
+
children: [/*#__PURE__*/jsxs("ul", {
|
|
3459
|
+
ref: listRef,
|
|
3460
|
+
id: listboxId,
|
|
3461
|
+
role: type,
|
|
3462
|
+
"aria-label": label,
|
|
3463
|
+
className: block$Y([className, 'lumx-list lumx-list--item-padding-big']),
|
|
3464
|
+
style: {
|
|
3465
|
+
flex: 1,
|
|
3466
|
+
overflowY: 'auto'
|
|
3467
|
+
},
|
|
3468
|
+
...listProps,
|
|
3469
|
+
children: [!showFullLoading && children, [...FULL_LOADING_STATES, 'loadingMore'].includes(status) && /*#__PURE__*/jsx(ComboboxListSkeleton, {
|
|
3470
|
+
isLoadingMore: status === 'loadingMore',
|
|
3471
|
+
children: renderItemSkeleton
|
|
3472
|
+
})]
|
|
3473
|
+
}), footer, (isEmptyStateDisplayed || isErrorStateDisplayed) && /*#__PURE__*/jsx(GenericBlock, {
|
|
3474
|
+
className: element$K('state'),
|
|
3475
|
+
orientation: "vertical",
|
|
3476
|
+
vAlign: "center",
|
|
3477
|
+
children: /*#__PURE__*/jsxs(GenericBlock.Content, {
|
|
3478
|
+
children: [inputValue && isEmptyStateDisplayed && /*#__PURE__*/jsx(Text, {
|
|
3479
|
+
as: "p",
|
|
3480
|
+
typography: "body1",
|
|
3481
|
+
color: "dark",
|
|
3482
|
+
colorVariant: "L2",
|
|
3483
|
+
dangerouslySetInnerHTML: {
|
|
3484
|
+
__html: translations.noResultsForInputLabel(inputValue)
|
|
3485
|
+
}
|
|
3486
|
+
}), !inputValue && isEmptyStateDisplayed && /*#__PURE__*/jsx(Text, {
|
|
3487
|
+
as: "p",
|
|
3488
|
+
typography: "body1",
|
|
3489
|
+
color: "dark",
|
|
3490
|
+
colorVariant: "L2",
|
|
3491
|
+
children: translations.noResultsForInputLabel()
|
|
3492
|
+
}), isErrorStateDisplayed && /*#__PURE__*/jsxs(Fragment, {
|
|
3493
|
+
children: [/*#__PURE__*/jsx(Heading, {
|
|
3494
|
+
as: "h2",
|
|
3495
|
+
typography: "subtitle2",
|
|
3496
|
+
children: translations.serviceUnavailableLabel
|
|
3497
|
+
}), /*#__PURE__*/jsx(Text, {
|
|
3498
|
+
as: "p",
|
|
3499
|
+
typography: "body1",
|
|
3500
|
+
color: "dark",
|
|
3501
|
+
colorVariant: "L2",
|
|
3502
|
+
children: translations.tryReloadLabel
|
|
3503
|
+
})]
|
|
3504
|
+
})]
|
|
3505
|
+
})
|
|
3506
|
+
})]
|
|
3507
|
+
})
|
|
3508
|
+
})]
|
|
3509
|
+
});
|
|
3510
|
+
};
|
|
3511
|
+
|
|
3512
|
+
/**
|
|
3513
|
+
* Action to set on a Combobox Option.
|
|
3514
|
+
* Allows to add an interactive element that
|
|
3515
|
+
* can be navigated to and triggered using the keyboard.
|
|
3516
|
+
*
|
|
3517
|
+
* Defaults as "button"
|
|
3518
|
+
*
|
|
3519
|
+
* @family Combobox
|
|
3520
|
+
* @param ComboboxOptionActionProps
|
|
3521
|
+
* @returns ComboboxOptionAction
|
|
3522
|
+
*/
|
|
3523
|
+
const ComboboxOptionAction = props => {
|
|
3524
|
+
const {
|
|
3525
|
+
as,
|
|
3526
|
+
isDisabled,
|
|
3527
|
+
onClick,
|
|
3528
|
+
id: originalId,
|
|
3529
|
+
...forwardedProps
|
|
3530
|
+
} = props;
|
|
3531
|
+
const {
|
|
3532
|
+
optionId
|
|
3533
|
+
} = useComboboxOptionContext();
|
|
3534
|
+
const {
|
|
3535
|
+
triggerRef
|
|
3536
|
+
} = useComboboxRefs();
|
|
3537
|
+
const itemRef = React__default.useRef(null);
|
|
3538
|
+
const generatedId = useId();
|
|
3539
|
+
const id = originalId || generatedId;
|
|
3540
|
+
const isHighlighted = useVirtualFocus(id, itemRef, isDisabled, optionId);
|
|
3541
|
+
const {
|
|
3542
|
+
state
|
|
3543
|
+
} = React__default.useContext(MovingFocusContext);
|
|
3544
|
+
const Component = as || 'button';
|
|
3545
|
+
const registeredActionOption = React__default.useMemo(() => ({
|
|
3546
|
+
id,
|
|
3547
|
+
generatedId: id,
|
|
3548
|
+
isAction: true,
|
|
3549
|
+
isDisabled,
|
|
3550
|
+
onSelect: () => {
|
|
3551
|
+
itemRef.current?.click();
|
|
3552
|
+
}
|
|
3553
|
+
}), [id, isDisabled]);
|
|
3554
|
+
|
|
3555
|
+
// Register the option
|
|
3556
|
+
useRegisterOption(id, registeredActionOption, !isDisabled);
|
|
3557
|
+
const handleActionClick = React__default.useCallback(() => {
|
|
3558
|
+
if (onClick) {
|
|
3559
|
+
onClick();
|
|
3560
|
+
}
|
|
3561
|
+
if (triggerRef?.current) {
|
|
3562
|
+
triggerRef.current?.focus();
|
|
3563
|
+
}
|
|
3564
|
+
}, [triggerRef, onClick]);
|
|
3565
|
+
return /*#__PURE__*/jsx(Component, {
|
|
3566
|
+
...forwardedProps,
|
|
3567
|
+
isDisabled: isDisabled,
|
|
3568
|
+
id: id,
|
|
3569
|
+
role: "gridcell",
|
|
3570
|
+
ref: itemRef,
|
|
3571
|
+
"data-focus-visible-added": state.isUsingKeyboard && isHighlighted ? 'true' : undefined,
|
|
3572
|
+
"aria-disabled": isDisabled,
|
|
3573
|
+
onClick: handleActionClick
|
|
3574
|
+
});
|
|
3575
|
+
};
|
|
3576
|
+
|
|
3577
|
+
const useBooleanState = defaultValue => {
|
|
3578
|
+
const [booleanValue, setBoolean] = useState(defaultValue);
|
|
3579
|
+
const setToFalse = useCallback(() => setBoolean(false), []);
|
|
3580
|
+
const setToTrue = useCallback(() => setBoolean(true), []);
|
|
3581
|
+
const toggleBoolean = useCallback(() => setBoolean(previousValue => !previousValue), []);
|
|
3582
|
+
return [booleanValue, setToFalse, setToTrue, toggleBoolean];
|
|
3583
|
+
};
|
|
2116
3584
|
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
return {
|
|
2123
|
-
findPreviousEnabledChip
|
|
2124
|
-
};
|
|
2125
|
-
}
|
|
3585
|
+
const CLASSNAME$15 = 'lumx-combobox-option-more-info';
|
|
3586
|
+
const {
|
|
3587
|
+
block: block$X,
|
|
3588
|
+
element: element$J
|
|
3589
|
+
} = classNames.bem(CLASSNAME$15);
|
|
2126
3590
|
|
|
2127
3591
|
/**
|
|
2128
|
-
*
|
|
3592
|
+
* Display more info on the option as a popover opening on mouse hover or keyboard nav
|
|
3593
|
+
* Please consider using a simpler option description instead for better UX and a11y.
|
|
3594
|
+
*
|
|
3595
|
+
* @family Combobox
|
|
2129
3596
|
*/
|
|
2130
|
-
const
|
|
3597
|
+
const ComboboxOptionMoreInfo = ({
|
|
3598
|
+
buttonProps,
|
|
3599
|
+
popoverProps,
|
|
3600
|
+
onToggle,
|
|
3601
|
+
children
|
|
3602
|
+
}) => {
|
|
3603
|
+
const ref = React__default.useRef(null);
|
|
3604
|
+
const [isHovered,, onMouseLeave, onMouseEnter] = useBooleanState(false);
|
|
3605
|
+
const comboboxOption = useComboboxOptionContext();
|
|
3606
|
+
|
|
3607
|
+
// Open on mouse hover or key nav
|
|
3608
|
+
const isOpen = isHovered || comboboxOption.isKeyboardHighlighted;
|
|
3609
|
+
React__default.useEffect(() => {
|
|
3610
|
+
onToggle?.(isOpen);
|
|
3611
|
+
}, [isOpen, onToggle]);
|
|
3612
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
3613
|
+
children: [/*#__PURE__*/jsx(IconButton, {
|
|
3614
|
+
...buttonProps,
|
|
3615
|
+
ref: ref,
|
|
3616
|
+
className: block$X([buttonProps?.className]),
|
|
3617
|
+
icon: mdiInformationOutline,
|
|
3618
|
+
size: "s",
|
|
3619
|
+
emphasis: "low",
|
|
3620
|
+
onMouseEnter: onMouseEnter,
|
|
3621
|
+
onMouseLeave: onMouseLeave
|
|
3622
|
+
// Button actually plays no role here other than a target for the mouse hover
|
|
3623
|
+
// Keyboard accessibility is handled via combobox keyboard highlighting
|
|
3624
|
+
,
|
|
3625
|
+
"aria-hidden": true,
|
|
3626
|
+
label: ""
|
|
3627
|
+
}), /*#__PURE__*/jsx(Popover, {
|
|
3628
|
+
...popoverProps,
|
|
3629
|
+
className: element$J('popover', [popoverProps?.className]),
|
|
3630
|
+
anchorRef: ref,
|
|
3631
|
+
isOpen: isOpen,
|
|
3632
|
+
closeOnEscape: true,
|
|
3633
|
+
closeOnClickAway: true,
|
|
3634
|
+
placement: "bottom-start",
|
|
3635
|
+
children: children
|
|
3636
|
+
}), /*#__PURE__*/jsx(A11YLiveMessage, {
|
|
3637
|
+
hidden: true,
|
|
3638
|
+
children: isOpen ? children : undefined
|
|
3639
|
+
})]
|
|
3640
|
+
});
|
|
3641
|
+
};
|
|
3642
|
+
|
|
3643
|
+
const CLASSNAME$14 = 'lumx-combobox-section';
|
|
2131
3644
|
const {
|
|
2132
3645
|
block: block$W,
|
|
2133
3646
|
element: element$I
|
|
2134
3647
|
} = classNames.bem(CLASSNAME$14);
|
|
2135
3648
|
|
|
2136
3649
|
/**
|
|
2137
|
-
*
|
|
2138
|
-
*
|
|
2139
|
-
* @param props Component props.
|
|
2140
|
-
* @param ref Component ref.
|
|
2141
|
-
* @return React element.
|
|
3650
|
+
* Content of the ComboboxSection.
|
|
2142
3651
|
*/
|
|
2143
|
-
const
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
inputLabel,
|
|
2150
|
-
renderChip,
|
|
2151
|
-
theme,
|
|
2152
|
-
isDisabled,
|
|
2153
|
-
chipTooltipLabel,
|
|
2154
|
-
label,
|
|
2155
|
-
...forwardedProps
|
|
3652
|
+
const ComboboxSectionContent = ({
|
|
3653
|
+
className,
|
|
3654
|
+
title,
|
|
3655
|
+
children,
|
|
3656
|
+
isLoading,
|
|
3657
|
+
renderItemSkeleton
|
|
2156
3658
|
}) => {
|
|
2157
|
-
const chipRefs = React__default.useRef([]);
|
|
2158
3659
|
const {
|
|
2159
|
-
|
|
2160
|
-
} =
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
}
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
3660
|
+
options
|
|
3661
|
+
} = useCombobox();
|
|
3662
|
+
const {
|
|
3663
|
+
sectionId
|
|
3664
|
+
} = useComboboxSectionId();
|
|
3665
|
+
const hasRegisteredChildren = Boolean(Object.values(options).find(option => isComboboxValue(option) && option.sectionId === sectionId));
|
|
3666
|
+
const titleId = title && `${sectionId}-title`;
|
|
3667
|
+
if (!children && !isLoading) {
|
|
3668
|
+
return null;
|
|
3669
|
+
}
|
|
3670
|
+
const isHidden = !hasRegisteredChildren && !isLoading;
|
|
3671
|
+
return /*#__PURE__*/jsxs("li", {
|
|
3672
|
+
className: block$W([className]),
|
|
3673
|
+
role: !isHidden ? 'none' : undefined,
|
|
3674
|
+
"aria-hidden": isHidden,
|
|
3675
|
+
style: {
|
|
3676
|
+
display: isHidden ? 'none' : undefined
|
|
3677
|
+
},
|
|
3678
|
+
children: [title && /*#__PURE__*/jsx(Text, {
|
|
3679
|
+
as: "span",
|
|
3680
|
+
className: element$I('header', [ListSubheader.className]),
|
|
3681
|
+
"aria-hidden": "true",
|
|
3682
|
+
id: titleId,
|
|
3683
|
+
children: title
|
|
3684
|
+
}), /*#__PURE__*/jsxs("ul", {
|
|
3685
|
+
className: element$I('content'),
|
|
3686
|
+
role: "group",
|
|
3687
|
+
"aria-labelledby": titleId,
|
|
3688
|
+
children: [children, isLoading && /*#__PURE__*/jsx(ComboboxListSkeleton, {
|
|
3689
|
+
children: renderItemSkeleton
|
|
3690
|
+
})]
|
|
3691
|
+
})]
|
|
3692
|
+
});
|
|
3693
|
+
};
|
|
3694
|
+
|
|
3695
|
+
/**
|
|
3696
|
+
* Section for options of a Combobox.
|
|
3697
|
+
*
|
|
3698
|
+
* @family Combobox
|
|
3699
|
+
* @param ComboboxSectionProps
|
|
3700
|
+
* @returns ComboboxSection
|
|
3701
|
+
*/
|
|
3702
|
+
const ComboboxSection = ({
|
|
3703
|
+
children,
|
|
3704
|
+
...props
|
|
3705
|
+
}) => {
|
|
3706
|
+
const sectionId = useId();
|
|
3707
|
+
const value = React__default.useMemo(() => ({
|
|
3708
|
+
sectionId,
|
|
3709
|
+
isLoading: props.isLoading
|
|
3710
|
+
}), [sectionId, props.isLoading]);
|
|
3711
|
+
return /*#__PURE__*/jsx(SectionContext.Provider, {
|
|
3712
|
+
value: value,
|
|
3713
|
+
children: /*#__PURE__*/jsx(ComboboxSectionContent, {
|
|
3714
|
+
...props,
|
|
3715
|
+
children: children
|
|
3716
|
+
})
|
|
3717
|
+
});
|
|
3718
|
+
};
|
|
3719
|
+
|
|
3720
|
+
/** Context provider for the combobox. */
|
|
3721
|
+
const ComboboxProvider = ({
|
|
3722
|
+
children,
|
|
3723
|
+
value
|
|
3724
|
+
}) => {
|
|
3725
|
+
return /*#__PURE__*/jsx(ComboboxContext.Provider, {
|
|
3726
|
+
value: value,
|
|
3727
|
+
children: /*#__PURE__*/jsx(MovingFocusProvider, {
|
|
3728
|
+
options: {
|
|
3729
|
+
direction: value.type === 'grid' ? 'both' : 'vertical',
|
|
3730
|
+
firstFocusDirection: value.type === 'grid' ? 'vertical' : undefined,
|
|
3731
|
+
loopAround: {
|
|
3732
|
+
row: 'next-loop',
|
|
3733
|
+
col: 'inside'
|
|
3734
|
+
},
|
|
3735
|
+
gridJumpToShortcutDirection: 'vertical',
|
|
3736
|
+
defaultSelectedId: value.selectedIds?.[0],
|
|
3737
|
+
listKey: value.inputValue
|
|
3738
|
+
},
|
|
3739
|
+
children: children
|
|
3740
|
+
})
|
|
3741
|
+
});
|
|
3742
|
+
};
|
|
3743
|
+
|
|
3744
|
+
const Combobox$1 = ({
|
|
3745
|
+
id: htmlId,
|
|
3746
|
+
inputValue,
|
|
3747
|
+
defaultInputValue,
|
|
3748
|
+
autoFilter = true,
|
|
3749
|
+
openOnClick,
|
|
3750
|
+
openOnFocus,
|
|
3751
|
+
status,
|
|
3752
|
+
showEmptyState = !autoFilter,
|
|
3753
|
+
showErrorState = !!status,
|
|
3754
|
+
selectedIds,
|
|
3755
|
+
onInputChange,
|
|
3756
|
+
onSelect,
|
|
3757
|
+
onOpen,
|
|
3758
|
+
children,
|
|
3759
|
+
selectionType,
|
|
3760
|
+
translations
|
|
3761
|
+
}) => {
|
|
3762
|
+
const textFieldRef = useRef(null);
|
|
3763
|
+
const triggerRef = useRef(null);
|
|
3764
|
+
|
|
3765
|
+
// Generate a unique id for the combobox that will be used for every child components.
|
|
3766
|
+
const generatedId = useId();
|
|
3767
|
+
const comboboxId = htmlId || generatedId;
|
|
3768
|
+
const listboxId = `${comboboxId}-popover`;
|
|
3769
|
+
|
|
3770
|
+
/** Generate the selected option id from the given selected id. */
|
|
3771
|
+
const currentSelectedIds = selectedIds?.map(selectedId => generateOptionId(comboboxId, selectedId.toString()));
|
|
3772
|
+
|
|
3773
|
+
/** Generate the state */
|
|
3774
|
+
const [state, dispatch] = useReducer(reducer$1, initialState, defaultState => ({
|
|
3775
|
+
...defaultState,
|
|
3776
|
+
comboboxId,
|
|
3777
|
+
listboxId,
|
|
3778
|
+
// a default input value can be set if needed
|
|
3779
|
+
inputValue: defaultInputValue || defaultState.inputValue
|
|
3780
|
+
}));
|
|
3781
|
+
|
|
3782
|
+
/**
|
|
3783
|
+
* Return the current input value.
|
|
3784
|
+
*/
|
|
3785
|
+
const currentInputValue = useMemo(() => {
|
|
3786
|
+
// If the component is controlled and a value is already set by the parent, use this value
|
|
3787
|
+
if (inputValue !== null && inputValue !== undefined) {
|
|
3788
|
+
return inputValue;
|
|
3789
|
+
}
|
|
3790
|
+
|
|
3791
|
+
// Then use the local value
|
|
3792
|
+
if (state.inputValue) {
|
|
3793
|
+
return state.inputValue;
|
|
3794
|
+
}
|
|
3795
|
+
|
|
3796
|
+
// In all other cases, return an empty string.
|
|
3797
|
+
return '';
|
|
3798
|
+
}, [inputValue, state.inputValue]);
|
|
3799
|
+
|
|
3800
|
+
/** Return a memoized state */
|
|
3801
|
+
const synchedState = useMemo(() => {
|
|
3802
|
+
return {
|
|
3803
|
+
...state,
|
|
3804
|
+
showAll: !autoFilter || state.showAll,
|
|
3805
|
+
inputValue: currentInputValue,
|
|
3806
|
+
status: status || state.status,
|
|
3807
|
+
listboxId
|
|
3808
|
+
};
|
|
3809
|
+
}, [currentInputValue, listboxId, autoFilter, state, status]);
|
|
3810
|
+
|
|
3811
|
+
/** Props to set in the context */
|
|
3812
|
+
const comboboxProviderValue = useMemo(() => ({
|
|
3813
|
+
...synchedState,
|
|
3814
|
+
openOnFocus,
|
|
3815
|
+
openOnClick,
|
|
3816
|
+
onInputChange,
|
|
3817
|
+
onOpen,
|
|
3818
|
+
onSelect,
|
|
3819
|
+
dispatch,
|
|
3820
|
+
selectionType,
|
|
3821
|
+
selectedIds: currentSelectedIds,
|
|
3822
|
+
showEmptyState,
|
|
3823
|
+
showErrorState,
|
|
3824
|
+
translations
|
|
3825
|
+
}), [synchedState, openOnFocus, openOnClick, onInputChange, onOpen, onSelect, selectionType, currentSelectedIds, showEmptyState, showErrorState, translations]);
|
|
3826
|
+
return /*#__PURE__*/jsx(ComboboxRefsProvider, {
|
|
3827
|
+
triggerRef: triggerRef,
|
|
3828
|
+
anchorRef: textFieldRef,
|
|
3829
|
+
children: /*#__PURE__*/jsx(ComboboxProvider, {
|
|
3830
|
+
value: comboboxProviderValue,
|
|
3831
|
+
children: children
|
|
2219
3832
|
})
|
|
2220
3833
|
});
|
|
2221
3834
|
};
|
|
2222
3835
|
|
|
3836
|
+
const SUB_COMPONENTS = {
|
|
3837
|
+
/**
|
|
3838
|
+
* Option to set within a combobox list.
|
|
3839
|
+
*
|
|
3840
|
+
* @family Combobox
|
|
3841
|
+
* @param ComboboxOptionProps
|
|
3842
|
+
* @returns ComboboxOption
|
|
3843
|
+
*/
|
|
3844
|
+
Option: ComboboxOption,
|
|
3845
|
+
/**
|
|
3846
|
+
* Skeleton for a combobox option.
|
|
3847
|
+
* A typography skeleton is rendered by default but can be overridden by passing children.
|
|
3848
|
+
*/
|
|
3849
|
+
OptionSkeleton: ComboboxOptionSkeleton,
|
|
3850
|
+
/**
|
|
3851
|
+
* Section for options of a Combobox.
|
|
3852
|
+
*
|
|
3853
|
+
* @family Combobox
|
|
3854
|
+
* @param ComboboxSectionProps
|
|
3855
|
+
* @returns ComboboxSection
|
|
3856
|
+
*/
|
|
3857
|
+
Section: ComboboxSection,
|
|
3858
|
+
/**
|
|
3859
|
+
* Combobox input trigger.
|
|
3860
|
+
*
|
|
3861
|
+
* @family Combobox
|
|
3862
|
+
*/
|
|
3863
|
+
Input: ComboboxInput,
|
|
3864
|
+
/**
|
|
3865
|
+
* The listbox containing the combobox's options.
|
|
3866
|
+
*
|
|
3867
|
+
* @family Combobox
|
|
3868
|
+
* @param ComboboxListBoxProps
|
|
3869
|
+
* @returns ComboboxListBox
|
|
3870
|
+
*/
|
|
3871
|
+
List: ComboboxListBox,
|
|
3872
|
+
/**
|
|
3873
|
+
* Combobox button trigger.
|
|
3874
|
+
*
|
|
3875
|
+
* @family Combobox
|
|
3876
|
+
*/
|
|
3877
|
+
Button: ComboboxButton
|
|
3878
|
+
};
|
|
3879
|
+
|
|
3880
|
+
/**
|
|
3881
|
+
*
|
|
3882
|
+
* A Combobox is a combination of two components:
|
|
3883
|
+
* * An input to enter the user's value
|
|
3884
|
+
* * A popover with a list of suggestions to fill the value.
|
|
3885
|
+
*
|
|
3886
|
+
* These two components are included via the Combobox.Input and Combobox.ListBox components.
|
|
3887
|
+
*
|
|
3888
|
+
* In its simplest implementation the component will automatically filter the given options
|
|
3889
|
+
* from the value of the input and fill the input with the textValue of the selected option.
|
|
3890
|
+
*
|
|
3891
|
+
* Props are available for more complex implementations.
|
|
3892
|
+
*
|
|
3893
|
+
* @family Combobox
|
|
3894
|
+
* @param ComboboxProps
|
|
3895
|
+
* @returns Combobox
|
|
3896
|
+
*/
|
|
3897
|
+
const Combobox = Object.assign(Combobox$1, SUB_COMPONENTS);
|
|
3898
|
+
|
|
2223
3899
|
/**
|
|
2224
3900
|
* Comment block variants.
|
|
2225
3901
|
*/
|
|
@@ -2249,7 +3925,7 @@ const {
|
|
|
2249
3925
|
/**
|
|
2250
3926
|
* Component default props.
|
|
2251
3927
|
*/
|
|
2252
|
-
const DEFAULT_PROPS$
|
|
3928
|
+
const DEFAULT_PROPS$Z = {
|
|
2253
3929
|
variant: CommentBlockVariant.indented
|
|
2254
3930
|
};
|
|
2255
3931
|
|
|
@@ -2279,7 +3955,7 @@ const CommentBlock = forwardRef((props, ref) => {
|
|
|
2279
3955
|
onMouseLeave,
|
|
2280
3956
|
text,
|
|
2281
3957
|
theme = defaultTheme,
|
|
2282
|
-
variant = DEFAULT_PROPS$
|
|
3958
|
+
variant = DEFAULT_PROPS$Z.variant,
|
|
2283
3959
|
...forwardedProps
|
|
2284
3960
|
} = props;
|
|
2285
3961
|
const hasChildren = Children.count(children) > 0;
|
|
@@ -2348,7 +4024,7 @@ const CommentBlock = forwardRef((props, ref) => {
|
|
|
2348
4024
|
});
|
|
2349
4025
|
CommentBlock.displayName = COMPONENT_NAME$15;
|
|
2350
4026
|
CommentBlock.className = CLASSNAME$13;
|
|
2351
|
-
CommentBlock.defaultProps = DEFAULT_PROPS$
|
|
4027
|
+
CommentBlock.defaultProps = DEFAULT_PROPS$Z;
|
|
2352
4028
|
|
|
2353
4029
|
/**
|
|
2354
4030
|
* Add a number of months from a date while resetting the day to prevent month length mismatches.
|
|
@@ -2838,14 +4514,6 @@ const DatePicker = forwardRef((props, ref) => {
|
|
|
2838
4514
|
DatePicker.displayName = COMPONENT_NAME$14;
|
|
2839
4515
|
DatePicker.className = CLASSNAME$12;
|
|
2840
4516
|
|
|
2841
|
-
const useBooleanState = defaultValue => {
|
|
2842
|
-
const [booleanValue, setBoolean] = useState(defaultValue);
|
|
2843
|
-
const setToFalse = useCallback(() => setBoolean(false), []);
|
|
2844
|
-
const setToTrue = useCallback(() => setBoolean(true), []);
|
|
2845
|
-
const toggleBoolean = useCallback(() => setBoolean(previousValue => !previousValue), []);
|
|
2846
|
-
return [booleanValue, setToFalse, setToTrue, toggleBoolean];
|
|
2847
|
-
};
|
|
2848
|
-
|
|
2849
4517
|
/**
|
|
2850
4518
|
* Component display name.
|
|
2851
4519
|
*/
|
|
@@ -3453,7 +5121,7 @@ const {
|
|
|
3453
5121
|
/**
|
|
3454
5122
|
* Component default props.
|
|
3455
5123
|
*/
|
|
3456
|
-
const DEFAULT_PROPS$
|
|
5124
|
+
const DEFAULT_PROPS$Y = {
|
|
3457
5125
|
size: Size$1.big,
|
|
3458
5126
|
disableBodyScroll: true
|
|
3459
5127
|
};
|
|
@@ -3484,11 +5152,11 @@ const Dialog = forwardRef((props, ref) => {
|
|
|
3484
5152
|
parentElement,
|
|
3485
5153
|
contentRef,
|
|
3486
5154
|
preventAutoClose,
|
|
3487
|
-
size = DEFAULT_PROPS$
|
|
5155
|
+
size = DEFAULT_PROPS$Y.size,
|
|
3488
5156
|
zIndex,
|
|
3489
5157
|
dialogProps,
|
|
3490
5158
|
onVisibilityChange,
|
|
3491
|
-
disableBodyScroll = DEFAULT_PROPS$
|
|
5159
|
+
disableBodyScroll = DEFAULT_PROPS$Y.disableBodyScroll,
|
|
3492
5160
|
preventCloseOnClick,
|
|
3493
5161
|
preventCloseOnEscape,
|
|
3494
5162
|
...forwardedProps
|
|
@@ -3628,7 +5296,7 @@ const Dialog = forwardRef((props, ref) => {
|
|
|
3628
5296
|
});
|
|
3629
5297
|
Dialog.displayName = COMPONENT_NAME$11;
|
|
3630
5298
|
Dialog.className = CLASSNAME$11;
|
|
3631
|
-
Dialog.defaultProps = DEFAULT_PROPS$
|
|
5299
|
+
Dialog.defaultProps = DEFAULT_PROPS$Y;
|
|
3632
5300
|
|
|
3633
5301
|
/**
|
|
3634
5302
|
* Component display name.
|
|
@@ -3672,7 +5340,7 @@ const Divider$1 = props => {
|
|
|
3672
5340
|
/**
|
|
3673
5341
|
* Component default props.
|
|
3674
5342
|
*/
|
|
3675
|
-
const DEFAULT_PROPS$
|
|
5343
|
+
const DEFAULT_PROPS$X = {};
|
|
3676
5344
|
|
|
3677
5345
|
/**
|
|
3678
5346
|
* Divider component.
|
|
@@ -3695,7 +5363,7 @@ const Divider = forwardRef((props, ref) => {
|
|
|
3695
5363
|
});
|
|
3696
5364
|
Divider.displayName = COMPONENT_NAME$10;
|
|
3697
5365
|
Divider.className = CLASSNAME$10;
|
|
3698
|
-
Divider.defaultProps = DEFAULT_PROPS$
|
|
5366
|
+
Divider.defaultProps = DEFAULT_PROPS$X;
|
|
3699
5367
|
|
|
3700
5368
|
/**
|
|
3701
5369
|
* Component display name.
|
|
@@ -3920,7 +5588,7 @@ const {
|
|
|
3920
5588
|
/**
|
|
3921
5589
|
* Component default props.
|
|
3922
5590
|
*/
|
|
3923
|
-
const DEFAULT_PROPS$
|
|
5591
|
+
const DEFAULT_PROPS$W = {
|
|
3924
5592
|
tabIndex: -1
|
|
3925
5593
|
};
|
|
3926
5594
|
|
|
@@ -3939,7 +5607,7 @@ const InternalList = forwardRef((props, ref) => {
|
|
|
3939
5607
|
isClickable,
|
|
3940
5608
|
itemPadding,
|
|
3941
5609
|
onListItemSelected,
|
|
3942
|
-
tabIndex = DEFAULT_PROPS$
|
|
5610
|
+
tabIndex = DEFAULT_PROPS$W.tabIndex,
|
|
3943
5611
|
...forwardedProps
|
|
3944
5612
|
} = props;
|
|
3945
5613
|
const adjustedItemPadding = itemPadding ?? (isClickable ? Size$1.big : undefined);
|
|
@@ -3955,7 +5623,7 @@ const InternalList = forwardRef((props, ref) => {
|
|
|
3955
5623
|
});
|
|
3956
5624
|
InternalList.displayName = COMPONENT_NAME$_;
|
|
3957
5625
|
InternalList.className = CLASSNAME$_;
|
|
3958
|
-
InternalList.defaultProps = DEFAULT_PROPS$
|
|
5626
|
+
InternalList.defaultProps = DEFAULT_PROPS$W;
|
|
3959
5627
|
const List = Object.assign(InternalList, {
|
|
3960
5628
|
useKeyboardListNavigation
|
|
3961
5629
|
});
|
|
@@ -4074,7 +5742,7 @@ function getNodeName(element) {
|
|
|
4074
5742
|
return element ? (element.nodeName || '').toLowerCase() : null;
|
|
4075
5743
|
}
|
|
4076
5744
|
|
|
4077
|
-
/*:: import type { Window } from '../types
|
|
5745
|
+
/*:: import type { Window } from '../types'; */
|
|
4078
5746
|
|
|
4079
5747
|
/*:: declare function getWindow(node: Node | Window): Window; */
|
|
4080
5748
|
function getWindow(node) {
|
|
@@ -6400,7 +8068,7 @@ const {
|
|
|
6400
8068
|
/**
|
|
6401
8069
|
* Component default props.
|
|
6402
8070
|
*/
|
|
6403
|
-
const DEFAULT_PROPS$
|
|
8071
|
+
const DEFAULT_PROPS$V = {
|
|
6404
8072
|
elevation: 3,
|
|
6405
8073
|
placement: Placement.AUTO,
|
|
6406
8074
|
focusAnchorOnClose: true,
|
|
@@ -6417,24 +8085,24 @@ const _InnerPopover = forwardRef((props, ref) => {
|
|
|
6417
8085
|
className,
|
|
6418
8086
|
closeOnClickAway,
|
|
6419
8087
|
closeOnEscape,
|
|
6420
|
-
elevation = DEFAULT_PROPS$
|
|
8088
|
+
elevation = DEFAULT_PROPS$V.elevation,
|
|
6421
8089
|
focusElement,
|
|
6422
8090
|
hasArrow,
|
|
6423
8091
|
isOpen,
|
|
6424
8092
|
onClose,
|
|
6425
8093
|
parentElement,
|
|
6426
|
-
usePortal = DEFAULT_PROPS$
|
|
6427
|
-
focusAnchorOnClose = DEFAULT_PROPS$
|
|
8094
|
+
usePortal = DEFAULT_PROPS$V.usePortal,
|
|
8095
|
+
focusAnchorOnClose = DEFAULT_PROPS$V.focusAnchorOnClose,
|
|
6428
8096
|
withFocusTrap,
|
|
6429
8097
|
boundaryRef,
|
|
6430
8098
|
fitToAnchorWidth,
|
|
6431
8099
|
fitWithinViewportHeight,
|
|
6432
8100
|
focusTrapZoneElement,
|
|
6433
8101
|
offset,
|
|
6434
|
-
placement = DEFAULT_PROPS$
|
|
8102
|
+
placement = DEFAULT_PROPS$V.placement,
|
|
6435
8103
|
style,
|
|
6436
8104
|
theme,
|
|
6437
|
-
zIndex = DEFAULT_PROPS$
|
|
8105
|
+
zIndex = DEFAULT_PROPS$V.zIndex,
|
|
6438
8106
|
...forwardedProps
|
|
6439
8107
|
} = props;
|
|
6440
8108
|
const popoverRef = useRef(null);
|
|
@@ -6520,7 +8188,7 @@ const Popover = skipRender(
|
|
|
6520
8188
|
() => Boolean(DOCUMENT), _InnerPopover);
|
|
6521
8189
|
Popover.displayName = COMPONENT_NAME$Z;
|
|
6522
8190
|
Popover.className = CLASSNAME$Z;
|
|
6523
|
-
Popover.defaultProps = DEFAULT_PROPS$
|
|
8191
|
+
Popover.defaultProps = DEFAULT_PROPS$V;
|
|
6524
8192
|
|
|
6525
8193
|
// The error margin in px we want to have for triggering infinite scroll
|
|
6526
8194
|
const SCROLL_TRIGGER_MARGIN = 5;
|
|
@@ -6580,7 +8248,7 @@ const {
|
|
|
6580
8248
|
/**
|
|
6581
8249
|
* Component default props.
|
|
6582
8250
|
*/
|
|
6583
|
-
const DEFAULT_PROPS$
|
|
8251
|
+
const DEFAULT_PROPS$U = {
|
|
6584
8252
|
closeOnClick: true,
|
|
6585
8253
|
closeOnClickAway: true,
|
|
6586
8254
|
closeOnEscape: true,
|
|
@@ -6603,18 +8271,18 @@ const Dropdown = forwardRef((props, ref) => {
|
|
|
6603
8271
|
anchorRef,
|
|
6604
8272
|
children,
|
|
6605
8273
|
className,
|
|
6606
|
-
closeOnClick = DEFAULT_PROPS$
|
|
6607
|
-
closeOnClickAway = DEFAULT_PROPS$
|
|
6608
|
-
closeOnEscape = DEFAULT_PROPS$
|
|
6609
|
-
fitToAnchorWidth = DEFAULT_PROPS$
|
|
6610
|
-
fitWithinViewportHeight = DEFAULT_PROPS$
|
|
8274
|
+
closeOnClick = DEFAULT_PROPS$U.closeOnClick,
|
|
8275
|
+
closeOnClickAway = DEFAULT_PROPS$U.closeOnClickAway,
|
|
8276
|
+
closeOnEscape = DEFAULT_PROPS$U.closeOnEscape,
|
|
8277
|
+
fitToAnchorWidth = DEFAULT_PROPS$U.fitToAnchorWidth,
|
|
8278
|
+
fitWithinViewportHeight = DEFAULT_PROPS$U.fitWithinViewportHeight,
|
|
6611
8279
|
isOpen,
|
|
6612
8280
|
offset,
|
|
6613
|
-
focusAnchorOnClose = DEFAULT_PROPS$
|
|
8281
|
+
focusAnchorOnClose = DEFAULT_PROPS$U.focusAnchorOnClose,
|
|
6614
8282
|
onClose,
|
|
6615
8283
|
onInfiniteScroll,
|
|
6616
|
-
placement = DEFAULT_PROPS$
|
|
6617
|
-
shouldFocusOnOpen = DEFAULT_PROPS$
|
|
8284
|
+
placement = DEFAULT_PROPS$U.placement,
|
|
8285
|
+
shouldFocusOnOpen = DEFAULT_PROPS$U.shouldFocusOnOpen,
|
|
6618
8286
|
zIndex,
|
|
6619
8287
|
...forwardedProps
|
|
6620
8288
|
} = props;
|
|
@@ -6660,7 +8328,7 @@ const Dropdown = forwardRef((props, ref) => {
|
|
|
6660
8328
|
});
|
|
6661
8329
|
Dropdown.displayName = COMPONENT_NAME$Y;
|
|
6662
8330
|
Dropdown.className = CLASSNAME$Y;
|
|
6663
|
-
Dropdown.defaultProps = DEFAULT_PROPS$
|
|
8331
|
+
Dropdown.defaultProps = DEFAULT_PROPS$U;
|
|
6664
8332
|
|
|
6665
8333
|
/**
|
|
6666
8334
|
* Component display name.
|
|
@@ -6679,7 +8347,7 @@ const {
|
|
|
6679
8347
|
/**
|
|
6680
8348
|
* Component default props.
|
|
6681
8349
|
*/
|
|
6682
|
-
const DEFAULT_PROPS$
|
|
8350
|
+
const DEFAULT_PROPS$T = {
|
|
6683
8351
|
closeMode: 'unmount'
|
|
6684
8352
|
};
|
|
6685
8353
|
const isDragHandle = isComponent(DragHandle);
|
|
@@ -6697,7 +8365,7 @@ const ExpansionPanel = forwardRef((props, ref) => {
|
|
|
6697
8365
|
const defaultTheme = useTheme() || Theme$1.light;
|
|
6698
8366
|
const {
|
|
6699
8367
|
className,
|
|
6700
|
-
closeMode = DEFAULT_PROPS$
|
|
8368
|
+
closeMode = DEFAULT_PROPS$T.closeMode,
|
|
6701
8369
|
children: anyChildren,
|
|
6702
8370
|
hasBackground,
|
|
6703
8371
|
hasHeaderDivider,
|
|
@@ -6814,11 +8482,11 @@ const ExpansionPanel = forwardRef((props, ref) => {
|
|
|
6814
8482
|
});
|
|
6815
8483
|
ExpansionPanel.displayName = COMPONENT_NAME$X;
|
|
6816
8484
|
ExpansionPanel.className = CLASSNAME$X;
|
|
6817
|
-
ExpansionPanel.defaultProps = DEFAULT_PROPS$
|
|
8485
|
+
ExpansionPanel.defaultProps = DEFAULT_PROPS$T;
|
|
6818
8486
|
|
|
6819
8487
|
const COMPONENT_NAME$W = 'Flag';
|
|
6820
8488
|
const CLASSNAME$W = 'lumx-flag';
|
|
6821
|
-
const DEFAULT_PROPS$
|
|
8489
|
+
const DEFAULT_PROPS$S = {};
|
|
6822
8490
|
const {
|
|
6823
8491
|
block: block$N,
|
|
6824
8492
|
element: element$B
|
|
@@ -6882,7 +8550,7 @@ const Flag = forwardRef((props, ref) => {
|
|
|
6882
8550
|
});
|
|
6883
8551
|
Flag.displayName = COMPONENT_NAME$W;
|
|
6884
8552
|
Flag.className = CLASSNAME$W;
|
|
6885
|
-
Flag.defaultProps = DEFAULT_PROPS$
|
|
8553
|
+
Flag.defaultProps = DEFAULT_PROPS$S;
|
|
6886
8554
|
|
|
6887
8555
|
/**
|
|
6888
8556
|
* Defines the props of the component.
|
|
@@ -6975,7 +8643,7 @@ const {
|
|
|
6975
8643
|
/**
|
|
6976
8644
|
* Component default props.
|
|
6977
8645
|
*/
|
|
6978
|
-
const DEFAULT_PROPS$
|
|
8646
|
+
const DEFAULT_PROPS$R = {
|
|
6979
8647
|
gap: Size$1.big,
|
|
6980
8648
|
orientation: Orientation$1.horizontal
|
|
6981
8649
|
};
|
|
@@ -7005,8 +8673,8 @@ const BaseGenericBlock = forwardRef((props, ref) => {
|
|
|
7005
8673
|
children,
|
|
7006
8674
|
actions,
|
|
7007
8675
|
actionsProps,
|
|
7008
|
-
gap = DEFAULT_PROPS$
|
|
7009
|
-
orientation = DEFAULT_PROPS$
|
|
8676
|
+
gap = DEFAULT_PROPS$R.gap,
|
|
8677
|
+
orientation = DEFAULT_PROPS$R.orientation,
|
|
7010
8678
|
contentProps,
|
|
7011
8679
|
...forwardedProps
|
|
7012
8680
|
} = props;
|
|
@@ -7060,7 +8728,7 @@ const BaseGenericBlock = forwardRef((props, ref) => {
|
|
|
7060
8728
|
});
|
|
7061
8729
|
BaseGenericBlock.displayName = COMPONENT_NAME$U;
|
|
7062
8730
|
BaseGenericBlock.className = CLASSNAME$U;
|
|
7063
|
-
BaseGenericBlock.defaultProps = DEFAULT_PROPS$
|
|
8731
|
+
BaseGenericBlock.defaultProps = DEFAULT_PROPS$R;
|
|
7064
8732
|
const GenericBlock = Object.assign(BaseGenericBlock, {
|
|
7065
8733
|
Figure,
|
|
7066
8734
|
Content,
|
|
@@ -7108,7 +8776,7 @@ const CLASSNAME$T = 'lumx-heading';
|
|
|
7108
8776
|
/**
|
|
7109
8777
|
* Component default props.
|
|
7110
8778
|
*/
|
|
7111
|
-
const DEFAULT_PROPS$
|
|
8779
|
+
const DEFAULT_PROPS$Q = {};
|
|
7112
8780
|
|
|
7113
8781
|
/**
|
|
7114
8782
|
* Get Heading component common props
|
|
@@ -7209,7 +8877,7 @@ const {
|
|
|
7209
8877
|
/**
|
|
7210
8878
|
* Component default props.
|
|
7211
8879
|
*/
|
|
7212
|
-
const DEFAULT_PROPS$
|
|
8880
|
+
const DEFAULT_PROPS$P = {};
|
|
7213
8881
|
|
|
7214
8882
|
/**
|
|
7215
8883
|
* Text component common props
|
|
@@ -7296,7 +8964,7 @@ const Text = forwardRef((props, ref) => {
|
|
|
7296
8964
|
});
|
|
7297
8965
|
Text.displayName = COMPONENT_NAME$S;
|
|
7298
8966
|
Text.className = CLASSNAME$S;
|
|
7299
|
-
Text.defaultProps = DEFAULT_PROPS$
|
|
8967
|
+
Text.defaultProps = DEFAULT_PROPS$P;
|
|
7300
8968
|
|
|
7301
8969
|
const HeadingLevelContext = /*#__PURE__*/createContext(defaultContext);
|
|
7302
8970
|
|
|
@@ -7333,7 +9001,7 @@ const Heading = forwardRef((props, ref) => {
|
|
|
7333
9001
|
});
|
|
7334
9002
|
Heading.displayName = COMPONENT_NAME$T;
|
|
7335
9003
|
Heading.className = CLASSNAME$T;
|
|
7336
|
-
Heading.defaultProps = DEFAULT_PROPS$
|
|
9004
|
+
Heading.defaultProps = DEFAULT_PROPS$Q;
|
|
7337
9005
|
|
|
7338
9006
|
/**
|
|
7339
9007
|
* Computes the next heading level based on the optional prop level or the parent context level.
|
|
@@ -7384,7 +9052,7 @@ const {
|
|
|
7384
9052
|
/**
|
|
7385
9053
|
* Component default props.
|
|
7386
9054
|
*/
|
|
7387
|
-
const DEFAULT_PROPS$
|
|
9055
|
+
const DEFAULT_PROPS$O = {
|
|
7388
9056
|
orientation: Orientation$1.horizontal,
|
|
7389
9057
|
wrap: 'nowrap'
|
|
7390
9058
|
};
|
|
@@ -7402,9 +9070,9 @@ const Grid = forwardRef((props, ref) => {
|
|
|
7402
9070
|
className,
|
|
7403
9071
|
gutter,
|
|
7404
9072
|
hAlign,
|
|
7405
|
-
orientation = DEFAULT_PROPS$
|
|
9073
|
+
orientation = DEFAULT_PROPS$O.orientation,
|
|
7406
9074
|
vAlign,
|
|
7407
|
-
wrap = DEFAULT_PROPS$
|
|
9075
|
+
wrap = DEFAULT_PROPS$O.wrap,
|
|
7408
9076
|
...forwardedProps
|
|
7409
9077
|
} = props;
|
|
7410
9078
|
return /*#__PURE__*/jsx("div", {
|
|
@@ -7422,7 +9090,7 @@ const Grid = forwardRef((props, ref) => {
|
|
|
7422
9090
|
});
|
|
7423
9091
|
Grid.displayName = COMPONENT_NAME$R;
|
|
7424
9092
|
Grid.className = CLASSNAME$R;
|
|
7425
|
-
Grid.defaultProps = DEFAULT_PROPS$
|
|
9093
|
+
Grid.defaultProps = DEFAULT_PROPS$O;
|
|
7426
9094
|
|
|
7427
9095
|
/**
|
|
7428
9096
|
* Component display name.
|
|
@@ -7480,7 +9148,7 @@ const CLASSNAME$P = 'lumx-grid-column';
|
|
|
7480
9148
|
/**
|
|
7481
9149
|
* Component default props.
|
|
7482
9150
|
*/
|
|
7483
|
-
const DEFAULT_PROPS$
|
|
9151
|
+
const DEFAULT_PROPS$N = {};
|
|
7484
9152
|
|
|
7485
9153
|
/**
|
|
7486
9154
|
* The GridColumn is a layout component that can display children in a grid
|
|
@@ -7488,10 +9156,9 @@ const DEFAULT_PROPS$M = {};
|
|
|
7488
9156
|
* with a number of column that reduce when there is not enough space for each item.
|
|
7489
9157
|
*
|
|
7490
9158
|
* @param props Component props.
|
|
7491
|
-
* @
|
|
7492
|
-
* @return React element.
|
|
9159
|
+
* @return JSX element.
|
|
7493
9160
|
*/
|
|
7494
|
-
const GridColumn =
|
|
9161
|
+
const GridColumn$1 = props => {
|
|
7495
9162
|
const {
|
|
7496
9163
|
as: Component = 'div',
|
|
7497
9164
|
gap,
|
|
@@ -7500,12 +9167,13 @@ const GridColumn = forwardRef((props, ref) => {
|
|
|
7500
9167
|
children,
|
|
7501
9168
|
className,
|
|
7502
9169
|
style = {},
|
|
9170
|
+
ref,
|
|
7503
9171
|
...forwardedProps
|
|
7504
9172
|
} = props;
|
|
7505
9173
|
return /*#__PURE__*/jsx(Component, {
|
|
7506
9174
|
...forwardedProps,
|
|
7507
9175
|
ref: ref,
|
|
7508
|
-
className:
|
|
9176
|
+
className: classnames(className, CLASSNAME$P),
|
|
7509
9177
|
style: {
|
|
7510
9178
|
...style,
|
|
7511
9179
|
['--lumx-grid-column-item-min-width']: isInteger(itemMinWidth) && `${itemMinWidth}px`,
|
|
@@ -7514,6 +9182,36 @@ const GridColumn = forwardRef((props, ref) => {
|
|
|
7514
9182
|
},
|
|
7515
9183
|
children: children
|
|
7516
9184
|
});
|
|
9185
|
+
};
|
|
9186
|
+
GridColumn$1.displayName = COMPONENT_NAME$P;
|
|
9187
|
+
GridColumn$1.className = CLASSNAME$P;
|
|
9188
|
+
GridColumn$1.defaultProps = DEFAULT_PROPS$N;
|
|
9189
|
+
|
|
9190
|
+
/**
|
|
9191
|
+
* Defines the props of the component.
|
|
9192
|
+
*/
|
|
9193
|
+
|
|
9194
|
+
// Re-export types for backward compatibility
|
|
9195
|
+
|
|
9196
|
+
/**
|
|
9197
|
+
* Component default props.
|
|
9198
|
+
*/
|
|
9199
|
+
const DEFAULT_PROPS$M = {};
|
|
9200
|
+
|
|
9201
|
+
/**
|
|
9202
|
+
* The GridColumn is a layout component that can display children in a grid
|
|
9203
|
+
* with custom display properties. It also comes with a responsive design,
|
|
9204
|
+
* with a number of column that reduce when there is not enough space for each item.
|
|
9205
|
+
*
|
|
9206
|
+
* @param props Component props.
|
|
9207
|
+
* @param ref Component ref.
|
|
9208
|
+
* @return React element.
|
|
9209
|
+
*/
|
|
9210
|
+
const GridColumn = forwardRef((props, ref) => {
|
|
9211
|
+
return GridColumn$1({
|
|
9212
|
+
ref,
|
|
9213
|
+
...props
|
|
9214
|
+
});
|
|
7517
9215
|
});
|
|
7518
9216
|
GridColumn.displayName = COMPONENT_NAME$P;
|
|
7519
9217
|
GridColumn.className = CLASSNAME$P;
|
|
@@ -15304,5 +17002,5 @@ UserBlock.displayName = COMPONENT_NAME;
|
|
|
15304
17002
|
UserBlock.className = CLASSNAME;
|
|
15305
17003
|
UserBlock.defaultProps = DEFAULT_PROPS;
|
|
15306
17004
|
|
|
15307
|
-
export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonGroup,
|
|
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 };
|
|
15308
17006
|
//# sourceMappingURL=index.js.map
|