@fluentui/react-menu 9.0.0-beta.1 → 9.0.0-beta.5
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +307 -1
- package/CHANGELOG.md +74 -2
- package/dist/react-menu.d.ts +34 -7
- package/lib/components/Menu/Menu.js +3 -3
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/Menu.types.d.ts +2 -1
- package/lib/components/Menu/renderMenu.js +1 -1
- package/lib/components/Menu/renderMenu.js.map +1 -1
- package/lib/components/Menu/useMenu.js +95 -112
- package/lib/components/Menu/useMenu.js.map +1 -1
- package/lib/components/Menu/useMenuContextValues.js +34 -32
- package/lib/components/Menu/useMenuContextValues.js.map +1 -1
- package/lib/components/MenuDivider/MenuDivider.js +2 -2
- package/lib/components/MenuDivider/MenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/renderMenuDivider.js +6 -7
- package/lib/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDivider.js +6 -7
- package/lib/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDividerStyles.d.ts +1 -0
- package/lib/components/MenuDivider/useMenuDividerStyles.js +5 -4
- package/lib/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib/components/MenuGroup/MenuGroup.js +5 -3
- package/lib/components/MenuGroup/MenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/index.d.ts +1 -0
- package/lib/components/MenuGroup/index.js +1 -0
- package/lib/components/MenuGroup/index.js.map +1 -1
- package/lib/components/MenuGroup/renderMenuGroup.js +6 -7
- package/lib/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroup.js +6 -6
- package/lib/components/MenuGroup/useMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroupContextValues.js +7 -7
- package/lib/components/MenuGroup/useMenuGroupContextValues.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroupStyles.d.ts +3 -0
- package/lib/components/MenuGroup/useMenuGroupStyles.js +7 -0
- package/lib/components/MenuGroup/useMenuGroupStyles.js.map +1 -0
- package/lib/components/MenuGroupHeader/MenuGroupHeader.js +2 -2
- package/lib/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js +6 -7
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js +8 -6
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.d.ts +1 -0
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +5 -4
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib/components/MenuItem/MenuItem.js +2 -2
- package/lib/components/MenuItem/MenuItem.js.map +1 -1
- package/lib/components/MenuItem/renderMenuItem.js +6 -7
- package/lib/components/MenuItem/renderMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useCharacterSearch.js +6 -6
- package/lib/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib/components/MenuItem/useMenuItem.js +31 -36
- package/lib/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useMenuItemStyles.d.ts +1 -0
- package/lib/components/MenuItem/useMenuItemStyles.js +5 -4
- package/lib/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.js +4 -4
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/index.d.ts +1 -0
- package/lib/components/MenuItemCheckbox/index.js +1 -0
- package/lib/components/MenuItemCheckbox/index.js.map +1 -1
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js +6 -7
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js +12 -13
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.d.ts +2 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +4 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib/components/MenuItemRadio/MenuItemRadio.js +2 -2
- package/lib/components/MenuItemRadio/MenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/index.d.ts +1 -0
- package/lib/components/MenuItemRadio/index.js +1 -0
- package/lib/components/MenuItemRadio/index.js.map +1 -1
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js +6 -7
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadio.js +12 -12
- package/lib/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.d.ts +1 -0
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js +4 -1
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib/components/MenuList/MenuList.js +3 -3
- package/lib/components/MenuList/MenuList.js.map +1 -1
- package/lib/components/MenuList/MenuList.types.d.ts +8 -6
- package/lib/components/MenuList/renderMenuList.js +6 -7
- package/lib/components/MenuList/renderMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuList.js +66 -86
- package/lib/components/MenuList/useMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuListContextValues.js +18 -16
- package/lib/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib/components/MenuList/useMenuListStyles.d.ts +1 -0
- package/lib/components/MenuList/useMenuListStyles.js +5 -4
- package/lib/components/MenuList/useMenuListStyles.js.map +1 -1
- package/lib/components/MenuPopover/MenuPopover.js +2 -2
- package/lib/components/MenuPopover/MenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/renderMenuPopover.js +7 -7
- package/lib/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopover.js +29 -38
- package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopoverStyles.d.ts +1 -0
- package/lib/components/MenuPopover/useMenuPopoverStyles.js +7 -6
- package/lib/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib/components/MenuTrigger/MenuTrigger.js +2 -2
- package/lib/components/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/renderMenuTrigger.js +1 -1
- package/lib/components/MenuTrigger/renderMenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/useMenuTrigger.js +3 -4
- package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/useTriggerElement.js +51 -65
- package/lib/components/MenuTrigger/useTriggerElement.js.map +1 -1
- package/lib/contexts/menuContext.js +5 -11
- package/lib/contexts/menuContext.js.map +1 -1
- package/lib/contexts/menuGroupContext.js +3 -5
- package/lib/contexts/menuGroupContext.js.map +1 -1
- package/lib/contexts/menuListContext.js +7 -17
- package/lib/contexts/menuListContext.js.map +1 -1
- package/lib/contexts/menuTriggerContext.js +3 -5
- package/lib/contexts/menuTriggerContext.js.map +1 -1
- package/lib/selectable/useCheckmarkStyles.js +3 -3
- package/lib/selectable/useCheckmarkStyles.js.map +1 -1
- package/lib/utils/useIsSubmenu.js +2 -4
- package/lib/utils/useIsSubmenu.js.map +1 -1
- package/lib/utils/useOnMenuEnter.js +16 -14
- package/lib/utils/useOnMenuEnter.js.map +1 -1
- package/lib-commonjs/Menu.js +1 -1
- package/lib-commonjs/MenuDivider.js +1 -1
- package/lib-commonjs/MenuGroup.js +1 -1
- package/lib-commonjs/MenuGroupHeader.js +1 -1
- package/lib-commonjs/MenuItem.js +1 -1
- package/lib-commonjs/MenuItemCheckbox.js +1 -1
- package/lib-commonjs/MenuItemRadio.js +1 -1
- package/lib-commonjs/MenuList.js +1 -1
- package/lib-commonjs/MenuPopover.js +1 -1
- package/lib-commonjs/MenuTrigger.js +1 -1
- package/lib-commonjs/components/Menu/Menu.js +6 -6
- package/lib-commonjs/components/Menu/Menu.js.map +1 -1
- package/lib-commonjs/components/Menu/Menu.types.d.ts +2 -1
- package/lib-commonjs/components/Menu/index.js +1 -1
- package/lib-commonjs/components/Menu/renderMenu.js +3 -3
- package/lib-commonjs/components/Menu/renderMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenu.js +104 -122
- package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenuContextValues.js +34 -32
- package/lib-commonjs/components/Menu/useMenuContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/MenuDivider.js +6 -6
- package/lib-commonjs/components/MenuDivider/MenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/index.js +1 -1
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.js +8 -10
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/useMenuDivider.js +7 -9
- package/lib-commonjs/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.d.ts +1 -0
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js +8 -6
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/MenuGroup.js +10 -7
- package/lib-commonjs/components/MenuGroup/MenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/index.d.ts +1 -0
- package/lib-commonjs/components/MenuGroup/index.js +3 -1
- package/lib-commonjs/components/MenuGroup/index.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.js +9 -11
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroup.js +7 -8
- package/lib-commonjs/components/MenuGroup/useMenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.js +8 -8
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.d.ts +3 -0
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js +18 -0
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js.map +1 -0
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.js +6 -6
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/index.js +1 -1
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.js +8 -10
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.js +10 -9
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.d.ts +1 -0
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +8 -6
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItem/MenuItem.js +7 -7
- package/lib-commonjs/components/MenuItem/MenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/index.js +1 -1
- package/lib-commonjs/components/MenuItem/renderMenuItem.js +9 -11
- package/lib-commonjs/components/MenuItem/renderMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js +7 -7
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItem.js +38 -44
- package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.d.ts +1 -0
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js +9 -7
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.js +7 -7
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/index.d.ts +1 -0
- package/lib-commonjs/components/MenuItemCheckbox/index.js +3 -1
- package/lib-commonjs/components/MenuItemCheckbox/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.js +9 -11
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js +17 -19
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.d.ts +2 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +10 -5
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.js +6 -6
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/index.d.ts +1 -0
- package/lib-commonjs/components/MenuItemRadio/index.js +3 -1
- package/lib-commonjs/components/MenuItemRadio/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.js +9 -11
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js +17 -18
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.d.ts +1 -0
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js +9 -4
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib-commonjs/components/MenuList/MenuList.js +8 -8
- package/lib-commonjs/components/MenuList/MenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/MenuList.types.d.ts +8 -6
- package/lib-commonjs/components/MenuList/index.js +1 -1
- package/lib-commonjs/components/MenuList/renderMenuList.js +9 -11
- package/lib-commonjs/components/MenuList/renderMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuList.js +72 -93
- package/lib-commonjs/components/MenuList/useMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListContextValues.js +18 -16
- package/lib-commonjs/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListStyles.d.ts +1 -0
- package/lib-commonjs/components/MenuList/useMenuListStyles.js +8 -6
- package/lib-commonjs/components/MenuList/useMenuListStyles.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/MenuPopover.js +6 -6
- package/lib-commonjs/components/MenuPopover/MenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/index.js +1 -1
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.js +10 -11
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js +36 -46
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.d.ts +1 -0
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js +10 -8
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.js +4 -4
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/index.js +1 -1
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.js +3 -3
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +4 -6
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/useTriggerElement.js +58 -73
- package/lib-commonjs/components/MenuTrigger/useTriggerElement.js.map +1 -1
- package/lib-commonjs/components/index.js +1 -1
- package/lib-commonjs/contexts/menuContext.js +4 -10
- package/lib-commonjs/contexts/menuContext.js.map +1 -1
- package/lib-commonjs/contexts/menuGroupContext.js +3 -5
- package/lib-commonjs/contexts/menuGroupContext.js.map +1 -1
- package/lib-commonjs/contexts/menuListContext.js +6 -16
- package/lib-commonjs/contexts/menuListContext.js.map +1 -1
- package/lib-commonjs/contexts/menuTriggerContext.js +3 -5
- package/lib-commonjs/contexts/menuTriggerContext.js.map +1 -1
- package/lib-commonjs/index.js +1 -1
- package/lib-commonjs/selectable/index.js +1 -1
- package/lib-commonjs/selectable/useCheckmarkStyles.js +4 -4
- package/lib-commonjs/selectable/useCheckmarkStyles.js.map +1 -1
- package/lib-commonjs/utils/index.js +1 -1
- package/lib-commonjs/utils/useIsSubmenu.js +5 -7
- package/lib-commonjs/utils/useIsSubmenu.js.map +1 -1
- package/lib-commonjs/utils/useOnMenuEnter.js +18 -16
- package/lib-commonjs/utils/useOnMenuEnter.js.map +1 -1
- package/package.json +15 -15
- package/lib/common/isConformant.d.ts +0 -4
- package/lib/common/isConformant.js +0 -12
- package/lib/common/isConformant.js.map +0 -1
- package/lib/common/mockUseMenuContext.d.ts +0 -7
- package/lib/common/mockUseMenuContext.js +0 -36
- package/lib/common/mockUseMenuContext.js.map +0 -1
- package/lib/utils/DefaultIcons.d.ts +0 -7
- package/lib/utils/DefaultIcons.js +0 -88
- package/lib/utils/DefaultIcons.js.map +0 -1
- package/lib-commonjs/common/isConformant.d.ts +0 -4
- package/lib-commonjs/common/isConformant.js +0 -23
- package/lib-commonjs/common/isConformant.js.map +0 -1
- package/lib-commonjs/common/mockUseMenuContext.d.ts +0 -7
- package/lib-commonjs/common/mockUseMenuContext.js +0 -47
- package/lib-commonjs/common/mockUseMenuContext.js.map +0 -1
- package/lib-commonjs/utils/DefaultIcons.d.ts +0 -7
- package/lib-commonjs/utils/DefaultIcons.js +0 -100
- package/lib-commonjs/utils/DefaultIcons.js.map +0 -1
@@ -1,8 +1,7 @@
|
|
1
|
-
import { __assign } from "tslib";
|
2
1
|
import * as React from 'react';
|
3
2
|
import { usePopperMouseTarget, usePopper, resolvePositioningShorthand } from '@fluentui/react-positioning';
|
4
3
|
import { useControllableState, useId, useOnClickOutside, useEventCallback } from '@fluentui/react-utilities';
|
5
|
-
import { useFluent } from '@fluentui/react-
|
4
|
+
import { useFluent } from '@fluentui/react-shared-contexts';
|
6
5
|
import { elementContains } from '@fluentui/react-portal';
|
7
6
|
import { useFocusFinders } from '@fluentui/react-tabster';
|
8
7
|
import { MenuTrigger } from '../MenuTrigger/index';
|
@@ -18,28 +17,27 @@ import { useIsSubmenu } from '../../utils/useIsSubmenu';
|
|
18
17
|
* @param props - props from this instance of Menu
|
19
18
|
*/
|
20
19
|
|
21
|
-
export
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
contextTarget = _a[0],
|
27
|
-
setContextTarget = _a[1];
|
28
|
-
|
29
|
-
var popperState = __assign({
|
20
|
+
export const useMenu = props => {
|
21
|
+
const triggerId = useId('menu');
|
22
|
+
const isSubmenu = useIsSubmenu();
|
23
|
+
const [contextTarget, setContextTarget] = usePopperMouseTarget();
|
24
|
+
const popperState = {
|
30
25
|
position: isSubmenu ? 'after' : 'below',
|
31
26
|
align: isSubmenu ? 'top' : 'start',
|
32
|
-
target: props.openOnContext ? contextTarget : undefined
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
target: props.openOnContext ? contextTarget : undefined,
|
28
|
+
...resolvePositioningShorthand(props.positioning)
|
29
|
+
};
|
30
|
+
const children = React.Children.toArray(props.children);
|
36
31
|
|
37
32
|
if (children.length !== 2 && process.env.NODE_ENV !== 'production') {
|
38
33
|
// eslint-disable-next-line no-console
|
39
34
|
console.warn('Menu can only take one MenuTrigger and one MenuList as children');
|
40
35
|
}
|
41
36
|
|
42
|
-
|
37
|
+
const {
|
38
|
+
menuTrigger,
|
39
|
+
menuPopover
|
40
|
+
} = children.reduce((acc, child) => {
|
43
41
|
if (child.type === MenuTrigger) {
|
44
42
|
acc.menuTrigger = child;
|
45
43
|
} else {
|
@@ -47,106 +45,94 @@ export var useMenu = function (props) {
|
|
47
45
|
}
|
48
46
|
|
49
47
|
return acc;
|
50
|
-
}, {})
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
menuPopoverRef = _c.containerRef;
|
57
|
-
|
58
|
-
var initialState = __assign(__assign({
|
48
|
+
}, {});
|
49
|
+
const {
|
50
|
+
targetRef: triggerRef,
|
51
|
+
containerRef: menuPopoverRef
|
52
|
+
} = usePopper(popperState);
|
53
|
+
const initialState = {
|
59
54
|
hoverDelay: 500,
|
60
|
-
triggerId
|
55
|
+
triggerId,
|
61
56
|
isSubmenu: !!isSubmenu,
|
62
57
|
openOnHover: !!isSubmenu,
|
63
|
-
contextTarget
|
64
|
-
setContextTarget
|
65
|
-
|
66
|
-
menuTrigger
|
67
|
-
menuPopover
|
68
|
-
triggerRef
|
69
|
-
menuPopoverRef
|
70
|
-
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
return __assign(__assign({}, initialState), {
|
82
|
-
open: open,
|
83
|
-
setOpen: setOpen,
|
84
|
-
checkedValues: checkedValues,
|
85
|
-
onCheckedValueChange: onCheckedValueChange
|
86
|
-
});
|
58
|
+
contextTarget,
|
59
|
+
setContextTarget,
|
60
|
+
...props,
|
61
|
+
menuTrigger,
|
62
|
+
menuPopover,
|
63
|
+
triggerRef,
|
64
|
+
menuPopoverRef
|
65
|
+
}; // TODO Better way to narrow types ?
|
66
|
+
|
67
|
+
const [open, setOpen] = useMenuOpenState(initialState);
|
68
|
+
const [checkedValues, onCheckedValueChange] = useMenuSelectableState(initialState);
|
69
|
+
return { ...initialState,
|
70
|
+
open,
|
71
|
+
setOpen,
|
72
|
+
checkedValues,
|
73
|
+
onCheckedValueChange
|
74
|
+
};
|
87
75
|
};
|
88
76
|
/**
|
89
77
|
* Adds appropriate state values and handlers for selectable items
|
90
78
|
* i.e checkboxes and radios
|
91
79
|
*/
|
92
80
|
|
93
|
-
|
94
|
-
|
81
|
+
const useMenuSelectableState = state => {
|
82
|
+
const [checkedValues, setCheckedValues] = useControllableState({
|
95
83
|
state: state.checkedValues,
|
96
84
|
defaultState: state.defaultCheckedValues,
|
97
85
|
initialState: {}
|
98
|
-
})
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
86
|
+
});
|
87
|
+
const {
|
88
|
+
onCheckedValueChange: onCheckedValueChangeOriginal
|
89
|
+
} = state;
|
90
|
+
const onCheckedValueChange = useEventCallback((e, {
|
91
|
+
name,
|
92
|
+
checkedItems
|
93
|
+
}) => {
|
107
94
|
if (onCheckedValueChangeOriginal) {
|
108
95
|
onCheckedValueChangeOriginal(e, {
|
109
|
-
name
|
110
|
-
checkedItems
|
96
|
+
name,
|
97
|
+
checkedItems
|
111
98
|
});
|
112
99
|
}
|
113
100
|
|
114
|
-
setCheckedValues(
|
115
|
-
|
116
|
-
|
117
|
-
|
101
|
+
setCheckedValues(s => {
|
102
|
+
return s ? { ...s,
|
103
|
+
[name]: checkedItems
|
104
|
+
} : {
|
105
|
+
[name]: checkedItems
|
106
|
+
};
|
118
107
|
});
|
119
108
|
});
|
120
109
|
return [checkedValues, onCheckedValueChange];
|
121
110
|
};
|
122
111
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
112
|
+
const useMenuOpenState = state => {
|
113
|
+
const {
|
114
|
+
targetDocument
|
115
|
+
} = useFluent();
|
116
|
+
const parentSetOpen = useMenuContext(context => context.setOpen);
|
117
|
+
const onOpenChange = useEventCallback((e, data) => {
|
129
118
|
var _a;
|
130
119
|
|
131
120
|
return (_a = state.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(state, e, data);
|
132
121
|
});
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
var _a = useControllableState({
|
122
|
+
const shouldHandleKeyboardRef = React.useRef(false);
|
123
|
+
const shouldHandleTabRef = React.useRef(false);
|
124
|
+
const pressedShiftRef = React.useRef(false);
|
125
|
+
const setOpenTimeout = React.useRef(0);
|
126
|
+
const enteringTriggerRef = React.useRef(false);
|
127
|
+
const [open, setOpenState] = useControllableState({
|
140
128
|
state: state.open,
|
141
129
|
defaultState: state.defaultOpen,
|
142
130
|
initialState: false
|
143
|
-
})
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
var event = e instanceof CustomEvent && e.type === MENU_ENTER_EVENT ? e.detail.nativeEvent : e;
|
149
|
-
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, __assign({}, data));
|
131
|
+
});
|
132
|
+
const trySetOpen = useEventCallback((e, data) => {
|
133
|
+
const event = e instanceof CustomEvent && e.type === MENU_ENTER_EVENT ? e.detail.nativeEvent : e;
|
134
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, { ...data
|
135
|
+
});
|
150
136
|
|
151
137
|
if (data.open && e.type === 'contextmenu') {
|
152
138
|
state.setContextTarget(e);
|
@@ -163,12 +149,13 @@ var useMenuOpenState = function (state) {
|
|
163
149
|
}
|
164
150
|
|
165
151
|
if (data.bubble) {
|
166
|
-
parentSetOpen(e,
|
152
|
+
parentSetOpen(e, { ...data
|
153
|
+
});
|
167
154
|
}
|
168
155
|
|
169
156
|
setOpenState(data.open);
|
170
157
|
});
|
171
|
-
|
158
|
+
const setOpen = useEventCallback((e, data) => {
|
172
159
|
var _a;
|
173
160
|
|
174
161
|
clearTimeout(setOpenTimeout.current);
|
@@ -186,9 +173,7 @@ var useMenuOpenState = function (state) {
|
|
186
173
|
// @ts-ignore
|
187
174
|
|
188
175
|
|
189
|
-
setOpenTimeout.current = setTimeout(
|
190
|
-
return trySetOpen(e, data);
|
191
|
-
}, state.hoverDelay);
|
176
|
+
setOpenTimeout.current = setTimeout(() => trySetOpen(e, data), state.hoverDelay);
|
192
177
|
} else {
|
193
178
|
trySetOpen(e, data);
|
194
179
|
}
|
@@ -198,15 +183,13 @@ var useMenuOpenState = function (state) {
|
|
198
183
|
disabled: !open,
|
199
184
|
element: targetDocument,
|
200
185
|
refs: [state.menuPopoverRef, state.triggerRef],
|
201
|
-
callback:
|
202
|
-
|
203
|
-
|
204
|
-
});
|
205
|
-
}
|
186
|
+
callback: e => setOpen(e, {
|
187
|
+
open: false
|
188
|
+
})
|
206
189
|
});
|
207
190
|
useOnMenuMouseEnter({
|
208
191
|
element: targetDocument,
|
209
|
-
callback:
|
192
|
+
callback: e => {
|
210
193
|
// When moving from a menu directly back to its trigger, this handler can close the menu
|
211
194
|
// Explicitly check a flag to see if this situation happens
|
212
195
|
if (!enteringTriggerRef.current) {
|
@@ -220,30 +203,30 @@ var useMenuOpenState = function (state) {
|
|
220
203
|
}); // Clear timeout on unmount
|
221
204
|
// Setting state after a component unmounts can cause memory leaks
|
222
205
|
|
223
|
-
React.useEffect(
|
224
|
-
return
|
206
|
+
React.useEffect(() => {
|
207
|
+
return () => {
|
225
208
|
clearTimeout(setOpenTimeout.current);
|
226
209
|
};
|
227
210
|
}, []); // Manage focus for open state
|
228
211
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
212
|
+
const {
|
213
|
+
findFirstFocusable,
|
214
|
+
findNextFocusable,
|
215
|
+
findPrevFocusable
|
216
|
+
} = useFocusFinders();
|
217
|
+
const focusFirst = React.useCallback(() => {
|
218
|
+
const firstFocusable = findFirstFocusable(state.menuPopoverRef.current);
|
236
219
|
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
237
220
|
}, [findFirstFocusable, state.menuPopoverRef]);
|
238
|
-
|
239
|
-
|
221
|
+
const focusAfterMenuTrigger = React.useCallback(() => {
|
222
|
+
const nextFocusable = findNextFocusable(state.triggerRef.current);
|
240
223
|
nextFocusable === null || nextFocusable === void 0 ? void 0 : nextFocusable.focus();
|
241
224
|
}, [findNextFocusable, state.triggerRef]);
|
242
|
-
|
243
|
-
|
225
|
+
const focusBeforeMenuTrigger = React.useCallback(() => {
|
226
|
+
const prevFocusable = findPrevFocusable(state.triggerRef.current);
|
244
227
|
prevFocusable === null || prevFocusable === void 0 ? void 0 : prevFocusable.focus();
|
245
228
|
}, [findPrevFocusable, state.triggerRef]);
|
246
|
-
React.useEffect(
|
229
|
+
React.useEffect(() => {
|
247
230
|
var _a;
|
248
231
|
|
249
232
|
if (!shouldHandleKeyboardRef.current) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Menu/useMenu.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/components/Menu/useMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,oBAAT,EAA+B,SAA/B,EAA0C,2BAA1C,QAA6E,6BAA7E;AACA,SAAS,oBAAT,EAA+B,KAA/B,EAAsC,iBAAtC,EAAyD,gBAAzD,QAAiF,2BAAjF;AACA,SAAS,SAAT,QAA0B,iCAA1B;AACA,SAAS,eAAT,QAAgC,wBAAhC;AACA,SAAS,eAAT,QAAgC,yBAAhC;AACA,SAAS,WAAT,QAA4B,sBAA5B;AACA,SAAS,cAAT,QAA+B,4BAA/B;AACA,SAAS,gBAAT,EAA2B,mBAA3B,QAAsD,mBAAtD;AACA,SAAS,YAAT,QAA6B,0BAA7B;AAGA;;;;;;;AAOG;;AACH,OAAO,MAAM,OAAO,GAAI,KAAD,IAAgC;AACrD,QAAM,SAAS,GAAG,KAAK,CAAC,MAAD,CAAvB;AACA,QAAM,SAAS,GAAG,YAAY,EAA9B;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AzC,EAAoD;AAClD,QAAA,eAAe,CAAC,OAAhB,GAA0B,sBAAsB,EAAhD,GAAqD,qBAAqB,EAA1E;AACD,OAFD,MAEO;AACL,SAAA,EAAA,GAAA,KAAK,CAAC,UAAN,CAAiB,OAAjB,MAAwB,IAAxB,IAAwB,EAAA,KAAA,KAAA,CAAxB,GAAwB,KAAA,CAAxB,GAAwB,EAAA,CAAE,KAAF,EAAxB;AACD;AACF;;AAED,IAAA,uBAAuB,CAAC,OAAxB,GAAkC,KAAlC;AACA,IAAA,kBAAkB,CAAC,OAAnB,GAA6B,KAA7B;AACA,IAAA,eAAe,CAAC,OAAhB,GAA0B,KAA1B;AACD,GAlBD,EAkBG,CAAC,KAAK,CAAC,UAAP,EAAmB,KAAK,CAAC,SAAzB,EAAoC,IAApC,EAA0C,UAA1C,EAAsD,qBAAtD,EAA6E,sBAA7E,CAlBH;AAoBA,SAAO,CAAC,IAAI,KAAA,IAAJ,IAAA,IAAI,KAAA,KAAA,CAAJ,GAAA,IAAA,GAAQ,KAAT,EAAgB,OAAhB,CAAP;AACD,CAnID","sourceRoot":""}
|
@@ -1,39 +1,41 @@
|
|
1
1
|
export function useMenuContextValues(state) {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
2
|
+
const {
|
3
|
+
open,
|
4
|
+
setOpen,
|
5
|
+
onCheckedValueChange,
|
6
|
+
checkedValues,
|
7
|
+
defaultCheckedValues,
|
8
|
+
openOnHover,
|
9
|
+
openOnContext,
|
10
|
+
triggerRef,
|
11
|
+
triggerId,
|
12
|
+
menuPopoverRef,
|
13
|
+
isSubmenu,
|
14
|
+
hasCheckmarks,
|
15
|
+
hasIcons,
|
16
|
+
persistOnItemClick,
|
17
|
+
inline
|
18
|
+
} = state; // This context is created with "@fluentui/react-context-selector", these is no sense to memoize it
|
17
19
|
|
18
|
-
|
19
|
-
open
|
20
|
-
setOpen
|
21
|
-
onCheckedValueChange
|
22
|
-
checkedValues
|
23
|
-
defaultCheckedValues
|
24
|
-
triggerRef
|
25
|
-
openOnHover
|
26
|
-
openOnContext
|
27
|
-
triggerId
|
28
|
-
menuPopoverRef
|
29
|
-
isSubmenu
|
30
|
-
hasCheckmarks
|
31
|
-
hasIcons
|
32
|
-
persistOnItemClick
|
33
|
-
inline
|
20
|
+
const menu = {
|
21
|
+
open,
|
22
|
+
setOpen,
|
23
|
+
onCheckedValueChange,
|
24
|
+
checkedValues,
|
25
|
+
defaultCheckedValues,
|
26
|
+
triggerRef,
|
27
|
+
openOnHover,
|
28
|
+
openOnContext,
|
29
|
+
triggerId,
|
30
|
+
menuPopoverRef,
|
31
|
+
isSubmenu,
|
32
|
+
hasCheckmarks,
|
33
|
+
hasIcons,
|
34
|
+
persistOnItemClick,
|
35
|
+
inline
|
34
36
|
};
|
35
37
|
return {
|
36
|
-
menu
|
38
|
+
menu
|
37
39
|
};
|
38
40
|
}
|
39
41
|
//# sourceMappingURL=useMenuContextValues.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Menu/useMenuContextValues.ts"],"names":[],"mappings":"AAEA,OAAM,SAAU,oBAAV,CAA+B,KAA/B,EAA+C;
|
1
|
+
{"version":3,"sources":["../../../src/components/Menu/useMenuContextValues.ts"],"names":[],"mappings":"AAEA,OAAM,SAAU,oBAAV,CAA+B,KAA/B,EAA+C;AACnD,QAAM;AACJ,IAAA,IADI;AAEJ,IAAA,OAFI;AAGJ,IAAA,oBAHI;AAIJ,IAAA,aAJI;AAKJ,IAAA,oBALI;AAMJ,IAAA,WANI;AAOJ,IAAA,aAPI;AAQJ,IAAA,UARI;AASJ,IAAA,SATI;AAUJ,IAAA,cAVI;AAWJ,IAAA,SAXI;AAYJ,IAAA,aAZI;AAaJ,IAAA,QAbI;AAcJ,IAAA,kBAdI;AAeJ,IAAA;AAfI,MAgBF,KAhBJ,CADmD,CAmBnD;;AACA,QAAM,IAAI,GAAG;AACX,IAAA,IADW;AAEX,IAAA,OAFW;AAGX,IAAA,oBAHW;AAIX,IAAA,aAJW;AAKX,IAAA,oBALW;AAMX,IAAA,UANW;AAOX,IAAA,WAPW;AAQX,IAAA,aARW;AASX,IAAA,SATW;AAUX,IAAA,cAVW;AAWX,IAAA,SAXW;AAYX,IAAA,aAZW;AAaX,IAAA,QAbW;AAcX,IAAA,kBAdW;AAeX,IAAA;AAfW,GAAb;AAkBA,SAAO;AAAE,IAAA;AAAF,GAAP;AACD","sourceRoot":""}
|
@@ -6,8 +6,8 @@ import { renderMenuDivider } from './renderMenuDivider';
|
|
6
6
|
* Define a styled MenuDivider, using the `useMenuDivider` hook.
|
7
7
|
*/
|
8
8
|
|
9
|
-
export
|
10
|
-
|
9
|
+
export const MenuDivider = /*#__PURE__*/React.forwardRef((props, ref) => {
|
10
|
+
const state = useMenuDivider(props, ref);
|
11
11
|
useMenuDividerStyles(state);
|
12
12
|
return renderMenuDivider(state);
|
13
13
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/MenuDivider/MenuDivider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,cAAT,QAA+B,kBAA/B;AACA,SAAS,oBAAT,QAAqC,wBAArC;AACA,SAAS,iBAAT,QAAkC,qBAAlC;AAIA;;AAEG;;AACH,OAAO,
|
1
|
+
{"version":3,"sources":["../../../src/components/MenuDivider/MenuDivider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,cAAT,QAA+B,kBAA/B;AACA,SAAS,oBAAT,QAAqC,wBAArC;AACA,SAAS,iBAAT,QAAkC,qBAAlC;AAIA;;AAEG;;AACH,OAAO,MAAM,WAAW,gBAA0C,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AAChG,QAAM,KAAK,GAAG,cAAc,CAAC,KAAD,EAAQ,GAAR,CAA5B;AACA,EAAA,oBAAoB,CAAC,KAAD,CAApB;AAEA,SAAO,iBAAiB,CAAC,KAAD,CAAxB;AACD,CALiE,CAA3D;AAOP,WAAW,CAAC,WAAZ,GAA0B,aAA1B","sourceRoot":""}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { __assign } from "tslib";
|
2
1
|
import * as React from 'react';
|
3
2
|
import { getSlots } from '@fluentui/react-utilities';
|
4
3
|
/**
|
@@ -6,11 +5,11 @@ import { getSlots } from '@fluentui/react-utilities';
|
|
6
5
|
* slots to children.
|
7
6
|
*/
|
8
7
|
|
9
|
-
export
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return /*#__PURE__*/React.createElement(slots.root,
|
8
|
+
export const renderMenuDivider = state => {
|
9
|
+
const {
|
10
|
+
slots,
|
11
|
+
slotProps
|
12
|
+
} = getSlots(state);
|
13
|
+
return /*#__PURE__*/React.createElement(slots.root, Object.assign({}, slotProps.root));
|
15
14
|
};
|
16
15
|
//# sourceMappingURL=renderMenuDivider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/MenuDivider/renderMenuDivider.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/components/MenuDivider/renderMenuDivider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;;AAGG;;AACH,OAAO,MAAM,iBAAiB,GAAI,KAAD,IAA4B;AAC3D,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAmB,KAAnB,CAArC;AAEA,sBAAO,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,SAAS,CAAC,IAAf,CAAX,CAAP;AACD,CAJM","sourceRoot":""}
|
@@ -1,17 +1,16 @@
|
|
1
|
-
import { __assign } from "tslib";
|
2
1
|
import { getNativeElementProps } from '@fluentui/react-utilities';
|
3
2
|
/**
|
4
3
|
* Given user props, returns state and render function for a MenuDivider.
|
5
4
|
*/
|
6
5
|
|
7
|
-
export
|
6
|
+
export const useMenuDivider = (props, ref) => {
|
8
7
|
return {
|
9
|
-
root: getNativeElementProps('div',
|
8
|
+
root: getNativeElementProps('div', {
|
10
9
|
role: 'presentation',
|
11
|
-
'aria-hidden': true
|
12
|
-
|
13
|
-
ref
|
14
|
-
})
|
10
|
+
'aria-hidden': true,
|
11
|
+
...props,
|
12
|
+
ref
|
13
|
+
})
|
15
14
|
};
|
16
15
|
};
|
17
16
|
//# sourceMappingURL=useMenuDivider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/MenuDivider/useMenuDivider.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/components/MenuDivider/useMenuDivider.ts"],"names":[],"mappings":"AAAA,SAAS,qBAAT,QAAsC,2BAAtC;AAIA;;AAEG;;AACH,OAAO,MAAM,cAAc,GAAG,CAAC,KAAD,EAA0B,GAA1B,KAA2E;AACvG,SAAO;AACL,IAAA,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAQ;AACjC,MAAA,IAAI,EAAE,cAD2B;AAEjC,qBAAe,IAFkB;AAGjC,SAAG,KAH8B;AAIjC,MAAA;AAJiC,KAAR;AADtB,GAAP;AAQD,CATM","sourceRoot":""}
|
@@ -1,2 +1,3 @@
|
|
1
1
|
import type { MenuDividerState } from './MenuDivider.types';
|
2
|
+
export declare const menuDividerClassName = "fui-MenuDivider";
|
2
3
|
export declare const useMenuDividerStyles: (state: MenuDividerState) => import("@fluentui/react-utilities").ComponentState<import("./MenuDivider.types").MenuDividerSlots>;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { mergeClasses, __styles } from '@fluentui/react-make-styles';
|
2
|
+
export const menuDividerClassName = 'fui-MenuDivider';
|
2
3
|
|
3
|
-
|
4
|
+
const useStyles = /*#__PURE__*/__styles({
|
4
5
|
"root": {
|
5
6
|
"Bqenvij": "f1mpe4l3",
|
6
7
|
"B6of3ja": "fvjh0tl",
|
@@ -14,9 +15,9 @@ var useStyles = /*#__PURE__*/__styles({
|
|
14
15
|
"d": [".f1mpe4l3{height:1px;}", ".fvjh0tl{margin-top:4px;}", ".f1rnx978{margin-right:-5px;}", ".f1q7jvqi{margin-left:-5px;}", ".fd1gkq{margin-bottom:4px;}", ".f14z66ap{width:auto;}", ".fn4h89p{background-color:var(--colorNeutralStroke2);}"]
|
15
16
|
});
|
16
17
|
|
17
|
-
export
|
18
|
-
|
19
|
-
state.root.className = mergeClasses(styles.root, state.root.className);
|
18
|
+
export const useMenuDividerStyles = state => {
|
19
|
+
const styles = useStyles();
|
20
|
+
state.root.className = mergeClasses(menuDividerClassName, styles.root, state.root.className);
|
20
21
|
return state;
|
21
22
|
};
|
22
23
|
//# sourceMappingURL=useMenuDividerStyles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/MenuDivider/useMenuDividerStyles.ts"],"names":[],"mappings":"AAAA,SAAS,YAAT,kBAAyC,6BAAzC
|
1
|
+
{"version":3,"sources":["../../../src/components/MenuDivider/useMenuDividerStyles.ts"],"names":[],"mappings":"AAAA,SAAS,YAAT,kBAAyC,6BAAzC;AAGA,OAAO,MAAM,oBAAoB,GAAG,iBAA7B;;AAEP,MAAM,SAAS,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAlB;;AASA,OAAO,MAAM,oBAAoB,GAAI,KAAD,IAA4B;AAC9D,QAAM,MAAM,GAAG,SAAS,EAAxB;AACA,EAAA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CAAC,oBAAD,EAAuB,MAAM,CAAC,IAA9B,EAAoC,KAAK,CAAC,IAAN,CAAW,SAA/C,CAAnC;AAEA,SAAO,KAAP;AACD,CALM","sourceRoot":""}
|
@@ -2,13 +2,15 @@ import * as React from 'react';
|
|
2
2
|
import { useMenuGroup } from './useMenuGroup';
|
3
3
|
import { renderMenuGroup } from './renderMenuGroup';
|
4
4
|
import { useMenuGroupContextValues } from './useMenuGroupContextValues';
|
5
|
+
import { useMenuGroupStyles } from './useMenuGroupStyles';
|
5
6
|
/**
|
6
7
|
* Define a styled MenuGroup, using the `useMenuGroup` hook.
|
7
8
|
*/
|
8
9
|
|
9
|
-
export
|
10
|
-
|
11
|
-
|
10
|
+
export const MenuGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
11
|
+
const state = useMenuGroup(props, ref);
|
12
|
+
const contextValues = useMenuGroupContextValues(state);
|
13
|
+
useMenuGroupStyles(state);
|
12
14
|
return renderMenuGroup(state, contextValues);
|
13
15
|
});
|
14
16
|
MenuGroup.displayName = 'MenuGroup';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/MenuGroup/MenuGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,YAAT,QAA6B,gBAA7B;AACA,SAAS,eAAT,QAAgC,mBAAhC;AACA,SAAS,yBAAT,QAA0C,6BAA1C;
|
1
|
+
{"version":3,"sources":["../../../src/components/MenuGroup/MenuGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,YAAT,QAA6B,gBAA7B;AACA,SAAS,eAAT,QAAgC,mBAAhC;AACA,SAAS,yBAAT,QAA0C,6BAA1C;AAGA,SAAS,kBAAT,QAAmC,sBAAnC;AAEA;;AAEG;;AACH,OAAO,MAAM,SAAS,gBAAwC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AAC5F,QAAM,KAAK,GAAG,YAAY,CAAC,KAAD,EAAQ,GAAR,CAA1B;AACA,QAAM,aAAa,GAAG,yBAAyB,CAAC,KAAD,CAA/C;AAEA,EAAA,kBAAkB,CAAC,KAAD,CAAlB;AAEA,SAAO,eAAe,CAAC,KAAD,EAAQ,aAAR,CAAtB;AACD,CAP6D,CAAvD;AASP,SAAS,CAAC,WAAV,GAAwB,WAAxB","sourceRoot":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/MenuGroup/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/MenuGroup/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC"}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { __assign } from "tslib";
|
2
1
|
import * as React from 'react';
|
3
2
|
import { getSlots } from '@fluentui/react-utilities';
|
4
3
|
import { MenuGroupContextProvider } from '../../contexts/menuGroupContext';
|
@@ -7,13 +6,13 @@ import { MenuGroupContextProvider } from '../../contexts/menuGroupContext';
|
|
7
6
|
* slots to children.
|
8
7
|
*/
|
9
8
|
|
10
|
-
export
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
export const renderMenuGroup = (state, contextValues) => {
|
10
|
+
const {
|
11
|
+
slots,
|
12
|
+
slotProps
|
13
|
+
} = getSlots(state);
|
15
14
|
return /*#__PURE__*/React.createElement(MenuGroupContextProvider, {
|
16
15
|
value: contextValues.menuGroup
|
17
|
-
}, /*#__PURE__*/React.createElement(slots.root,
|
16
|
+
}, /*#__PURE__*/React.createElement(slots.root, Object.assign({}, slotProps.root)));
|
18
17
|
};
|
19
18
|
//# sourceMappingURL=renderMenuGroup.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/MenuGroup/renderMenuGroup.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/components/MenuGroup/renderMenuGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAEA,SAAS,wBAAT,QAAyC,iCAAzC;AAEA;;;AAGG;;AACH,OAAO,MAAM,eAAe,GAAG,CAAC,KAAD,EAAwB,aAAxB,KAAiE;AAC9F,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAiB,KAAjB,CAArC;AAEA,sBACE,KAAA,CAAA,aAAA,CAAC,wBAAD,EAAyB;AAAC,IAAA,KAAK,EAAE,aAAa,CAAC;AAAtB,GAAzB,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,SAAS,CAAC,IAAf,CAAX,CADF,CADF;AAKD,CARM","sourceRoot":""}
|