@lumx/react 4.3.2-alpha.18 → 4.3.2-alpha.19
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/CzTdCnO5.js +1375 -0
- package/_internal/CzTdCnO5.js.map +1 -0
- package/index.d.ts +424 -7
- package/index.js +754 -112
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/utils/index.js +3 -1217
- 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,8 +1,8 @@
|
|
|
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';
|
|
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
2
|
export * from '@lumx/core/js/constants';
|
|
3
3
|
export * from '@lumx/core/js/types';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, { useState, useEffect, useMemo, useRef, useCallback, Children, useLayoutEffect, cloneElement,
|
|
5
|
+
import React__default, { useState, useEffect, useMemo, useRef, useCallback, useContext, createContext, Children, useLayoutEffect, cloneElement, isValidElement, useReducer } from 'react';
|
|
6
6
|
import { mdiAlert } from '@lumx/icons/esm/alert';
|
|
7
7
|
import { mdiAlertCircle } from '@lumx/icons/esm/alert-circle';
|
|
8
8
|
import { mdiCheckCircle } from '@lumx/icons/esm/check-circle';
|
|
@@ -16,7 +16,7 @@ import concat from 'lodash/concat';
|
|
|
16
16
|
import dropRight from 'lodash/dropRight';
|
|
17
17
|
import partition from 'lodash/partition';
|
|
18
18
|
import reduce from 'lodash/reduce';
|
|
19
|
-
import { u as useDisabledStateContext, P as Portal, C as ClickAwayProvider } from './_internal/
|
|
19
|
+
import { u as useDisabledStateContext, M as MovingFocusContext, a as useVirtualFocus, A as A11YLiveMessage, P as Portal, C as ClickAwayProvider } from './_internal/CzTdCnO5.js';
|
|
20
20
|
import isEmpty from 'lodash/isEmpty';
|
|
21
21
|
import { getDisabledState } from '@lumx/core/js/utils/disabledState';
|
|
22
22
|
import { mdiCloseCircle } from '@lumx/icons/esm/close-circle';
|
|
@@ -24,15 +24,17 @@ import memoize from 'lodash/memoize';
|
|
|
24
24
|
import { mdiClose } from '@lumx/icons/esm/close';
|
|
25
25
|
import isFunction from 'lodash/isFunction';
|
|
26
26
|
import { mdiImageBroken } from '@lumx/icons/esm/image-broken';
|
|
27
|
+
import noop from 'lodash/noop';
|
|
28
|
+
import uniqueId from 'lodash/uniqueId';
|
|
29
|
+
import castArray from 'lodash/castArray';
|
|
27
30
|
import { mdiCheck } from '@lumx/icons/esm/check';
|
|
28
31
|
import { mdiMinus } from '@lumx/icons/esm/minus';
|
|
32
|
+
import { mdiInformationOutline } from '@lumx/icons/esm/information-outline';
|
|
29
33
|
import { mdiChevronLeft } from '@lumx/icons/esm/chevron-left';
|
|
30
34
|
import { mdiChevronRight } from '@lumx/icons/esm/chevron-right';
|
|
31
|
-
import castArray from 'lodash/castArray';
|
|
32
35
|
import { mdiDragVertical } from '@lumx/icons/esm/drag-vertical';
|
|
33
36
|
import { mdiChevronDown } from '@lumx/icons/esm/chevron-down';
|
|
34
37
|
import { mdiChevronUp } from '@lumx/icons/esm/chevron-up';
|
|
35
|
-
import noop from 'lodash/noop';
|
|
36
38
|
import pick from 'lodash/pick';
|
|
37
39
|
import isInteger from 'lodash/isInteger';
|
|
38
40
|
import { mdiMagnifyMinusOutline } from '@lumx/icons/esm/magnify-minus-outline';
|
|
@@ -101,10 +103,10 @@ const COMPONENT_NAME$1l = 'AlertDialog';
|
|
|
101
103
|
/**
|
|
102
104
|
* Component default class name and class prefix.
|
|
103
105
|
*/
|
|
104
|
-
const CLASSNAME$
|
|
106
|
+
const CLASSNAME$1k = 'lumx-alert-dialog';
|
|
105
107
|
const {
|
|
106
|
-
block: block$
|
|
107
|
-
} = classNames.bem(CLASSNAME$
|
|
108
|
+
block: block$17
|
|
109
|
+
} = classNames.bem(CLASSNAME$1k);
|
|
108
110
|
|
|
109
111
|
/**
|
|
110
112
|
* Component default props.
|
|
@@ -172,7 +174,7 @@ const AlertDialog = forwardRef((props, ref) => {
|
|
|
172
174
|
'aria-describedby': descriptionId,
|
|
173
175
|
...dialogProps
|
|
174
176
|
},
|
|
175
|
-
className: classNames.join(className, block$
|
|
177
|
+
className: classNames.join(className, block$17({
|
|
176
178
|
[`kind-${kind}`]: Boolean(kind)
|
|
177
179
|
})),
|
|
178
180
|
...forwardedProps,
|
|
@@ -218,7 +220,7 @@ const AlertDialog = forwardRef((props, ref) => {
|
|
|
218
220
|
});
|
|
219
221
|
});
|
|
220
222
|
AlertDialog.displayName = COMPONENT_NAME$1l;
|
|
221
|
-
AlertDialog.className = CLASSNAME$
|
|
223
|
+
AlertDialog.className = CLASSNAME$1k;
|
|
222
224
|
AlertDialog.defaultProps = DEFAULT_PROPS$1b;
|
|
223
225
|
|
|
224
226
|
/**
|
|
@@ -316,7 +318,7 @@ const COMPONENT_NAME$1k = 'Autocomplete';
|
|
|
316
318
|
/**
|
|
317
319
|
* Component default class name and class prefix.
|
|
318
320
|
*/
|
|
319
|
-
const CLASSNAME$
|
|
321
|
+
const CLASSNAME$1j = 'lumx-autocomplete';
|
|
320
322
|
|
|
321
323
|
/**
|
|
322
324
|
* Component default props.
|
|
@@ -383,7 +385,7 @@ const Autocomplete = forwardRef((props, ref) => {
|
|
|
383
385
|
return /*#__PURE__*/jsxs("div", {
|
|
384
386
|
ref: ref,
|
|
385
387
|
...forwardedProps,
|
|
386
|
-
className: classNames.join(className, CLASSNAME$
|
|
388
|
+
className: classNames.join(className, CLASSNAME$1j),
|
|
387
389
|
children: [/*#__PURE__*/jsx(TextField, {
|
|
388
390
|
...textFieldProps,
|
|
389
391
|
chips: chips,
|
|
@@ -424,7 +426,7 @@ const Autocomplete = forwardRef((props, ref) => {
|
|
|
424
426
|
});
|
|
425
427
|
});
|
|
426
428
|
Autocomplete.displayName = COMPONENT_NAME$1k;
|
|
427
|
-
Autocomplete.className = CLASSNAME$
|
|
429
|
+
Autocomplete.className = CLASSNAME$1j;
|
|
428
430
|
Autocomplete.defaultProps = DEFAULT_PROPS$1a;
|
|
429
431
|
|
|
430
432
|
/**
|
|
@@ -435,7 +437,7 @@ const COMPONENT_NAME$1j = 'AutocompleteMultiple';
|
|
|
435
437
|
/**
|
|
436
438
|
* Component default class name and class prefix.
|
|
437
439
|
*/
|
|
438
|
-
const CLASSNAME$
|
|
440
|
+
const CLASSNAME$1i = 'lumx-autocomplete-multiple';
|
|
439
441
|
|
|
440
442
|
/**
|
|
441
443
|
* Component default props.
|
|
@@ -515,7 +517,7 @@ const AutocompleteMultiple = forwardRef((props, ref) => {
|
|
|
515
517
|
ref: ref,
|
|
516
518
|
...forwardedProps,
|
|
517
519
|
anchorToInput: anchorToInput,
|
|
518
|
-
className: classNames.join(className, CLASSNAME$
|
|
520
|
+
className: classNames.join(className, CLASSNAME$1i),
|
|
519
521
|
name: name,
|
|
520
522
|
value: value,
|
|
521
523
|
onChange: onChange,
|
|
@@ -549,7 +551,7 @@ const AutocompleteMultiple = forwardRef((props, ref) => {
|
|
|
549
551
|
});
|
|
550
552
|
});
|
|
551
553
|
AutocompleteMultiple.displayName = COMPONENT_NAME$1j;
|
|
552
|
-
AutocompleteMultiple.className = CLASSNAME$
|
|
554
|
+
AutocompleteMultiple.className = CLASSNAME$1i;
|
|
553
555
|
AutocompleteMultiple.defaultProps = DEFAULT_PROPS$19;
|
|
554
556
|
|
|
555
557
|
/**
|
|
@@ -560,11 +562,11 @@ const COMPONENT_NAME$1i = 'Avatar';
|
|
|
560
562
|
/**
|
|
561
563
|
* Component default class name and class prefix.
|
|
562
564
|
*/
|
|
563
|
-
const CLASSNAME$
|
|
565
|
+
const CLASSNAME$1h = 'lumx-avatar';
|
|
564
566
|
const {
|
|
565
|
-
block: block$
|
|
566
|
-
element: element$
|
|
567
|
-
} = classNames.bem(CLASSNAME$
|
|
567
|
+
block: block$16,
|
|
568
|
+
element: element$Q
|
|
569
|
+
} = classNames.bem(CLASSNAME$1h);
|
|
568
570
|
|
|
569
571
|
/**
|
|
570
572
|
* Component default props.
|
|
@@ -600,14 +602,14 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
600
602
|
return /*#__PURE__*/jsxs("div", {
|
|
601
603
|
ref: ref,
|
|
602
604
|
...forwardedProps,
|
|
603
|
-
className: classNames.join(className, block$
|
|
605
|
+
className: classNames.join(className, block$16({
|
|
604
606
|
[`size-${size}`]: Boolean(size),
|
|
605
607
|
[`theme-${theme}`]: Boolean(theme)
|
|
606
608
|
})),
|
|
607
609
|
children: [/*#__PURE__*/jsx(Thumbnail, {
|
|
608
610
|
linkProps: linkProps,
|
|
609
611
|
linkAs: linkAs,
|
|
610
|
-
className: element$
|
|
612
|
+
className: element$Q('thumbnail'),
|
|
611
613
|
onClick: onClick,
|
|
612
614
|
onKeyPress: onKeyPress,
|
|
613
615
|
...thumbnailProps,
|
|
@@ -617,16 +619,16 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
617
619
|
alt: alt,
|
|
618
620
|
theme: theme
|
|
619
621
|
}), actions && /*#__PURE__*/jsx("div", {
|
|
620
|
-
className: element$
|
|
622
|
+
className: element$Q('actions'),
|
|
621
623
|
children: actions
|
|
622
624
|
}), badge && /*#__PURE__*/jsx("div", {
|
|
623
|
-
className: element$
|
|
625
|
+
className: element$Q('badge'),
|
|
624
626
|
children: badge
|
|
625
627
|
})]
|
|
626
628
|
});
|
|
627
629
|
});
|
|
628
630
|
Avatar.displayName = COMPONENT_NAME$1i;
|
|
629
|
-
Avatar.className = CLASSNAME$
|
|
631
|
+
Avatar.className = CLASSNAME$1h;
|
|
630
632
|
Avatar.defaultProps = DEFAULT_PROPS$18;
|
|
631
633
|
|
|
632
634
|
/**
|
|
@@ -855,7 +857,7 @@ function modifier$1(baseName, modifiers) {
|
|
|
855
857
|
* block('button', { active: true, disabled: false }); // 'button button--active'
|
|
856
858
|
*/
|
|
857
859
|
|
|
858
|
-
function block$
|
|
860
|
+
function block$15(baseName, modifiersOrAdditionalClasses, additionalClasses) {
|
|
859
861
|
let modifiers;
|
|
860
862
|
let classes;
|
|
861
863
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
@@ -890,11 +892,11 @@ function block$12(baseName, modifiersOrAdditionalClasses, additionalClasses) {
|
|
|
890
892
|
* element('my-button', 'icon', { active: true }); // 'my-button__icon my-button__icon--active'
|
|
891
893
|
*/
|
|
892
894
|
|
|
893
|
-
function element$
|
|
895
|
+
function element$P(baseClass, elem, modifiersOrAdditionalClasses, additionalClasses) {
|
|
894
896
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
895
|
-
return block$
|
|
897
|
+
return block$15(`${baseClass}__${elem}`, modifiersOrAdditionalClasses);
|
|
896
898
|
}
|
|
897
|
-
return block$
|
|
899
|
+
return block$15(`${baseClass}__${elem}`, modifiersOrAdditionalClasses, additionalClasses);
|
|
898
900
|
}
|
|
899
901
|
|
|
900
902
|
/**
|
|
@@ -903,15 +905,15 @@ function element$M(baseClass, elem, modifiersOrAdditionalClasses, additionalClas
|
|
|
903
905
|
function bem(baseName) {
|
|
904
906
|
function blockFn(modifiersOrAdditionalClasses, additionalClasses) {
|
|
905
907
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
906
|
-
return block$
|
|
908
|
+
return block$15(baseName, modifiersOrAdditionalClasses);
|
|
907
909
|
}
|
|
908
|
-
return block$
|
|
910
|
+
return block$15(baseName, modifiersOrAdditionalClasses, additionalClasses);
|
|
909
911
|
}
|
|
910
912
|
function elementFn(elem, modifiersOrAdditionalClasses, additionalClasses) {
|
|
911
913
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
912
|
-
return element$
|
|
914
|
+
return element$P(baseName, elem, modifiersOrAdditionalClasses);
|
|
913
915
|
}
|
|
914
|
-
return element$
|
|
916
|
+
return element$P(baseName, elem, modifiersOrAdditionalClasses, additionalClasses);
|
|
915
917
|
}
|
|
916
918
|
return {
|
|
917
919
|
block: blockFn,
|
|
@@ -928,10 +930,10 @@ const COMPONENT_NAME$1h = 'Badge';
|
|
|
928
930
|
/**
|
|
929
931
|
* Component default class name and class prefix.
|
|
930
932
|
*/
|
|
931
|
-
const CLASSNAME$
|
|
933
|
+
const CLASSNAME$1g = 'lumx-badge';
|
|
932
934
|
const {
|
|
933
|
-
block: block$
|
|
934
|
-
} = bem(CLASSNAME$
|
|
935
|
+
block: block$14
|
|
936
|
+
} = bem(CLASSNAME$1g);
|
|
935
937
|
|
|
936
938
|
/**
|
|
937
939
|
* Component default props.
|
|
@@ -957,14 +959,14 @@ const Badge$1 = props => {
|
|
|
957
959
|
return /*#__PURE__*/jsx("div", {
|
|
958
960
|
ref: ref,
|
|
959
961
|
...forwardedProps,
|
|
960
|
-
className: classnames(className, block$
|
|
962
|
+
className: classnames(className, block$14({
|
|
961
963
|
[`color-${color}`]: Boolean(color)
|
|
962
964
|
})),
|
|
963
965
|
children: children
|
|
964
966
|
});
|
|
965
967
|
};
|
|
966
968
|
Badge$1.displayName = COMPONENT_NAME$1h;
|
|
967
|
-
Badge$1.className = CLASSNAME$
|
|
969
|
+
Badge$1.className = CLASSNAME$1g;
|
|
968
970
|
Badge$1.defaultProps = DEFAULT_PROPS$17;
|
|
969
971
|
|
|
970
972
|
/**
|
|
@@ -989,11 +991,11 @@ Badge.className = Badge$1.className;
|
|
|
989
991
|
Badge.defaultProps = Badge$1.defaultProps;
|
|
990
992
|
|
|
991
993
|
const COMPONENT_NAME$1g = 'BadgeWrapper';
|
|
992
|
-
const CLASSNAME$
|
|
994
|
+
const CLASSNAME$1f = 'lumx-badge-wrapper';
|
|
993
995
|
const {
|
|
994
|
-
block: block$
|
|
995
|
-
element: element$
|
|
996
|
-
} = bem(CLASSNAME$
|
|
996
|
+
block: block$13,
|
|
997
|
+
element: element$O
|
|
998
|
+
} = bem(CLASSNAME$1f);
|
|
997
999
|
const BadgeWrapper$1 = props => {
|
|
998
1000
|
const {
|
|
999
1001
|
badge,
|
|
@@ -1005,9 +1007,9 @@ const BadgeWrapper$1 = props => {
|
|
|
1005
1007
|
return /*#__PURE__*/jsxs("div", {
|
|
1006
1008
|
ref: ref,
|
|
1007
1009
|
...forwardedProps,
|
|
1008
|
-
className: classnames(className, block$
|
|
1010
|
+
className: classnames(className, block$13()),
|
|
1009
1011
|
children: [children, badge && /*#__PURE__*/jsx("div", {
|
|
1010
|
-
className: element$
|
|
1012
|
+
className: element$O('badge'),
|
|
1011
1013
|
children: badge
|
|
1012
1014
|
})]
|
|
1013
1015
|
});
|
|
@@ -1020,7 +1022,7 @@ const BadgeWrapper = forwardRef((props, ref) => {
|
|
|
1020
1022
|
});
|
|
1021
1023
|
});
|
|
1022
1024
|
BadgeWrapper.displayName = COMPONENT_NAME$1g;
|
|
1023
|
-
BadgeWrapper.className = CLASSNAME$
|
|
1025
|
+
BadgeWrapper.className = CLASSNAME$1f;
|
|
1024
1026
|
|
|
1025
1027
|
/**
|
|
1026
1028
|
* Render clickable element (link, button or custom element)
|
|
@@ -1181,10 +1183,10 @@ const COMPONENT_NAME$1e = 'Button';
|
|
|
1181
1183
|
/**
|
|
1182
1184
|
* Component default class name and class prefix.
|
|
1183
1185
|
*/
|
|
1184
|
-
const CLASSNAME$
|
|
1186
|
+
const CLASSNAME$1e = 'lumx-button';
|
|
1185
1187
|
const {
|
|
1186
1188
|
modifier
|
|
1187
|
-
} = bem(CLASSNAME$
|
|
1189
|
+
} = bem(CLASSNAME$1e);
|
|
1188
1190
|
|
|
1189
1191
|
/**
|
|
1190
1192
|
* Component default props.
|
|
@@ -1222,7 +1224,7 @@ const Button$1 = props => {
|
|
|
1222
1224
|
});
|
|
1223
1225
|
};
|
|
1224
1226
|
Button$1.displayName = COMPONENT_NAME$1e;
|
|
1225
|
-
Button$1.className = CLASSNAME$
|
|
1227
|
+
Button$1.className = CLASSNAME$1e;
|
|
1226
1228
|
Button$1.defaultProps = DEFAULT_PROPS$16;
|
|
1227
1229
|
|
|
1228
1230
|
/**
|
|
@@ -1290,7 +1292,7 @@ const Button = forwardRef((props, ref) => {
|
|
|
1290
1292
|
});
|
|
1291
1293
|
});
|
|
1292
1294
|
Button.displayName = COMPONENT_NAME$1e;
|
|
1293
|
-
Button.className = CLASSNAME$
|
|
1295
|
+
Button.className = CLASSNAME$1e;
|
|
1294
1296
|
Button.defaultProps = DEFAULT_PROPS$16;
|
|
1295
1297
|
|
|
1296
1298
|
const COMPONENT_NAME$1d = 'Icon';
|
|
@@ -1300,10 +1302,10 @@ const IconClassName = 'lumx-icon';
|
|
|
1300
1302
|
* Defines the props of the component.
|
|
1301
1303
|
*/
|
|
1302
1304
|
|
|
1303
|
-
const CLASSNAME$
|
|
1305
|
+
const CLASSNAME$1d = IconClassName;
|
|
1304
1306
|
const {
|
|
1305
|
-
block: block
|
|
1306
|
-
} = bem(CLASSNAME$
|
|
1307
|
+
block: block$12
|
|
1308
|
+
} = bem(CLASSNAME$1d);
|
|
1307
1309
|
|
|
1308
1310
|
/**
|
|
1309
1311
|
* Component default props.
|
|
@@ -1357,7 +1359,7 @@ const Icon$1 = props => {
|
|
|
1357
1359
|
return /*#__PURE__*/jsx("i", {
|
|
1358
1360
|
ref: ref,
|
|
1359
1361
|
...forwardedProps,
|
|
1360
|
-
className: classnames(className, block
|
|
1362
|
+
className: classnames(className, block$12({
|
|
1361
1363
|
[`color-${iconColor}`]: Boolean(iconColor),
|
|
1362
1364
|
[`color-variant-${iconColorVariant}`]: Boolean(iconColorVariant),
|
|
1363
1365
|
'has-shape': hasShape,
|
|
@@ -1387,7 +1389,7 @@ const Icon$1 = props => {
|
|
|
1387
1389
|
});
|
|
1388
1390
|
};
|
|
1389
1391
|
Icon$1.displayName = COMPONENT_NAME$1d;
|
|
1390
|
-
Icon$1.className = CLASSNAME$
|
|
1392
|
+
Icon$1.className = CLASSNAME$1d;
|
|
1391
1393
|
Icon$1.defaultProps = DEFAULT_PROPS$15;
|
|
1392
1394
|
|
|
1393
1395
|
/**
|
|
@@ -1398,7 +1400,7 @@ const COMPONENT_NAME$1c = 'IconButton';
|
|
|
1398
1400
|
/**
|
|
1399
1401
|
* Component default class name and class prefix.
|
|
1400
1402
|
*/
|
|
1401
|
-
const CLASSNAME$
|
|
1403
|
+
const CLASSNAME$1c = 'lumx-icon-button';
|
|
1402
1404
|
|
|
1403
1405
|
/**
|
|
1404
1406
|
* Component default props.
|
|
@@ -1440,7 +1442,7 @@ const IconButton$1 = props => {
|
|
|
1440
1442
|
});
|
|
1441
1443
|
};
|
|
1442
1444
|
IconButton$1.displayName = COMPONENT_NAME$1c;
|
|
1443
|
-
IconButton$1.className = CLASSNAME$
|
|
1445
|
+
IconButton$1.className = CLASSNAME$1c;
|
|
1444
1446
|
IconButton$1.defaultProps = DEFAULT_PROPS$14;
|
|
1445
1447
|
|
|
1446
1448
|
/**
|
|
@@ -1477,7 +1479,7 @@ const IconButton = forwardRef((props, ref) => {
|
|
|
1477
1479
|
});
|
|
1478
1480
|
});
|
|
1479
1481
|
IconButton.displayName = COMPONENT_NAME$1c;
|
|
1480
|
-
IconButton.className = CLASSNAME$
|
|
1482
|
+
IconButton.className = CLASSNAME$1c;
|
|
1481
1483
|
IconButton.defaultProps = DEFAULT_PROPS$14;
|
|
1482
1484
|
|
|
1483
1485
|
/**
|
|
@@ -1488,7 +1490,7 @@ const COMPONENT_NAME$1b = 'ButtonGroup';
|
|
|
1488
1490
|
/**
|
|
1489
1491
|
* Component default class name and class prefix.
|
|
1490
1492
|
*/
|
|
1491
|
-
const CLASSNAME$
|
|
1493
|
+
const CLASSNAME$1b = 'lumx-button-group';
|
|
1492
1494
|
|
|
1493
1495
|
/**
|
|
1494
1496
|
* Component default props.
|
|
@@ -1509,12 +1511,12 @@ const ButtonGroup$1 = props => {
|
|
|
1509
1511
|
} = props;
|
|
1510
1512
|
return /*#__PURE__*/jsx("div", {
|
|
1511
1513
|
...forwardedProps,
|
|
1512
|
-
className: classnames(className, CLASSNAME$
|
|
1514
|
+
className: classnames(className, CLASSNAME$1b),
|
|
1513
1515
|
children: children
|
|
1514
1516
|
});
|
|
1515
1517
|
};
|
|
1516
1518
|
ButtonGroup$1.displayName = COMPONENT_NAME$1b;
|
|
1517
|
-
ButtonGroup$1.className = CLASSNAME$
|
|
1519
|
+
ButtonGroup$1.className = CLASSNAME$1b;
|
|
1518
1520
|
ButtonGroup$1.defaultProps = DEFAULT_PROPS$13;
|
|
1519
1521
|
|
|
1520
1522
|
/**
|
|
@@ -1531,15 +1533,15 @@ const ButtonGroup = forwardRef((props, ref) => {
|
|
|
1531
1533
|
});
|
|
1532
1534
|
});
|
|
1533
1535
|
ButtonGroup.displayName = COMPONENT_NAME$1b;
|
|
1534
|
-
ButtonGroup.className = CLASSNAME$
|
|
1536
|
+
ButtonGroup.className = CLASSNAME$1b;
|
|
1535
1537
|
ButtonGroup.defaultProps = DEFAULT_PROPS$13;
|
|
1536
1538
|
|
|
1537
1539
|
const COMPONENT_NAME$1a = 'InputLabel';
|
|
1538
1540
|
const InputLabelClassName = 'lumx-input-label';
|
|
1539
|
-
const CLASSNAME$
|
|
1541
|
+
const CLASSNAME$1a = InputLabelClassName;
|
|
1540
1542
|
const {
|
|
1541
|
-
block: block$
|
|
1542
|
-
} = bem(CLASSNAME$
|
|
1543
|
+
block: block$11
|
|
1544
|
+
} = bem(CLASSNAME$1a);
|
|
1543
1545
|
const DEFAULT_PROPS$12 = {};
|
|
1544
1546
|
|
|
1545
1547
|
/**
|
|
@@ -1560,7 +1562,7 @@ function InputLabel$1(props) {
|
|
|
1560
1562
|
ref: ref,
|
|
1561
1563
|
...forwardedProps,
|
|
1562
1564
|
htmlFor: htmlFor,
|
|
1563
|
-
className: classnames(className, block$
|
|
1565
|
+
className: classnames(className, block$11({
|
|
1564
1566
|
'is-required': isRequired,
|
|
1565
1567
|
[`theme-${theme}`]: Boolean(theme),
|
|
1566
1568
|
'has-custom-typography': Boolean(typography$1)
|
|
@@ -1569,7 +1571,7 @@ function InputLabel$1(props) {
|
|
|
1569
1571
|
});
|
|
1570
1572
|
}
|
|
1571
1573
|
InputLabel$1.displayName = COMPONENT_NAME$1a;
|
|
1572
|
-
InputLabel$1.className = CLASSNAME$
|
|
1574
|
+
InputLabel$1.className = CLASSNAME$1a;
|
|
1573
1575
|
InputLabel$1.defaultProps = DEFAULT_PROPS$12;
|
|
1574
1576
|
|
|
1575
1577
|
const INPUT_HELPER_CONFIGURATION = {
|
|
@@ -1591,10 +1593,10 @@ const InputHelperClassName = 'lumx-input-helper';
|
|
|
1591
1593
|
* Defines the props of the component.
|
|
1592
1594
|
*/
|
|
1593
1595
|
|
|
1594
|
-
const CLASSNAME$
|
|
1596
|
+
const CLASSNAME$19 = InputHelperClassName;
|
|
1595
1597
|
const {
|
|
1596
|
-
block: block$
|
|
1597
|
-
} = bem(CLASSNAME$
|
|
1598
|
+
block: block$10
|
|
1599
|
+
} = bem(CLASSNAME$19);
|
|
1598
1600
|
|
|
1599
1601
|
/**
|
|
1600
1602
|
* Component default props.
|
|
@@ -1621,7 +1623,7 @@ function InputHelper$1(props) {
|
|
|
1621
1623
|
return /*#__PURE__*/jsx("p", {
|
|
1622
1624
|
ref: ref,
|
|
1623
1625
|
...forwardedProps,
|
|
1624
|
-
className: classnames(className, block$
|
|
1626
|
+
className: classnames(className, block$10({
|
|
1625
1627
|
[`color-${color}`]: Boolean(color),
|
|
1626
1628
|
[`theme-${theme}`]: Boolean(theme)
|
|
1627
1629
|
})),
|
|
@@ -1629,7 +1631,7 @@ function InputHelper$1(props) {
|
|
|
1629
1631
|
});
|
|
1630
1632
|
}
|
|
1631
1633
|
InputHelper$1.displayName = COMPONENT_NAME$19;
|
|
1632
|
-
InputHelper$1.className = CLASSNAME$
|
|
1634
|
+
InputHelper$1.className = CLASSNAME$19;
|
|
1633
1635
|
InputHelper$1.defaultProps = DEFAULT_PROPS$11;
|
|
1634
1636
|
|
|
1635
1637
|
const INTERMEDIATE_STATE = 'intermediate';
|
|
@@ -1646,11 +1648,11 @@ const COMPONENT_NAME$18 = 'Checkbox';
|
|
|
1646
1648
|
/**
|
|
1647
1649
|
* Component default class name and class prefix.
|
|
1648
1650
|
*/
|
|
1649
|
-
const CLASSNAME$
|
|
1651
|
+
const CLASSNAME$18 = 'lumx-checkbox';
|
|
1650
1652
|
const {
|
|
1651
|
-
block: block
|
|
1652
|
-
element: element$
|
|
1653
|
-
} = bem(CLASSNAME$
|
|
1653
|
+
block: block$$,
|
|
1654
|
+
element: element$N
|
|
1655
|
+
} = bem(CLASSNAME$18);
|
|
1654
1656
|
|
|
1655
1657
|
/**
|
|
1656
1658
|
* Checkbox component.
|
|
@@ -1686,7 +1688,7 @@ const Checkbox$1 = props => {
|
|
|
1686
1688
|
return /*#__PURE__*/jsxs("div", {
|
|
1687
1689
|
ref: ref,
|
|
1688
1690
|
...forwardedProps,
|
|
1689
|
-
className: classnames(className, block
|
|
1691
|
+
className: classnames(className, block$$({
|
|
1690
1692
|
// Whether state is intermediate class name will "-checked"
|
|
1691
1693
|
'is-checked': intermediateState ? true : isChecked,
|
|
1692
1694
|
'is-disabled': isDisabled,
|
|
@@ -1694,12 +1696,12 @@ const Checkbox$1 = props => {
|
|
|
1694
1696
|
[`theme-${theme}`]: Boolean(theme)
|
|
1695
1697
|
})),
|
|
1696
1698
|
children: [/*#__PURE__*/jsxs("div", {
|
|
1697
|
-
className: element$
|
|
1699
|
+
className: element$N('input-wrapper'),
|
|
1698
1700
|
children: [/*#__PURE__*/jsx("input", {
|
|
1699
1701
|
ref: inputRef,
|
|
1700
1702
|
type: "checkbox",
|
|
1701
1703
|
id: inputId,
|
|
1702
|
-
className: element$
|
|
1704
|
+
className: element$N('input-native'),
|
|
1703
1705
|
name: name,
|
|
1704
1706
|
value: value,
|
|
1705
1707
|
checked: isChecked,
|
|
@@ -1711,26 +1713,26 @@ const Checkbox$1 = props => {
|
|
|
1711
1713
|
} : {}),
|
|
1712
1714
|
...inputProps
|
|
1713
1715
|
}), /*#__PURE__*/jsxs("div", {
|
|
1714
|
-
className: element$
|
|
1716
|
+
className: element$N('input-placeholder'),
|
|
1715
1717
|
children: [/*#__PURE__*/jsx("div", {
|
|
1716
|
-
className: element$
|
|
1718
|
+
className: element$N('input-background')
|
|
1717
1719
|
}), /*#__PURE__*/jsx("div", {
|
|
1718
|
-
className: element$
|
|
1720
|
+
className: element$N('input-indicator'),
|
|
1719
1721
|
children: Icon$1({
|
|
1720
1722
|
icon: intermediateState ? mdiMinus : mdiCheck
|
|
1721
1723
|
})
|
|
1722
1724
|
})]
|
|
1723
1725
|
})]
|
|
1724
1726
|
}), /*#__PURE__*/jsxs("div", {
|
|
1725
|
-
className: element$
|
|
1727
|
+
className: element$N('content'),
|
|
1726
1728
|
children: [label && InputLabel$1({
|
|
1727
1729
|
htmlFor: inputId,
|
|
1728
|
-
className: element$
|
|
1730
|
+
className: element$N('label'),
|
|
1729
1731
|
theme,
|
|
1730
1732
|
children: label
|
|
1731
1733
|
}), helper && InputHelper$1({
|
|
1732
1734
|
id: `${inputId}-helper`,
|
|
1733
|
-
className: element$
|
|
1735
|
+
className: element$N('helper'),
|
|
1734
1736
|
theme,
|
|
1735
1737
|
children: helper
|
|
1736
1738
|
})]
|
|
@@ -1806,7 +1808,7 @@ const Checkbox = forwardRef((props, ref) => {
|
|
|
1806
1808
|
});
|
|
1807
1809
|
});
|
|
1808
1810
|
Checkbox.displayName = COMPONENT_NAME$18;
|
|
1809
|
-
Checkbox.className = CLASSNAME$
|
|
1811
|
+
Checkbox.className = CLASSNAME$18;
|
|
1810
1812
|
Checkbox.defaultProps = DEFAULT_PROPS$10;
|
|
1811
1813
|
|
|
1812
1814
|
/**
|
|
@@ -1833,11 +1835,11 @@ const COMPONENT_NAME$17 = 'Chip';
|
|
|
1833
1835
|
/**
|
|
1834
1836
|
* Component default class name and class prefix.
|
|
1835
1837
|
*/
|
|
1836
|
-
const CLASSNAME$
|
|
1838
|
+
const CLASSNAME$17 = 'lumx-chip';
|
|
1837
1839
|
const {
|
|
1838
|
-
block: block$
|
|
1839
|
-
element: element$
|
|
1840
|
-
} = classNames.bem(CLASSNAME$
|
|
1840
|
+
block: block$_,
|
|
1841
|
+
element: element$M
|
|
1842
|
+
} = classNames.bem(CLASSNAME$17);
|
|
1841
1843
|
|
|
1842
1844
|
/**
|
|
1843
1845
|
* Component default props.
|
|
@@ -1903,7 +1905,7 @@ const Chip = forwardRef((props, ref) => {
|
|
|
1903
1905
|
...forwardedProps,
|
|
1904
1906
|
href: !disabledStateProps.disabled ? href : undefined,
|
|
1905
1907
|
ref: ref,
|
|
1906
|
-
className: classNames.join(className, block$
|
|
1908
|
+
className: classNames.join(className, block$_({
|
|
1907
1909
|
'is-clickable': isClickable,
|
|
1908
1910
|
[`color-${chipColor}`]: Boolean(chipColor),
|
|
1909
1911
|
'is-disabled': isAnyDisabled,
|
|
@@ -1921,19 +1923,19 @@ const Chip = forwardRef((props, ref) => {
|
|
|
1921
1923
|
/*#__PURE__*/
|
|
1922
1924
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
1923
1925
|
jsx("div", {
|
|
1924
|
-
className: element$
|
|
1926
|
+
className: element$M('before', {
|
|
1925
1927
|
'is-clickable': hasBeforeClick
|
|
1926
1928
|
}),
|
|
1927
1929
|
onClick: handleOnBeforeClick,
|
|
1928
1930
|
children: before
|
|
1929
1931
|
}), /*#__PURE__*/jsx("div", {
|
|
1930
|
-
className: element$
|
|
1932
|
+
className: element$M('label'),
|
|
1931
1933
|
children: children
|
|
1932
1934
|
}), after &&
|
|
1933
1935
|
/*#__PURE__*/
|
|
1934
1936
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
1935
1937
|
jsx("div", {
|
|
1936
|
-
className: element$
|
|
1938
|
+
className: element$M('after', {
|
|
1937
1939
|
'is-clickable': hasAfterClick
|
|
1938
1940
|
}),
|
|
1939
1941
|
onClick: handleOnAfterClick,
|
|
@@ -1943,7 +1945,7 @@ const Chip = forwardRef((props, ref) => {
|
|
|
1943
1945
|
);
|
|
1944
1946
|
});
|
|
1945
1947
|
Chip.displayName = COMPONENT_NAME$17;
|
|
1946
|
-
Chip.className = CLASSNAME$
|
|
1948
|
+
Chip.className = CLASSNAME$17;
|
|
1947
1949
|
Chip.defaultProps = DEFAULT_PROPS$$;
|
|
1948
1950
|
|
|
1949
1951
|
const INITIAL_STATE_ACTIVE_CHIP = -1;
|
|
@@ -2010,7 +2012,7 @@ const COMPONENT_NAME$16 = 'ChipGroup';
|
|
|
2010
2012
|
/**
|
|
2011
2013
|
* Component default class name and class prefix.
|
|
2012
2014
|
*/
|
|
2013
|
-
const CLASSNAME$
|
|
2015
|
+
const CLASSNAME$16 = 'lumx-chip-group';
|
|
2014
2016
|
|
|
2015
2017
|
/**
|
|
2016
2018
|
* ChipGroup component.
|
|
@@ -2029,12 +2031,12 @@ const InternalChipGroup = forwardRef((props, ref) => {
|
|
|
2029
2031
|
return /*#__PURE__*/jsx("div", {
|
|
2030
2032
|
ref: ref,
|
|
2031
2033
|
...forwardedProps,
|
|
2032
|
-
className: classNames.join(className, CLASSNAME$
|
|
2034
|
+
className: classNames.join(className, CLASSNAME$16),
|
|
2033
2035
|
children: children
|
|
2034
2036
|
});
|
|
2035
2037
|
});
|
|
2036
2038
|
InternalChipGroup.displayName = COMPONENT_NAME$16;
|
|
2037
|
-
InternalChipGroup.className = CLASSNAME$
|
|
2039
|
+
InternalChipGroup.className = CLASSNAME$16;
|
|
2038
2040
|
InternalChipGroup.defaultProps = DEFAULT_PROPS$_;
|
|
2039
2041
|
const ChipGroup = Object.assign(InternalChipGroup, {
|
|
2040
2042
|
useChipGroupNavigation
|
|
@@ -2125,11 +2127,11 @@ function useFocusLastChipOnBackspace(chipRefs, inputRef) {
|
|
|
2125
2127
|
/**
|
|
2126
2128
|
* Component default class name and class prefix.
|
|
2127
2129
|
*/
|
|
2128
|
-
const CLASSNAME$
|
|
2130
|
+
const CLASSNAME$15 = 'lumx-selection-chip-group';
|
|
2129
2131
|
const {
|
|
2130
|
-
block: block$
|
|
2131
|
-
element: element$
|
|
2132
|
-
} = classNames.bem(CLASSNAME$
|
|
2132
|
+
block: block$Z,
|
|
2133
|
+
element: element$L
|
|
2134
|
+
} = classNames.bem(CLASSNAME$15);
|
|
2133
2135
|
|
|
2134
2136
|
/**
|
|
2135
2137
|
* SelectionChipGroup component.
|
|
@@ -2159,7 +2161,7 @@ const SelectionChipGroup = ({
|
|
|
2159
2161
|
return /*#__PURE__*/jsx(ChipGroup, {
|
|
2160
2162
|
role: "group",
|
|
2161
2163
|
"aria-label": label,
|
|
2162
|
-
className: block$
|
|
2164
|
+
className: block$Z(),
|
|
2163
2165
|
...forwardedProps,
|
|
2164
2166
|
children: value?.map((v, index) => {
|
|
2165
2167
|
const name = getWithSelector(getOptionName, v);
|
|
@@ -2203,7 +2205,7 @@ const SelectionChipGroup = ({
|
|
|
2203
2205
|
after: /*#__PURE__*/jsx(Icon, {
|
|
2204
2206
|
icon: mdiClose
|
|
2205
2207
|
}),
|
|
2206
|
-
className: element$
|
|
2208
|
+
className: element$L('chip', [props?.className]),
|
|
2207
2209
|
size: "s",
|
|
2208
2210
|
ref: ref,
|
|
2209
2211
|
onClick: onClick,
|
|
@@ -2218,6 +2220,654 @@ const SelectionChipGroup = ({
|
|
|
2218
2220
|
});
|
|
2219
2221
|
};
|
|
2220
2222
|
|
|
2223
|
+
const ComboboxOptionContext = /*#__PURE__*/createContext({});
|
|
2224
|
+
/** Context Provider to store the current combobox option id. */
|
|
2225
|
+
const ComboboxOptionContextProvider = ({
|
|
2226
|
+
optionId,
|
|
2227
|
+
isKeyboardHighlighted,
|
|
2228
|
+
children
|
|
2229
|
+
}) => {
|
|
2230
|
+
const value = React__default.useMemo(() => ({
|
|
2231
|
+
optionId,
|
|
2232
|
+
isKeyboardHighlighted
|
|
2233
|
+
}), [optionId, isKeyboardHighlighted]);
|
|
2234
|
+
return /*#__PURE__*/jsx(ComboboxOptionContext.Provider, {
|
|
2235
|
+
value: value,
|
|
2236
|
+
children: children
|
|
2237
|
+
});
|
|
2238
|
+
};
|
|
2239
|
+
|
|
2240
|
+
/**
|
|
2241
|
+
* Retrieve the current combobox option id.
|
|
2242
|
+
* Must be used within a ComboboxOptionIdProvider
|
|
2243
|
+
*/
|
|
2244
|
+
const useComboboxOptionContext = () => {
|
|
2245
|
+
const comboboxOption = useContext(ComboboxOptionContext);
|
|
2246
|
+
if (!comboboxOption?.optionId) {
|
|
2247
|
+
throw new Error('This hook must be used within a ComboboxOptionIdProvider');
|
|
2248
|
+
}
|
|
2249
|
+
return comboboxOption;
|
|
2250
|
+
};
|
|
2251
|
+
|
|
2252
|
+
/** Generate the combobox option id from the combobox id and the given id */
|
|
2253
|
+
const generateOptionId = (comboboxId, optionId) => `${comboboxId}-option-${optionId}`;
|
|
2254
|
+
|
|
2255
|
+
/** Verifies that the combobox registered option is an action */
|
|
2256
|
+
const isComboboxAction = option => Boolean(option?.isAction);
|
|
2257
|
+
|
|
2258
|
+
/** Verifies that the combobox registered option is the option's value */
|
|
2259
|
+
const isComboboxValue = option => {
|
|
2260
|
+
return !isComboboxAction(option);
|
|
2261
|
+
};
|
|
2262
|
+
|
|
2263
|
+
const comboboxId = `combobox-${uniqueId()}`;
|
|
2264
|
+
const initialState = {
|
|
2265
|
+
comboboxId,
|
|
2266
|
+
listboxId: `${comboboxId}-popover`,
|
|
2267
|
+
status: 'idle',
|
|
2268
|
+
isOpen: false,
|
|
2269
|
+
inputValue: '',
|
|
2270
|
+
showAll: true,
|
|
2271
|
+
options: {},
|
|
2272
|
+
type: 'listbox',
|
|
2273
|
+
optionsLength: 0
|
|
2274
|
+
};
|
|
2275
|
+
|
|
2276
|
+
/** Dispatch for the combobox component */
|
|
2277
|
+
|
|
2278
|
+
/** Context for the Combobox component */
|
|
2279
|
+
const ComboboxContext = /*#__PURE__*/React__default.createContext({
|
|
2280
|
+
...initialState,
|
|
2281
|
+
openOnFocus: false,
|
|
2282
|
+
openOnClick: false,
|
|
2283
|
+
selectionType: 'single',
|
|
2284
|
+
optionsLength: 0,
|
|
2285
|
+
onSelect: noop,
|
|
2286
|
+
onInputChange: noop,
|
|
2287
|
+
onOpen: noop,
|
|
2288
|
+
dispatch: noop,
|
|
2289
|
+
translations: {
|
|
2290
|
+
clearLabel: '',
|
|
2291
|
+
tryReloadLabel: '',
|
|
2292
|
+
showSuggestionsLabel: '',
|
|
2293
|
+
noResultsForInputLabel: input => input || '',
|
|
2294
|
+
loadingLabel: '',
|
|
2295
|
+
serviceUnavailableLabel: '',
|
|
2296
|
+
nbOptionsLabel: options => `${options}`
|
|
2297
|
+
}
|
|
2298
|
+
});
|
|
2299
|
+
|
|
2300
|
+
/** Context for a combobox section to store its unique id */
|
|
2301
|
+
const SectionContext = /*#__PURE__*/React__default.createContext({
|
|
2302
|
+
sectionId: ''
|
|
2303
|
+
});
|
|
2304
|
+
|
|
2305
|
+
/** Context to store the refs of the combobox elements */
|
|
2306
|
+
const ComboboxRefsContext = /*#__PURE__*/createContext({
|
|
2307
|
+
triggerRef: {
|
|
2308
|
+
current: null
|
|
2309
|
+
},
|
|
2310
|
+
anchorRef: {
|
|
2311
|
+
current: null
|
|
2312
|
+
}
|
|
2313
|
+
});
|
|
2314
|
+
|
|
2315
|
+
/** Retrieves the combobox elements references from context */
|
|
2316
|
+
const useComboboxRefs = () => {
|
|
2317
|
+
const refs = useContext(ComboboxRefsContext);
|
|
2318
|
+
if (!refs) {
|
|
2319
|
+
throw new Error('The useComboboxRefs hook must be called within a ComboboxRefsProvider');
|
|
2320
|
+
}
|
|
2321
|
+
return refs;
|
|
2322
|
+
};
|
|
2323
|
+
|
|
2324
|
+
/** Retrieve the current combobox state and actions */
|
|
2325
|
+
const useCombobox = () => {
|
|
2326
|
+
const comboboxContext = React__default.useContext(ComboboxContext);
|
|
2327
|
+
const {
|
|
2328
|
+
dispatch: movingFocusDispatch
|
|
2329
|
+
} = React__default.useContext(MovingFocusContext);
|
|
2330
|
+
const {
|
|
2331
|
+
onSelect,
|
|
2332
|
+
onInputChange,
|
|
2333
|
+
onOpen,
|
|
2334
|
+
dispatch,
|
|
2335
|
+
inputValue,
|
|
2336
|
+
...contextValues
|
|
2337
|
+
} = comboboxContext;
|
|
2338
|
+
const {
|
|
2339
|
+
triggerRef
|
|
2340
|
+
} = useComboboxRefs();
|
|
2341
|
+
|
|
2342
|
+
/** Action triggered when the listBox is closed without selecting any option */
|
|
2343
|
+
const handleClose = React__default.useCallback(() => {
|
|
2344
|
+
dispatch({
|
|
2345
|
+
type: 'CLOSE_COMBOBOX'
|
|
2346
|
+
});
|
|
2347
|
+
// Reset visual focus
|
|
2348
|
+
movingFocusDispatch({
|
|
2349
|
+
type: 'RESET_SELECTED_TAB_STOP'
|
|
2350
|
+
});
|
|
2351
|
+
}, [dispatch, movingFocusDispatch]);
|
|
2352
|
+
|
|
2353
|
+
// Handle callbacks on options mounted
|
|
2354
|
+
const [optionsMountedCallbacks, setOptionsMountedCallback] = React__default.useState();
|
|
2355
|
+
React__default.useEffect(() => {
|
|
2356
|
+
if (comboboxContext.optionsLength > 0 && optionsMountedCallbacks?.length) {
|
|
2357
|
+
const optionsArray = Object.values(comboboxContext.options);
|
|
2358
|
+
// Execute callbacks
|
|
2359
|
+
for (const callback of optionsMountedCallbacks) {
|
|
2360
|
+
callback(optionsArray);
|
|
2361
|
+
}
|
|
2362
|
+
setOptionsMountedCallback(undefined);
|
|
2363
|
+
}
|
|
2364
|
+
}, [comboboxContext.options, comboboxContext.optionsLength, optionsMountedCallbacks]);
|
|
2365
|
+
|
|
2366
|
+
/** Callback for when an option is selected */
|
|
2367
|
+
const handleSelected = React__default.useCallback((option, source) => {
|
|
2368
|
+
if (option?.isDisabled) {
|
|
2369
|
+
return;
|
|
2370
|
+
}
|
|
2371
|
+
if (isComboboxValue(option)) {
|
|
2372
|
+
/**
|
|
2373
|
+
* We only close the list if the selection type is single.
|
|
2374
|
+
* If it is multiple, we want to allow the user to continue
|
|
2375
|
+
* selecting multiple options.
|
|
2376
|
+
*/
|
|
2377
|
+
if (comboboxContext.selectionType !== 'multiple') {
|
|
2378
|
+
handleClose();
|
|
2379
|
+
}
|
|
2380
|
+
/** Call parent onSelect callback */
|
|
2381
|
+
if (onSelect) {
|
|
2382
|
+
onSelect(option);
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
/** If the option itself has a custom action, also call it */
|
|
2387
|
+
if (option?.onSelect) {
|
|
2388
|
+
option.onSelect(option, source);
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
/** Reset focus on input */
|
|
2392
|
+
if (triggerRef?.current) {
|
|
2393
|
+
triggerRef.current?.focus();
|
|
2394
|
+
}
|
|
2395
|
+
}, [comboboxContext.selectionType, handleClose, onSelect, triggerRef]);
|
|
2396
|
+
|
|
2397
|
+
/** Callback for when the input must be updated */
|
|
2398
|
+
const handleInputChange = React__default.useCallback((value, ...args) => {
|
|
2399
|
+
// Update the local state
|
|
2400
|
+
dispatch({
|
|
2401
|
+
type: 'SET_INPUT_VALUE',
|
|
2402
|
+
payload: value
|
|
2403
|
+
});
|
|
2404
|
+
// If a callback if given, call it with the value
|
|
2405
|
+
if (onInputChange) {
|
|
2406
|
+
onInputChange(value, ...args);
|
|
2407
|
+
}
|
|
2408
|
+
// Reset visual focus
|
|
2409
|
+
movingFocusDispatch({
|
|
2410
|
+
type: 'RESET_SELECTED_TAB_STOP'
|
|
2411
|
+
});
|
|
2412
|
+
}, [dispatch, movingFocusDispatch, onInputChange]);
|
|
2413
|
+
|
|
2414
|
+
/**
|
|
2415
|
+
* Open the popover
|
|
2416
|
+
*
|
|
2417
|
+
* @returns a promise with the updated context once all options are mounted
|
|
2418
|
+
*/
|
|
2419
|
+
const handleOpen = React__default.useCallback(params => {
|
|
2420
|
+
/** update the local state */
|
|
2421
|
+
dispatch({
|
|
2422
|
+
type: 'OPEN_COMBOBOX',
|
|
2423
|
+
payload: params
|
|
2424
|
+
});
|
|
2425
|
+
/** If a parent callback was given, trigger it with state information */
|
|
2426
|
+
if (onOpen) {
|
|
2427
|
+
onOpen({
|
|
2428
|
+
currentValue: inputValue,
|
|
2429
|
+
manual: Boolean(params?.manual)
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
// Promise resolving options on mount
|
|
2434
|
+
return new Promise(resolve => {
|
|
2435
|
+
// Append to the list of callback on options mounted
|
|
2436
|
+
setOptionsMountedCallback((callbacks = []) => {
|
|
2437
|
+
callbacks.push(resolve);
|
|
2438
|
+
return callbacks;
|
|
2439
|
+
});
|
|
2440
|
+
});
|
|
2441
|
+
}, [dispatch, inputValue, onOpen]);
|
|
2442
|
+
return React__default.useMemo(() => ({
|
|
2443
|
+
handleClose,
|
|
2444
|
+
handleOpen,
|
|
2445
|
+
handleInputChange,
|
|
2446
|
+
handleSelected,
|
|
2447
|
+
dispatch,
|
|
2448
|
+
inputValue,
|
|
2449
|
+
...contextValues
|
|
2450
|
+
}), [contextValues, dispatch, handleClose, handleInputChange, handleOpen, handleSelected, inputValue]);
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
/** Retrieve the current combobox section id */
|
|
2454
|
+
const useComboboxSectionId = () => {
|
|
2455
|
+
return useContext(SectionContext);
|
|
2456
|
+
};
|
|
2457
|
+
|
|
2458
|
+
/**
|
|
2459
|
+
* Register the given option to the context
|
|
2460
|
+
*/
|
|
2461
|
+
const useRegisterOption = (registerId, option, shouldRegister) => {
|
|
2462
|
+
const {
|
|
2463
|
+
dispatch
|
|
2464
|
+
} = useCombobox();
|
|
2465
|
+
|
|
2466
|
+
/** Register the given options */
|
|
2467
|
+
React__default.useEffect(() => {
|
|
2468
|
+
if (option && shouldRegister) {
|
|
2469
|
+
dispatch({
|
|
2470
|
+
type: 'ADD_OPTION',
|
|
2471
|
+
payload: {
|
|
2472
|
+
id: registerId,
|
|
2473
|
+
option
|
|
2474
|
+
}
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
// Unregister ids if/when the component unmounts or if option changes
|
|
2479
|
+
return () => {
|
|
2480
|
+
if (option) {
|
|
2481
|
+
dispatch({
|
|
2482
|
+
type: 'REMOVE_OPTION',
|
|
2483
|
+
payload: {
|
|
2484
|
+
id: registerId
|
|
2485
|
+
}
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
};
|
|
2489
|
+
}, [dispatch, option, registerId, shouldRegister]);
|
|
2490
|
+
};
|
|
2491
|
+
|
|
2492
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
2493
|
+
const COMBOBOX_OPTION_CLASSNAME = 'lumx-combobox-option';
|
|
2494
|
+
const LUMX_CLASSNAME = 'lumx-list-item';
|
|
2495
|
+
const {
|
|
2496
|
+
block: block$Y,
|
|
2497
|
+
element: element$K
|
|
2498
|
+
} = classNames.bem(COMBOBOX_OPTION_CLASSNAME);
|
|
2499
|
+
const lumxListItem = classNames.bem(LUMX_CLASSNAME);
|
|
2500
|
+
|
|
2501
|
+
/**
|
|
2502
|
+
* Content of the option.
|
|
2503
|
+
* This should only be rendered if the option is shown.
|
|
2504
|
+
*/
|
|
2505
|
+
const OptionContent = forwardRef((props, ref) => {
|
|
2506
|
+
const {
|
|
2507
|
+
id,
|
|
2508
|
+
onSelect,
|
|
2509
|
+
isSelected,
|
|
2510
|
+
isDisabled,
|
|
2511
|
+
children,
|
|
2512
|
+
className,
|
|
2513
|
+
before,
|
|
2514
|
+
after,
|
|
2515
|
+
as,
|
|
2516
|
+
size = Size$1.tiny,
|
|
2517
|
+
comboboxType,
|
|
2518
|
+
tooltipProps,
|
|
2519
|
+
description,
|
|
2520
|
+
'aria-hidden': ariaHidden,
|
|
2521
|
+
autofocus,
|
|
2522
|
+
...forwardedProps
|
|
2523
|
+
} = props;
|
|
2524
|
+
const itemRef = React__default.useRef(null);
|
|
2525
|
+
const {
|
|
2526
|
+
state
|
|
2527
|
+
} = React__default.useContext(MovingFocusContext);
|
|
2528
|
+
const {
|
|
2529
|
+
selectedIds
|
|
2530
|
+
} = useCombobox();
|
|
2531
|
+
const hasSelection = selectedIds !== undefined;
|
|
2532
|
+
const isHighlighted = useVirtualFocus(id, itemRef, false, comboboxType === 'grid' ? id : undefined, autofocus);
|
|
2533
|
+
const Element = as || 'span';
|
|
2534
|
+
const ariaSelected = isSelected ? 'true' : 'false';
|
|
2535
|
+
const ariaDescriptionId = description ? `${id}-description` : undefined;
|
|
2536
|
+
const isKeyboardHighlighted = state.isUsingKeyboard && isHighlighted;
|
|
2537
|
+
|
|
2538
|
+
/**
|
|
2539
|
+
* The DS `ListItem` component has a lot of behavior / default props we do not want here.
|
|
2540
|
+
* Notably the before/after items are within the interactive element, which we do not want.
|
|
2541
|
+
* So we use a native li tag.
|
|
2542
|
+
*/
|
|
2543
|
+
return /*#__PURE__*/jsx("li", {
|
|
2544
|
+
className: block$Y(undefined, [className ?? '', lumxListItem.block({
|
|
2545
|
+
[`size-${size}`]: !!size
|
|
2546
|
+
})]),
|
|
2547
|
+
role: "presentation",
|
|
2548
|
+
ref: itemRef,
|
|
2549
|
+
"aria-hidden": ariaHidden,
|
|
2550
|
+
style: {
|
|
2551
|
+
display: ariaHidden ? 'none' : undefined
|
|
2552
|
+
},
|
|
2553
|
+
...forwardedProps,
|
|
2554
|
+
children: /*#__PURE__*/jsxs(GenericBlock, {
|
|
2555
|
+
as: "div",
|
|
2556
|
+
role: comboboxType === 'grid' ? 'row' : 'presentation',
|
|
2557
|
+
className: element$K('content', {
|
|
2558
|
+
// Not using the lumx list item disabled style as it blocks pointer events
|
|
2559
|
+
'is-disabled': !!isDisabled
|
|
2560
|
+
},
|
|
2561
|
+
// TODO: migrate away from using lumx-list-item styles https://lumapps.atlassian.net/browse/DSW-288
|
|
2562
|
+
[lumxListItem.element('link', {
|
|
2563
|
+
'is-selected': Boolean(isSelected),
|
|
2564
|
+
'is-highlighted': Boolean(isHighlighted)
|
|
2565
|
+
})]),
|
|
2566
|
+
"data-focus-visible-added": isKeyboardHighlighted ? 'true' : undefined,
|
|
2567
|
+
children: [before && /*#__PURE__*/jsx(GenericBlock.Figure, {
|
|
2568
|
+
as: "span",
|
|
2569
|
+
role: "presentation",
|
|
2570
|
+
className: element$K('before', undefined, [lumxListItem.element('before')]),
|
|
2571
|
+
children: before
|
|
2572
|
+
}), /*#__PURE__*/jsxs(GenericBlock.Content, {
|
|
2573
|
+
as: "span",
|
|
2574
|
+
role: "presentation",
|
|
2575
|
+
className: lumxListItem.element('content'),
|
|
2576
|
+
children: [/*#__PURE__*/jsx(Tooltip, {
|
|
2577
|
+
forceOpen: isKeyboardHighlighted,
|
|
2578
|
+
closeMode: "hide",
|
|
2579
|
+
...tooltipProps,
|
|
2580
|
+
children: /*#__PURE__*/jsx(Element, {
|
|
2581
|
+
id: id,
|
|
2582
|
+
className: element$K('trigger'),
|
|
2583
|
+
role: comboboxType === 'grid' ? 'gridcell' : 'option',
|
|
2584
|
+
"aria-selected": hasSelection ? ariaSelected : undefined,
|
|
2585
|
+
"aria-disabled": isDisabled,
|
|
2586
|
+
"aria-describedby": ariaDescriptionId,
|
|
2587
|
+
onClick: onSelect
|
|
2588
|
+
// Prevent mouse down to avoid blur before the click is activated
|
|
2589
|
+
,
|
|
2590
|
+
onMouseDown: event => event.preventDefault(),
|
|
2591
|
+
ref: ref,
|
|
2592
|
+
...forwardedProps,
|
|
2593
|
+
children: children
|
|
2594
|
+
})
|
|
2595
|
+
}), description && /*#__PURE__*/jsx(Text, {
|
|
2596
|
+
as: "span",
|
|
2597
|
+
id: ariaDescriptionId,
|
|
2598
|
+
role: "presentation",
|
|
2599
|
+
className: element$K('description'),
|
|
2600
|
+
typography: "caption",
|
|
2601
|
+
color: "dark",
|
|
2602
|
+
colorVariant: "L2",
|
|
2603
|
+
children: description
|
|
2604
|
+
})]
|
|
2605
|
+
}), after && /*#__PURE__*/jsx(GenericBlock.Actions, {
|
|
2606
|
+
as: "span",
|
|
2607
|
+
role: "presentation",
|
|
2608
|
+
className: element$K('after', undefined, [lumxListItem.element('after')]),
|
|
2609
|
+
children: /*#__PURE__*/jsx(ComboboxOptionContextProvider, {
|
|
2610
|
+
optionId: id,
|
|
2611
|
+
isKeyboardHighlighted: isKeyboardHighlighted,
|
|
2612
|
+
children: after
|
|
2613
|
+
})
|
|
2614
|
+
})]
|
|
2615
|
+
})
|
|
2616
|
+
});
|
|
2617
|
+
});
|
|
2618
|
+
|
|
2619
|
+
/**
|
|
2620
|
+
* Props for ComboboxOption with additional generic properties.
|
|
2621
|
+
*/
|
|
2622
|
+
|
|
2623
|
+
/**
|
|
2624
|
+
* Option to set within a combobox list.
|
|
2625
|
+
*
|
|
2626
|
+
* @family Combobox
|
|
2627
|
+
* @param ComboboxOptionProps
|
|
2628
|
+
* @returns ComboboxOption
|
|
2629
|
+
*/
|
|
2630
|
+
const ComboboxOption = forwardRef((props, ref) => {
|
|
2631
|
+
const {
|
|
2632
|
+
children,
|
|
2633
|
+
id,
|
|
2634
|
+
textValue,
|
|
2635
|
+
data,
|
|
2636
|
+
filterFromInput = true,
|
|
2637
|
+
onSelect: onOptionSelect,
|
|
2638
|
+
isDisabled,
|
|
2639
|
+
as = 'span',
|
|
2640
|
+
...optionProps
|
|
2641
|
+
} = props;
|
|
2642
|
+
|
|
2643
|
+
// Get the id of the current group, if any.
|
|
2644
|
+
const section = useComboboxSectionId();
|
|
2645
|
+
const {
|
|
2646
|
+
comboboxId,
|
|
2647
|
+
selectedIds,
|
|
2648
|
+
showAll,
|
|
2649
|
+
inputValue,
|
|
2650
|
+
handleSelected,
|
|
2651
|
+
type
|
|
2652
|
+
} = useCombobox();
|
|
2653
|
+
// Generate a unique id for this option.
|
|
2654
|
+
const generatedId = generateOptionId(comboboxId, id);
|
|
2655
|
+
const isSelected = selectedIds?.includes(generatedId);
|
|
2656
|
+
|
|
2657
|
+
// If no text value is set and the direct child is a simple string, use it as value.
|
|
2658
|
+
const isStringChild = typeof children === 'string' || typeof children === 'number';
|
|
2659
|
+
const value = children && !textValue && isStringChild ? children.toString() : textValue;
|
|
2660
|
+
const showOption = !filterFromInput || showAll || value?.toString()?.toLowerCase().includes(inputValue?.toLowerCase());
|
|
2661
|
+
const registeredOption = React__default.useMemo(() => ({
|
|
2662
|
+
id,
|
|
2663
|
+
generatedId,
|
|
2664
|
+
textValue: value,
|
|
2665
|
+
data,
|
|
2666
|
+
filter: filterFromInput,
|
|
2667
|
+
isDisabled: isDisabled || !showOption,
|
|
2668
|
+
sectionId: section.sectionId,
|
|
2669
|
+
onSelect: onOptionSelect
|
|
2670
|
+
}), [data, filterFromInput, generatedId, section.sectionId, id, isDisabled, onOptionSelect, showOption, value]);
|
|
2671
|
+
|
|
2672
|
+
// Register the option
|
|
2673
|
+
useRegisterOption(generatedId, registeredOption, showOption);
|
|
2674
|
+
const handleSelect = React__default.useCallback(() => handleSelected(registeredOption, 'click'), [handleSelected, registeredOption]);
|
|
2675
|
+
if (!id || !showOption) {
|
|
2676
|
+
return null;
|
|
2677
|
+
}
|
|
2678
|
+
return /*#__PURE__*/jsx(OptionContent, {
|
|
2679
|
+
id: generatedId,
|
|
2680
|
+
onSelect: handleSelect,
|
|
2681
|
+
isSelected: isSelected,
|
|
2682
|
+
isDisabled: isDisabled,
|
|
2683
|
+
as: as,
|
|
2684
|
+
ref: ref,
|
|
2685
|
+
comboboxType: type,
|
|
2686
|
+
"aria-hidden": section.isLoading,
|
|
2687
|
+
...optionProps,
|
|
2688
|
+
children: children || textValue
|
|
2689
|
+
});
|
|
2690
|
+
});
|
|
2691
|
+
|
|
2692
|
+
// Default widths the skeletons must have
|
|
2693
|
+
const defaultWidths = [REAL_SIZE_FOR_LUMX_SIZE.xxl, REAL_SIZE_FOR_LUMX_SIZE.xl, REAL_SIZE_FOR_LUMX_SIZE.l];
|
|
2694
|
+
const {
|
|
2695
|
+
block: block$X,
|
|
2696
|
+
element: element$J
|
|
2697
|
+
} = classNames.bem(COMBOBOX_OPTION_CLASSNAME);
|
|
2698
|
+
|
|
2699
|
+
/**
|
|
2700
|
+
* Skeleton for a combobox option.
|
|
2701
|
+
* A typography skeleton is rendered by default but can be overridden by passing children.
|
|
2702
|
+
*/
|
|
2703
|
+
const ComboboxOptionSkeleton = ({
|
|
2704
|
+
className,
|
|
2705
|
+
index,
|
|
2706
|
+
before,
|
|
2707
|
+
after,
|
|
2708
|
+
size = Size$1.tiny,
|
|
2709
|
+
children
|
|
2710
|
+
}) => {
|
|
2711
|
+
const renderedChildren = typeof children === 'function' ? children({
|
|
2712
|
+
index
|
|
2713
|
+
}) : children;
|
|
2714
|
+
const content = renderedChildren || /*#__PURE__*/jsx(SkeletonTypography, {
|
|
2715
|
+
typography: "body1",
|
|
2716
|
+
width: index !== undefined && defaultWidths[index] ? defaultWidths[index] : REAL_SIZE_FOR_LUMX_SIZE.xl
|
|
2717
|
+
});
|
|
2718
|
+
return /*#__PURE__*/jsxs("li", {
|
|
2719
|
+
role: "presentation",
|
|
2720
|
+
className: block$X({
|
|
2721
|
+
skeleton: true
|
|
2722
|
+
}, ['lumx-list-item', `lumx-list-item--size-${size}`, className]),
|
|
2723
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
2724
|
+
role: "presentation",
|
|
2725
|
+
className: element$J('content', ['lumx-list-item__wrapper']),
|
|
2726
|
+
children: [before && /*#__PURE__*/jsx(Text, {
|
|
2727
|
+
as: "span",
|
|
2728
|
+
role: "presentation",
|
|
2729
|
+
className: element$J('before', ['lumx-list-item__before']),
|
|
2730
|
+
children: before
|
|
2731
|
+
}), content]
|
|
2732
|
+
}), after && /*#__PURE__*/jsx("div", {
|
|
2733
|
+
role: "presentation",
|
|
2734
|
+
className: element$J('after', ['lumx-list-item__after']),
|
|
2735
|
+
children: after
|
|
2736
|
+
})]
|
|
2737
|
+
});
|
|
2738
|
+
};
|
|
2739
|
+
|
|
2740
|
+
/**
|
|
2741
|
+
* Action to set on a Combobox Option.
|
|
2742
|
+
* Allows to add an interactive element that
|
|
2743
|
+
* can be navigated to and triggered using the keyboard.
|
|
2744
|
+
*
|
|
2745
|
+
* Defaults as "button"
|
|
2746
|
+
*
|
|
2747
|
+
* @family Combobox
|
|
2748
|
+
* @param ComboboxOptionActionProps
|
|
2749
|
+
* @returns ComboboxOptionAction
|
|
2750
|
+
*/
|
|
2751
|
+
const ComboboxOptionAction = props => {
|
|
2752
|
+
const {
|
|
2753
|
+
as,
|
|
2754
|
+
isDisabled,
|
|
2755
|
+
onClick,
|
|
2756
|
+
id: originalId,
|
|
2757
|
+
...forwardedProps
|
|
2758
|
+
} = props;
|
|
2759
|
+
const {
|
|
2760
|
+
optionId
|
|
2761
|
+
} = useComboboxOptionContext();
|
|
2762
|
+
const {
|
|
2763
|
+
triggerRef
|
|
2764
|
+
} = useComboboxRefs();
|
|
2765
|
+
const itemRef = React__default.useRef(null);
|
|
2766
|
+
const generatedId = useId();
|
|
2767
|
+
const id = originalId || generatedId;
|
|
2768
|
+
const isHighlighted = useVirtualFocus(id, itemRef, isDisabled, optionId);
|
|
2769
|
+
const {
|
|
2770
|
+
state
|
|
2771
|
+
} = React__default.useContext(MovingFocusContext);
|
|
2772
|
+
const Component = as || 'button';
|
|
2773
|
+
const registeredActionOption = React__default.useMemo(() => ({
|
|
2774
|
+
id,
|
|
2775
|
+
generatedId: id,
|
|
2776
|
+
isAction: true,
|
|
2777
|
+
isDisabled,
|
|
2778
|
+
onSelect: () => {
|
|
2779
|
+
itemRef.current?.click();
|
|
2780
|
+
}
|
|
2781
|
+
}), [id, isDisabled]);
|
|
2782
|
+
|
|
2783
|
+
// Register the option
|
|
2784
|
+
useRegisterOption(id, registeredActionOption, !isDisabled);
|
|
2785
|
+
const handleActionClick = React__default.useCallback(() => {
|
|
2786
|
+
if (onClick) {
|
|
2787
|
+
onClick();
|
|
2788
|
+
}
|
|
2789
|
+
if (triggerRef?.current) {
|
|
2790
|
+
triggerRef.current?.focus();
|
|
2791
|
+
}
|
|
2792
|
+
}, [triggerRef, onClick]);
|
|
2793
|
+
return /*#__PURE__*/jsx(Component, {
|
|
2794
|
+
...forwardedProps,
|
|
2795
|
+
isDisabled: isDisabled,
|
|
2796
|
+
id: id,
|
|
2797
|
+
role: "gridcell",
|
|
2798
|
+
ref: itemRef,
|
|
2799
|
+
"data-focus-visible-added": state.isUsingKeyboard && isHighlighted ? 'true' : undefined,
|
|
2800
|
+
"aria-disabled": isDisabled,
|
|
2801
|
+
onClick: handleActionClick
|
|
2802
|
+
});
|
|
2803
|
+
};
|
|
2804
|
+
|
|
2805
|
+
const useBooleanState = defaultValue => {
|
|
2806
|
+
const [booleanValue, setBoolean] = useState(defaultValue);
|
|
2807
|
+
const setToFalse = useCallback(() => setBoolean(false), []);
|
|
2808
|
+
const setToTrue = useCallback(() => setBoolean(true), []);
|
|
2809
|
+
const toggleBoolean = useCallback(() => setBoolean(previousValue => !previousValue), []);
|
|
2810
|
+
return [booleanValue, setToFalse, setToTrue, toggleBoolean];
|
|
2811
|
+
};
|
|
2812
|
+
|
|
2813
|
+
const CLASSNAME$14 = 'lumx-combobox-option-more-info';
|
|
2814
|
+
const {
|
|
2815
|
+
block: block$W,
|
|
2816
|
+
element: element$I
|
|
2817
|
+
} = classNames.bem(CLASSNAME$14);
|
|
2818
|
+
|
|
2819
|
+
/**
|
|
2820
|
+
* Display more info on the option as a popover opening on mouse hover or keyboard nav
|
|
2821
|
+
* Please consider using a simpler option description instead for better UX and a11y.
|
|
2822
|
+
*
|
|
2823
|
+
* @family Combobox
|
|
2824
|
+
*/
|
|
2825
|
+
const ComboboxOptionMoreInfo = ({
|
|
2826
|
+
buttonProps,
|
|
2827
|
+
popoverProps,
|
|
2828
|
+
onToggle,
|
|
2829
|
+
children
|
|
2830
|
+
}) => {
|
|
2831
|
+
const ref = React__default.useRef(null);
|
|
2832
|
+
const [isHovered,, onMouseLeave, onMouseEnter] = useBooleanState(false);
|
|
2833
|
+
const comboboxOption = useComboboxOptionContext();
|
|
2834
|
+
|
|
2835
|
+
// Open on mouse hover or key nav
|
|
2836
|
+
const isOpen = isHovered || comboboxOption.isKeyboardHighlighted;
|
|
2837
|
+
React__default.useEffect(() => {
|
|
2838
|
+
onToggle?.(isOpen);
|
|
2839
|
+
}, [isOpen, onToggle]);
|
|
2840
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
2841
|
+
children: [/*#__PURE__*/jsx(IconButton, {
|
|
2842
|
+
...buttonProps,
|
|
2843
|
+
ref: ref,
|
|
2844
|
+
className: block$W([buttonProps?.className]),
|
|
2845
|
+
icon: mdiInformationOutline,
|
|
2846
|
+
size: "s",
|
|
2847
|
+
emphasis: "low",
|
|
2848
|
+
onMouseEnter: onMouseEnter,
|
|
2849
|
+
onMouseLeave: onMouseLeave
|
|
2850
|
+
// Button actually plays no role here other than a target for the mouse hover
|
|
2851
|
+
// Keyboard accessibility is handled via combobox keyboard highlighting
|
|
2852
|
+
,
|
|
2853
|
+
"aria-hidden": true,
|
|
2854
|
+
label: ""
|
|
2855
|
+
}), /*#__PURE__*/jsx(Popover, {
|
|
2856
|
+
...popoverProps,
|
|
2857
|
+
className: element$I('popover', [popoverProps?.className]),
|
|
2858
|
+
anchorRef: ref,
|
|
2859
|
+
isOpen: isOpen,
|
|
2860
|
+
closeOnEscape: true,
|
|
2861
|
+
closeOnClickAway: true,
|
|
2862
|
+
placement: "bottom-start",
|
|
2863
|
+
children: children
|
|
2864
|
+
}), /*#__PURE__*/jsx(A11YLiveMessage, {
|
|
2865
|
+
hidden: true,
|
|
2866
|
+
children: isOpen ? children : undefined
|
|
2867
|
+
})]
|
|
2868
|
+
});
|
|
2869
|
+
};
|
|
2870
|
+
|
|
2221
2871
|
/**
|
|
2222
2872
|
* Comment block variants.
|
|
2223
2873
|
*/
|
|
@@ -2836,14 +3486,6 @@ const DatePicker = forwardRef((props, ref) => {
|
|
|
2836
3486
|
DatePicker.displayName = COMPONENT_NAME$14;
|
|
2837
3487
|
DatePicker.className = CLASSNAME$12;
|
|
2838
3488
|
|
|
2839
|
-
const useBooleanState = defaultValue => {
|
|
2840
|
-
const [booleanValue, setBoolean] = useState(defaultValue);
|
|
2841
|
-
const setToFalse = useCallback(() => setBoolean(false), []);
|
|
2842
|
-
const setToTrue = useCallback(() => setBoolean(true), []);
|
|
2843
|
-
const toggleBoolean = useCallback(() => setBoolean(previousValue => !previousValue), []);
|
|
2844
|
-
return [booleanValue, setToFalse, setToTrue, toggleBoolean];
|
|
2845
|
-
};
|
|
2846
|
-
|
|
2847
3489
|
/**
|
|
2848
3490
|
* Component display name.
|
|
2849
3491
|
*/
|
|
@@ -15332,5 +15974,5 @@ UserBlock.displayName = COMPONENT_NAME;
|
|
|
15332
15974
|
UserBlock.className = CLASSNAME;
|
|
15333
15975
|
UserBlock.defaultProps = DEFAULT_PROPS;
|
|
15334
15976
|
|
|
15335
|
-
export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonGroup, CLASSNAME$
|
|
15977
|
+
export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonGroup, CLASSNAME$1e as CLASSNAME, COMBOBOX_OPTION_CLASSNAME, COMPONENT_NAME$1e as COMPONENT_NAME, Checkbox, Chip, ChipGroup, ComboboxOption, ComboboxOptionAction, ComboboxOptionMoreInfo, ComboboxOptionSkeleton, 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, 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 };
|
|
15336
15978
|
//# sourceMappingURL=index.js.map
|