@qualtrics/ui-react 2.7.1 → 2.9.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 +38 -0
- package/dist/__shared/cjs/{index-68af2c28.js → index-38a79098.js} +198 -551
- package/dist/__shared/cjs/{index-7f94d375.js → index-3e5149c9.js} +3 -3
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Button/Button2.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/Combobox/ComboboxInput.js +3 -1
- 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/Controls.js +4 -4
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/{SelectMenu → NewMenu}/BaseMenu.js +2 -1
- package/dist/components/NewMenu/Menu/Menu.js +24 -0
- package/dist/components/NewMenu/Menu/index.js +1 -0
- package/dist/components/NewMenu/NewMenu.js +8 -0
- package/dist/components/{SelectMenu → NewMenu/SelectMenu}/SelectMenu.js +1 -1
- package/dist/components/NewMenu/SelectMenu/index.js +1 -0
- package/dist/components/{SelectMenu → NewMenu}/index.js +2 -1
- package/dist/components/{SelectMenu → NewMenu}/parts/MenuAnchor.js +1 -1
- package/dist/components/NewMenu/parts/MenuItem.js +65 -0
- package/dist/components/{SelectMenu → NewMenu}/parts/MenuSearchBox.js +1 -1
- package/dist/components/{SelectMenu → NewMenu}/parts/MenuSpinner.js +1 -1
- package/dist/components/{SelectMenu → NewMenu}/parts/SubmenuAnchor.js +1 -1
- 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/Popover.js +1 -1
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch.js +4 -4
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/QuickSearch/QuickSearchInput.js +1 -1
- 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/components/index.js +1 -2
- 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.es.js +4 -4
- package/dist/index.js +107 -204
- package/dist/next/AdvancedTable/AdvancedTable.js +5 -3
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTableColumnHeaderMenu.js +3 -3
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/Combobox/Combobox.js +4 -1
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Combobox/ComboboxInput.js +6 -2
- package/dist/next/Combobox/ComboboxOption.js +4 -1
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/PhoneNumberInput/PhoneNumberInput.js +3 -3
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/index.d.ts +1 -0
- package/dist/next/index.js +38 -28
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/package.json +1 -1
- package/dist/components/Menu/Menu.js +0 -112
- package/dist/components/Menu/MenuContext.js +0 -11
- package/dist/components/Menu/index.js +0 -1
- package/dist/components/SelectMenu/SelectMenu2.js +0 -8
- package/dist/components/SelectMenu/parts/MenuItem.js +0 -76
- package/dist/next/Menu/Menu.js +0 -28
- package/dist/next/Menu/Menu2.js +0 -8
- package/dist/next/Menu/MenuButton.js +0 -44
- package/dist/next/Menu/MenuContext.js +0 -41
- package/dist/next/Menu/MenuItem.js +0 -55
- package/dist/next/Menu/MenuPane.js +0 -72
- package/dist/next/Menu/MenuSearch.js +0 -105
- package/dist/next/Menu/SubMenu.js +0 -84
- package/dist/next/Menu/constants.js +0 -9
- package/dist/next/Menu/index.js +0 -5
- /package/dist/components/{SelectMenu → NewMenu}/parts/ArrowNav/ArrowNav.js +0 -0
- /package/dist/components/{SelectMenu → NewMenu}/parts/ArrowNav/index.js +0 -0
- /package/dist/components/{SelectMenu → NewMenu}/parts/MenuContext.js +0 -0
- /package/dist/components/{SelectMenu → NewMenu}/parts/index.js +0 -0
package/dist/next/Menu/Menu.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { Root } from '@radix-ui/react-dropdown-menu';
|
|
3
|
-
import { MenuContextProvider } from './MenuContext.js';
|
|
4
|
-
import '../../hooks/index.js';
|
|
5
|
-
import useControllableState from '../../hooks/useControllableState/useControllableState.js';
|
|
6
|
-
|
|
7
|
-
const Menu = _ref => {
|
|
8
|
-
let {
|
|
9
|
-
'data-testid': dataTestId,
|
|
10
|
-
isOpen,
|
|
11
|
-
onIsOpenChange,
|
|
12
|
-
isDisabled,
|
|
13
|
-
children
|
|
14
|
-
} = _ref;
|
|
15
|
-
const [open, setOpen] = useControllableState(isOpen, onIsOpenChange, isOpen);
|
|
16
|
-
return /*#__PURE__*/React__default.createElement(MenuContextProvider, {
|
|
17
|
-
value: {
|
|
18
|
-
dataTestId,
|
|
19
|
-
isDisabled,
|
|
20
|
-
setOpen
|
|
21
|
-
}
|
|
22
|
-
}, /*#__PURE__*/React__default.createElement(Root, {
|
|
23
|
-
open: open,
|
|
24
|
-
onOpenChange: shouldOpen => setOpen(!isDisabled && shouldOpen)
|
|
25
|
-
}, children));
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { Menu, Menu as default };
|
package/dist/next/Menu/Menu2.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
-
|
|
3
|
-
var css_248z = "._P64UM{position:relative;display:inline-flex;height:36px;background-color:#fafafa;min-width:0;cursor:pointer;border-radius:4px}._2U9R0{width:100%;height:100%;padding:0 28px 0 12px;border-radius:4px;white-space:nowrap;line-height:20px;font-size:14px;text-align:left;outline:none;background-color:transparent;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559}._2U9R0:hover:not([aria-disabled=true]){background-color:#f5f5f5}._2U9R0:focus{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._2U9R0+._EAwHK{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._2U9R0[data-state=open]+._EAwHK{transform:rotate(-180deg) translateY(50%)}._2U9R0[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._2U9R0[aria-disabled=true]+._EAwHK{fill:#515559;opacity:.4}._2mZkU{margin:0;padding:4px 0;font-size:14px;color:#32363a;fill:#32363a;list-style:none;min-width:160px;max-width:350px;min-height:10px;max-height:99%;background:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000;overflow:scroll}._3hgv9{position:relative;padding:10px 12px;min-height:40px;display:flex;flex-direction:row;align-items:center;cursor:pointer;outline:none;word-break:break-word}._3hgv9[data-highlighted]{background-color:#efefef}._3hgv9[aria-disabled=true]{cursor:not-allowed;opacity:.65}._3hgv9._3uFjB{padding-right:32px}._3hgv9._3uFjB ._EAwHK{position:absolute;top:8px;right:3px;fill:#515559}._3QJOO{padding:8px;border-bottom:1px solid #e8e8e8;border-radius:4px 4px 0 0;margin-top:-4px}._2sytQ{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;background-color:#fff;font-size:14px;color:#32363a;word-break:break-word}";
|
|
4
|
-
var styles = {"buttonContainer":"_P64UM","button":"_2U9R0","rightIcon":"_EAwHK","flyout":"_2mZkU","menuItem":"_3hgv9","subMenu":"_3uFjB","searchBox":"_3QJOO","emptyOption":"_2sytQ"};
|
|
5
|
-
var stylesheet="._P64UM{position:relative;display:inline-flex;height:36px;background-color:#fafafa;min-width:0;cursor:pointer;border-radius:4px}._2U9R0{width:100%;height:100%;padding:0 28px 0 12px;border-radius:4px;white-space:nowrap;line-height:20px;font-size:14px;text-align:left;outline:none;background-color:transparent;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559}._2U9R0:hover:not([aria-disabled=true]){background-color:#f5f5f5}._2U9R0:focus{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._2U9R0+._EAwHK{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._2U9R0[data-state=open]+._EAwHK{transform:rotate(-180deg) translateY(50%)}._2U9R0[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._2U9R0[aria-disabled=true]+._EAwHK{fill:#515559;opacity:.4}._2mZkU{margin:0;padding:4px 0;font-size:14px;color:#32363a;fill:#32363a;list-style:none;min-width:160px;max-width:350px;min-height:10px;max-height:99%;background:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000;overflow:scroll}._3hgv9{position:relative;padding:10px 12px;min-height:40px;display:flex;flex-direction:row;align-items:center;cursor:pointer;outline:none;word-break:break-word}._3hgv9[data-highlighted]{background-color:#efefef}._3hgv9[aria-disabled=true]{cursor:not-allowed;opacity:.65}._3hgv9._3uFjB{padding-right:32px}._3hgv9._3uFjB ._EAwHK{position:absolute;top:8px;right:3px;fill:#515559}._3QJOO{padding:8px;border-bottom:1px solid #e8e8e8;border-radius:4px 4px 0 0;margin-top:-4px}._2sytQ{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;background-color:#fff;font-size:14px;color:#32363a;word-break:break-word}";
|
|
6
|
-
styleInject(css_248z);
|
|
7
|
-
|
|
8
|
-
export { styles as default, stylesheet };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
2
|
-
import React__default from 'react';
|
|
3
|
-
import { Trigger } from '@radix-ui/react-dropdown-menu';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
import '../../icons/index.es.js';
|
|
6
|
-
import styles from './Menu2.js';
|
|
7
|
-
import '../../utils/index.js';
|
|
8
|
-
import { useMenuContext } from './MenuContext.js';
|
|
9
|
-
import { DATA_TESTID_SUFFIXES } from './constants.js';
|
|
10
|
-
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
11
|
-
import ChevronDownIcon from '../../icons/components/ChevronDownIcon.js';
|
|
12
|
-
|
|
13
|
-
const MenuButton = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
14
|
-
let {
|
|
15
|
-
asChild,
|
|
16
|
-
children,
|
|
17
|
-
style,
|
|
18
|
-
className,
|
|
19
|
-
...rest
|
|
20
|
-
} = _ref;
|
|
21
|
-
const {
|
|
22
|
-
dataTestId: rootDataTestId,
|
|
23
|
-
isDisabled
|
|
24
|
-
} = useMenuContext();
|
|
25
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
26
|
-
className: classNames(className, {
|
|
27
|
-
[styles.buttonContainer]: !asChild
|
|
28
|
-
}),
|
|
29
|
-
style: style
|
|
30
|
-
}, /*#__PURE__*/React__default.createElement(Trigger, _extends({}, rest, {
|
|
31
|
-
"aria-disabled": isDisabled,
|
|
32
|
-
className: classNames({
|
|
33
|
-
[styles.button]: !asChild
|
|
34
|
-
}),
|
|
35
|
-
asChild: asChild,
|
|
36
|
-
ref: ref,
|
|
37
|
-
"data-testid": getSubDataTestId(rootDataTestId, DATA_TESTID_SUFFIXES.MENU_BUTTON)
|
|
38
|
-
}), children), !asChild && /*#__PURE__*/React__default.createElement(ChevronDownIcon, {
|
|
39
|
-
className: styles.rightIcon,
|
|
40
|
-
"aria-hidden": "true"
|
|
41
|
-
}));
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
export { MenuButton, MenuButton as default };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import '../../utils/index.js';
|
|
3
|
-
import { ChildIndexProvider, useChildIndex } from '../../components/Dropdown/ChildIndexContext/index.js';
|
|
4
|
-
import createContextUtilities from '../../utils/createContextUtilities/createContextUtilities.js';
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
useContext: useMenuContext,
|
|
8
|
-
Provider: MenuContextProvider
|
|
9
|
-
} = createContextUtilities({});
|
|
10
|
-
const {
|
|
11
|
-
useContext: intermediaryUseMenuContext,
|
|
12
|
-
Provider: IntermediaryMenuContextProvider
|
|
13
|
-
} = createContextUtilities({});
|
|
14
|
-
|
|
15
|
-
const PaneContextProvider = _ref => {
|
|
16
|
-
let {
|
|
17
|
-
items,
|
|
18
|
-
setItems,
|
|
19
|
-
value,
|
|
20
|
-
children
|
|
21
|
-
} = _ref;
|
|
22
|
-
return /*#__PURE__*/React__default.createElement(ChildIndexProvider, {
|
|
23
|
-
items: items,
|
|
24
|
-
setItems: setItems
|
|
25
|
-
}, /*#__PURE__*/React__default.createElement(IntermediaryMenuContextProvider, {
|
|
26
|
-
value: value
|
|
27
|
-
}, children));
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const usePaneContext = childItemRef => {
|
|
31
|
-
const coreContext = intermediaryUseMenuContext();
|
|
32
|
-
const childIndex = useChildIndex({
|
|
33
|
-
element: childItemRef
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
childIndex,
|
|
37
|
-
...coreContext
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export { MenuContextProvider, PaneContextProvider, useMenuContext, usePaneContext };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
2
|
-
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
3
|
-
import React__default, { useRef, useMemo } from 'react';
|
|
4
|
-
import { Item } from '@radix-ui/react-dropdown-menu';
|
|
5
|
-
import classNames from 'classnames';
|
|
6
|
-
import styles from './Menu2.js';
|
|
7
|
-
import { usePaneContext } from './MenuContext.js';
|
|
8
|
-
import '../../utils/index.js';
|
|
9
|
-
import { DATA_TESTID_SUFFIXES } from './constants.js';
|
|
10
|
-
import { useMenuContext } from '../../components/Menu/MenuContext.js';
|
|
11
|
-
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
12
|
-
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
13
|
-
|
|
14
|
-
const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
15
|
-
let {
|
|
16
|
-
isDisabled,
|
|
17
|
-
asChild,
|
|
18
|
-
children,
|
|
19
|
-
className,
|
|
20
|
-
onSelect,
|
|
21
|
-
label,
|
|
22
|
-
...rest
|
|
23
|
-
} = _ref;
|
|
24
|
-
const itemRef = useRef(null);
|
|
25
|
-
const {
|
|
26
|
-
dataTestId: menuParentDataTestId,
|
|
27
|
-
childIndex: index,
|
|
28
|
-
searchValue,
|
|
29
|
-
isSearchFilteringDisabled
|
|
30
|
-
} = usePaneContext(itemRef);
|
|
31
|
-
const dataTestId = getSubDataTestId(menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM), String(index));
|
|
32
|
-
const isVisible = useMemo(() => {
|
|
33
|
-
var _context;
|
|
34
|
-
|
|
35
|
-
const searchMatcher = label !== null && label !== void 0 ? label : typeof children === 'string' ? children : undefined;
|
|
36
|
-
return isSearchFilteringDisabled || !searchValue || (searchMatcher === null || searchMatcher === void 0 ? void 0 : _includesInstanceProperty(_context = searchMatcher.toLowerCase()).call(_context, searchValue.toLowerCase()));
|
|
37
|
-
}, [children, searchValue, label, isSearchFilteringDisabled]);
|
|
38
|
-
const {
|
|
39
|
-
isChildOfMenu: isChildOfOldMenu
|
|
40
|
-
} = useMenuContext();
|
|
41
|
-
return isVisible ? /*#__PURE__*/React__default.createElement(Item, _extends({}, rest, {
|
|
42
|
-
asChild: asChild,
|
|
43
|
-
"aria-disabled": isDisabled,
|
|
44
|
-
className: classNames(className, styles.menuItem),
|
|
45
|
-
"data-testid": dataTestId,
|
|
46
|
-
ref: mergeRefs(ref, itemRef) // stop radix from closing the menu on selection of disabled item
|
|
47
|
-
// other pointer and keyboard events still work, even when disabled
|
|
48
|
-
,
|
|
49
|
-
onSelect: e => isDisabled ? e.preventDefault() : // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
|
-
// @ts-ignore: passing event to old menu to comply with its API
|
|
51
|
-
onSelect === null || onSelect === void 0 ? void 0 : onSelect(isChildOfOldMenu ? e : undefined)
|
|
52
|
-
}), (!children || typeof children === 'string') && label ? label : children) : null;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export { MenuItem, MenuItem as default };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
2
|
-
import React__default, { useMemo, useState, useRef, useCallback } from 'react';
|
|
3
|
-
import { Portal, Content } from '@radix-ui/react-dropdown-menu';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
import styles from './Menu2.js';
|
|
6
|
-
import { usePortalTarget } from '../../components/UIProvider/PortalTargetContext.js';
|
|
7
|
-
import { useMenuContext, PaneContextProvider } from './MenuContext.js';
|
|
8
|
-
import '../../utils/index.js';
|
|
9
|
-
import { DATA_TESTID_SUFFIXES } from './constants.js';
|
|
10
|
-
import { MenuSearch } from './MenuSearch.js';
|
|
11
|
-
import '../../hooks/index.js';
|
|
12
|
-
import useControllableState from '../../hooks/useControllableState/useControllableState.js';
|
|
13
|
-
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
14
|
-
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
15
|
-
|
|
16
|
-
const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
17
|
-
let {
|
|
18
|
-
placement,
|
|
19
|
-
children,
|
|
20
|
-
isSearchable,
|
|
21
|
-
searchValue: externalSearchValue,
|
|
22
|
-
onSearchValueChange,
|
|
23
|
-
className,
|
|
24
|
-
isSearchFilteringDisabled = false,
|
|
25
|
-
...rest
|
|
26
|
-
} = _ref;
|
|
27
|
-
const [internalSearchValue, setSearchValue] = useControllableState(externalSearchValue, onSearchValueChange, externalSearchValue);
|
|
28
|
-
const portalTarget = usePortalTarget();
|
|
29
|
-
const [side, align] = useMemo(() => {
|
|
30
|
-
var _placement$split, _placement$split2;
|
|
31
|
-
|
|
32
|
-
return (_placement$split = placement === null || placement === void 0 ? void 0 : (_placement$split2 = placement.split) === null || _placement$split2 === void 0 ? void 0 : _placement$split2.call(placement, '-')) !== null && _placement$split !== void 0 ? _placement$split : [];
|
|
33
|
-
}, [placement]);
|
|
34
|
-
const [items, setItems] = useState([]);
|
|
35
|
-
const {
|
|
36
|
-
dataTestId: rootDataTestId,
|
|
37
|
-
setOpen: setOpenEntireMenu
|
|
38
|
-
} = useMenuContext();
|
|
39
|
-
const dataTestId = getSubDataTestId(rootDataTestId, DATA_TESTID_SUFFIXES.MENU_PANE);
|
|
40
|
-
const paneRef = useRef(null);
|
|
41
|
-
const handleTabPress = useCallback(() => {
|
|
42
|
-
setOpenEntireMenu === null || setOpenEntireMenu === void 0 ? void 0 : setOpenEntireMenu(false);
|
|
43
|
-
}, [setOpenEntireMenu]);
|
|
44
|
-
return /*#__PURE__*/React__default.createElement(PaneContextProvider, {
|
|
45
|
-
items: items,
|
|
46
|
-
setItems: setItems,
|
|
47
|
-
value: {
|
|
48
|
-
dataTestId,
|
|
49
|
-
searchValue: internalSearchValue,
|
|
50
|
-
paneRef,
|
|
51
|
-
isSearchFilteringDisabled
|
|
52
|
-
}
|
|
53
|
-
}, /*#__PURE__*/React__default.createElement(Portal, {
|
|
54
|
-
container: portalTarget || undefined
|
|
55
|
-
}, /*#__PURE__*/React__default.createElement(Content, _extends({}, rest, {
|
|
56
|
-
sideOffset: 6,
|
|
57
|
-
loop: true,
|
|
58
|
-
side: side || 'bottom',
|
|
59
|
-
align: align || 'start',
|
|
60
|
-
className: classNames(styles.flyout, className),
|
|
61
|
-
ref: mergeRefs(ref, paneRef),
|
|
62
|
-
"data-testid": dataTestId // having to add our own due to https://github.com/radix-ui/primitives/issues/1934
|
|
63
|
-
,
|
|
64
|
-
onKeyDownCapture: e => e.key === 'Tab' && handleTabPress()
|
|
65
|
-
}), isSearchable && /*#__PURE__*/React__default.createElement(MenuSearch, {
|
|
66
|
-
setSearchValue: setSearchValue,
|
|
67
|
-
items: items,
|
|
68
|
-
paneRef: paneRef
|
|
69
|
-
}), children)));
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
export { MenuPane, MenuPane as default };
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
2
|
-
import React__default, { useRef, useState, useEffect } from 'react';
|
|
3
|
-
import { Item } from '@radix-ui/react-dropdown-menu';
|
|
4
|
-
import styles from './Menu2.js';
|
|
5
|
-
import '../Input/index.js';
|
|
6
|
-
import '../../icons/index.es.js';
|
|
7
|
-
import '../../utils/index.js';
|
|
8
|
-
import { usePaneContext } from './MenuContext.js';
|
|
9
|
-
import { DATA_TESTID_SUFFIXES } from './constants.js';
|
|
10
|
-
import '../../hooks/index.js';
|
|
11
|
-
import useTranslation from '../../utils/Translation/useTranslation.js';
|
|
12
|
-
import useEventListener from '../../hooks/useEventListener/useEventListener.js';
|
|
13
|
-
import Input from '../Input/Input.js';
|
|
14
|
-
import SearchIcon from '../../icons/components/SearchIcon.js';
|
|
15
|
-
|
|
16
|
-
const MenuSearch = _ref => {
|
|
17
|
-
let {
|
|
18
|
-
setSearchValue,
|
|
19
|
-
items,
|
|
20
|
-
paneRef
|
|
21
|
-
} = _ref;
|
|
22
|
-
const itemRef = useRef(null);
|
|
23
|
-
const inputRef = useRef(null);
|
|
24
|
-
const {
|
|
25
|
-
translate
|
|
26
|
-
} = useTranslation();
|
|
27
|
-
const noMatchesText = translate('menu.noItemsToDisplay');
|
|
28
|
-
const searchText = translate('searchText');
|
|
29
|
-
const {
|
|
30
|
-
dataTestId: menuParentDataTestId,
|
|
31
|
-
searchValue = ''
|
|
32
|
-
} = usePaneContext();
|
|
33
|
-
const dataTestId = menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_SEARCH); // not using `useMemo` to force an extra render after items have updated https://stackoverflow.com/a/56029184
|
|
34
|
-
|
|
35
|
-
const [zeroSearchResults, setZeroSearchResults] = useState();
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
setZeroSearchResults((items === null || items === void 0 ? void 0 : items.filter(item => item.element.current).length) === 0);
|
|
38
|
-
}, [items, searchValue]);
|
|
39
|
-
useEffect(() => () => setSearchValue(''), [setSearchValue]);
|
|
40
|
-
const [previouslyFocusedElement, setPreviouslyFocusedElement] = useState(); // a backdoor hack to keep focus on search input on mouse leave
|
|
41
|
-
|
|
42
|
-
useEventListener(paneRef, 'focus', e => {
|
|
43
|
-
if (e.target === e.currentTarget && previouslyFocusedElement === itemRef.current) {
|
|
44
|
-
var _inputRef$current;
|
|
45
|
-
|
|
46
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
setPreviouslyFocusedElement(e.target);
|
|
50
|
-
}, {
|
|
51
|
-
isCaptureEvent: true
|
|
52
|
-
});
|
|
53
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Item, {
|
|
54
|
-
className: styles.searchBox // prevents dropdown from closing
|
|
55
|
-
,
|
|
56
|
-
onSelect: e => e.preventDefault(),
|
|
57
|
-
onFocus: () => {
|
|
58
|
-
var _inputRef$current2;
|
|
59
|
-
|
|
60
|
-
return (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
|
|
61
|
-
},
|
|
62
|
-
role: undefined,
|
|
63
|
-
ref: itemRef
|
|
64
|
-
}, /*#__PURE__*/React__default.createElement(Input, {
|
|
65
|
-
"data-testid": dataTestId,
|
|
66
|
-
role: "searchbox",
|
|
67
|
-
value: searchValue,
|
|
68
|
-
onChange: e => setSearchValue(e.target.value),
|
|
69
|
-
placeholder: searchText,
|
|
70
|
-
onKeyDown: e => {
|
|
71
|
-
var _e$target;
|
|
72
|
-
|
|
73
|
-
// stop propagation to prevent typeAhead
|
|
74
|
-
e.stopPropagation();
|
|
75
|
-
const keysToForward = ['Escape', 'ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End']; // allow caret movement through text entry, but close searchable submenu if on the very left
|
|
76
|
-
|
|
77
|
-
if (((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.selectionStart) === 0) {
|
|
78
|
-
keysToForward.push('ArrowLeft');
|
|
79
|
-
} // forward keypress directly to `Item` to let Radix handle keyboard navigation
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (_includesInstanceProperty(keysToForward).call(keysToForward, e.key)) {
|
|
83
|
-
var _itemRef$current;
|
|
84
|
-
|
|
85
|
-
// `view` types are incompatible
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
|
-
const {
|
|
88
|
-
view,
|
|
89
|
-
...eventClone
|
|
90
|
-
} = e;
|
|
91
|
-
itemRef === null || itemRef === void 0 ? void 0 : (_itemRef$current = itemRef.current) === null || _itemRef$current === void 0 ? void 0 : _itemRef$current.dispatchEvent(new KeyboardEvent('keydown', eventClone));
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
leftAddOn: /*#__PURE__*/React__default.createElement(SearchIcon, null),
|
|
95
|
-
ref: inputRef
|
|
96
|
-
})), zeroSearchResults && /*#__PURE__*/React__default.createElement("div", {
|
|
97
|
-
className: styles.emptyOption // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
|
|
98
|
-
,
|
|
99
|
-
role: "option" // `aria-selected` is omitted because this option is not selectable
|
|
100
|
-
,
|
|
101
|
-
"aria-live": "assertive"
|
|
102
|
-
}, noMatchesText));
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export { MenuSearch, MenuSearch as default };
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
2
|
-
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
3
|
-
import React__default, { useRef, useState, useMemo } from 'react';
|
|
4
|
-
import { Sub, SubTrigger, SubContent } from '@radix-ui/react-dropdown-menu';
|
|
5
|
-
import classNames from 'classnames';
|
|
6
|
-
import styles from './Menu2.js';
|
|
7
|
-
import '../../icons/index.es.js';
|
|
8
|
-
import { usePaneContext, PaneContextProvider } from './MenuContext.js';
|
|
9
|
-
import '../../utils/index.js';
|
|
10
|
-
import { DATA_TESTID_SUFFIXES } from './constants.js';
|
|
11
|
-
import { MenuSearch } from './MenuSearch.js';
|
|
12
|
-
import '../../hooks/index.js';
|
|
13
|
-
import { useMenuContext } from '../../components/Menu/MenuContext.js';
|
|
14
|
-
import useControllableState from '../../hooks/useControllableState/useControllableState.js';
|
|
15
|
-
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
16
|
-
import ChevronRightIcon from '../../icons/components/ChevronRightIcon.js';
|
|
17
|
-
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
18
|
-
|
|
19
|
-
const SubMenu = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
20
|
-
let {
|
|
21
|
-
children,
|
|
22
|
-
label,
|
|
23
|
-
isDisabled,
|
|
24
|
-
isSearchable,
|
|
25
|
-
searchValue: externalSearchValue,
|
|
26
|
-
onSearchValueChange,
|
|
27
|
-
className,
|
|
28
|
-
isSearchFilteringDisabled: isSearchFilteringDisabledForChildren = false,
|
|
29
|
-
...rest
|
|
30
|
-
} = _ref;
|
|
31
|
-
const {
|
|
32
|
-
onIsOpenChange,
|
|
33
|
-
subMenuTriggerProps
|
|
34
|
-
} = useMenuContext();
|
|
35
|
-
const itemRef = useRef(null);
|
|
36
|
-
const paneRef = useRef(null);
|
|
37
|
-
const {
|
|
38
|
-
dataTestId: menuParentDataTestId,
|
|
39
|
-
childIndex: index,
|
|
40
|
-
searchValue: triggerMenuParentSearchValue,
|
|
41
|
-
isSearchFilteringDisabled: isSearchFilteringDisabledForTrigger
|
|
42
|
-
} = usePaneContext(itemRef);
|
|
43
|
-
const [internalSearchValue, setSearchValue] = useControllableState(externalSearchValue, onSearchValueChange, externalSearchValue);
|
|
44
|
-
const paneDataTestId = getSubDataTestId(menuParentDataTestId, String(index));
|
|
45
|
-
const triggerDataTestId = paneDataTestId === null || paneDataTestId === void 0 ? void 0 : paneDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM);
|
|
46
|
-
const [items, setItems] = useState([]);
|
|
47
|
-
const isVisible = useMemo(() => {
|
|
48
|
-
var _context;
|
|
49
|
-
|
|
50
|
-
return isSearchFilteringDisabledForTrigger || !triggerMenuParentSearchValue || typeof label === 'string' && _includesInstanceProperty(_context = label.toLowerCase()).call(_context, triggerMenuParentSearchValue.toLowerCase());
|
|
51
|
-
}, [triggerMenuParentSearchValue, label, isSearchFilteringDisabledForTrigger]);
|
|
52
|
-
return isVisible ? /*#__PURE__*/React__default.createElement(Sub, {
|
|
53
|
-
onOpenChange: onIsOpenChange
|
|
54
|
-
}, /*#__PURE__*/React__default.createElement(SubTrigger, _extends({
|
|
55
|
-
"data-testid": triggerDataTestId,
|
|
56
|
-
"aria-disabled": isDisabled,
|
|
57
|
-
disabled: isDisabled,
|
|
58
|
-
ref: itemRef
|
|
59
|
-
}, subMenuTriggerProps, {
|
|
60
|
-
className: classNames(styles.menuItem, styles.subMenu, subMenuTriggerProps === null || subMenuTriggerProps === void 0 ? void 0 : subMenuTriggerProps.className),
|
|
61
|
-
style: subMenuTriggerProps === null || subMenuTriggerProps === void 0 ? void 0 : subMenuTriggerProps.style
|
|
62
|
-
}), label, /*#__PURE__*/React__default.createElement(ChevronRightIcon, {
|
|
63
|
-
className: styles.rightIcon
|
|
64
|
-
})), /*#__PURE__*/React__default.createElement(PaneContextProvider, {
|
|
65
|
-
items: items,
|
|
66
|
-
setItems: setItems,
|
|
67
|
-
value: {
|
|
68
|
-
dataTestId: paneDataTestId,
|
|
69
|
-
searchValue: internalSearchValue,
|
|
70
|
-
isSearchFilteringDisabled: isSearchFilteringDisabledForChildren
|
|
71
|
-
}
|
|
72
|
-
}, /*#__PURE__*/React__default.createElement(SubContent, _extends({}, rest, {
|
|
73
|
-
className: classNames(styles.flyout, className),
|
|
74
|
-
loop: true,
|
|
75
|
-
"data-testid": paneDataTestId,
|
|
76
|
-
ref: mergeRefs(ref, paneRef)
|
|
77
|
-
}), isSearchable && /*#__PURE__*/React__default.createElement(MenuSearch, {
|
|
78
|
-
setSearchValue: setSearchValue,
|
|
79
|
-
items: items,
|
|
80
|
-
paneRef: paneRef
|
|
81
|
-
}), children))) : null;
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
export { SubMenu, SubMenu as default };
|
package/dist/next/Menu/index.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|