@qualtrics/ui-react 2.24.2 → 2.25.0
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/CHANGELOG.md +10 -0
- package/dist/__shared/cjs/{index-8f52588d.js → index-5b3b3406.js} +3 -3
- package/dist/__shared/cjs/{index-b7a35c2e.js → index-610a1e02.js} +133 -133
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
- package/dist/components/Checkbox/Checkbox2.js +3 -3
- package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/FilePicker/FilePicker2.js +3 -3
- package/dist/components/FormField/Caption.js +3 -3
- package/dist/components/FormField/FormField2.js +3 -3
- package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
- package/dist/components/IconButton/IconButton2.js +3 -3
- package/dist/components/InlineInput/InlineInput2.js +3 -3
- package/dist/components/Input/Input2.js +3 -3
- package/dist/components/InputGroup/InputGroup2.js +3 -3
- package/dist/components/Label/Label2.js +3 -3
- package/dist/components/Link/Link2.js +3 -3
- package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/PageLayout/PageLayout.js +3 -3
- package/dist/components/Pagination/Pagination2.js +3 -3
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/Radio/Radio2.js +3 -3
- package/dist/components/SearchInput/SearchInput2.js +3 -3
- package/dist/components/SidebarNav/SidebarNav2.js +3 -3
- package/dist/components/Slider/Slider2.js +3 -3
- package/dist/components/Switch/Switch2.js +3 -3
- package/dist/components/Table/Table2.js +3 -3
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
- package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
- package/dist/hooks/useOverlay/useOverlay.js +1 -1
- package/dist/hooks/useOverlay/useOverlay2.js +3 -3
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.es.js +2 -1
- package/dist/index.js +4 -3
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTableCheckbox.js +6 -3
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Drawer/Drawer2.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/Menu/Menu.js +4 -1
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuButton.js +5 -2
- package/dist/next/Menu/MenuItem.js +19 -4
- package/dist/next/Menu/MenuPane.js +48 -32
- package/dist/next/Menu/SubMenu.js +49 -21
- package/dist/next/Menu/useCSSVariable.js +1 -1
- package/dist/next/Menu/usePaneSearch.js +20 -15
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/Select/Select.js +114 -0
- package/dist/next/Select/Select2.js +8 -0
- package/dist/next/Select/SelectButton.js +46 -0
- package/dist/next/Select/SelectContext.js +16 -0
- package/dist/next/Select/SelectItem.js +46 -0
- package/dist/next/Select/SelectPane.js +43 -0
- package/dist/next/Select/SelectedItems.js +45 -0
- package/dist/next/Select/SubSelect.js +90 -0
- package/dist/next/Select/constants.js +13 -0
- package/dist/next/Select/index.js +5 -0
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.d.ts +54 -6
- package/dist/next/index.es.js +6 -0
- package/dist/next/index.js +680 -255
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/next/package.json +1 -1
- package/package.json +3 -2
|
@@ -6,9 +6,11 @@ import '../../icons/index.es.js';
|
|
|
6
6
|
import styles from './Menu2.js';
|
|
7
7
|
import '../../utils/index.js';
|
|
8
8
|
import { useMenuContext } from './MenuContext.js';
|
|
9
|
-
import { DATA_TESTID_SUFFIXES } from './constants.js';
|
|
9
|
+
import { DATA_TESTID_SUFFIXES as DATA_TESTID_SUFFIXES$1 } from './constants.js';
|
|
10
10
|
import '../../hooks/index.js';
|
|
11
11
|
import '../../components/index.js';
|
|
12
|
+
import { DATA_TESTID_SUFFIXES } from '../Select/constants.js';
|
|
13
|
+
import useSelectContext from '../Select/SelectContext.js';
|
|
12
14
|
import Tooltip from '../../components/Tooltip/Tooltip.js';
|
|
13
15
|
import useIsTruncated from '../../hooks/useIsTruncated/useIsTruncated.js';
|
|
14
16
|
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
@@ -43,6 +45,7 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef((_ref2, ref) => {
|
|
|
43
45
|
triggerRef
|
|
44
46
|
} = useMenuContext();
|
|
45
47
|
const isTruncated = useIsTruncated(triggerRef);
|
|
48
|
+
const withinSelect = useSelectContext(true) !== null;
|
|
46
49
|
return /*#__PURE__*/React__default.createElement(AsChildWrapper, {
|
|
47
50
|
asChild: asChild,
|
|
48
51
|
tooltipContent: children,
|
|
@@ -54,7 +57,7 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef((_ref2, ref) => {
|
|
|
54
57
|
}),
|
|
55
58
|
asChild: asChild,
|
|
56
59
|
ref: mergeRefs(triggerRef, ref),
|
|
57
|
-
"data-testid": getSubDataTestId(rootDataTestId, DATA_TESTID_SUFFIXES.MENU_BUTTON)
|
|
60
|
+
"data-testid": getSubDataTestId(rootDataTestId, withinSelect ? DATA_TESTID_SUFFIXES.SELECT_BUTTON : DATA_TESTID_SUFFIXES$1.MENU_BUTTON)
|
|
58
61
|
}), children), !asChild && /*#__PURE__*/React__default.createElement(ChevronDownIcon, {
|
|
59
62
|
className: styles.rightIcon,
|
|
60
63
|
"aria-hidden": "true"
|
|
@@ -6,7 +6,9 @@ import { useFocusVisible } from '@react-aria/interactions';
|
|
|
6
6
|
import styles from './Menu2.js';
|
|
7
7
|
import { usePaneContext } from './MenuContext.js';
|
|
8
8
|
import '../../utils/index.js';
|
|
9
|
-
import { DATA_TESTID_SUFFIXES
|
|
9
|
+
import { DATA_TESTID_SUFFIXES } from '../Select/constants.js';
|
|
10
|
+
import { DATA_TESTID_SUFFIXES as DATA_TESTID_SUFFIXES$1, KEYS } from './constants.js';
|
|
11
|
+
import useSelectContext from '../Select/SelectContext.js';
|
|
10
12
|
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
11
13
|
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
12
14
|
|
|
@@ -20,6 +22,9 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
20
22
|
label,
|
|
21
23
|
...rest
|
|
22
24
|
} = _ref;
|
|
25
|
+
const selectContext = useSelectContext(true);
|
|
26
|
+
const withinSelect = selectContext !== null;
|
|
27
|
+
const multiselect = selectContext === null || selectContext === void 0 ? void 0 : selectContext.multiselect;
|
|
23
28
|
const itemRef = useRef(null);
|
|
24
29
|
const {
|
|
25
30
|
dataTestId: menuParentDataTestId,
|
|
@@ -36,7 +41,7 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
36
41
|
} = useFocusVisible({
|
|
37
42
|
isTextInput: true
|
|
38
43
|
});
|
|
39
|
-
const dataTestId = getSubDataTestId(menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM), String(index));
|
|
44
|
+
const dataTestId = getSubDataTestId(menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(withinSelect ? DATA_TESTID_SUFFIXES.SELECT_PANE : DATA_TESTID_SUFFIXES$1.MENU_PANE, withinSelect ? DATA_TESTID_SUFFIXES.SELECT_ITEM : DATA_TESTID_SUFFIXES$1.MENU_ITEM), String(index));
|
|
40
45
|
const isVisible = useMemo(() => {
|
|
41
46
|
const searchMatcher = label !== null && label !== void 0 ? label : typeof children === 'string' ? children : undefined;
|
|
42
47
|
return isSearchFilteringDisabled || !searchValue || (searchMatcher === null || searchMatcher === void 0 ? void 0 : searchMatcher.toLowerCase().includes(searchValue.toLowerCase()));
|
|
@@ -74,8 +79,18 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
74
79
|
// stop radix from closing the menu on selection of disabled item
|
|
75
80
|
// other pointer and keyboard events still work, even when disabled
|
|
76
81
|
,
|
|
77
|
-
onSelect: e =>
|
|
82
|
+
onSelect: e => {
|
|
83
|
+
if (isDisabled) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (multiselect) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
}
|
|
90
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
|
91
|
+
}
|
|
78
92
|
}), (!children || typeof children === 'string') && label ? label : children) : null;
|
|
79
93
|
});
|
|
94
|
+
var MenuItem$1 = MenuItem;
|
|
80
95
|
|
|
81
|
-
export { MenuItem as default };
|
|
96
|
+
export { MenuItem$1 as default };
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
2
|
-
import React__default, { useState, useRef, useMemo } from 'react';
|
|
2
|
+
import React__default, { useState, useRef, useMemo, useEffect } from 'react';
|
|
3
3
|
import { Portal, Content } from '@radix-ui/react-dropdown-menu';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import styles from './Menu2.js';
|
|
6
6
|
import { usePortalTarget } from '../../components/UIProvider/PortalTargetContext.js';
|
|
7
7
|
import { useMenuContext, PaneContextProvider } from './MenuContext.js';
|
|
8
8
|
import '../../utils/index.js';
|
|
9
|
-
import { DATA_TESTID_SUFFIXES } from './constants.js';
|
|
9
|
+
import { DATA_TESTID_SUFFIXES as DATA_TESTID_SUFFIXES$1 } from './constants.js';
|
|
10
|
+
import { DATA_TESTID_SUFFIXES } from '../Select/constants.js';
|
|
10
11
|
import MenuSearch from './MenuSearch.js';
|
|
11
12
|
import usePaneSearch from './usePaneSearch.js';
|
|
12
13
|
import '../../hooks/index.js';
|
|
13
14
|
import useMutationObserver from './useMutationObserver.js';
|
|
14
15
|
import useOverlay from '../../hooks/useOverlay/useOverlay.js';
|
|
15
16
|
import useCSSVariable from './useCSSVariable.js';
|
|
17
|
+
import useSelectContext from '../Select/SelectContext.js';
|
|
18
|
+
import SelectedItems from '../Select/SelectedItems.js';
|
|
16
19
|
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
17
20
|
import useId from '../../hooks/useId/useId.js';
|
|
18
|
-
import { useDidUpdate } from '../../hooks/useDidUpdate/useDidUpdate.js';
|
|
19
21
|
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
20
22
|
|
|
21
23
|
const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
22
|
-
var _flyoutRef$current$pa, _flyoutRef$
|
|
24
|
+
var _flyoutRef$current$pa, _flyoutRef$current3, _flyoutRef$current4;
|
|
23
25
|
let {
|
|
24
26
|
placement,
|
|
25
27
|
children,
|
|
@@ -35,6 +37,12 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
35
37
|
const [items, setItems] = useState([]);
|
|
36
38
|
const flyoutRef = useRef(null);
|
|
37
39
|
const stickyBoxRef = useRef(null);
|
|
40
|
+
const selectContext = useSelectContext(true);
|
|
41
|
+
const withinSelect = selectContext !== null;
|
|
42
|
+
const {
|
|
43
|
+
multiselect,
|
|
44
|
+
showSelectedItemsPane
|
|
45
|
+
} = selectContext !== null && selectContext !== void 0 ? selectContext : {};
|
|
38
46
|
const portalTarget = usePortalTarget();
|
|
39
47
|
const [side, align] = useMemo(() => {
|
|
40
48
|
var _placement$split, _placement$split2;
|
|
@@ -47,7 +55,9 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
47
55
|
maskHeight,
|
|
48
56
|
open,
|
|
49
57
|
triggerRef,
|
|
50
|
-
searchBarConfigs
|
|
58
|
+
searchBarConfigs,
|
|
59
|
+
setMaskWidth,
|
|
60
|
+
maskWidth
|
|
51
61
|
} = useMenuContext();
|
|
52
62
|
const thisPanesDepth = 1;
|
|
53
63
|
const maskContainerId = 'maskContainer';
|
|
@@ -57,29 +67,28 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
57
67
|
opacity: 0
|
|
58
68
|
});
|
|
59
69
|
const animatedLeft = useMemo(() => openPaneDepth > thisPanesDepth, [openPaneDepth]);
|
|
60
|
-
const dataTestId = getSubDataTestId(rootDataTestId, DATA_TESTID_SUFFIXES.MENU_PANE);
|
|
70
|
+
const dataTestId = getSubDataTestId(rootDataTestId, withinSelect ? DATA_TESTID_SUFFIXES.SELECT_PANE : DATA_TESTID_SUFFIXES$1.MENU_PANE);
|
|
61
71
|
const {
|
|
62
72
|
internalSearchValue,
|
|
63
73
|
noSearchResultsNode,
|
|
64
74
|
onInteractOutside
|
|
65
|
-
} = usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, items, animatedLeft, false, dataTestId, useId(), flyoutRef);
|
|
66
|
-
|
|
67
|
-
// In order to preseve the css animation for vertical resizing, we cannot set the height of this pane to `auto`. It must be a pixel value.
|
|
68
|
-
// We cache the pixel value here, to use it later if the user returns to this pane from a submenu.
|
|
69
|
-
const initialHeightOfThisPane = useRef(null);
|
|
70
|
-
useDidUpdate(() => {
|
|
75
|
+
} = usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, items, animatedLeft, false, dataTestId, useId(), flyoutRef, withinSelect);
|
|
76
|
+
useEffect(() => {
|
|
71
77
|
if (openPaneDepth === thisPanesDepth) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
78
|
+
window.requestAnimationFrame(() => {
|
|
79
|
+
var _flyoutRef$current, _flyoutRef$current2;
|
|
80
|
+
if ((_flyoutRef$current = flyoutRef.current) !== null && _flyoutRef$current !== void 0 && _flyoutRef$current.clientHeight) {
|
|
81
|
+
setMaskHeight(flyoutRef.current.clientHeight);
|
|
82
|
+
}
|
|
83
|
+
if ((_flyoutRef$current2 = flyoutRef.current) !== null && _flyoutRef$current2 !== void 0 && _flyoutRef$current2.clientWidth) {
|
|
84
|
+
setMaskWidth(flyoutRef.current.clientWidth);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} else if (openPaneDepth === 0) {
|
|
88
|
+
setMaskHeight('auto');
|
|
89
|
+
setMaskWidth('auto');
|
|
81
90
|
}
|
|
82
|
-
}, [openPaneDepth]);
|
|
91
|
+
}, [openPaneDepth, internalSearchValue, setMaskHeight, setMaskWidth]);
|
|
83
92
|
const defaultSide = useMemo(() => {
|
|
84
93
|
var _triggerRef$current;
|
|
85
94
|
const rect = triggerRef === null || triggerRef === void 0 || (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.getBoundingClientRect();
|
|
@@ -104,9 +113,12 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
104
113
|
return 'top';
|
|
105
114
|
}
|
|
106
115
|
return 'bottom';
|
|
107
|
-
},
|
|
116
|
+
},
|
|
117
|
+
// including `open` because the trigger location may change between openings
|
|
118
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
119
|
+
[open, triggerRef]);
|
|
108
120
|
const [transform, setTransform] = useState('');
|
|
109
|
-
const target = (_flyoutRef$current$pa = (_flyoutRef$
|
|
121
|
+
const target = (_flyoutRef$current$pa = (_flyoutRef$current3 = flyoutRef.current) === null || _flyoutRef$current3 === void 0 ? void 0 : _flyoutRef$current3.parentNode) !== null && _flyoutRef$current$pa !== void 0 ? _flyoutRef$current$pa : undefined;
|
|
110
122
|
useMutationObserver(target, {
|
|
111
123
|
attributes: true,
|
|
112
124
|
attributeFilter: ['style']
|
|
@@ -114,7 +126,12 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
114
126
|
var _style$transform, _style;
|
|
115
127
|
return setTransform((_style$transform = target === null || target === void 0 || (_style = target.style) === null || _style === void 0 ? void 0 : _style.transform) !== null && _style$transform !== void 0 ? _style$transform : '');
|
|
116
128
|
});
|
|
129
|
+
|
|
130
|
+
// We use the top-level Radix container as a mask. Radix does not expose this container to consumers, except through CSS.
|
|
131
|
+
// This hook is dynamically updating the style of that container using a CSS variable.
|
|
117
132
|
useCSSVariable('--mask-z-index', String(zIndex), [open]);
|
|
133
|
+
useCSSVariable('--mask-width', "".concat(maskWidth, "px"));
|
|
134
|
+
useCSSVariable('--mask-height', "".concat(maskHeight, "px"));
|
|
118
135
|
return /*#__PURE__*/React__default.createElement(PaneContextProvider, {
|
|
119
136
|
items: items,
|
|
120
137
|
setItems: setItems,
|
|
@@ -147,22 +164,21 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
147
164
|
[styles.animatedLeft]: animatedLeft
|
|
148
165
|
}, styles.flyout),
|
|
149
166
|
onInteractOutside: onInteractOutside,
|
|
150
|
-
style:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
className: classNames(styles.stickyBox, styles.isSearchable),
|
|
167
|
+
style: style
|
|
168
|
+
}), (isSearchable || multiselect && showSelectedItemsPane) && /*#__PURE__*/React__default.createElement("div", {
|
|
169
|
+
className: classNames(styles.stickyBox, {
|
|
170
|
+
[styles.isSearchable]: isSearchable
|
|
171
|
+
}),
|
|
156
172
|
ref: stickyBoxRef,
|
|
157
173
|
style: {
|
|
158
174
|
zIndex
|
|
159
175
|
}
|
|
160
|
-
}), noSearchResultsNode, children), /*#__PURE__*/React__default.createElement("div", {
|
|
176
|
+
}, showSelectedItemsPane && multiselect && /*#__PURE__*/React__default.createElement(SelectedItems, null)), noSearchResultsNode, children), /*#__PURE__*/React__default.createElement("div", {
|
|
161
177
|
className: styles.searchBoxesContainer,
|
|
162
178
|
style: {
|
|
163
179
|
transform,
|
|
164
180
|
zIndex: zIndex + openPaneDepth,
|
|
165
|
-
width: (_flyoutRef$
|
|
181
|
+
width: (_flyoutRef$current4 = flyoutRef.current) === null || _flyoutRef$current4 === void 0 ? void 0 : _flyoutRef$current4.clientWidth
|
|
166
182
|
}
|
|
167
183
|
}, searchBarConfigs.length ? searchBarConfigs.map(_ref2 => {
|
|
168
184
|
let {
|
|
@@ -7,9 +7,13 @@ import styles from './Menu2.js';
|
|
|
7
7
|
import '../../icons/index.es.js';
|
|
8
8
|
import { usePaneContext, useMenuContext, PaneContextProvider } from './MenuContext.js';
|
|
9
9
|
import '../../utils/index.js';
|
|
10
|
-
import { DATA_TESTID_SUFFIXES, KEYS } from './constants.js';
|
|
10
|
+
import { DATA_TESTID_SUFFIXES as DATA_TESTID_SUFFIXES$1, KEYS as KEYS$1 } from './constants.js';
|
|
11
|
+
import { DATA_TESTID_SUFFIXES, KEYS } from '../Select/constants.js';
|
|
11
12
|
import '../../hooks/index.js';
|
|
12
13
|
import usePaneSearch from './usePaneSearch.js';
|
|
14
|
+
import useSelectContext from '../Select/SelectContext.js';
|
|
15
|
+
import AdvancedTableCheckbox from '../AdvancedTable/AdvancedTableCheckbox.js';
|
|
16
|
+
import styles$1 from '../Select/Select2.js';
|
|
13
17
|
import useId from '../../hooks/useId/useId.js';
|
|
14
18
|
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
15
19
|
import { useDidUpdate } from '../../hooks/useDidUpdate/useDidUpdate.js';
|
|
@@ -31,6 +35,16 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
31
35
|
onIsOpenChange,
|
|
32
36
|
...rest
|
|
33
37
|
} = _ref;
|
|
38
|
+
const selectContext = useSelectContext(true);
|
|
39
|
+
const withinSelect = selectContext !== null;
|
|
40
|
+
const {
|
|
41
|
+
subSelectTriggerProps,
|
|
42
|
+
multiselect,
|
|
43
|
+
subSelectPaneProps,
|
|
44
|
+
isSelectedItems,
|
|
45
|
+
triggerCheckedState = 'false',
|
|
46
|
+
onTriggerCheckboxSelect
|
|
47
|
+
} = selectContext !== null && selectContext !== void 0 ? selectContext : {};
|
|
34
48
|
const [items, setItems] = useState([]);
|
|
35
49
|
const internalId = useId();
|
|
36
50
|
const triggerRef = useRef(null);
|
|
@@ -49,7 +63,8 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
49
63
|
const {
|
|
50
64
|
openPaneDepth: totalOpenPaneDepth,
|
|
51
65
|
registerSubmenu,
|
|
52
|
-
setMaskHeight
|
|
66
|
+
setMaskHeight,
|
|
67
|
+
setMaskWidth
|
|
53
68
|
} = useMenuContext();
|
|
54
69
|
const {
|
|
55
70
|
isFocusVisible
|
|
@@ -60,7 +75,7 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
60
75
|
const [isFrameAfterPaneAddedToDOM, setIsFrameAfterPaneAddedToDOM] = useState(false);
|
|
61
76
|
const [isTransitioningFromRight, setIsTransitioningFromRight] = useState(false);
|
|
62
77
|
const animatedLeft = useMemo(() => thisPanesDepth < totalOpenPaneDepth, [totalOpenPaneDepth, thisPanesDepth]);
|
|
63
|
-
const animatedRight = useMemo(() => thisPanesDepth > totalOpenPaneDepth || isFrameAfterPaneAddedToDOM, [totalOpenPaneDepth, isFrameAfterPaneAddedToDOM, thisPanesDepth]);
|
|
78
|
+
const animatedRight = useMemo(() => thisPanesDepth > totalOpenPaneDepth || thisPanesDepth === totalOpenPaneDepth && !isPaneInDOM || isFrameAfterPaneAddedToDOM, [totalOpenPaneDepth, isFrameAfterPaneAddedToDOM, thisPanesDepth, isPaneInDOM]);
|
|
64
79
|
const paneDataTestId = getSubDataTestId(paneContainingTriggerDataTestId, String(triggerIndex));
|
|
65
80
|
const closeThisSubmenu = e => {
|
|
66
81
|
// prevent closing the entire menu, and Radix keyboard navigation
|
|
@@ -71,9 +86,9 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
71
86
|
internalSearchValue,
|
|
72
87
|
noSearchResultsNode,
|
|
73
88
|
onInteractOutside
|
|
74
|
-
} = usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, items, animatedLeft, animatedRight, paneDataTestId, internalId, flyoutRef, backButtonRef, closeThisSubmenu);
|
|
75
|
-
const backButtonDataTestId = paneDataTestId === null || paneDataTestId === void 0 ? void 0 : paneDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_BACK);
|
|
76
|
-
const triggerDataTestId = paneDataTestId === null || paneDataTestId === void 0 ? void 0 : paneDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM);
|
|
89
|
+
} = usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, items, animatedLeft, animatedRight, paneDataTestId, internalId, flyoutRef, withinSelect, backButtonRef, closeThisSubmenu);
|
|
90
|
+
const backButtonDataTestId = paneDataTestId === null || paneDataTestId === void 0 ? void 0 : paneDataTestId.replace(withinSelect ? DATA_TESTID_SUFFIXES.SELECT_PANE : DATA_TESTID_SUFFIXES$1.MENU_PANE, withinSelect ? DATA_TESTID_SUFFIXES.SELECT_BACK : DATA_TESTID_SUFFIXES$1.MENU_BACK);
|
|
91
|
+
const triggerDataTestId = paneDataTestId === null || paneDataTestId === void 0 ? void 0 : paneDataTestId.replace(withinSelect ? DATA_TESTID_SUFFIXES.SELECT_PANE : DATA_TESTID_SUFFIXES$1.MENU_PANE, withinSelect ? DATA_TESTID_SUFFIXES.SELECT_ITEM : DATA_TESTID_SUFFIXES$1.MENU_ITEM);
|
|
77
92
|
const triggerIsVisible = useMemo(() => isSearchFilteringDisabledForPaneContainingTrigger || !paneContainingTriggerSearchValue || typeof label === 'string' && label.toLowerCase().includes(paneContainingTriggerSearchValue.toLowerCase()), [paneContainingTriggerSearchValue, label, isSearchFilteringDisabledForPaneContainingTrigger]);
|
|
78
93
|
useDidUpdate(() => {
|
|
79
94
|
if (isPaneInDOM) {
|
|
@@ -90,9 +105,9 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
90
105
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
106
|
useEffect(() => () => registerSubmenu(internalId, false), []);
|
|
92
107
|
useDidUpdate(() => {
|
|
93
|
-
if (thisPanesDepth === totalOpenPaneDepth) {
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
if (thisPanesDepth === totalOpenPaneDepth && flyoutRef.current) {
|
|
109
|
+
setMaskHeight(flyoutRef.current.clientHeight);
|
|
110
|
+
setMaskWidth(flyoutRef.current.clientWidth);
|
|
96
111
|
}
|
|
97
112
|
},
|
|
98
113
|
// ignoring other dependencies because this should only run when the children change
|
|
@@ -100,13 +115,15 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
100
115
|
useDidUpdate(() => {
|
|
101
116
|
if (thisPanesDepth === totalOpenPaneDepth) {
|
|
102
117
|
window.requestAnimationFrame(() => {
|
|
103
|
-
|
|
104
|
-
|
|
118
|
+
if (flyoutRef.current) {
|
|
119
|
+
setMaskHeight(flyoutRef.current.clientHeight);
|
|
120
|
+
setMaskWidth(flyoutRef.current.clientWidth);
|
|
121
|
+
}
|
|
105
122
|
});
|
|
106
123
|
}
|
|
107
124
|
}, [totalOpenPaneDepth, internalSearchValue]);
|
|
108
125
|
const handlePaneTransitionEnd = () => {
|
|
109
|
-
var _flyoutRef$
|
|
126
|
+
var _flyoutRef$current;
|
|
110
127
|
if (animatedLeft) {
|
|
111
128
|
return;
|
|
112
129
|
}
|
|
@@ -120,7 +137,7 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
120
137
|
}
|
|
121
138
|
|
|
122
139
|
// if the newly closed submenu doesn't place the focus on its trigger due to mouse events
|
|
123
|
-
if (!((_flyoutRef$
|
|
140
|
+
if (!((_flyoutRef$current = flyoutRef.current) !== null && _flyoutRef$current !== void 0 && _flyoutRef$current.contains(document.activeElement)) && isFocusVisible) {
|
|
124
141
|
if (triggerRef.current && paneContainingTriggerIsInteractive) {
|
|
125
142
|
triggerRef.current.focus();
|
|
126
143
|
} else if (backButtonRef.current) {
|
|
@@ -131,9 +148,10 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
131
148
|
};
|
|
132
149
|
return triggerIsVisible ? /*#__PURE__*/React__default.createElement(Sub, {
|
|
133
150
|
open: isPaneInDOM
|
|
134
|
-
}, /*#__PURE__*/React__default.createElement(SubTrigger, {
|
|
151
|
+
}, /*#__PURE__*/React__default.createElement(SubTrigger, _extends({
|
|
135
152
|
className: classNames(styles.menuItem, styles.subMenu, {
|
|
136
|
-
[styles.unresponsive]: !paneContainingTriggerIsInteractive
|
|
153
|
+
[styles.unresponsive]: !paneContainingTriggerIsInteractive,
|
|
154
|
+
[styles$1.selectedItem]: triggerCheckedState === 'true' && !isSelectedItems
|
|
137
155
|
}),
|
|
138
156
|
"data-testid": triggerDataTestId,
|
|
139
157
|
"aria-disabled": isDisabled,
|
|
@@ -144,13 +162,22 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
144
162
|
e.preventDefault();
|
|
145
163
|
return;
|
|
146
164
|
}
|
|
147
|
-
if (!
|
|
165
|
+
if (multiselect && !isSelectedItems && KEYS.CHECK_PARENT.includes(e.key)) {
|
|
166
|
+
onTriggerCheckboxSelect === null || onTriggerCheckboxSelect === void 0 ? void 0 : onTriggerCheckboxSelect();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (!isDisabled && KEYS$1.OPEN_SUBMENU.includes(e.key)) {
|
|
148
170
|
setIsPaneInDOM(true);
|
|
149
|
-
} else if (KEYS.CLOSE_SUBMENU.includes(e.key)) {
|
|
171
|
+
} else if (KEYS$1.CLOSE_SUBMENU.includes(e.key)) {
|
|
150
172
|
closeSubmenuContainingTrigger === null || closeSubmenuContainingTrigger === void 0 ? void 0 : closeSubmenuContainingTrigger(e);
|
|
151
173
|
}
|
|
152
174
|
}
|
|
153
|
-
},
|
|
175
|
+
}, subSelectTriggerProps), multiselect && !isSelectedItems ? /*#__PURE__*/React__default.createElement(AdvancedTableCheckbox, {
|
|
176
|
+
state: triggerCheckedState,
|
|
177
|
+
className: styles$1.checkbox,
|
|
178
|
+
onClick: onTriggerCheckboxSelect,
|
|
179
|
+
isDisabled: isDisabled
|
|
180
|
+
}) : null, label, /*#__PURE__*/React__default.createElement(ChevronRightIcon, {
|
|
154
181
|
className: styles.rightIcon
|
|
155
182
|
})), /*#__PURE__*/React__default.createElement(PaneContextProvider, {
|
|
156
183
|
items: items,
|
|
@@ -179,7 +206,7 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
179
206
|
...style,
|
|
180
207
|
zIndex
|
|
181
208
|
}
|
|
182
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
209
|
+
}, subSelectPaneProps), /*#__PURE__*/React__default.createElement("div", {
|
|
183
210
|
className: classNames(styles.stickyBox, {
|
|
184
211
|
[styles.isSearchable]: isSearchable
|
|
185
212
|
}),
|
|
@@ -195,7 +222,7 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
195
222
|
onSelect: closeThisSubmenu,
|
|
196
223
|
ref: backButtonRef,
|
|
197
224
|
onKeyDown: e => {
|
|
198
|
-
if (KEYS.CLOSE_SUBMENU.includes(e.key)) {
|
|
225
|
+
if (KEYS$1.CLOSE_SUBMENU.includes(e.key)) {
|
|
199
226
|
closeThisSubmenu(e);
|
|
200
227
|
}
|
|
201
228
|
}
|
|
@@ -204,5 +231,6 @@ const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
204
231
|
className: styles.backIcon
|
|
205
232
|
}), label)), noSearchResultsNode, children))) : null;
|
|
206
233
|
});
|
|
234
|
+
var SubMenu$1 = SubMenu;
|
|
207
235
|
|
|
208
|
-
export { SubMenu as default };
|
|
236
|
+
export { SubMenu$1 as default };
|
|
@@ -4,7 +4,7 @@ const useCSSVariable = function (name, value) {
|
|
|
4
4
|
let dependencies = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
document.documentElement.style.setProperty(name, value !== null && value !== void 0 ? value : null);
|
|
7
|
-
}, [value, ...dependencies]);
|
|
7
|
+
}, [value, name, ...dependencies]);
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export { useCSSVariable as default };
|
|
@@ -3,7 +3,8 @@ import classNames from 'classnames';
|
|
|
3
3
|
import '../../hooks/index.js';
|
|
4
4
|
import '../../utils/index.js';
|
|
5
5
|
import { useMenuContext } from './MenuContext.js';
|
|
6
|
-
import { KEYS, DATA_TESTID_SUFFIXES } from './constants.js';
|
|
6
|
+
import { KEYS, DATA_TESTID_SUFFIXES as DATA_TESTID_SUFFIXES$1 } from './constants.js';
|
|
7
|
+
import { DATA_TESTID_SUFFIXES } from '../Select/constants.js';
|
|
7
8
|
import styles from './Menu2.js';
|
|
8
9
|
import useControllableState from '../../hooks/useControllableState/useControllableState.js';
|
|
9
10
|
import useTranslation from '../../utils/Translation/useTranslation.js';
|
|
@@ -14,8 +15,9 @@ import useEventListener from '../../hooks/useEventListener/useEventListener.js';
|
|
|
14
15
|
// returns values that are necessary for use within pane
|
|
15
16
|
function usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, items, animatedLeft, animatedRight, menuParentDataTestId, id, flyoutRef) {
|
|
16
17
|
var _searchRef$current$qu, _searchRef$current;
|
|
17
|
-
let
|
|
18
|
-
let
|
|
18
|
+
let withinSelect = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : undefined;
|
|
19
|
+
let backButtonRef = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : undefined;
|
|
20
|
+
let closeSubmenu = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : undefined;
|
|
19
21
|
const [internalSearchValue, setSearchValue] = useControllableState(externalSearchValue, onSearchValueChange, externalSearchValue);
|
|
20
22
|
const [zeroSearchResults, setZeroSearchResults] = useState();
|
|
21
23
|
const {
|
|
@@ -81,7 +83,7 @@ function usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, i
|
|
|
81
83
|
}) && e.preventDefault(), [searchBarConfigs]);
|
|
82
84
|
useEffect(() => {
|
|
83
85
|
if (!isSearchable) {
|
|
84
|
-
return
|
|
86
|
+
return;
|
|
85
87
|
}
|
|
86
88
|
setSearchBarConfigs(configs => {
|
|
87
89
|
const configsClone = [...configs];
|
|
@@ -90,7 +92,7 @@ function usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, i
|
|
|
90
92
|
isInteractive: !animatedLeft && !animatedRight,
|
|
91
93
|
animatedLeft,
|
|
92
94
|
animatedRight,
|
|
93
|
-
dataTestId: menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_SEARCH),
|
|
95
|
+
dataTestId: menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(withinSelect ? DATA_TESTID_SUFFIXES.SELECT_PANE : DATA_TESTID_SUFFIXES$1.MENU_PANE, withinSelect ? DATA_TESTID_SUFFIXES.SELECT_SEARCH : DATA_TESTID_SUFFIXES$1.MENU_SEARCH),
|
|
94
96
|
setSearchValue,
|
|
95
97
|
ref: searchRef,
|
|
96
98
|
id,
|
|
@@ -104,16 +106,19 @@ function usePaneSearch(isSearchable, externalSearchValue, onSearchValueChange, i
|
|
|
104
106
|
}
|
|
105
107
|
return configsClone;
|
|
106
108
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
},
|
|
109
|
+
}, [isSearchable, searchPlaceholder, setSearchBarConfigs, internalSearchValue, animatedLeft, animatedRight, menuParentDataTestId, setSearchValue, searchRef, id, withinSelect]);
|
|
110
|
+
useEffect(() => () => setSearchBarConfigs(configs => {
|
|
111
|
+
const configIndex = configs.findIndex(config => config.id === id);
|
|
112
|
+
if (configIndex === -1) {
|
|
113
|
+
return configs;
|
|
114
|
+
}
|
|
115
|
+
const configsClone = [...configs];
|
|
116
|
+
configsClone.splice(configIndex, 1);
|
|
117
|
+
return configsClone;
|
|
118
|
+
}),
|
|
119
|
+
// Omitted dependencies because we only want this to run on unmount
|
|
120
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
+
[]);
|
|
117
122
|
const noSearchResultsNode = zeroSearchResults && /*#__PURE__*/React__default.createElement("div", {
|
|
118
123
|
className: classNames(styles.menuItem, styles.noItems),
|
|
119
124
|
"aria-live": "assertive"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".
|
|
4
|
-
var styles = {"input":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._HPfzi input{padding-left:76px!important}._66Idh input{background-color:#e5e5e5!important;color:#9d9fa1!important;cursor:not-allowed!important;-webkit-text-fill-color:#9d9fa1}._66Idh input::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._66Idh input::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._dQNnM{position:absolute!important;left:4px;right:4px;bottom:4px;z-index:100;width:67px;height:28px!important;border-radius:4px}._dQNnM,._dQNnM._66Idh:hover{background-color:transparent!important}._dQNnM:hover{background-color:rgba(50,54,58,.08)!important}._dQNnM:active{background-color:rgba(50,54,58,.11)!important}._dQNnM svg{top:2px!important}._HVMkk{position:relative}._glnNQ{position:absolute;top:18px;left:12px;line-height:0;font-size:14px;color:#32363a;z-index:101;pointer-events:none}";
|
|
4
|
+
var styles = {"input":"_HPfzi","disabled":"_66Idh","dropdown":"_dQNnM","container":"_HVMkk","countryCode":"_glnNQ"};
|
|
5
|
+
var stylesheet="._HPfzi input{padding-left:76px!important}._66Idh input{background-color:#e5e5e5!important;color:#9d9fa1!important;cursor:not-allowed!important;-webkit-text-fill-color:#9d9fa1}._66Idh input::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._66Idh input::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._dQNnM{position:absolute!important;left:4px;right:4px;bottom:4px;z-index:100;width:67px;height:28px!important;border-radius:4px}._dQNnM,._dQNnM._66Idh:hover{background-color:transparent!important}._dQNnM:hover{background-color:rgba(50,54,58,.08)!important}._dQNnM:active{background-color:rgba(50,54,58,.11)!important}._dQNnM svg{top:2px!important}._HVMkk{position:relative}._glnNQ{position:absolute;top:18px;left:12px;line-height:0;font-size:14px;color:#32363a;z-index:101;pointer-events:none}";
|
|
6
6
|
if(typeof process !== 'object' || !process.hasOwnProperty('env') || process.env.NODE_ENV !== 'test'){styleInject(css_248z);}
|
|
7
7
|
|
|
8
8
|
export { styles as default, stylesheet };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React__default, { useMemo, useCallback } from 'react';
|
|
2
|
+
import '../Menu/index.js';
|
|
3
|
+
import { SelectContextProvider } from './SelectContext.js';
|
|
4
|
+
import '../../hooks/index.js';
|
|
5
|
+
import SelectItem from './SelectItem.js';
|
|
6
|
+
import SubSelect from './SubSelect.js';
|
|
7
|
+
import SelectPane from './SelectPane.js';
|
|
8
|
+
import useControllableState from '../../hooks/useControllableState/useControllableState.js';
|
|
9
|
+
import Menu from '../Menu/Menu.js';
|
|
10
|
+
|
|
11
|
+
const GetSelectItemsFrom = function (startingChildren) {
|
|
12
|
+
let filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
13
|
+
const current = [];
|
|
14
|
+
if (!startingChildren) {
|
|
15
|
+
return current;
|
|
16
|
+
}
|
|
17
|
+
const childrenArray = Array.isArray(startingChildren) ? startingChildren : [startingChildren];
|
|
18
|
+
childrenArray.forEach(child => {
|
|
19
|
+
if (filter && !filter(child.props)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (child.type === SelectItem) {
|
|
23
|
+
const {
|
|
24
|
+
label,
|
|
25
|
+
value: childValue
|
|
26
|
+
} = child.props;
|
|
27
|
+
current.push([childValue, label]);
|
|
28
|
+
} else if (child.type === SubSelect) {
|
|
29
|
+
current.push(...GetSelectItemsFrom(child.props.children, filter));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return current;
|
|
33
|
+
};
|
|
34
|
+
const Select = _ref => {
|
|
35
|
+
let {
|
|
36
|
+
multiselect,
|
|
37
|
+
children,
|
|
38
|
+
isDisabled,
|
|
39
|
+
onChange,
|
|
40
|
+
isOpen,
|
|
41
|
+
onIsOpenChange,
|
|
42
|
+
value,
|
|
43
|
+
isInvalid,
|
|
44
|
+
'data-testid': dataTestId
|
|
45
|
+
} = _ref;
|
|
46
|
+
const [selectedValues, setSelectedValues] = useControllableState(value, onChange, value);
|
|
47
|
+
const selectPaneChildren = useMemo(() => {
|
|
48
|
+
var _children$find;
|
|
49
|
+
return Array.isArray(children) ? (_children$find = children.find(child => child.type === SelectPane)) === null || _children$find === void 0 ? void 0 : _children$find.props.children : null;
|
|
50
|
+
}, [children]);
|
|
51
|
+
const selectedSelectItems = useMemo(() => {
|
|
52
|
+
if (Array.isArray(selectedValues)) {
|
|
53
|
+
return new Map(GetSelectItemsFrom(selectPaneChildren, _ref2 => {
|
|
54
|
+
let {
|
|
55
|
+
value: _value
|
|
56
|
+
} = _ref2;
|
|
57
|
+
return !_value || selectedValues.includes(_value);
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
return new Map(GetSelectItemsFrom(selectPaneChildren, _ref3 => {
|
|
61
|
+
let {
|
|
62
|
+
value: _value
|
|
63
|
+
} = _ref3;
|
|
64
|
+
return !_value || selectedValues === _value;
|
|
65
|
+
}));
|
|
66
|
+
}, [selectedValues, selectPaneChildren]);
|
|
67
|
+
const enabledSelectItems = useMemo(() => new Map(GetSelectItemsFrom(selectPaneChildren, _ref4 => {
|
|
68
|
+
let {
|
|
69
|
+
isDisabled: _isDisabled
|
|
70
|
+
} = _ref4;
|
|
71
|
+
return !_isDisabled;
|
|
72
|
+
})), [selectPaneChildren]);
|
|
73
|
+
const onItemSelect = useCallback((_value, isSelected) => {
|
|
74
|
+
setSelectedValues(currentSelectedValues => {
|
|
75
|
+
if (multiselect) {
|
|
76
|
+
if (Array.isArray(currentSelectedValues)) {
|
|
77
|
+
const clone = new Set(currentSelectedValues);
|
|
78
|
+
if (isSelected) {
|
|
79
|
+
clone.add(_value);
|
|
80
|
+
} else {
|
|
81
|
+
clone.delete(_value);
|
|
82
|
+
}
|
|
83
|
+
return Array.from(clone);
|
|
84
|
+
}
|
|
85
|
+
if (isSelected) {
|
|
86
|
+
return [_value];
|
|
87
|
+
}
|
|
88
|
+
} else if (isSelected) {
|
|
89
|
+
return _value;
|
|
90
|
+
}
|
|
91
|
+
return currentSelectedValues;
|
|
92
|
+
});
|
|
93
|
+
}, [setSelectedValues, multiselect]);
|
|
94
|
+
const sharedMenuProps = {
|
|
95
|
+
isDisabled,
|
|
96
|
+
isOpen,
|
|
97
|
+
onIsOpenChange,
|
|
98
|
+
'data-testid': dataTestId
|
|
99
|
+
};
|
|
100
|
+
return /*#__PURE__*/React__default.createElement(SelectContextProvider, {
|
|
101
|
+
value: {
|
|
102
|
+
multiselect,
|
|
103
|
+
onItemSelect,
|
|
104
|
+
selectedValues,
|
|
105
|
+
selectedSelectItems,
|
|
106
|
+
GetSelectItemsFrom,
|
|
107
|
+
isInvalid,
|
|
108
|
+
setSelectedValues,
|
|
109
|
+
enabledSelectItems
|
|
110
|
+
}
|
|
111
|
+
}, /*#__PURE__*/React__default.createElement(Menu, sharedMenuProps, children));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export { Select as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = "._xxuYT{box-shadow:inset 0 0 0 1px #b00!important}._pk2uK{width:unset!important;min-height:unset!important;padding:0!important;margin-right:7px}._m1vLs{background-color:rgba(11,110,208,.08);font-weight:500}";
|
|
4
|
+
var styles = {"isInvalid":"_xxuYT","checkbox":"_pk2uK","selectedItem":"_m1vLs"};
|
|
5
|
+
var stylesheet="._xxuYT{box-shadow:inset 0 0 0 1px #b00!important}._pk2uK{width:unset!important;min-height:unset!important;padding:0!important;margin-right:7px}._m1vLs{background-color:rgba(11,110,208,.08);font-weight:500}";
|
|
6
|
+
if(typeof process !== 'object' || !process.hasOwnProperty('env') || process.env.NODE_ENV !== 'test'){styleInject(css_248z);}
|
|
7
|
+
|
|
8
|
+
export { styles as default, stylesheet };
|