@fluentui/react-menu 9.0.0-nightly.b5b7401007.0 → 9.0.0-rc.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +520 -34
- package/CHANGELOG.md +120 -22
- package/Spec.md +21 -16
- package/dist/react-menu.d.ts +141 -71
- 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.d.ts +1 -0
- 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.d.ts +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.d.ts +1 -1
- package/lib/components/Menu/renderMenu.js +1 -1
- package/lib/components/Menu/renderMenu.js.map +1 -1
- package/lib/components/Menu/useMenu.d.ts +2 -2
- package/lib/components/Menu/useMenu.js +119 -128
- package/lib/components/Menu/useMenu.js.map +1 -1
- package/lib/components/Menu/useMenuContextValues.d.ts +1 -1
- package/lib/components/Menu/useMenuContextValues.js +35 -33
- package/lib/components/Menu/useMenuContextValues.js.map +1 -1
- package/lib/components/MenuDivider/MenuDivider.d.ts +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.d.ts +2 -2
- package/lib/components/MenuDivider/MenuDivider.types.js.map +1 -1
- package/lib/components/MenuDivider/index.js.map +1 -1
- package/lib/components/MenuDivider/renderMenuDivider.d.ts +1 -1
- package/lib/components/MenuDivider/renderMenuDivider.js +7 -7
- package/lib/components/MenuDivider/renderMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDivider.d.ts +1 -1
- package/lib/components/MenuDivider/useMenuDivider.js +9 -7
- package/lib/components/MenuDivider/useMenuDivider.js.map +1 -1
- package/lib/components/MenuDivider/useMenuDividerStyles.d.ts +2 -1
- package/lib/components/MenuDivider/useMenuDividerStyles.js +7 -5
- package/lib/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib/components/MenuGroup/MenuGroup.d.ts +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.d.ts +3 -3
- package/lib/components/MenuGroup/MenuGroup.types.js.map +1 -1
- package/lib/components/MenuGroup/index.d.ts +1 -0
- package/lib/components/MenuGroup/index.js +1 -0
- package/lib/components/MenuGroup/index.js.map +1 -1
- package/lib/components/MenuGroup/renderMenuGroup.d.ts +1 -1
- package/lib/components/MenuGroup/renderMenuGroup.js +7 -7
- package/lib/components/MenuGroup/renderMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroup.d.ts +1 -1
- package/lib/components/MenuGroup/useMenuGroup.js +10 -7
- package/lib/components/MenuGroup/useMenuGroup.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroupContextValues.d.ts +1 -1
- package/lib/components/MenuGroup/useMenuGroupContextValues.js +8 -8
- package/lib/components/MenuGroup/useMenuGroupContextValues.js.map +1 -1
- package/lib/components/MenuGroup/useMenuGroupStyles.d.ts +3 -0
- package/lib/components/MenuGroup/useMenuGroupStyles.js +7 -0
- package/lib/components/MenuGroup/useMenuGroupStyles.js.map +1 -0
- package/lib/components/MenuGroupHeader/MenuGroupHeader.d.ts +1 -1
- package/lib/components/MenuGroupHeader/MenuGroupHeader.js +8 -8
- package/lib/components/MenuGroupHeader/MenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/MenuGroupHeader.types.d.ts +2 -2
- package/lib/components/MenuGroupHeader/MenuGroupHeader.types.js.map +1 -1
- package/lib/components/MenuGroupHeader/index.js.map +1 -1
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.d.ts +1 -1
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js +7 -7
- package/lib/components/MenuGroupHeader/renderMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.d.ts +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js +13 -8
- package/lib/components/MenuGroupHeader/useMenuGroupHeader.js.map +1 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.d.ts +2 -1
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +7 -5
- package/lib/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib/components/MenuItem/MenuItem.d.ts +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.d.ts +7 -7
- package/lib/components/MenuItem/MenuItem.types.js.map +1 -1
- package/lib/components/MenuItem/index.js.map +1 -1
- package/lib/components/MenuItem/renderMenuItem.d.ts +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.d.ts +2 -6
- package/lib/components/MenuItem/useMenuItem.js +37 -44
- package/lib/components/MenuItem/useMenuItem.js.map +1 -1
- package/lib/components/MenuItem/useMenuItemStyles.d.ts +2 -1
- package/lib/components/MenuItem/useMenuItemStyles.js +31 -27
- package/lib/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.d.ts +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.d.ts +1 -0
- package/lib/components/MenuItemCheckbox/index.js +1 -0
- package/lib/components/MenuItemCheckbox/index.js.map +1 -1
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.d.ts +1 -1
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js +11 -8
- package/lib/components/MenuItemCheckbox/renderMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.d.ts +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js +14 -15
- package/lib/components/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.d.ts +2 -1
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +8 -5
- package/lib/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib/components/MenuItemRadio/MenuItemRadio.d.ts +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.d.ts +1 -0
- package/lib/components/MenuItemRadio/index.js +1 -0
- package/lib/components/MenuItemRadio/index.js.map +1 -1
- package/lib/components/MenuItemRadio/renderMenuItemRadio.d.ts +1 -1
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js +11 -8
- package/lib/components/MenuItemRadio/renderMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadio.d.ts +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadio.js +14 -14
- package/lib/components/MenuItemRadio/useMenuItemRadio.js.map +1 -1
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.d.ts +2 -1
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js +8 -5
- package/lib/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib/components/MenuList/MenuList.d.ts +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.d.ts +12 -10
- package/lib/components/MenuList/MenuList.types.js.map +1 -1
- package/lib/components/MenuList/index.d.ts +1 -1
- package/lib/components/MenuList/index.js +0 -1
- package/lib/components/MenuList/index.js.map +1 -1
- package/lib/components/MenuList/renderMenuList.d.ts +1 -1
- package/lib/components/MenuList/renderMenuList.js +7 -7
- package/lib/components/MenuList/renderMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuList.d.ts +1 -1
- package/lib/components/MenuList/useMenuList.js +70 -87
- package/lib/components/MenuList/useMenuList.js.map +1 -1
- package/lib/components/MenuList/useMenuListContextValues.d.ts +1 -1
- package/lib/components/MenuList/useMenuListContextValues.js +19 -17
- package/lib/components/MenuList/useMenuListContextValues.js.map +1 -1
- package/lib/components/MenuList/useMenuListStyles.d.ts +2 -1
- package/lib/components/MenuList/useMenuListStyles.js +9 -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.d.ts +2 -2
- package/lib/components/MenuPopover/MenuPopover.types.js.map +1 -1
- package/lib/components/MenuPopover/index.js.map +1 -1
- package/lib/components/MenuPopover/renderMenuPopover.d.ts +1 -1
- package/lib/components/MenuPopover/renderMenuPopover.js +9 -7
- package/lib/components/MenuPopover/renderMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopover.d.ts +3 -3
- package/lib/components/MenuPopover/useMenuPopover.js +35 -41
- package/lib/components/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/components/MenuPopover/useMenuPopoverStyles.d.ts +2 -1
- package/lib/components/MenuPopover/useMenuPopoverStyles.js +13 -8
- package/lib/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib/components/MenuSplitGroup/MenuSplitGroup.d.ts +6 -0
- package/lib/components/MenuSplitGroup/MenuSplitGroup.js +15 -0
- package/lib/components/MenuSplitGroup/MenuSplitGroup.js.map +1 -0
- package/lib/components/MenuSplitGroup/MenuSplitGroup.types.d.ts +14 -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.d.ts +5 -0
- package/lib/components/MenuSplitGroup/index.js +6 -0
- package/lib/components/MenuSplitGroup/index.js.map +1 -0
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.d.ts +5 -0
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.js +15 -0
- package/lib/components/MenuSplitGroup/renderMenuSplitGroup.js.map +1 -0
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.d.ts +12 -0
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js +67 -0
- package/lib/components/MenuSplitGroup/useMenuSplitGroup.js.map +1 -0
- package/lib/components/MenuSplitGroup/useMenuSplitGroupStyles.d.ts +6 -0
- package/lib/components/MenuSplitGroup/useMenuSplitGroupStyles.js +35 -0
- package/lib/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -0
- package/lib/components/MenuTrigger/MenuTrigger.d.ts +2 -1
- package/lib/components/MenuTrigger/MenuTrigger.js +6 -5
- package/lib/components/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/MenuTrigger.types.d.ts +7 -3
- package/lib/components/MenuTrigger/MenuTrigger.types.js.map +1 -1
- package/lib/components/MenuTrigger/index.js.map +1 -1
- package/lib/components/MenuTrigger/renderMenuTrigger.d.ts +1 -1
- package/lib/components/MenuTrigger/renderMenuTrigger.js +2 -2
- package/lib/components/MenuTrigger/renderMenuTrigger.js.map +1 -1
- package/lib/components/MenuTrigger/useMenuTrigger.d.ts +2 -2
- 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.d.ts +1 -1
- package/lib/contexts/menuContext.js +5 -11
- package/lib/contexts/menuContext.js.map +1 -1
- package/lib/contexts/menuGroupContext.d.ts +1 -1
- package/lib/contexts/menuGroupContext.js +3 -5
- package/lib/contexts/menuGroupContext.js.map +1 -1
- package/lib/contexts/menuListContext.d.ts +1 -1
- package/lib/contexts/menuListContext.js +7 -17
- package/lib/contexts/menuListContext.js.map +1 -1
- package/lib/contexts/menuTriggerContext.d.ts +1 -1
- package/lib/contexts/menuTriggerContext.js +4 -6
- package/lib/contexts/menuTriggerContext.js.map +1 -1
- package/lib/index.d.ts +11 -10
- package/lib/index.js +11 -10
- 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.d.ts +2 -2
- 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.d.ts +1 -0
- 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.d.ts +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.d.ts +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.d.ts +2 -2
- package/lib-commonjs/components/Menu/useMenu.js +130 -141
- package/lib-commonjs/components/Menu/useMenu.js.map +1 -1
- package/lib-commonjs/components/Menu/useMenuContextValues.d.ts +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.d.ts +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.d.ts +2 -2
- 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.d.ts +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.d.ts +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.d.ts +2 -1
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js +11 -7
- package/lib-commonjs/components/MenuDivider/useMenuDividerStyles.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/MenuGroup.d.ts +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.d.ts +3 -3
- package/lib-commonjs/components/MenuGroup/MenuGroup.types.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/index.d.ts +1 -0
- package/lib-commonjs/components/MenuGroup/index.js +3 -1
- package/lib-commonjs/components/MenuGroup/index.js.map +1 -1
- package/lib-commonjs/components/MenuGroup/renderMenuGroup.d.ts +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.d.ts +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.d.ts +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.d.ts +3 -0
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js +18 -0
- package/lib-commonjs/components/MenuGroup/useMenuGroupStyles.js.map +1 -0
- package/lib-commonjs/components/MenuGroupHeader/MenuGroupHeader.d.ts +1 -1
- 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.d.ts +2 -2
- 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.d.ts +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.d.ts +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.d.ts +2 -1
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js +11 -7
- package/lib-commonjs/components/MenuGroupHeader/useMenuGroupHeaderStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItem/MenuItem.d.ts +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.d.ts +7 -7
- 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.d.ts +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.d.ts +2 -6
- 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.d.ts +2 -1
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js +40 -33
- package/lib-commonjs/components/MenuItem/useMenuItemStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/MenuItemCheckbox.d.ts +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.d.ts +1 -0
- package/lib-commonjs/components/MenuItemCheckbox/index.js +3 -1
- package/lib-commonjs/components/MenuItemCheckbox/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemCheckbox/renderMenuItemCheckbox.d.ts +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.d.ts +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.d.ts +2 -1
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js +12 -7
- package/lib-commonjs/components/MenuItemCheckbox/useMenuItemCheckboxStyles.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/MenuItemRadio.d.ts +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.d.ts +1 -0
- package/lib-commonjs/components/MenuItemRadio/index.js +3 -1
- package/lib-commonjs/components/MenuItemRadio/index.js.map +1 -1
- package/lib-commonjs/components/MenuItemRadio/renderMenuItemRadio.d.ts +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.d.ts +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.d.ts +2 -1
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js +12 -7
- package/lib-commonjs/components/MenuItemRadio/useMenuItemRadioStyles.js.map +1 -1
- package/lib-commonjs/components/MenuList/MenuList.d.ts +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.d.ts +12 -10
- package/lib-commonjs/components/MenuList/MenuList.types.js.map +1 -1
- package/lib-commonjs/components/MenuList/index.d.ts +1 -1
- package/lib-commonjs/components/MenuList/index.js +1 -3
- package/lib-commonjs/components/MenuList/index.js.map +1 -1
- package/lib-commonjs/components/MenuList/renderMenuList.d.ts +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.d.ts +1 -1
- package/lib-commonjs/components/MenuList/useMenuList.js +77 -95
- package/lib-commonjs/components/MenuList/useMenuList.js.map +1 -1
- package/lib-commonjs/components/MenuList/useMenuListContextValues.d.ts +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.d.ts +2 -1
- package/lib-commonjs/components/MenuList/useMenuListStyles.js +12 -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.d.ts +2 -2
- 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.d.ts +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.d.ts +3 -3
- 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.d.ts +2 -1
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js +17 -10
- package/lib-commonjs/components/MenuPopover/useMenuPopoverStyles.js.map +1 -1
- package/lib-commonjs/components/MenuSplitGroup/MenuSplitGroup.d.ts +6 -0
- 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.d.ts +14 -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.d.ts +5 -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.d.ts +5 -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.d.ts +12 -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.d.ts +6 -0
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroupStyles.js +47 -0
- package/lib-commonjs/components/MenuSplitGroup/useMenuSplitGroupStyles.js.map +1 -0
- package/lib-commonjs/components/MenuTrigger/MenuTrigger.d.ts +2 -1
- 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.d.ts +7 -3
- 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.d.ts +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.d.ts +2 -2
- 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.d.ts +1 -1
- package/lib-commonjs/contexts/menuContext.js +6 -12
- package/lib-commonjs/contexts/menuContext.js.map +1 -1
- package/lib-commonjs/contexts/menuGroupContext.d.ts +1 -1
- package/lib-commonjs/contexts/menuGroupContext.js +5 -7
- package/lib-commonjs/contexts/menuGroupContext.js.map +1 -1
- package/lib-commonjs/contexts/menuListContext.d.ts +1 -1
- package/lib-commonjs/contexts/menuListContext.js +8 -18
- package/lib-commonjs/contexts/menuListContext.js.map +1 -1
- package/lib-commonjs/contexts/menuTriggerContext.d.ts +1 -1
- package/lib-commonjs/contexts/menuTriggerContext.js +6 -8
- package/lib-commonjs/contexts/menuTriggerContext.js.map +1 -1
- package/lib-commonjs/index.d.ts +11 -10
- package/lib-commonjs/index.js +17 -15
- 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.d.ts +2 -2
- 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 +15 -17
- 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/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-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/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
@@ -3,8 +3,8 @@ import type { MenuProps, MenuState } from './Menu.types';
|
|
3
3
|
* Create the state required to render Menu.
|
4
4
|
*
|
5
5
|
* The returned state can be modified with hooks such as useMenuStyles,
|
6
|
-
* before being passed to
|
6
|
+
* before being passed to renderMenu_unstable.
|
7
7
|
*
|
8
8
|
* @param props - props from this instance of Menu
|
9
9
|
*/
|
10
|
-
export declare const
|
10
|
+
export declare const useMenu_unstable: (props: MenuProps) => MenuState;
|
@@ -1,152 +1,143 @@
|
|
1
|
-
import { __assign } from "tslib";
|
2
1
|
import * as React from 'react';
|
3
2
|
import { usePopperMouseTarget, usePopper, resolvePositioningShorthand } from '@fluentui/react-positioning';
|
4
3
|
import { useControllableState, useId, useOnClickOutside, useEventCallback } from '@fluentui/react-utilities';
|
5
|
-
import { useFluent } from '@fluentui/react-
|
4
|
+
import { useFluent } from '@fluentui/react-shared-contexts';
|
6
5
|
import { elementContains } from '@fluentui/react-portal';
|
7
6
|
import { useFocusFinders } from '@fluentui/react-tabster';
|
8
|
-
import {
|
9
|
-
import { useMenuContext } from '../../contexts/menuContext';
|
7
|
+
import { useMenuContext_unstable } from '../../contexts/menuContext';
|
10
8
|
import { MENU_ENTER_EVENT, useOnMenuMouseEnter } from '../../utils/index';
|
11
9
|
import { useIsSubmenu } from '../../utils/useIsSubmenu';
|
12
10
|
/**
|
13
11
|
* Create the state required to render Menu.
|
14
12
|
*
|
15
13
|
* The returned state can be modified with hooks such as useMenuStyles,
|
16
|
-
* before being passed to
|
14
|
+
* before being passed to renderMenu_unstable.
|
17
15
|
*
|
18
16
|
* @param props - props from this instance of Menu
|
19
17
|
*/
|
20
18
|
|
21
|
-
export
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
contextTarget = _a[0],
|
27
|
-
setContextTarget = _a[1];
|
28
|
-
|
29
|
-
var popperState = __assign({
|
19
|
+
export const useMenu_unstable = props => {
|
20
|
+
const triggerId = useId('menu');
|
21
|
+
const isSubmenu = useIsSubmenu();
|
22
|
+
const [contextTarget, setContextTarget] = usePopperMouseTarget();
|
23
|
+
const popperState = {
|
30
24
|
position: isSubmenu ? 'after' : 'below',
|
31
25
|
align: isSubmenu ? 'top' : 'start',
|
32
|
-
target: props.openOnContext ? contextTarget : undefined
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
if (
|
38
|
-
|
39
|
-
|
40
|
-
|
26
|
+
target: props.openOnContext ? contextTarget : undefined,
|
27
|
+
...resolvePositioningShorthand(props.positioning)
|
28
|
+
};
|
29
|
+
const children = React.Children.toArray(props.children);
|
30
|
+
|
31
|
+
if (process.env.NODE_ENV !== 'production') {
|
32
|
+
if (children.length === 0) {
|
33
|
+
// eslint-disable-next-line no-console
|
34
|
+
console.warn('Menu must contain at least one child');
|
35
|
+
}
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
} else {
|
46
|
-
acc.menuPopover = child;
|
37
|
+
if (children.length > 2) {
|
38
|
+
// eslint-disable-next-line no-console
|
39
|
+
console.warn('Menu must contain at most two children');
|
47
40
|
}
|
41
|
+
}
|
48
42
|
|
49
|
-
|
50
|
-
|
51
|
-
menuTrigger = _b.menuTrigger,
|
52
|
-
menuPopover = _b.menuPopover;
|
43
|
+
let menuTrigger = undefined;
|
44
|
+
let menuPopover = undefined;
|
53
45
|
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
if (children.length === 2) {
|
47
|
+
menuTrigger = children[0];
|
48
|
+
menuPopover = children[1];
|
49
|
+
} else if (children.length === 1) {
|
50
|
+
menuPopover = children[0];
|
51
|
+
}
|
57
52
|
|
58
|
-
|
53
|
+
const {
|
54
|
+
targetRef: triggerRef,
|
55
|
+
containerRef: menuPopoverRef
|
56
|
+
} = usePopper(popperState);
|
57
|
+
const initialState = {
|
59
58
|
hoverDelay: 500,
|
60
|
-
triggerId
|
59
|
+
triggerId,
|
61
60
|
isSubmenu: !!isSubmenu,
|
62
61
|
openOnHover: !!isSubmenu,
|
63
|
-
contextTarget
|
64
|
-
setContextTarget
|
65
|
-
|
66
|
-
menuTrigger
|
67
|
-
menuPopover
|
68
|
-
triggerRef
|
69
|
-
menuPopoverRef
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
return __assign(__assign({}, initialState), {
|
82
|
-
open: open,
|
83
|
-
setOpen: setOpen,
|
84
|
-
checkedValues: checkedValues,
|
85
|
-
onCheckedValueChange: onCheckedValueChange
|
86
|
-
});
|
62
|
+
contextTarget,
|
63
|
+
setContextTarget,
|
64
|
+
...props,
|
65
|
+
menuTrigger,
|
66
|
+
menuPopover,
|
67
|
+
triggerRef,
|
68
|
+
menuPopoverRef,
|
69
|
+
components: {}
|
70
|
+
}; // TODO Better way to narrow types ?
|
71
|
+
|
72
|
+
const [open, setOpen] = useMenuOpenState(initialState);
|
73
|
+
const [checkedValues, onCheckedValueChange] = useMenuSelectableState(initialState);
|
74
|
+
return { ...initialState,
|
75
|
+
open,
|
76
|
+
setOpen,
|
77
|
+
checkedValues,
|
78
|
+
onCheckedValueChange
|
79
|
+
};
|
87
80
|
};
|
88
81
|
/**
|
89
82
|
* Adds appropriate state values and handlers for selectable items
|
90
83
|
* i.e checkboxes and radios
|
91
84
|
*/
|
92
85
|
|
93
|
-
|
94
|
-
|
86
|
+
const useMenuSelectableState = state => {
|
87
|
+
const [checkedValues, setCheckedValues] = useControllableState({
|
95
88
|
state: state.checkedValues,
|
96
89
|
defaultState: state.defaultCheckedValues,
|
97
90
|
initialState: {}
|
98
|
-
})
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
91
|
+
});
|
92
|
+
const {
|
93
|
+
onCheckedValueChange: onCheckedValueChangeOriginal
|
94
|
+
} = state;
|
95
|
+
const onCheckedValueChange = useEventCallback((e, {
|
96
|
+
name,
|
97
|
+
checkedItems
|
98
|
+
}) => {
|
107
99
|
if (onCheckedValueChangeOriginal) {
|
108
100
|
onCheckedValueChangeOriginal(e, {
|
109
|
-
name
|
110
|
-
checkedItems
|
101
|
+
name,
|
102
|
+
checkedItems
|
111
103
|
});
|
112
104
|
}
|
113
105
|
|
114
|
-
setCheckedValues(
|
115
|
-
|
116
|
-
|
117
|
-
|
106
|
+
setCheckedValues(s => {
|
107
|
+
return s ? { ...s,
|
108
|
+
[name]: checkedItems
|
109
|
+
} : {
|
110
|
+
[name]: checkedItems
|
111
|
+
};
|
118
112
|
});
|
119
113
|
});
|
120
114
|
return [checkedValues, onCheckedValueChange];
|
121
115
|
};
|
122
116
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
117
|
+
const useMenuOpenState = state => {
|
118
|
+
const {
|
119
|
+
targetDocument
|
120
|
+
} = useFluent();
|
121
|
+
const parentSetOpen = useMenuContext_unstable(context => context.setOpen);
|
122
|
+
const onOpenChange = useEventCallback((e, data) => {
|
129
123
|
var _a;
|
130
124
|
|
131
125
|
return (_a = state.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(state, e, data);
|
132
126
|
});
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
var _a = useControllableState({
|
127
|
+
const shouldHandleKeyboardRef = React.useRef(false);
|
128
|
+
const shouldHandleTabRef = React.useRef(false);
|
129
|
+
const pressedShiftRef = React.useRef(false);
|
130
|
+
const setOpenTimeout = React.useRef(0);
|
131
|
+
const enteringTriggerRef = React.useRef(false);
|
132
|
+
const [open, setOpenState] = useControllableState({
|
140
133
|
state: state.open,
|
141
134
|
defaultState: state.defaultOpen,
|
142
135
|
initialState: false
|
143
|
-
})
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
var event = e instanceof CustomEvent && e.type === MENU_ENTER_EVENT ? e.detail.nativeEvent : e;
|
149
|
-
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, __assign({}, data));
|
136
|
+
});
|
137
|
+
const trySetOpen = useEventCallback((e, data) => {
|
138
|
+
const event = e instanceof CustomEvent && e.type === MENU_ENTER_EVENT ? e.detail.nativeEvent : e;
|
139
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, { ...data
|
140
|
+
});
|
150
141
|
|
151
142
|
if (data.open && e.type === 'contextmenu') {
|
152
143
|
state.setContextTarget(e);
|
@@ -163,12 +154,13 @@ var useMenuOpenState = function (state) {
|
|
163
154
|
}
|
164
155
|
|
165
156
|
if (data.bubble) {
|
166
|
-
parentSetOpen(e,
|
157
|
+
parentSetOpen(e, { ...data
|
158
|
+
});
|
167
159
|
}
|
168
160
|
|
169
161
|
setOpenState(data.open);
|
170
162
|
});
|
171
|
-
|
163
|
+
const setOpen = useEventCallback((e, data) => {
|
172
164
|
var _a;
|
173
165
|
|
174
166
|
clearTimeout(setOpenTimeout.current);
|
@@ -186,9 +178,7 @@ var useMenuOpenState = function (state) {
|
|
186
178
|
// @ts-ignore
|
187
179
|
|
188
180
|
|
189
|
-
setOpenTimeout.current = setTimeout(
|
190
|
-
return trySetOpen(e, data);
|
191
|
-
}, state.hoverDelay);
|
181
|
+
setOpenTimeout.current = setTimeout(() => trySetOpen(e, data), state.hoverDelay);
|
192
182
|
} else {
|
193
183
|
trySetOpen(e, data);
|
194
184
|
}
|
@@ -198,15 +188,13 @@ var useMenuOpenState = function (state) {
|
|
198
188
|
disabled: !open,
|
199
189
|
element: targetDocument,
|
200
190
|
refs: [state.menuPopoverRef, state.triggerRef],
|
201
|
-
callback:
|
202
|
-
|
203
|
-
|
204
|
-
});
|
205
|
-
}
|
191
|
+
callback: e => setOpen(e, {
|
192
|
+
open: false
|
193
|
+
})
|
206
194
|
});
|
207
195
|
useOnMenuMouseEnter({
|
208
196
|
element: targetDocument,
|
209
|
-
callback:
|
197
|
+
callback: e => {
|
210
198
|
// When moving from a menu directly back to its trigger, this handler can close the menu
|
211
199
|
// Explicitly check a flag to see if this situation happens
|
212
200
|
if (!enteringTriggerRef.current) {
|
@@ -220,39 +208,42 @@ var useMenuOpenState = function (state) {
|
|
220
208
|
}); // Clear timeout on unmount
|
221
209
|
// Setting state after a component unmounts can cause memory leaks
|
222
210
|
|
223
|
-
React.useEffect(
|
224
|
-
return
|
211
|
+
React.useEffect(() => {
|
212
|
+
return () => {
|
225
213
|
clearTimeout(setOpenTimeout.current);
|
226
214
|
};
|
227
215
|
}, []); // Manage focus for open state
|
228
216
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
217
|
+
const {
|
218
|
+
findFirstFocusable,
|
219
|
+
findNextFocusable,
|
220
|
+
findPrevFocusable
|
221
|
+
} = useFocusFinders();
|
222
|
+
const focusFirst = React.useCallback(() => {
|
223
|
+
const firstFocusable = findFirstFocusable(state.menuPopoverRef.current);
|
236
224
|
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
237
225
|
}, [findFirstFocusable, state.menuPopoverRef]);
|
238
|
-
|
239
|
-
|
226
|
+
const focusAfterMenuTrigger = React.useCallback(() => {
|
227
|
+
const nextFocusable = findNextFocusable(state.triggerRef.current);
|
240
228
|
nextFocusable === null || nextFocusable === void 0 ? void 0 : nextFocusable.focus();
|
241
229
|
}, [findNextFocusable, state.triggerRef]);
|
242
|
-
|
243
|
-
|
230
|
+
const focusBeforeMenuTrigger = React.useCallback(() => {
|
231
|
+
const prevFocusable = findPrevFocusable(state.triggerRef.current);
|
244
232
|
prevFocusable === null || prevFocusable === void 0 ? void 0 : prevFocusable.focus();
|
245
233
|
}, [findPrevFocusable, state.triggerRef]);
|
246
|
-
React.useEffect(
|
247
|
-
|
248
|
-
|
249
|
-
if (!shouldHandleKeyboardRef.current) {
|
250
|
-
return;
|
234
|
+
React.useEffect(() => {
|
235
|
+
if (open) {
|
236
|
+
focusFirst();
|
251
237
|
}
|
238
|
+
}, [open, focusFirst]);
|
239
|
+
React.useEffect(() => {
|
240
|
+
var _a;
|
252
241
|
|
253
242
|
if (open) {
|
254
243
|
focusFirst();
|
255
|
-
}
|
244
|
+
}
|
245
|
+
|
246
|
+
if (shouldHandleKeyboardRef.current && !open) {
|
256
247
|
if (shouldHandleTabRef.current && !state.isSubmenu) {
|
257
248
|
pressedShiftRef.current ? focusBeforeMenuTrigger() : focusAfterMenuTrigger();
|
258
249
|
} else {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Menu/useMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,oBAAT,EAA+B,SAA/B,EAA0C,2BAA1C,QAA6E,6BAA7E;AACA,SAAS,oBAAT,EAA+B,KAA/B,EAAsC,iBAAtC,EAAyD,gBAAzD,QAAiF,2BAAjF;AACA,SAAS,SAAT,QAA0B,0BAA1B;AACA,SAAS,eAAT,QAAgC,wBAAhC;AACA,SAAS,eAAT,QAAgC,yBAAhC;AACA,SAAS,WAAT,QAA4B,sBAA5B;AACA,SAAS,cAAT,QAA+B,4BAA/B;AACA,SAAS,gBAAT,EAA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aAAa,CAAE,KAAf,EAAA;AACD,GAH8B,EAG5B,CAAC,iBAAD,EAAoB,KAAK,CAAC,UAA1B,CAH4B,CAA/B;AAKA,EAAA,KAAK,CAAC,SAAN,CAAgB,MAAK;AACnB,QAAI,IAAJ,EAAU;AACR,MAAA,UAAU;AACX;AACF,GAJD,EAIG,CAAC,IAAD,EAAO,UAAP,CAJH;AAMA,EAAA,KAAK,CAAC,SAAN,CAAgB,MAAK;;;AACnB,QAAI,IAAJ,EAAU;AACR,MAAA,UAAU;AACX;;AAED,QAAI,uBAAuB,CAAC,OAAxB,IAAmC,CAAC,IAAxC,EAA8C;AAC5C,UAAI,kBAAkB,CAAC,OAAnB,IAA8B,CAAC,KAAK,CAAC,SAAzC,EAAoD;AAClD,QAAA,eAAe,CAAC,OAAhB,GAA0B,sBAAsB,EAAhD,GAAqD,qBAAqB,EAA1E;AACD,OAFD,MAEO;AACL,SAAA,EAAA,GAAA,KAAK,CAAC,UAAN,CAAiB,OAAjB,MAAwB,IAAxB,IAAwB,EAAA,KAAA,KAAA,CAAxB,GAAwB,KAAA,CAAxB,GAAwB,EAAA,CAAE,KAAF,EAAxB;AACD;AACF;;AAED,IAAA,uBAAuB,CAAC,OAAxB,GAAkC,KAAlC;AACA,IAAA,kBAAkB,CAAC,OAAnB,GAA6B,KAA7B;AACA,IAAA,eAAe,CAAC,OAAhB,GAA0B,KAA1B;AACD,GAhBD,EAgBG,CAAC,KAAK,CAAC,UAAP,EAAmB,KAAK,CAAC,SAAzB,EAAoC,IAApC,EAA0C,UAA1C,EAAsD,qBAAtD,EAA6E,sBAA7E,CAhBH;AAkBA,SAAO,CAAC,IAAI,KAAA,IAAJ,IAAA,IAAI,KAAA,KAAA,CAAJ,GAAA,IAAA,GAAQ,KAAT,EAAgB,OAAhB,CAAP;AACD,CAvID","sourcesContent":["import * as React from 'react';\nimport { usePopperMouseTarget, usePopper, resolvePositioningShorthand } from '@fluentui/react-positioning';\nimport { useControllableState, useId, useOnClickOutside, useEventCallback } from '@fluentui/react-utilities';\nimport { 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, MenuOpenEvents, MenuProps, MenuState } from './Menu.types';\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 triggerId = useId('menu');\n const isSubmenu = useIsSubmenu();\n const [contextTarget, setContextTarget] = usePopperMouseTarget();\n\n const popperState = {\n position: isSubmenu ? ('after' as const) : ('below' as const),\n align: isSubmenu ? ('top' as const) : ('start' as const),\n target: props.openOnContext ? contextTarget : undefined,\n ...resolvePositioningShorthand(props.positioning),\n };\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 const { targetRef: triggerRef, containerRef: menuPopoverRef } = usePopper(popperState);\n\n const initialState = {\n hoverDelay: 500,\n triggerId,\n isSubmenu: !!isSubmenu,\n openOnHover: !!isSubmenu,\n contextTarget,\n setContextTarget,\n ...props,\n menuTrigger,\n menuPopover,\n triggerRef,\n menuPopoverRef,\n components: {},\n } as const;\n\n // TODO Better way to narrow types ?\n\n const [open, setOpen] = useMenuOpenState(initialState);\n const [checkedValues, onCheckedValueChange] = useMenuSelectableState(initialState);\n\n return {\n ...initialState,\n open,\n setOpen,\n checkedValues,\n onCheckedValueChange,\n };\n};\n\n/**\n * Adds appropriate state values and handlers for selectable items\n * i.e checkboxes and radios\n */\nconst useMenuSelectableState = (\n state: Pick<MenuProps, 'checkedValues' | 'defaultCheckedValues' | 'onCheckedValueChange'>,\n) => {\n const [checkedValues, setCheckedValues] = useControllableState({\n state: state.checkedValues,\n defaultState: state.defaultCheckedValues,\n initialState: {},\n });\n const { onCheckedValueChange: onCheckedValueChangeOriginal } = state;\n const onCheckedValueChange: MenuState['onCheckedValueChange'] = useEventCallback((e, { name, checkedItems }) => {\n if (onCheckedValueChangeOriginal) {\n onCheckedValueChangeOriginal(e, { name, checkedItems });\n }\n\n setCheckedValues(s => {\n return s ? { ...s, [name]: checkedItems } : { [name]: checkedItems };\n });\n });\n\n return [checkedValues, onCheckedValueChange] as const;\n};\n\nconst useMenuOpenState = (\n state: Pick<MenuState, 'onOpenChange' | 'setContextTarget' | 'triggerRef' | 'menuPopoverRef' | 'isSubmenu'> &\n Pick<MenuProps, 'open' | 'defaultOpen'>,\n) => {\n const { targetDocument } = useFluent();\n const parentSetOpen = useMenuContext_unstable(context => context.setOpen);\n const onOpenChange: MenuState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const shouldHandleKeyboardRef = React.useRef(false);\n const shouldHandleTabRef = React.useRef(false);\n const pressedShiftRef = 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: MenuOpenEvents, 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 }\n\n if (data.keyboard) {\n shouldHandleKeyboardRef.current = true;\n shouldHandleTabRef.current = (e as React.KeyboardEvent).key === 'Tab';\n pressedShiftRef.current = (e as React.KeyboardEvent).shiftKey;\n }\n\n if (data.bubble) {\n parentSetOpen(e, { ...data });\n }\n\n setOpenState(data.open);\n });\n\n const setOpen = useEventCallback((e: MenuOpenEvents, 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.triggerRef],\n callback: e => setOpen(e, { open: false }),\n });\n useOnMenuMouseEnter({\n element: targetDocument,\n callback: e => {\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(e, { open: false });\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, findNextFocusable, findPrevFocusable } = useFocusFinders();\n const focusFirst = React.useCallback(() => {\n const firstFocusable = findFirstFocusable(state.menuPopoverRef.current);\n firstFocusable?.focus();\n }, [findFirstFocusable, state.menuPopoverRef]);\n\n const focusAfterMenuTrigger = React.useCallback(() => {\n const nextFocusable = findNextFocusable(state.triggerRef.current);\n nextFocusable?.focus();\n }, [findNextFocusable, state.triggerRef]);\n\n const focusBeforeMenuTrigger = React.useCallback(() => {\n const prevFocusable = findPrevFocusable(state.triggerRef.current);\n prevFocusable?.focus();\n }, [findPrevFocusable, state.triggerRef]);\n\n React.useEffect(() => {\n if (open) {\n focusFirst();\n }\n }, [open, focusFirst]);\n\n React.useEffect(() => {\n if (open) {\n focusFirst();\n }\n\n if (shouldHandleKeyboardRef.current && !open) {\n if (shouldHandleTabRef.current && !state.isSubmenu) {\n pressedShiftRef.current ? focusBeforeMenuTrigger() : focusAfterMenuTrigger();\n } else {\n state.triggerRef.current?.focus();\n }\n }\n\n shouldHandleKeyboardRef.current = false;\n shouldHandleTabRef.current = false;\n pressedShiftRef.current = false;\n }, [state.triggerRef, state.isSubmenu, open, focusFirst, focusAfterMenuTrigger, focusBeforeMenuTrigger]);\n\n return [open ?? false, setOpen] as const;\n};\n"],"sourceRoot":"../src/"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import type { MenuContextValues, MenuState } from './Menu.types';
|
2
|
-
export declare function
|
2
|
+
export declare function useMenuContextValues_unstable(state: MenuState): MenuContextValues;
|
@@ -1,39 +1,41 @@
|
|
1
|
-
export function
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
export function useMenuContextValues_unstable(state) {
|
2
|
+
const {
|
3
|
+
open,
|
4
|
+
setOpen,
|
5
|
+
onCheckedValueChange,
|
6
|
+
checkedValues,
|
7
|
+
defaultCheckedValues,
|
8
|
+
openOnHover,
|
9
|
+
openOnContext,
|
10
|
+
triggerRef,
|
11
|
+
triggerId,
|
12
|
+
menuPopoverRef,
|
13
|
+
isSubmenu,
|
14
|
+
hasCheckmarks,
|
15
|
+
hasIcons,
|
16
|
+
persistOnItemClick,
|
17
|
+
inline
|
18
|
+
} = state; // This context is created with "@fluentui/react-context-selector", these is no sense to memoize it
|
17
19
|
|
18
|
-
|
19
|
-
open
|
20
|
-
setOpen
|
21
|
-
onCheckedValueChange
|
22
|
-
checkedValues
|
23
|
-
defaultCheckedValues
|
24
|
-
triggerRef
|
25
|
-
openOnHover
|
26
|
-
openOnContext
|
27
|
-
triggerId
|
28
|
-
menuPopoverRef
|
29
|
-
isSubmenu
|
30
|
-
hasCheckmarks
|
31
|
-
hasIcons
|
32
|
-
persistOnItemClick
|
33
|
-
inline
|
20
|
+
const menu = {
|
21
|
+
open,
|
22
|
+
setOpen,
|
23
|
+
onCheckedValueChange,
|
24
|
+
checkedValues,
|
25
|
+
defaultCheckedValues,
|
26
|
+
triggerRef,
|
27
|
+
openOnHover,
|
28
|
+
openOnContext,
|
29
|
+
triggerId,
|
30
|
+
menuPopoverRef,
|
31
|
+
isSubmenu,
|
32
|
+
hasCheckmarks,
|
33
|
+
hasIcons,
|
34
|
+
persistOnItemClick,
|
35
|
+
inline
|
34
36
|
};
|
35
37
|
return {
|
36
|
-
menu
|
38
|
+
menu
|
37
39
|
};
|
38
40
|
}
|
39
41
|
//# sourceMappingURL=useMenuContextValues.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/Menu/useMenuContextValues.ts"],"names":[],"mappings":"AAEA,OAAM,SAAU,6BAAV,CAAwC,KAAxC,EAAwD;AAC5D,QAAM;AACJ,IAAA,IADI;AAEJ,IAAA,OAFI;AAGJ,IAAA,oBAHI;AAIJ,IAAA,aAJI;AAKJ,IAAA,oBALI;AAMJ,IAAA,WANI;AAOJ,IAAA,aAPI;AAQJ,IAAA,UARI;AASJ,IAAA,SATI;AAUJ,IAAA,cAVI;AAWJ,IAAA,SAXI;AAYJ,IAAA,aAZI;AAaJ,IAAA,QAbI;AAcJ,IAAA,kBAdI;AAeJ,IAAA;AAfI,MAgBF,KAhBJ,CAD4D,CAmB5D;;AACA,QAAM,IAAI,GAAG;AACX,IAAA,IADW;AAEX,IAAA,OAFW;AAGX,IAAA,oBAHW;AAIX,IAAA,aAJW;AAKX,IAAA,oBALW;AAMX,IAAA,UANW;AAOX,IAAA,WAPW;AAQX,IAAA,aARW;AASX,IAAA,SATW;AAUX,IAAA,cAVW;AAWX,IAAA,SAXW;AAYX,IAAA,aAZW;AAaX,IAAA,QAbW;AAcX,IAAA,kBAdW;AAeX,IAAA;AAfW,GAAb;AAkBA,SAAO;AAAE,IAAA;AAAF,GAAP;AACD","sourcesContent":["import type { MenuContextValues, MenuState } from './Menu.types';\n\nexport function useMenuContextValues_unstable(state: MenuState): MenuContextValues {\n const {\n open,\n setOpen,\n onCheckedValueChange,\n checkedValues,\n defaultCheckedValues,\n openOnHover,\n openOnContext,\n triggerRef,\n triggerId,\n menuPopoverRef,\n isSubmenu,\n hasCheckmarks,\n hasIcons,\n persistOnItemClick,\n inline,\n } = state;\n\n // This context is created with \"@fluentui/react-context-selector\", these is no sense to memoize it\n const menu = {\n open,\n setOpen,\n onCheckedValueChange,\n checkedValues,\n defaultCheckedValues,\n triggerRef,\n openOnHover,\n openOnContext,\n triggerId,\n menuPopoverRef,\n isSubmenu,\n hasCheckmarks,\n hasIcons,\n persistOnItemClick,\n inline,\n };\n\n return { menu };\n}\n"],"sourceRoot":"../src/"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { MenuDividerProps } from './MenuDivider.types';
|
2
2
|
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
3
3
|
/**
|
4
|
-
* Define a styled MenuDivider, using the `
|
4
|
+
* Define a styled MenuDivider, using the `useMenuDivider_unstable` hook.
|
5
5
|
*/
|
6
6
|
export declare const MenuDivider: ForwardRefComponent<MenuDividerProps>;
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
2
|
+
import { useMenuDivider_unstable } from './useMenuDivider';
|
3
|
+
import { useMenuDividerStyles_unstable } from './useMenuDividerStyles';
|
4
|
+
import { renderMenuDivider_unstable } from './renderMenuDivider';
|
5
5
|
/**
|
6
|
-
* Define a styled MenuDivider, using the `
|
6
|
+
* Define a styled MenuDivider, using the `useMenuDivider_unstable` hook.
|
7
7
|
*/
|
8
8
|
|
9
|
-
export
|
10
|
-
|
11
|
-
|
12
|
-
return
|
9
|
+
export const MenuDivider = /*#__PURE__*/React.forwardRef((props, ref) => {
|
10
|
+
const state = useMenuDivider_unstable(props, ref);
|
11
|
+
useMenuDividerStyles_unstable(state);
|
12
|
+
return renderMenuDivider_unstable(state);
|
13
13
|
});
|
14
14
|
MenuDivider.displayName = 'MenuDivider';
|
15
15
|
//# sourceMappingURL=MenuDivider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/MenuDivider/MenuDivider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,uBAAT,QAAwC,kBAAxC;AACA,SAAS,6BAAT,QAA8C,wBAA9C;AACA,SAAS,0BAAT,QAA2C,qBAA3C;AAIA;;AAEG;;AACH,OAAO,MAAM,WAAW,gBAA0C,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AAChG,QAAM,KAAK,GAAG,uBAAuB,CAAC,KAAD,EAAQ,GAAR,CAArC;AACA,EAAA,6BAA6B,CAAC,KAAD,CAA7B;AAEA,SAAO,0BAA0B,CAAC,KAAD,CAAjC;AACD,CALiE,CAA3D;AAOP,WAAW,CAAC,WAAZ,GAA0B,aAA1B","sourcesContent":["import * as React from 'react';\nimport { useMenuDivider_unstable } from './useMenuDivider';\nimport { useMenuDividerStyles_unstable } from './useMenuDividerStyles';\nimport { renderMenuDivider_unstable } from './renderMenuDivider';\nimport type { MenuDividerProps } from './MenuDivider.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Define a styled MenuDivider, using the `useMenuDivider_unstable` hook.\n */\nexport const MenuDivider: ForwardRefComponent<MenuDividerProps> = React.forwardRef((props, ref) => {\n const state = useMenuDivider_unstable(props, ref);\n useMenuDividerStyles_unstable(state);\n\n return renderMenuDivider_unstable(state);\n});\n\nMenuDivider.displayName = 'MenuDivider';\n"],"sourceRoot":"../src/"}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { ComponentProps, ComponentState,
|
1
|
+
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
|
2
2
|
export declare type MenuDividerSlots = {
|
3
|
-
root:
|
3
|
+
root: Slot<'div'>;
|
4
4
|
};
|
5
5
|
export declare type MenuDividerProps = ComponentProps<MenuDividerSlots>;
|
6
6
|
export declare type MenuDividerState = ComponentState<MenuDividerSlots>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MenuDivider.types.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"MenuDivider.types.js","sourceRoot":"../src/","sources":["components/MenuDivider/MenuDivider.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type MenuDividerSlots = {\n root: Slot<'div'>;\n};\n\nexport type MenuDividerProps = ComponentProps<MenuDividerSlots>;\n\nexport type MenuDividerState = ComponentState<MenuDividerSlots>;\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/MenuDivider/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './MenuDivider.types';\nexport * from './MenuDivider';\nexport * from './renderMenuDivider';\nexport * from './useMenuDivider';\nexport * from './useMenuDividerStyles';\n"]}
|
@@ -3,4 +3,4 @@ import { MenuDividerState } from './MenuDivider.types';
|
|
3
3
|
* Redefine the render function to add slots. Reuse the menudivider structure but add
|
4
4
|
* slots to children.
|
5
5
|
*/
|
6
|
-
export declare const
|
6
|
+
export declare const renderMenuDivider_unstable: (state: MenuDividerState) => JSX.Element;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { __assign } from "tslib";
|
2
1
|
import * as React from 'react';
|
3
2
|
import { getSlots } from '@fluentui/react-utilities';
|
4
3
|
/**
|
@@ -6,11 +5,12 @@ import { getSlots } from '@fluentui/react-utilities';
|
|
6
5
|
* slots to children.
|
7
6
|
*/
|
8
7
|
|
9
|
-
export
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return /*#__PURE__*/React.createElement(slots.root,
|
8
|
+
export const renderMenuDivider_unstable = state => {
|
9
|
+
const {
|
10
|
+
slots,
|
11
|
+
slotProps
|
12
|
+
} = getSlots(state);
|
13
|
+
return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
|
14
|
+
});
|
15
15
|
};
|
16
16
|
//# sourceMappingURL=renderMenuDivider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/MenuDivider/renderMenuDivider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;;AAGG;;AACH,OAAO,MAAM,0BAA0B,GAAI,KAAD,IAA4B;AACpE,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAmB,KAAnB,CAArC;AAEA,sBAAO,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,CAAP;AACD,CAJM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { MenuDividerSlots, MenuDividerState } from './MenuDivider.types';\n\n/**\n * Redefine the render function to add slots. Reuse the menudivider structure but add\n * slots to children.\n */\nexport const renderMenuDivider_unstable = (state: MenuDividerState) => {\n const { slots, slotProps } = getSlots<MenuDividerSlots>(state);\n\n return <slots.root {...slotProps.root} />;\n};\n"],"sourceRoot":"../src/"}
|
@@ -3,4 +3,4 @@ import type { MenuDividerProps, MenuDividerState } from './MenuDivider.types';
|
|
3
3
|
/**
|
4
4
|
* Given user props, returns state and render function for a MenuDivider.
|
5
5
|
*/
|
6
|
-
export declare const
|
6
|
+
export declare const useMenuDivider_unstable: (props: MenuDividerProps, ref: React.Ref<HTMLElement>) => MenuDividerState;
|