@fluentui/react-menu 9.5.3 → 9.5.4
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +72 -1
- package/CHANGELOG.md +18 -2
- package/lib/components/Menu/Menu.js +0 -1
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/renderMenu.js +0 -1
- package/lib/components/Menu/renderMenu.js.map +1 -1
- package/lib/components/Menu/useMenu.js +16 -34
- package/lib/components/Menu/useMenu.js.map +1 -1
- package/lib/components/Menu/useMenuContextValues.js +2 -2
- package/lib/components/Menu/useMenuContextValues.js.map +1 -1
- package/lib/components/MenuDivider/MenuDivider.js +0 -1
- package/lib/components/MenuDivider/MenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/renderMenuDivider.js +2 -2
- package/lib/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDivider.js +0 -1
- package/lib/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDividerStyles.js +10 -12
- package/lib/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib/components/MenuGroup/MenuGroup.js +0 -1
- package/lib/components/MenuGroup/MenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/renderMenuGroup.js +2 -2
- package/lib/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroup.js +0 -1
- package/lib/components/MenuGroup/useMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroupContextValues.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroupStyles.js.map +1 -1
- package/lib/components/MenuGroupHeader/MenuGroupHeader.js +0 -1
- package/lib/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js +2 -2
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js +0 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +10 -12
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib/components/MenuItem/MenuItem.js +0 -1
- package/lib/components/MenuItem/MenuItem.js.map +1 -1
- package/lib/components/MenuItem/renderMenuItem.js +12 -7
- package/lib/components/MenuItem/renderMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useCharacterSearch.js +0 -5
- package/lib/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib/components/MenuItem/useMenuItem.js +0 -6
- package/lib/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useMenuItemStyles.js +108 -117
- package/lib/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.js +0 -1
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js +10 -6
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js +2 -4
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +0 -5
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib/components/MenuItemRadio/MenuItemRadio.js +0 -1
- package/lib/components/MenuItemRadio/MenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js +10 -6
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadio.js +3 -4
- package/lib/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js +0 -5
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib/components/MenuList/MenuList.js +0 -1
- package/lib/components/MenuList/MenuList.js.map +1 -1
- package/lib/components/MenuList/renderMenuList.js +2 -2
- package/lib/components/MenuList/renderMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuList.js +10 -27
- package/lib/components/MenuList/useMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuListContextValues.js +2 -2
- package/lib/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib/components/MenuList/useMenuListStyles.js +6 -9
- package/lib/components/MenuList/useMenuListStyles.js.map +1 -1
- package/lib/components/MenuPopover/MenuPopover.js +0 -1
- package/lib/components/MenuPopover/MenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/renderMenuPopover.js +4 -5
- package/lib/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopover.js +6 -13
- package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopoverStyles.js +32 -35
- package/lib/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib/components/MenuSplitGroup/MenuSplitGroup.js +0 -1
- package/lib/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -1
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.js +2 -2
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -1
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js +0 -6
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -1
- package/lib/components/MenuSplitGroup/useMenuSplitGroupStyles.js +12 -15
- package/lib/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -1
- package/lib/components/MenuTrigger/MenuTrigger.js +2 -3
- package/lib/components/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/renderMenuTrigger.js +0 -1
- package/lib/components/MenuTrigger/renderMenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/useMenuTrigger.js +4 -24
- package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib/contexts/menuContext.js.map +1 -1
- package/lib/contexts/menuGroupContext.js +0 -1
- package/lib/contexts/menuGroupContext.js.map +1 -1
- package/lib/contexts/menuListContext.js.map +1 -1
- package/lib/contexts/menuTriggerContext.js +0 -2
- package/lib/contexts/menuTriggerContext.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/selectable/useCheckmarkStyles.js +7 -11
- package/lib/selectable/useCheckmarkStyles.js.map +1 -1
- package/lib/utils/useIsSubmenu.js +0 -1
- package/lib/utils/useIsSubmenu.js.map +1 -1
- package/lib/utils/useOnMenuEnter.js +4 -11
- package/lib/utils/useOnMenuEnter.js.map +1 -1
- package/lib-commonjs/Menu.js +0 -2
- package/lib-commonjs/Menu.js.map +1 -1
- package/lib-commonjs/MenuDivider.js +0 -2
- package/lib-commonjs/MenuDivider.js.map +1 -1
- package/lib-commonjs/MenuGroup.js +0 -2
- package/lib-commonjs/MenuGroup.js.map +1 -1
- package/lib-commonjs/MenuGroupHeader.js +0 -2
- package/lib-commonjs/MenuGroupHeader.js.map +1 -1
- package/lib-commonjs/MenuItem.js +0 -2
- package/lib-commonjs/MenuItem.js.map +1 -1
- package/lib-commonjs/MenuItemCheckbox.js +0 -2
- package/lib-commonjs/MenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/MenuItemRadio.js +0 -2
- package/lib-commonjs/MenuItemRadio.js.map +1 -1
- package/lib-commonjs/MenuList.js +0 -2
- package/lib-commonjs/MenuList.js.map +1 -1
- package/lib-commonjs/MenuPopover.js +0 -2
- package/lib-commonjs/MenuPopover.js.map +1 -1
- package/lib-commonjs/MenuSplitGroup.js +0 -2
- package/lib-commonjs/MenuSplitGroup.js.map +1 -1
- package/lib-commonjs/MenuTrigger.js +0 -2
- package/lib-commonjs/MenuTrigger.js.map +1 -1
- package/lib-commonjs/components/Menu/Menu.js +0 -6
- package/lib-commonjs/components/Menu/Menu.js.map +1 -1
- package/lib-commonjs/components/Menu/Menu.types.js.map +1 -1
- package/lib-commonjs/components/Menu/index.js +0 -6
- package/lib-commonjs/components/Menu/index.js.map +1 -1
- package/lib-commonjs/components/Menu/renderMenu.js +0 -5
- package/lib-commonjs/components/Menu/renderMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenu.js +16 -46
- package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenuContextValues.js +2 -4
- package/lib-commonjs/components/Menu/useMenuContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/MenuDivider.js +0 -6
- package/lib-commonjs/components/MenuDivider/MenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/MenuDivider.types.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/index.js +0 -6
- package/lib-commonjs/components/MenuDivider/index.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.js +2 -6
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/useMenuDivider.js +0 -4
- package/lib-commonjs/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js +10 -16
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/MenuGroup.js +0 -7
- package/lib-commonjs/components/MenuGroup/MenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/MenuGroup.types.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/index.js +0 -7
- package/lib-commonjs/components/MenuGroup/index.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.js +2 -7
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroup.js +0 -4
- package/lib-commonjs/components/MenuGroup/useMenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.js +0 -3
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js +0 -4
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.js +0 -6
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.types.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/index.js +0 -6
- package/lib-commonjs/components/MenuGroupHeader/index.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.js +2 -6
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.js +0 -5
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +10 -16
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItem/MenuItem.js +0 -6
- package/lib-commonjs/components/MenuItem/MenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/MenuItem.types.js.map +1 -1
- package/lib-commonjs/components/MenuItem/index.js +0 -6
- package/lib-commonjs/components/MenuItem/index.js.map +1 -1
- package/lib-commonjs/components/MenuItem/renderMenuItem.js +12 -11
- package/lib-commonjs/components/MenuItem/renderMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js +0 -8
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItem.js +0 -18
- package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js +108 -124
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.js +0 -6
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.types.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/index.js +0 -6
- package/lib-commonjs/components/MenuItemCheckbox/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.js +10 -10
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js +2 -11
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +0 -11
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.js +0 -6
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.types.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/index.js +0 -6
- package/lib-commonjs/components/MenuItemRadio/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.js +10 -10
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js +3 -11
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js +0 -11
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib-commonjs/components/MenuList/MenuList.js +0 -7
- package/lib-commonjs/components/MenuList/MenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/MenuList.types.js.map +1 -1
- package/lib-commonjs/components/MenuList/index.js +0 -7
- package/lib-commonjs/components/MenuList/index.js.map +1 -1
- package/lib-commonjs/components/MenuList/renderMenuList.js +2 -7
- package/lib-commonjs/components/MenuList/renderMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuList.js +10 -35
- package/lib-commonjs/components/MenuList/useMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListContextValues.js +2 -4
- package/lib-commonjs/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListStyles.js +6 -12
- package/lib-commonjs/components/MenuList/useMenuListStyles.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/MenuPopover.js +0 -6
- package/lib-commonjs/components/MenuPopover/MenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/MenuPopover.types.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/index.js +0 -6
- package/lib-commonjs/components/MenuPopover/index.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.js +4 -10
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js +6 -22
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js +32 -39
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.js +0 -6
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.types.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/index.js +0 -6
- package/lib-commonjs/components/MenuSplitGroup/index.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/renderMenuSplitGroup.js +2 -6
- package/lib-commonjs/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroup.js +0 -13
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroupStyles.js +12 -20
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.js +2 -7
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.types.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/index.js +0 -5
- package/lib-commonjs/components/MenuTrigger/index.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.js +0 -5
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +4 -34
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib-commonjs/components/index.js +0 -3
- package/lib-commonjs/components/index.js.map +1 -1
- package/lib-commonjs/contexts/menuContext.js +0 -4
- package/lib-commonjs/contexts/menuContext.js.map +1 -1
- package/lib-commonjs/contexts/menuGroupContext.js +0 -5
- package/lib-commonjs/contexts/menuGroupContext.js.map +1 -1
- package/lib-commonjs/contexts/menuListContext.js +0 -4
- package/lib-commonjs/contexts/menuListContext.js.map +1 -1
- package/lib-commonjs/contexts/menuTriggerContext.js +0 -6
- package/lib-commonjs/contexts/menuTriggerContext.js.map +1 -1
- package/lib-commonjs/index.js +0 -32
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/selectable/index.js +0 -3
- package/lib-commonjs/selectable/index.js.map +1 -1
- package/lib-commonjs/selectable/types.js.map +1 -1
- package/lib-commonjs/selectable/useCheckmarkStyles.js +7 -13
- package/lib-commonjs/selectable/useCheckmarkStyles.js.map +1 -1
- package/lib-commonjs/utils/index.js +0 -2
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/useIsSubmenu.js +0 -6
- package/lib-commonjs/utils/useIsSubmenu.js.map +1 -1
- package/lib-commonjs/utils/useOnMenuEnter.js +4 -17
- package/lib-commonjs/utils/useOnMenuEnter.js.map +1 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AAC","names":["React","resolveShorthand","Checkmark16Filled","useMenuListContext_unstable","useMenuItem_unstable","useMenuItemRadio_unstable","props","ref","name","value","checked","context","checkedItems","checkedValues","indexOf","selectRadio","role","checkmark","defaultProps","children","required","onClick","e"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuItemRadio/useMenuItemRadio.tsx"],"sourcesContent":["import * as React from 'react';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { Checkmark16Filled } from '@fluentui/react-icons';\nimport { useMenuListContext_unstable } from '../../contexts/menuListContext';\nimport { useMenuItem_unstable } from '../MenuItem/useMenuItem';\nimport type { MenuItemRadioProps, MenuItemRadioState } from './MenuItemRadio.types';\nimport type { ARIAButtonElement, ARIAButtonElementIntersection } from '@fluentui/react-aria';\n\n/**\n * Given user props, returns state and render function for a MenuItemRadio.\n */\nexport const useMenuItemRadio_unstable = (\n props: MenuItemRadioProps,\n ref: React.Ref<ARIAButtonElement<'div'>>,\n): MenuItemRadioState => {\n const { name, value } = props;\n\n const checked = useMenuListContext_unstable(context => {\n const checkedItems = context.checkedValues?.[name] || [];\n return checkedItems.indexOf(value) !== -1;\n });\n\n const selectRadio = useMenuListContext_unstable(context => context.selectRadio);\n\n return {\n ...useMenuItem_unstable(\n {\n ...props,\n role: 'menuitemradio',\n 'aria-checked': checked,\n checkmark: resolveShorthand(props.checkmark, {\n defaultProps: { children: <Checkmark16Filled /> },\n required: true,\n }),\n onClick: (e: React.MouseEvent<ARIAButtonElementIntersection<'div'>>) => {\n selectRadio?.(e, name, value, checked);\n props.onClick?.(e);\n },\n },\n ref,\n ),\n checked,\n name,\n value,\n };\n};\n"]}
|
@@ -10,23 +10,18 @@ export const menuItemRadioClassNames = {
|
|
10
10
|
};
|
11
11
|
export const useMenuItemRadioStyles_unstable = state => {
|
12
12
|
state.root.className = mergeClasses(menuItemRadioClassNames.root, state.root.className);
|
13
|
-
|
14
13
|
if (state.content) {
|
15
14
|
state.content.className = mergeClasses(menuItemRadioClassNames.content, state.content.className);
|
16
15
|
}
|
17
|
-
|
18
16
|
if (state.secondaryContent) {
|
19
17
|
state.secondaryContent.className = mergeClasses(menuItemRadioClassNames.secondaryContent, state.secondaryContent.className);
|
20
18
|
}
|
21
|
-
|
22
19
|
if (state.icon) {
|
23
20
|
state.icon.className = mergeClasses(menuItemRadioClassNames.icon, state.icon.className);
|
24
21
|
}
|
25
|
-
|
26
22
|
if (state.checkmark) {
|
27
23
|
state.checkmark.className = mergeClasses(menuItemRadioClassNames.checkmark, state.checkmark.className);
|
28
24
|
}
|
29
|
-
|
30
25
|
useMenuItemStyles_unstable(state);
|
31
26
|
useCheckmarkStyles_unstable(state);
|
32
27
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,2BAA2B,QAAQ,wBAAwB;AACpE,SAASC,0BAA0B,QAAQ,+BAA+B;AAK1E,OAAO,MAAMC,uBAAuB,GAA4D;EAC9FC,IAAI,EAAE,mBAAmB;EACzBC,IAAI,EAAE,yBAAyB;EAC/BC,SAAS,EAAE,8BAA8B;EACzCC,OAAO,EAAE,4BAA4B;EACrCC,gBAAgB,EAAE;CACnB;AAED,OAAO,MAAMC,+BAA+B,GAAIC,KAAyB,IAAI;EAC3EA,KAAK,CAACN,IAAI,CAACO,SAAS,GAAGX,YAAY,CAACG,uBAAuB,CAACC,IAAI,EAAEM,KAAK,CAACN,IAAI,CAACO,SAAS,CAAC;EAEvF,IAAID,KAAK,CAACH,OAAO,EAAE;IACjBG,KAAK,CAACH,OAAO,CAACI,SAAS,GAAGX,YAAY,CAACG,uBAAuB,CAACI,OAAO,EAAEG,KAAK,CAACH,OAAO,CAACI,SAAS,CAAC;;EAGlG,IAAID,KAAK,CAACF,gBAAgB,EAAE;IAC1BE,KAAK,CAACF,gBAAgB,CAACG,SAAS,GAAGX,YAAY,CAC7CG,uBAAuB,CAACK,gBAAgB,EACxCE,KAAK,CAACF,gBAAgB,CAACG,SAAS,CACjC;;EAGH,IAAID,KAAK,CAACL,IAAI,EAAE;IACdK,KAAK,CAACL,IAAI,CAACM,SAAS,GAAGX,YAAY,CAACG,uBAAuB,CAACE,IAAI,EAAEK,KAAK,CAACL,IAAI,CAACM,SAAS,CAAC;;EAGzF,IAAID,KAAK,CAACJ,SAAS,EAAE;IACnBI,KAAK,CAACJ,SAAS,CAACK,SAAS,GAAGX,YAAY,CAACG,uBAAuB,CAACG,SAAS,EAAEI,KAAK,CAACJ,SAAS,CAACK,SAAS,CAAC;;EAGxGT,0BAA0B,CAACQ,KAAK,CAAC;EACjCT,2BAA2B,CAACS,KAAK,CAAC;AACpC,CAAC","names":["mergeClasses","useCheckmarkStyles_unstable","useMenuItemStyles_unstable","menuItemRadioClassNames","root","icon","checkmark","content","secondaryContent","useMenuItemRadioStyles_unstable","state","className"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuItemRadio/useMenuItemRadioStyles.ts"],"sourcesContent":["import { mergeClasses } from '@griffel/react';\nimport { useCheckmarkStyles_unstable } from '../../selectable/index';\nimport { useMenuItemStyles_unstable } from '../MenuItem/useMenuItemStyles';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { MenuItemSlots } from '../index';\nimport type { MenuItemRadioState } from './MenuItemRadio.types';\n\nexport const menuItemRadioClassNames: SlotClassNames<Omit<MenuItemSlots, 'submenuIndicator'>> = {\n root: 'fui-MenuItemRadio',\n icon: 'fui-MenuItemRadio__icon',\n checkmark: 'fui-MenuItemRadio__checkmark',\n content: 'fui-MenuItemRadio__content',\n secondaryContent: 'fui-MenuItemRadio__secondaryContent',\n};\n\nexport const useMenuItemRadioStyles_unstable = (state: MenuItemRadioState) => {\n state.root.className = mergeClasses(menuItemRadioClassNames.root, state.root.className);\n\n if (state.content) {\n state.content.className = mergeClasses(menuItemRadioClassNames.content, state.content.className);\n }\n\n if (state.secondaryContent) {\n state.secondaryContent.className = mergeClasses(\n menuItemRadioClassNames.secondaryContent,\n state.secondaryContent.className,\n );\n }\n\n if (state.icon) {\n state.icon.className = mergeClasses(menuItemRadioClassNames.icon, state.icon.className);\n }\n\n if (state.checkmark) {\n state.checkmark.className = mergeClasses(menuItemRadioClassNames.checkmark, state.checkmark.className);\n }\n\n useMenuItemStyles_unstable(state);\n useCheckmarkStyles_unstable(state);\n};\n"]}
|
@@ -6,7 +6,6 @@ import { useMenuListStyles_unstable } from './useMenuListStyles';
|
|
6
6
|
/**
|
7
7
|
* Define a styled MenuList, using the `useMenuList_unstable` hook.
|
8
8
|
*/
|
9
|
-
|
10
9
|
export const MenuList = /*#__PURE__*/React.forwardRef((props, ref) => {
|
11
10
|
const state = useMenuList_unstable(props, ref);
|
12
11
|
const contextValues = useMenuListContextValues_unstable(state);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,SAASC,iCAAiC,QAAQ,4BAA4B;AAC9E,SAASC,0BAA0B,QAAQ,qBAAqB;AAIhE;;;AAGA,OAAO,MAAMC,QAAQ,gBAAuCL,KAAK,CAACM,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EAC1F,MAAMC,KAAK,GAAGR,oBAAoB,CAACM,KAAK,EAAEC,GAAG,CAAC;EAC9C,MAAME,aAAa,GAAGP,iCAAiC,CAACM,KAAK,CAAC;EAC9DL,0BAA0B,CAACK,KAAK,CAAC;EAEjC,OAAOP,uBAAuB,CAACO,KAAK,EAAEC,aAAa,CAAC;AACtD,CAAC,CAAC;AAEFL,QAAQ,CAACM,WAAW,GAAG,UAAU","names":["React","useMenuList_unstable","renderMenuList_unstable","useMenuListContextValues_unstable","useMenuListStyles_unstable","MenuList","forwardRef","props","ref","state","contextValues","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuList/MenuList.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMenuList_unstable } from './useMenuList';\nimport { renderMenuList_unstable } from './renderMenuList';\nimport { useMenuListContextValues_unstable } from './useMenuListContextValues';\nimport { useMenuListStyles_unstable } from './useMenuListStyles';\nimport type { MenuListProps } from './MenuList.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Define a styled MenuList, using the `useMenuList_unstable` hook.\n */\nexport const MenuList: ForwardRefComponent<MenuListProps> = React.forwardRef((props, ref) => {\n const state = useMenuList_unstable(props, ref);\n const contextValues = useMenuListContextValues_unstable(state);\n useMenuListStyles_unstable(state);\n\n return renderMenuList_unstable(state, contextValues);\n});\n\nMenuList.displayName = 'MenuList';\n"]}
|
@@ -4,7 +4,6 @@ import { MenuListProvider } from '../../contexts/menuListContext';
|
|
4
4
|
/**
|
5
5
|
* Function that renders the final JSX of the component
|
6
6
|
*/
|
7
|
-
|
8
7
|
export const renderMenuList_unstable = (state, contextValues) => {
|
9
8
|
const {
|
10
9
|
slots,
|
@@ -12,7 +11,8 @@ export const renderMenuList_unstable = (state, contextValues) => {
|
|
12
11
|
} = getSlots(state);
|
13
12
|
return /*#__PURE__*/React.createElement(MenuListProvider, {
|
14
13
|
value: contextValues.menuList
|
15
|
-
}, /*#__PURE__*/React.createElement(slots.root, {
|
14
|
+
}, /*#__PURE__*/React.createElement(slots.root, {
|
15
|
+
...slotProps.root
|
16
16
|
}));
|
17
17
|
};
|
18
18
|
//# sourceMappingURL=renderMenuList.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,QAAQ,2BAA2B;AAEpD,SAASC,gBAAgB,QAAQ,gCAAgC;AAEjE;;;AAGA,OAAO,MAAMC,uBAAuB,GAAG,CAACC,KAAoB,EAAEC,aAAoC,KAAI;EACpG,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGN,QAAQ,CAAgBG,KAAK,CAAC;EAE3D,oBACEJ,oBAACE,gBAAgB;IAACM,KAAK,EAAEH,aAAa,CAACI;EAAQ,gBAC7CT,oBAACM,KAAK,CAACI,IAAI;IAAA,GAAKH,SAAS,CAACG;EAAI,EAAI,CACjB;AAEvB,CAAC","names":["React","getSlots","MenuListProvider","renderMenuList_unstable","state","contextValues","slots","slotProps","value","menuList","root"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuList/renderMenuList.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { MenuListContextValues, MenuListSlots, MenuListState } from './MenuList.types';\nimport { MenuListProvider } from '../../contexts/menuListContext';\n\n/**\n * Function that renders the final JSX of the component\n */\nexport const renderMenuList_unstable = (state: MenuListState, contextValues: MenuListContextValues) => {\n const { slots, slotProps } = getSlots<MenuListSlots>(state);\n\n return (\n <MenuListProvider value={contextValues.menuList}>\n <slots.root {...slotProps.root} />\n </MenuListProvider>\n );\n};\n"]}
|
@@ -7,7 +7,6 @@ import { MenuContext } from '../../contexts/menuContext';
|
|
7
7
|
/**
|
8
8
|
* Returns the props and state required to render the component
|
9
9
|
*/
|
10
|
-
|
11
10
|
export const useMenuList_unstable = (props, ref) => {
|
12
11
|
const focusAttributes = useArrowNavigationGroup({
|
13
12
|
circular: true,
|
@@ -20,54 +19,43 @@ export const useMenuList_unstable = (props, ref) => {
|
|
20
19
|
} = useFocusFinders();
|
21
20
|
const menuContext = useMenuContextSelectors();
|
22
21
|
const hasMenuContext = useHasParentContext(MenuContext);
|
23
|
-
|
24
22
|
if (usingPropsAndMenuContext(props, menuContext, hasMenuContext)) {
|
25
23
|
// TODO throw warnings in development safely
|
26
24
|
// eslint-disable-next-line no-console
|
27
25
|
console.warn('You are using both MenuList and Menu props, we recommend you to use Menu props when available');
|
28
26
|
}
|
29
|
-
|
30
27
|
const innerRef = React.useRef(null);
|
31
28
|
const setFocusByFirstCharacter = React.useCallback((e, itemEl) => {
|
32
29
|
// TODO use some kind of children registration to reduce dependency on DOM roles
|
33
30
|
const acceptedRoles = ['menuitem', 'menuitemcheckbox', 'menuitemradio'];
|
34
|
-
|
35
31
|
if (!innerRef.current) {
|
36
32
|
return;
|
37
33
|
}
|
38
|
-
|
39
34
|
const menuItems = findAllFocusable(innerRef.current, el => el.hasAttribute('role') && acceptedRoles.indexOf(el.getAttribute('role')) !== -1);
|
40
35
|
let startIndex = menuItems.indexOf(itemEl) + 1;
|
41
|
-
|
42
36
|
if (startIndex === menuItems.length) {
|
43
37
|
startIndex = 0;
|
44
38
|
}
|
45
|
-
|
46
39
|
const firstChars = menuItems.map(menuItem => {
|
47
40
|
var _a;
|
48
|
-
|
49
41
|
return (_a = menuItem.textContent) === null || _a === void 0 ? void 0 : _a.charAt(0).toLowerCase();
|
50
42
|
});
|
51
43
|
const char = e.key.toLowerCase();
|
52
|
-
|
53
44
|
const getIndexFirstChars = (start, firstChar) => {
|
54
45
|
for (let i = start; i < firstChars.length; i++) {
|
55
46
|
if (char === firstChars[i]) {
|
56
47
|
return i;
|
57
48
|
}
|
58
49
|
}
|
59
|
-
|
60
50
|
return -1;
|
61
|
-
};
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
51
|
+
};
|
52
|
+
// Check remaining slots in the menu
|
53
|
+
let index = getIndexFirstChars(startIndex, char);
|
54
|
+
// If not found in remaining slots, check from beginning
|
66
55
|
if (index === -1) {
|
67
56
|
index = getIndexFirstChars(0, char);
|
68
|
-
}
|
69
|
-
|
70
|
-
|
57
|
+
}
|
58
|
+
// If match was found...
|
71
59
|
if (index > -1) {
|
72
60
|
menuItems[index].focus();
|
73
61
|
}
|
@@ -81,24 +69,24 @@ export const useMenuList_unstable = (props, ref) => {
|
|
81
69
|
const toggleCheckbox = useEventCallback((e, name, value, checked) => {
|
82
70
|
const checkedItems = (checkedValues === null || checkedValues === void 0 ? void 0 : checkedValues[name]) || [];
|
83
71
|
const newCheckedItems = [...checkedItems];
|
84
|
-
|
85
72
|
if (checked) {
|
86
73
|
newCheckedItems.splice(newCheckedItems.indexOf(value), 1);
|
87
74
|
} else {
|
88
75
|
newCheckedItems.push(value);
|
89
76
|
}
|
90
|
-
|
91
77
|
handleCheckedValueChange === null || handleCheckedValueChange === void 0 ? void 0 : handleCheckedValueChange(e, {
|
92
78
|
name,
|
93
79
|
checkedItems: newCheckedItems
|
94
80
|
});
|
95
|
-
setCheckedValues(s => ({
|
81
|
+
setCheckedValues(s => ({
|
82
|
+
...s,
|
96
83
|
[name]: newCheckedItems
|
97
84
|
}));
|
98
85
|
});
|
99
86
|
const selectRadio = useEventCallback((e, name, value) => {
|
100
87
|
const newCheckedItems = [value];
|
101
|
-
setCheckedValues(s => ({
|
88
|
+
setCheckedValues(s => ({
|
89
|
+
...s,
|
102
90
|
[name]: newCheckedItems
|
103
91
|
}));
|
104
92
|
handleCheckedValueChange === null || handleCheckedValueChange === void 0 ? void 0 : handleCheckedValueChange(e, {
|
@@ -128,7 +116,6 @@ export const useMenuList_unstable = (props, ref) => {
|
|
128
116
|
/**
|
129
117
|
* Adds some sugar to fetching multiple context selector values
|
130
118
|
*/
|
131
|
-
|
132
119
|
const useMenuContextSelectors = () => {
|
133
120
|
const checkedValues = useMenuContext_unstable(context => context.checkedValues);
|
134
121
|
const onCheckedValueChange = useMenuContext_unstable(context => context.onCheckedValueChange);
|
@@ -146,17 +133,13 @@ const useMenuContextSelectors = () => {
|
|
146
133
|
/**
|
147
134
|
* Helper function to detect if props and MenuContext values are both used
|
148
135
|
*/
|
149
|
-
|
150
|
-
|
151
136
|
const usingPropsAndMenuContext = (props, contextValue, hasMenuContext) => {
|
152
137
|
let isUsingPropsAndContext = false;
|
153
|
-
|
154
138
|
for (const val in contextValue) {
|
155
139
|
if (props[val]) {
|
156
140
|
isUsingPropsAndContext = true;
|
157
141
|
}
|
158
142
|
}
|
159
|
-
|
160
143
|
return hasMenuContext && isUsingPropsAndContext;
|
161
144
|
};
|
162
145
|
//# sourceMappingURL=useMenuList.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-menu/src/components/MenuList/useMenuList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SACE,aADF,EAEE,gBAFF,EAGE,oBAHF,EAIE,qBAJF,QAKO,2BALP;AAMA,SAAS,uBAAT,EAAkC,eAAlC,QAAyD,yBAAzD;AACA,SAAS,mBAAT,QAAoC,kCAApC;AACA,SAAS,uBAAT,QAAwC,4BAAxC;AACA,SAAS,WAAT,QAA4B,4BAA5B;AAGA;;AAEG;;AACH,OAAO,MAAM,oBAAoB,GAAG,CAAC,KAAD,EAAuB,GAAvB,KAAqE;EACvG,MAAM,eAAe,GAAG,uBAAuB,CAAC;IAAE,QAAQ,EAAE,IAAZ;IAAkB,oBAAoB,EAAE;MAAE,GAAG,EAAE;IAAP;EAAxC,CAAD,CAA/C;EACA,MAAM;IAAE;EAAF,IAAuB,eAAe,EAA5C;EACA,MAAM,WAAW,GAAG,uBAAuB,EAA3C;EACA,MAAM,cAAc,GAAG,mBAAmB,CAAC,WAAD,CAA1C;;EAEA,IAAI,wBAAwB,CAAC,KAAD,EAAQ,WAAR,EAAqB,cAArB,CAA5B,EAAkE;IAChE;IACA;IACA,OAAO,CAAC,IAAR,CAAa,+FAAb;EACD;;EAED,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAA0B,IAA1B,CAAjB;EAEA,MAAM,wBAAwB,GAAG,KAAK,CAAC,WAAN,CAC/B,CAAC,CAAD,EAAsC,MAAtC,KAA6D;IAC3D;IACA,MAAM,aAAa,GAAG,CAAC,UAAD,EAAa,kBAAb,EAAiC,eAAjC,CAAtB;;IACA,IAAI,CAAC,QAAQ,CAAC,OAAd,EAAuB;MACrB;IACD;;IAED,MAAM,SAAS,GAAG,gBAAgB,CAChC,QAAQ,CAAC,OADuB,EAE/B,EAAD,IAAqB,EAAE,C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G;;;AACH,MAAM,wBAAwB,GAAG,CAC/B,KAD+B,EAE/B,YAF+B,EAG/B,cAH+B,KAI7B;EACF,IAAI,sBAAsB,GAAG,KAA7B;;EACA,KAAK,MAAM,GAAX,IAAkB,YAAlB,EAAgC;IAC9B,IAAI,KAAK,CAAC,GAAD,CAAT,EAA4G;MAC1G,sBAAsB,GAAG,IAAzB;IACD;EACF;;EAED,OAAO,cAAc,IAAI,sBAAzB;AACD,CAbD","sourcesContent":["import * as React from 'react';\nimport {\n useMergedRefs,\n useEventCallback,\n useControllableState,\n getNativeElementProps,\n} from '@fluentui/react-utilities';\nimport { useArrowNavigationGroup, useFocusFinders } from '@fluentui/react-tabster';\nimport { useHasParentContext } from '@fluentui/react-context-selector';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { MenuContext } from '../../contexts/menuContext';\nimport type { MenuListProps, MenuListState } from './MenuList.types';\n\n/**\n * Returns the props and state required to render the component\n */\nexport const useMenuList_unstable = (props: MenuListProps, ref: React.Ref<HTMLElement>): MenuListState => {\n const focusAttributes = useArrowNavigationGroup({ circular: true, ignoreDefaultKeydown: { Tab: true } });\n const { findAllFocusable } = useFocusFinders();\n const menuContext = useMenuContextSelectors();\n const hasMenuContext = useHasParentContext(MenuContext);\n\n if (usingPropsAndMenuContext(props, menuContext, hasMenuContext)) {\n // TODO throw warnings in development safely\n // eslint-disable-next-line no-console\n console.warn('You are using both MenuList and Menu props, we recommend you to use Menu props when available');\n }\n\n const innerRef = React.useRef<HTMLElement>(null);\n\n const setFocusByFirstCharacter = React.useCallback(\n (e: React.KeyboardEvent<HTMLElement>, itemEl: HTMLElement) => {\n // TODO use some kind of children registration to reduce dependency on DOM roles\n const acceptedRoles = ['menuitem', 'menuitemcheckbox', 'menuitemradio'];\n if (!innerRef.current) {\n return;\n }\n\n const menuItems = findAllFocusable(\n innerRef.current,\n (el: HTMLElement) => el.hasAttribute('role') && acceptedRoles.indexOf(el.getAttribute('role')!) !== -1,\n );\n\n let startIndex = menuItems.indexOf(itemEl) + 1;\n if (startIndex === menuItems.length) {\n startIndex = 0;\n }\n\n const firstChars = menuItems.map(menuItem => menuItem.textContent?.charAt(0).toLowerCase());\n const char = e.key.toLowerCase();\n\n const getIndexFirstChars = (start: number, firstChar: string) => {\n for (let i = start; i < firstChars.length; i++) {\n if (char === firstChars[i]) {\n return i;\n }\n }\n return -1;\n };\n\n // Check remaining slots in the menu\n let index = getIndexFirstChars(startIndex, char);\n\n // If not found in remaining slots, check from beginning\n if (index === -1) {\n index = getIndexFirstChars(0, char);\n }\n\n // If match was found...\n if (index > -1) {\n menuItems[index].focus();\n }\n },\n [findAllFocusable],\n );\n\n const [checkedValues, setCheckedValues] = useControllableState({\n state: hasMenuContext ? menuContext.checkedValues : props.checkedValues,\n defaultState: props.defaultCheckedValues,\n initialState: {},\n });\n\n const handleCheckedValueChange = hasMenuContext ? menuContext.onCheckedValueChange : props.onCheckedValueChange;\n\n const toggleCheckbox = useEventCallback(\n (e: React.MouseEvent | React.KeyboardEvent, name: string, value: string, checked: boolean) => {\n const checkedItems = checkedValues?.[name] || [];\n const newCheckedItems = [...checkedItems];\n if (checked) {\n newCheckedItems.splice(newCheckedItems.indexOf(value), 1);\n } else {\n newCheckedItems.push(value);\n }\n\n handleCheckedValueChange?.(e, { name, checkedItems: newCheckedItems });\n setCheckedValues(s => ({ ...s, [name]: newCheckedItems }));\n },\n );\n\n const selectRadio = useEventCallback((e: React.MouseEvent | React.KeyboardEvent, name: string, value: string) => {\n const newCheckedItems = [value];\n setCheckedValues(s => ({ ...s, [name]: newCheckedItems }));\n handleCheckedValueChange?.(e, { name, checkedItems: newCheckedItems });\n });\n\n return {\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, innerRef),\n role: 'menu',\n 'aria-labelledby': menuContext.triggerId,\n ...focusAttributes,\n ...props,\n }),\n hasIcons: menuContext.hasIcons || false,\n hasCheckmarks: menuContext.hasCheckmarks || false,\n checkedValues,\n setFocusByFirstCharacter,\n selectRadio,\n toggleCheckbox,\n };\n};\n\n/**\n * Adds some sugar to fetching multiple context selector values\n */\nconst useMenuContextSelectors = () => {\n const checkedValues = useMenuContext_unstable(context => context.checkedValues);\n const onCheckedValueChange = useMenuContext_unstable(context => context.onCheckedValueChange);\n const triggerId = useMenuContext_unstable(context => context.triggerId);\n const hasIcons = useMenuContext_unstable(context => context.hasIcons);\n const hasCheckmarks = useMenuContext_unstable(context => context.hasCheckmarks);\n\n return {\n checkedValues,\n onCheckedValueChange,\n triggerId,\n hasIcons,\n hasCheckmarks,\n };\n};\n\n/**\n * Helper function to detect if props and MenuContext values are both used\n */\nconst usingPropsAndMenuContext = (\n props: MenuListProps,\n contextValue: ReturnType<typeof useMenuContextSelectors>,\n hasMenuContext: boolean,\n) => {\n let isUsingPropsAndContext = false;\n for (const val in contextValue) {\n if (props[val as keyof Omit<typeof contextValue, 'hasMenuContext' | 'onCheckedValueChange' | 'triggerId'>]) {\n isUsingPropsAndContext = true;\n }\n }\n\n return hasMenuContext && isUsingPropsAndContext;\n};\n"],"sourceRoot":"../src/"}
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACEC,aAAa,EACbC,gBAAgB,EAChBC,oBAAoB,EACpBC,qBAAqB,QAChB,2BAA2B;AAClC,SAASC,uBAAuB,EAAEC,eAAe,QAAQ,yBAAyB;AAClF,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,uBAAuB,QAAQ,4BAA4B;AACpE,SAASC,WAAW,QAAQ,4BAA4B;AAGxD;;;AAGA,OAAO,MAAMC,oBAAoB,GAAG,CAACC,KAAoB,EAAEC,GAA2B,KAAmB;EACvG,MAAMC,eAAe,GAAGR,uBAAuB,CAAC;IAAES,QAAQ,EAAE,IAAI;IAAEC,oBAAoB,EAAE;MAAEC,GAAG,EAAE;IAAI;EAAE,CAAE,CAAC;EACxG,MAAM;IAAEC;EAAgB,CAAE,GAAGX,eAAe,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pD,uBAAuB,CAACqE,OAAO,IAAIA,OAAO,CAACjB,oBAAoB,CAAC;EAC7F,MAAMc,SAAS,GAAGlE,uBAAuB,CAACqE,OAAO,IAAIA,OAAO,CAACH,SAAS,CAAC;EACvE,MAAMC,QAAQ,GAAGnE,uBAAuB,CAACqE,OAAO,IAAIA,OAAO,CAACF,QAAQ,CAAC;EACrE,MAAMC,aAAa,GAAGpE,uBAAuB,CAACqE,OAAO,IAAIA,OAAO,CAACD,aAAa,CAAC;EAE/E,OAAO;IACLvB,aAAa;IACbO,oBAAoB;IACpBc,SAAS;IACTC,QAAQ;IACRC;GACD;AACH,CAAC;AAED;;;AAGA,MAAMvD,wBAAwB,GAAG,CAC/BV,KAAoB,EACpBmE,YAAwD,EACxD1D,cAAuB,KACrB;EACF,IAAI2D,sBAAsB,GAAG,KAAK;EAClC,KAAK,MAAMC,GAAG,IAAIF,YAAY,EAAE;IAC9B,IAAInE,KAAK,CAACqE,GAA+F,CAAC,EAAE;MAC1GD,sBAAsB,GAAG,IAAI;;;EAIjC,OAAO3D,cAAc,IAAI2D,sBAAsB;AACjD,CAAC","names":["React","useMergedRefs","useEventCallback","useControllableState","getNativeElementProps","useArrowNavigationGroup","useFocusFinders","useHasParentContext","useMenuContext_unstable","MenuContext","useMenuList_unstable","props","ref","focusAttributes","circular","ignoreDefaultKeydown","Tab","findAllFocusable","menuContext","useMenuContextSelectors","hasMenuContext","usingPropsAndMenuContext","console","warn","innerRef","useRef","setFocusByFirstCharacter","useCallback","e","itemEl","acceptedRoles","current","menuItems","el","hasAttribute","indexOf","getAttribute","startIndex","length","firstChars","map","menuItem","textContent","charAt","toLowerCase","char","key","getIndexFirstChars","start","firstChar","i","index","focus","checkedValues","setCheckedValues","state","defaultState","defaultCheckedValues","initialState","handleCheckedValueChange","onCheckedValueChange","toggleCheckbox","name","value","checked","checkedItems","newCheckedItems","splice","push","s","selectRadio","components","root","role","triggerId","hasIcons","hasCheckmarks","context","contextValue","isUsingPropsAndContext","val"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuList/useMenuList.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n useMergedRefs,\n useEventCallback,\n useControllableState,\n getNativeElementProps,\n} from '@fluentui/react-utilities';\nimport { useArrowNavigationGroup, useFocusFinders } from '@fluentui/react-tabster';\nimport { useHasParentContext } from '@fluentui/react-context-selector';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { MenuContext } from '../../contexts/menuContext';\nimport type { MenuListProps, MenuListState } from './MenuList.types';\n\n/**\n * Returns the props and state required to render the component\n */\nexport const useMenuList_unstable = (props: MenuListProps, ref: React.Ref<HTMLElement>): MenuListState => {\n const focusAttributes = useArrowNavigationGroup({ circular: true, ignoreDefaultKeydown: { Tab: true } });\n const { findAllFocusable } = useFocusFinders();\n const menuContext = useMenuContextSelectors();\n const hasMenuContext = useHasParentContext(MenuContext);\n\n if (usingPropsAndMenuContext(props, menuContext, hasMenuContext)) {\n // TODO throw warnings in development safely\n // eslint-disable-next-line no-console\n console.warn('You are using both MenuList and Menu props, we recommend you to use Menu props when available');\n }\n\n const innerRef = React.useRef<HTMLElement>(null);\n\n const setFocusByFirstCharacter = React.useCallback(\n (e: React.KeyboardEvent<HTMLElement>, itemEl: HTMLElement) => {\n // TODO use some kind of children registration to reduce dependency on DOM roles\n const acceptedRoles = ['menuitem', 'menuitemcheckbox', 'menuitemradio'];\n if (!innerRef.current) {\n return;\n }\n\n const menuItems = findAllFocusable(\n innerRef.current,\n (el: HTMLElement) => el.hasAttribute('role') && acceptedRoles.indexOf(el.getAttribute('role')!) !== -1,\n );\n\n let startIndex = menuItems.indexOf(itemEl) + 1;\n if (startIndex === menuItems.length) {\n startIndex = 0;\n }\n\n const firstChars = menuItems.map(menuItem => menuItem.textContent?.charAt(0).toLowerCase());\n const char = e.key.toLowerCase();\n\n const getIndexFirstChars = (start: number, firstChar: string) => {\n for (let i = start; i < firstChars.length; i++) {\n if (char === firstChars[i]) {\n return i;\n }\n }\n return -1;\n };\n\n // Check remaining slots in the menu\n let index = getIndexFirstChars(startIndex, char);\n\n // If not found in remaining slots, check from beginning\n if (index === -1) {\n index = getIndexFirstChars(0, char);\n }\n\n // If match was found...\n if (index > -1) {\n menuItems[index].focus();\n }\n },\n [findAllFocusable],\n );\n\n const [checkedValues, setCheckedValues] = useControllableState({\n state: hasMenuContext ? menuContext.checkedValues : props.checkedValues,\n defaultState: props.defaultCheckedValues,\n initialState: {},\n });\n\n const handleCheckedValueChange = hasMenuContext ? menuContext.onCheckedValueChange : props.onCheckedValueChange;\n\n const toggleCheckbox = useEventCallback(\n (e: React.MouseEvent | React.KeyboardEvent, name: string, value: string, checked: boolean) => {\n const checkedItems = checkedValues?.[name] || [];\n const newCheckedItems = [...checkedItems];\n if (checked) {\n newCheckedItems.splice(newCheckedItems.indexOf(value), 1);\n } else {\n newCheckedItems.push(value);\n }\n\n handleCheckedValueChange?.(e, { name, checkedItems: newCheckedItems });\n setCheckedValues(s => ({ ...s, [name]: newCheckedItems }));\n },\n );\n\n const selectRadio = useEventCallback((e: React.MouseEvent | React.KeyboardEvent, name: string, value: string) => {\n const newCheckedItems = [value];\n setCheckedValues(s => ({ ...s, [name]: newCheckedItems }));\n handleCheckedValueChange?.(e, { name, checkedItems: newCheckedItems });\n });\n\n return {\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, innerRef),\n role: 'menu',\n 'aria-labelledby': menuContext.triggerId,\n ...focusAttributes,\n ...props,\n }),\n hasIcons: menuContext.hasIcons || false,\n hasCheckmarks: menuContext.hasCheckmarks || false,\n checkedValues,\n setFocusByFirstCharacter,\n selectRadio,\n toggleCheckbox,\n };\n};\n\n/**\n * Adds some sugar to fetching multiple context selector values\n */\nconst useMenuContextSelectors = () => {\n const checkedValues = useMenuContext_unstable(context => context.checkedValues);\n const onCheckedValueChange = useMenuContext_unstable(context => context.onCheckedValueChange);\n const triggerId = useMenuContext_unstable(context => context.triggerId);\n const hasIcons = useMenuContext_unstable(context => context.hasIcons);\n const hasCheckmarks = useMenuContext_unstable(context => context.hasCheckmarks);\n\n return {\n checkedValues,\n onCheckedValueChange,\n triggerId,\n hasIcons,\n hasCheckmarks,\n };\n};\n\n/**\n * Helper function to detect if props and MenuContext values are both used\n */\nconst usingPropsAndMenuContext = (\n props: MenuListProps,\n contextValue: ReturnType<typeof useMenuContextSelectors>,\n hasMenuContext: boolean,\n) => {\n let isUsingPropsAndContext = false;\n for (const val in contextValue) {\n if (props[val as keyof Omit<typeof contextValue, 'hasMenuContext' | 'onCheckedValueChange' | 'triggerId'>]) {\n isUsingPropsAndContext = true;\n }\n }\n\n return hasMenuContext && isUsingPropsAndContext;\n};\n"]}
|
@@ -6,8 +6,8 @@ export function useMenuListContextValues_unstable(state) {
|
|
6
6
|
selectRadio,
|
7
7
|
setFocusByFirstCharacter,
|
8
8
|
toggleCheckbox
|
9
|
-
} = state;
|
10
|
-
|
9
|
+
} = state;
|
10
|
+
// This context is created with "@fluentui/react-context-selector", these is no sense to memoize it
|
11
11
|
const menuList = {
|
12
12
|
checkedValues,
|
13
13
|
hasCheckmarks,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAEA,OAAM,SAAUA,iCAAiC,CAACC,KAAoB;EACpE,MAAM;IAAEC,aAAa;IAAEC,aAAa;IAAEC,QAAQ;IAAEC,WAAW;IAAEC,wBAAwB;IAAEC;EAAc,CAAE,GAAGN,KAAK;EAE/G;EACA,MAAMO,QAAQ,GAAG;IACfN,aAAa;IACbC,aAAa;IACbC,QAAQ;IACRC,WAAW;IACXC,wBAAwB;IACxBC;GACD;EAED,OAAO;IAAEC;EAAQ,CAAE;AACrB","names":["useMenuListContextValues_unstable","state","checkedValues","hasCheckmarks","hasIcons","selectRadio","setFocusByFirstCharacter","toggleCheckbox","menuList"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuList/useMenuListContextValues.ts"],"sourcesContent":["import type { MenuListContextValues, MenuListState } from './MenuList.types';\n\nexport function useMenuListContextValues_unstable(state: MenuListState): MenuListContextValues {\n const { checkedValues, hasCheckmarks, hasIcons, selectRadio, setFocusByFirstCharacter, toggleCheckbox } = state;\n\n // This context is created with \"@fluentui/react-context-selector\", these is no sense to memoize it\n const menuList = {\n checkedValues,\n hasCheckmarks,\n hasIcons,\n selectRadio,\n setFocusByFirstCharacter,\n toggleCheckbox,\n };\n\n return { menuList };\n}\n"]}
|
@@ -2,22 +2,19 @@ import { mergeClasses, __styles, shorthands } from '@griffel/react';
|
|
2
2
|
export const menuListClassNames = {
|
3
3
|
root: 'fui-MenuList'
|
4
4
|
};
|
5
|
-
|
6
5
|
const useStyles = /*#__PURE__*/__styles({
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
root: {
|
7
|
+
mc9l5x: "f22iagw",
|
8
|
+
Beiy3e4: "f1vx9l62",
|
9
|
+
i8kkvl: "f16mnhsx",
|
10
|
+
Belr9w4: "fbi42co"
|
12
11
|
}
|
13
12
|
}, {
|
14
|
-
|
13
|
+
d: [".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".f16mnhsx{-webkit-column-gap:2px;column-gap:2px;}", ".fbi42co{row-gap:2px;}"]
|
15
14
|
});
|
16
15
|
/**
|
17
16
|
* Apply styling to the Menu slots based on the state
|
18
17
|
*/
|
19
|
-
|
20
|
-
|
21
18
|
export const useMenuListStyles_unstable = state => {
|
22
19
|
const styles = useStyles();
|
23
20
|
state.root.className = mergeClasses(menuListClassNames.root, styles.root, state.root.className);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AACA,SAASA,YAAY,YAAcC,UAAU,QAAQ,gBAAgB;AAGrE,OAAO,MAAMC,kBAAkB,GAAkC;EAC/DC,IAAI,EAAE;CACP;AAED,MAAMC,SAAS,gBAAG;EAAA;IAAA;IAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAMhB;AAEF;;;AAGA,OAAO,MAAMC,0BAA0B,GAAIC,KAAoB,IAAmB;EAChF,MAAMC,MAAM,GAAGH,SAAS,EAAE;EAC1BE,KAAK,CAACH,IAAI,CAACK,SAAS,GAAGR,YAAY,CAACE,kBAAkB,CAACC,IAAI,EAAEI,MAAM,CAACJ,IAAI,EAAEG,KAAK,CAACH,IAAI,CAACK,SAAS,CAAC;EAC/F,OAAOF,KAAK;AACd,CAAC","names":["mergeClasses","shorthands","menuListClassNames","root","useStyles","useMenuListStyles_unstable","state","styles","className"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuList/useMenuListStyles.ts"],"sourcesContent":["import type { SlotClassNames } from '@fluentui/react-utilities';\nimport { mergeClasses, makeStyles, shorthands } from '@griffel/react';\nimport type { MenuListSlots, MenuListState } from './MenuList.types';\n\nexport const menuListClassNames: SlotClassNames<MenuListSlots> = {\n root: 'fui-MenuList',\n};\n\nconst useStyles = makeStyles({\n root: {\n display: 'flex',\n flexDirection: 'column',\n ...shorthands.gap('2px'),\n },\n});\n\n/**\n * Apply styling to the Menu slots based on the state\n */\nexport const useMenuListStyles_unstable = (state: MenuListState): MenuListState => {\n const styles = useStyles();\n state.root.className = mergeClasses(menuListClassNames.root, styles.root, state.root.className);\n return state;\n};\n"]}
|
@@ -5,7 +5,6 @@ import { renderMenuPopover_unstable } from './renderMenuPopover';
|
|
5
5
|
/**
|
6
6
|
* Popover intended to wrap `MenuList` and adds styling and interaction support specific to menus
|
7
7
|
*/
|
8
|
-
|
9
8
|
export const MenuPopover = /*#__PURE__*/React.forwardRef((props, ref) => {
|
10
9
|
const state = useMenuPopover_unstable(props, ref);
|
11
10
|
useMenuPopoverStyles_unstable(state);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,SAASC,6BAA6B,QAAQ,wBAAwB;AACtE,SAASC,0BAA0B,QAAQ,qBAAqB;AAIhE;;;AAGA,OAAO,MAAMC,WAAW,gBAA0CJ,KAAK,CAACK,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EAChG,MAAMC,KAAK,GAAGP,uBAAuB,CAACK,KAAK,EAAEC,GAAG,CAAC;EAEjDL,6BAA6B,CAACM,KAAK,CAAC;EACpC,OAAOL,0BAA0B,CAACK,KAAK,CAAC;AAC1C,CAAC,CAAC;AAEFJ,WAAW,CAACK,WAAW,GAAG,aAAa","names":["React","useMenuPopover_unstable","useMenuPopoverStyles_unstable","renderMenuPopover_unstable","MenuPopover","forwardRef","props","ref","state","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuPopover/MenuPopover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMenuPopover_unstable } from './useMenuPopover';\nimport { useMenuPopoverStyles_unstable } from './useMenuPopoverStyles';\nimport { renderMenuPopover_unstable } from './renderMenuPopover';\nimport type { MenuPopoverProps } from './MenuPopover.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Popover intended to wrap `MenuList` and adds styling and interaction support specific to menus\n */\nexport const MenuPopover: ForwardRefComponent<MenuPopoverProps> = React.forwardRef((props, ref) => {\n const state = useMenuPopover_unstable(props, ref);\n\n useMenuPopoverStyles_unstable(state);\n return renderMenuPopover_unstable(state);\n});\n\nMenuPopover.displayName = 'MenuPopover';\n"]}
|
@@ -4,19 +4,18 @@ import { Portal } from '@fluentui/react-portal';
|
|
4
4
|
/**
|
5
5
|
* Render the final JSX of MenuPopover
|
6
6
|
*/
|
7
|
-
|
8
7
|
export const renderMenuPopover_unstable = state => {
|
9
8
|
const {
|
10
9
|
slots,
|
11
10
|
slotProps
|
12
11
|
} = getSlots(state);
|
13
|
-
|
14
12
|
if (state.inline) {
|
15
|
-
return /*#__PURE__*/React.createElement(slots.root, {
|
13
|
+
return /*#__PURE__*/React.createElement(slots.root, {
|
14
|
+
...slotProps.root
|
16
15
|
});
|
17
16
|
}
|
18
|
-
|
19
|
-
|
17
|
+
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(slots.root, {
|
18
|
+
...slotProps.root
|
20
19
|
}));
|
21
20
|
};
|
22
21
|
//# sourceMappingURL=renderMenuPopover.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,QAAQ,2BAA2B;AAEpD,SAASC,MAAM,QAAQ,wBAAwB;AAE/C;;;AAGA,OAAO,MAAMC,0BAA0B,GAAIC,KAAuB,IAAI;EACpE,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGL,QAAQ,CAAmBG,KAAK,CAAC;EAE9D,IAAIA,KAAK,CAACG,MAAM,EAAE;IAChB,oBAAOP,oBAACK,KAAK,CAACG,IAAI;MAAA,GAAKF,SAAS,CAACE;IAAI,EAAI;;EAG3C,oBACER,oBAACE,MAAM,qBACLF,oBAACK,KAAK,CAACG,IAAI;IAAA,GAAKF,SAAS,CAACE;EAAI,EAAI,CAC3B;AAEb,CAAC","names":["React","getSlots","Portal","renderMenuPopover_unstable","state","slots","slotProps","inline","root"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuPopover/renderMenuPopover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { MenuPopoverSlots, MenuPopoverState } from './MenuPopover.types';\nimport { Portal } from '@fluentui/react-portal';\n\n/**\n * Render the final JSX of MenuPopover\n */\nexport const renderMenuPopover_unstable = (state: MenuPopoverState) => {\n const { slots, slotProps } = getSlots<MenuPopoverSlots>(state);\n\n if (state.inline) {\n return <slots.root {...slotProps.root} />;\n }\n\n return (\n <Portal>\n <slots.root {...slotProps.root} />\n </Portal>\n );\n};\n"]}
|
@@ -14,10 +14,8 @@ import { useIsSubmenu } from '../../utils/useIsSubmenu';
|
|
14
14
|
* @param props - props from this instance of MenuPopover
|
15
15
|
* @param ref - reference to root HTMLElement of MenuPopover
|
16
16
|
*/
|
17
|
-
|
18
17
|
export const useMenuPopover_unstable = (props, ref) => {
|
19
18
|
var _a;
|
20
|
-
|
21
19
|
const popoverRef = useMenuContext_unstable(context => context.menuPopoverRef);
|
22
20
|
const setOpen = useMenuContext_unstable(context => context.setOpen);
|
23
21
|
const open = useMenuContext_unstable(context => context.open);
|
@@ -28,9 +26,9 @@ export const useMenuPopover_unstable = (props, ref) => {
|
|
28
26
|
const {
|
29
27
|
dir
|
30
28
|
} = useFluent();
|
31
|
-
const CloseArrowKey = dir === 'ltr' ? ArrowLeft : ArrowRight;
|
29
|
+
const CloseArrowKey = dir === 'ltr' ? ArrowLeft : ArrowRight;
|
30
|
+
// use DOM listener since react events propagate up the react tree
|
32
31
|
// no need to do `contains` logic as menus are all positioned in different portals
|
33
|
-
|
34
32
|
const mouseOverListenerCallbackRef = React.useCallback(node => {
|
35
33
|
if (node) {
|
36
34
|
// Dispatches the custom menu mouse enter event with throttling
|
@@ -39,9 +37,9 @@ export const useMenuPopover_unstable = (props, ref) => {
|
|
39
37
|
node.addEventListener('mouseover', e => {
|
40
38
|
if (canDispatchCustomEventRef.current) {
|
41
39
|
canDispatchCustomEventRef.current = false;
|
42
|
-
dispatchMenuEnterEvent(popoverRef.current, e);
|
40
|
+
dispatchMenuEnterEvent(popoverRef.current, e);
|
41
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
43
42
|
// @ts-ignore #16889 Node setTimeout type leaking
|
44
|
-
|
45
43
|
throttleDispatchTimerRef.current = setTimeout(() => canDispatchCustomEventRef.current = true, 250);
|
46
44
|
}
|
47
45
|
});
|
@@ -69,14 +67,11 @@ export const useMenuPopover_unstable = (props, ref) => {
|
|
69
67
|
event
|
70
68
|
});
|
71
69
|
}
|
72
|
-
|
73
70
|
onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(event);
|
74
71
|
});
|
75
72
|
rootProps.onKeyDown = useEventCallback(event => {
|
76
73
|
var _a;
|
77
|
-
|
78
74
|
const key = event.key;
|
79
|
-
|
80
75
|
if (key === Escape || isSubmenu && key === CloseArrowKey) {
|
81
76
|
if (open && ((_a = popoverRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))) {
|
82
77
|
setOpen(event, {
|
@@ -84,13 +79,12 @@ export const useMenuPopover_unstable = (props, ref) => {
|
|
84
79
|
keyboard: true,
|
85
80
|
type: 'menuPopoverKeyDown',
|
86
81
|
event
|
87
|
-
});
|
82
|
+
});
|
83
|
+
// stop propagation to avoid conflicting with other elements that listen for `Escape`
|
88
84
|
// e,g: Dialog, Popover and Tooltip
|
89
|
-
|
90
85
|
event.stopPropagation();
|
91
86
|
}
|
92
87
|
}
|
93
|
-
|
94
88
|
if (key === Tab) {
|
95
89
|
setOpen(event, {
|
96
90
|
open: false,
|
@@ -100,7 +94,6 @@ export const useMenuPopover_unstable = (props, ref) => {
|
|
100
94
|
});
|
101
95
|
event.preventDefault();
|
102
96
|
}
|
103
|
-
|
104
97
|
onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(event);
|
105
98
|
});
|
106
99
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,SAAS,EAAEC,GAAG,EAAEC,UAAU,EAAEC,MAAM,QAAQ,yBAAyB;AAC5E,SAASC,qBAAqB,EAAEC,gBAAgB,EAAEC,aAAa,QAAQ,2BAA2B;AAElG,SAASC,uBAAuB,QAAQ,4BAA4B;AACpE,SAASC,sBAAsB,QAAQ,mBAAmB;AAC1D,SAASC,kBAAkB,IAAIC,SAAS,QAAQ,iCAAiC;AACjF,SAAS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CAAE,CAAC;QAClF;QACA;QACAA,KAAK,CAACM,eAAe,EAAE;;;IAI3B,IAAIH,GAAG,KAAK7C,GAAG,EAAE;MACfiB,OAAO,CAACyB,KAAK,EAAE;QAAExB,IAAI,EAAE,KAAK;QAAEyB,QAAQ,EAAE,IAAI;QAAEC,IAAI,EAAE,oBAAoB;QAAEF;MAAK,CAAE,CAAC;MAClFA,KAAK,CAACO,cAAc,EAAE;;IAGxBR,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAGC,KAAK,CAAC;EAC5B,CAAC,CAAC;EAEF,OAAO;IACLP,MAAM;IACNe,UAAU,EAAE;MACVC,IAAI,EAAE;KACP;IACDA,IAAI,EAAEf;GACP;AACH,CAAC","names":["React","ArrowLeft","Tab","ArrowRight","Escape","getNativeElementProps","useEventCallback","useMergedRefs","useMenuContext_unstable","dispatchMenuEnterEvent","useFluent_unstable","useFluent","useIsSubmenu","useMenuPopover_unstable","props","ref","popoverRef","context","menuPopoverRef","setOpen","open","openOnHover","isSubmenu","canDispatchCustomEventRef","useRef","throttleDispatchTimerRef","dir","CloseArrowKey","mouseOverListenerCallbackRef","useCallback","node","addEventListener","e","current","setTimeout","useEffect","clearTimeout","inline","rootProps","role","onMouseEnter","onMouseEnterOriginal","onKeyDown","onKeyDownOriginal","event","keyboard","type","key","contains","target","stopPropagation","preventDefault","components","root"],"sourceRoot":"../src/","sources":["packages/react-components/react-menu/src/components/MenuPopover/useMenuPopover.ts"],"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"]}
|