@qualtrics/ui-react 2.17.0 → 2.19.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 +32 -0
- package/dist/__shared/cjs/{index-01a9a3bd.js → index-4e4cc354.js} +193 -150
- package/dist/__shared/cjs/{index-a16a4f66.js → index-bf07471d.js} +11 -3
- 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/Icon/IconTypes.js +2 -0
- 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/ConditionSet.js +4 -5
- package/dist/components/LogicEditor/Controls.js +19 -4
- package/dist/components/LogicEditor/LogicEditor.js +9 -3
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/LogicEditor/utils.js +20 -1
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +9 -7
- 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/useOverlay2.js +3 -3
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/components/RecordIcon.js +6 -0
- package/dist/icons/components/StopRecordingIcon.js +6 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.es.js +2 -0
- package/dist/icons/index.js +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +1 -1
- package/dist/index.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -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 +29 -3
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuButton.js +7 -4
- package/dist/next/Menu/MenuContext.js +2 -2
- package/dist/next/Menu/MenuItem.js +36 -5
- package/dist/next/Menu/MenuPane.js +111 -21
- package/dist/next/Menu/MenuSearch.js +29 -35
- package/dist/next/Menu/SubMenu.js +165 -31
- package/dist/next/Menu/constants.js +8 -2
- package/dist/next/Menu/index.js +5 -5
- package/dist/next/Menu/usePaneSearch.js +25 -0
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/Stack/HStack.js +11 -0
- package/dist/next/Stack/Stack.js +98 -0
- package/dist/next/Stack/StackItem.js +37 -0
- package/dist/next/Stack/VStack.js +11 -0
- package/dist/next/Stack/index.js +3 -0
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.d.ts +82 -4
- package/dist/next/index.es.js +9 -5
- package/dist/next/index.js +547 -117
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/icons/package.json +2 -2
- package/next/package.json +2 -2
- package/package.json +3 -3
|
@@ -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 = {"loadingSpinner":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._3nVyL :after{background-color:#515559!important}._3lo8J>input:focus{box-shadow:none!important;border:1px solid #898989!important}._3ratD{max-width:500px;padding:4px 0;background-color:#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-x:hidden;overflow-y:auto;overflow:hidden auto}._3ratD ._2Xilc ._3cTQ5{display:flex;align-items:center;min-height:40px;padding:10px 12px;color:#32363a;font-size:12px;line-height:16px;font-weight:700;word-break:break-word}._3ratD ._2Xilc:first-child ._2N8Ah{display:none}._3ratD ._bAx3x{display:flex;align-items:center;min-height:40px;padding:10px 12px;font-size:14px;color:#32363a;word-break:break-word;outline:none;cursor:pointer}._3ratD ._bAx3x:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._3ratD ._bAx3x:hover._2r6-j{background-color:#e4effa}._3ratD ._bAx3x._2r6-j{background-color:#ebf3fb;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._3ratD ._bAx3x:active:not(._2r6-j){background-color:#e8e9e9}";
|
|
4
|
+
var styles = {"loadingSpinner":"_3nVyL","ignoreFocusStyle":"_3lo8J","flyout":"_3ratD","group":"_2Xilc","header":"_3cTQ5","divider":"_2N8Ah","option":"_bAx3x","selected":"_2r6-j"};
|
|
5
|
+
var stylesheet="._3nVyL :after{background-color:#515559!important}._3lo8J>input:focus{box-shadow:none!important;border:1px solid #898989!important}._3ratD{max-width:500px;padding:4px 0;background-color:#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-x:hidden;overflow-y:auto;overflow:hidden auto}._3ratD ._2Xilc ._3cTQ5{display:flex;align-items:center;min-height:40px;padding:10px 12px;color:#32363a;font-size:12px;line-height:16px;font-weight:700;word-break:break-word}._3ratD ._2Xilc:first-child ._2N8Ah{display:none}._3ratD ._bAx3x{display:flex;align-items:center;min-height:40px;padding:10px 12px;font-size:14px;color:#32363a;word-break:break-word;outline:none;cursor:pointer}._3ratD ._bAx3x:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._3ratD ._bAx3x:hover._2r6-j{background-color:#e4effa}._3ratD ._bAx3x._2r6-j{background-color:#ebf3fb;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._3ratD ._bAx3x:active:not(._2r6-j){background-color:#e8e9e9}";
|
|
6
6
|
styleInject(css_248z);
|
|
7
7
|
|
|
8
8
|
export { styles as default, stylesheet };
|
|
@@ -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 = {"drawer":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._R7Qk_{position:absolute;top:0;height:100%;color:#32363a;background-color:#fff;border-right:1px solid #eee;z-index:1000;padding:12px 20px 20px;transition:left .5s}._3gieE{visibility:hidden}._2hC5u{display:flex;justify-content:space-between;align-items:start;line-height:20px;font-size:16px;padding-bottom:12px}._37AZj{padding-top:8px}._343YV{margin-left:12px}";
|
|
4
|
+
var styles = {"drawer":"_R7Qk_","hidden":"_3gieE","header":"_2hC5u","title":"_37AZj","closeButton":"_343YV"};
|
|
5
|
+
var stylesheet="._R7Qk_{position:absolute;top:0;height:100%;color:#32363a;background-color:#fff;border-right:1px solid #eee;z-index:1000;padding:12px 20px 20px;transition:left .5s}._3gieE{visibility:hidden}._2hC5u{display:flex;justify-content:space-between;align-items:start;line-height:20px;font-size:16px;padding-bottom:12px}._37AZj{padding-top:8px}._343YV{margin-left:12px}";
|
|
6
6
|
styleInject(css_248z);
|
|
7
7
|
|
|
8
8
|
export { styles as default, stylesheet };
|
|
@@ -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 = {"button":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._3p7AT{display:flex;justify-content:space-between;align-items:center;max-width:100%;min-width:76px;height:36px;padding:0 6px 0 12px;outline:none;font-size:14px;background-color:#fff;border:1px solid #898989;border-radius:20px;cursor:pointer}._3p7AT:hover:not(._3iVBA){background-color:rgba(50,54,58,.08)}._3p7AT:hover:not(._3iVBA)._RlzPR{border-color:#085caf;background-color:rgba(11,110,208,.04)}._3p7AT:hover:not(._3iVBA)._RlzPR ._1XWGr{color:#32363a}._3p7AT:hover:not(._3iVBA)._RlzPR ._3XMIf{fill:#32363a}._3p7AT:hover:not(._3iVBA)._RlzPR ._mlRvN{fill:#085caf}._3p7AT:hover:not(._3iVBA)._RlzPR ._1eW_T{background-color:rgba(11,110,208,.11)}._3p7AT:hover:not(._3iVBA)._RlzPR ._1eW_T ._2CAT5{color:#085caf}._3p7AT:active:not(._3iVBA){background-color:#e8e9e9}._3p7AT:active:not(._3iVBA)._RlzPR{background-color:rgba(11,110,208,.11);border-color:#0854a1}._3p7AT:active:not(._3iVBA)._RlzPR ._mlRvN{fill:#0854a1}._3p7AT:active:not(._3iVBA)._RlzPR ._1eW_T{background-color:rgba(11,110,208,.11)}._3p7AT:active:not(._3iVBA)._RlzPR ._1eW_T ._2CAT5{color:#0854a1}._3p7AT._3iVBA{background-color:#fafafa;border-color:#e5e5e5;cursor:not-allowed}._3p7AT._RlzPR{border-color:#0b6ed0}._3XMIf{fill:#515559;margin-right:4px}._1XWGr{max-width:180px;margin-right:3px;color:#515559;fill:#515559;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._1XWGr+._1eW_T{margin-left:6px}._1XWGr._3iVBA{color:#74777a}._1eW_T{display:flex;justify-content:center;align-items:center;max-width:350px;flex:1;min-width:0;height:24px;margin-right:3px;padding:0 10px;background-color:#ebf3fb;border-radius:20px}._2CAT5{color:#0b6ed0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._mlRvN{fill:#515559}._mlRvN._3iVBA,._mlRvN._3iVBA._RlzPR{fill:rgba(116,119,122,.4)}._mlRvN._RlzPR{fill:#0b6ed0}._mlRvN._1PE4B{transform:rotate(-180deg)}body.keyboard-user ._3p7AT:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
4
|
+
var styles = {"button":"_3p7AT","disabled":"_3iVBA","selected":"_RlzPR","label":"_1XWGr","lockIcon":"_3XMIf","chevronIcon":"_mlRvN","selectedFiltersContainer":"_1eW_T","selectedFilters":"_2CAT5","open":"_1PE4B"};
|
|
5
|
+
var stylesheet="._3p7AT{display:flex;justify-content:space-between;align-items:center;max-width:100%;min-width:76px;height:36px;padding:0 6px 0 12px;outline:none;font-size:14px;background-color:#fff;border:1px solid #898989;border-radius:20px;cursor:pointer}._3p7AT:hover:not(._3iVBA){background-color:rgba(50,54,58,.08)}._3p7AT:hover:not(._3iVBA)._RlzPR{border-color:#085caf;background-color:rgba(11,110,208,.04)}._3p7AT:hover:not(._3iVBA)._RlzPR ._1XWGr{color:#32363a}._3p7AT:hover:not(._3iVBA)._RlzPR ._3XMIf{fill:#32363a}._3p7AT:hover:not(._3iVBA)._RlzPR ._mlRvN{fill:#085caf}._3p7AT:hover:not(._3iVBA)._RlzPR ._1eW_T{background-color:rgba(11,110,208,.11)}._3p7AT:hover:not(._3iVBA)._RlzPR ._1eW_T ._2CAT5{color:#085caf}._3p7AT:active:not(._3iVBA){background-color:#e8e9e9}._3p7AT:active:not(._3iVBA)._RlzPR{background-color:rgba(11,110,208,.11);border-color:#0854a1}._3p7AT:active:not(._3iVBA)._RlzPR ._mlRvN{fill:#0854a1}._3p7AT:active:not(._3iVBA)._RlzPR ._1eW_T{background-color:rgba(11,110,208,.11)}._3p7AT:active:not(._3iVBA)._RlzPR ._1eW_T ._2CAT5{color:#0854a1}._3p7AT._3iVBA{background-color:#fafafa;border-color:#e5e5e5;cursor:not-allowed}._3p7AT._RlzPR{border-color:#0b6ed0}._3XMIf{fill:#515559;margin-right:4px}._1XWGr{max-width:180px;margin-right:3px;color:#515559;fill:#515559;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._1XWGr+._1eW_T{margin-left:6px}._1XWGr._3iVBA{color:#74777a}._1eW_T{display:flex;justify-content:center;align-items:center;max-width:350px;flex:1;min-width:0;height:24px;margin-right:3px;padding:0 10px;background-color:#ebf3fb;border-radius:20px}._2CAT5{color:#0b6ed0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._mlRvN{fill:#515559}._mlRvN._3iVBA,._mlRvN._3iVBA._RlzPR{fill:rgba(116,119,122,.4)}._mlRvN._RlzPR{fill:#0b6ed0}._mlRvN._1PE4B{transform:rotate(-180deg)}body.keyboard-user ._3p7AT:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
6
6
|
styleInject(css_248z);
|
|
7
7
|
|
|
8
8
|
export { styles as default, stylesheet };
|
|
@@ -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 inputClasses = {"container":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._3vFiE{position:relative;display:inline-block;height:36px}._1gSSe{width:100%;height:100%;padding:8px 12px;color:#32363a;caret-color:#32363a;font-size:14px;background-color:#fafafa;border:1px solid #898989;border-radius:4px;outline:none}._1gSSe:hover{cursor:pointer;background-color:#f5f5f5}._1gSSe:focus{background-color:#fafafa;cursor:text;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;outline:none;border-color:transparent}._1gSSe:disabled,._1gSSe[aria-disabled=true]{background-color:#fafafa;border-color:#e5e5e5;color:#9d9fa1;-webkit-text-fill-color:#9d9fa1;cursor:not-allowed}._1gSSe:disabled::-moz-placeholder,._1gSSe[aria-disabled=true]::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._1gSSe:disabled::placeholder,._1gSSe[aria-disabled=true]::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._1gSSe:invalid,._1gSSe[aria-invalid=true]{border-color:#b00}._1gSSe:invalid:focus,._1gSSe[aria-invalid=true]:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000;border-color:transparent}._1gSSe[type=number]{-moz-appearance:textfield}._1gSSe[type=number]::-webkit-inner-spin-button,._1gSSe[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}._1gSSe::-moz-placeholder{color:#515559;opacity:1}._1gSSe::placeholder{color:#515559;opacity:1}._5Sfq-{pointer-events:none;color:#515559;fill:#515559}._3fFpz{display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._2YXiE{color:#515559;font-size:16px}._3rmDK{left:0;margin-left:6px}._3ah3W,._3rmDK{pointer-events:none;color:#515559;fill:#515559;display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._3ah3W{right:0;margin-right:6px}";
|
|
4
|
+
var inputClasses = {"container":"_3vFiE","input":"_1gSSe","addOn":"_5Sfq-","addOnVerticalCenter":"_3fFpz","addOnTextNode":"_2YXiE","leftAddOn":"_3rmDK","rightAddOn":"_3ah3W"};
|
|
5
|
+
var stylesheet="._3vFiE{position:relative;display:inline-block;height:36px}._1gSSe{width:100%;height:100%;padding:8px 12px;color:#32363a;caret-color:#32363a;font-size:14px;background-color:#fafafa;border:1px solid #898989;border-radius:4px;outline:none}._1gSSe:hover{cursor:pointer;background-color:#f5f5f5}._1gSSe:focus{background-color:#fafafa;cursor:text;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;outline:none;border-color:transparent}._1gSSe:disabled,._1gSSe[aria-disabled=true]{background-color:#fafafa;border-color:#e5e5e5;color:#9d9fa1;-webkit-text-fill-color:#9d9fa1;cursor:not-allowed}._1gSSe:disabled::-moz-placeholder,._1gSSe[aria-disabled=true]::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._1gSSe:disabled::placeholder,._1gSSe[aria-disabled=true]::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._1gSSe:invalid,._1gSSe[aria-invalid=true]{border-color:#b00}._1gSSe:invalid:focus,._1gSSe[aria-invalid=true]:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000;border-color:transparent}._1gSSe[type=number]{-moz-appearance:textfield}._1gSSe[type=number]::-webkit-inner-spin-button,._1gSSe[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}._1gSSe::-moz-placeholder{color:#515559;opacity:1}._1gSSe::placeholder{color:#515559;opacity:1}._5Sfq-{pointer-events:none;color:#515559;fill:#515559}._3fFpz{display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._2YXiE{color:#515559;font-size:16px}._3rmDK{left:0;margin-left:6px}._3ah3W,._3rmDK{pointer-events:none;color:#515559;fill:#515559;display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._3ah3W{right:0;margin-right:6px}";
|
|
6
6
|
styleInject(css_248z);
|
|
7
7
|
|
|
8
8
|
export { inputClasses as default, stylesheet };
|
package/dist/next/Menu/Menu.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
1
|
+
import React__default, { useState, useRef, useMemo } from 'react';
|
|
2
2
|
import { Root } from '@radix-ui/react-dropdown-menu';
|
|
3
3
|
import { MenuContextProvider } from './MenuContext.js';
|
|
4
4
|
import '../../hooks/index.js';
|
|
5
5
|
import useControllableState from '../../hooks/useControllableState/useControllableState.js';
|
|
6
6
|
|
|
7
7
|
/* eslint-disable max-classes-per-file */
|
|
8
|
+
|
|
8
9
|
const Menu = _ref => {
|
|
9
10
|
var _process$env;
|
|
10
11
|
|
|
@@ -24,10 +25,35 @@ const Menu = _ref => {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const [open, setOpen] = useControllableState(isOpen, onIsOpenChange, isOpen);
|
|
28
|
+
const [maskHeight, setMaskHeight] = useState(null);
|
|
29
|
+
const [submenus, setSubmenus] = useState(new Set());
|
|
30
|
+
const triggerRef = useRef(null);
|
|
31
|
+
|
|
32
|
+
const registerSubmenu = (submenuId, submenuIsOpen) => {
|
|
33
|
+
setSubmenus(subs => {
|
|
34
|
+
const clone = new Set(subs);
|
|
35
|
+
|
|
36
|
+
if (submenuIsOpen) {
|
|
37
|
+
clone.add(submenuId);
|
|
38
|
+
} else {
|
|
39
|
+
clone.delete(submenuId);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return clone;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const openPaneDepth = useMemo(() => open ? submenus.size + 1 : 0, [submenus, open]);
|
|
27
47
|
return /*#__PURE__*/React__default.createElement(MenuContextProvider, {
|
|
28
48
|
value: {
|
|
29
49
|
dataTestId,
|
|
30
|
-
isDisabled
|
|
50
|
+
isDisabled,
|
|
51
|
+
openPaneDepth,
|
|
52
|
+
registerSubmenu,
|
|
53
|
+
maskHeight,
|
|
54
|
+
setMaskHeight,
|
|
55
|
+
open,
|
|
56
|
+
triggerRef
|
|
31
57
|
}
|
|
32
58
|
}, /*#__PURE__*/React__default.createElement(Root, {
|
|
33
59
|
open: open,
|
|
@@ -68,4 +94,4 @@ class PointerEvent extends Event {
|
|
|
68
94
|
|
|
69
95
|
}
|
|
70
96
|
|
|
71
|
-
export { Menu
|
|
97
|
+
export { Menu as default };
|
package/dist/next/Menu/Menu2.js
CHANGED
|
@@ -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 = {"buttonContainer":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._3cPV_{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._3cPV_>._1cXMI{cursor:unset;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;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559;background-color:#fafafa;overflow:hidden;text-overflow:ellipsis}._3cPV_>._1cXMI:hover:not([aria-disabled=true]){background-color:#f5f5f5}._3cPV_>._1cXMI:focus{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._3cPV_>._1cXMI+._1zYaI{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._3cPV_>._1cXMI[data-state=open]+._1zYaI{transform:rotate(-180deg) translateY(50%)}._3cPV_>._1cXMI[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._3cPV_>._1cXMI[aria-disabled=true]+._1zYaI{fill:#515559;opacity:.4}._JqaGP>[data-radix-popper-content-wrapper]{overflow:hidden;background-color:#fff;width:var(--radix-dropdown-menu-trigger-width);min-width:200px!important;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);border-radius:4px;z-index:1!important}._JqaGP>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._3vPBN{margin:0;padding:4px 0;background:#fff;transition:.35s;opacity:1;overflow:scroll;width:var(--radix-dropdown-menu-trigger-width);min-width:200px;max-height:350px}._3vPBN._2Lk6S{padding-top:0}._3vPBN._1mAS3{margin-left:30px;opacity:0;pointer-events:none}._3vPBN._31uw2{margin-left:-30px;pointer-events:none}._12itw{position:relative;padding:10px 12px;min-height:40px;display:flex;flex-direction:row;align-items:center;cursor:pointer;outline:none;word-break:break-word;font-size:14px;color:#32363a;width:100%}._12itw._PENPH{cursor:unset}._12itw ._1Aprb{fill:#32363a;margin-right:4px}._12itw[data-highlighted]{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._12itw[aria-disabled=true]{cursor:not-allowed;opacity:.65}._12itw._3GbMA{padding-right:32px}._12itw._3GbMA ._1zYaI{position:absolute;height:100%;right:3px;fill:#515559}._12itw._8s7kI{pointer-events:none}._1fgXo{position:-webkit-sticky;position:sticky;top:0;padding-top:4px;background-color:#fff;z-index:1;border-bottom:1px solid #e8e8e8}._1fgXo>._1DFLz{padding:4px 8px 8px;border-radius:4px 4px 0 0}._1fgXo>._1DFLz>._iiOJs{width:100%}._1fgXo>._1DFLz._8s7kI{pointer-events:none}";
|
|
4
|
+
var styles = {"buttonContainer":"_3cPV_","button":"_1cXMI","rightIcon":"_1zYaI","maskContainer":"_JqaGP","flyout":"_3vPBN","containsStickyBox":"_2Lk6S","animatedRight":"_1mAS3","animatedLeft":"_31uw2","menuItem":"_12itw","noItems":"_PENPH","backIcon":"_1Aprb","subMenu":"_3GbMA","unresponsive":"_8s7kI","stickyBox":"_1fgXo","searchBox":"_1DFLz","searchInput":"_iiOJs"};
|
|
5
|
+
var stylesheet="._3cPV_{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._3cPV_>._1cXMI{cursor:unset;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;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559;background-color:#fafafa;overflow:hidden;text-overflow:ellipsis}._3cPV_>._1cXMI:hover:not([aria-disabled=true]){background-color:#f5f5f5}._3cPV_>._1cXMI:focus{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._3cPV_>._1cXMI+._1zYaI{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._3cPV_>._1cXMI[data-state=open]+._1zYaI{transform:rotate(-180deg) translateY(50%)}._3cPV_>._1cXMI[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._3cPV_>._1cXMI[aria-disabled=true]+._1zYaI{fill:#515559;opacity:.4}._JqaGP>[data-radix-popper-content-wrapper]{overflow:hidden;background-color:#fff;width:var(--radix-dropdown-menu-trigger-width);min-width:200px!important;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);border-radius:4px;z-index:1!important}._JqaGP>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._3vPBN{margin:0;padding:4px 0;background:#fff;transition:.35s;opacity:1;overflow:scroll;width:var(--radix-dropdown-menu-trigger-width);min-width:200px;max-height:350px}._3vPBN._2Lk6S{padding-top:0}._3vPBN._1mAS3{margin-left:30px;opacity:0;pointer-events:none}._3vPBN._31uw2{margin-left:-30px;pointer-events:none}._12itw{position:relative;padding:10px 12px;min-height:40px;display:flex;flex-direction:row;align-items:center;cursor:pointer;outline:none;word-break:break-word;font-size:14px;color:#32363a;width:100%}._12itw._PENPH{cursor:unset}._12itw ._1Aprb{fill:#32363a;margin-right:4px}._12itw[data-highlighted]{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._12itw[aria-disabled=true]{cursor:not-allowed;opacity:.65}._12itw._3GbMA{padding-right:32px}._12itw._3GbMA ._1zYaI{position:absolute;height:100%;right:3px;fill:#515559}._12itw._8s7kI{pointer-events:none}._1fgXo{position:-webkit-sticky;position:sticky;top:0;padding-top:4px;background-color:#fff;z-index:1;border-bottom:1px solid #e8e8e8}._1fgXo>._1DFLz{padding:4px 8px 8px;border-radius:4px 4px 0 0}._1fgXo>._1DFLz>._iiOJs{width:100%}._1fgXo>._1DFLz._8s7kI{pointer-events:none}";
|
|
6
6
|
styleInject(css_248z);
|
|
7
7
|
|
|
8
8
|
export { styles as default, stylesheet };
|
|
@@ -7,6 +7,7 @@ import styles from './Menu2.js';
|
|
|
7
7
|
import '../../utils/index.js';
|
|
8
8
|
import { useMenuContext } from './MenuContext.js';
|
|
9
9
|
import { DATA_TESTID_SUFFIXES } from './constants.js';
|
|
10
|
+
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
10
11
|
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
11
12
|
import ChevronDownIcon from '../../icons/components/ChevronDownIcon.js';
|
|
12
13
|
|
|
@@ -14,11 +15,13 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
14
15
|
let {
|
|
15
16
|
asChild,
|
|
16
17
|
children,
|
|
18
|
+
className,
|
|
17
19
|
...rest
|
|
18
20
|
} = _ref;
|
|
19
21
|
const {
|
|
20
22
|
dataTestId: rootDataTestId,
|
|
21
|
-
isDisabled
|
|
23
|
+
isDisabled,
|
|
24
|
+
triggerRef
|
|
22
25
|
} = useMenuContext();
|
|
23
26
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
24
27
|
className: classNames({
|
|
@@ -26,11 +29,11 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
26
29
|
})
|
|
27
30
|
}, /*#__PURE__*/React__default.createElement(Trigger, _extends({}, rest, {
|
|
28
31
|
"aria-disabled": isDisabled,
|
|
29
|
-
className: classNames({
|
|
32
|
+
className: classNames(className, {
|
|
30
33
|
[styles.button]: !asChild
|
|
31
34
|
}),
|
|
32
35
|
asChild: asChild,
|
|
33
|
-
ref: ref,
|
|
36
|
+
ref: mergeRefs(triggerRef, ref),
|
|
34
37
|
"data-testid": getSubDataTestId(rootDataTestId, DATA_TESTID_SUFFIXES.MENU_BUTTON)
|
|
35
38
|
}), children), !asChild && /*#__PURE__*/React__default.createElement(ChevronDownIcon, {
|
|
36
39
|
className: styles.rightIcon,
|
|
@@ -38,4 +41,4 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
38
41
|
}));
|
|
39
42
|
});
|
|
40
43
|
|
|
41
|
-
export { MenuButton
|
|
44
|
+
export { MenuButton as default };
|
|
@@ -6,11 +6,11 @@ import createContextUtilities from '../../utils/createContextUtilities/createCon
|
|
|
6
6
|
const {
|
|
7
7
|
useContext: useMenuContext,
|
|
8
8
|
Provider: MenuContextProvider
|
|
9
|
-
} = createContextUtilities(
|
|
9
|
+
} = createContextUtilities();
|
|
10
10
|
const {
|
|
11
11
|
useContext: intermediaryUseMenuContext,
|
|
12
12
|
Provider: IntermediaryMenuContextProvider
|
|
13
|
-
} = createContextUtilities(
|
|
13
|
+
} = createContextUtilities();
|
|
14
14
|
|
|
15
15
|
const PaneContextProvider = _ref => {
|
|
16
16
|
let {
|
|
@@ -6,8 +6,9 @@ import classNames from 'classnames';
|
|
|
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 } from './constants.js';
|
|
9
|
+
import { DATA_TESTID_SUFFIXES, KEYS } from './constants.js';
|
|
10
10
|
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
11
|
+
import { getIsKeyboardUser } from '../../utils/keyboardUser/keyboardUser.js';
|
|
11
12
|
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
12
13
|
|
|
13
14
|
const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
@@ -25,7 +26,10 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
25
26
|
dataTestId: menuParentDataTestId,
|
|
26
27
|
childIndex: index,
|
|
27
28
|
searchValue,
|
|
28
|
-
isSearchFilteringDisabled
|
|
29
|
+
isSearchFilteringDisabled,
|
|
30
|
+
isInteractive,
|
|
31
|
+
closeSubmenu,
|
|
32
|
+
flyoutRef
|
|
29
33
|
} = usePaneContext(itemRef);
|
|
30
34
|
const dataTestId = getSubDataTestId(menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_ITEM), String(index));
|
|
31
35
|
const isVisible = useMemo(() => {
|
|
@@ -34,16 +38,43 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
34
38
|
const searchMatcher = label !== null && label !== void 0 ? label : typeof children === 'string' ? children : undefined;
|
|
35
39
|
return isSearchFilteringDisabled || !searchValue || (searchMatcher === null || searchMatcher === void 0 ? void 0 : _includesInstanceProperty(_context = searchMatcher.toLowerCase()).call(_context, searchValue.toLowerCase()));
|
|
36
40
|
}, [children, searchValue, label, isSearchFilteringDisabled]);
|
|
41
|
+
|
|
42
|
+
const handleFocus = () => {
|
|
43
|
+
if (itemRef.current && flyoutRef.current && getIsKeyboardUser()) {
|
|
44
|
+
const stickyBoxHeight = 93; // if the top of the focused menu item is beneath the sticky box
|
|
45
|
+
|
|
46
|
+
if (itemRef.current.offsetTop < flyoutRef.current.scrollTop + stickyBoxHeight) {
|
|
47
|
+
// scroll down a little
|
|
48
|
+
flyoutRef.current.scrollTop = itemRef.current.offsetTop - stickyBoxHeight;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
37
53
|
return isVisible ? /*#__PURE__*/React__default.createElement(Item, _extends({}, rest, {
|
|
38
54
|
asChild: asChild,
|
|
39
55
|
"aria-disabled": isDisabled,
|
|
40
|
-
className: classNames(className, styles.menuItem
|
|
56
|
+
className: classNames(className, styles.menuItem, {
|
|
57
|
+
[styles.unresponsive]: !isInteractive
|
|
58
|
+
}),
|
|
41
59
|
"data-testid": dataTestId,
|
|
42
|
-
ref: mergeRefs(ref, itemRef)
|
|
60
|
+
ref: mergeRefs(ref, itemRef),
|
|
61
|
+
onKeyDown: e => {
|
|
62
|
+
var _context2;
|
|
63
|
+
|
|
64
|
+
if (!isInteractive) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (_includesInstanceProperty(_context2 = KEYS.CLOSE_SUBMENU).call(_context2, e.key)) {
|
|
70
|
+
closeSubmenu === null || closeSubmenu === void 0 ? void 0 : closeSubmenu(e);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
onFocus: handleFocus // stop radix from closing the menu on selection of disabled item
|
|
43
74
|
// other pointer and keyboard events still work, even when disabled
|
|
44
75
|
,
|
|
45
76
|
onSelect: e => isDisabled ? e.preventDefault() : onSelect === null || onSelect === void 0 ? void 0 : onSelect()
|
|
46
77
|
}), (!children || typeof children === 'string') && label ? label : children) : null;
|
|
47
78
|
});
|
|
48
79
|
|
|
49
|
-
export { MenuItem
|
|
80
|
+
export { MenuItem as default };
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
2
|
-
import
|
|
2
|
+
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
3
|
+
import React__default, { useState, useRef, useMemo } from 'react';
|
|
3
4
|
import { Portal, Content } from '@radix-ui/react-dropdown-menu';
|
|
5
|
+
import classNames from 'classnames';
|
|
4
6
|
import styles from './Menu2.js';
|
|
5
7
|
import { usePortalTarget } from '../../components/UIProvider/PortalTargetContext.js';
|
|
6
8
|
import { useMenuContext, PaneContextProvider } from './MenuContext.js';
|
|
7
9
|
import '../../utils/index.js';
|
|
8
|
-
import { DATA_TESTID_SUFFIXES } from './constants.js';
|
|
9
|
-
import
|
|
10
|
+
import { DATA_TESTID_SUFFIXES, KEYS } from './constants.js';
|
|
11
|
+
import MenuSearch from './MenuSearch.js';
|
|
12
|
+
import usePaneSearch from './usePaneSearch.js';
|
|
10
13
|
import '../../hooks/index.js';
|
|
11
|
-
import
|
|
14
|
+
import { useDidUpdate } from '../../hooks/useDidUpdate/useDidUpdate.js';
|
|
12
15
|
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
16
|
+
import useEventListener from '../../hooks/useEventListener/useEventListener.js';
|
|
17
|
+
import { setIsKeyboardUser } from '../../utils/keyboardUser/keyboardUser.js';
|
|
13
18
|
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
14
19
|
|
|
15
20
|
const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
@@ -20,45 +25,130 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
20
25
|
searchValue: externalSearchValue,
|
|
21
26
|
onSearchValueChange,
|
|
22
27
|
isSearchFilteringDisabled = false,
|
|
28
|
+
className,
|
|
29
|
+
style,
|
|
23
30
|
...rest
|
|
24
31
|
} = _ref;
|
|
25
|
-
const [
|
|
32
|
+
const [items, setItems] = useState([]);
|
|
33
|
+
const flyoutRef = useRef(null);
|
|
34
|
+
const {
|
|
35
|
+
internalSearchValue,
|
|
36
|
+
setSearchValue,
|
|
37
|
+
zeroSearchResults,
|
|
38
|
+
noMatchesText
|
|
39
|
+
} = usePaneSearch(externalSearchValue, onSearchValueChange, items);
|
|
26
40
|
const portalTarget = usePortalTarget();
|
|
27
41
|
const [side, align] = useMemo(() => {
|
|
28
42
|
var _placement$split, _placement$split2;
|
|
29
43
|
|
|
30
44
|
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 : [];
|
|
31
45
|
}, [placement]);
|
|
32
|
-
const [items, setItems] = useState([]);
|
|
33
46
|
const {
|
|
34
|
-
dataTestId: rootDataTestId
|
|
35
|
-
|
|
47
|
+
dataTestId: rootDataTestId,
|
|
48
|
+
openPaneDepth,
|
|
49
|
+
setMaskHeight,
|
|
50
|
+
maskHeight,
|
|
51
|
+
open,
|
|
52
|
+
triggerRef
|
|
53
|
+
} = useMenuContext(); // 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.
|
|
54
|
+
// We cache the pixel value here, to use it later if the user returns to this pane from a submenu.
|
|
55
|
+
|
|
56
|
+
const initialHeightOfThisPane = useRef(null);
|
|
57
|
+
useDidUpdate(() => {
|
|
58
|
+
if (openPaneDepth === 1) {
|
|
59
|
+
if (initialHeightOfThisPane.current === null) {
|
|
60
|
+
window.requestAnimationFrame(() => {
|
|
61
|
+
var _flyoutRef$current$cl, _flyoutRef$current;
|
|
62
|
+
|
|
63
|
+
initialHeightOfThisPane.current = (_flyoutRef$current$cl = (_flyoutRef$current = flyoutRef.current) === null || _flyoutRef$current === void 0 ? void 0 : _flyoutRef$current.clientHeight) !== null && _flyoutRef$current$cl !== void 0 ? _flyoutRef$current$cl : null;
|
|
64
|
+
setMaskHeight(initialHeightOfThisPane.current);
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
setMaskHeight(initialHeightOfThisPane.current);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, [openPaneDepth]);
|
|
36
71
|
const dataTestId = getSubDataTestId(rootDataTestId, DATA_TESTID_SUFFIXES.MENU_PANE);
|
|
37
|
-
const
|
|
72
|
+
const animatedLeft = useMemo(() => openPaneDepth > 1, [openPaneDepth]);
|
|
73
|
+
useEventListener(flyoutRef, 'keydown', e => {
|
|
74
|
+
var _context;
|
|
75
|
+
|
|
76
|
+
return _includesInstanceProperty(_context = Object.values(KEYS).flat()).call(_context, e.key) && setIsKeyboardUser(true);
|
|
77
|
+
}, {
|
|
78
|
+
additionalDependencies: [openPaneDepth]
|
|
79
|
+
});
|
|
80
|
+
useEventListener(flyoutRef, 'pointerenter', () => setIsKeyboardUser(false), {
|
|
81
|
+
additionalDependencies: [openPaneDepth]
|
|
82
|
+
});
|
|
83
|
+
const defaultSide = useMemo(() => {
|
|
84
|
+
var _triggerRef$current;
|
|
85
|
+
|
|
86
|
+
const rect = triggerRef === null || triggerRef === void 0 ? void 0 : (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.getBoundingClientRect();
|
|
87
|
+
|
|
88
|
+
if (!rect) {
|
|
89
|
+
return 'bottom';
|
|
90
|
+
} // hard coded in Menu.less
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
let maxHeight = 350;
|
|
94
|
+
|
|
95
|
+
if (flyoutRef.current) {
|
|
96
|
+
const computedString = window.getComputedStyle(flyoutRef.current).maxHeight.slice(0, -2);
|
|
97
|
+
|
|
98
|
+
if (computedString !== '' && !Number.isNaN(+computedString)) {
|
|
99
|
+
maxHeight = +computedString;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const distanceToBottom = window.innerHeight - rect.bottom;
|
|
104
|
+
const distanceToTop = rect.top;
|
|
105
|
+
|
|
106
|
+
if (distanceToBottom > maxHeight) {
|
|
107
|
+
return 'bottom';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (distanceToTop > maxHeight) {
|
|
111
|
+
return 'top';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return 'bottom';
|
|
115
|
+
}, [open, triggerRef]);
|
|
38
116
|
return /*#__PURE__*/React__default.createElement(PaneContextProvider, {
|
|
39
117
|
items: items,
|
|
40
118
|
setItems: setItems,
|
|
41
119
|
value: {
|
|
42
120
|
dataTestId,
|
|
43
121
|
searchValue: internalSearchValue,
|
|
44
|
-
|
|
45
|
-
|
|
122
|
+
isSearchFilteringDisabled,
|
|
123
|
+
isInteractive: !animatedLeft,
|
|
124
|
+
flyoutRef
|
|
46
125
|
}
|
|
47
126
|
}, /*#__PURE__*/React__default.createElement(Portal, {
|
|
48
127
|
container: portalTarget || undefined
|
|
128
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
129
|
+
className: styles.maskContainer
|
|
49
130
|
}, /*#__PURE__*/React__default.createElement(Content, _extends({}, rest, {
|
|
50
131
|
sideOffset: 6,
|
|
51
132
|
loop: true,
|
|
52
|
-
side: side ||
|
|
133
|
+
side: side || defaultSide,
|
|
53
134
|
align: align || 'start',
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
135
|
+
ref: mergeRefs(ref, flyoutRef),
|
|
136
|
+
"data-testid": dataTestId,
|
|
137
|
+
className: classNames(className, {
|
|
138
|
+
[styles.animatedLeft]: animatedLeft,
|
|
139
|
+
[styles.containsStickyBox]: isSearchable
|
|
140
|
+
}, styles.flyout),
|
|
141
|
+
style: { ...style,
|
|
142
|
+
height: internalSearchValue && openPaneDepth === 1 ? undefined : maskHeight !== null && maskHeight !== void 0 ? maskHeight : undefined
|
|
143
|
+
}
|
|
144
|
+
}), isSearchable && /*#__PURE__*/React__default.createElement("div", {
|
|
145
|
+
className: styles.stickyBox
|
|
146
|
+
}, /*#__PURE__*/React__default.createElement(MenuSearch, {
|
|
147
|
+
setSearchValue: setSearchValue
|
|
148
|
+
})), zeroSearchResults && /*#__PURE__*/React__default.createElement("div", {
|
|
149
|
+
className: classNames(styles.menuItem, styles.noItems),
|
|
150
|
+
"aria-live": "assertive"
|
|
151
|
+
}, noMatchesText), children))));
|
|
62
152
|
});
|
|
63
153
|
|
|
64
|
-
export { MenuPane
|
|
154
|
+
export { MenuPane as default };
|
|
@@ -1,46 +1,43 @@
|
|
|
1
1
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
2
|
-
import React__default, { useRef,
|
|
2
|
+
import React__default, { useRef, useEffect, useState } from 'react';
|
|
3
3
|
import { Item } from '@radix-ui/react-dropdown-menu';
|
|
4
|
+
import classNames from 'classnames';
|
|
4
5
|
import styles from './Menu2.js';
|
|
5
6
|
import '../Input/index.js';
|
|
6
7
|
import '../../icons/index.es.js';
|
|
7
8
|
import '../../utils/index.js';
|
|
8
9
|
import { usePaneContext } from './MenuContext.js';
|
|
9
|
-
import { DATA_TESTID_SUFFIXES } from './constants.js';
|
|
10
|
+
import { DATA_TESTID_SUFFIXES, KEYS } from './constants.js';
|
|
10
11
|
import '../../hooks/index.js';
|
|
11
12
|
import useTranslation from '../../utils/Translation/useTranslation.js';
|
|
12
13
|
import useEventListener from '../../hooks/useEventListener/useEventListener.js';
|
|
14
|
+
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
13
15
|
import Input from '../Input/Input.js';
|
|
14
16
|
import SearchIcon from '../../icons/components/SearchIcon.js';
|
|
15
17
|
|
|
16
|
-
const MenuSearch = _ref => {
|
|
18
|
+
const MenuSearch = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
17
19
|
let {
|
|
18
|
-
setSearchValue
|
|
19
|
-
items,
|
|
20
|
-
paneRef
|
|
20
|
+
setSearchValue
|
|
21
21
|
} = _ref;
|
|
22
22
|
const itemRef = useRef(null);
|
|
23
23
|
const inputRef = useRef(null);
|
|
24
24
|
const {
|
|
25
25
|
translate
|
|
26
26
|
} = useTranslation();
|
|
27
|
-
const noMatchesText = translate('menu.noItemsToDisplay');
|
|
28
27
|
const searchText = translate('searchText');
|
|
29
28
|
const {
|
|
30
29
|
dataTestId: menuParentDataTestId,
|
|
31
|
-
searchValue = ''
|
|
30
|
+
searchValue = '',
|
|
31
|
+
isInteractive,
|
|
32
|
+
closeSubmenu,
|
|
33
|
+
flyoutRef
|
|
32
34
|
} = usePaneContext();
|
|
33
|
-
const dataTestId = menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_SEARCH);
|
|
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]);
|
|
35
|
+
const dataTestId = menuParentDataTestId === null || menuParentDataTestId === void 0 ? void 0 : menuParentDataTestId.replace(DATA_TESTID_SUFFIXES.MENU_PANE, DATA_TESTID_SUFFIXES.MENU_SEARCH);
|
|
39
36
|
useEffect(() => () => setSearchValue(''), [setSearchValue]);
|
|
40
|
-
const [previouslyFocusedElement, setPreviouslyFocusedElement] = useState(); //
|
|
37
|
+
const [previouslyFocusedElement, setPreviouslyFocusedElement] = useState(); // hack to keep focus on search input on mouse leave
|
|
41
38
|
|
|
42
|
-
useEventListener(
|
|
43
|
-
if (e.target === e.currentTarget && previouslyFocusedElement === itemRef.current) {
|
|
39
|
+
useEventListener(flyoutRef, 'focus', e => {
|
|
40
|
+
if (e.target === e.currentTarget && previouslyFocusedElement === itemRef.current && isInteractive) {
|
|
44
41
|
var _inputRef$current;
|
|
45
42
|
|
|
46
43
|
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
@@ -51,7 +48,9 @@ const MenuSearch = _ref => {
|
|
|
51
48
|
isCaptureEvent: true
|
|
52
49
|
});
|
|
53
50
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Item, {
|
|
54
|
-
className: styles.searchBox
|
|
51
|
+
className: classNames(styles.searchBox, {
|
|
52
|
+
[styles.unresponsive]: !isInteractive
|
|
53
|
+
}) // prevents dropdown from closing
|
|
55
54
|
,
|
|
56
55
|
onSelect: e => e.preventDefault(),
|
|
57
56
|
onFocus: () => {
|
|
@@ -60,7 +59,7 @@ const MenuSearch = _ref => {
|
|
|
60
59
|
return (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
|
|
61
60
|
},
|
|
62
61
|
role: undefined,
|
|
63
|
-
ref: itemRef
|
|
62
|
+
ref: mergeRefs(itemRef, ref)
|
|
64
63
|
}, /*#__PURE__*/React__default.createElement(Input, {
|
|
65
64
|
"data-testid": dataTestId,
|
|
66
65
|
role: "searchbox",
|
|
@@ -68,18 +67,18 @@ const MenuSearch = _ref => {
|
|
|
68
67
|
onChange: e => setSearchValue(e.target.value),
|
|
69
68
|
placeholder: searchText,
|
|
70
69
|
onKeyDown: e => {
|
|
71
|
-
var _e$target;
|
|
70
|
+
var _e$target, _context, _context2;
|
|
72
71
|
|
|
73
72
|
// 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
|
|
73
|
+
e.stopPropagation(); // allow caret movement through text entry, but close searchable submenu if on the very left
|
|
76
74
|
|
|
77
|
-
if (((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.selectionStart) === 0) {
|
|
78
|
-
|
|
75
|
+
if (((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.selectionStart) === 0 && _includesInstanceProperty(_context = KEYS.CLOSE_SUBMENU).call(_context, e.key)) {
|
|
76
|
+
closeSubmenu === null || closeSubmenu === void 0 ? void 0 : closeSubmenu(e);
|
|
77
|
+
return;
|
|
79
78
|
} // forward keypress directly to `Item` to let Radix handle keyboard navigation
|
|
80
79
|
|
|
81
80
|
|
|
82
|
-
if (_includesInstanceProperty(
|
|
81
|
+
if (_includesInstanceProperty(_context2 = KEYS.IGNORED_BY_SEARCH_INPUT).call(_context2, e.key)) {
|
|
83
82
|
var _itemRef$current;
|
|
84
83
|
|
|
85
84
|
// `view` types are incompatible
|
|
@@ -92,14 +91,9 @@ const MenuSearch = _ref => {
|
|
|
92
91
|
}
|
|
93
92
|
},
|
|
94
93
|
leftAddOn: /*#__PURE__*/React__default.createElement(SearchIcon, null),
|
|
95
|
-
ref: inputRef
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
role: "option" // `aria-selected` is omitted because this option is not selectable
|
|
100
|
-
,
|
|
101
|
-
"aria-live": "assertive"
|
|
102
|
-
}, noMatchesText));
|
|
103
|
-
};
|
|
94
|
+
ref: inputRef,
|
|
95
|
+
className: styles.searchInput
|
|
96
|
+
})));
|
|
97
|
+
});
|
|
104
98
|
|
|
105
|
-
export { MenuSearch
|
|
99
|
+
export { MenuSearch as default };
|