@fluentui/react-menu 9.4.0 → 9.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +143 -1
- package/CHANGELOG.md +36 -2
- package/dist/index.d.ts +46 -5
- package/lib/components/Menu/Menu.types.js.map +1 -1
- package/lib/components/Menu/useMenu.js +13 -7
- package/lib/components/Menu/useMenu.js.map +1 -1
- package/lib/components/MenuItem/useMenuItem.js +3 -1
- package/lib/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopover.js +20 -14
- package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/components/MenuTrigger/MenuTrigger.types.js.map +1 -1
- package/lib/components/MenuTrigger/useMenuTrigger.js +46 -31
- package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-amd/Menu.js +6 -0
- package/lib-amd/Menu.js.map +1 -0
- package/lib-amd/MenuDivider.js +6 -0
- package/lib-amd/MenuDivider.js.map +1 -0
- package/lib-amd/MenuGroup.js +6 -0
- package/lib-amd/MenuGroup.js.map +1 -0
- package/lib-amd/MenuGroupHeader.js +6 -0
- package/lib-amd/MenuGroupHeader.js.map +1 -0
- package/lib-amd/MenuItem.js +6 -0
- package/lib-amd/MenuItem.js.map +1 -0
- package/lib-amd/MenuItemCheckbox.js +6 -0
- package/lib-amd/MenuItemCheckbox.js.map +1 -0
- package/lib-amd/MenuItemRadio.js +6 -0
- package/lib-amd/MenuItemRadio.js.map +1 -0
- package/lib-amd/MenuList.js +6 -0
- package/lib-amd/MenuList.js.map +1 -0
- package/lib-amd/MenuPopover.js +6 -0
- package/lib-amd/MenuPopover.js.map +1 -0
- package/lib-amd/MenuSplitGroup.js +6 -0
- package/lib-amd/MenuSplitGroup.js.map +1 -0
- package/lib-amd/MenuTrigger.js +6 -0
- package/lib-amd/MenuTrigger.js.map +1 -0
- package/lib-amd/components/Menu/Menu.js +16 -0
- package/lib-amd/components/Menu/Menu.js.map +1 -0
- package/lib-amd/components/Menu/Menu.types.js +5 -0
- package/lib-amd/components/Menu/Menu.types.js.map +1 -0
- package/lib-amd/components/Menu/index.js +10 -0
- package/lib-amd/components/Menu/index.js.map +1 -0
- package/lib-amd/components/Menu/renderMenu.js +15 -0
- package/lib-amd/components/Menu/renderMenu.js.map +1 -0
- package/lib-amd/components/Menu/useMenu.js +233 -0
- package/lib-amd/components/Menu/useMenu.js.map +1 -0
- package/lib-amd/components/Menu/useMenuContextValues.js +29 -0
- package/lib-amd/components/Menu/useMenuContextValues.js.map +1 -0
- package/lib-amd/components/MenuDivider/MenuDivider.js +15 -0
- package/lib-amd/components/MenuDivider/MenuDivider.js.map +1 -0
- package/lib-amd/components/MenuDivider/MenuDivider.types.js +5 -0
- package/lib-amd/components/MenuDivider/MenuDivider.types.js.map +1 -0
- package/lib-amd/components/MenuDivider/index.js +10 -0
- package/lib-amd/components/MenuDivider/index.js.map +1 -0
- package/lib-amd/components/MenuDivider/renderMenuDivider.js +15 -0
- package/lib-amd/components/MenuDivider/renderMenuDivider.js.map +1 -0
- package/lib-amd/components/MenuDivider/useMenuDivider.js +18 -0
- package/lib-amd/components/MenuDivider/useMenuDivider.js.map +1 -0
- package/lib-amd/components/MenuDivider/useMenuDividerStyles.js +18 -0
- package/lib-amd/components/MenuDivider/useMenuDividerStyles.js.map +1 -0
- package/lib-amd/components/MenuGroup/MenuGroup.js +16 -0
- package/lib-amd/components/MenuGroup/MenuGroup.js.map +1 -0
- package/lib-amd/components/MenuGroup/MenuGroup.types.js +5 -0
- package/lib-amd/components/MenuGroup/MenuGroup.types.js.map +1 -0
- package/lib-amd/components/MenuGroup/index.js +11 -0
- package/lib-amd/components/MenuGroup/index.js.map +1 -0
- package/lib-amd/components/MenuGroup/renderMenuGroup.js +16 -0
- package/lib-amd/components/MenuGroup/renderMenuGroup.js.map +1 -0
- package/lib-amd/components/MenuGroup/useMenuGroup.js +20 -0
- package/lib-amd/components/MenuGroup/useMenuGroup.js.map +1 -0
- package/lib-amd/components/MenuGroup/useMenuGroupContextValues.js +12 -0
- package/lib-amd/components/MenuGroup/useMenuGroupContextValues.js.map +1 -0
- package/lib-amd/components/MenuGroup/useMenuGroupStyles.js +14 -0
- package/lib-amd/components/MenuGroup/useMenuGroupStyles.js.map +1 -0
- package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.js +15 -0
- package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -0
- package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.types.js +5 -0
- package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.types.js.map +1 -0
- package/lib-amd/components/MenuGroupHeader/index.js +10 -0
- package/lib-amd/components/MenuGroupHeader/index.js.map +1 -0
- package/lib-amd/components/MenuGroupHeader/renderMenuGroupHeader.js +15 -0
- package/lib-amd/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -0
- package/lib-amd/components/MenuGroupHeader/useMenuGroupHeader.js +19 -0
- package/lib-amd/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -0
- package/lib-amd/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +27 -0
- package/lib-amd/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -0
- package/lib-amd/components/MenuItem/MenuItem.js +15 -0
- package/lib-amd/components/MenuItem/MenuItem.js.map +1 -0
- package/lib-amd/components/MenuItem/MenuItem.types.js +5 -0
- package/lib-amd/components/MenuItem/MenuItem.types.js.map +1 -0
- package/lib-amd/components/MenuItem/index.js +10 -0
- package/lib-amd/components/MenuItem/index.js.map +1 -0
- package/lib-amd/components/MenuItem/renderMenuItem.js +19 -0
- package/lib-amd/components/MenuItem/renderMenuItem.js.map +1 -0
- package/lib-amd/components/MenuItem/useCharacterSearch.js +22 -0
- package/lib-amd/components/MenuItem/useCharacterSearch.js.map +1 -0
- package/lib-amd/components/MenuItem/useMenuItem.js +80 -0
- package/lib-amd/components/MenuItem/useMenuItem.js.map +1 -0
- package/lib-amd/components/MenuItem/useMenuItemStyles.js +100 -0
- package/lib-amd/components/MenuItem/useMenuItemStyles.js.map +1 -0
- package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.js +15 -0
- package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -0
- package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.types.js +5 -0
- package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.types.js.map +1 -0
- package/lib-amd/components/MenuItemCheckbox/index.js +10 -0
- package/lib-amd/components/MenuItemCheckbox/index.js.map +1 -0
- package/lib-amd/components/MenuItemCheckbox/renderMenuItemCheckbox.js +16 -0
- package/lib-amd/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -0
- package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckbox.js +26 -0
- package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -0
- package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +31 -0
- package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -0
- package/lib-amd/components/MenuItemRadio/MenuItemRadio.js +15 -0
- package/lib-amd/components/MenuItemRadio/MenuItemRadio.js.map +1 -0
- package/lib-amd/components/MenuItemRadio/MenuItemRadio.types.js +5 -0
- package/lib-amd/components/MenuItemRadio/MenuItemRadio.types.js.map +1 -0
- package/lib-amd/components/MenuItemRadio/index.js +10 -0
- package/lib-amd/components/MenuItemRadio/index.js.map +1 -0
- package/lib-amd/components/MenuItemRadio/renderMenuItemRadio.js +19 -0
- package/lib-amd/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -0
- package/lib-amd/components/MenuItemRadio/useMenuItemRadio.js +27 -0
- package/lib-amd/components/MenuItemRadio/useMenuItemRadio.js.map +1 -0
- package/lib-amd/components/MenuItemRadio/useMenuItemRadioStyles.js +31 -0
- package/lib-amd/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -0
- package/lib-amd/components/MenuList/MenuList.js +16 -0
- package/lib-amd/components/MenuList/MenuList.js.map +1 -0
- package/lib-amd/components/MenuList/MenuList.types.js +5 -0
- package/lib-amd/components/MenuList/MenuList.types.js.map +1 -0
- package/lib-amd/components/MenuList/index.js +11 -0
- package/lib-amd/components/MenuList/index.js.map +1 -0
- package/lib-amd/components/MenuList/renderMenuList.js +15 -0
- package/lib-amd/components/MenuList/renderMenuList.js.map +1 -0
- package/lib-amd/components/MenuList/useMenuList.js +119 -0
- package/lib-amd/components/MenuList/useMenuList.js.map +1 -0
- package/lib-amd/components/MenuList/useMenuListContextValues.js +21 -0
- package/lib-amd/components/MenuList/useMenuListContextValues.js.map +1 -0
- package/lib-amd/components/MenuList/useMenuListStyles.js +21 -0
- package/lib-amd/components/MenuList/useMenuListStyles.js.map +1 -0
- package/lib-amd/components/MenuPopover/MenuPopover.js +15 -0
- package/lib-amd/components/MenuPopover/MenuPopover.js.map +1 -0
- package/lib-amd/components/MenuPopover/MenuPopover.types.js +5 -0
- package/lib-amd/components/MenuPopover/MenuPopover.types.js.map +1 -0
- package/lib-amd/components/MenuPopover/index.js +10 -0
- package/lib-amd/components/MenuPopover/index.js.map +1 -0
- package/lib-amd/components/MenuPopover/renderMenuPopover.js +18 -0
- package/lib-amd/components/MenuPopover/renderMenuPopover.js.map +1 -0
- package/lib-amd/components/MenuPopover/useMenuPopover.js +82 -0
- package/lib-amd/components/MenuPopover/useMenuPopover.js.map +1 -0
- package/lib-amd/components/MenuPopover/useMenuPopoverStyles.js +21 -0
- package/lib-amd/components/MenuPopover/useMenuPopoverStyles.js.map +1 -0
- package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.js +15 -0
- package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -0
- package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.types.js +5 -0
- package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.types.js.map +1 -0
- package/lib-amd/components/MenuSplitGroup/index.js +10 -0
- package/lib-amd/components/MenuSplitGroup/index.js.map +1 -0
- package/lib-amd/components/MenuSplitGroup/renderMenuSplitGroup.js +14 -0
- package/lib-amd/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -0
- package/lib-amd/components/MenuSplitGroup/useMenuSplitGroup.js +47 -0
- package/lib-amd/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -0
- package/lib-amd/components/MenuSplitGroup/useMenuSplitGroupStyles.js +43 -0
- package/lib-amd/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -0
- package/lib-amd/components/MenuTrigger/MenuTrigger.js +18 -0
- package/lib-amd/components/MenuTrigger/MenuTrigger.js.map +1 -0
- package/lib-amd/components/MenuTrigger/MenuTrigger.types.js +5 -0
- package/lib-amd/components/MenuTrigger/MenuTrigger.types.js.map +1 -0
- package/lib-amd/components/MenuTrigger/index.js +9 -0
- package/lib-amd/components/MenuTrigger/index.js.map +1 -0
- package/lib-amd/components/MenuTrigger/renderMenuTrigger.js +15 -0
- package/lib-amd/components/MenuTrigger/renderMenuTrigger.js.map +1 -0
- package/lib-amd/components/MenuTrigger/useMenuTrigger.js +112 -0
- package/lib-amd/components/MenuTrigger/useMenuTrigger.js.map +1 -0
- package/lib-amd/components/index.js +7 -0
- package/lib-amd/components/index.js.map +1 -0
- package/lib-amd/contexts/menuContext.js +32 -0
- package/lib-amd/contexts/menuContext.js.map +1 -0
- package/lib-amd/contexts/menuGroupContext.js +13 -0
- package/lib-amd/contexts/menuGroupContext.js.map +1 -0
- package/lib-amd/contexts/menuListContext.js +24 -0
- package/lib-amd/contexts/menuListContext.js.map +1 -0
- package/lib-amd/contexts/menuTriggerContext.js +14 -0
- package/lib-amd/contexts/menuTriggerContext.js.map +1 -0
- package/lib-amd/index.js +69 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-amd/selectable/index.js +7 -0
- package/lib-amd/selectable/index.js.map +1 -0
- package/lib-amd/selectable/types.js +5 -0
- package/lib-amd/selectable/types.js.map +1 -0
- package/lib-amd/selectable/useCheckmarkStyles.js +28 -0
- package/lib-amd/selectable/useCheckmarkStyles.js.map +1 -0
- package/lib-amd/utils/index.js +6 -0
- package/lib-amd/utils/index.js.map +1 -0
- package/lib-amd/utils/useIsSubmenu.js +20 -0
- package/lib-amd/utils/useIsSubmenu.js.map +1 -0
- package/lib-amd/utils/useOnMenuEnter.js +59 -0
- package/lib-amd/utils/useOnMenuEnter.js.map +1 -0
- package/lib-commonjs/components/Menu/useMenu.js +13 -7
- package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItem.js +3 -1
- package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js +20 -14
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +46 -31
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +11 -11
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useMenuPopover.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuPopover/useMenuPopover.ts"],"names":[],"mappings":";;;;IASA;;;;;;;;OAQG;IACI,IAAM,uBAAuB,GAAG,UAAC,KAAuB,EAAE,GAA2B;;QAC1F,IAAM,UAAU,GAAG,qCAAuB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,cAAc,EAAtB,CAAsB,CAAC,CAAC;QAC9E,IAAM,OAAO,GAAG,qCAAuB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,OAAO,EAAf,CAAe,CAAC,CAAC;QACpE,IAAM,IAAI,GAAG,qCAAuB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,IAAI,EAAZ,CAAY,CAAC,CAAC;QAC9D,IAAM,WAAW,GAAG,qCAAuB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,WAAW,EAAnB,CAAmB,CAAC,CAAC;QAC5E,IA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,IAAI,EAAE,oBAAoB,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;gBACnF,KAAK,CAAC,cAAc,EAAE,CAAC;aACxB;YAED,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,KAAK,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,MAAM,QAAA;YACN,UAAU,EAAE;gBACV,IAAI,EAAE,KAAK;aACZ;YACD,IAAI,EAAE,SAAS;SAChB,CAAC;IACJ,CAAC,CAAC;IAlFW,QAAA,uBAAuB,2BAkFlC","sourcesContent":["import * as React from 'react';\nimport { ArrowLeft, Tab, ArrowRight, Escape } from '@fluentui/keyboard-keys';\nimport { getNativeElementProps, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { MenuPopoverProps, MenuPopoverState } from './MenuPopover.types';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { dispatchMenuEnterEvent } from '../../utils/index';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\n\n/**\n * Create the state required to render MenuPopover.\n *\n * The returned state can be modified with hooks such as useMenuPopoverStyles_unstable,\n * before being passed to renderMenuPopover_unstable.\n *\n * @param props - props from this instance of MenuPopover\n * @param ref - reference to root HTMLElement of MenuPopover\n */\nexport const useMenuPopover_unstable = (props: MenuPopoverProps, ref: React.Ref<HTMLElement>): MenuPopoverState => {\n const popoverRef = useMenuContext_unstable(context => context.menuPopoverRef);\n const setOpen = useMenuContext_unstable(context => context.setOpen);\n const open = useMenuContext_unstable(context => context.open);\n const openOnHover = useMenuContext_unstable(context => context.openOnHover);\n const isSubmenu = useIsSubmenu();\n const canDispatchCustomEventRef = React.useRef(true);\n const throttleDispatchTimerRef = React.useRef(0);\n\n const { dir } = useFluent();\n const CloseArrowKey = dir === 'ltr' ? ArrowLeft : ArrowRight;\n\n // use DOM listener since react events propagate up the react tree\n // no need to do `contains` logic as menus are all positioned in different portals\n const mouseOverListenerCallbackRef = React.useCallback(\n (node: HTMLElement) => {\n if (node) {\n // Dispatches the custom menu mouse enter event with throttling\n // Needs to trigger on mouseover to support keyboard + mouse together\n // i.e. keyboard opens submenus while cursor is still on the parent\n node.addEventListener('mouseover', e => {\n if (canDispatchCustomEventRef.current) {\n canDispatchCustomEventRef.current = false;\n dispatchMenuEnterEvent(popoverRef.current as HTMLElement, e);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore #16889 Node setTimeout type leaking\n throttleDispatchTimerRef.current = setTimeout(() => (canDispatchCustomEventRef.current = true), 250);\n }\n });\n }\n },\n [popoverRef, throttleDispatchTimerRef],\n );\n\n React.useEffect(() => {\n () => clearTimeout(throttleDispatchTimerRef.current);\n }, []);\n\n const inline = useMenuContext_unstable(context => context.inline) ?? false;\n const rootProps = getNativeElementProps('div', {\n role: 'presentation',\n ...props,\n ref: useMergedRefs(ref, popoverRef, mouseOverListenerCallbackRef),\n });\n\n const { onMouseEnter: onMouseEnterOriginal, onKeyDown: onKeyDownOriginal } = rootProps;\n\n rootProps.onMouseEnter = useEventCallback((event: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(event, { open: true, keyboard: false, type: 'menuPopoverMouseEnter', event });\n }\n\n onMouseEnterOriginal?.(event);\n });\n\n rootProps.onKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLElement>) => {\n const key = event.key;\n\n if (key === Escape || (isSubmenu && key === CloseArrowKey)) {\n if (open && popoverRef.current?.contains(event.target as HTMLElement)) {\n setOpen(event, { open: false, keyboard: true, type: 'menuPopoverKeyDown', event });\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover and Tooltip\n event.stopPropagation();\n }\n }\n\n if (key === Tab) {\n setOpen(event, { open: false, keyboard: true, type: 'menuPopoverKeyDown', event });\n event.preventDefault();\n }\n\n onKeyDownOriginal?.(event);\n });\n\n return {\n inline,\n components: {\n root: 'div',\n },\n root: rootProps,\n };\n};\n"]}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
define(["require", "exports", "tslib", "@griffel/react", "@fluentui/react-theme"], function (require, exports, tslib_1, react_1, react_theme_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.useMenuPopoverStyles_unstable = exports.menuPopoverClassNames = void 0;
|
5
|
+
exports.menuPopoverClassNames = {
|
6
|
+
root: 'fui-MenuPopover',
|
7
|
+
};
|
8
|
+
var useStyles = react_1.makeStyles({
|
9
|
+
root: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.borderRadius(react_theme_1.tokens.borderRadiusMedium)), { backgroundColor: react_theme_1.tokens.colorNeutralBackground1, minWidth: '128px', maxWidth: '300px', width: 'max-content', boxShadow: "" + react_theme_1.tokens.shadow16 }), react_1.shorthands.padding('4px')), react_1.shorthands.border('1px', 'solid', react_theme_1.tokens.colorTransparentStroke)),
|
10
|
+
});
|
11
|
+
/**
|
12
|
+
* Apply styling to the Menu slots based on the state
|
13
|
+
*/
|
14
|
+
var useMenuPopoverStyles_unstable = function (state) {
|
15
|
+
var styles = useStyles();
|
16
|
+
state.root.className = react_1.mergeClasses(exports.menuPopoverClassNames.root, styles.root, state.root.className);
|
17
|
+
return state;
|
18
|
+
};
|
19
|
+
exports.useMenuPopoverStyles_unstable = useMenuPopoverStyles_unstable;
|
20
|
+
});
|
21
|
+
//# sourceMappingURL=useMenuPopoverStyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useMenuPopoverStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuPopover/useMenuPopoverStyles.ts"],"names":[],"mappings":";;;;IAKa,QAAA,qBAAqB,GAAqC;QACrE,IAAI,EAAE,iBAAiB;KACxB,CAAC;IAEF,IAAM,SAAS,GAAG,kBAAU,CAAC;QAC3B,IAAI,0EACC,kBAAU,CAAC,YAAY,CAAC,oBAAM,CAAC,kBAAkB,CAAC,KACrD,eAAe,EAAE,oBAAM,CAAC,uBAAuB,EAC/C,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,aAAa,EACpB,SAAS,EAAE,KAAG,oBAAM,CAAC,QAAU,KAC5B,kBAAU,CAAC,OAAO,CAAC,KAAK,CAAC,GACzB,kBAAU,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,oBAAM,CAAC,sBAAsB,CAAC,CACpE;KACF,CAAC,CAAC;IAEH;;OAEG;IACI,IAAM,6BAA6B,GAAG,UAAC,KAAuB;QACnE,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,oBAAY,CAAC,6BAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnG,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAJW,QAAA,6BAA6B,iCAIxC","sourcesContent":["import { shorthands, mergeClasses, makeStyles } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { MenuPopoverSlots, MenuPopoverState } from './MenuPopover.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const menuPopoverClassNames: SlotClassNames<MenuPopoverSlots> = {\n root: 'fui-MenuPopover',\n};\n\nconst useStyles = makeStyles({\n root: {\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n backgroundColor: tokens.colorNeutralBackground1,\n minWidth: '128px',\n maxWidth: '300px',\n width: 'max-content',\n boxShadow: `${tokens.shadow16}`,\n ...shorthands.padding('4px'),\n ...shorthands.border('1px', 'solid', tokens.colorTransparentStroke),\n },\n});\n\n/**\n * Apply styling to the Menu slots based on the state\n */\nexport const useMenuPopoverStyles_unstable = (state: MenuPopoverState): MenuPopoverState => {\n const styles = useStyles();\n state.root.className = mergeClasses(menuPopoverClassNames.root, styles.root, state.root.className);\n return state;\n};\n"]}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
define(["require", "exports", "react", "./useMenuSplitGroup", "./renderMenuSplitGroup", "./useMenuSplitGroupStyles"], function (require, exports, React, useMenuSplitGroup_1, renderMenuSplitGroup_1, useMenuSplitGroupStyles_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.MenuSplitGroup = void 0;
|
5
|
+
/**
|
6
|
+
* Layout wrapper that provides extra keyboard navigation behavior for two `MenuItem` components.
|
7
|
+
*/
|
8
|
+
exports.MenuSplitGroup = React.forwardRef(function (props, ref) {
|
9
|
+
var state = useMenuSplitGroup_1.useMenuSplitGroup_unstable(props, ref);
|
10
|
+
useMenuSplitGroupStyles_1.useMenuSplitGroupStyles_unstable(state);
|
11
|
+
return renderMenuSplitGroup_1.renderMenuSplitGroup_unstable(state);
|
12
|
+
});
|
13
|
+
exports.MenuSplitGroup.displayName = 'MenuSplitGroup';
|
14
|
+
});
|
15
|
+
//# sourceMappingURL=MenuSplitGroup.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MenuSplitGroup.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/MenuSplitGroup.tsx"],"names":[],"mappings":";;;;IAOA;;OAEG;IACU,QAAA,cAAc,GAA6C,KAAK,CAAC,UAAU,CAAC,UAAC,KAAK,EAAE,GAAG;QAClG,IAAM,KAAK,GAAG,8CAA0B,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAErD,0DAAgC,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,oDAA6B,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,sBAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC","sourcesContent":["import * as React from 'react';\nimport { useMenuSplitGroup_unstable } from './useMenuSplitGroup';\nimport { renderMenuSplitGroup_unstable } from './renderMenuSplitGroup';\nimport { useMenuSplitGroupStyles_unstable } from './useMenuSplitGroupStyles';\nimport type { MenuSplitGroupProps } from './MenuSplitGroup.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Layout wrapper that provides extra keyboard navigation behavior for two `MenuItem` components.\n */\nexport const MenuSplitGroup: ForwardRefComponent<MenuSplitGroupProps> = React.forwardRef((props, ref) => {\n const state = useMenuSplitGroup_unstable(props, ref);\n\n useMenuSplitGroupStyles_unstable(state);\n return renderMenuSplitGroup_unstable(state);\n});\n\nMenuSplitGroup.displayName = 'MenuSplitGroup';\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MenuSplitGroup.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/MenuSplitGroup.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type MenuSplitGroupSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * MenuSplitGroup Props\n */\nexport type MenuSplitGroupProps = ComponentProps<MenuSplitGroupSlots>;\n\n/**\n * State used in rendering MenuSplitGroup\n */\nexport type MenuSplitGroupState = ComponentState<MenuSplitGroupSlots>;\n"]}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
define(["require", "exports", "tslib", "./MenuSplitGroup", "./MenuSplitGroup.types", "./renderMenuSplitGroup", "./useMenuSplitGroup", "./useMenuSplitGroupStyles"], function (require, exports, tslib_1, MenuSplitGroup_1, MenuSplitGroup_types_1, renderMenuSplitGroup_1, useMenuSplitGroup_1, useMenuSplitGroupStyles_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
tslib_1.__exportStar(MenuSplitGroup_1, exports);
|
5
|
+
tslib_1.__exportStar(MenuSplitGroup_types_1, exports);
|
6
|
+
tslib_1.__exportStar(renderMenuSplitGroup_1, exports);
|
7
|
+
tslib_1.__exportStar(useMenuSplitGroup_1, exports);
|
8
|
+
tslib_1.__exportStar(useMenuSplitGroupStyles_1, exports);
|
9
|
+
});
|
10
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/index.ts"],"names":[],"mappings":";;;IAAA,gDAAiC;IACjC,sDAAuC;IACvC,sDAAuC;IACvC,mDAAoC;IACpC,yDAA0C","sourcesContent":["export * from './MenuSplitGroup';\nexport * from './MenuSplitGroup.types';\nexport * from './renderMenuSplitGroup';\nexport * from './useMenuSplitGroup';\nexport * from './useMenuSplitGroupStyles';\n"]}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
define(["require", "exports", "tslib", "react", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_utilities_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.renderMenuSplitGroup_unstable = void 0;
|
5
|
+
/**
|
6
|
+
* Render the final JSX of MenuSplitGroup
|
7
|
+
*/
|
8
|
+
var renderMenuSplitGroup_unstable = function (state) {
|
9
|
+
var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
|
10
|
+
return React.createElement(slots.root, tslib_1.__assign({}, slotProps.root));
|
11
|
+
};
|
12
|
+
exports.renderMenuSplitGroup_unstable = renderMenuSplitGroup_unstable;
|
13
|
+
});
|
14
|
+
//# sourceMappingURL=renderMenuSplitGroup.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"renderMenuSplitGroup.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/renderMenuSplitGroup.tsx"],"names":[],"mappings":";;;;IAIA;;OAEG;IACI,IAAM,6BAA6B,GAAG,UAAC,KAA0B;QAChE,IAAA,KAAuB,0BAAQ,CAAsB,KAAK,CAAC,EAAzD,KAAK,WAAA,EAAE,SAAS,eAAyC,CAAC;QAElE,OAAO,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI,CAAC;IAC5C,CAAC,CAAC;IAJW,QAAA,6BAA6B,iCAIxC","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"]}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@fluentui/react-tabster", "@fluentui/react-shared-contexts", "@fluentui/keyboard-keys"], function (require, exports, tslib_1, React, react_utilities_1, react_tabster_1, react_shared_contexts_1, keyboard_keys_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.useMenuSplitGroup_unstable = void 0;
|
5
|
+
/**
|
6
|
+
* Create the state required to render MenuSplitGroup.
|
7
|
+
*
|
8
|
+
* The returned state can be modified with hooks such as useMenuSplitGroupStyles_unstable,
|
9
|
+
* before being passed to renderMenuSplitGroup_unstable.
|
10
|
+
*
|
11
|
+
* @param props - props from this instance of MenuSplitGroup
|
12
|
+
* @param ref - reference to root HTMLElement of MenuSplitGroup
|
13
|
+
*/
|
14
|
+
var useMenuSplitGroup_unstable = function (props, ref) {
|
15
|
+
var innerRef = React.useRef();
|
16
|
+
var _a = react_shared_contexts_1.useFluent_unstable(), dir = _a.dir, targetDocument = _a.targetDocument;
|
17
|
+
var nextArrowKey = react_utilities_1.getRTLSafeKey(keyboard_keys_1.ArrowRight, dir);
|
18
|
+
var prevArrowKey = react_utilities_1.getRTLSafeKey(keyboard_keys_1.ArrowLeft, dir);
|
19
|
+
var _b = react_tabster_1.useFocusFinders(), findNextFocusable = _b.findNextFocusable, findPrevFocusable = _b.findPrevFocusable;
|
20
|
+
var onKeyDown = React.useCallback(function (e) {
|
21
|
+
var _a;
|
22
|
+
var activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
|
23
|
+
if (!activeElement) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
if (!((_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.contains(activeElement))) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
if (e.key === nextArrowKey) {
|
30
|
+
var next = findNextFocusable(activeElement, { container: innerRef.current });
|
31
|
+
next === null || next === void 0 ? void 0 : next.focus();
|
32
|
+
}
|
33
|
+
if (e.key === prevArrowKey) {
|
34
|
+
var prev = findPrevFocusable(activeElement, { container: innerRef.current });
|
35
|
+
prev === null || prev === void 0 ? void 0 : prev.focus();
|
36
|
+
}
|
37
|
+
}, [findNextFocusable, findPrevFocusable, targetDocument, nextArrowKey, prevArrowKey]);
|
38
|
+
return {
|
39
|
+
components: {
|
40
|
+
root: 'div',
|
41
|
+
},
|
42
|
+
root: react_utilities_1.getNativeElementProps('div', tslib_1.__assign({ role: 'group', ref: react_utilities_1.useMergedRefs(ref, innerRef), onKeyDown: onKeyDown }, props)),
|
43
|
+
};
|
44
|
+
};
|
45
|
+
exports.useMenuSplitGroup_unstable = useMenuSplitGroup_unstable;
|
46
|
+
});
|
47
|
+
//# sourceMappingURL=useMenuSplitGroup.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useMenuSplitGroup.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/useMenuSplitGroup.ts"],"names":[],"mappings":";;;;IAOA;;;;;;;;OAQG;IACI,IAAM,0BAA0B,GAAG,UACxC,KAA0B,EAC1B,GAA2B;QAE3B,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAe,CAAC;QACvC,IAAA,KAA0B,0CAAS,EAAE,EAAnC,GAAG,SAAA,EAA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AAE,+BAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,EACjC,SAAS,WAAA,IACN,KAAK,EACR;SACH,CAAC;IACJ,CAAC,CAAC;IA/CW,QAAA,0BAA0B,8BA+CrC","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"]}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
define(["require", "exports", "@griffel/react", "@fluentui/react-theme", "../MenuItem/useMenuItemStyles"], function (require, exports, react_1, react_theme_1, useMenuItemStyles_1) {
|
2
|
+
"use strict";
|
3
|
+
var _a;
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
5
|
+
exports.useMenuSplitGroupStyles_unstable = exports.menuSplitGroupClassNames = void 0;
|
6
|
+
exports.menuSplitGroupClassNames = {
|
7
|
+
root: 'fui-MenuSplitGroup',
|
8
|
+
};
|
9
|
+
/**
|
10
|
+
* Styles for the root slot
|
11
|
+
*/
|
12
|
+
var useStyles = react_1.makeStyles({
|
13
|
+
root: (_a = {
|
14
|
+
display: 'flex'
|
15
|
+
},
|
16
|
+
_a["& > ." + useMenuItemStyles_1.menuItemClassNames.root + ":nth-child(1)"] = {
|
17
|
+
width: '100%',
|
18
|
+
},
|
19
|
+
_a["& > ." + useMenuItemStyles_1.menuItemClassNames.root + ":nth-child(2)"] = {
|
20
|
+
borderTopLeftRadius: 0,
|
21
|
+
borderBottomLeftRadius: 0,
|
22
|
+
paddingLeft: 0,
|
23
|
+
marginLeft: 'auto',
|
24
|
+
'::before': {
|
25
|
+
content: '""',
|
26
|
+
width: react_theme_1.tokens.strokeWidthThin,
|
27
|
+
height: '24px',
|
28
|
+
backgroundColor: react_theme_1.tokens.colorNeutralStroke1,
|
29
|
+
},
|
30
|
+
},
|
31
|
+
_a),
|
32
|
+
});
|
33
|
+
/**
|
34
|
+
* Apply styling to the MenuSplitGroup slots based on the state
|
35
|
+
*/
|
36
|
+
var useMenuSplitGroupStyles_unstable = function (state) {
|
37
|
+
var styles = useStyles();
|
38
|
+
state.root.className = react_1.mergeClasses(exports.menuSplitGroupClassNames.root, styles.root, state.root.className);
|
39
|
+
return state;
|
40
|
+
};
|
41
|
+
exports.useMenuSplitGroupStyles_unstable = useMenuSplitGroupStyles_unstable;
|
42
|
+
});
|
43
|
+
//# sourceMappingURL=useMenuSplitGroupStyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useMenuSplitGroupStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuSplitGroup/useMenuSplitGroupStyles.ts"],"names":[],"mappings":";;;;;IAMa,QAAA,wBAAwB,GAAwC;QAC3E,IAAI,EAAE,oBAAoB;KAC3B,CAAC;IACF;;OAEG;IACH,IAAM,SAAS,GAAG,kBAAU,CAAC;QAC3B,IAAI;gBACF,OAAO,EAAE,MAAM;;YACf,GAAC,UAAQ,sCAAkB,CAAC,IAAI,kBAAe,IAAG;gBAChD,KAAK,EAAE,MAAM;aACd;YACD,GAAC,UAAQ,sCAAkB,CAAC,IAAI,kBAAe,IAAG;gBAChD,mBAAmB,EAAE,CAAC;gBACtB,sBAAsB,EAAE,CAAC;gBACzB,WAAW,EAAE,CAAC;gBACd,UAAU,EAAE,MAAM;gBAClB,UAAU,EAAE;oBACV,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,oBAAM,CAAC,eAAe;oBAC7B,MAAM,EAAE,MAAM;oBACd,eAAe,EAAE,oBAAM,CAAC,mBAAmB;iBAC5C;aACF;eACF;KACF,CAAC,CAAC;IAEH;;OAEG;IACI,IAAM,gCAAgC,GAAG,UAAC,KAA0B;QACzE,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,oBAAY,CAAC,gCAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtG,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAJW,QAAA,gCAAgC,oCAI3C","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"]}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
define(["require", "exports", "./useMenuTrigger", "./renderMenuTrigger"], function (require, exports, useMenuTrigger_1, renderMenuTrigger_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.MenuTrigger = void 0;
|
5
|
+
/**
|
6
|
+
* Wraps a trigger element as an only child
|
7
|
+
* and adds the necessary event handling to open a popup menu
|
8
|
+
*/
|
9
|
+
var MenuTrigger = function (props) {
|
10
|
+
var state = useMenuTrigger_1.useMenuTrigger_unstable(props);
|
11
|
+
return renderMenuTrigger_1.renderMenuTrigger_unstable(state);
|
12
|
+
};
|
13
|
+
exports.MenuTrigger = MenuTrigger;
|
14
|
+
exports.MenuTrigger.displayName = 'MenuTrigger';
|
15
|
+
// type casting here is required to ensure internal type FluentTriggerComponent is not leaked
|
16
|
+
exports.MenuTrigger.isFluentTriggerComponent = true;
|
17
|
+
});
|
18
|
+
//# sourceMappingURL=MenuTrigger.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MenuTrigger.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuTrigger/MenuTrigger.tsx"],"names":[],"mappings":";;;;IAMA;;;OAGG;IACI,IAAM,WAAW,GAA+B,UAAA,KAAK;QAC1D,IAAM,KAAK,GAAG,wCAAuB,CAAC,KAAK,CAAC,CAAC;QAE7C,OAAO,8CAA0B,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC,CAAC;IAJW,QAAA,WAAW,eAItB;IAEF,mBAAW,CAAC,WAAW,GAAG,aAAa,CAAC;IACxC,6FAA6F;IAC5F,mBAAsC,CAAC,wBAAwB,GAAG,IAAI,CAAC","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"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MenuTrigger.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuTrigger/MenuTrigger.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ARIAButtonResultProps, ARIAButtonType } from '@fluentui/react-aria';\nimport type { TriggerProps } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nexport type MenuTriggerProps = TriggerProps<MenuTriggerChildProps> & {\n /**\n * Disables internal trigger mechanism that ensures a child provided will be a compliant ARIA button.\n * @default false\n */\n disableButtonEnhancement?: boolean;\n};\n\n/**\n * Props that are passed to the child of the MenuTrigger when cloned to ensure correct behaviour for the Menu\n */\nexport type MenuTriggerChildProps<Type extends ARIAButtonType = ARIAButtonType, Props = {}> = ARIAButtonResultProps<\n Type,\n Props & {\n 'aria-haspopup'?: 'menu';\n 'aria-expanded'?: boolean;\n id: string;\n ref: React.Ref<never>;\n onMouseEnter: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;\n onMouseLeave: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;\n onMouseMove: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;\n onContextMenu: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;\n }\n>;\n\nexport type MenuTriggerState = {\n children: React.ReactElement | null;\n isSubmenu: boolean;\n};\n"]}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
define(["require", "exports", "tslib", "./MenuTrigger", "./MenuTrigger.types", "./renderMenuTrigger", "./useMenuTrigger"], function (require, exports, tslib_1, MenuTrigger_1, MenuTrigger_types_1, renderMenuTrigger_1, useMenuTrigger_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
tslib_1.__exportStar(MenuTrigger_1, exports);
|
5
|
+
tslib_1.__exportStar(MenuTrigger_types_1, exports);
|
6
|
+
tslib_1.__exportStar(renderMenuTrigger_1, exports);
|
7
|
+
tslib_1.__exportStar(useMenuTrigger_1, exports);
|
8
|
+
});
|
9
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuTrigger/index.ts"],"names":[],"mappings":";;;IAAA,6CAA8B;IAC9B,mDAAoC;IACpC,mDAAoC;IACpC,gDAAiC","sourcesContent":["export * from './MenuTrigger';\nexport * from './MenuTrigger.types';\nexport * from './renderMenuTrigger';\nexport * from './useMenuTrigger';\n"]}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
define(["require", "exports", "react", "../../contexts/menuTriggerContext"], function (require, exports, React, menuTriggerContext_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.renderMenuTrigger_unstable = void 0;
|
5
|
+
/**
|
6
|
+
* Render the final JSX of MenuTrigger
|
7
|
+
*
|
8
|
+
* Only renders children
|
9
|
+
*/
|
10
|
+
var renderMenuTrigger_unstable = function (state) {
|
11
|
+
return React.createElement(menuTriggerContext_1.MenuTriggerContextProvider, { value: state.isSubmenu }, state.children);
|
12
|
+
};
|
13
|
+
exports.renderMenuTrigger_unstable = renderMenuTrigger_unstable;
|
14
|
+
});
|
15
|
+
//# sourceMappingURL=renderMenuTrigger.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"renderMenuTrigger.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuTrigger/renderMenuTrigger.tsx"],"names":[],"mappings":";;;;IAIA;;;;OAIG;IACI,IAAM,0BAA0B,GAAG,UAAC,KAAuB;QAChE,OAAO,oBAAC,+CAA0B,IAAC,KAAK,EAAE,KAAK,CAAC,SAAS,IAAG,KAAK,CAAC,QAAQ,CAA8B,CAAC;IAC3G,CAAC,CAAC;IAFW,QAAA,0BAA0B,8BAErC","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"]}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
define(["require", "exports", "tslib", "react", "../../contexts/menuContext", "../../utils/useIsSubmenu", "@fluentui/react-tabster", "@fluentui/react-shared-contexts", "@fluentui/keyboard-keys", "@fluentui/react-utilities", "@fluentui/react-aria"], function (require, exports, tslib_1, React, menuContext_1, useIsSubmenu_1, react_tabster_1, react_shared_contexts_1, keyboard_keys_1, react_utilities_1, react_aria_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.useMenuTrigger_unstable = void 0;
|
5
|
+
/**
|
6
|
+
* Create the state required to render MenuTrigger.
|
7
|
+
* Clones the only child component and adds necessary event handling behaviours to open a popup menu
|
8
|
+
*
|
9
|
+
* @param props - props from this instance of MenuTrigger
|
10
|
+
*/
|
11
|
+
var useMenuTrigger_unstable = function (props) {
|
12
|
+
var children = props.children, _a = props.disableButtonEnhancement, disableButtonEnhancement = _a === void 0 ? false : _a;
|
13
|
+
var triggerRef = menuContext_1.useMenuContext_unstable(function (context) { return context.triggerRef; });
|
14
|
+
var menuPopoverRef = menuContext_1.useMenuContext_unstable(function (context) { return context.menuPopoverRef; });
|
15
|
+
var setOpen = menuContext_1.useMenuContext_unstable(function (context) { return context.setOpen; });
|
16
|
+
var open = menuContext_1.useMenuContext_unstable(function (context) { return context.open; });
|
17
|
+
var triggerId = menuContext_1.useMenuContext_unstable(function (context) { return context.triggerId; });
|
18
|
+
var openOnHover = menuContext_1.useMenuContext_unstable(function (context) { return context.openOnHover; });
|
19
|
+
var openOnContext = menuContext_1.useMenuContext_unstable(function (context) { return context.openOnContext; });
|
20
|
+
var isSubmenu = useIsSubmenu_1.useIsSubmenu();
|
21
|
+
var findFirstFocusable = react_tabster_1.useFocusFinders().findFirstFocusable;
|
22
|
+
var focusFirst = React.useCallback(function () {
|
23
|
+
var firstFocusable = findFirstFocusable(menuPopoverRef.current);
|
24
|
+
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
25
|
+
}, [findFirstFocusable, menuPopoverRef]);
|
26
|
+
var openedWithKeyboardRef = React.useRef(false);
|
27
|
+
var hasMouseMoved = React.useRef(false);
|
28
|
+
var dir = react_shared_contexts_1.useFluent_unstable().dir;
|
29
|
+
var OpenArrowKey = dir === 'ltr' ? keyboard_keys_1.ArrowRight : keyboard_keys_1.ArrowLeft;
|
30
|
+
var child = react_utilities_1.getTriggerChild(children);
|
31
|
+
var onContextMenu = function (event) {
|
32
|
+
if (isTargetDisabled(event)) {
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
if (openOnContext) {
|
36
|
+
event.preventDefault();
|
37
|
+
setOpen(event, { open: true, keyboard: false, type: 'menuTriggerContextMenu', event: event });
|
38
|
+
}
|
39
|
+
};
|
40
|
+
var onClick = function (event) {
|
41
|
+
if (isTargetDisabled(event)) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
if (!openOnContext) {
|
45
|
+
setOpen(event, { open: !open, keyboard: openedWithKeyboardRef.current, type: 'menuTriggerClick', event: event });
|
46
|
+
openedWithKeyboardRef.current = false;
|
47
|
+
}
|
48
|
+
};
|
49
|
+
var onKeyDown = function (event) {
|
50
|
+
if (isTargetDisabled(event)) {
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
var key = event.key;
|
54
|
+
if (!openOnContext && ((isSubmenu && key === OpenArrowKey) || (!isSubmenu && key === keyboard_keys_1.ArrowDown))) {
|
55
|
+
setOpen(event, { open: true, keyboard: true, type: 'menuTriggerKeyDown', event: event });
|
56
|
+
}
|
57
|
+
if (key === keyboard_keys_1.Escape && !isSubmenu) {
|
58
|
+
setOpen(event, { open: false, keyboard: true, type: 'menuTriggerKeyDown', event: event });
|
59
|
+
}
|
60
|
+
// if menu is already open, can't rely on effects to focus
|
61
|
+
if (open && key === OpenArrowKey && isSubmenu) {
|
62
|
+
focusFirst();
|
63
|
+
}
|
64
|
+
};
|
65
|
+
var onMouseEnter = function (event) {
|
66
|
+
if (isTargetDisabled(event)) {
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
if (openOnHover && hasMouseMoved.current) {
|
70
|
+
setOpen(event, { open: true, keyboard: false, type: 'menuTriggerMouseEnter', event: event });
|
71
|
+
}
|
72
|
+
};
|
73
|
+
// Opening a menu when a mouse hasn't moved and just entering the trigger is a bad a11y experience
|
74
|
+
// First time open the mouse using mousemove and then continue with mouseenter
|
75
|
+
// Only use once to determine that the user is using the mouse since it is an expensive event to handle
|
76
|
+
var onMouseMove = function (event) {
|
77
|
+
if (isTargetDisabled(event)) {
|
78
|
+
return;
|
79
|
+
}
|
80
|
+
if (openOnHover && !hasMouseMoved.current) {
|
81
|
+
setOpen(event, { open: true, keyboard: false, type: 'menuTriggerMouseMove', event: event });
|
82
|
+
hasMouseMoved.current = true;
|
83
|
+
}
|
84
|
+
};
|
85
|
+
var onMouseLeave = function (event) {
|
86
|
+
if (isTargetDisabled(event)) {
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
if (openOnHover) {
|
90
|
+
setOpen(event, { open: false, keyboard: false, type: 'menuTriggerMouseLeave', event: event });
|
91
|
+
}
|
92
|
+
};
|
93
|
+
var contextMenuProps = tslib_1.__assign(tslib_1.__assign({ id: triggerId }, child === null || child === void 0 ? void 0 : child.props), { ref: react_utilities_1.useMergedRefs(triggerRef, child === null || child === void 0 ? void 0 : child.ref), onMouseEnter: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onMouseEnter, onMouseEnter)), onMouseLeave: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onMouseLeave, onMouseLeave)), onContextMenu: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onContextMenu, onContextMenu)), onMouseMove: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onMouseMove, onMouseMove)) });
|
94
|
+
var triggerChildProps = tslib_1.__assign(tslib_1.__assign({ 'aria-haspopup': 'menu', 'aria-expanded': !open && !isSubmenu ? undefined : open }, contextMenuProps), { onClick: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onClick, onClick)), onKeyDown: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onKeyDown, onKeyDown)) });
|
95
|
+
var ariaButtonTriggerChildProps = react_aria_1.useARIAButtonProps((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', triggerChildProps);
|
96
|
+
return {
|
97
|
+
isSubmenu: isSubmenu,
|
98
|
+
children: react_utilities_1.applyTriggerPropsToChildren(children, openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps),
|
99
|
+
};
|
100
|
+
};
|
101
|
+
exports.useMenuTrigger_unstable = useMenuTrigger_unstable;
|
102
|
+
var isTargetDisabled = function (e) {
|
103
|
+
var isDisabled = function (el) {
|
104
|
+
return el.hasAttribute('disabled') || (el.hasAttribute('aria-disabled') && el.getAttribute('aria-disabled') === 'true');
|
105
|
+
};
|
106
|
+
if (e.target instanceof HTMLElement && isDisabled(e.target)) {
|
107
|
+
return true;
|
108
|
+
}
|
109
|
+
return e.currentTarget instanceof HTMLElement && isDisabled(e.currentTarget);
|
110
|
+
};
|
111
|
+
});
|
112
|
+
//# sourceMappingURL=useMenuTrigger.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useMenuTrigger.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-menu/src/components/MenuTrigger/useMenuTrigger.ts"],"names":[],"mappings":";;;;IAgBA;;;;;OAKG;IACI,IAAM,uBAAuB,GAAG,UAAC,KAAuB;QACrD,IAAA,QAAQ,GAAuC,KAAK,SAA5C,EAAE,KAAqC,KAAK,yBAAV,EAAhC,wBAAwB,mBAAG,KAAK,KAAA,CAAW;QAE7D,IAAM,UAAU,GAAG,qCAAuB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,UAAU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AS,CAAC,CAAC,GACtE,CAAC;QAEX,IAAM,2BAA2B,GAAG,+BAAkB,CACpD,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,QAAQ,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EACpE,iBAAiB,CAClB,CAAC;QAEF,OAAO;YACL,SAAS,WAAA;YACT,QAAQ,EAAE,6CAA2B,CACnC,QAAQ,EACR,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,2BAA2B,CAC9G;SACF,CAAC;IACJ,CAAC,CAAC;IAnIW,QAAA,uBAAuB,2BAmIlC;IAEF,IAAM,gBAAgB,GAAG,UAAC,CAA+B;QACvD,IAAM,UAAU,GAAG,UAAC,EAAe;YACjC,OAAA,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;QAAhH,CAAgH,CAAC;QACnH,IAAI,CAAC,CAAC,MAAM,YAAY,WAAW,IAAI,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;YAC3D,OAAO,IAAI,CAAC;SACb;QAED,OAAO,CAAC,CAAC,aAAa,YAAY,WAAW,IAAI,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;IAC/E,CAAC,CAAC","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"]}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
define(["require", "exports", "tslib", "./MenuItem/index", "./MenuList/index"], function (require, exports, tslib_1, index_1, index_2) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
tslib_1.__exportStar(index_1, exports);
|
5
|
+
tslib_1.__exportStar(index_2, exports);
|
6
|
+
});
|
7
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-menu/src/components/index.ts"],"names":[],"mappings":";;;IAAA,uCAAiC;IACjC,uCAAiC","sourcesContent":["export * from './MenuItem/index';\nexport * from './MenuList/index';\n"]}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
define(["require", "exports", "@fluentui/react-context-selector"], function (require, exports, react_context_selector_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.useMenuContext_unstable = exports.MenuProvider = exports.MenuContext = void 0;
|
5
|
+
exports.MenuContext = react_context_selector_1.createContext(undefined);
|
6
|
+
var menuContextDefaultValue = {
|
7
|
+
open: false,
|
8
|
+
setOpen: function () { return false; },
|
9
|
+
checkedValues: {},
|
10
|
+
onCheckedValueChange: function () { return null; },
|
11
|
+
defaultCheckedValues: {},
|
12
|
+
isSubmenu: false,
|
13
|
+
triggerRef: { current: null },
|
14
|
+
menuPopoverRef: { current: null },
|
15
|
+
triggerId: '',
|
16
|
+
openOnContext: false,
|
17
|
+
openOnHover: false,
|
18
|
+
hasIcons: false,
|
19
|
+
hasCheckmarks: false,
|
20
|
+
inline: false,
|
21
|
+
persistOnItemClick: false,
|
22
|
+
};
|
23
|
+
exports.MenuProvider = exports.MenuContext.Provider;
|
24
|
+
var useMenuContext_unstable = function (selector) {
|
25
|
+
return react_context_selector_1.useContextSelector(exports.MenuContext, function (ctx) {
|
26
|
+
if (ctx === void 0) { ctx = menuContextDefaultValue; }
|
27
|
+
return selector(ctx);
|
28
|
+
});
|
29
|
+
};
|
30
|
+
exports.useMenuContext_unstable = useMenuContext_unstable;
|
31
|
+
});
|
32
|
+
//# sourceMappingURL=menuContext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"menuContext.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-menu/src/contexts/menuContext.ts"],"names":[],"mappings":";;;;IAKa,QAAA,WAAW,GAA8B,sCAAa,CACjE,SAAS,CACmB,CAAC;IAE/B,IAAM,uBAAuB,GAAqB;QAChD,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;QACpB,aAAa,EAAE,EAAE;QACjB,oBAAoB,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QAChC,oBAAoB,EAAE,EAAE;QACxB,SAAS,EAAE,KAAK;QAChB,UAAU,EAAG,EAAE,OAAO,EAAE,IAAI,EAAqD;QACjF,cAAc,EAAG,EAAE,OAAO,EAAE,IAAI,EAAqD;QACrF,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,KAAK;QACpB,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,KAAK;QACpB,MAAM,EAAE,KAAK;QACb,kBAAkB,EAAE,KAAK;KAC1B,CAAC;IA4BW,QAAA,YAAY,GAAG,mBAAW,CAAC,QAAQ,CAAC;IAE1C,IAAM,uBAAuB,GAAG,UAAI,QAA8C;QACvF,OAAA,2CAAkB,CAAC,mBAAW,EAAE,UAAC,GAA6B;YAA7B,oBAAA,EAAA,6BAA6B;YAAK,OAAA,QAAQ,CAAC,GAAG,CAAC;QAAb,CAAa,CAAC;IAAjF,CAAiF,CAAC;IADvE,QAAA,uBAAuB,2BACgD","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 defaultCheckedValues: {},\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 | 'defaultCheckedValues'\n> & {\n open: boolean;\n triggerId: 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"]}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
define(["require", "exports", "react"], function (require, exports, React) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.useMenuGroupContext_unstable = exports.MenuGroupContextProvider = void 0;
|
5
|
+
var MenuGroupContext = React.createContext(undefined);
|
6
|
+
var menuGroupContextDefaultValue = {
|
7
|
+
headerId: '',
|
8
|
+
};
|
9
|
+
exports.MenuGroupContextProvider = MenuGroupContext.Provider;
|
10
|
+
var useMenuGroupContext_unstable = function () { var _a; return (_a = React.useContext(MenuGroupContext)) !== null && _a !== void 0 ? _a : menuGroupContextDefaultValue; };
|
11
|
+
exports.useMenuGroupContext_unstable = useMenuGroupContext_unstable;
|
12
|
+
});
|
13
|
+
//# sourceMappingURL=menuGroupContext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"menuGroupContext.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-menu/src/contexts/menuGroupContext.ts"],"names":[],"mappings":";;;;IAEA,IAAM,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAC1C,SAAS,CAC8B,CAAC;IAE1C,IAAM,4BAA4B,GAA0B;QAC1D,QAAQ,EAAE,EAAE;KACb,CAAC;IAaW,QAAA,wBAAwB,GAAG,gBAAgB,CAAC,QAAQ,CAAC;IAC3D,IAAM,4BAA4B,GAAG,sBAAM,OAAA,MAAA,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,mCAAI,4BAA4B,CAAA,EAAA,CAAC;IAAxG,QAAA,4BAA4B,gCAA4E","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"]}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
define(["require", "exports", "@fluentui/react-context-selector"], function (require, exports, react_context_selector_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.useMenuListContext_unstable = exports.MenuListProvider = exports.MenuListContext = void 0;
|
5
|
+
exports.MenuListContext = react_context_selector_1.createContext(undefined);
|
6
|
+
var menuListContextDefaultValue = {
|
7
|
+
checkedValues: {},
|
8
|
+
onCheckedValueChange: function () { return null; },
|
9
|
+
setFocusByFirstCharacter: function () { return null; },
|
10
|
+
toggleCheckbox: function () { return null; },
|
11
|
+
selectRadio: function () { return null; },
|
12
|
+
hasIcons: false,
|
13
|
+
hasCheckmarks: false,
|
14
|
+
};
|
15
|
+
exports.MenuListProvider = exports.MenuListContext.Provider;
|
16
|
+
var useMenuListContext_unstable = function (selector) {
|
17
|
+
return react_context_selector_1.useContextSelector(exports.MenuListContext, function (ctx) {
|
18
|
+
if (ctx === void 0) { ctx = menuListContextDefaultValue; }
|
19
|
+
return selector(ctx);
|
20
|
+
});
|
21
|
+
};
|
22
|
+
exports.useMenuListContext_unstable = useMenuListContext_unstable;
|
23
|
+
});
|
24
|
+
//# sourceMappingURL=menuListContext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"menuListContext.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-menu/src/contexts/menuListContext.tsx"],"names":[],"mappings":";;;;IAMa,QAAA,eAAe,GAAkC,sCAAa,CACzE,SAAS,CACuB,CAAC;IAEnC,IAAM,2BAA2B,GAAyB;QACxD,aAAa,EAAE,EAAE;QACjB,oBAAoB,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QAChC,wBAAwB,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QACpC,cAAc,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QAC1B,WAAW,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QACvB,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,KAAK;KACrB,CAAC;IAcW,QAAA,gBAAgB,GAAG,uBAAe,CAAC,QAAQ,CAAC;IAElD,IAAM,2BAA2B,GAAG,UAAK,QAAkD;QAChG,OAAA,2CAAkB,CAAC,uBAAe,EAAE,UAAC,GAAiC;YAAjC,oBAAA,EAAA,iCAAiC;YAAK,OAAA,QAAQ,CAAC,GAAG,CAAC;QAAb,CAAa,CAAC;IAAzF,CAAyF,CAAC;IAD/E,QAAA,2BAA2B,+BACoD","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 { SelectableHandler } from '../selectable/index';\nimport type { MenuListProps } from '../components/index';\n\nexport const MenuListContext: Context<MenuListContextValue> = createContext<MenuListContextValue | undefined>(\n undefined,\n) as Context<MenuListContextValue>;\n\nconst menuListContextDefaultValue: MenuListContextValue = {\n checkedValues: {},\n onCheckedValueChange: () => null,\n setFocusByFirstCharacter: () => null,\n toggleCheckbox: () => null,\n selectRadio: () => null,\n hasIcons: false,\n hasCheckmarks: false,\n};\n\n/**\n * Context shared between MenuList and its children components\n */\nexport type MenuListContextValue = Pick<\n MenuListProps,\n 'checkedValues' | 'onCheckedValueChange' | 'hasIcons' | 'hasCheckmarks'\n> & {\n setFocusByFirstCharacter?: (e: React.KeyboardEvent<HTMLElement>, itemEl: HTMLElement) => void;\n toggleCheckbox?: SelectableHandler;\n selectRadio?: SelectableHandler;\n};\n\nexport const MenuListProvider = MenuListContext.Provider;\n\nexport const useMenuListContext_unstable = <T,>(selector: ContextSelector<MenuListContextValue, T>) =>\n useContextSelector(MenuListContext, (ctx = menuListContextDefaultValue) => selector(ctx));\n"]}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
define(["require", "exports", "react"], function (require, exports, React) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.useMenuTriggerContext_unstable = exports.MenuTriggerContextProvider = void 0;
|
5
|
+
/**
|
6
|
+
* Context used communicate with a child menu item that it is a trigger for a submenu
|
7
|
+
*/
|
8
|
+
var MenuTriggerContext = React.createContext(undefined);
|
9
|
+
var menuTriggerContextDefaultValue = false;
|
10
|
+
exports.MenuTriggerContextProvider = MenuTriggerContext.Provider;
|
11
|
+
var useMenuTriggerContext_unstable = function () { var _a; return (_a = React.useContext(MenuTriggerContext)) !== null && _a !== void 0 ? _a : menuTriggerContextDefaultValue; };
|
12
|
+
exports.useMenuTriggerContext_unstable = useMenuTriggerContext_unstable;
|
13
|
+
});
|
14
|
+
//# sourceMappingURL=menuTriggerContext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"menuTriggerContext.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-menu/src/contexts/menuTriggerContext.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACH,IAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAAsB,SAAS,CAA2B,CAAC;IAEzG,IAAM,8BAA8B,GAAG,KAAK,CAAC;IAEhC,QAAA,0BAA0B,GAAG,kBAAkB,CAAC,QAAQ,CAAC;IAC/D,IAAM,8BAA8B,GAAG,sBAC5C,OAAA,MAAA,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,mCAAI,8BAA8B,CAAA,EAAA,CAAC;IAD5D,QAAA,8BAA8B,kCAC8B","sourcesContent":["import * as React from 'react';\n\n/**\n * Context used communicate with a child menu item that it is a trigger for a submenu\n */\nconst MenuTriggerContext = React.createContext<boolean | undefined>(undefined) as React.Context<boolean>;\n\nconst menuTriggerContextDefaultValue = false;\n\nexport const MenuTriggerContextProvider = MenuTriggerContext.Provider;\nexport const useMenuTriggerContext_unstable = () =>\n React.useContext(MenuTriggerContext) ?? menuTriggerContextDefaultValue;\n"]}
|