@fluentui/react-menu 9.0.0-nightly.d730088d7f.0 → 9.0.0-rc.10
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +981 -32
- package/CHANGELOG.md +354 -138
- package/Spec.md +21 -16
- package/dist/{react-menu.d.ts → index.d.ts} +295 -166
- package/{lib → dist}/tsdoc-metadata.json +0 -0
- package/lib/Menu.js.map +1 -1
- package/lib/MenuDivider.js.map +1 -1
- package/lib/MenuGroup.js.map +1 -1
- package/lib/MenuGroupHeader.js.map +1 -1
- package/lib/MenuItem.js.map +1 -1
- package/lib/MenuItemCheckbox.js.map +1 -1
- package/lib/MenuItemRadio.js.map +1 -1
- package/lib/MenuList.js.map +1 -1
- package/lib/MenuPopover.js.map +1 -1
- package/lib/MenuSplitGroup.js +2 -0
- package/lib/MenuSplitGroup.js.map +1 -0
- package/lib/MenuTrigger.js.map +1 -1
- package/lib/components/Menu/Menu.js +7 -7
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/Menu.types.js.map +1 -1
- package/lib/components/Menu/index.js.map +1 -1
- package/lib/components/Menu/renderMenu.js +1 -1
- package/lib/components/Menu/renderMenu.js.map +1 -1
- package/lib/components/Menu/useMenu.js +120 -129
- package/lib/components/Menu/useMenu.js.map +1 -1
- package/lib/components/Menu/useMenuContextValues.js +35 -33
- package/lib/components/Menu/useMenuContextValues.js.map +1 -1
- package/lib/components/MenuDivider/MenuDivider.js +8 -8
- package/lib/components/MenuDivider/MenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/MenuDivider.types.js.map +1 -1
- package/lib/components/MenuDivider/index.js.map +1 -1
- package/lib/components/MenuDivider/renderMenuDivider.js +7 -7
- package/lib/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDivider.js +9 -7
- package/lib/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDividerStyles.js +14 -5
- package/lib/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib/components/MenuGroup/MenuGroup.js +10 -8
- package/lib/components/MenuGroup/MenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/MenuGroup.types.js.map +1 -1
- package/lib/components/MenuGroup/index.js +1 -0
- package/lib/components/MenuGroup/index.js.map +1 -1
- package/lib/components/MenuGroup/renderMenuGroup.js +7 -7
- package/lib/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroup.js +10 -7
- package/lib/components/MenuGroup/useMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroupContextValues.js +8 -8
- package/lib/components/MenuGroup/useMenuGroupContextValues.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroupStyles.js +14 -0
- package/lib/components/MenuGroup/useMenuGroupStyles.js.map +1 -0
- package/lib/components/MenuGroupHeader/MenuGroupHeader.js +8 -8
- package/lib/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/MenuGroupHeader.types.js.map +1 -1
- package/lib/components/MenuGroupHeader/index.js.map +1 -1
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js +7 -7
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js +13 -8
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +14 -5
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib/components/MenuItem/MenuItem.js +8 -10
- package/lib/components/MenuItem/MenuItem.js.map +1 -1
- package/lib/components/MenuItem/MenuItem.types.js.map +1 -1
- package/lib/components/MenuItem/index.js.map +1 -1
- package/lib/components/MenuItem/renderMenuItem.js +12 -8
- package/lib/components/MenuItem/renderMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useCharacterSearch.js +7 -7
- package/lib/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib/components/MenuItem/useMenuItem.js +37 -44
- package/lib/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useMenuItemStyles.js +61 -17
- package/lib/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.js +8 -8
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.types.js.map +1 -1
- package/lib/components/MenuItemCheckbox/index.js +1 -0
- package/lib/components/MenuItemCheckbox/index.js.map +1 -1
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js +11 -8
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js +14 -15
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +36 -5
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib/components/MenuItemRadio/MenuItemRadio.js +8 -8
- package/lib/components/MenuItemRadio/MenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/MenuItemRadio.types.js.map +1 -1
- package/lib/components/MenuItemRadio/index.js +1 -0
- package/lib/components/MenuItemRadio/index.js.map +1 -1
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js +11 -8
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadio.js +14 -14
- package/lib/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js +36 -5
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib/components/MenuList/MenuList.js +10 -10
- package/lib/components/MenuList/MenuList.js.map +1 -1
- package/lib/components/MenuList/MenuList.types.js.map +1 -1
- package/lib/components/MenuList/index.js.map +1 -1
- package/lib/components/MenuList/renderMenuList.js +7 -7
- package/lib/components/MenuList/renderMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuList.js +71 -88
- package/lib/components/MenuList/useMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuListContextValues.js +19 -17
- package/lib/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib/components/MenuList/useMenuListStyles.js +16 -7
- package/lib/components/MenuList/useMenuListStyles.js.map +1 -1
- package/lib/components/MenuPopover/MenuPopover.js +7 -7
- package/lib/components/MenuPopover/MenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/MenuPopover.types.js.map +1 -1
- package/lib/components/MenuPopover/index.js.map +1 -1
- package/lib/components/MenuPopover/renderMenuPopover.js +9 -7
- package/lib/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopover.js +35 -41
- package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopoverStyles.js +20 -8
- package/lib/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib/components/MenuSplitGroup/MenuSplitGroup.js +15 -0
- package/lib/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -0
- package/lib/components/MenuSplitGroup/MenuSplitGroup.types.js +2 -0
- package/lib/components/MenuSplitGroup/MenuSplitGroup.types.js.map +1 -0
- package/lib/components/MenuSplitGroup/index.js +6 -0
- package/lib/components/MenuSplitGroup/index.js.map +1 -0
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.js +15 -0
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -0
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js +67 -0
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -0
- package/lib/components/MenuSplitGroup/useMenuSplitGroupStyles.js +42 -0
- package/lib/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -0
- package/lib/components/MenuTrigger/MenuTrigger.js +6 -5
- package/lib/components/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/MenuTrigger.types.js.map +1 -1
- package/lib/components/MenuTrigger/index.js.map +1 -1
- package/lib/components/MenuTrigger/renderMenuTrigger.js +2 -2
- package/lib/components/MenuTrigger/renderMenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/useMenuTrigger.js +167 -5
- package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib/components/index.js.map +1 -1
- package/lib/contexts/menuContext.js +5 -11
- package/lib/contexts/menuContext.js.map +1 -1
- package/lib/contexts/menuGroupContext.js +3 -5
- package/lib/contexts/menuGroupContext.js.map +1 -1
- package/lib/contexts/menuListContext.js +7 -17
- package/lib/contexts/menuListContext.js.map +1 -1
- package/lib/contexts/menuTriggerContext.js +4 -6
- package/lib/contexts/menuTriggerContext.js.map +1 -1
- package/lib/index.js +25 -15
- package/lib/index.js.map +1 -1
- package/lib/selectable/index.js.map +1 -1
- package/lib/selectable/types.js.map +1 -1
- package/lib/selectable/useCheckmarkStyles.js +4 -4
- package/lib/selectable/useCheckmarkStyles.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/useIsSubmenu.js +3 -5
- package/lib/utils/useIsSubmenu.js.map +1 -1
- package/lib/utils/useOnMenuEnter.js +16 -14
- package/lib/utils/useOnMenuEnter.js.map +1 -1
- package/lib-commonjs/Menu.js +1 -1
- package/lib-commonjs/Menu.js.map +1 -1
- package/lib-commonjs/MenuDivider.js +1 -1
- package/lib-commonjs/MenuDivider.js.map +1 -1
- package/lib-commonjs/MenuGroup.js +1 -1
- package/lib-commonjs/MenuGroup.js.map +1 -1
- package/lib-commonjs/MenuGroupHeader.js +1 -1
- package/lib-commonjs/MenuGroupHeader.js.map +1 -1
- package/lib-commonjs/MenuItem.js +1 -1
- package/lib-commonjs/MenuItem.js.map +1 -1
- package/lib-commonjs/MenuItemCheckbox.js +1 -1
- package/lib-commonjs/MenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/MenuItemRadio.js +1 -1
- package/lib-commonjs/MenuItemRadio.js.map +1 -1
- package/lib-commonjs/MenuList.js +1 -1
- package/lib-commonjs/MenuList.js.map +1 -1
- package/lib-commonjs/MenuPopover.js +1 -1
- package/lib-commonjs/MenuPopover.js.map +1 -1
- package/lib-commonjs/MenuSplitGroup.js +10 -0
- package/lib-commonjs/MenuSplitGroup.js.map +1 -0
- package/lib-commonjs/MenuTrigger.js +1 -1
- package/lib-commonjs/MenuTrigger.js.map +1 -1
- package/lib-commonjs/components/Menu/Menu.js +7 -7
- 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 +1 -1
- package/lib-commonjs/components/Menu/index.js.map +1 -1
- package/lib-commonjs/components/Menu/renderMenu.js +5 -5
- package/lib-commonjs/components/Menu/renderMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenu.js +131 -142
- package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenuContextValues.js +37 -35
- package/lib-commonjs/components/Menu/useMenuContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/MenuDivider.js +9 -9
- 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 +1 -1
- package/lib-commonjs/components/MenuDivider/index.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.js +11 -12
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/useMenuDivider.js +12 -11
- package/lib-commonjs/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js +18 -7
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/MenuGroup.js +12 -9
- 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 +3 -1
- package/lib-commonjs/components/MenuGroup/index.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.js +12 -13
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroup.js +13 -11
- package/lib-commonjs/components/MenuGroup/useMenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.js +11 -11
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js +25 -0
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js.map +1 -0
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.js +9 -9
- 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 +1 -1
- package/lib-commonjs/components/MenuGroupHeader/index.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.js +11 -12
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.js +16 -12
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +18 -7
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItem/MenuItem.js +9 -12
- 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 +1 -1
- package/lib-commonjs/components/MenuItem/index.js.map +1 -1
- package/lib-commonjs/components/MenuItem/renderMenuItem.js +16 -14
- package/lib-commonjs/components/MenuItem/renderMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js +7 -7
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItem.js +45 -53
- package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js +68 -20
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.js +9 -9
- 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 +3 -1
- package/lib-commonjs/components/MenuItemCheckbox/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.js +15 -14
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js +19 -21
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +40 -7
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.js +9 -9
- 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 +3 -1
- package/lib-commonjs/components/MenuItemRadio/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.js +15 -14
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js +19 -20
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js +40 -7
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib-commonjs/components/MenuList/MenuList.js +11 -11
- 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 +1 -1
- package/lib-commonjs/components/MenuList/index.js.map +1 -1
- package/lib-commonjs/components/MenuList/renderMenuList.js +12 -13
- package/lib-commonjs/components/MenuList/renderMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuList.js +78 -96
- package/lib-commonjs/components/MenuList/useMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListContextValues.js +21 -19
- package/lib-commonjs/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListStyles.js +19 -9
- package/lib-commonjs/components/MenuList/useMenuListStyles.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/MenuPopover.js +8 -8
- 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 +1 -1
- package/lib-commonjs/components/MenuPopover/index.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.js +14 -13
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js +43 -50
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js +24 -10
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.js +26 -0
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -0
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.types.js +6 -0
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.types.js.map +1 -0
- package/lib-commonjs/components/MenuSplitGroup/index.js +18 -0
- package/lib-commonjs/components/MenuSplitGroup/index.js.map +1 -0
- package/lib-commonjs/components/MenuSplitGroup/renderMenuSplitGroup.js +26 -0
- package/lib-commonjs/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -0
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroup.js +81 -0
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -0
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroupStyles.js +54 -0
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -0
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.js +6 -5
- 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 +1 -1
- package/lib-commonjs/components/MenuTrigger/index.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.js +6 -6
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +175 -7
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib-commonjs/components/index.js +1 -1
- package/lib-commonjs/components/index.js.map +1 -1
- package/lib-commonjs/contexts/menuContext.js +6 -12
- package/lib-commonjs/contexts/menuContext.js.map +1 -1
- package/lib-commonjs/contexts/menuGroupContext.js +5 -7
- package/lib-commonjs/contexts/menuGroupContext.js.map +1 -1
- package/lib-commonjs/contexts/menuListContext.js +8 -18
- package/lib-commonjs/contexts/menuListContext.js.map +1 -1
- package/lib-commonjs/contexts/menuTriggerContext.js +6 -8
- package/lib-commonjs/contexts/menuTriggerContext.js.map +1 -1
- package/lib-commonjs/index.js +487 -16
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/selectable/index.js +1 -1
- 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 -7
- package/lib-commonjs/selectable/useCheckmarkStyles.js.map +1 -1
- package/lib-commonjs/utils/index.js +1 -1
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/useIsSubmenu.js +5 -7
- package/lib-commonjs/utils/useIsSubmenu.js.map +1 -1
- package/lib-commonjs/utils/useOnMenuEnter.js +18 -16
- package/lib-commonjs/utils/useOnMenuEnter.js.map +1 -1
- package/package.json +25 -29
- package/lib/Menu.d.ts +0 -1
- package/lib/MenuDivider.d.ts +0 -1
- package/lib/MenuGroup.d.ts +0 -1
- package/lib/MenuGroupHeader.d.ts +0 -1
- package/lib/MenuItem.d.ts +0 -1
- package/lib/MenuItemCheckbox.d.ts +0 -1
- package/lib/MenuItemRadio.d.ts +0 -1
- package/lib/MenuList.d.ts +0 -1
- package/lib/MenuPopover.d.ts +0 -1
- package/lib/MenuTrigger.d.ts +0 -1
- package/lib/common/isConformant.d.ts +0 -4
- package/lib/common/isConformant.js +0 -12
- package/lib/common/isConformant.js.map +0 -1
- package/lib/common/mockUseMenuContext.d.ts +0 -7
- package/lib/common/mockUseMenuContext.js +0 -36
- package/lib/common/mockUseMenuContext.js.map +0 -1
- package/lib/components/Menu/Menu.d.ts +0 -6
- package/lib/components/Menu/Menu.types.d.ts +0 -112
- package/lib/components/Menu/index.d.ts +0 -5
- package/lib/components/Menu/renderMenu.d.ts +0 -5
- package/lib/components/Menu/useMenu.d.ts +0 -10
- package/lib/components/Menu/useMenuContextValues.d.ts +0 -2
- package/lib/components/MenuDivider/MenuDivider.d.ts +0 -6
- package/lib/components/MenuDivider/MenuDivider.types.d.ts +0 -6
- package/lib/components/MenuDivider/index.d.ts +0 -5
- package/lib/components/MenuDivider/renderMenuDivider.d.ts +0 -6
- package/lib/components/MenuDivider/useMenuDivider.d.ts +0 -6
- package/lib/components/MenuDivider/useMenuDividerStyles.d.ts +0 -2
- package/lib/components/MenuGroup/MenuGroup.d.ts +0 -6
- package/lib/components/MenuGroup/MenuGroup.types.d.ts +0 -15
- package/lib/components/MenuGroup/index.d.ts +0 -5
- package/lib/components/MenuGroup/renderMenuGroup.d.ts +0 -6
- package/lib/components/MenuGroup/useMenuGroup.d.ts +0 -6
- package/lib/components/MenuGroup/useMenuGroupContextValues.d.ts +0 -2
- package/lib/components/MenuGroupHeader/MenuGroupHeader.d.ts +0 -6
- package/lib/components/MenuGroupHeader/MenuGroupHeader.types.d.ts +0 -6
- package/lib/components/MenuGroupHeader/index.d.ts +0 -5
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.d.ts +0 -6
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.d.ts +0 -6
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.d.ts +0 -2
- package/lib/components/MenuItem/MenuItem.d.ts +0 -6
- package/lib/components/MenuItem/MenuItem.types.d.ts +0 -43
- package/lib/components/MenuItem/index.d.ts +0 -5
- package/lib/components/MenuItem/renderMenuItem.d.ts +0 -5
- package/lib/components/MenuItem/useCharacterSearch.d.ts +0 -3
- package/lib/components/MenuItem/useMenuItem.d.ts +0 -10
- package/lib/components/MenuItem/useMenuItemStyles.d.ts +0 -3
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.d.ts +0 -6
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.types.d.ts +0 -4
- package/lib/components/MenuItemCheckbox/index.d.ts +0 -4
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.d.ts +0 -3
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.d.ts +0 -4
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.d.ts +0 -2
- package/lib/components/MenuItemRadio/MenuItemRadio.d.ts +0 -6
- package/lib/components/MenuItemRadio/MenuItemRadio.types.d.ts +0 -4
- package/lib/components/MenuItemRadio/index.d.ts +0 -4
- package/lib/components/MenuItemRadio/renderMenuItemRadio.d.ts +0 -6
- package/lib/components/MenuItemRadio/useMenuItemRadio.d.ts +0 -6
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.d.ts +0 -2
- package/lib/components/MenuList/MenuList.d.ts +0 -6
- package/lib/components/MenuList/MenuList.types.d.ts +0 -53
- package/lib/components/MenuList/index.d.ts +0 -6
- package/lib/components/MenuList/renderMenuList.d.ts +0 -5
- package/lib/components/MenuList/useMenuList.d.ts +0 -6
- package/lib/components/MenuList/useMenuListContextValues.d.ts +0 -2
- package/lib/components/MenuList/useMenuListStyles.d.ts +0 -5
- package/lib/components/MenuPopover/MenuPopover.d.ts +0 -6
- package/lib/components/MenuPopover/MenuPopover.types.d.ts +0 -18
- package/lib/components/MenuPopover/index.d.ts +0 -5
- package/lib/components/MenuPopover/renderMenuPopover.d.ts +0 -5
- package/lib/components/MenuPopover/useMenuPopover.d.ts +0 -12
- package/lib/components/MenuPopover/useMenuPopoverStyles.d.ts +0 -5
- package/lib/components/MenuTrigger/MenuTrigger.d.ts +0 -7
- package/lib/components/MenuTrigger/MenuTrigger.types.d.ts +0 -16
- package/lib/components/MenuTrigger/index.d.ts +0 -4
- package/lib/components/MenuTrigger/renderMenuTrigger.d.ts +0 -7
- package/lib/components/MenuTrigger/useMenuTrigger.d.ts +0 -8
- package/lib/components/MenuTrigger/useTriggerElement.d.ts +0 -5
- package/lib/components/MenuTrigger/useTriggerElement.js +0 -179
- package/lib/components/MenuTrigger/useTriggerElement.js.map +0 -1
- package/lib/components/index.d.ts +0 -2
- package/lib/contexts/menuContext.d.ts +0 -16
- package/lib/contexts/menuGroupContext.d.ts +0 -13
- package/lib/contexts/menuListContext.d.ts +0 -15
- package/lib/contexts/menuTriggerContext.d.ts +0 -3
- package/lib/index.d.ts +0 -15
- package/lib/selectable/index.d.ts +0 -2
- package/lib/selectable/types.d.ts +0 -34
- package/lib/selectable/useCheckmarkStyles.d.ts +0 -8
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/useIsSubmenu.d.ts +0 -9
- package/lib/utils/useOnMenuEnter.d.ts +0 -23
- package/lib-commonjs/Menu.d.ts +0 -1
- package/lib-commonjs/MenuDivider.d.ts +0 -1
- package/lib-commonjs/MenuGroup.d.ts +0 -1
- package/lib-commonjs/MenuGroupHeader.d.ts +0 -1
- package/lib-commonjs/MenuItem.d.ts +0 -1
- package/lib-commonjs/MenuItemCheckbox.d.ts +0 -1
- package/lib-commonjs/MenuItemRadio.d.ts +0 -1
- package/lib-commonjs/MenuList.d.ts +0 -1
- package/lib-commonjs/MenuPopover.d.ts +0 -1
- package/lib-commonjs/MenuTrigger.d.ts +0 -1
- package/lib-commonjs/common/isConformant.d.ts +0 -4
- package/lib-commonjs/common/isConformant.js +0 -23
- package/lib-commonjs/common/isConformant.js.map +0 -1
- package/lib-commonjs/common/mockUseMenuContext.d.ts +0 -7
- package/lib-commonjs/common/mockUseMenuContext.js +0 -47
- package/lib-commonjs/common/mockUseMenuContext.js.map +0 -1
- package/lib-commonjs/components/Menu/Menu.d.ts +0 -6
- package/lib-commonjs/components/Menu/Menu.types.d.ts +0 -112
- package/lib-commonjs/components/Menu/index.d.ts +0 -5
- package/lib-commonjs/components/Menu/renderMenu.d.ts +0 -5
- package/lib-commonjs/components/Menu/useMenu.d.ts +0 -10
- package/lib-commonjs/components/Menu/useMenuContextValues.d.ts +0 -2
- package/lib-commonjs/components/MenuDivider/MenuDivider.d.ts +0 -6
- package/lib-commonjs/components/MenuDivider/MenuDivider.types.d.ts +0 -6
- package/lib-commonjs/components/MenuDivider/index.d.ts +0 -5
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.d.ts +0 -6
- package/lib-commonjs/components/MenuDivider/useMenuDivider.d.ts +0 -6
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.d.ts +0 -2
- package/lib-commonjs/components/MenuGroup/MenuGroup.d.ts +0 -6
- package/lib-commonjs/components/MenuGroup/MenuGroup.types.d.ts +0 -15
- package/lib-commonjs/components/MenuGroup/index.d.ts +0 -5
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.d.ts +0 -6
- package/lib-commonjs/components/MenuGroup/useMenuGroup.d.ts +0 -6
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.d.ts +0 -2
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.d.ts +0 -6
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.types.d.ts +0 -6
- package/lib-commonjs/components/MenuGroupHeader/index.d.ts +0 -5
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.d.ts +0 -6
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.d.ts +0 -6
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.d.ts +0 -2
- package/lib-commonjs/components/MenuItem/MenuItem.d.ts +0 -6
- package/lib-commonjs/components/MenuItem/MenuItem.types.d.ts +0 -43
- package/lib-commonjs/components/MenuItem/index.d.ts +0 -5
- package/lib-commonjs/components/MenuItem/renderMenuItem.d.ts +0 -5
- package/lib-commonjs/components/MenuItem/useCharacterSearch.d.ts +0 -3
- package/lib-commonjs/components/MenuItem/useMenuItem.d.ts +0 -10
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.d.ts +0 -3
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.d.ts +0 -6
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.types.d.ts +0 -4
- package/lib-commonjs/components/MenuItemCheckbox/index.d.ts +0 -4
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.d.ts +0 -3
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.d.ts +0 -4
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.d.ts +0 -2
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.d.ts +0 -6
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.types.d.ts +0 -4
- package/lib-commonjs/components/MenuItemRadio/index.d.ts +0 -4
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.d.ts +0 -6
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.d.ts +0 -6
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.d.ts +0 -2
- package/lib-commonjs/components/MenuList/MenuList.d.ts +0 -6
- package/lib-commonjs/components/MenuList/MenuList.types.d.ts +0 -53
- package/lib-commonjs/components/MenuList/index.d.ts +0 -6
- package/lib-commonjs/components/MenuList/renderMenuList.d.ts +0 -5
- package/lib-commonjs/components/MenuList/useMenuList.d.ts +0 -6
- package/lib-commonjs/components/MenuList/useMenuListContextValues.d.ts +0 -2
- package/lib-commonjs/components/MenuList/useMenuListStyles.d.ts +0 -5
- package/lib-commonjs/components/MenuPopover/MenuPopover.d.ts +0 -6
- package/lib-commonjs/components/MenuPopover/MenuPopover.types.d.ts +0 -18
- package/lib-commonjs/components/MenuPopover/index.d.ts +0 -5
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.d.ts +0 -5
- package/lib-commonjs/components/MenuPopover/useMenuPopover.d.ts +0 -12
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.d.ts +0 -5
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.d.ts +0 -7
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.types.d.ts +0 -16
- package/lib-commonjs/components/MenuTrigger/index.d.ts +0 -4
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.d.ts +0 -7
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.d.ts +0 -8
- package/lib-commonjs/components/MenuTrigger/useTriggerElement.d.ts +0 -5
- package/lib-commonjs/components/MenuTrigger/useTriggerElement.js +0 -195
- package/lib-commonjs/components/MenuTrigger/useTriggerElement.js.map +0 -1
- package/lib-commonjs/components/index.d.ts +0 -2
- package/lib-commonjs/contexts/menuContext.d.ts +0 -16
- package/lib-commonjs/contexts/menuGroupContext.d.ts +0 -13
- package/lib-commonjs/contexts/menuListContext.d.ts +0 -15
- package/lib-commonjs/contexts/menuTriggerContext.d.ts +0 -3
- package/lib-commonjs/index.d.ts +0 -15
- package/lib-commonjs/selectable/index.d.ts +0 -2
- package/lib-commonjs/selectable/types.d.ts +0 -34
- package/lib-commonjs/selectable/useCheckmarkStyles.d.ts +0 -8
- package/lib-commonjs/utils/index.d.ts +0 -1
- package/lib-commonjs/utils/useIsSubmenu.d.ts +0 -9
- package/lib-commonjs/utils/useOnMenuEnter.d.ts +0 -23
@@ -1,13 +1,14 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { useMenuTrigger_unstable } from './useMenuTrigger';
|
2
|
+
import { renderMenuTrigger_unstable } from './renderMenuTrigger';
|
3
3
|
/**
|
4
4
|
* Wraps a trigger element as an only child
|
5
5
|
* and adds the necessary event handling to open a popup menu
|
6
6
|
*/
|
7
7
|
|
8
|
-
export
|
9
|
-
|
10
|
-
return
|
8
|
+
export const MenuTrigger = props => {
|
9
|
+
const state = useMenuTrigger_unstable(props);
|
10
|
+
return renderMenuTrigger_unstable(state);
|
11
11
|
};
|
12
12
|
MenuTrigger.displayName = 'MenuTrigger';
|
13
|
+
MenuTrigger.isFluentTriggerComponent = true;
|
13
14
|
//# sourceMappingURL=MenuTrigger.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/MenuTrigger/MenuTrigger.tsx"],"names":[],"mappings":"AACA,SAAS,uBAAT,QAAwC,kBAAxC;AACA,SAAS,0BAAT,QAA2C,qBAA3C;AAIA;;;AAGG;;AACH,OAAO,MAAM,WAAW,GAAwD,KAAK,IAAG;AACtF,QAAM,KAAK,GAAG,uBAAuB,CAAC,KAAD,CAArC;AAEA,SAAO,0BAA0B,CAAC,KAAD,CAAjC;AACD,CAJM;AAMP,WAAW,CAAC,WAAZ,GAA0B,aAA1B;AACA,WAAW,CAAC,wBAAZ,GAAuC,IAAvC","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> & FluentTriggerComponent = props => {\n const state = useMenuTrigger_unstable(props);\n\n return renderMenuTrigger_unstable(state);\n};\n\nMenuTrigger.displayName = 'MenuTrigger';\nMenuTrigger.isFluentTriggerComponent = true;\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MenuTrigger.types.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"MenuTrigger.types.js","sourceRoot":"../src/","sources":["components/MenuTrigger/MenuTrigger.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type MenuTriggerProps = {\n /**\n * Explicitly require single child or render function\n */\n children:\n | (React.ReactElement & { ref?: React.Ref<unknown> })\n | ((props: MenuTriggerChildProps) => React.ReactElement | null);\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 = Required<\n Pick<\n React.HTMLAttributes<HTMLElement>,\n 'onClick' | 'onMouseEnter' | 'onMouseLeave' | 'onMouseMove' | 'onContextMenu' | 'onKeyDown' | 'aria-haspopup' | 'id'\n >\n> & {\n ref?: React.Ref<never>;\n // aria-expanded should only be present when the menu when it is not a submenu\n 'aria-expanded': boolean | undefined;\n};\n\nexport type MenuTriggerState = {\n children: React.ReactElement | null;\n isSubmenu: boolean;\n};\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/MenuTrigger/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './MenuTrigger';\nexport * from './MenuTrigger.types';\nexport * from './renderMenuTrigger';\nexport * from './useMenuTrigger';\n"]}
|
@@ -6,9 +6,9 @@ import { MenuTriggerContextProvider } from '../../contexts/menuTriggerContext';
|
|
6
6
|
* Only renders children
|
7
7
|
*/
|
8
8
|
|
9
|
-
export
|
9
|
+
export const renderMenuTrigger_unstable = state => {
|
10
10
|
return /*#__PURE__*/React.createElement(MenuTriggerContextProvider, {
|
11
|
-
value:
|
11
|
+
value: state.isSubmenu
|
12
12
|
}, state.children);
|
13
13
|
};
|
14
14
|
//# sourceMappingURL=renderMenuTrigger.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/MenuTrigger/renderMenuTrigger.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,0BAAT,QAA2C,mCAA3C;AAGA;;;;AAIG;;AACH,OAAO,MAAM,0BAA0B,GAAI,KAAD,IAA4B;AACpE,sBAAO,KAAA,CAAA,aAAA,CAAC,0BAAD,EAA2B;AAAC,IAAA,KAAK,EAAE,KAAK,CAAC;AAAd,GAA3B,EAAqD,KAAK,CAAC,QAA3D,CAAP;AACD,CAFM","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"],"sourceRoot":"../src/"}
|
@@ -1,5 +1,11 @@
|
|
1
|
-
import
|
2
|
-
import {
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useMenuContext_unstable } from '../../contexts/menuContext';
|
3
|
+
import { useIsSubmenu } from '../../utils/useIsSubmenu';
|
4
|
+
import { useFocusFinders } from '@fluentui/react-tabster';
|
5
|
+
import { useFluent } from '@fluentui/react-shared-contexts';
|
6
|
+
import { ArrowRight, ArrowLeft, Escape, ArrowDown } from '@fluentui/keyboard-keys';
|
7
|
+
import { applyTriggerPropsToChildren, getTriggerChild, useMergedEventCallbacks, useMergedRefs } from '@fluentui/react-utilities';
|
8
|
+
import { shouldPreventDefaultOnKeyDown } from '@fluentui/react-utilities';
|
3
9
|
/**
|
4
10
|
* Create the state required to render MenuTrigger.
|
5
11
|
* Clones the only child component and adds necessary event handling behaviours to open a popup menu
|
@@ -7,10 +13,166 @@ import { useTriggerElement } from './useTriggerElement';
|
|
7
13
|
* @param props - props from this instance of MenuTrigger
|
8
14
|
*/
|
9
15
|
|
10
|
-
export
|
11
|
-
var
|
16
|
+
export const useMenuTrigger_unstable = props => {
|
17
|
+
var _a, _b, _c, _d, _e, _f;
|
12
18
|
|
19
|
+
const {
|
20
|
+
children
|
21
|
+
} = props;
|
22
|
+
const triggerRef = useMenuContext_unstable(context => context.triggerRef);
|
23
|
+
const menuPopoverRef = useMenuContext_unstable(context => context.menuPopoverRef);
|
24
|
+
const setOpen = useMenuContext_unstable(context => context.setOpen);
|
25
|
+
const open = useMenuContext_unstable(context => context.open);
|
26
|
+
const triggerId = useMenuContext_unstable(context => context.triggerId);
|
27
|
+
const openOnHover = useMenuContext_unstable(context => context.openOnHover);
|
28
|
+
const openOnContext = useMenuContext_unstable(context => context.openOnContext);
|
29
|
+
const isSubmenu = useIsSubmenu();
|
30
|
+
const {
|
31
|
+
findFirstFocusable
|
32
|
+
} = useFocusFinders();
|
33
|
+
const focusFirst = React.useCallback(() => {
|
34
|
+
const firstFocusable = findFirstFocusable(menuPopoverRef.current);
|
35
|
+
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
36
|
+
}, [findFirstFocusable, menuPopoverRef]);
|
37
|
+
const openedWithKeyboardRef = React.useRef(false);
|
38
|
+
const hasMouseMoved = React.useRef(false);
|
39
|
+
const {
|
40
|
+
dir
|
41
|
+
} = useFluent();
|
42
|
+
const OpenArrowKey = dir === 'ltr' ? ArrowRight : ArrowLeft;
|
43
|
+
const child = /*#__PURE__*/React.isValidElement(children) ? getTriggerChild(children) : undefined;
|
13
44
|
|
14
|
-
|
45
|
+
const onContextMenu = e => {
|
46
|
+
if (isTargetDisabled(e)) {
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
|
50
|
+
if (openOnContext) {
|
51
|
+
e.preventDefault();
|
52
|
+
setOpen(e, {
|
53
|
+
open: true,
|
54
|
+
keyboard: false
|
55
|
+
});
|
56
|
+
}
|
57
|
+
};
|
58
|
+
|
59
|
+
const onClick = e => {
|
60
|
+
if (isTargetDisabled(e)) {
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
|
64
|
+
if (!openOnContext) {
|
65
|
+
setOpen(e, {
|
66
|
+
open: !open,
|
67
|
+
keyboard: openedWithKeyboardRef.current
|
68
|
+
});
|
69
|
+
openedWithKeyboardRef.current = false;
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
const onKeyDown = e => {
|
74
|
+
var _a;
|
75
|
+
|
76
|
+
if (isTargetDisabled(e)) {
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
|
80
|
+
if (shouldPreventDefaultOnKeyDown(e)) {
|
81
|
+
e.preventDefault();
|
82
|
+
openedWithKeyboardRef.current = true;
|
83
|
+
(_a = e.target) === null || _a === void 0 ? void 0 : _a.click();
|
84
|
+
}
|
85
|
+
|
86
|
+
const key = e.key;
|
87
|
+
|
88
|
+
if (!openOnContext && (isSubmenu && key === OpenArrowKey || !isSubmenu && key === ArrowDown)) {
|
89
|
+
setOpen(e, {
|
90
|
+
open: true,
|
91
|
+
keyboard: true
|
92
|
+
});
|
93
|
+
}
|
94
|
+
|
95
|
+
if (key === Escape && !isSubmenu) {
|
96
|
+
setOpen(e, {
|
97
|
+
open: false,
|
98
|
+
keyboard: true
|
99
|
+
});
|
100
|
+
} // if menu is already open, can't rely on effects to focus
|
101
|
+
|
102
|
+
|
103
|
+
if (open && key === OpenArrowKey && isSubmenu) {
|
104
|
+
focusFirst();
|
105
|
+
}
|
106
|
+
};
|
107
|
+
|
108
|
+
const onMouseEnter = e => {
|
109
|
+
if (isTargetDisabled(e)) {
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
|
113
|
+
if (openOnHover && hasMouseMoved.current) {
|
114
|
+
setOpen(e, {
|
115
|
+
open: true,
|
116
|
+
keyboard: false
|
117
|
+
});
|
118
|
+
}
|
119
|
+
}; // Opening a menu when a mouse hasn't moved and just entering the trigger is a bad a11y experience
|
120
|
+
// First time open the mouse using mousemove and then continue with mouseenter
|
121
|
+
// Only use once to determine that the user is using the mouse since it is an expensive event to handle
|
122
|
+
|
123
|
+
|
124
|
+
const onMouseMove = e => {
|
125
|
+
if (isTargetDisabled(e)) {
|
126
|
+
return;
|
127
|
+
}
|
128
|
+
|
129
|
+
if (openOnHover && !hasMouseMoved.current) {
|
130
|
+
setOpen(e, {
|
131
|
+
open: true,
|
132
|
+
keyboard: false
|
133
|
+
});
|
134
|
+
hasMouseMoved.current = true;
|
135
|
+
}
|
136
|
+
};
|
137
|
+
|
138
|
+
const onMouseLeave = e => {
|
139
|
+
if (isTargetDisabled(e)) {
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
|
143
|
+
if (openOnHover) {
|
144
|
+
setOpen(e, {
|
145
|
+
open: false,
|
146
|
+
keyboard: false
|
147
|
+
});
|
148
|
+
}
|
149
|
+
};
|
150
|
+
|
151
|
+
return {
|
152
|
+
isSubmenu,
|
153
|
+
children: applyTriggerPropsToChildren(children, {
|
154
|
+
'aria-haspopup': 'menu',
|
155
|
+
'aria-expanded': !open && !isSubmenu ? undefined : open,
|
156
|
+
id: triggerId,
|
157
|
+
...(child === null || child === void 0 ? void 0 : child.props),
|
158
|
+
ref: useMergedRefs(triggerRef, child === null || child === void 0 ? void 0 : child.ref),
|
159
|
+
onClick: useMergedEventCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onClick, onClick),
|
160
|
+
onMouseEnter: useMergedEventCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onMouseEnter, onMouseEnter),
|
161
|
+
onMouseLeave: useMergedEventCallbacks((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.onMouseLeave, onMouseLeave),
|
162
|
+
onKeyDown: useMergedEventCallbacks((_d = child === null || child === void 0 ? void 0 : child.props) === null || _d === void 0 ? void 0 : _d.onKeyDown, onKeyDown),
|
163
|
+
onContextMenu: useMergedEventCallbacks((_e = child === null || child === void 0 ? void 0 : child.props) === null || _e === void 0 ? void 0 : _e.onContextMenu, onContextMenu),
|
164
|
+
onMouseMove: useMergedEventCallbacks((_f = child === null || child === void 0 ? void 0 : child.props) === null || _f === void 0 ? void 0 : _f.onMouseMove, onMouseMove)
|
165
|
+
})
|
166
|
+
};
|
167
|
+
};
|
168
|
+
|
169
|
+
const isTargetDisabled = e => {
|
170
|
+
const isDisabled = el => el.hasAttribute('disabled') || el.hasAttribute('aria-disabled') && el.getAttribute('aria-disabled') === 'true';
|
171
|
+
|
172
|
+
if (e.target instanceof HTMLElement && isDisabled(e.target)) {
|
173
|
+
return true;
|
174
|
+
}
|
175
|
+
|
176
|
+
return e.currentTarget instanceof HTMLElement && isDisabled(e.currentTarget);
|
15
177
|
};
|
16
178
|
//# sourceMappingURL=useMenuTrigger.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/MenuTrigger/useMenuTrigger.ts"],"names":[],"mappings":";AAAA,SAAS,iBAAT,QAAkC,qBAAlC;AAGA;;;;;AAKG;;AACH,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KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,KAAP,MAAY,IAAZ,IAAY,EAAA,KAAA,KAAA,CAAZ,GAAY,KAAA,CAAZ,GAAY,EAAA,CAAE,WAAf,EAA4B,WAA5B;AAXiC,KAAlC;AAFhC,GAAP;AAgBD,CA3HM;;AA6HP,MAAM,gBAAgB,GAAI,CAAD,IAAoC;AAC3D,QAAM,UAAU,GAAI,EAAD,IACjB,EAAE,CAAC,YAAH,CAAgB,UAAhB,KAAgC,EAAE,CAAC,YAAH,CAAgB,eAAhB,KAAoC,EAAE,CAAC,YAAH,CAAgB,eAAhB,MAAqC,MAD3G;;AAEA,MAAI,CAAC,CAAC,MAAF,YAAoB,WAApB,IAAmC,UAAU,CAAC,CAAC,CAAC,MAAH,CAAjD,EAA6D;AAC3D,WAAO,IAAP;AACD;;AAED,SAAO,CAAC,CAAC,aAAF,YAA2B,WAA3B,IAA0C,UAAU,CAAC,CAAC,CAAC,aAAH,CAA3D;AACD,CARD","sourcesContent":["import * as React from 'react';\nimport { MenuTriggerChildProps, MenuTriggerProps, MenuTriggerState } from './MenuTrigger.types';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport { ArrowRight, ArrowLeft, Escape, ArrowDown } from '@fluentui/keyboard-keys';\nimport {\n applyTriggerPropsToChildren,\n getTriggerChild,\n useMergedEventCallbacks,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { shouldPreventDefaultOnKeyDown } from '@fluentui/react-utilities';\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 } = 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 = React.isValidElement(children) ? getTriggerChild(children) : undefined;\n\n const onContextMenu = (e: React.MouseEvent<HTMLElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n\n if (openOnContext) {\n e.preventDefault();\n setOpen(e, { open: true, keyboard: false });\n }\n };\n\n const onClick = (e: React.MouseEvent<HTMLElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n\n if (!openOnContext) {\n setOpen(e, { open: !open, keyboard: openedWithKeyboardRef.current });\n openedWithKeyboardRef.current = false;\n }\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n\n if (shouldPreventDefaultOnKeyDown(e)) {\n e.preventDefault();\n openedWithKeyboardRef.current = true;\n (e.target as HTMLElement)?.click();\n }\n\n const key = e.key;\n\n if (!openOnContext && ((isSubmenu && key === OpenArrowKey) || (!isSubmenu && key === ArrowDown))) {\n setOpen(e, { open: true, keyboard: true });\n }\n\n if (key === Escape && !isSubmenu) {\n setOpen(e, { open: false, keyboard: true });\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 = (e: React.MouseEvent<HTMLElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n if (openOnHover && hasMouseMoved.current) {\n setOpen(e, { open: true, keyboard: false });\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 = (e: React.MouseEvent<HTMLElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n if (openOnHover && !hasMouseMoved.current) {\n setOpen(e, { open: true, keyboard: false });\n hasMouseMoved.current = true;\n }\n };\n\n const onMouseLeave = (e: React.MouseEvent<HTMLElement>) => {\n if (isTargetDisabled(e)) {\n return;\n }\n if (openOnHover) {\n setOpen(e, { open: false, keyboard: false });\n }\n };\n\n return {\n isSubmenu,\n children: applyTriggerPropsToChildren<MenuTriggerChildProps>(children, {\n 'aria-haspopup': 'menu',\n 'aria-expanded': !open && !isSubmenu ? undefined : open,\n id: triggerId,\n ...child?.props,\n ref: useMergedRefs(triggerRef, child?.ref),\n onClick: useMergedEventCallbacks(child?.props?.onClick, onClick),\n onMouseEnter: useMergedEventCallbacks(child?.props?.onMouseEnter, onMouseEnter),\n onMouseLeave: useMergedEventCallbacks(child?.props?.onMouseLeave, onMouseLeave),\n onKeyDown: useMergedEventCallbacks(child?.props?.onKeyDown, onKeyDown),\n onContextMenu: useMergedEventCallbacks(child?.props?.onContextMenu, onContextMenu),\n onMouseMove: useMergedEventCallbacks(child?.props?.onMouseMove, onMouseMove),\n }),\n };\n};\n\nconst isTargetDisabled = (e: React.SyntheticEvent | Event) => {\n const isDisabled = (el: HTMLElement) =>\n el.hasAttribute('disabled') || (el.hasAttribute('aria-disabled') && el.getAttribute('aria-disabled') === 'true');\n if (e.target instanceof HTMLElement && isDisabled(e.target)) {\n return true;\n }\n\n return e.currentTarget instanceof HTMLElement && isDisabled(e.currentTarget);\n};\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './MenuItem/index';\nexport * from './MenuList/index';\n"]}
|
@@ -1,13 +1,9 @@
|
|
1
1
|
import { createContext, useContextSelector } from '@fluentui/react-context-selector';
|
2
|
-
export
|
2
|
+
export const MenuContext = /*#__PURE__*/createContext({
|
3
3
|
open: false,
|
4
|
-
setOpen:
|
5
|
-
return false;
|
6
|
-
},
|
4
|
+
setOpen: () => false,
|
7
5
|
checkedValues: {},
|
8
|
-
onCheckedValueChange:
|
9
|
-
return null;
|
10
|
-
},
|
6
|
+
onCheckedValueChange: () => null,
|
11
7
|
defaultCheckedValues: {},
|
12
8
|
isSubmenu: false,
|
13
9
|
triggerRef: {
|
@@ -22,8 +18,6 @@ export var MenuContext = /*#__PURE__*/createContext({
|
|
22
18
|
hasIcons: false,
|
23
19
|
hasCheckmarks: false
|
24
20
|
});
|
25
|
-
export
|
26
|
-
export
|
27
|
-
return useContextSelector(MenuContext, selector);
|
28
|
-
};
|
21
|
+
export const MenuProvider = MenuContext.Provider;
|
22
|
+
export const useMenuContext_unstable = selector => useContextSelector(MenuContext, selector);
|
29
23
|
//# sourceMappingURL=menuContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["contexts/menuContext.ts"],"names":[],"mappings":"AACA,SAAS,aAAT,EAAwB,kBAAxB,QAAkD,kCAAlD;AAKA,OAAO,MAAM,WAAW,gBAA8B,aAAa,CAAmB;AACpF,EAAA,IAAI,EAAE,KAD8E;AAEpF,EAAA,OAAO,EAAE,MAAM,KAFqE;AAGpF,EAAA,aAAa,EAAE,EAHqE;AAIpF,EAAA,oBAAoB,EAAE,MAAM,IAJwD;AAKpF,EAAA,oBAAoB,EAAE,EAL8D;AAMpF,EAAA,SAAS,EAAE,KANyE;AAOpF,EAAA,UAAU,EAAG;AAAE,IAAA,OAAO,EAAE;AAAX,GAPuE;AAQpF,EAAA,cAAc,EAAG;AAAE,IAAA,OAAO,EAAE;AAAX,GARmE;AASpF,EAAA,SAAS,EAAE,EATyE;AAUpF,EAAA,aAAa,EAAE,KAVqE;AAWpF,EAAA,WAAW,EAAE,KAXuE;AAYpF,EAAA,QAAQ,EAAE,KAZ0E;AAapF,EAAA,aAAa,EAAE;AAbqE,CAAnB,CAA5D;AAwCP,OAAO,MAAM,YAAY,GAAG,WAAW,CAAC,QAAjC;AAEP,OAAO,MAAM,uBAAuB,GAAO,QAAJ,IACrC,kBAAkB,CAAC,WAAD,EAAc,QAAd,CADb","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 { MenuListProps } from '../components/index';\nimport type { MenuState } from '../components/Menu/index';\n\nexport const MenuContext: Context<MenuContextValue> = createContext<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});\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 = MenuListProps &\n 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 > & {\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, selector);\n"],"sourceRoot":"../src/"}
|
@@ -1,9 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
|
2
|
+
const MenuGroupContext = /*#__PURE__*/React.createContext({
|
3
3
|
headerId: ''
|
4
4
|
});
|
5
|
-
export
|
6
|
-
export
|
7
|
-
return React.useContext(MenuGroupContext);
|
8
|
-
};
|
5
|
+
export const MenuGroupContextProvider = MenuGroupContext.Provider;
|
6
|
+
export const useMenuGroupContext_unstable = () => React.useContext(MenuGroupContext);
|
9
7
|
//# sourceMappingURL=menuGroupContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["contexts/menuGroupContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA,MAAM,gBAAgB,gBAAG,KAAK,CAAC,aAAN,CAA2C;AAAE,EAAA,QAAQ,EAAE;AAAZ,CAA3C,CAAzB;AAaA,OAAO,MAAM,wBAAwB,GAAG,gBAAgB,CAAC,QAAlD;AACP,OAAO,MAAM,4BAA4B,GAAG,MAAM,KAAK,CAAC,UAAN,CAAiB,gBAAjB,CAA3C","sourcesContent":["import * as React from 'react';\n\nconst MenuGroupContext = React.createContext<MenuGroupContextValue>({ headerId: '' });\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);\n"],"sourceRoot":"../src/"}
|
@@ -1,23 +1,13 @@
|
|
1
1
|
import { createContext, useContextSelector } from '@fluentui/react-context-selector';
|
2
|
-
export
|
2
|
+
export const MenuListContext = /*#__PURE__*/createContext({
|
3
3
|
checkedValues: {},
|
4
|
-
onCheckedValueChange:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
return null;
|
9
|
-
},
|
10
|
-
toggleCheckbox: function () {
|
11
|
-
return null;
|
12
|
-
},
|
13
|
-
selectRadio: function () {
|
14
|
-
return null;
|
15
|
-
},
|
4
|
+
onCheckedValueChange: () => null,
|
5
|
+
setFocusByFirstCharacter: () => null,
|
6
|
+
toggleCheckbox: () => null,
|
7
|
+
selectRadio: () => null,
|
16
8
|
hasIcons: false,
|
17
9
|
hasCheckmarks: false
|
18
10
|
});
|
19
|
-
export
|
20
|
-
export
|
21
|
-
return useContextSelector(MenuListContext, selector);
|
22
|
-
};
|
11
|
+
export const MenuListProvider = MenuListContext.Provider;
|
12
|
+
export const useMenuListContext_unstable = selector => useContextSelector(MenuListContext, selector);
|
23
13
|
//# sourceMappingURL=menuListContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["contexts/menuListContext.tsx"],"names":[],"mappings":"AACA,SAAS,aAAT,EAAwB,kBAAxB,QAAkD,kCAAlD;AAKA,OAAO,MAAM,eAAe,gBAAkC,aAAa,CAAuB;AAChG,EAAA,aAAa,EAAE,EADiF;AAEhG,EAAA,oBAAoB,EAAE,MAAM,IAFoE;AAGhG,EAAA,wBAAwB,EAAE,MAAM,IAHgE;AAIhG,EAAA,cAAc,EAAE,MAAM,IAJ0E;AAKhG,EAAA,WAAW,EAAE,MAAM,IAL6E;AAMhG,EAAA,QAAQ,EAAE,KANsF;AAOhG,EAAA,aAAa,EAAE;AAPiF,CAAvB,CAApE;AAsBP,OAAO,MAAM,gBAAgB,GAAG,eAAe,CAAC,QAAzC;AAEP,OAAO,MAAM,2BAA2B,GAAQ,QAAL,IACzC,kBAAkB,CAAC,eAAD,EAAkB,QAAlB,CADb","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>({\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, selector);\n"],"sourceRoot":"../src/"}
|
@@ -1,11 +1,9 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
/**
|
3
|
-
* Context used communicate with child that it is a trigger for a
|
3
|
+
* Context used communicate with a child menu item that it is a trigger for a submenu
|
4
4
|
*/
|
5
5
|
|
6
|
-
|
7
|
-
export
|
8
|
-
export
|
9
|
-
return React.useContext(MenuTriggerContext);
|
10
|
-
};
|
6
|
+
const MenuTriggerContext = /*#__PURE__*/React.createContext(false);
|
7
|
+
export const MenuTriggerContextProvider = MenuTriggerContext.Provider;
|
8
|
+
export const useMenuTriggerContext_unstable = () => React.useContext(MenuTriggerContext);
|
11
9
|
//# sourceMappingURL=menuTriggerContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["contexts/menuTriggerContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;AAEG;;AACH,MAAM,kBAAkB,gBAAG,KAAK,CAAC,aAAN,CAA6B,KAA7B,CAA3B;AAEA,OAAO,MAAM,0BAA0B,GAAG,kBAAkB,CAAC,QAAtD;AACP,OAAO,MAAM,8BAA8B,GAAG,MAAM,KAAK,CAAC,UAAN,CAAiB,kBAAjB,CAA7C","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>(false);\n\nexport const MenuTriggerContextProvider = MenuTriggerContext.Provider;\nexport const useMenuTriggerContext_unstable = () => React.useContext(MenuTriggerContext);\n"],"sourceRoot":"../src/"}
|
package/lib/index.js
CHANGED
@@ -1,16 +1,26 @@
|
|
1
|
-
export
|
2
|
-
export
|
3
|
-
export
|
4
|
-
export
|
5
|
-
export
|
6
|
-
export
|
7
|
-
|
8
|
-
export
|
9
|
-
|
10
|
-
export
|
11
|
-
|
12
|
-
export
|
13
|
-
|
14
|
-
export
|
15
|
-
|
1
|
+
export { MenuContext, MenuProvider, useMenuContext_unstable } from './contexts/menuContext';
|
2
|
+
export { MenuTriggerContextProvider, useMenuTriggerContext_unstable } from './contexts/menuTriggerContext';
|
3
|
+
export { MenuGroupContextProvider, useMenuGroupContext_unstable } from './contexts/menuGroupContext';
|
4
|
+
export { MenuListContext, MenuListProvider, useMenuListContext_unstable } from './contexts/menuListContext';
|
5
|
+
export { Menu, renderMenu_unstable, useMenuContextValues_unstable, useMenu_unstable } from './Menu';
|
6
|
+
export { MenuDivider, // eslint-disable-next-line deprecation/deprecation
|
7
|
+
menuDividerClassName, menuDividerClassNames, renderMenuDivider_unstable, useMenuDividerStyles_unstable, useMenuDivider_unstable } from './MenuDivider';
|
8
|
+
export { MenuGroup, // eslint-disable-next-line deprecation/deprecation
|
9
|
+
menuGroupClassName, menuGroupClassNames, renderMenuGroup_unstable, useMenuGroupContextValues_unstable, useMenuGroupStyles_unstable, useMenuGroup_unstable } from './MenuGroup';
|
10
|
+
export { MenuGroupHeader, // eslint-disable-next-line deprecation/deprecation
|
11
|
+
menuGroupHeaderClassName, menuGroupHeaderClassNames, renderMenuGroupHeader_unstable, useMenuGroupHeaderStyles_unstable, useMenuGroupHeader_unstable } from './MenuGroupHeader';
|
12
|
+
export { MenuItem, // eslint-disable-next-line deprecation/deprecation
|
13
|
+
menuItemClassName, menuItemClassNames, renderMenuItem_unstable, useMenuItemStyles_unstable, useMenuItem_unstable } from './MenuItem';
|
14
|
+
export { MenuItemCheckbox, // eslint-disable-next-line deprecation/deprecation
|
15
|
+
menuItemCheckboxClassName, menuItemCheckboxClassNames, renderMenuItemCheckbox_unstable, useMenuItemCheckboxStyles_unstable, useMenuItemCheckbox_unstable } from './MenuItemCheckbox';
|
16
|
+
export { MenuItemRadio, // eslint-disable-next-line deprecation/deprecation
|
17
|
+
menuItemRadioClassName, menuItemRadioClassNames, renderMenuItemRadio_unstable, useMenuItemRadioStyles_unstable, useMenuItemRadio_unstable } from './MenuItemRadio';
|
18
|
+
export { MenuList, // eslint-disable-next-line deprecation/deprecation
|
19
|
+
menuListClassName, menuListClassNames, renderMenuList_unstable, useMenuListContextValues_unstable, useMenuListStyles_unstable, useMenuList_unstable } from './MenuList';
|
20
|
+
export { MenuPopover, // eslint-disable-next-line deprecation/deprecation
|
21
|
+
menuPopoverClassName, menuPopoverClassNames, renderMenuPopover_unstable, useMenuPopoverStyles_unstable, useMenuPopover_unstable } from './MenuPopover';
|
22
|
+
export { MenuSplitGroup, // eslint-disable-next-line deprecation/deprecation
|
23
|
+
menuSplitGroupClassName, menuSplitGroupClassNames, renderMenuSplitGroup_unstable, useMenuSplitGroupStyles_unstable, useMenuSplitGroup_unstable } from './MenuSplitGroup';
|
24
|
+
export { MenuTrigger, renderMenuTrigger_unstable, useMenuTrigger_unstable } from './MenuTrigger';
|
25
|
+
export { useCheckmarkStyles_unstable } from './selectable/index';
|
16
26
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,SAAS,WAAT,EAAsB,YAAtB,EAAoC,uBAAp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cesContent":["export { MenuContext, MenuProvider, useMenuContext_unstable } from './contexts/menuContext';\nexport type { MenuContextValue } from './contexts/menuContext';\nexport { MenuTriggerContextProvider, useMenuTriggerContext_unstable } from './contexts/menuTriggerContext';\nexport { MenuGroupContextProvider, useMenuGroupContext_unstable } from './contexts/menuGroupContext';\nexport type { MenuGroupContextValue } from './contexts/menuGroupContext';\nexport { MenuListContext, MenuListProvider, useMenuListContext_unstable } from './contexts/menuListContext';\nexport type { MenuListContextValue } from './contexts/menuListContext';\n\nexport { Menu, renderMenu_unstable, useMenuContextValues_unstable, useMenu_unstable } from './Menu';\nexport type { MenuContextValues, MenuOpenChangeData, MenuOpenEvents, MenuProps, MenuSlots, MenuState } from './Menu';\nexport {\n MenuDivider,\n // eslint-disable-next-line deprecation/deprecation\n menuDividerClassName,\n menuDividerClassNames,\n renderMenuDivider_unstable,\n useMenuDividerStyles_unstable,\n useMenuDivider_unstable,\n} from './MenuDivider';\nexport type { MenuDividerProps, MenuDividerSlots, MenuDividerState } from './MenuDivider';\nexport {\n MenuGroup,\n // eslint-disable-next-line deprecation/deprecation\n menuGroupClassName,\n menuGroupClassNames,\n renderMenuGroup_unstable,\n useMenuGroupContextValues_unstable,\n useMenuGroupStyles_unstable,\n useMenuGroup_unstable,\n} from './MenuGroup';\nexport type { MenuGroupContextValues, MenuGroupProps, MenuGroupSlots, MenuGroupState } from './MenuGroup';\nexport {\n MenuGroupHeader,\n // eslint-disable-next-line deprecation/deprecation\n menuGroupHeaderClassName,\n menuGroupHeaderClassNames,\n renderMenuGroupHeader_unstable,\n useMenuGroupHeaderStyles_unstable,\n useMenuGroupHeader_unstable,\n} from './MenuGroupHeader';\nexport type { MenuGroupHeaderProps, MenuGroupHeaderSlots, MenuGroupHeaderState } from './MenuGroupHeader';\nexport {\n MenuItem,\n // eslint-disable-next-line deprecation/deprecation\n menuItemClassName,\n menuItemClassNames,\n renderMenuItem_unstable,\n useMenuItemStyles_unstable,\n useMenuItem_unstable,\n} from './MenuItem';\nexport type { MenuItemProps, MenuItemSlots, MenuItemState } from './MenuItem';\nexport {\n MenuItemCheckbox,\n // eslint-disable-next-line deprecation/deprecation\n menuItemCheckboxClassName,\n menuItemCheckboxClassNames,\n renderMenuItemCheckbox_unstable,\n useMenuItemCheckboxStyles_unstable,\n useMenuItemCheckbox_unstable,\n} from './MenuItemCheckbox';\nexport type { MenuItemCheckboxProps, MenuItemCheckboxState } from './MenuItemCheckbox';\nexport {\n MenuItemRadio,\n // eslint-disable-next-line deprecation/deprecation\n menuItemRadioClassName,\n menuItemRadioClassNames,\n renderMenuItemRadio_unstable,\n useMenuItemRadioStyles_unstable,\n useMenuItemRadio_unstable,\n} from './MenuItemRadio';\nexport type { MenuItemRadioProps, MenuItemRadioState } from './MenuItemRadio';\nexport {\n MenuList,\n // eslint-disable-next-line deprecation/deprecation\n menuListClassName,\n menuListClassNames,\n renderMenuList_unstable,\n useMenuListContextValues_unstable,\n useMenuListStyles_unstable,\n useMenuList_unstable,\n} from './MenuList';\nexport type {\n MenuCheckedValueChangeData,\n MenuCheckedValueChangeEvent,\n MenuListContextValues,\n MenuListProps,\n MenuListSlots,\n MenuListState,\n UninitializedMenuListState,\n} from './MenuList';\nexport {\n MenuPopover,\n // eslint-disable-next-line deprecation/deprecation\n menuPopoverClassName,\n menuPopoverClassNames,\n renderMenuPopover_unstable,\n useMenuPopoverStyles_unstable,\n useMenuPopover_unstable,\n} from './MenuPopover';\nexport type { MenuPopoverProps, MenuPopoverSlots, MenuPopoverState } from './MenuPopover';\nexport {\n MenuSplitGroup,\n // eslint-disable-next-line deprecation/deprecation\n menuSplitGroupClassName,\n menuSplitGroupClassNames,\n renderMenuSplitGroup_unstable,\n useMenuSplitGroupStyles_unstable,\n useMenuSplitGroup_unstable,\n} from './MenuSplitGroup';\nexport type { MenuSplitGroupProps, MenuSplitGroupSlots, MenuSplitGroupState } from './MenuSplitGroup';\nexport { MenuTrigger, renderMenuTrigger_unstable, useMenuTrigger_unstable } from './MenuTrigger';\nexport type { MenuTriggerChildProps, MenuTriggerProps, MenuTriggerState } from './MenuTrigger';\n\nexport { useCheckmarkStyles_unstable } from './selectable/index';\nexport type { MenuItemSelectableProps, MenuItemSelectableState, SelectableHandler } from './selectable/index';\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["selectable/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC","sourcesContent":["export * from './useCheckmarkStyles';\nexport * from './types';\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["selectable/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type SelectableHandler = (\n e: React.MouseEvent | React.KeyboardEvent,\n name: string,\n value: string,\n checked: boolean,\n) => void;\n\n/**\n * Props for selecatble menu items\n */\nexport type MenuItemSelectableProps = {\n /**\n * Follows input convention\n * https://www.w3schools.com/jsref/prop_checkbox_name.asp\n */\n name: string;\n\n /**\n * Follows input convention\n * https://www.w3schools.com/jsref/prop_checkbox_value.asp\n */\n value: string;\n};\n\n/**\n * State for selectable menu items\n */\nexport type MenuItemSelectableState = MenuItemSelectableProps & {\n /**\n * Checked items for a value with `name`\n */\n checkedItems: string[];\n\n /**\n * Callback when checked items changes for a given value with `name`\n */\n onCheckedValueChange: (e: React.MouseEvent | React.KeyboardEvent, name: string, checkedItems: string[]) => void;\n\n /**\n * Selectable is checked\n */\n checked: boolean;\n};\n"]}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { mergeClasses, __styles } from '@
|
1
|
+
import { mergeClasses, __styles } from '@griffel/react';
|
2
2
|
|
3
|
-
|
3
|
+
const useStyles = /*#__PURE__*/__styles({
|
4
4
|
"root": {
|
5
5
|
"a9b677": "fjw5fx7",
|
6
6
|
"Bqenvij": "fd461yt",
|
@@ -19,8 +19,8 @@ var useStyles = /*#__PURE__*/__styles({
|
|
19
19
|
*/
|
20
20
|
|
21
21
|
|
22
|
-
export
|
23
|
-
|
22
|
+
export const useCheckmarkStyles_unstable = state => {
|
23
|
+
const styles = useStyles();
|
24
24
|
|
25
25
|
if (state.checkmark) {
|
26
26
|
state.checkmark.className = mergeClasses(styles.root, state.checked && styles.rootChecked, state.checkmark.className);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["selectable/useCheckmarkStyles.ts"],"names":[],"mappings":"AAAA,SAAS,YAAT,kBAAyC,gBAAzC;;AAIA,MAAM,SAAS,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAlB;AAWA;;;;AAIG;;;AACH,OAAO,MAAM,2BAA2B,GAAI,KAAD,IAAsE;AAC/G,QAAM,MAAM,GAAG,SAAS,EAAxB;;AACA,MAAI,KAAK,CAAC,SAAV,EAAqB;AACnB,IAAA,KAAK,CAAC,SAAN,CAAgB,SAAhB,GAA4B,YAAY,CACtC,MAAM,CAAC,IAD+B,EAEtC,KAAK,CAAC,OAAN,IAAiB,MAAM,CAAC,WAFc,EAGtC,KAAK,CAAC,SAAN,CAAgB,SAHsB,CAAxC;AAKD;AACF,CATM","sourcesContent":["import { mergeClasses, makeStyles } from '@griffel/react';\nimport type { MenuItemSelectableState } from './types';\nimport type { MenuItemState } from '../components/MenuItem/MenuItem.types';\n\nconst useStyles = makeStyles({\n root: {\n width: '16px',\n height: '16px',\n visibility: 'hidden',\n },\n rootChecked: {\n visibility: 'visible',\n },\n});\n\n/**\n * Applies styles to a checkmark slot for selectable menu items\n *\n * @param state - should contain a `checkmark` slot\n */\nexport const useCheckmarkStyles_unstable = (state: MenuItemSelectableState & Pick<MenuItemState, 'checkmark'>) => {\n const styles = useStyles();\n if (state.checkmark) {\n state.checkmark.className = mergeClasses(\n styles.root,\n state.checked && styles.rootChecked,\n state.checkmark.className,\n );\n }\n};\n"],"sourceRoot":"../src/"}
|
package/lib/utils/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './useOnMenuEnter';\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useHasParentContext } from '@fluentui/react-context-selector';
|
2
|
-
import {
|
2
|
+
import { useMenuContext_unstable } from '../contexts/menuContext';
|
3
3
|
import { MenuListContext } from '../contexts/menuListContext';
|
4
4
|
/**
|
5
5
|
* A component can be a part of a submenu whether its menu context `isSubmenu` flag is true
|
@@ -11,10 +11,8 @@ import { MenuListContext } from '../contexts/menuListContext';
|
|
11
11
|
*/
|
12
12
|
|
13
13
|
export function useIsSubmenu() {
|
14
|
-
|
15
|
-
|
16
|
-
});
|
17
|
-
var hasMenuListContext = useHasParentContext(MenuListContext);
|
14
|
+
const menuContextValue = useMenuContext_unstable(context => context.isSubmenu);
|
15
|
+
const hasMenuListContext = useHasParentContext(MenuListContext);
|
18
16
|
return menuContextValue || hasMenuListContext;
|
19
17
|
}
|
20
18
|
//# sourceMappingURL=useIsSubmenu.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["utils/useIsSubmenu.ts"],"names":[],"mappings":"AAAA,SAAS,mBAAT,QAAoC,kCAApC;AACA,SAAS,uBAAT,QAAwC,yBAAxC;AACA,SAAS,eAAT,QAAgC,6BAAhC;AAEA;;;;;;;AAOG;;AACH,OAAM,SAAU,YAAV,GAAsB;AAC1B,QAAM,gBAAgB,GAAG,uBAAuB,CAAC,OAAO,IAAI,OAAO,CAAC,SAApB,CAAhD;AACA,QAAM,kBAAkB,GAAG,mBAAmB,CAAC,eAAD,CAA9C;AAEA,SAAO,gBAAgB,IAAI,kBAA3B;AACD","sourcesContent":["import { useHasParentContext } from '@fluentui/react-context-selector';\nimport { useMenuContext_unstable } from '../contexts/menuContext';\nimport { MenuListContext } from '../contexts/menuListContext';\n\n/**\n * A component can be a part of a submenu whether its menu context `isSubmenu` flag is true\n * or whether it is a part of a `MenuList`\n *\n * A simple hook to check box contexts easily\n *\n * @returns whether the component is part of a submenu\n */\nexport function useIsSubmenu() {\n const menuContextValue = useMenuContext_unstable(context => context.isSubmenu);\n const hasMenuListContext = useHasParentContext(MenuListContext);\n\n return menuContextValue || hasMenuListContext;\n}\n"],"sourceRoot":"../src/"}
|
@@ -5,7 +5,7 @@ import { elementContains } from '@fluentui/react-portal';
|
|
5
5
|
* Name of the custom event
|
6
6
|
*/
|
7
7
|
|
8
|
-
export
|
8
|
+
export const MENU_ENTER_EVENT = 'fuimenuenter';
|
9
9
|
/**
|
10
10
|
* This hook works similarly to @see {useOnClickOutside}
|
11
11
|
*
|
@@ -18,27 +18,29 @@ export var MENU_ENTER_EVENT = 'fuimenuenter';
|
|
18
18
|
* Each nested menu can use the listener to check if the event is from a child or parent menu
|
19
19
|
*/
|
20
20
|
|
21
|
-
export
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
export const useOnMenuMouseEnter = options => {
|
22
|
+
const {
|
23
|
+
refs,
|
24
|
+
callback,
|
25
|
+
element,
|
26
|
+
disabled
|
27
|
+
} = options; // Keep mouse event here because this is essentially a custom 'mouseenter' event
|
26
28
|
|
27
|
-
|
29
|
+
const listener = useEventCallback(ev => {
|
28
30
|
var _a;
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
+
const popoverRef = refs[0];
|
33
|
+
const someMenuPopover = ev.target; // someMenu is a child -> will always be contained because of vParents
|
32
34
|
// someMenu is a parent -> will always not be contained because no vParent
|
33
35
|
// someMenu is the current popover -> it will contain itself
|
34
36
|
|
35
|
-
|
37
|
+
const isOutsidePopover = !elementContains((_a = popoverRef.current) !== null && _a !== void 0 ? _a : null, someMenuPopover);
|
36
38
|
|
37
39
|
if (isOutsidePopover && !disabled) {
|
38
40
|
callback(ev);
|
39
41
|
}
|
40
42
|
});
|
41
|
-
React.useEffect(
|
43
|
+
React.useEffect(() => {
|
42
44
|
// eslint-disable-next-line eqeqeq
|
43
45
|
if (element == null) {
|
44
46
|
return;
|
@@ -48,7 +50,7 @@ export var useOnMenuMouseEnter = function (options) {
|
|
48
50
|
element.addEventListener(MENU_ENTER_EVENT, listener);
|
49
51
|
}
|
50
52
|
|
51
|
-
return
|
53
|
+
return () => {
|
52
54
|
element.removeEventListener(MENU_ENTER_EVENT, listener);
|
53
55
|
};
|
54
56
|
}, [listener, element, disabled]);
|
@@ -59,11 +61,11 @@ export var useOnMenuMouseEnter = function (options) {
|
|
59
61
|
* @param nativeEvent the native mouse event this is mapped to
|
60
62
|
*/
|
61
63
|
|
62
|
-
export
|
64
|
+
export const dispatchMenuEnterEvent = (el, nativeEvent) => {
|
63
65
|
el.dispatchEvent(new CustomEvent(MENU_ENTER_EVENT, {
|
64
66
|
bubbles: true,
|
65
67
|
detail: {
|
66
|
-
nativeEvent
|
68
|
+
nativeEvent
|
67
69
|
}
|
68
70
|
}));
|
69
71
|
};
|