@fluentui/react-menu 9.7.4 → 9.7.5
Sign up to get free protection for your applications and to get access to all the features.
- package/.swcrc +30 -0
- package/CHANGELOG.json +94 -1
- package/CHANGELOG.md +24 -2
- 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.map +1 -1
- package/lib/MenuTrigger.js.map +1 -1
- package/lib/components/Menu/Menu.js +1 -0
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/Menu.types.js +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.map +1 -1
- package/lib/components/Menu/useMenu.js +9 -8
- package/lib/components/Menu/useMenu.js.map +1 -1
- package/lib/components/Menu/useMenuContextValues.js.map +1 -1
- 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 +1 -3
- package/lib/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDivider.js +1 -0
- package/lib/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- 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.map +1 -1
- package/lib/components/MenuGroup/renderMenuGroup.js +1 -3
- package/lib/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroup.js +1 -0
- 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.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 +1 -3
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js +1 -0
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- 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 +1 -13
- package/lib/components/MenuItem/renderMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useCharacterSearch.js +3 -2
- package/lib/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib/components/MenuItem/useMenuItem.js +7 -7
- package/lib/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useMenuItemStyles.js +15 -2
- package/lib/components/MenuItem/useMenuItemStyles.js.map +1 -1
- 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.map +1 -1
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js +1 -11
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js +4 -4
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- 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.map +1 -1
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js +1 -11
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadio.js +4 -4
- package/lib/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib/components/MenuList/MenuList.js.map +1 -1
- package/lib/components/MenuList/MenuList.types.js +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 +1 -3
- package/lib/components/MenuList/renderMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuList.js +6 -5
- package/lib/components/MenuList/useMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib/components/MenuList/useMenuListStyles.js.map +1 -1
- 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 +2 -6
- package/lib/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopover.js +4 -4
- package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -1
- package/lib/components/MenuSplitGroup/MenuSplitGroup.types.js.map +1 -1
- package/lib/components/MenuSplitGroup/index.js.map +1 -1
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.js +1 -3
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -1
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js +2 -2
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -1
- package/lib/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -1
- package/lib/components/MenuTrigger/MenuTrigger.js +1 -0
- package/lib/components/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/MenuTrigger.types.js +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.map +1 -1
- package/lib/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib/components/index.js.map +1 -1
- package/lib/contexts/menuContext.js +1 -0
- package/lib/contexts/menuContext.js.map +1 -1
- package/lib/contexts/menuGroupContext.js +2 -4
- package/lib/contexts/menuGroupContext.js.map +1 -1
- package/lib/contexts/menuListContext.js +1 -0
- package/lib/contexts/menuListContext.js.map +1 -1
- package/lib/contexts/menuTriggerContext.js +2 -4
- package/lib/contexts/menuTriggerContext.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/selectable/index.js.map +1 -1
- package/lib/selectable/types.js +1 -1
- package/lib/selectable/types.js.map +1 -1
- package/lib/selectable/useCheckmarkStyles.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/useIsSubmenu.js.map +1 -1
- package/lib/utils/useOnMenuEnter.js +2 -2
- package/lib/utils/useOnMenuEnter.js.map +1 -1
- package/lib-commonjs/Menu.js +5 -4
- package/lib-commonjs/Menu.js.map +1 -1
- package/lib-commonjs/MenuDivider.js +5 -4
- package/lib-commonjs/MenuDivider.js.map +1 -1
- package/lib-commonjs/MenuGroup.js +5 -4
- package/lib-commonjs/MenuGroup.js.map +1 -1
- package/lib-commonjs/MenuGroupHeader.js +5 -4
- package/lib-commonjs/MenuGroupHeader.js.map +1 -1
- package/lib-commonjs/MenuItem.js +5 -4
- package/lib-commonjs/MenuItem.js.map +1 -1
- package/lib-commonjs/MenuItemCheckbox.js +5 -4
- package/lib-commonjs/MenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/MenuItemRadio.js +5 -4
- package/lib-commonjs/MenuItemRadio.js.map +1 -1
- package/lib-commonjs/MenuList.js +5 -4
- package/lib-commonjs/MenuList.js.map +1 -1
- package/lib-commonjs/MenuPopover.js +5 -4
- package/lib-commonjs/MenuPopover.js.map +1 -1
- package/lib-commonjs/MenuSplitGroup.js +5 -4
- package/lib-commonjs/MenuSplitGroup.js.map +1 -1
- package/lib-commonjs/MenuTrigger.js +5 -4
- package/lib-commonjs/MenuTrigger.js.map +1 -1
- package/lib-commonjs/components/Menu/Menu.js +16 -15
- package/lib-commonjs/components/Menu/Menu.js.map +1 -1
- package/lib-commonjs/components/Menu/Menu.types.js +5 -2
- package/lib-commonjs/components/Menu/Menu.types.js.map +1 -1
- package/lib-commonjs/components/Menu/index.js +9 -8
- package/lib-commonjs/components/Menu/index.js.map +1 -1
- package/lib-commonjs/components/Menu/renderMenu.js +14 -14
- package/lib-commonjs/components/Menu/renderMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenu.js +258 -256
- package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenuContextValues.js +29 -43
- package/lib-commonjs/components/Menu/useMenuContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/MenuDivider.js +19 -20
- package/lib-commonjs/components/MenuDivider/MenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/MenuDivider.types.js +3 -2
- package/lib-commonjs/components/MenuDivider/MenuDivider.types.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/index.js +9 -8
- package/lib-commonjs/components/MenuDivider/index.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.js +13 -19
- package/lib-commonjs/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/useMenuDivider.js +22 -21
- package/lib-commonjs/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js +47 -25
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/MenuGroup.js +21 -22
- package/lib-commonjs/components/MenuGroup/MenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/MenuGroup.types.js +3 -2
- package/lib-commonjs/components/MenuGroup/MenuGroup.types.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/index.js +10 -9
- package/lib-commonjs/components/MenuGroup/index.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.js +16 -22
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroup.js +23 -22
- package/lib-commonjs/components/MenuGroup/useMenuGroup.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.js +18 -15
- package/lib-commonjs/components/MenuGroup/useMenuGroupContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js +19 -11
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.js +19 -20
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.types.js +3 -2
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.types.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/index.js +9 -8
- package/lib-commonjs/components/MenuGroupHeader/index.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.js +13 -19
- package/lib-commonjs/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.js +22 -23
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +47 -25
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItem/MenuItem.js +19 -20
- package/lib-commonjs/components/MenuItem/MenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/MenuItem.types.js +3 -2
- package/lib-commonjs/components/MenuItem/MenuItem.types.js.map +1 -1
- package/lib-commonjs/components/MenuItem/index.js +9 -8
- package/lib-commonjs/components/MenuItem/index.js.map +1 -1
- package/lib-commonjs/components/MenuItem/renderMenuItem.js +13 -28
- package/lib-commonjs/components/MenuItem/renderMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js +24 -22
- package/lib-commonjs/components/MenuItem/useCharacterSearch.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItem.js +97 -104
- package/lib-commonjs/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js +318 -137
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.js +19 -20
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.types.js +3 -2
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.types.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/index.js +9 -8
- package/lib-commonjs/components/MenuItemCheckbox/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.js +13 -24
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js +44 -45
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +38 -30
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.js +19 -20
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.types.js +3 -2
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.types.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/index.js +9 -8
- package/lib-commonjs/components/MenuItemRadio/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.js +13 -27
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js +42 -45
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js +38 -30
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib-commonjs/components/MenuList/MenuList.js +21 -22
- package/lib-commonjs/components/MenuList/MenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/MenuList.types.js +5 -2
- package/lib-commonjs/components/MenuList/MenuList.types.js.map +1 -1
- package/lib-commonjs/components/MenuList/index.js +10 -9
- package/lib-commonjs/components/MenuList/index.js.map +1 -1
- package/lib-commonjs/components/MenuList/renderMenuList.js +16 -21
- package/lib-commonjs/components/MenuList/renderMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuList.js +143 -137
- package/lib-commonjs/components/MenuList/useMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListContextValues.js +20 -25
- package/lib-commonjs/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListStyles.js +33 -23
- package/lib-commonjs/components/MenuList/useMenuListStyles.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/MenuPopover.js +19 -20
- package/lib-commonjs/components/MenuPopover/MenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/MenuPopover.types.js +3 -2
- package/lib-commonjs/components/MenuPopover/MenuPopover.types.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/index.js +9 -8
- package/lib-commonjs/components/MenuPopover/index.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.js +19 -26
- package/lib-commonjs/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js +102 -110
- package/lib-commonjs/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js +121 -50
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.js +19 -20
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.types.js +3 -2
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.types.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/index.js +9 -8
- package/lib-commonjs/components/MenuSplitGroup/index.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/renderMenuSplitGroup.js +13 -18
- package/lib-commonjs/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroup.js +58 -64
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroupStyles.js +61 -32
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.js +15 -15
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.types.js +5 -2
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.types.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/index.js +8 -7
- package/lib-commonjs/components/MenuTrigger/index.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.js +14 -16
- package/lib-commonjs/components/MenuTrigger/renderMenuTrigger.js.map +1 -1
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js +163 -170
- package/lib-commonjs/components/MenuTrigger/useMenuTrigger.js.map +1 -1
- package/lib-commonjs/components/index.js +6 -5
- package/lib-commonjs/components/index.js.map +1 -1
- package/lib-commonjs/contexts/menuContext.js +38 -27
- package/lib-commonjs/contexts/menuContext.js.map +1 -1
- package/lib-commonjs/contexts/menuGroupContext.js +19 -12
- package/lib-commonjs/contexts/menuGroupContext.js.map +1 -1
- package/lib-commonjs/contexts/menuListContext.js +25 -14
- package/lib-commonjs/contexts/menuListContext.js.map +1 -1
- package/lib-commonjs/contexts/menuTriggerContext.js +18 -12
- package/lib-commonjs/contexts/menuTriggerContext.js.map +1 -1
- package/lib-commonjs/index.js +91 -399
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/selectable/index.js +6 -5
- package/lib-commonjs/selectable/index.js.map +1 -1
- package/lib-commonjs/selectable/types.js +5 -2
- package/lib-commonjs/selectable/types.js.map +1 -1
- package/lib-commonjs/selectable/useCheckmarkStyles.js +28 -26
- package/lib-commonjs/selectable/useCheckmarkStyles.js.map +1 -1
- package/lib-commonjs/utils/index.js +5 -4
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/useIsSubmenu.js +13 -19
- package/lib-commonjs/utils/useIsSubmenu.js.map +1 -1
- package/lib-commonjs/utils/useOnMenuEnter.js +57 -68
- package/lib-commonjs/utils/useOnMenuEnter.js.map +1 -1
- package/package.json +15 -14
- package/lib-amd/Menu.js +0 -6
- package/lib-amd/Menu.js.map +0 -1
- package/lib-amd/MenuDivider.js +0 -6
- package/lib-amd/MenuDivider.js.map +0 -1
- package/lib-amd/MenuGroup.js +0 -6
- package/lib-amd/MenuGroup.js.map +0 -1
- package/lib-amd/MenuGroupHeader.js +0 -6
- package/lib-amd/MenuGroupHeader.js.map +0 -1
- package/lib-amd/MenuItem.js +0 -6
- package/lib-amd/MenuItem.js.map +0 -1
- package/lib-amd/MenuItemCheckbox.js +0 -6
- package/lib-amd/MenuItemCheckbox.js.map +0 -1
- package/lib-amd/MenuItemRadio.js +0 -6
- package/lib-amd/MenuItemRadio.js.map +0 -1
- package/lib-amd/MenuList.js +0 -6
- package/lib-amd/MenuList.js.map +0 -1
- package/lib-amd/MenuPopover.js +0 -6
- package/lib-amd/MenuPopover.js.map +0 -1
- package/lib-amd/MenuSplitGroup.js +0 -6
- package/lib-amd/MenuSplitGroup.js.map +0 -1
- package/lib-amd/MenuTrigger.js +0 -6
- package/lib-amd/MenuTrigger.js.map +0 -1
- package/lib-amd/components/Menu/Menu.js +0 -16
- package/lib-amd/components/Menu/Menu.js.map +0 -1
- package/lib-amd/components/Menu/Menu.types.js +0 -5
- package/lib-amd/components/Menu/Menu.types.js.map +0 -1
- package/lib-amd/components/Menu/index.js +0 -10
- package/lib-amd/components/Menu/index.js.map +0 -1
- package/lib-amd/components/Menu/renderMenu.js +0 -15
- package/lib-amd/components/Menu/renderMenu.js.map +0 -1
- package/lib-amd/components/Menu/useMenu.js +0 -224
- package/lib-amd/components/Menu/useMenu.js.map +0 -1
- package/lib-amd/components/Menu/useMenuContextValues.js +0 -29
- package/lib-amd/components/Menu/useMenuContextValues.js.map +0 -1
- package/lib-amd/components/MenuDivider/MenuDivider.js +0 -17
- package/lib-amd/components/MenuDivider/MenuDivider.js.map +0 -1
- package/lib-amd/components/MenuDivider/MenuDivider.types.js +0 -5
- package/lib-amd/components/MenuDivider/MenuDivider.types.js.map +0 -1
- package/lib-amd/components/MenuDivider/index.js +0 -10
- package/lib-amd/components/MenuDivider/index.js.map +0 -1
- package/lib-amd/components/MenuDivider/renderMenuDivider.js +0 -15
- package/lib-amd/components/MenuDivider/renderMenuDivider.js.map +0 -1
- package/lib-amd/components/MenuDivider/useMenuDivider.js +0 -18
- package/lib-amd/components/MenuDivider/useMenuDivider.js.map +0 -1
- package/lib-amd/components/MenuDivider/useMenuDividerStyles.js +0 -18
- package/lib-amd/components/MenuDivider/useMenuDividerStyles.js.map +0 -1
- package/lib-amd/components/MenuGroup/MenuGroup.js +0 -18
- package/lib-amd/components/MenuGroup/MenuGroup.js.map +0 -1
- package/lib-amd/components/MenuGroup/MenuGroup.types.js +0 -5
- package/lib-amd/components/MenuGroup/MenuGroup.types.js.map +0 -1
- package/lib-amd/components/MenuGroup/index.js +0 -11
- package/lib-amd/components/MenuGroup/index.js.map +0 -1
- package/lib-amd/components/MenuGroup/renderMenuGroup.js +0 -16
- package/lib-amd/components/MenuGroup/renderMenuGroup.js.map +0 -1
- package/lib-amd/components/MenuGroup/useMenuGroup.js +0 -20
- package/lib-amd/components/MenuGroup/useMenuGroup.js.map +0 -1
- package/lib-amd/components/MenuGroup/useMenuGroupContextValues.js +0 -12
- package/lib-amd/components/MenuGroup/useMenuGroupContextValues.js.map +0 -1
- package/lib-amd/components/MenuGroup/useMenuGroupStyles.js +0 -14
- package/lib-amd/components/MenuGroup/useMenuGroupStyles.js.map +0 -1
- package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.js +0 -17
- package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.js.map +0 -1
- package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.types.js +0 -5
- package/lib-amd/components/MenuGroupHeader/MenuGroupHeader.types.js.map +0 -1
- package/lib-amd/components/MenuGroupHeader/index.js +0 -10
- package/lib-amd/components/MenuGroupHeader/index.js.map +0 -1
- package/lib-amd/components/MenuGroupHeader/renderMenuGroupHeader.js +0 -15
- package/lib-amd/components/MenuGroupHeader/renderMenuGroupHeader.js.map +0 -1
- package/lib-amd/components/MenuGroupHeader/useMenuGroupHeader.js +0 -19
- package/lib-amd/components/MenuGroupHeader/useMenuGroupHeader.js.map +0 -1
- package/lib-amd/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +0 -27
- package/lib-amd/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +0 -1
- package/lib-amd/components/MenuItem/MenuItem.js +0 -17
- package/lib-amd/components/MenuItem/MenuItem.js.map +0 -1
- package/lib-amd/components/MenuItem/MenuItem.types.js +0 -5
- package/lib-amd/components/MenuItem/MenuItem.types.js.map +0 -1
- package/lib-amd/components/MenuItem/index.js +0 -10
- package/lib-amd/components/MenuItem/index.js.map +0 -1
- package/lib-amd/components/MenuItem/renderMenuItem.js +0 -19
- package/lib-amd/components/MenuItem/renderMenuItem.js.map +0 -1
- package/lib-amd/components/MenuItem/useCharacterSearch.js +0 -22
- package/lib-amd/components/MenuItem/useCharacterSearch.js.map +0 -1
- package/lib-amd/components/MenuItem/useMenuItem.js +0 -75
- package/lib-amd/components/MenuItem/useMenuItem.js.map +0 -1
- package/lib-amd/components/MenuItem/useMenuItemStyles.js +0 -109
- package/lib-amd/components/MenuItem/useMenuItemStyles.js.map +0 -1
- package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.js +0 -17
- package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.js.map +0 -1
- package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.types.js +0 -5
- package/lib-amd/components/MenuItemCheckbox/MenuItemCheckbox.types.js.map +0 -1
- package/lib-amd/components/MenuItemCheckbox/index.js +0 -10
- package/lib-amd/components/MenuItemCheckbox/index.js.map +0 -1
- package/lib-amd/components/MenuItemCheckbox/renderMenuItemCheckbox.js +0 -16
- package/lib-amd/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +0 -1
- package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckbox.js +0 -26
- package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +0 -1
- package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +0 -31
- package/lib-amd/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +0 -1
- package/lib-amd/components/MenuItemRadio/MenuItemRadio.js +0 -17
- package/lib-amd/components/MenuItemRadio/MenuItemRadio.js.map +0 -1
- package/lib-amd/components/MenuItemRadio/MenuItemRadio.types.js +0 -5
- package/lib-amd/components/MenuItemRadio/MenuItemRadio.types.js.map +0 -1
- package/lib-amd/components/MenuItemRadio/index.js +0 -10
- package/lib-amd/components/MenuItemRadio/index.js.map +0 -1
- package/lib-amd/components/MenuItemRadio/renderMenuItemRadio.js +0 -19
- package/lib-amd/components/MenuItemRadio/renderMenuItemRadio.js.map +0 -1
- package/lib-amd/components/MenuItemRadio/useMenuItemRadio.js +0 -27
- package/lib-amd/components/MenuItemRadio/useMenuItemRadio.js.map +0 -1
- package/lib-amd/components/MenuItemRadio/useMenuItemRadioStyles.js +0 -31
- package/lib-amd/components/MenuItemRadio/useMenuItemRadioStyles.js.map +0 -1
- package/lib-amd/components/MenuList/MenuList.js +0 -18
- package/lib-amd/components/MenuList/MenuList.js.map +0 -1
- package/lib-amd/components/MenuList/MenuList.types.js +0 -5
- package/lib-amd/components/MenuList/MenuList.types.js.map +0 -1
- package/lib-amd/components/MenuList/index.js +0 -11
- package/lib-amd/components/MenuList/index.js.map +0 -1
- package/lib-amd/components/MenuList/renderMenuList.js +0 -15
- package/lib-amd/components/MenuList/renderMenuList.js.map +0 -1
- package/lib-amd/components/MenuList/useMenuList.js +0 -125
- package/lib-amd/components/MenuList/useMenuList.js.map +0 -1
- package/lib-amd/components/MenuList/useMenuListContextValues.js +0 -20
- package/lib-amd/components/MenuList/useMenuListContextValues.js.map +0 -1
- package/lib-amd/components/MenuList/useMenuListStyles.js +0 -21
- package/lib-amd/components/MenuList/useMenuListStyles.js.map +0 -1
- package/lib-amd/components/MenuPopover/MenuPopover.js +0 -17
- package/lib-amd/components/MenuPopover/MenuPopover.js.map +0 -1
- package/lib-amd/components/MenuPopover/MenuPopover.types.js +0 -5
- package/lib-amd/components/MenuPopover/MenuPopover.types.js.map +0 -1
- package/lib-amd/components/MenuPopover/index.js +0 -10
- package/lib-amd/components/MenuPopover/index.js.map +0 -1
- package/lib-amd/components/MenuPopover/renderMenuPopover.js +0 -18
- package/lib-amd/components/MenuPopover/renderMenuPopover.js.map +0 -1
- package/lib-amd/components/MenuPopover/useMenuPopover.js +0 -83
- package/lib-amd/components/MenuPopover/useMenuPopover.js.map +0 -1
- package/lib-amd/components/MenuPopover/useMenuPopoverStyles.js +0 -21
- package/lib-amd/components/MenuPopover/useMenuPopoverStyles.js.map +0 -1
- package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.js +0 -17
- package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.js.map +0 -1
- package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.types.js +0 -5
- package/lib-amd/components/MenuSplitGroup/MenuSplitGroup.types.js.map +0 -1
- package/lib-amd/components/MenuSplitGroup/index.js +0 -10
- package/lib-amd/components/MenuSplitGroup/index.js.map +0 -1
- package/lib-amd/components/MenuSplitGroup/renderMenuSplitGroup.js +0 -14
- package/lib-amd/components/MenuSplitGroup/renderMenuSplitGroup.js.map +0 -1
- package/lib-amd/components/MenuSplitGroup/useMenuSplitGroup.js +0 -47
- package/lib-amd/components/MenuSplitGroup/useMenuSplitGroup.js.map +0 -1
- package/lib-amd/components/MenuSplitGroup/useMenuSplitGroupStyles.js +0 -43
- package/lib-amd/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +0 -1
- package/lib-amd/components/MenuTrigger/MenuTrigger.js +0 -18
- package/lib-amd/components/MenuTrigger/MenuTrigger.js.map +0 -1
- package/lib-amd/components/MenuTrigger/MenuTrigger.types.js +0 -5
- package/lib-amd/components/MenuTrigger/MenuTrigger.types.js.map +0 -1
- package/lib-amd/components/MenuTrigger/index.js +0 -9
- package/lib-amd/components/MenuTrigger/index.js.map +0 -1
- package/lib-amd/components/MenuTrigger/renderMenuTrigger.js +0 -15
- package/lib-amd/components/MenuTrigger/renderMenuTrigger.js.map +0 -1
- package/lib-amd/components/MenuTrigger/useMenuTrigger.js +0 -112
- package/lib-amd/components/MenuTrigger/useMenuTrigger.js.map +0 -1
- package/lib-amd/components/index.js +0 -7
- package/lib-amd/components/index.js.map +0 -1
- package/lib-amd/contexts/menuContext.js +0 -32
- package/lib-amd/contexts/menuContext.js.map +0 -1
- package/lib-amd/contexts/menuGroupContext.js +0 -13
- package/lib-amd/contexts/menuGroupContext.js.map +0 -1
- package/lib-amd/contexts/menuListContext.js +0 -23
- package/lib-amd/contexts/menuListContext.js.map +0 -1
- package/lib-amd/contexts/menuTriggerContext.js +0 -14
- package/lib-amd/contexts/menuTriggerContext.js.map +0 -1
- package/lib-amd/index.js +0 -69
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/selectable/index.js +0 -7
- package/lib-amd/selectable/index.js.map +0 -1
- package/lib-amd/selectable/types.js +0 -5
- package/lib-amd/selectable/types.js.map +0 -1
- package/lib-amd/selectable/useCheckmarkStyles.js +0 -28
- package/lib-amd/selectable/useCheckmarkStyles.js.map +0 -1
- package/lib-amd/utils/index.js +0 -6
- package/lib-amd/utils/index.js.map +0 -1
- package/lib-amd/utils/useIsSubmenu.js +0 -20
- package/lib-amd/utils/useIsSubmenu.js.map +0 -1
- package/lib-amd/utils/useOnMenuEnter.js +0 -59
- package/lib-amd/utils/useOnMenuEnter.js.map +0 -1
@@ -1,272 +1,274 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useMenu_unstable", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>useMenu_unstable
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
13
|
-
const
|
14
|
-
const
|
15
|
-
const
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _reactPositioning = require("@fluentui/react-positioning");
|
12
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
13
|
+
const _reactSharedContexts = require("@fluentui/react-shared-contexts");
|
14
|
+
const _reactPortal = require("@fluentui/react-portal");
|
15
|
+
const _reactTabster = require("@fluentui/react-tabster");
|
16
|
+
const _menuContext = require("../../contexts/menuContext");
|
17
|
+
const _index = require("../../utils/index");
|
18
|
+
const _useIsSubmenu = require("../../utils/useIsSubmenu");
|
16
19
|
// If it's not possible to position the submenu in smaller viewports, try
|
17
20
|
// and fallback to this order of positions
|
18
|
-
const submenuFallbackPositions = [
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
const
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
...react_positioning_1.resolvePositioningShorthand(props.positioning)
|
49
|
-
};
|
50
|
-
const children = React.Children.toArray(props.children);
|
51
|
-
if (process.env.NODE_ENV !== 'production') {
|
52
|
-
if (children.length === 0) {
|
53
|
-
// eslint-disable-next-line no-console
|
54
|
-
console.warn('Menu must contain at least one child');
|
21
|
+
const submenuFallbackPositions = [
|
22
|
+
'after',
|
23
|
+
'after-bottom',
|
24
|
+
'before-top',
|
25
|
+
'before',
|
26
|
+
'before-bottom',
|
27
|
+
'above'
|
28
|
+
];
|
29
|
+
const useMenu_unstable = (props)=>{
|
30
|
+
const isSubmenu = (0, _useIsSubmenu.useIsSubmenu)();
|
31
|
+
const { hoverDelay =500 , inline =false , hasCheckmarks =false , hasIcons =false , closeOnScroll =false , openOnContext =false , persistOnItemClick =false , openOnHover =isSubmenu , defaultCheckedValues , mountNode =null } = props;
|
32
|
+
const triggerId = (0, _reactUtilities.useId)('menu');
|
33
|
+
const [contextTarget, setContextTarget] = (0, _reactPositioning.usePositioningMouseTarget)();
|
34
|
+
const positioningState = {
|
35
|
+
position: isSubmenu ? 'after' : 'below',
|
36
|
+
align: isSubmenu ? 'top' : 'start',
|
37
|
+
target: props.openOnContext ? contextTarget : undefined,
|
38
|
+
fallbackPositions: isSubmenu ? submenuFallbackPositions : undefined,
|
39
|
+
...(0, _reactPositioning.resolvePositioningShorthand)(props.positioning)
|
40
|
+
};
|
41
|
+
const children = _react.Children.toArray(props.children);
|
42
|
+
if (process.env.NODE_ENV !== 'production') {
|
43
|
+
if (children.length === 0) {
|
44
|
+
// eslint-disable-next-line no-console
|
45
|
+
console.warn('Menu must contain at least one child');
|
46
|
+
}
|
47
|
+
if (children.length > 2) {
|
48
|
+
// eslint-disable-next-line no-console
|
49
|
+
console.warn('Menu must contain at most two children');
|
50
|
+
}
|
55
51
|
}
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
let menuTrigger = undefined;
|
53
|
+
let menuPopover = undefined;
|
54
|
+
if (children.length === 2) {
|
55
|
+
menuTrigger = children[0];
|
56
|
+
menuPopover = children[1];
|
57
|
+
} else if (children.length === 1) {
|
58
|
+
menuPopover = children[0];
|
59
59
|
}
|
60
|
-
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
menuPopover,
|
104
|
-
mountNode,
|
105
|
-
triggerRef,
|
106
|
-
menuPopoverRef,
|
107
|
-
components: {},
|
108
|
-
openOnContext,
|
109
|
-
open,
|
110
|
-
setOpen,
|
111
|
-
checkedValues,
|
112
|
-
onCheckedValueChange,
|
113
|
-
persistOnItemClick
|
114
|
-
};
|
60
|
+
const { targetRef: triggerRef , containerRef: menuPopoverRef } = (0, _reactPositioning.usePositioning)(positioningState);
|
61
|
+
// TODO Better way to narrow types ?
|
62
|
+
const [open, setOpen] = useMenuOpenState({
|
63
|
+
hoverDelay,
|
64
|
+
isSubmenu,
|
65
|
+
setContextTarget,
|
66
|
+
closeOnScroll,
|
67
|
+
menuPopoverRef,
|
68
|
+
triggerRef,
|
69
|
+
open: props.open,
|
70
|
+
defaultOpen: props.defaultOpen,
|
71
|
+
onOpenChange: props.onOpenChange,
|
72
|
+
openOnContext
|
73
|
+
});
|
74
|
+
const [checkedValues, onCheckedValueChange] = useMenuSelectableState({
|
75
|
+
checkedValues: props.checkedValues,
|
76
|
+
defaultCheckedValues,
|
77
|
+
onCheckedValueChange: props.onCheckedValueChange
|
78
|
+
});
|
79
|
+
return {
|
80
|
+
inline,
|
81
|
+
hoverDelay,
|
82
|
+
triggerId,
|
83
|
+
isSubmenu,
|
84
|
+
openOnHover,
|
85
|
+
contextTarget,
|
86
|
+
setContextTarget,
|
87
|
+
hasCheckmarks,
|
88
|
+
hasIcons,
|
89
|
+
closeOnScroll,
|
90
|
+
menuTrigger,
|
91
|
+
menuPopover,
|
92
|
+
mountNode,
|
93
|
+
triggerRef,
|
94
|
+
menuPopoverRef,
|
95
|
+
components: {},
|
96
|
+
openOnContext,
|
97
|
+
open,
|
98
|
+
setOpen,
|
99
|
+
checkedValues,
|
100
|
+
onCheckedValueChange,
|
101
|
+
persistOnItemClick
|
102
|
+
};
|
115
103
|
};
|
116
|
-
exports.useMenu_unstable = useMenu_unstable;
|
117
104
|
/**
|
118
105
|
* Adds appropriate state values and handlers for selectable items
|
119
106
|
* i.e checkboxes and radios
|
120
|
-
*/
|
121
|
-
const
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
})
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
107
|
+
*/ const useMenuSelectableState = (props)=>{
|
108
|
+
const [checkedValues, setCheckedValues] = (0, _reactUtilities.useControllableState)({
|
109
|
+
state: props.checkedValues,
|
110
|
+
defaultState: props.defaultCheckedValues,
|
111
|
+
initialState: {}
|
112
|
+
});
|
113
|
+
const onCheckedValueChange = (0, _reactUtilities.useEventCallback)((e, { name , checkedItems })=>{
|
114
|
+
var _props_onCheckedValueChange;
|
115
|
+
(_props_onCheckedValueChange = props.onCheckedValueChange) === null || _props_onCheckedValueChange === void 0 ? void 0 : _props_onCheckedValueChange.call(props, e, {
|
116
|
+
name,
|
117
|
+
checkedItems
|
118
|
+
});
|
119
|
+
setCheckedValues((currentValue)=>({
|
120
|
+
...currentValue,
|
121
|
+
[name]: checkedItems
|
122
|
+
}));
|
135
123
|
});
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
});
|
141
|
-
return [checkedValues, onCheckedValueChange];
|
124
|
+
return [
|
125
|
+
checkedValues,
|
126
|
+
onCheckedValueChange
|
127
|
+
];
|
142
128
|
};
|
143
|
-
const useMenuOpenState = state
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
var _a;
|
150
|
-
return (_a = state.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(state, e, data);
|
151
|
-
});
|
152
|
-
const shouldHandleCloseRef = React.useRef(false);
|
153
|
-
const setOpenTimeout = React.useRef(0);
|
154
|
-
const enteringTriggerRef = React.useRef(false);
|
155
|
-
const [open, setOpenState] = react_utilities_1.useControllableState({
|
156
|
-
state: state.open,
|
157
|
-
defaultState: state.defaultOpen,
|
158
|
-
initialState: false
|
159
|
-
});
|
160
|
-
const trySetOpen = react_utilities_1.useEventCallback((e, data) => {
|
161
|
-
const event = e instanceof CustomEvent && e.type === index_1.MENU_ENTER_EVENT ? e.detail.nativeEvent : e;
|
162
|
-
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, {
|
163
|
-
...data
|
129
|
+
const useMenuOpenState = (state)=>{
|
130
|
+
const { targetDocument } = (0, _reactSharedContexts.useFluent_unstable)();
|
131
|
+
const parentSetOpen = (0, _menuContext.useMenuContext_unstable)((context)=>context.setOpen);
|
132
|
+
const onOpenChange = (0, _reactUtilities.useEventCallback)((e, data)=>{
|
133
|
+
var _state_onOpenChange;
|
134
|
+
return (_state_onOpenChange = state.onOpenChange) === null || _state_onOpenChange === void 0 ? void 0 : _state_onOpenChange.call(state, e, data);
|
164
135
|
});
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
setOpenState(data.open);
|
178
|
-
});
|
179
|
-
const setOpen = react_utilities_1.useEventCallback((e, data) => {
|
180
|
-
var _a;
|
181
|
-
clearTimeout(setOpenTimeout.current);
|
182
|
-
if (!(e instanceof Event) && e.persist) {
|
183
|
-
// < React 17 still uses pooled synthetic events
|
184
|
-
e.persist();
|
185
|
-
}
|
186
|
-
if (e.type === 'mouseleave' || e.type === 'mouseenter' || e.type === 'mousemove' || e.type === index_1.MENU_ENTER_EVENT) {
|
187
|
-
if ((_a = state.triggerRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) {
|
188
|
-
enteringTriggerRef.current = e.type === 'mouseenter' || e.type === 'mousemove';
|
189
|
-
}
|
190
|
-
// FIXME leaking Node timeout type
|
191
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
192
|
-
// @ts-ignore
|
193
|
-
setOpenTimeout.current = setTimeout(() => trySetOpen(e, data), state.hoverDelay);
|
194
|
-
} else {
|
195
|
-
trySetOpen(e, data);
|
196
|
-
}
|
197
|
-
});
|
198
|
-
react_utilities_1.useOnClickOutside({
|
199
|
-
contains: react_portal_1.elementContains,
|
200
|
-
disabled: !open,
|
201
|
-
element: targetDocument,
|
202
|
-
refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(Boolean),
|
203
|
-
callback: event => setOpen(event, {
|
204
|
-
open: false,
|
205
|
-
type: 'clickOutside',
|
206
|
-
event
|
207
|
-
})
|
208
|
-
});
|
209
|
-
// only close on scroll for context, or when closeOnScroll is specified
|
210
|
-
const closeOnScroll = state.openOnContext || state.closeOnScroll;
|
211
|
-
react_utilities_1.useOnScrollOutside({
|
212
|
-
contains: react_portal_1.elementContains,
|
213
|
-
element: targetDocument,
|
214
|
-
callback: event => setOpen(event, {
|
215
|
-
open: false,
|
216
|
-
type: 'scrollOutside',
|
217
|
-
event
|
218
|
-
}),
|
219
|
-
refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(Boolean),
|
220
|
-
disabled: !open || !closeOnScroll
|
221
|
-
});
|
222
|
-
index_1.useOnMenuMouseEnter({
|
223
|
-
element: targetDocument,
|
224
|
-
callback: event => {
|
225
|
-
// When moving from a menu directly back to its trigger, this handler can close the menu
|
226
|
-
// Explicitly check a flag to see if this situation happens
|
227
|
-
if (!enteringTriggerRef.current) {
|
228
|
-
setOpen(event, {
|
229
|
-
open: false,
|
230
|
-
type: 'menuMouseEnter',
|
231
|
-
event
|
136
|
+
const shouldHandleCloseRef = _react.useRef(false);
|
137
|
+
const setOpenTimeout = _react.useRef(0);
|
138
|
+
const enteringTriggerRef = _react.useRef(false);
|
139
|
+
const [open, setOpenState] = (0, _reactUtilities.useControllableState)({
|
140
|
+
state: state.open,
|
141
|
+
defaultState: state.defaultOpen,
|
142
|
+
initialState: false
|
143
|
+
});
|
144
|
+
const trySetOpen = (0, _reactUtilities.useEventCallback)((e, data)=>{
|
145
|
+
const event = e instanceof CustomEvent && e.type === _index.MENU_ENTER_EVENT ? e.detail.nativeEvent : e;
|
146
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, {
|
147
|
+
...data
|
232
148
|
});
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
149
|
+
if (data.open && e.type === 'contextmenu') {
|
150
|
+
state.setContextTarget(e);
|
151
|
+
}
|
152
|
+
if (!data.open) {
|
153
|
+
state.setContextTarget(undefined);
|
154
|
+
shouldHandleCloseRef.current = true;
|
155
|
+
}
|
156
|
+
if (data.bubble) {
|
157
|
+
parentSetOpen(e, {
|
158
|
+
...data
|
159
|
+
});
|
160
|
+
}
|
161
|
+
setOpenState(data.open);
|
162
|
+
});
|
163
|
+
const setOpen = (0, _reactUtilities.useEventCallback)((e, data)=>{
|
164
|
+
clearTimeout(setOpenTimeout.current);
|
165
|
+
if (!(e instanceof Event) && e.persist) {
|
166
|
+
// < React 17 still uses pooled synthetic events
|
167
|
+
e.persist();
|
168
|
+
}
|
169
|
+
if (e.type === 'mouseleave' || e.type === 'mouseenter' || e.type === 'mousemove' || e.type === _index.MENU_ENTER_EVENT) {
|
170
|
+
var _state_triggerRef_current;
|
171
|
+
if ((_state_triggerRef_current = state.triggerRef.current) === null || _state_triggerRef_current === void 0 ? void 0 : _state_triggerRef_current.contains(e.target)) {
|
172
|
+
enteringTriggerRef.current = e.type === 'mouseenter' || e.type === 'mousemove';
|
173
|
+
}
|
174
|
+
// FIXME leaking Node timeout type
|
175
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
176
|
+
// @ts-ignore
|
177
|
+
setOpenTimeout.current = setTimeout(()=>trySetOpen(e, data), state.hoverDelay);
|
178
|
+
} else {
|
179
|
+
trySetOpen(e, data);
|
180
|
+
}
|
181
|
+
});
|
182
|
+
(0, _reactUtilities.useOnClickOutside)({
|
183
|
+
contains: _reactPortal.elementContains,
|
184
|
+
disabled: !open,
|
185
|
+
element: targetDocument,
|
186
|
+
refs: [
|
187
|
+
state.menuPopoverRef,
|
188
|
+
!state.openOnContext && state.triggerRef
|
189
|
+
].filter(Boolean),
|
190
|
+
callback: (event)=>setOpen(event, {
|
191
|
+
open: false,
|
192
|
+
type: 'clickOutside',
|
193
|
+
event
|
194
|
+
})
|
195
|
+
});
|
196
|
+
// only close on scroll for context, or when closeOnScroll is specified
|
197
|
+
const closeOnScroll = state.openOnContext || state.closeOnScroll;
|
198
|
+
(0, _reactUtilities.useOnScrollOutside)({
|
199
|
+
contains: _reactPortal.elementContains,
|
200
|
+
element: targetDocument,
|
201
|
+
callback: (event)=>setOpen(event, {
|
202
|
+
open: false,
|
203
|
+
type: 'scrollOutside',
|
204
|
+
event
|
205
|
+
}),
|
206
|
+
refs: [
|
207
|
+
state.menuPopoverRef,
|
208
|
+
!state.openOnContext && state.triggerRef
|
209
|
+
].filter(Boolean),
|
210
|
+
disabled: !open || !closeOnScroll
|
211
|
+
});
|
212
|
+
(0, _index.useOnMenuMouseEnter)({
|
213
|
+
element: targetDocument,
|
214
|
+
callback: (event)=>{
|
215
|
+
// When moving from a menu directly back to its trigger, this handler can close the menu
|
216
|
+
// Explicitly check a flag to see if this situation happens
|
217
|
+
if (!enteringTriggerRef.current) {
|
218
|
+
setOpen(event, {
|
219
|
+
open: false,
|
220
|
+
type: 'menuMouseEnter',
|
221
|
+
event
|
222
|
+
});
|
223
|
+
}
|
224
|
+
},
|
225
|
+
disabled: !open,
|
226
|
+
refs: [
|
227
|
+
state.menuPopoverRef
|
228
|
+
]
|
229
|
+
});
|
230
|
+
// Clear timeout on unmount
|
231
|
+
// Setting state after a component unmounts can cause memory leaks
|
232
|
+
_react.useEffect(()=>{
|
233
|
+
return ()=>{
|
234
|
+
clearTimeout(setOpenTimeout.current);
|
235
|
+
};
|
236
|
+
}, []);
|
237
|
+
// Manage focus for open state
|
238
|
+
const { findFirstFocusable } = (0, _reactTabster.useFocusFinders)();
|
239
|
+
const focusFirst = _react.useCallback(()=>{
|
240
|
+
const firstFocusable = findFirstFocusable(state.menuPopoverRef.current);
|
241
|
+
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
242
|
+
}, [
|
243
|
+
findFirstFocusable,
|
244
|
+
state.menuPopoverRef
|
245
|
+
]);
|
246
|
+
_react.useEffect(()=>{
|
247
|
+
if (open) {
|
248
|
+
focusFirst();
|
249
|
+
} else {
|
250
|
+
if (shouldHandleCloseRef.current) {
|
251
|
+
var // We know that React effects are sync so we focus the trigger here
|
252
|
+
// after any event handler (event handlers will update state and re-render).
|
253
|
+
// Since the browser only performs the default behaviour for the Tab key once
|
254
|
+
// keyboard events have fully bubbled up the window, the browser will move
|
255
|
+
// focus to the next tabbable element before/after the trigger if needed.
|
256
|
+
// If the Tab key was not pressed, focus will remain on the trigger as expected.
|
257
|
+
_state_triggerRef_current;
|
258
|
+
(_state_triggerRef_current = state.triggerRef.current) === null || _state_triggerRef_current === void 0 ? void 0 : _state_triggerRef_current.focus();
|
259
|
+
}
|
260
|
+
}
|
261
|
+
shouldHandleCloseRef.current = false;
|
262
|
+
}, [
|
263
|
+
state.triggerRef,
|
264
|
+
state.isSubmenu,
|
265
|
+
open,
|
266
|
+
focusFirst
|
267
|
+
]);
|
268
|
+
return [
|
269
|
+
open,
|
270
|
+
setOpen
|
271
|
+
];
|
272
|
+
}; //# sourceMappingURL=useMenu.js.map
|
273
|
+
|
272
274
|
//# sourceMappingURL=useMenu.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","require","react_positioning_1","react_utilities_1","react_shared_contexts_1","react_portal_1","react_tabster_1","menuContext_1","index_1","useIsSubmenu_1","submenuFallbackPositions","useMenu_unstable","props","isSubmenu","useIsSubmenu","hoverDelay","inline","hasCheckmarks","hasIcons","closeOnScroll","openOnContext","persistOnItemClick","openOnHover","defaultCheckedValues","mountNode","triggerId","useId","contextTarget","setContextTarget","usePositioningMouseTarget","positioningState","position","align","target","undefined","fallbackPositions","resolvePositioningShorthand","positioning","children","Children","toArray","process","env","NODE_ENV","length","console","warn","menuTrigger","menuPopover","targetRef","triggerRef","containerRef","menuPopoverRef","usePositioning","open","setOpen","useMenuOpenState","defaultOpen","onOpenChange","checkedValues","onCheckedValueChange","useMenuSelectableState","components","exports","setCheckedValues","useControllableState","state","defaultState","initialState","useEventCallback","e","name","checkedItems","_a","call","currentValue","targetDocument","useFluent_unstable","parentSetOpen","useMenuContext_unstable","context","data","shouldHandleCloseRef","useRef","setOpenTimeout","enteringTriggerRef","setOpenState","trySetOpen","event","CustomEvent","type","MENU_ENTER_EVENT","detail","nativeEvent","current","bubble","clearTimeout","Event","persist","contains","setTimeout","useOnClickOutside","elementContains","disabled","element","refs","filter","Boolean","callback","useOnScrollOutside","useOnMenuMouseEnter","useEffect","findFirstFocusable","useFocusFinders","focusFirst","useCallback","firstFocusable","focus"],"sources":["../src/packages/react-components/react-menu/src/components/Menu/useMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n usePositioningMouseTarget,\n usePositioning,\n resolvePositioningShorthand,\n PositioningShorthandValue,\n} from '@fluentui/react-positioning';\nimport {\n useControllableState,\n useId,\n useOnClickOutside,\n useEventCallback,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { MENU_ENTER_EVENT, useOnMenuMouseEnter } from '../../utils/index';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\nimport type { MenuOpenChangeData, MenuOpenEvent, MenuProps, MenuState } from './Menu.types';\n\n// If it's not possible to position the submenu in smaller viewports, try\n// and fallback to this order of positions\nconst submenuFallbackPositions: PositioningShorthandValue[] = [\n 'after',\n 'after-bottom',\n 'before-top',\n 'before',\n 'before-bottom',\n 'above',\n];\n\n/**\n * Create the state required to render Menu.\n *\n * The returned state can be modified with hooks such as useMenuStyles,\n * before being passed to renderMenu_unstable.\n *\n * @param props - props from this instance of Menu\n */\nexport const useMenu_unstable = (props: MenuProps): MenuState => {\n const isSubmenu = useIsSubmenu();\n const {\n hoverDelay = 500,\n inline = false,\n hasCheckmarks = false,\n hasIcons = false,\n closeOnScroll = false,\n openOnContext = false,\n persistOnItemClick = false,\n openOnHover = isSubmenu,\n defaultCheckedValues,\n mountNode = null,\n } = props;\n const triggerId = useId('menu');\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n\n const positioningState = {\n position: isSubmenu ? 'after' : 'below',\n align: isSubmenu ? 'top' : 'start',\n target: props.openOnContext ? contextTarget : undefined,\n fallbackPositions: isSubmenu ? submenuFallbackPositions : undefined,\n ...resolvePositioningShorthand(props.positioning),\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Menu must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Menu must contain at most two children');\n }\n }\n\n let menuTrigger: React.ReactElement | undefined = undefined;\n let menuPopover: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n menuTrigger = children[0];\n menuPopover = children[1];\n } else if (children.length === 1) {\n menuPopover = children[0];\n }\n\n const { targetRef: triggerRef, containerRef: menuPopoverRef } = usePositioning(positioningState);\n\n // TODO Better way to narrow types ?\n const [open, setOpen] = useMenuOpenState({\n hoverDelay,\n isSubmenu,\n setContextTarget,\n closeOnScroll,\n menuPopoverRef,\n triggerRef,\n open: props.open,\n defaultOpen: props.defaultOpen,\n onOpenChange: props.onOpenChange,\n openOnContext,\n });\n\n const [checkedValues, onCheckedValueChange] = useMenuSelectableState({\n checkedValues: props.checkedValues,\n defaultCheckedValues,\n onCheckedValueChange: props.onCheckedValueChange,\n });\n\n return {\n inline,\n hoverDelay,\n triggerId,\n isSubmenu,\n openOnHover,\n contextTarget,\n setContextTarget,\n hasCheckmarks,\n hasIcons,\n closeOnScroll,\n menuTrigger,\n menuPopover,\n mountNode,\n triggerRef,\n menuPopoverRef,\n components: {},\n openOnContext,\n open,\n setOpen,\n checkedValues,\n onCheckedValueChange,\n persistOnItemClick,\n };\n};\n\n/**\n * Adds appropriate state values and handlers for selectable items\n * i.e checkboxes and radios\n */\nconst useMenuSelectableState = (\n props: Pick<MenuProps, 'checkedValues' | 'defaultCheckedValues' | 'onCheckedValueChange'>,\n) => {\n const [checkedValues, setCheckedValues] = useControllableState({\n state: props.checkedValues,\n defaultState: props.defaultCheckedValues,\n initialState: {},\n });\n const onCheckedValueChange: MenuState['onCheckedValueChange'] = useEventCallback((e, { name, checkedItems }) => {\n props.onCheckedValueChange?.(e, { name, checkedItems });\n\n setCheckedValues(currentValue => ({\n ...currentValue,\n [name]: checkedItems,\n }));\n });\n\n return [checkedValues, onCheckedValueChange] as const;\n};\n\nconst useMenuOpenState = (\n state: Pick<\n MenuState,\n | 'isSubmenu'\n | 'menuPopoverRef'\n | 'setContextTarget'\n | 'triggerRef'\n | 'openOnContext'\n | 'closeOnScroll'\n | 'hoverDelay'\n > &\n Pick<MenuProps, 'open' | 'defaultOpen' | 'onOpenChange'>,\n) => {\n const { targetDocument } = useFluent();\n const parentSetOpen = useMenuContext_unstable(context => context.setOpen);\n const onOpenChange: MenuProps['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const shouldHandleCloseRef = React.useRef(false);\n const setOpenTimeout = React.useRef(0);\n const enteringTriggerRef = React.useRef(false);\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n\n const trySetOpen = useEventCallback((e: MenuOpenEvent, data: MenuOpenChangeData) => {\n const event = e instanceof CustomEvent && e.type === MENU_ENTER_EVENT ? e.detail.nativeEvent : e;\n onOpenChange?.(event, { ...data });\n if (data.open && e.type === 'contextmenu') {\n state.setContextTarget(e as React.MouseEvent);\n }\n\n if (!data.open) {\n state.setContextTarget(undefined);\n shouldHandleCloseRef.current = true;\n }\n\n if (data.bubble) {\n parentSetOpen(e, { ...data });\n }\n\n setOpenState(data.open);\n });\n\n const setOpen = useEventCallback((e: MenuOpenEvent, data: MenuOpenChangeData) => {\n clearTimeout(setOpenTimeout.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave' || e.type === 'mouseenter' || e.type === 'mousemove' || e.type === MENU_ENTER_EVENT) {\n if (state.triggerRef.current?.contains(e.target as HTMLElement)) {\n enteringTriggerRef.current = e.type === 'mouseenter' || e.type === 'mousemove';\n }\n\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeout.current = setTimeout(() => trySetOpen(e, data), state.hoverDelay);\n } else {\n trySetOpen(e, data);\n }\n });\n\n useOnClickOutside({\n contains: elementContains,\n disabled: !open,\n element: targetDocument,\n refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(\n Boolean,\n ) as React.MutableRefObject<HTMLElement>[],\n callback: event => setOpen(event, { open: false, type: 'clickOutside', event }),\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = state.openOnContext || state.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: event => setOpen(event, { open: false, type: 'scrollOutside', event }),\n refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(\n Boolean,\n ) as React.MutableRefObject<HTMLElement>[],\n disabled: !open || !closeOnScroll,\n });\n\n useOnMenuMouseEnter({\n element: targetDocument,\n callback: event => {\n // When moving from a menu directly back to its trigger, this handler can close the menu\n // Explicitly check a flag to see if this situation happens\n if (!enteringTriggerRef.current) {\n setOpen(event, { open: false, type: 'menuMouseEnter', event });\n }\n },\n disabled: !open,\n refs: [state.menuPopoverRef],\n });\n\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeout.current);\n };\n }, []);\n\n // Manage focus for open state\n const { findFirstFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(state.menuPopoverRef.current);\n firstFocusable?.focus();\n }, [findFirstFocusable, state.menuPopoverRef]);\n\n React.useEffect(() => {\n if (open) {\n focusFirst();\n } else {\n if (shouldHandleCloseRef.current) {\n // We know that React effects are sync so we focus the trigger here\n // after any event handler (event handlers will update state and re-render).\n // Since the browser only performs the default behaviour for the Tab key once\n // keyboard events have fully bubbled up the window, the browser will move\n // focus to the next tabbable element before/after the trigger if needed.\n // If the Tab key was not pressed, focus will remain on the trigger as expected.\n state.triggerRef.current?.focus();\n }\n }\n\n shouldHandleCloseRef.current = false;\n }, [state.triggerRef, state.isSubmenu, open, focusFirst]);\n\n return [open, setOpen] as const;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,mBAAA,gBAAAD,OAAA;AAMA,MAAAE,iBAAA,gBAAAF,OAAA;AAOA,MAAAG,uBAAA,gBAAAH,OAAA;AACA,MAAAI,cAAA,gBAAAJ,OAAA;AACA,MAAAK,eAAA,gBAAAL,OAAA;AACA,MAAAM,aAAA,gBAAAN,OAAA;AACA,MAAAO,OAAA,gBAAAP,OAAA;AACA,MAAAQ,cAAA,gBAAAR,OAAA;AAGA;AACA;AACA,MAAMS,wBAAwB,GAAgC,CAC5D,OAAO,EACP,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,OAAO,CACR;AAED;;;;;;;;AAQO,MAAMC,gBAAgB,GAAIC,KAAgB,IAAe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,cAAc,GAAGJ,kBAAkB,CAAC9C,KAAK,CAACd,cAAc,CAAC0C,OAAO,CAAC;IACvEsB,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEC,KAAK,EAAE;EACzB,CAAC,EAAE,CAACL,kBAAkB,EAAE9C,KAAK,CAACd,cAAc,CAAC,CAAC;EAE9CpD,KAAK,CAAC+G,SAAS,CAAC,MAAK;;IACnB,IAAIzD,IAAI,EAAE;MACR4D,UAAU,EAAE;KACb,MAAM;MACL,IAAIhC,oBAAoB,CAACY,OAAO,EAAE;QAChC;QACA;QACA;QACA;QACA;QACA;QACA,CAAArB,EAAA,GAAAP,KAAK,CAAChB,UAAU,CAAC4C,OAAO,cAAArB,EAAA,uBAAAA,EAAA,CAAE4C,KAAK,EAAE;;;IAIrCnC,oBAAoB,CAACY,OAAO,GAAG,KAAK;EACtC,CAAC,EAAE,CAAC5B,KAAK,CAAChB,UAAU,EAAEgB,KAAK,CAACrD,SAAS,EAAEyC,IAAI,EAAE4D,UAAU,CAAC,CAAC;EAEzD,OAAO,CAAC5D,IAAI,EAAEC,OAAO,CAAU;AACjC,CAAC"}
|
1
|
+
{"version":3,"sources":["../../../lib/components/Menu/useMenu.js"],"sourcesContent":["import * as React from 'react';\nimport { usePositioningMouseTarget, usePositioning, resolvePositioningShorthand } from '@fluentui/react-positioning';\nimport { useControllableState, useId, useOnClickOutside, useEventCallback, useOnScrollOutside } from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { useMenuContext_unstable } from '../../contexts/menuContext';\nimport { MENU_ENTER_EVENT, useOnMenuMouseEnter } from '../../utils/index';\nimport { useIsSubmenu } from '../../utils/useIsSubmenu';\n// If it's not possible to position the submenu in smaller viewports, try\n// and fallback to this order of positions\nconst submenuFallbackPositions = ['after', 'after-bottom', 'before-top', 'before', 'before-bottom', 'above'];\n/**\n * Create the state required to render Menu.\n *\n * The returned state can be modified with hooks such as useMenuStyles,\n * before being passed to renderMenu_unstable.\n *\n * @param props - props from this instance of Menu\n */\nexport const useMenu_unstable = props => {\n const isSubmenu = useIsSubmenu();\n const {\n hoverDelay = 500,\n inline = false,\n hasCheckmarks = false,\n hasIcons = false,\n closeOnScroll = false,\n openOnContext = false,\n persistOnItemClick = false,\n openOnHover = isSubmenu,\n defaultCheckedValues,\n mountNode = null\n } = props;\n const triggerId = useId('menu');\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n const positioningState = {\n position: isSubmenu ? 'after' : 'below',\n align: isSubmenu ? 'top' : 'start',\n target: props.openOnContext ? contextTarget : undefined,\n fallbackPositions: isSubmenu ? submenuFallbackPositions : undefined,\n ...resolvePositioningShorthand(props.positioning)\n };\n const children = React.Children.toArray(props.children);\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Menu must contain at least one child');\n }\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Menu must contain at most two children');\n }\n }\n let menuTrigger = undefined;\n let menuPopover = undefined;\n if (children.length === 2) {\n menuTrigger = children[0];\n menuPopover = children[1];\n } else if (children.length === 1) {\n menuPopover = children[0];\n }\n const {\n targetRef: triggerRef,\n containerRef: menuPopoverRef\n } = usePositioning(positioningState);\n // TODO Better way to narrow types ?\n const [open, setOpen] = useMenuOpenState({\n hoverDelay,\n isSubmenu,\n setContextTarget,\n closeOnScroll,\n menuPopoverRef,\n triggerRef,\n open: props.open,\n defaultOpen: props.defaultOpen,\n onOpenChange: props.onOpenChange,\n openOnContext\n });\n const [checkedValues, onCheckedValueChange] = useMenuSelectableState({\n checkedValues: props.checkedValues,\n defaultCheckedValues,\n onCheckedValueChange: props.onCheckedValueChange\n });\n return {\n inline,\n hoverDelay,\n triggerId,\n isSubmenu,\n openOnHover,\n contextTarget,\n setContextTarget,\n hasCheckmarks,\n hasIcons,\n closeOnScroll,\n menuTrigger,\n menuPopover,\n mountNode,\n triggerRef,\n menuPopoverRef,\n components: {},\n openOnContext,\n open,\n setOpen,\n checkedValues,\n onCheckedValueChange,\n persistOnItemClick\n };\n};\n/**\n * Adds appropriate state values and handlers for selectable items\n * i.e checkboxes and radios\n */\nconst useMenuSelectableState = props => {\n const [checkedValues, setCheckedValues] = useControllableState({\n state: props.checkedValues,\n defaultState: props.defaultCheckedValues,\n initialState: {}\n });\n const onCheckedValueChange = useEventCallback((e, {\n name,\n checkedItems\n }) => {\n var _props_onCheckedValueChange;\n (_props_onCheckedValueChange = props.onCheckedValueChange) === null || _props_onCheckedValueChange === void 0 ? void 0 : _props_onCheckedValueChange.call(props, e, {\n name,\n checkedItems\n });\n setCheckedValues(currentValue => ({\n ...currentValue,\n [name]: checkedItems\n }));\n });\n return [checkedValues, onCheckedValueChange];\n};\nconst useMenuOpenState = state => {\n const {\n targetDocument\n } = useFluent();\n const parentSetOpen = useMenuContext_unstable(context => context.setOpen);\n const onOpenChange = useEventCallback((e, data) => {\n var _state_onOpenChange;\n return (_state_onOpenChange = state.onOpenChange) === null || _state_onOpenChange === void 0 ? void 0 : _state_onOpenChange.call(state, e, data);\n });\n const shouldHandleCloseRef = React.useRef(false);\n const setOpenTimeout = React.useRef(0);\n const enteringTriggerRef = React.useRef(false);\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false\n });\n const trySetOpen = useEventCallback((e, data) => {\n const event = e instanceof CustomEvent && e.type === MENU_ENTER_EVENT ? e.detail.nativeEvent : e;\n onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, {\n ...data\n });\n if (data.open && e.type === 'contextmenu') {\n state.setContextTarget(e);\n }\n if (!data.open) {\n state.setContextTarget(undefined);\n shouldHandleCloseRef.current = true;\n }\n if (data.bubble) {\n parentSetOpen(e, {\n ...data\n });\n }\n setOpenState(data.open);\n });\n const setOpen = useEventCallback((e, data) => {\n clearTimeout(setOpenTimeout.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n if (e.type === 'mouseleave' || e.type === 'mouseenter' || e.type === 'mousemove' || e.type === MENU_ENTER_EVENT) {\n var _state_triggerRef_current;\n if ((_state_triggerRef_current = state.triggerRef.current) === null || _state_triggerRef_current === void 0 ? void 0 : _state_triggerRef_current.contains(e.target)) {\n enteringTriggerRef.current = e.type === 'mouseenter' || e.type === 'mousemove';\n }\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeout.current = setTimeout(() => trySetOpen(e, data), state.hoverDelay);\n } else {\n trySetOpen(e, data);\n }\n });\n useOnClickOutside({\n contains: elementContains,\n disabled: !open,\n element: targetDocument,\n refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(Boolean),\n callback: event => setOpen(event, {\n open: false,\n type: 'clickOutside',\n event\n })\n });\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = state.openOnContext || state.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: event => setOpen(event, {\n open: false,\n type: 'scrollOutside',\n event\n }),\n refs: [state.menuPopoverRef, !state.openOnContext && state.triggerRef].filter(Boolean),\n disabled: !open || !closeOnScroll\n });\n useOnMenuMouseEnter({\n element: targetDocument,\n callback: event => {\n // When moving from a menu directly back to its trigger, this handler can close the menu\n // Explicitly check a flag to see if this situation happens\n if (!enteringTriggerRef.current) {\n setOpen(event, {\n open: false,\n type: 'menuMouseEnter',\n event\n });\n }\n },\n disabled: !open,\n refs: [state.menuPopoverRef]\n });\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeout.current);\n };\n }, []);\n // Manage focus for open state\n const {\n findFirstFocusable\n } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(state.menuPopoverRef.current);\n firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();\n }, [findFirstFocusable, state.menuPopoverRef]);\n React.useEffect(() => {\n if (open) {\n focusFirst();\n } else {\n if (shouldHandleCloseRef.current) {\n var\n // We know that React effects are sync so we focus the trigger here\n // after any event handler (event handlers will update state and re-render).\n // Since the browser only performs the default behaviour for the Tab key once\n // keyboard events have fully bubbled up the window, the browser will move\n // focus to the next tabbable element before/after the trigger if needed.\n // If the Tab key was not pressed, focus will remain on the trigger as expected.\n _state_triggerRef_current;\n (_state_triggerRef_current = state.triggerRef.current) === null || _state_triggerRef_current === void 0 ? void 0 : _state_triggerRef_current.focus();\n }\n }\n shouldHandleCloseRef.current = false;\n }, [state.triggerRef, state.isSubmenu, open, focusFirst]);\n return [open, setOpen];\n};\n//# sourceMappingURL=useMenu.js.map"],"names":["useMenu_unstable","submenuFallbackPositions","props","isSubmenu","useIsSubmenu","hoverDelay","inline","hasCheckmarks","hasIcons","closeOnScroll","openOnContext","persistOnItemClick","openOnHover","defaultCheckedValues","mountNode","triggerId","useId","contextTarget","setContextTarget","usePositioningMouseTarget","positioningState","position","align","target","undefined","fallbackPositions","resolvePositioningShorthand","positioning","children","React","Children","toArray","process","env","NODE_ENV","length","console","warn","menuTrigger","menuPopover","targetRef","triggerRef","containerRef","menuPopoverRef","usePositioning","open","setOpen","useMenuOpenState","defaultOpen","onOpenChange","checkedValues","onCheckedValueChange","useMenuSelectableState","components","setCheckedValues","useControllableState","state","defaultState","initialState","useEventCallback","e","name","checkedItems","_props_onCheckedValueChange","call","currentValue","targetDocument","useFluent","parentSetOpen","useMenuContext_unstable","context","data","_state_onOpenChange","shouldHandleCloseRef","useRef","setOpenTimeout","enteringTriggerRef","setOpenState","trySetOpen","event","CustomEvent","type","MENU_ENTER_EVENT","detail","nativeEvent","current","bubble","clearTimeout","Event","persist","_state_triggerRef_current","contains","setTimeout","useOnClickOutside","elementContains","disabled","element","refs","filter","Boolean","callback","useOnScrollOutside","useOnMenuMouseEnter","useEffect","findFirstFocusable","useFocusFin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