@fluentui/react-menu 9.5.2 → 9.5.4
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +111 -1
- package/CHANGELOG.md +31 -2
- package/lib/components/Menu/Menu.js +0 -1
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/renderMenu.js +0 -1
- package/lib/components/Menu/renderMenu.js.map +1 -1
- package/lib/components/Menu/useMenu.js +16 -34
- package/lib/components/Menu/useMenu.js.map +1 -1
- package/lib/components/Menu/useMenuContextValues.js +2 -2
- package/lib/components/Menu/useMenuContextValues.js.map +1 -1
- package/lib/components/MenuDivider/MenuDivider.js +0 -1
- package/lib/components/MenuDivider/MenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/renderMenuDivider.js +2 -2
- package/lib/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDivider.js +0 -1
- package/lib/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDividerStyles.js +10 -12
- package/lib/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib/components/MenuGroup/MenuGroup.js +0 -1
- package/lib/components/MenuGroup/MenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/renderMenuGroup.js +2 -2
- package/lib/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroup.js +0 -1
- package/lib/components/MenuGroup/useMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroupContextValues.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroupStyles.js.map +1 -1
- package/lib/components/MenuGroupHeader/MenuGroupHeader.js +0 -1
- package/lib/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js +2 -2
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js +0 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +10 -12
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib/components/MenuItem/MenuItem.js +0 -1
- package/lib/components/MenuItem/MenuItem.js.map +1 -1
- package/lib/components/MenuItem/renderMenuItem.js +12 -7
- package/lib/components/MenuItem/renderMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useCharacterSearch.js +0 -5
- package/lib/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib/components/MenuItem/useMenuItem.js +0 -6
- package/lib/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useMenuItemStyles.js +108 -117
- package/lib/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.js +0 -1
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js +10 -6
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js +2 -4
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +0 -5
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib/components/MenuItemRadio/MenuItemRadio.js +0 -1
- package/lib/components/MenuItemRadio/MenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js +10 -6
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadio.js +3 -4
- package/lib/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js +0 -5
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib/components/MenuList/MenuList.js +0 -1
- package/lib/components/MenuList/MenuList.js.map +1 -1
- package/lib/components/MenuList/renderMenuList.js +2 -2
- package/lib/components/MenuList/renderMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuList.js +10 -27
- package/lib/components/MenuList/useMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuListContextValues.js +2 -2
- package/lib/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib/components/MenuList/useMenuListStyles.js +6 -9
- package/lib/components/MenuList/useMenuListStyles.js.map +1 -1
- package/lib/components/MenuPopover/MenuPopover.js +0 -1
- package/lib/components/MenuPopover/MenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/renderMenuPopover.js +4 -5
- package/lib/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopover.js +6 -13
- package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopoverStyles.js +32 -35
- package/lib/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib/components/MenuSplitGroup/MenuSplitGroup.js +0 -1
- package/lib/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -1
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.js +2 -2
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -1
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js +0 -6
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -1
- package/lib/components/MenuSplitGroup/useMenuSplitGroupStyles.js +12 -15
- package/lib/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -1
- package/lib/components/MenuTrigger/MenuTrigger.js +2 -3
- package/lib/components/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/renderMenuTrigger.js +0 -1
- package/lib/components/MenuTrigger/renderMenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/useMenuTrigger.js +4 -24
- package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib/contexts/menuContext.js.map +1 -1
- package/lib/contexts/menuGroupContext.js +0 -1
- package/lib/contexts/menuGroupContext.js.map +1 -1
- package/lib/contexts/menuListContext.js.map +1 -1
- package/lib/contexts/menuTriggerContext.js +0 -2
- package/lib/contexts/menuTriggerContext.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/selectable/useCheckmarkStyles.js +7 -11
- package/lib/selectable/useCheckmarkStyles.js.map +1 -1
- package/lib/utils/useIsSubmenu.js +0 -1
- package/lib/utils/useIsSubmenu.js.map +1 -1
- package/lib/utils/useOnMenuEnter.js +4 -11
- package/lib/utils/useOnMenuEnter.js.map +1 -1
- package/lib-commonjs/Menu.js +0 -2
- package/lib-commonjs/Menu.js.map +1 -1
- package/lib-commonjs/MenuDivider.js +0 -2
- package/lib-commonjs/MenuDivider.js.map +1 -1
- package/lib-commonjs/MenuGroup.js +0 -2
- package/lib-commonjs/MenuGroup.js.map +1 -1
- package/lib-commonjs/MenuGroupHeader.js +0 -2
- package/lib-commonjs/MenuGroupHeader.js.map +1 -1
- package/lib-commonjs/MenuItem.js +0 -2
- package/lib-commonjs/MenuItem.js.map +1 -1
- package/lib-commonjs/MenuItemCheckbox.js +0 -2
- package/lib-commonjs/MenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/MenuItemRadio.js +0 -2
- package/lib-commonjs/MenuItemRadio.js.map +1 -1
- package/lib-commonjs/MenuList.js +0 -2
- package/lib-commonjs/MenuList.js.map +1 -1
- package/lib-commonjs/MenuPopover.js +0 -2
- package/lib-commonjs/MenuPopover.js.map +1 -1
- package/lib-commonjs/MenuSplitGroup.js +0 -2
- package/lib-commonjs/MenuSplitGroup.js.map +1 -1
- package/lib-commonjs/MenuTrigger.js +0 -2
- package/lib-commonjs/MenuTrigger.js.map +1 -1
- package/lib-commonjs/components/Menu/Menu.js +0 -6
- package/lib-commonjs/components/Menu/Menu.js.map +1 -1
- package/lib-commonjs/components/Menu/Menu.types.js.map +1 -1
- package/lib-commonjs/components/Menu/index.js +0 -6
- package/lib-commonjs/components/Menu/index.js.map +1 -1
- package/lib-commonjs/components/Menu/renderMenu.js +0 -5
- package/lib-commonjs/components/Menu/renderMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenu.js +16 -46
- package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenuContextValues.js +2 -4
- package/lib-commonjs/components/Menu/useMenuContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/MenuDivider.js +0 -6
- package/lib-commonjs/components/MenuDivider/MenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/MenuDivider.types.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/index.js +0 -6
- package/lib-commonjs/components/MenuDivider/index.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.js +2 -6
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/useMenuDivider.js +0 -4
- package/lib-commonjs/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js +10 -16
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/MenuGroup.js +0 -7
- package/lib-commonjs/components/MenuGroup/MenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/MenuGroup.types.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/index.js +0 -7
- package/lib-commonjs/components/MenuGroup/index.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.js +2 -7
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroup.js +0 -4
- package/lib-commonjs/components/MenuGroup/useMenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.js +0 -3
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js +0 -4
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.js +0 -6
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.types.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/index.js +0 -6
- package/lib-commonjs/components/MenuGroupHeader/index.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.js +2 -6
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.js +0 -5
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +10 -16
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItem/MenuItem.js +0 -6
- package/lib-commonjs/components/MenuItem/MenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/MenuItem.types.js.map +1 -1
- package/lib-commonjs/components/MenuItem/index.js +0 -6
- package/lib-commonjs/components/MenuItem/index.js.map +1 -1
- package/lib-commonjs/components/MenuItem/renderMenuItem.js +12 -11
- package/lib-commonjs/components/MenuItem/renderMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js +0 -8
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItem.js +0 -18
- package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js +108 -124
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.js +0 -6
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.types.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/index.js +0 -6
- package/lib-commonjs/components/MenuItemCheckbox/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.js +10 -10
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js +2 -11
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +0 -11
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.js +0 -6
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.types.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/index.js +0 -6
- package/lib-commonjs/components/MenuItemRadio/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.js +10 -10
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js +3 -11
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js +0 -11
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib-commonjs/components/MenuList/MenuList.js +0 -7
- package/lib-commonjs/components/MenuList/MenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/MenuList.types.js.map +1 -1
- package/lib-commonjs/components/MenuList/index.js +0 -7
- package/lib-commonjs/components/MenuList/index.js.map +1 -1
- package/lib-commonjs/components/MenuList/renderMenuList.js +2 -7
- package/lib-commonjs/components/MenuList/renderMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuList.js +10 -35
- package/lib-commonjs/components/MenuList/useMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListContextValues.js +2 -4
- package/lib-commonjs/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListStyles.js +6 -12
- package/lib-commonjs/components/MenuList/useMenuListStyles.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/MenuPopover.js +0 -6
- package/lib-commonjs/components/MenuPopover/MenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/MenuPopover.types.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/index.js +0 -6
- package/lib-commonjs/components/MenuPopover/index.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.js +4 -10
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js +6 -22
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js +32 -39
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.js +0 -6
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.types.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/index.js +0 -6
- package/lib-commonjs/components/MenuSplitGroup/index.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/renderMenuSplitGroup.js +2 -6
- package/lib-commonjs/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroup.js +0 -13
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroupStyles.js +12 -20
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.js +2 -7
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.types.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/index.js +0 -5
- package/lib-commonjs/components/MenuTrigger/index.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.js +0 -5
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +4 -34
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib-commonjs/components/index.js +0 -3
- package/lib-commonjs/components/index.js.map +1 -1
- package/lib-commonjs/contexts/menuContext.js +0 -4
- package/lib-commonjs/contexts/menuContext.js.map +1 -1
- package/lib-commonjs/contexts/menuGroupContext.js +0 -5
- package/lib-commonjs/contexts/menuGroupContext.js.map +1 -1
- package/lib-commonjs/contexts/menuListContext.js +0 -4
- package/lib-commonjs/contexts/menuListContext.js.map +1 -1
- package/lib-commonjs/contexts/menuTriggerContext.js +0 -6
- package/lib-commonjs/contexts/menuTriggerContext.js.map +1 -1
- package/lib-commonjs/index.js +0 -32
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/selectable/index.js +0 -3
- package/lib-commonjs/selectable/index.js.map +1 -1
- package/lib-commonjs/selectable/types.js.map +1 -1
- package/lib-commonjs/selectable/useCheckmarkStyles.js +7 -13
- package/lib-commonjs/selectable/useCheckmarkStyles.js.map +1 -1
- package/lib-commonjs/utils/index.js +0 -2
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/useIsSubmenu.js +0 -6
- package/lib-commonjs/utils/useIsSubmenu.js.map +1 -1
- package/lib-commonjs/utils/useOnMenuEnter.js +4 -17
- package/lib-commonjs/utils/useOnMenuEnter.js.map +1 -1
- package/package.json +12 -12
@@ -4,23 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.renderMenuSplitGroup_unstable = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
9
|
/**
|
12
10
|
* Render the final JSX of MenuSplitGroup
|
13
11
|
*/
|
14
|
-
|
15
|
-
|
16
12
|
const renderMenuSplitGroup_unstable = state => {
|
17
13
|
const {
|
18
14
|
slots,
|
19
15
|
slotProps
|
20
16
|
} = react_utilities_1.getSlots(state);
|
21
|
-
return React.createElement(slots.root, {
|
17
|
+
return React.createElement(slots.root, {
|
18
|
+
...slotProps.root
|
22
19
|
});
|
23
20
|
};
|
24
|
-
|
25
21
|
exports.renderMenuSplitGroup_unstable = renderMenuSplitGroup_unstable;
|
26
22
|
//# sourceMappingURL=renderMenuSplitGroup.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;;;AAGO,MAAMA,6BAA6B,GAAIC,KAA0B,IAAI;EAC1E,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGC,0BAAQ,CAAsBH,KAAK,CAAC;EAEjE,OAAOI,oBAACH,KAAK,CAACI,IAAI;IAAA,GAAKH,SAAS,CAACG;EAAI,EAAI;AAC3C,CAAC;AAJYC,qCAA6B","names":["renderMenuSplitGroup_unstable","state","slots","slotProps","react_utilities_1","React","root","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuSplitGroup/renderMenuSplitGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { MenuSplitGroupState, MenuSplitGroupSlots } from './MenuSplitGroup.types';\n\n/**\n * Render the final JSX of MenuSplitGroup\n */\nexport const renderMenuSplitGroup_unstable = (state: MenuSplitGroupState) => {\n const { slots, slotProps } = getSlots<MenuSplitGroupSlots>(state);\n\n return <slots.root {...slotProps.root} />;\n};\n"]}
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.useMenuSplitGroup_unstable = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
|
-
|
12
9
|
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
13
|
-
|
14
10
|
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
15
|
-
|
16
11
|
const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
|
17
12
|
/**
|
18
13
|
* Create the state required to render MenuSplitGroup.
|
@@ -23,8 +18,6 @@ const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
|
|
23
18
|
* @param props - props from this instance of MenuSplitGroup
|
24
19
|
* @param ref - reference to root HTMLElement of MenuSplitGroup
|
25
20
|
*/
|
26
|
-
|
27
|
-
|
28
21
|
const useMenuSplitGroup_unstable = (props, ref) => {
|
29
22
|
const innerRef = React.useRef();
|
30
23
|
const {
|
@@ -39,24 +32,19 @@ const useMenuSplitGroup_unstable = (props, ref) => {
|
|
39
32
|
} = react_tabster_1.useFocusFinders();
|
40
33
|
const onKeyDown = React.useCallback(e => {
|
41
34
|
var _a;
|
42
|
-
|
43
35
|
const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
|
44
|
-
|
45
36
|
if (!activeElement) {
|
46
37
|
return;
|
47
38
|
}
|
48
|
-
|
49
39
|
if (!((_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.contains(activeElement))) {
|
50
40
|
return;
|
51
41
|
}
|
52
|
-
|
53
42
|
if (e.key === nextArrowKey) {
|
54
43
|
const next = findNextFocusable(activeElement, {
|
55
44
|
container: innerRef.current
|
56
45
|
});
|
57
46
|
next === null || next === void 0 ? void 0 : next.focus();
|
58
47
|
}
|
59
|
-
|
60
48
|
if (e.key === prevArrowKey) {
|
61
49
|
const prev = findPrevFocusable(activeElement, {
|
62
50
|
container: innerRef.current
|
@@ -76,6 +64,5 @@ const useMenuSplitGroup_unstable = (props, ref) => {
|
|
76
64
|
})
|
77
65
|
};
|
78
66
|
};
|
79
|
-
|
80
67
|
exports.useMenuSplitGroup_unstable = useMenuSplitGroup_unstable;
|
81
68
|
//# sourceMappingURL=useMenuSplitGroup.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAEA;AAEA;;;;;;;;;AASO,MAAMA,0BAA0B,GAAG,CACxCC,KAA0B,EAC1BC,GAA2B,KACJ;EACvB,MAAMC,QAAQ,GAAGC,KAAK,CAACC,MAAM,EAAe;EAC5C,MAAM;IAAEC,GAAG;IAAEC;EAAc,CAAE,GAAGC,0CAAS,EAAE;EAE3C,MAAMC,YAAY,GAAGC,+BAAa,CAACC,0BAAU,EAAEL,GAAG,CAAC;EACnD,MAAMM,YAAY,GAAGF,+BAAa,CAACC,yBAAS,EAAEL,GAAG,CAAC;EAElD,MAAM;IAAEO,iBAAiB;IAAEC;EAAiB,CAAE,GAAGC,+BAAe,EAAE;EAElE,MAAMC,SAAS,GAAGZ,KAAK,CAACa,WAAW,CAChCC,CAAmC,IAAI;;IACtC,MAAMC,aAAa,GAAGZ,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEY,aAAa;IACnD,IAAI,CAACA,aAAa,EAAE;MAClB;;IAGF,IAAI,EAAC,cAAQ,CAACC,OAAO,0CAAEC,QAAQ,CAACF,aAAa,CAAC,GAAE;MAC9C;;IAGF,IAAID,CAAC,CAACI,GAAG,KAAKb,YAAY,EAAE;MAC1B,MAAMc,IAAI,GAAGV,iBAAiB,CAACM,aAA4B,EAAE;QAAEK,SAAS,EAAErB,QAAQ,CAACiB;MAAO,CAAE,CAAC;MAC7FG,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEE,KAAK,EAAE;;IAGf,IAAIP,CAAC,CAACI,GAAG,KAAKV,YAAY,EAAE;MAC1B,MAAMc,IAAI,GAAGZ,iBAAiB,CAACK,aAA4B,EAAE;QAAEK,SAAS,EAAErB,QAAQ,CAACiB;MAAO,CAAE,CAAC;MAC7FM,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAED,KAAK,EAAE;;EAEjB,CAAC,EACD,CAACZ,iBAAiB,EAAEC,iBAAiB,EAAEP,cAAc,EAAEE,YAAY,EAAEG,YAAY,CAAC,CACnF;EAED,OAAO;IACLe,UAAU,EAAE;MACVC,IAAI,EAAE;KACP;IACDA,IAAI,EAAElB,uCAAqB,CAAC,KAAK,EAAE;MACjCmB,IAAI,EAAE,OAAO;MACb3B,GAAG,EAAEQ,+BAAa,CAACR,GAAG,EAAEC,QAAQ,CAAC;MACjCa,SAAS;MACT,GAAGf;KACJ;GACF;AACH,CAAC;AA/CY6B,kCAA0B","names":["useMenuSplitGroup_unstable","props","ref","innerRef","React","useRef","dir","targetDocument","react_shared_contexts_1","nextArrowKey","react_utilities_1","keyboard_keys_1","prevArrowKey","findNextFocusable","findPrevFocusable","react_tabster_1","onKeyDown","useCallback","e","activeElement","current","contains","key","next","container","focus","prev","components","root","role","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuSplitGroup/useMenuSplitGroup.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, getRTLSafeKey, useMergedRefs } from '@fluentui/react-utilities';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport type { MenuSplitGroupProps, MenuSplitGroupState } from './MenuSplitGroup.types';\nimport { ArrowRight, ArrowLeft } from '@fluentui/keyboard-keys';\n\n/**\n * Create the state required to render MenuSplitGroup.\n *\n * The returned state can be modified with hooks such as useMenuSplitGroupStyles_unstable,\n * before being passed to renderMenuSplitGroup_unstable.\n *\n * @param props - props from this instance of MenuSplitGroup\n * @param ref - reference to root HTMLElement of MenuSplitGroup\n */\nexport const useMenuSplitGroup_unstable = (\n props: MenuSplitGroupProps,\n ref: React.Ref<HTMLElement>,\n): MenuSplitGroupState => {\n const innerRef = React.useRef<HTMLElement>();\n const { dir, targetDocument } = useFluent();\n\n const nextArrowKey = getRTLSafeKey(ArrowRight, dir);\n const prevArrowKey = getRTLSafeKey(ArrowLeft, dir);\n\n const { findNextFocusable, findPrevFocusable } = useFocusFinders();\n\n const onKeyDown = React.useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n const activeElement = targetDocument?.activeElement;\n if (!activeElement) {\n return;\n }\n\n if (!innerRef.current?.contains(activeElement)) {\n return;\n }\n\n if (e.key === nextArrowKey) {\n const next = findNextFocusable(activeElement as HTMLElement, { container: innerRef.current });\n next?.focus();\n }\n\n if (e.key === prevArrowKey) {\n const prev = findPrevFocusable(activeElement as HTMLElement, { container: innerRef.current });\n prev?.focus();\n }\n },\n [findNextFocusable, findPrevFocusable, targetDocument, nextArrowKey, prevArrowKey],\n );\n\n return {\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n role: 'group',\n ref: useMergedRefs(ref, innerRef),\n onKeyDown,\n ...props,\n }),\n };\n};\n"]}
|
@@ -4,46 +4,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.useMenuSplitGroupStyles_unstable = exports.menuSplitGroupClassNames = void 0;
|
7
|
-
|
8
7
|
const react_1 = /*#__PURE__*/require("@griffel/react");
|
9
|
-
|
10
8
|
const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
|
11
|
-
|
12
9
|
const useMenuItemStyles_1 = /*#__PURE__*/require("../MenuItem/useMenuItemStyles");
|
13
|
-
|
14
10
|
exports.menuSplitGroupClassNames = {
|
15
11
|
root: 'fui-MenuSplitGroup'
|
16
12
|
};
|
17
13
|
/**
|
18
14
|
* Styles for the root slot
|
19
15
|
*/
|
20
|
-
|
21
16
|
const useStyles = /*#__PURE__*/react_1.__styles({
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
17
|
+
root: {
|
18
|
+
mc9l5x: "f22iagw",
|
19
|
+
u7v6m2: "f168awwq",
|
20
|
+
Bo1wru1: ["f1om2jlk", "fcyhg04"],
|
21
|
+
Bhkyaub: ["fgqgg70", "fqo1hry"],
|
22
|
+
J9ixe0: ["fh1zedf", "f1auaj6e"],
|
23
|
+
rj29m3: ["fokbbcd", "f1xlvh9o"],
|
24
|
+
B2knx3v: "f1mf2v5d",
|
25
|
+
Bl7aesu: "fi8lk9b",
|
26
|
+
e82tai: "f1tc32yi",
|
27
|
+
Bnkcs84: "f1kve8m0"
|
33
28
|
}
|
34
29
|
}, {
|
35
|
-
|
30
|
+
d: [".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f168awwq>.fui-MenuItem:nth-child(1){width:100%;}", ".f1om2jlk>.fui-MenuItem:nth-child(2){border-top-left-radius:0;}", ".fcyhg04>.fui-MenuItem:nth-child(2){border-top-right-radius:0;}", ".fgqgg70>.fui-MenuItem:nth-child(2){border-bottom-left-radius:0;}", ".fqo1hry>.fui-MenuItem:nth-child(2){border-bottom-right-radius:0;}", ".fh1zedf>.fui-MenuItem:nth-child(2){padding-left:0;}", ".f1auaj6e>.fui-MenuItem:nth-child(2){padding-right:0;}", ".fokbbcd>.fui-MenuItem:nth-child(2){margin-left:auto;}", ".f1xlvh9o>.fui-MenuItem:nth-child(2){margin-right:auto;}", ".f1mf2v5d>.fui-MenuItem:nth-child(2)::before{content:\"\";}", ".fi8lk9b>.fui-MenuItem:nth-child(2)::before{width:var(--strokeWidthThin);}", ".f1tc32yi>.fui-MenuItem:nth-child(2)::before{height:24px;}", ".f1kve8m0>.fui-MenuItem:nth-child(2)::before{background-color:var(--colorNeutralStroke1);}"]
|
36
31
|
});
|
37
32
|
/**
|
38
33
|
* Apply styling to the MenuSplitGroup slots based on the state
|
39
34
|
*/
|
40
|
-
|
41
|
-
|
42
35
|
const useMenuSplitGroupStyles_unstable = state => {
|
43
36
|
const styles = useStyles();
|
44
37
|
state.root.className = react_1.mergeClasses(exports.menuSplitGroupClassNames.root, styles.root, state.root.className);
|
45
38
|
return state;
|
46
39
|
};
|
47
|
-
|
48
40
|
exports.useMenuSplitGroupStyles_unstable = useMenuSplitGroupStyles_unstable;
|
49
41
|
//# sourceMappingURL=useMenuSplitGroupStyles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAIaA,gCAAwB,GAAwC;EAC3EC,IAAI,EAAE;CACP;AACD;;;AAGA,MAAMC,SAAS,gBAAGC,gBAAU;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAmB1B;AAEF;;;AAGO,MAAMC,gCAAgC,GAAIC,KAA0B,IAAyB;EAClG,MAAMC,MAAM,GAAGJ,SAAS,EAAE;EAC1BG,KAAK,CAACJ,IAAI,CAACM,SAAS,GAAGJ,oBAAY,CAACH,gCAAwB,CAACC,IAAI,EAAEK,MAAM,CAACL,IAAI,EAAEI,KAAK,CAACJ,IAAI,CAACM,SAAS,CAAC;EACrG,OAAOF,KAAK;AACd,CAAC;AAJYL,wCAAgC","names":["exports","root","useStyles","react_1","useMenuSplitGroupStyles_unstable","state","styles","className"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuSplitGroup/useMenuSplitGroupStyles.ts"],"sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport { menuItemClassNames } from '../MenuItem/useMenuItemStyles';\nimport type { MenuSplitGroupSlots, MenuSplitGroupState } from './MenuSplitGroup.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const menuSplitGroupClassNames: SlotClassNames<MenuSplitGroupSlots> = {\n root: 'fui-MenuSplitGroup',\n};\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n display: 'flex',\n [`& > .${menuItemClassNames.root}:nth-child(1)`]: {\n width: '100%',\n },\n [`& > .${menuItemClassNames.root}:nth-child(2)`]: {\n borderTopLeftRadius: 0,\n borderBottomLeftRadius: 0,\n paddingLeft: 0,\n marginLeft: 'auto',\n '::before': {\n content: '\"\"',\n width: tokens.strokeWidthThin,\n height: '24px',\n backgroundColor: tokens.colorNeutralStroke1,\n },\n },\n },\n});\n\n/**\n * Apply styling to the MenuSplitGroup slots based on the state\n */\nexport const useMenuSplitGroupStyles_unstable = (state: MenuSplitGroupState): MenuSplitGroupState => {\n const styles = useStyles();\n state.root.className = mergeClasses(menuSplitGroupClassNames.root, styles.root, state.root.className);\n return state;\n};\n"]}
|
@@ -4,23 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.MenuTrigger = void 0;
|
7
|
-
|
8
7
|
const useMenuTrigger_1 = /*#__PURE__*/require("./useMenuTrigger");
|
9
|
-
|
10
8
|
const renderMenuTrigger_1 = /*#__PURE__*/require("./renderMenuTrigger");
|
11
9
|
/**
|
12
10
|
* Wraps a trigger element as an only child
|
13
11
|
* and adds the necessary event handling to open a popup menu
|
14
12
|
*/
|
15
|
-
|
16
|
-
|
17
13
|
const MenuTrigger = props => {
|
18
14
|
const state = useMenuTrigger_1.useMenuTrigger_unstable(props);
|
19
15
|
return renderMenuTrigger_1.renderMenuTrigger_unstable(state);
|
20
16
|
};
|
21
|
-
|
22
17
|
exports.MenuTrigger = MenuTrigger;
|
23
|
-
exports.MenuTrigger.displayName = 'MenuTrigger';
|
24
|
-
|
18
|
+
exports.MenuTrigger.displayName = 'MenuTrigger';
|
19
|
+
// type casting here is required to ensure internal type FluentTriggerComponent is not leaked
|
25
20
|
exports.MenuTrigger.isFluentTriggerComponent = true;
|
26
21
|
//# sourceMappingURL=MenuTrigger.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AACA;AACA;AAIA;;;;AAIO,MAAMA,WAAW,GAA+BC,KAAK,IAAG;EAC7D,MAAMC,KAAK,GAAGC,wCAAuB,CAACF,KAAK,CAAC;EAE5C,OAAOG,8CAA0B,CAACF,KAAK,CAAC;AAC1C,CAAC;AAJYG,mBAAW;AAMxBA,mBAAW,CAACC,WAAW,GAAG,aAAa;AACvC;AACCD,mBAAsC,CAACE,wBAAwB,GAAG,IAAI","names":["MenuTrigger","props","state","useMenuTrigger_1","renderMenuTrigger_1","exports","displayName","isFluentTriggerComponent"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuTrigger/MenuTrigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMenuTrigger_unstable } from './useMenuTrigger';\nimport { renderMenuTrigger_unstable } from './renderMenuTrigger';\nimport type { MenuTriggerProps } from './MenuTrigger.types';\nimport type { FluentTriggerComponent } from '@fluentui/react-utilities';\n\n/**\n * Wraps a trigger element as an only child\n * and adds the necessary event handling to open a popup menu\n */\nexport const MenuTrigger: React.FC<MenuTriggerProps> = props => {\n const state = useMenuTrigger_unstable(props);\n\n return renderMenuTrigger_unstable(state);\n};\n\nMenuTrigger.displayName = 'MenuTrigger';\n// type casting here is required to ensure internal type FluentTriggerComponent is not leaked\n(MenuTrigger as FluentTriggerComponent).isFluentTriggerComponent = true;\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
@@ -3,14 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
-
|
9
7
|
tslib_1.__exportStar(require("./MenuTrigger"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./MenuTrigger.types"), exports);
|
12
|
-
|
13
9
|
tslib_1.__exportStar(require("./renderMenuTrigger"), exports);
|
14
|
-
|
15
10
|
tslib_1.__exportStar(require("./useMenuTrigger"), exports);
|
16
11
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-menu/src/components/MenuTrigger/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuTrigger/index.ts"],"sourcesContent":["export * from './MenuTrigger';\nexport * from './MenuTrigger.types';\nexport * from './renderMenuTrigger';\nexport * from './useMenuTrigger';\n"]}
|
@@ -4,22 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.renderMenuTrigger_unstable = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const menuTriggerContext_1 = /*#__PURE__*/require("../../contexts/menuTriggerContext");
|
11
9
|
/**
|
12
10
|
* Render the final JSX of MenuTrigger
|
13
11
|
*
|
14
12
|
* Only renders children
|
15
13
|
*/
|
16
|
-
|
17
|
-
|
18
14
|
const renderMenuTrigger_unstable = state => {
|
19
15
|
return React.createElement(menuTriggerContext_1.MenuTriggerContextProvider, {
|
20
16
|
value: state.isSubmenu
|
21
17
|
}, state.children);
|
22
18
|
};
|
23
|
-
|
24
19
|
exports.renderMenuTrigger_unstable = renderMenuTrigger_unstable;
|
25
20
|
//# sourceMappingURL=renderMenuTrigger.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;;;;;AAKO,MAAMA,0BAA0B,GAAIC,KAAuB,IAAI;EACpE,OAAOC,oBAACC,+CAA0B;IAACC,KAAK,EAAEH,KAAK,CAACI;EAAS,GAAGJ,KAAK,CAACK,QAAQ,CAA8B;AAC1G,CAAC;AAFYC,kCAA0B","names":["renderMenuTrigger_unstable","state","React","menuTriggerContext_1","value","isSubmenu","children","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuTrigger/renderMenuTrigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { MenuTriggerContextProvider } from '../../contexts/menuTriggerContext';\nimport type { MenuTriggerState } from './MenuTrigger.types';\n\n/**\n * Render the final JSX of MenuTrigger\n *\n * Only renders children\n */\nexport const renderMenuTrigger_unstable = (state: MenuTriggerState) => {\n return <MenuTriggerContextProvider value={state.isSubmenu}>{state.children}</MenuTriggerContextProvider>;\n};\n"]}
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.useMenuTrigger_unstable = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const menuContext_1 = /*#__PURE__*/require("../../contexts/menuContext");
|
11
|
-
|
12
9
|
const useIsSubmenu_1 = /*#__PURE__*/require("../../utils/useIsSubmenu");
|
13
|
-
|
14
10
|
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
15
|
-
|
16
11
|
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
17
|
-
|
18
12
|
const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
|
19
|
-
|
20
13
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
21
|
-
|
22
14
|
const react_aria_1 = /*#__PURE__*/require("@fluentui/react-aria");
|
23
15
|
/**
|
24
16
|
* Create the state required to render MenuTrigger.
|
@@ -26,8 +18,6 @@ const react_aria_1 = /*#__PURE__*/require("@fluentui/react-aria");
|
|
26
18
|
*
|
27
19
|
* @param props - props from this instance of MenuTrigger
|
28
20
|
*/
|
29
|
-
|
30
|
-
|
31
21
|
const useMenuTrigger_unstable = props => {
|
32
22
|
const {
|
33
23
|
children,
|
@@ -55,12 +45,10 @@ const useMenuTrigger_unstable = props => {
|
|
55
45
|
} = react_shared_contexts_1.useFluent_unstable();
|
56
46
|
const OpenArrowKey = dir === 'ltr' ? keyboard_keys_1.ArrowRight : keyboard_keys_1.ArrowLeft;
|
57
47
|
const child = react_utilities_1.getTriggerChild(children);
|
58
|
-
|
59
48
|
const onContextMenu = event => {
|
60
49
|
if (isTargetDisabled(event)) {
|
61
50
|
return;
|
62
51
|
}
|
63
|
-
|
64
52
|
if (openOnContext) {
|
65
53
|
event.preventDefault();
|
66
54
|
setOpen(event, {
|
@@ -71,12 +59,10 @@ const useMenuTrigger_unstable = props => {
|
|
71
59
|
});
|
72
60
|
}
|
73
61
|
};
|
74
|
-
|
75
62
|
const onClick = event => {
|
76
63
|
if (isTargetDisabled(event)) {
|
77
64
|
return;
|
78
65
|
}
|
79
|
-
|
80
66
|
if (!openOnContext) {
|
81
67
|
setOpen(event, {
|
82
68
|
open: !open,
|
@@ -87,14 +73,11 @@ const useMenuTrigger_unstable = props => {
|
|
87
73
|
openedWithKeyboardRef.current = false;
|
88
74
|
}
|
89
75
|
};
|
90
|
-
|
91
76
|
const onKeyDown = event => {
|
92
77
|
if (isTargetDisabled(event)) {
|
93
78
|
return;
|
94
79
|
}
|
95
|
-
|
96
80
|
const key = event.key;
|
97
|
-
|
98
81
|
if (!openOnContext && (isSubmenu && key === OpenArrowKey || !isSubmenu && key === keyboard_keys_1.ArrowDown)) {
|
99
82
|
setOpen(event, {
|
100
83
|
open: true,
|
@@ -103,7 +86,6 @@ const useMenuTrigger_unstable = props => {
|
|
103
86
|
event
|
104
87
|
});
|
105
88
|
}
|
106
|
-
|
107
89
|
if (key === keyboard_keys_1.Escape && !isSubmenu) {
|
108
90
|
setOpen(event, {
|
109
91
|
open: false,
|
@@ -111,19 +93,16 @@ const useMenuTrigger_unstable = props => {
|
|
111
93
|
type: 'menuTriggerKeyDown',
|
112
94
|
event
|
113
95
|
});
|
114
|
-
}
|
115
|
-
|
116
|
-
|
96
|
+
}
|
97
|
+
// if menu is already open, can't rely on effects to focus
|
117
98
|
if (open && key === OpenArrowKey && isSubmenu) {
|
118
99
|
focusFirst();
|
119
100
|
}
|
120
101
|
};
|
121
|
-
|
122
102
|
const onMouseEnter = event => {
|
123
103
|
if (isTargetDisabled(event)) {
|
124
104
|
return;
|
125
105
|
}
|
126
|
-
|
127
106
|
if (openOnHover && hasMouseMoved.current) {
|
128
107
|
setOpen(event, {
|
129
108
|
open: true,
|
@@ -132,16 +111,14 @@ const useMenuTrigger_unstable = props => {
|
|
132
111
|
event
|
133
112
|
});
|
134
113
|
}
|
135
|
-
};
|
114
|
+
};
|
115
|
+
// Opening a menu when a mouse hasn't moved and just entering the trigger is a bad a11y experience
|
136
116
|
// First time open the mouse using mousemove and then continue with mouseenter
|
137
117
|
// Only use once to determine that the user is using the mouse since it is an expensive event to handle
|
138
|
-
|
139
|
-
|
140
118
|
const onMouseMove = event => {
|
141
119
|
if (isTargetDisabled(event)) {
|
142
120
|
return;
|
143
121
|
}
|
144
|
-
|
145
122
|
if (openOnHover && !hasMouseMoved.current) {
|
146
123
|
setOpen(event, {
|
147
124
|
open: true,
|
@@ -152,12 +129,10 @@ const useMenuTrigger_unstable = props => {
|
|
152
129
|
hasMouseMoved.current = true;
|
153
130
|
}
|
154
131
|
};
|
155
|
-
|
156
132
|
const onMouseLeave = event => {
|
157
133
|
if (isTargetDisabled(event)) {
|
158
134
|
return;
|
159
135
|
}
|
160
|
-
|
161
136
|
if (openOnHover) {
|
162
137
|
setOpen(event, {
|
163
138
|
open: false,
|
@@ -167,7 +142,6 @@ const useMenuTrigger_unstable = props => {
|
|
167
142
|
});
|
168
143
|
}
|
169
144
|
};
|
170
|
-
|
171
145
|
const contextMenuProps = {
|
172
146
|
id: triggerId,
|
173
147
|
...(child === null || child === void 0 ? void 0 : child.props),
|
@@ -190,16 +164,12 @@ const useMenuTrigger_unstable = props => {
|
|
190
164
|
children: react_utilities_1.applyTriggerPropsToChildren(children, openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps)
|
191
165
|
};
|
192
166
|
};
|
193
|
-
|
194
167
|
exports.useMenuTrigger_unstable = useMenuTrigger_unstable;
|
195
|
-
|
196
168
|
const isTargetDisabled = e => {
|
197
169
|
const isDisabled = el => el.hasAttribute('disabled') || el.hasAttribute('aria-disabled') && el.getAttribute('aria-disabled') === 'true';
|
198
|
-
|
199
170
|
if (e.target instanceof HTMLElement && isDisabled(e.target)) {
|
200
171
|
return true;
|
201
172
|
}
|
202
|
-
|
203
173
|
return e.currentTarget instanceof HTMLElement && isDisabled(e.currentTarget);
|
204
174
|
};
|
205
175
|
//# sourceMappingURL=useMenuTrigger.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-menu/src/components/MenuTrigger/useMenuTrigger.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,aAAA,gBAAA,OAAA,CAAA,4BAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,0BAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAOA,MAAA,YAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAEA;;;;;AAKG;;;AACI,MAAM,uBAAuB,GAAI,KAAD,IAA8C;EACnF,MAAM;IAAE,QAAF;IAAY,wBAAwB,GA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AmC,UAAU,CAAC,CAAC,CAAC,MAAH,CAAjD,EAA6D;IAC3D,OAAO,IAAP;EACD;;EAED,OAAO,CAAC,CAAC,aAAF,YAA2B,WAA3B,IAA0C,UAAU,CAAC,CAAC,CAAC,aAAH,CAA3D;AACD,CARD","sourcesContent":["import * as React from 'react';\nimport { MenuTriggerProps, MenuTriggerState } from './MenuTrigger.types';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { ArrowRight, ArrowLeft, Escape, ArrowDown } from '@fluentui/keyboard-keys';\nimport {\n applyTriggerPropsToChildren,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\n\n/**\n * Create the state required to render MenuTrigger.\n * Clones the only child component and adds necessary event handling behaviours to open a popup menu\n *\n * @param props - props from this instance of MenuTrigger\n */\nexport const useMenuTrigger_unstable = (props: MenuTriggerProps): MenuTriggerState => {\n const { children, disableButtonEnhancement = false } = props;\n\n const triggerRef = useMenuContext_unstable(context => context.triggerRef);\n const menuPopoverRef = useMenuContext_unstable(context => context.menuPopoverRef);\n const setOpen = useMenuContext_unstable(context => context.setOpen);\n const open = useMenuContext_unstable(context => context.open);\n const triggerId = useMenuContext_unstable(context => context.triggerId);\n const openOnHover = useMenuContext_unstable(context => context.openOnHover);\n const openOnContext = useMenuContext_unstable(context => context.openOnContext);\n\n const isSubmenu = useIsSubmenu();\n\n const { findFirstFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(menuPopoverRef.current);\n firstFocusable?.focus();\n }, [findFirstFocusable, menuPopoverRef]);\n\n const openedWithKeyboardRef = React.useRef(false);\n const hasMouseMoved = React.useRef(false);\n\n const { dir } = useFluent();\n const OpenArrowKey = dir === 'ltr' ? ArrowRight : ArrowLeft;\n\n const child = getTriggerChild(children);\n\n const onContextMenu = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n\n if (openOnContext) {\n event.preventDefault();\n setOpen(event, { open: true, keyboard: false, type: 'menuTriggerContextMenu', event });\n }\n };\n\n const onClick = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n\n if (!openOnContext) {\n setOpen(event, { open: !open, keyboard: openedWithKeyboardRef.current, type: 'menuTriggerClick', event });\n openedWithKeyboardRef.current = false;\n }\n };\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n\n const key = event.key;\n\n if (!openOnContext && ((isSubmenu && key === OpenArrowKey) || (!isSubmenu && key === ArrowDown))) {\n setOpen(event, { open: true, keyboard: true, type: 'menuTriggerKeyDown', event });\n }\n\n if (key === Escape && !isSubmenu) {\n setOpen(event, { open: false, keyboard: true, type: 'menuTriggerKeyDown', event });\n }\n\n // if menu is already open, can't rely on effects to focus\n if (open && key === OpenArrowKey && isSubmenu) {\n focusFirst();\n }\n };\n\n const onMouseEnter = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover && hasMouseMoved.current) {\n setOpen(event, { open: true, keyboard: false, type: 'menuTriggerMouseEnter', event });\n }\n };\n\n // Opening a menu when a mouse hasn't moved and just entering the trigger is a bad a11y experience\n // First time open the mouse using mousemove and then continue with mouseenter\n // Only use once to determine that the user is using the mouse since it is an expensive event to handle\n const onMouseMove = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover && !hasMouseMoved.current) {\n setOpen(event, { open: true, keyboard: false, type: 'menuTriggerMouseMove', event });\n hasMouseMoved.current = true;\n }\n };\n\n const onMouseLeave = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover) {\n setOpen(event, { open: false, keyboard: false, type: 'menuTriggerMouseLeave', event });\n }\n };\n\n const contextMenuProps = {\n id: triggerId,\n ...child?.props,\n ref: useMergedRefs(triggerRef, child?.ref),\n onMouseEnter: useEventCallback(mergeCallbacks(child?.props.onMouseEnter, onMouseEnter)),\n onMouseLeave: useEventCallback(mergeCallbacks(child?.props.onMouseLeave, onMouseLeave)),\n onContextMenu: useEventCallback(mergeCallbacks(child?.props.onContextMenu, onContextMenu)),\n onMouseMove: useEventCallback(mergeCallbacks(child?.props.onMouseMove, onMouseMove)),\n };\n\n const triggerChildProps = {\n 'aria-haspopup': 'menu',\n 'aria-expanded': !open && !isSubmenu ? undefined : open,\n ...contextMenuProps,\n onClick: useEventCallback(mergeCallbacks(child?.props.onClick, onClick)),\n onKeyDown: useEventCallback(mergeCallbacks(child?.props.onKeyDown, onKeyDown)),\n } as const;\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n triggerChildProps,\n );\n\n return {\n isSubmenu,\n children: applyTriggerPropsToChildren(\n children,\n openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n };\n};\n\nconst isTargetDisabled = (e: React.SyntheticEvent | Event) => {\n const isDisabled = (el: HTMLElement) =>\n el.hasAttribute('disabled') || (el.hasAttribute('aria-disabled') && el.getAttribute('aria-disabled') === 'true');\n if (e.target instanceof HTMLElement && isDisabled(e.target)) {\n return true;\n }\n\n return e.currentTarget instanceof HTMLElement && isDisabled(e.currentTarget);\n};\n"],"sourceRoot":"../src/"}
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AACA;AAC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uBAALA,KAAK,CAAEO,IAAI,MAAK,GAAG,GAAGP,KAAK,CAACO,IAAI,GAAG,KAAK,EACpEU,iBAAiB,CAClB;EAED,OAAO;IACLlC,SAAS;IACTX,QAAQ,EAAE6B,6CAA2B,CACnC7B,QAAQ,EACRU,aAAa,GAAGgC,gBAAgB,GAAGzC,wBAAwB,GAAG4C,iBAAiB,GAAGE,2BAA2B;GAEhH;AACH,CAAC;AAnIYE,+BAAuB;AAqIpC,MAAMjB,gBAAgB,GAAIkB,CAA+B,IAAI;EAC3D,MAAMC,UAAU,GAAIC,EAAe,IACjCA,EAAE,CAACC,YAAY,CAAC,UAAU,CAAC,IAAKD,EAAE,CAACC,YAAY,CAAC,eAAe,CAAC,IAAID,EAAE,CAACE,YAAY,CAAC,eAAe,CAAC,KAAK,MAAO;EAClH,IAAIJ,CAAC,CAACK,MAAM,YAAYC,WAAW,IAAIL,UAAU,CAACD,CAAC,CAACK,MAAM,CAAC,EAAE;IAC3D,OAAO,IAAI;;EAGb,OAAOL,CAAC,CAACO,aAAa,YAAYD,WAAW,IAAIL,UAAU,CAACD,CAAC,CAACO,aAAa,CAAC;AAC9E,CAAC","names":["useMenuTrigger_unstable","props","children","disableButtonEnhancement","triggerRef","menuContext_1","context","menuPopoverRef","setOpen","open","triggerId","openOnHover","openOnContext","isSubmenu","useIsSubmenu_1","findFirstFocusable","react_tabster_1","focusFirst","React","useCallback","firstFocusable","current","focus","openedWithKeyboardRef","useRef","hasMouseMoved","dir","react_shared_contexts_1","OpenArrowKey","keyboard_keys_1","child","react_utilities_1","onContextMenu","event","isTargetDisabled","preventDefault","keyboard","type","onClick","onKeyDown","key","onMouseEnter","onMouseMove","onMouseLeave","contextMenuProps","id","ref","triggerChildProps","undefined","ariaButtonTriggerChildProps","react_aria_1","exports","e","isDisabled","el","hasAttribute","getAttribute","target","HTMLElement","currentTarget"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuTrigger/useMenuTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport { MenuTriggerProps, MenuTriggerState } from './MenuTrigger.types';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { ArrowRight, ArrowLeft, Escape, ArrowDown } from '@fluentui/keyboard-keys';\nimport {\n applyTriggerPropsToChildren,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\n\n/**\n * Create the state required to render MenuTrigger.\n * Clones the only child component and adds necessary event handling behaviours to open a popup menu\n *\n * @param props - props from this instance of MenuTrigger\n */\nexport const useMenuTrigger_unstable = (props: MenuTriggerProps): MenuTriggerState => {\n const { children, disableButtonEnhancement = false } = props;\n\n const triggerRef = useMenuContext_unstable(context => context.triggerRef);\n const menuPopoverRef = useMenuContext_unstable(context => context.menuPopoverRef);\n const setOpen = useMenuContext_unstable(context => context.setOpen);\n const open = useMenuContext_unstable(context => context.open);\n const triggerId = useMenuContext_unstable(context => context.triggerId);\n const openOnHover = useMenuContext_unstable(context => context.openOnHover);\n const openOnContext = useMenuContext_unstable(context => context.openOnContext);\n\n const isSubmenu = useIsSubmenu();\n\n const { findFirstFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(menuPopoverRef.current);\n firstFocusable?.focus();\n }, [findFirstFocusable, menuPopoverRef]);\n\n const openedWithKeyboardRef = React.useRef(false);\n const hasMouseMoved = React.useRef(false);\n\n const { dir } = useFluent();\n const OpenArrowKey = dir === 'ltr' ? ArrowRight : ArrowLeft;\n\n const child = getTriggerChild(children);\n\n const onContextMenu = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n\n if (openOnContext) {\n event.preventDefault();\n setOpen(event, { open: true, keyboard: false, type: 'menuTriggerContextMenu', event });\n }\n };\n\n const onClick = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n\n if (!openOnContext) {\n setOpen(event, { open: !open, keyboard: openedWithKeyboardRef.current, type: 'menuTriggerClick', event });\n openedWithKeyboardRef.current = false;\n }\n };\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n\n const key = event.key;\n\n if (!openOnContext && ((isSubmenu && key === OpenArrowKey) || (!isSubmenu && key === ArrowDown))) {\n setOpen(event, { open: true, keyboard: true, type: 'menuTriggerKeyDown', event });\n }\n\n if (key === Escape && !isSubmenu) {\n setOpen(event, { open: false, keyboard: true, type: 'menuTriggerKeyDown', event });\n }\n\n // if menu is already open, can't rely on effects to focus\n if (open && key === OpenArrowKey && isSubmenu) {\n focusFirst();\n }\n };\n\n const onMouseEnter = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover && hasMouseMoved.current) {\n setOpen(event, { open: true, keyboard: false, type: 'menuTriggerMouseEnter', event });\n }\n };\n\n // Opening a menu when a mouse hasn't moved and just entering the trigger is a bad a11y experience\n // First time open the mouse using mousemove and then continue with mouseenter\n // Only use once to determine that the user is using the mouse since it is an expensive event to handle\n const onMouseMove = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover && !hasMouseMoved.current) {\n setOpen(event, { open: true, keyboard: false, type: 'menuTriggerMouseMove', event });\n hasMouseMoved.current = true;\n }\n };\n\n const onMouseLeave = (event: React.MouseEvent<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>) => {\n if (isTargetDisabled(event)) {\n return;\n }\n if (openOnHover) {\n setOpen(event, { open: false, keyboard: false, type: 'menuTriggerMouseLeave', event });\n }\n };\n\n const contextMenuProps = {\n id: triggerId,\n ...child?.props,\n ref: useMergedRefs(triggerRef, child?.ref),\n onMouseEnter: useEventCallback(mergeCallbacks(child?.props.onMouseEnter, onMouseEnter)),\n onMouseLeave: useEventCallback(mergeCallbacks(child?.props.onMouseLeave, onMouseLeave)),\n onContextMenu: useEventCallback(mergeCallbacks(child?.props.onContextMenu, onContextMenu)),\n onMouseMove: useEventCallback(mergeCallbacks(child?.props.onMouseMove, onMouseMove)),\n };\n\n const triggerChildProps = {\n 'aria-haspopup': 'menu',\n 'aria-expanded': !open && !isSubmenu ? undefined : open,\n ...contextMenuProps,\n onClick: useEventCallback(mergeCallbacks(child?.props.onClick, onClick)),\n onKeyDown: useEventCallback(mergeCallbacks(child?.props.onKeyDown, onKeyDown)),\n } as const;\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n triggerChildProps,\n );\n\n return {\n isSubmenu,\n children: applyTriggerPropsToChildren(\n children,\n openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n };\n};\n\nconst isTargetDisabled = (e: React.SyntheticEvent | Event) => {\n const isDisabled = (el: HTMLElement) =>\n el.hasAttribute('disabled') || (el.hasAttribute('aria-disabled') && el.getAttribute('aria-disabled') === 'true');\n if (e.target instanceof HTMLElement && isDisabled(e.target)) {\n return true;\n }\n\n return e.currentTarget instanceof HTMLElement && isDisabled(e.currentTarget);\n};\n"]}
|
@@ -3,10 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
-
|
9
7
|
tslib_1.__exportStar(require("./MenuItem/index"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./MenuList/index"), exports);
|
12
9
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-menu/src/components/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/index.ts"],"sourcesContent":["export * from './MenuItem/index';\nexport * from './MenuList/index';\n"]}
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.useMenuContext_unstable = exports.MenuProvider = exports.MenuContext = void 0;
|
7
|
-
|
8
7
|
const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
|
9
|
-
|
10
8
|
exports.MenuContext = /*#__PURE__*/react_context_selector_1.createContext(undefined);
|
11
9
|
const menuContextDefaultValue = {
|
12
10
|
open: false,
|
@@ -29,8 +27,6 @@ const menuContextDefaultValue = {
|
|
29
27
|
persistOnItemClick: false
|
30
28
|
};
|
31
29
|
exports.MenuProvider = exports.MenuContext.Provider;
|
32
|
-
|
33
30
|
const useMenuContext_unstable = selector => react_context_selector_1.useContextSelector(exports.MenuContext, (ctx = menuContextDefaultValue) => selector(ctx));
|
34
|
-
|
35
31
|
exports.useMenuContext_unstable = useMenuContext_unstable;
|
36
32
|
//# sourceMappingURL=menuContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AACA;AAIaA,mBAAW,gBAA8BC,sCAAa,CACjEC,SAAS,CACmB;AAE9B,MAAMC,uBAAuB,GAAqB;EAChDC,IAAI,EAAE,KAAK;EACXC,OAAO,EAAE,MAAM,KAAK;EACpBC,aAAa,EAAE,EAAE;EACjBC,oBAAoB,EAAE,MAAM,IAAI;EAChCC,SAAS,EAAE,KAAK;EAChBC,UAAU,EAAG;IAAEC,OAAO,EAAE;EAAI,CAAqD;EACjFC,cAAc,EAAG;IAAED,OAAO,EAAE;EAAI,CAAqD;EACrFE,SAAS,EAAE,EAAE;EACbC,aAAa,EAAE,KAAK;EACpBC,WAAW,EAAE,KAAK;EAClBC,QAAQ,EAAE,KAAK;EACfC,aAAa,EAAE,KAAK;EACpBC,MAAM,EAAE,KAAK;EACbC,kBAAkB,EAAE;CACrB;AAiCYlB,oBAAY,GAAGA,mBAAW,CAACmB,QAAQ;AAEzC,MAAMC,uBAAuB,GAAOC,QAA8C,IACvFpB,2CAAkB,CAACD,mBAAW,EAAE,CAACsB,GAAG,GAAGnB,uBAAuB,KAAKkB,QAAQ,CAACC,GAAG,CAAC,CAAC;AADtEtB,+BAAuB","names":["exports","react_context_selector_1","undefined","menuContextDefaultValue","open","setOpen","checkedValues","onCheckedValueChange","isSubmenu","triggerRef","current","menuPopoverRef","triggerId","openOnContext","openOnHover","hasIcons","hasCheckmarks","inline","persistOnItemClick","Provider","useMenuContext_unstable","selector","ctx"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/contexts/menuContext.ts"],"sourcesContent":["import * as React from 'react';\nimport { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { ContextSelector, Context } from '@fluentui/react-context-selector';\nimport type { MenuState } from '../components/Menu/index';\n\nexport const MenuContext: Context<MenuContextValue> = createContext<MenuContextValue | undefined>(\n undefined,\n) as Context<MenuContextValue>;\n\nconst menuContextDefaultValue: MenuContextValue = {\n open: false,\n setOpen: () => false,\n checkedValues: {},\n onCheckedValueChange: () => null,\n isSubmenu: false,\n triggerRef: ({ current: null } as unknown) as React.MutableRefObject<HTMLElement>,\n menuPopoverRef: ({ current: null } as unknown) as React.MutableRefObject<HTMLElement>,\n triggerId: '',\n openOnContext: false,\n openOnHover: false,\n hasIcons: false,\n hasCheckmarks: false,\n inline: false,\n persistOnItemClick: false,\n};\n\n/**\n * Context shared between Menu and its children components\n *\n * Extends and drills down MenuList props to simplify API\n */\nexport type MenuContextValue = Pick<\n MenuState,\n | 'openOnHover'\n | 'openOnContext'\n | 'triggerRef'\n | 'menuPopoverRef'\n | 'setOpen'\n | 'isSubmenu'\n | 'triggerId'\n | 'hasIcons'\n | 'hasCheckmarks'\n | 'persistOnItemClick'\n | 'inline'\n | 'checkedValues'\n | 'onCheckedValueChange'\n> & {\n open: boolean;\n triggerId: string;\n /**\n * Default values to be checked on mount\n * @deprecated this property is not used internally anymore,\n * the signature remains just to avoid breaking changes\n */\n defaultCheckedValues?: Record<string, string[]>;\n};\n\nexport const MenuProvider = MenuContext.Provider;\n\nexport const useMenuContext_unstable = <T>(selector: ContextSelector<MenuContextValue, T>) =>\n useContextSelector(MenuContext, (ctx = menuContextDefaultValue) => selector(ctx));\n"]}
|
@@ -4,20 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.useMenuGroupContext_unstable = exports.MenuGroupContextProvider = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const MenuGroupContext = /*#__PURE__*/React.createContext(undefined);
|
11
9
|
const menuGroupContextDefaultValue = {
|
12
10
|
headerId: ''
|
13
11
|
};
|
14
12
|
exports.MenuGroupContextProvider = MenuGroupContext.Provider;
|
15
|
-
|
16
13
|
const useMenuGroupContext_unstable = () => {
|
17
14
|
var _a;
|
18
|
-
|
19
15
|
return (_a = React.useContext(MenuGroupContext)) !== null && _a !== void 0 ? _a : menuGroupContextDefaultValue;
|
20
16
|
};
|
21
|
-
|
22
17
|
exports.useMenuGroupContext_unstable = useMenuGroupContext_unstable;
|
23
18
|
//# sourceMappingURL=menuGroupContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA,MAAMA,gBAAgB,gBAAGC,KAAK,CAACC,aAAa,CAC1CC,SAAS,CAC8B;AAEzC,MAAMC,4BAA4B,GAA0B;EAC1DC,QAAQ,EAAE;CACX;AAaYC,gCAAwB,GAAGN,gBAAgB,CAACO,QAAQ;AAC1D,MAAMC,4BAA4B,GAAG,MAAK;EAAA;EAAC,kBAAK,CAACC,UAAU,CAACT,gBAAgB,CAAC,mCAAII,4BAA4B;AAAA;AAAvGE,oCAA4B","names":["MenuGroupContext","React","createContext","undefined","menuGroupContextDefaultValue","headerId","exports","Provider","useMenuGroupContext_unstable","useContext"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/contexts/menuGroupContext.ts"],"sourcesContent":["import * as React from 'react';\n\nconst MenuGroupContext = React.createContext<MenuGroupContextValue | undefined>(\n undefined,\n) as React.Context<MenuGroupContextValue>;\n\nconst menuGroupContextDefaultValue: MenuGroupContextValue = {\n headerId: '',\n};\n\n/**\n * Context used to guarantee correct aria-relationship between header\n * and group information\n */\nexport type MenuGroupContextValue = {\n /**\n * Element id applied to the `MenuGroupHeader` component\n */\n headerId: string;\n};\n\nexport const MenuGroupContextProvider = MenuGroupContext.Provider;\nexport const useMenuGroupContext_unstable = () => React.useContext(MenuGroupContext) ?? menuGroupContextDefaultValue;\n"]}
|