@fluentui-react-native/menu 1.15.0 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/SPEC.md +8 -4
- package/lib/Menu/Menu.d.ts +2 -2
- package/lib/Menu/Menu.js +12 -12
- package/lib/Menu/Menu.types.d.ts +47 -47
- package/lib/Menu/Menu.types.js +4 -4
- package/lib/Menu/index.d.ts +1 -1
- package/lib/Menu/index.js +1 -1
- package/lib/Menu/renderMenu.android.d.ts +2 -6
- package/lib/Menu/renderMenu.android.js +10 -17
- package/lib/Menu/renderMenu.d.ts +2 -6
- package/lib/Menu/renderMenu.js +5 -8
- package/lib/Menu/useMenu.android.d.ts +1 -1
- package/lib/Menu/useMenu.android.js +245 -251
- package/lib/Menu/useMenu.d.ts +1 -1
- package/lib/Menu/useMenu.js +70 -75
- package/lib/Menu/useMenuContextValue.d.ts +1 -1
- package/lib/Menu/useMenuContextValue.js +4 -4
- package/lib/MenuCallout/MenuCallout.android.d.ts +2 -2
- package/lib/MenuCallout/MenuCallout.android.js +19 -39
- package/lib/MenuCallout/MenuCallout.d.ts +2 -2
- package/lib/MenuCallout/MenuCallout.js +7 -7
- package/lib/MenuCallout/MenuCallout.types.d.ts +13 -13
- package/lib/MenuCallout/MenuCallout.types.d.ts.map +1 -1
- package/lib/MenuCallout/MenuCallout.types.js +1 -1
- package/lib/MenuCallout/index.d.ts +1 -1
- package/lib/MenuCallout/index.js +1 -1
- package/lib/MenuDivider/MenuDivider.d.ts +2 -7
- package/lib/MenuDivider/MenuDivider.js +13 -13
- package/lib/MenuDivider/MenuDivider.styling.d.ts +1 -1
- package/lib/MenuDivider/MenuDivider.styling.js +16 -19
- package/lib/MenuDivider/MenuDivider.types.d.ts +12 -12
- package/lib/MenuDivider/MenuDivider.types.js +1 -1
- package/lib/MenuDivider/MenuDividerTokens.android.d.ts +1 -1
- package/lib/MenuDivider/MenuDividerTokens.android.js +4 -4
- package/lib/MenuDivider/MenuDividerTokens.d.ts +1 -1
- package/lib/MenuDivider/MenuDividerTokens.js +4 -4
- package/lib/MenuDivider/MenuDividerTokens.macos.d.ts +1 -1
- package/lib/MenuDivider/MenuDividerTokens.macos.js +4 -4
- package/lib/MenuDivider/MenuDividerTokens.win32.d.ts +1 -1
- package/lib/MenuDivider/MenuDividerTokens.win32.js +4 -4
- package/lib/MenuDivider/index.d.ts +1 -1
- package/lib/MenuDivider/index.js +1 -1
- package/lib/MenuGroup/MenuGroup.d.ts +2 -7
- package/lib/MenuGroup/MenuGroup.js +51 -63
- package/lib/MenuGroup/MenuGroup.types.d.ts +7 -7
- package/lib/MenuGroup/MenuGroup.types.js +1 -1
- package/lib/MenuGroup/index.d.ts +1 -1
- package/lib/MenuGroup/index.js +1 -1
- package/lib/MenuGroupHeader/MenuGroupHeader.d.ts +2 -7
- package/lib/MenuGroupHeader/MenuGroupHeader.js +14 -14
- package/lib/MenuGroupHeader/MenuGroupHeader.styling.d.ts +1 -1
- package/lib/MenuGroupHeader/MenuGroupHeader.styling.js +13 -16
- package/lib/MenuGroupHeader/MenuGroupHeader.types.d.ts +7 -7
- package/lib/MenuGroupHeader/MenuGroupHeader.types.js +1 -1
- package/lib/MenuGroupHeader/MenuGroupHeaderTokens.d.ts +1 -1
- package/lib/MenuGroupHeader/MenuGroupHeaderTokens.js +7 -7
- package/lib/MenuGroupHeader/MenuGroupHeaderTokens.macos.d.ts +1 -1
- package/lib/MenuGroupHeader/MenuGroupHeaderTokens.macos.js +8 -8
- package/lib/MenuGroupHeader/index.d.ts +1 -1
- package/lib/MenuGroupHeader/index.js +1 -1
- package/lib/MenuItem/MenuItem.d.ts +2 -7
- package/lib/MenuItem/MenuItem.js +41 -63
- package/lib/MenuItem/MenuItem.styling.d.ts +1 -1
- package/lib/MenuItem/MenuItem.styling.js +52 -70
- package/lib/MenuItem/MenuItem.types.d.ts +83 -83
- package/lib/MenuItem/MenuItem.types.js +1 -1
- package/lib/MenuItem/MenuItemTokens.android.d.ts +1 -1
- package/lib/MenuItem/MenuItemTokens.android.js +17 -17
- package/lib/MenuItem/MenuItemTokens.d.ts +1 -1
- package/lib/MenuItem/MenuItemTokens.js +35 -35
- package/lib/MenuItem/MenuItemTokens.macos.d.ts +1 -1
- package/lib/MenuItem/MenuItemTokens.macos.js +34 -34
- package/lib/MenuItem/MenuItemTokens.win32.d.ts +1 -1
- package/lib/MenuItem/MenuItemTokens.win32.js +36 -36
- package/lib/MenuItem/index.d.ts +1 -1
- package/lib/MenuItem/index.js +1 -1
- package/lib/MenuItem/useMenuItem.d.ts +1 -1
- package/lib/MenuItem/useMenuItem.js +101 -111
- package/lib/MenuItemCheckbox/MenuItemCheckbox.d.ts +3 -11
- package/lib/MenuItemCheckbox/MenuItemCheckbox.js +26 -54
- package/lib/MenuItemCheckbox/MenuItemCheckbox.styling.d.ts +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckbox.styling.js +62 -81
- package/lib/MenuItemCheckbox/MenuItemCheckbox.types.d.ts +89 -90
- package/lib/MenuItemCheckbox/MenuItemCheckbox.types.d.ts.map +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckbox.types.js +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckboxTokens.android.d.ts +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckboxTokens.android.js +35 -35
- package/lib/MenuItemCheckbox/MenuItemCheckboxTokens.d.ts +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckboxTokens.js +44 -44
- package/lib/MenuItemCheckbox/MenuItemCheckboxTokens.macos.d.ts +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckboxTokens.macos.js +42 -42
- package/lib/MenuItemCheckbox/MenuItemCheckboxTokens.win32.d.ts +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckboxTokens.win32.js +45 -45
- package/lib/MenuItemCheckbox/index.d.ts +2 -8
- package/lib/MenuItemCheckbox/index.js +1 -1
- package/lib/MenuItemCheckbox/useMenuItemCheckbox.d.ts +2 -5
- package/lib/MenuItemCheckbox/useMenuItemCheckbox.js +104 -129
- package/lib/MenuItemRadio/MenuItemRadio.d.ts +3 -11
- package/lib/MenuItemRadio/MenuItemRadio.js +26 -54
- package/lib/MenuItemRadio/MenuItemRadio.styling.android.d.ts +1 -1
- package/lib/MenuItemRadio/MenuItemRadio.styling.android.js +60 -78
- package/lib/MenuItemRadio/MenuItemRadio.styling.d.ts +1 -1
- package/lib/MenuItemRadio/MenuItemRadio.styling.js +44 -59
- package/lib/MenuItemRadio/MenuItemRadio.types.d.ts +120 -121
- package/lib/MenuItemRadio/MenuItemRadio.types.d.ts.map +1 -1
- package/lib/MenuItemRadio/MenuItemRadio.types.js +1 -1
- package/lib/MenuItemRadio/MenuItemRadioTokens.android.d.ts +1 -1
- package/lib/MenuItemRadio/MenuItemRadioTokens.android.js +38 -38
- package/lib/MenuItemRadio/MenuItemRadioTokens.d.ts +1 -1
- package/lib/MenuItemRadio/MenuItemRadioTokens.js +45 -45
- package/lib/MenuItemRadio/MenuItemRadioTokens.macos.d.ts +1 -1
- package/lib/MenuItemRadio/MenuItemRadioTokens.macos.js +43 -43
- package/lib/MenuItemRadio/index.d.ts +2 -8
- package/lib/MenuItemRadio/index.js +1 -1
- package/lib/MenuItemRadio/useMenuItemRadio.d.ts +1 -1
- package/lib/MenuItemRadio/useMenuItemRadio.js +23 -26
- package/lib/MenuList/MenuList.d.ts +2 -7
- package/lib/MenuList/MenuList.js +54 -70
- package/lib/MenuList/MenuList.styling.d.ts +1 -1
- package/lib/MenuList/MenuList.styling.js +21 -27
- package/lib/MenuList/MenuList.types.d.ts +72 -72
- package/lib/MenuList/MenuList.types.js +1 -1
- package/lib/MenuList/MenuListTokens.android.d.ts +1 -1
- package/lib/MenuList/MenuListTokens.android.js +4 -4
- package/lib/MenuList/MenuListTokens.d.ts +1 -1
- package/lib/MenuList/MenuListTokens.js +6 -6
- package/lib/MenuList/MenuListTokens.macos.d.ts +1 -1
- package/lib/MenuList/MenuListTokens.macos.js +4 -4
- package/lib/MenuList/MenuListTokens.win32.d.ts +1 -1
- package/lib/MenuList/MenuListTokens.win32.js +9 -9
- package/lib/MenuList/index.d.ts +1 -1
- package/lib/MenuList/index.js +1 -1
- package/lib/MenuList/useMenuList.d.ts +1 -1
- package/lib/MenuList/useMenuList.js +142 -159
- package/lib/MenuList/useMenuListContextValue.d.ts +1 -1
- package/lib/MenuList/useMenuListContextValue.js +2 -2
- package/lib/MenuPopover/MenuPopover.d.ts +3 -9
- package/lib/MenuPopover/MenuPopover.d.ts.map +1 -1
- package/lib/MenuPopover/MenuPopover.js +35 -35
- package/lib/MenuPopover/MenuPopover.types.d.ts +14 -14
- package/lib/MenuPopover/MenuPopover.types.d.ts.map +1 -1
- package/lib/MenuPopover/MenuPopover.types.js +1 -1
- package/lib/MenuPopover/MenuPopoverTokens.android.d.ts +3 -7
- package/lib/MenuPopover/MenuPopoverTokens.android.d.ts.map +1 -1
- package/lib/MenuPopover/MenuPopoverTokens.android.js +3 -6
- package/lib/MenuPopover/MenuPopoverTokens.d.ts +3 -7
- package/lib/MenuPopover/MenuPopoverTokens.d.ts.map +1 -1
- package/lib/MenuPopover/MenuPopoverTokens.js +2 -5
- package/lib/MenuPopover/MenuPopoverTokens.macos.d.ts +3 -7
- package/lib/MenuPopover/MenuPopoverTokens.macos.d.ts.map +1 -1
- package/lib/MenuPopover/MenuPopoverTokens.macos.js +7 -10
- package/lib/MenuPopover/MenuPopoverTokens.macos.js.map +1 -1
- package/lib/MenuPopover/index.d.ts +1 -1
- package/lib/MenuPopover/index.js +1 -1
- package/lib/MenuPopover/useMenuPopover.d.ts +2 -2
- package/lib/MenuPopover/useMenuPopover.js +79 -96
- package/lib/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib/MenuTrigger/MenuTrigger.d.ts +3 -3
- package/lib/MenuTrigger/MenuTrigger.js +16 -16
- package/lib/MenuTrigger/MenuTrigger.types.d.ts +13 -13
- package/lib/MenuTrigger/MenuTrigger.types.js +1 -1
- package/lib/MenuTrigger/index.d.ts +1 -1
- package/lib/MenuTrigger/index.js +1 -1
- package/lib/MenuTrigger/useMenuTrigger.d.ts +1 -1
- package/lib/MenuTrigger/useMenuTrigger.js +70 -99
- package/lib/MenuTrigger/useMergeRefs.d.ts +1 -1
- package/lib/MenuTrigger/useMergeRefs.js +14 -16
- package/lib/__tests__/Menu.test.d.ts +1 -1
- package/lib/__tests__/Menu.test.js +122 -230
- package/lib/consts.d.ts +1 -1
- package/lib/consts.js +3 -3
- package/lib/context/index.d.ts +1 -1
- package/lib/context/index.js +1 -1
- package/lib/context/menuContext.d.ts +5 -5
- package/lib/context/menuContext.js +15 -15
- package/lib/context/menuListContext.d.ts +4 -4
- package/lib/context/menuListContext.js +12 -12
- package/lib/context/menuTriggerContext.d.ts +1 -1
- package/lib/context/menuTriggerContext.js +1 -1
- package/lib/index.d.ts +4 -26
- package/lib/index.js +2 -12
- package/lib-commonjs/Menu/Menu.d.ts +2 -2
- package/lib-commonjs/Menu/Menu.js +23 -25
- package/lib-commonjs/Menu/Menu.types.d.ts +47 -47
- package/lib-commonjs/Menu/Menu.types.js +6 -6
- package/lib-commonjs/Menu/index.d.ts +1 -1
- package/lib-commonjs/Menu/index.js +11 -31
- package/lib-commonjs/Menu/renderMenu.android.d.ts +2 -6
- package/lib-commonjs/Menu/renderMenu.android.js +14 -26
- package/lib-commonjs/Menu/renderMenu.d.ts +2 -6
- package/lib-commonjs/Menu/renderMenu.js +8 -11
- package/lib-commonjs/Menu/useMenu.android.d.ts +1 -1
- package/lib-commonjs/Menu/useMenu.android.js +280 -303
- package/lib-commonjs/Menu/useMenu.d.ts +1 -1
- package/lib-commonjs/Menu/useMenu.js +79 -86
- package/lib-commonjs/Menu/useMenuContextValue.d.ts +1 -1
- package/lib-commonjs/Menu/useMenuContextValue.js +10 -12
- package/lib-commonjs/MenuCallout/MenuCallout.android.d.ts +2 -2
- package/lib-commonjs/MenuCallout/MenuCallout.android.js +25 -48
- package/lib-commonjs/MenuCallout/MenuCallout.d.ts +2 -2
- package/lib-commonjs/MenuCallout/MenuCallout.js +12 -12
- package/lib-commonjs/MenuCallout/MenuCallout.types.d.ts +13 -13
- package/lib-commonjs/MenuCallout/MenuCallout.types.d.ts.map +1 -1
- package/lib-commonjs/MenuCallout/MenuCallout.types.js +3 -3
- package/lib-commonjs/MenuCallout/index.d.ts +1 -1
- package/lib-commonjs/MenuCallout/index.js +7 -17
- package/lib-commonjs/MenuDivider/MenuDivider.d.ts +2 -7
- package/lib-commonjs/MenuDivider/MenuDivider.js +19 -19
- package/lib-commonjs/MenuDivider/MenuDivider.styling.d.ts +1 -1
- package/lib-commonjs/MenuDivider/MenuDivider.styling.js +22 -25
- package/lib-commonjs/MenuDivider/MenuDivider.types.d.ts +12 -12
- package/lib-commonjs/MenuDivider/MenuDivider.types.js +3 -3
- package/lib-commonjs/MenuDivider/MenuDividerTokens.android.d.ts +1 -1
- package/lib-commonjs/MenuDivider/MenuDividerTokens.android.js +7 -7
- package/lib-commonjs/MenuDivider/MenuDividerTokens.d.ts +1 -1
- package/lib-commonjs/MenuDivider/MenuDividerTokens.js +7 -7
- package/lib-commonjs/MenuDivider/MenuDividerTokens.macos.d.ts +1 -1
- package/lib-commonjs/MenuDivider/MenuDividerTokens.macos.js +7 -7
- package/lib-commonjs/MenuDivider/MenuDividerTokens.win32.d.ts +1 -1
- package/lib-commonjs/MenuDivider/MenuDividerTokens.win32.js +7 -7
- package/lib-commonjs/MenuDivider/index.d.ts +1 -1
- package/lib-commonjs/MenuDivider/index.js +7 -17
- package/lib-commonjs/MenuGroup/MenuGroup.d.ts +2 -7
- package/lib-commonjs/MenuGroup/MenuGroup.js +62 -78
- package/lib-commonjs/MenuGroup/MenuGroup.types.d.ts +7 -7
- package/lib-commonjs/MenuGroup/MenuGroup.types.js +3 -3
- package/lib-commonjs/MenuGroup/index.d.ts +1 -1
- package/lib-commonjs/MenuGroup/index.js +7 -17
- package/lib-commonjs/MenuGroupHeader/MenuGroupHeader.d.ts +2 -7
- package/lib-commonjs/MenuGroupHeader/MenuGroupHeader.js +20 -20
- package/lib-commonjs/MenuGroupHeader/MenuGroupHeader.styling.d.ts +1 -1
- package/lib-commonjs/MenuGroupHeader/MenuGroupHeader.styling.js +19 -22
- package/lib-commonjs/MenuGroupHeader/MenuGroupHeader.types.d.ts +7 -7
- package/lib-commonjs/MenuGroupHeader/MenuGroupHeader.types.js +3 -3
- package/lib-commonjs/MenuGroupHeader/MenuGroupHeaderTokens.d.ts +1 -1
- package/lib-commonjs/MenuGroupHeader/MenuGroupHeaderTokens.js +10 -10
- package/lib-commonjs/MenuGroupHeader/MenuGroupHeaderTokens.macos.d.ts +1 -1
- package/lib-commonjs/MenuGroupHeader/MenuGroupHeaderTokens.macos.js +11 -11
- package/lib-commonjs/MenuGroupHeader/index.d.ts +1 -1
- package/lib-commonjs/MenuGroupHeader/index.js +7 -17
- package/lib-commonjs/MenuItem/MenuItem.d.ts +2 -7
- package/lib-commonjs/MenuItem/MenuItem.js +51 -73
- package/lib-commonjs/MenuItem/MenuItem.styling.d.ts +1 -1
- package/lib-commonjs/MenuItem/MenuItem.styling.js +59 -80
- package/lib-commonjs/MenuItem/MenuItem.types.d.ts +83 -83
- package/lib-commonjs/MenuItem/MenuItem.types.js +3 -3
- package/lib-commonjs/MenuItem/MenuItemTokens.android.d.ts +1 -1
- package/lib-commonjs/MenuItem/MenuItemTokens.android.js +20 -20
- package/lib-commonjs/MenuItem/MenuItemTokens.d.ts +1 -1
- package/lib-commonjs/MenuItem/MenuItemTokens.js +38 -38
- package/lib-commonjs/MenuItem/MenuItemTokens.macos.d.ts +1 -1
- package/lib-commonjs/MenuItem/MenuItemTokens.macos.js +37 -37
- package/lib-commonjs/MenuItem/MenuItemTokens.win32.d.ts +1 -1
- package/lib-commonjs/MenuItem/MenuItemTokens.win32.js +39 -39
- package/lib-commonjs/MenuItem/index.d.ts +1 -1
- package/lib-commonjs/MenuItem/index.js +9 -24
- package/lib-commonjs/MenuItem/useMenuItem.d.ts +1 -1
- package/lib-commonjs/MenuItem/useMenuItem.js +140 -169
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.d.ts +3 -11
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.js +37 -65
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.styling.d.ts +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.styling.js +69 -91
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.types.d.ts +89 -90
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.types.d.ts.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.types.js +3 -3
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckboxTokens.android.d.ts +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckboxTokens.android.js +38 -38
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckboxTokens.d.ts +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckboxTokens.js +47 -47
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckboxTokens.macos.d.ts +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckboxTokens.macos.js +45 -45
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckboxTokens.win32.d.ts +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckboxTokens.win32.js +48 -48
- package/lib-commonjs/MenuItemCheckbox/index.d.ts +2 -8
- package/lib-commonjs/MenuItemCheckbox/index.js +10 -30
- package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.d.ts +2 -5
- package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.js +143 -185
- package/lib-commonjs/MenuItemRadio/MenuItemRadio.d.ts +3 -11
- package/lib-commonjs/MenuItemRadio/MenuItemRadio.js +37 -65
- package/lib-commonjs/MenuItemRadio/MenuItemRadio.styling.android.d.ts +1 -1
- package/lib-commonjs/MenuItemRadio/MenuItemRadio.styling.android.js +67 -88
- package/lib-commonjs/MenuItemRadio/MenuItemRadio.styling.d.ts +1 -1
- package/lib-commonjs/MenuItemRadio/MenuItemRadio.styling.js +51 -69
- package/lib-commonjs/MenuItemRadio/MenuItemRadio.types.d.ts +120 -121
- package/lib-commonjs/MenuItemRadio/MenuItemRadio.types.d.ts.map +1 -1
- package/lib-commonjs/MenuItemRadio/MenuItemRadio.types.js +3 -3
- package/lib-commonjs/MenuItemRadio/MenuItemRadioTokens.android.d.ts +1 -1
- package/lib-commonjs/MenuItemRadio/MenuItemRadioTokens.android.js +41 -41
- package/lib-commonjs/MenuItemRadio/MenuItemRadioTokens.d.ts +1 -1
- package/lib-commonjs/MenuItemRadio/MenuItemRadioTokens.js +48 -48
- package/lib-commonjs/MenuItemRadio/MenuItemRadioTokens.macos.d.ts +1 -1
- package/lib-commonjs/MenuItemRadio/MenuItemRadioTokens.macos.js +46 -46
- package/lib-commonjs/MenuItemRadio/index.d.ts +2 -8
- package/lib-commonjs/MenuItemRadio/index.js +9 -24
- package/lib-commonjs/MenuItemRadio/useMenuItemRadio.d.ts +1 -1
- package/lib-commonjs/MenuItemRadio/useMenuItemRadio.js +58 -78
- package/lib-commonjs/MenuList/MenuList.d.ts +2 -7
- package/lib-commonjs/MenuList/MenuList.js +69 -87
- package/lib-commonjs/MenuList/MenuList.styling.d.ts +1 -1
- package/lib-commonjs/MenuList/MenuList.styling.js +28 -34
- package/lib-commonjs/MenuList/MenuList.types.d.ts +72 -72
- package/lib-commonjs/MenuList/MenuList.types.js +3 -3
- package/lib-commonjs/MenuList/MenuListTokens.android.d.ts +1 -1
- package/lib-commonjs/MenuList/MenuListTokens.android.js +7 -7
- package/lib-commonjs/MenuList/MenuListTokens.d.ts +1 -1
- package/lib-commonjs/MenuList/MenuListTokens.js +9 -9
- package/lib-commonjs/MenuList/MenuListTokens.macos.d.ts +1 -1
- package/lib-commonjs/MenuList/MenuListTokens.macos.js +7 -7
- package/lib-commonjs/MenuList/MenuListTokens.win32.d.ts +1 -1
- package/lib-commonjs/MenuList/MenuListTokens.win32.js +12 -12
- package/lib-commonjs/MenuList/index.d.ts +1 -1
- package/lib-commonjs/MenuList/index.js +11 -31
- package/lib-commonjs/MenuList/useMenuList.d.ts +1 -1
- package/lib-commonjs/MenuList/useMenuList.js +151 -170
- package/lib-commonjs/MenuList/useMenuListContextValue.d.ts +1 -1
- package/lib-commonjs/MenuList/useMenuListContextValue.js +4 -4
- package/lib-commonjs/MenuPopover/MenuPopover.d.ts +3 -9
- package/lib-commonjs/MenuPopover/MenuPopover.d.ts.map +1 -1
- package/lib-commonjs/MenuPopover/MenuPopover.js +48 -50
- package/lib-commonjs/MenuPopover/MenuPopover.types.d.ts +14 -14
- package/lib-commonjs/MenuPopover/MenuPopover.types.d.ts.map +1 -1
- package/lib-commonjs/MenuPopover/MenuPopover.types.js +3 -3
- package/lib-commonjs/MenuPopover/MenuPopoverTokens.android.d.ts +3 -7
- package/lib-commonjs/MenuPopover/MenuPopoverTokens.android.d.ts.map +1 -1
- package/lib-commonjs/MenuPopover/MenuPopoverTokens.android.js +9 -12
- package/lib-commonjs/MenuPopover/MenuPopoverTokens.d.ts +3 -7
- package/lib-commonjs/MenuPopover/MenuPopoverTokens.d.ts.map +1 -1
- package/lib-commonjs/MenuPopover/MenuPopoverTokens.js +6 -9
- package/lib-commonjs/MenuPopover/MenuPopoverTokens.macos.d.ts +3 -7
- package/lib-commonjs/MenuPopover/MenuPopoverTokens.macos.d.ts.map +1 -1
- package/lib-commonjs/MenuPopover/MenuPopoverTokens.macos.js +12 -15
- package/lib-commonjs/MenuPopover/MenuPopoverTokens.macos.js.map +1 -1
- package/lib-commonjs/MenuPopover/index.d.ts +1 -1
- package/lib-commonjs/MenuPopover/index.js +9 -24
- package/lib-commonjs/MenuPopover/useMenuPopover.d.ts +2 -2
- package/lib-commonjs/MenuPopover/useMenuPopover.js +87 -106
- package/lib-commonjs/MenuPopover/useMenuPopover.js.map +1 -1
- package/lib-commonjs/MenuTrigger/MenuTrigger.d.ts +3 -3
- package/lib-commonjs/MenuTrigger/MenuTrigger.js +52 -69
- package/lib-commonjs/MenuTrigger/MenuTrigger.types.d.ts +13 -13
- package/lib-commonjs/MenuTrigger/MenuTrigger.types.js +3 -3
- package/lib-commonjs/MenuTrigger/index.d.ts +1 -1
- package/lib-commonjs/MenuTrigger/index.js +9 -24
- package/lib-commonjs/MenuTrigger/useMenuTrigger.d.ts +1 -1
- package/lib-commonjs/MenuTrigger/useMenuTrigger.js +80 -111
- package/lib-commonjs/MenuTrigger/useMergeRefs.d.ts +1 -1
- package/lib-commonjs/MenuTrigger/useMergeRefs.js +46 -65
- package/lib-commonjs/__tests__/Menu.test.d.ts +1 -1
- package/lib-commonjs/__tests__/Menu.test.js +169 -333
- package/lib-commonjs/consts.d.ts +1 -1
- package/lib-commonjs/consts.js +6 -6
- package/lib-commonjs/context/index.d.ts +1 -1
- package/lib-commonjs/context/index.js +16 -70
- package/lib-commonjs/context/menuContext.d.ts +5 -5
- package/lib-commonjs/context/menuContext.js +47 -64
- package/lib-commonjs/context/menuListContext.d.ts +4 -4
- package/lib-commonjs/context/menuListContext.js +44 -61
- package/lib-commonjs/context/menuTriggerContext.d.ts +1 -1
- package/lib-commonjs/context/menuTriggerContext.js +7 -9
- package/lib-commonjs/index.d.ts +4 -26
- package/lib-commonjs/index.js +56 -296
- package/package.json +28 -27
- package/src/MenuCallout/MenuCallout.types.ts +12 -13
- package/src/MenuItemCheckbox/MenuItemCheckbox.types.ts +4 -2
- package/src/MenuItemRadio/MenuItemRadio.types.ts +4 -2
- package/src/MenuPopover/MenuPopover.types.ts +12 -13
- package/src/MenuPopover/MenuPopoverTokens.macos.ts +2 -2
- package/src/MenuPopover/useMenuPopover.ts +1 -1
|
@@ -16,214 +16,214 @@ const EASING = Easing.bezier(0.4, 0, 0.2, 1);
|
|
|
16
16
|
// Screen indent is the fixed value according to Android guidelines which depicts the minimum distance from screen edge Menu should have
|
|
17
17
|
const SCREEN_INDENT = 16;
|
|
18
18
|
export const useMenu = (props) => {
|
|
19
|
-
/**
|
|
20
|
-
* State , Ref and Context Values for Menu Container and Anchor
|
|
21
|
-
*/
|
|
22
|
-
const triggerRef = React.useRef(null);
|
|
23
|
-
const context = useMenuContext();
|
|
24
|
-
const isSubmenu = context.triggerRef !== null;
|
|
25
|
-
const isOpenControlled = typeof props.open !== 'undefined';
|
|
26
|
-
const _container = useRef(null);
|
|
27
|
-
const [menuState, setMenuState] = React.useState(AndroidMenuStates.Hidden);
|
|
28
|
-
/**
|
|
29
|
-
* Call for useMenuCheckedState for identifying if any MenuItemCheckbox is checked or not
|
|
30
|
-
*/
|
|
31
|
-
const [checked, onCheckedChange] = useMenuCheckedState(props);
|
|
32
|
-
/**
|
|
33
|
-
* State Variables related to Height,Width and Position of the Menu Popover
|
|
34
|
-
*/
|
|
35
|
-
const [maxMenuHeight] = useState(250);
|
|
36
|
-
const [anchorWidth, setAnchorWidth] = React.useState(0);
|
|
37
|
-
const [left, setLeft] = React.useState(0);
|
|
38
|
-
const [menuHeight, setMenuHeight] = React.useState(0);
|
|
39
|
-
const [menuWidth, setMenuWidth] = React.useState(0);
|
|
40
|
-
const [top, setTop] = React.useState(0);
|
|
41
|
-
/**
|
|
42
|
-
* Animation value for the Menu popover show,hide and opacity values
|
|
43
|
-
*/
|
|
44
|
-
const [menuSizeAnimation, setMenuSizeAnimation] = React.useState(new Animated.ValueXY({ x: 0, y: 0 }));
|
|
45
|
-
const [opacityAnimation, setOpacityAnimation] = React.useState(new Animated.Value(0));
|
|
46
|
-
/**
|
|
47
|
-
* RTL for the MenuItem needs to taken care as well.
|
|
48
|
-
*/
|
|
49
|
-
const { isRTL } = I18nManager;
|
|
50
|
-
/**
|
|
51
|
-
* Calcualations related to Menu Popver position and dimensions
|
|
52
|
-
*/
|
|
53
|
-
const dimensions = Dimensions.get('screen');
|
|
54
|
-
const { width: windowWidth } = dimensions;
|
|
55
|
-
const windowHeight = dimensions.height - (StatusBar.currentHeight || 0);
|
|
56
|
-
const menuSize = {
|
|
57
|
-
width: menuSizeAnimation.x,
|
|
58
|
-
height: menuSizeAnimation.y,
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* show function handles the opening of the Menu , it calcuates the position of the Anchor in the screen.
|
|
62
|
-
* It also sets the Anchor width and change the state of the Popover
|
|
63
|
-
*/ /**
|
|
64
|
-
* show function handles the opening of the Menu , it calcuates the position of the Anchor in the screen.
|
|
65
|
-
* It also sets the Anchor width and change the state of the Popover
|
|
66
|
-
*/
|
|
67
|
-
const show = React.useCallback(() => {
|
|
68
|
-
_container.current?.measureInWindow((left, top, buttonWidth, buttonHeight) => {
|
|
69
|
-
setAnchorWidth(buttonWidth);
|
|
70
|
-
setLeft(left);
|
|
71
|
-
setMenuState(AndroidMenuStates.Shown);
|
|
72
|
-
setTop(top + buttonHeight);
|
|
73
|
-
});
|
|
74
|
-
}, []);
|
|
75
|
-
/**
|
|
76
|
-
* hide function handles the hiding of the Menu when user clicks on the scrim outside Menu or MenuItems such as (MenuItemRadio, MenuItem)
|
|
77
|
-
*/
|
|
78
|
-
const hide = React.useCallback(() => {
|
|
79
|
-
Animated.timing(opacityAnimation, {
|
|
80
|
-
toValue: 0,
|
|
81
|
-
duration: 250,
|
|
82
|
-
easing: EASING,
|
|
83
|
-
useNativeDriver: false,
|
|
84
|
-
}).start(() => {
|
|
85
|
-
// Reset state
|
|
86
|
-
setMenuState(AndroidMenuStates.Hidden);
|
|
87
|
-
setMenuSizeAnimation(new Animated.ValueXY({ x: 0, y: 0 }));
|
|
88
|
-
setOpacityAnimation(new Animated.Value(0));
|
|
89
|
-
});
|
|
90
|
-
}, [opacityAnimation]);
|
|
91
|
-
// Hook to maintain the state of the Menu for non controlled and controlled components.
|
|
92
|
-
const [open, shouldFocusOnContainer, setOpen] = useMenuOpenState(isOpenControlled, props, context.setOpen, hide, show);
|
|
93
|
-
/**
|
|
94
|
-
* Checks the value of the open props and show the menu accordingly
|
|
95
|
-
*/
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
if (props.open) {
|
|
98
|
-
show();
|
|
99
|
-
}
|
|
100
|
-
}, [props.open, show]);
|
|
101
|
-
/**
|
|
102
|
-
* onMenuLayout handles the start of the Animation when anchor is clicked
|
|
103
|
-
*/
|
|
104
|
-
const onMenuLayout = React.useCallback(
|
|
105
|
-
(e) => {
|
|
106
|
-
if (menuState === AndroidMenuStates.Animating) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const { width, height } = e.nativeEvent.layout;
|
|
110
|
-
setMenuHeight(height);
|
|
111
|
-
setMenuWidth(width);
|
|
112
|
-
setMenuState(AndroidMenuStates.Animating);
|
|
113
|
-
Animated.parallel([
|
|
114
|
-
Animated.timing(menuSizeAnimation, {
|
|
115
|
-
toValue: { x: width, y: height },
|
|
116
|
-
duration: 100,
|
|
117
|
-
easing: EASING,
|
|
118
|
-
useNativeDriver: false,
|
|
119
|
-
}),
|
|
120
|
-
Animated.timing(opacityAnimation, {
|
|
121
|
-
toValue: 1,
|
|
122
|
-
duration: 100,
|
|
123
|
-
easing: EASING,
|
|
124
|
-
useNativeDriver: false,
|
|
125
|
-
}),
|
|
126
|
-
]).start();
|
|
127
|
-
},
|
|
128
|
-
[menuSizeAnimation, menuState, opacityAnimation],
|
|
129
|
-
);
|
|
130
|
-
/**
|
|
131
|
-
* onRequestClose handles the closing of the Menu when the MenuItem or scrim or outside is clicked
|
|
132
|
-
*/
|
|
133
|
-
const onRequestClose = (e) => {
|
|
134
|
-
setOpen(e, false, false);
|
|
135
|
-
};
|
|
136
|
-
// Adjust position of menu - TODO: fix this warning removal, potentially adds extra re-renders
|
|
137
|
-
const transforms = [];
|
|
138
|
-
useMemo(() => {
|
|
139
19
|
/**
|
|
140
|
-
*
|
|
20
|
+
* State , Ref and Context Values for Menu Container and Anchor
|
|
21
|
+
*/
|
|
22
|
+
const triggerRef = React.useRef(null);
|
|
23
|
+
const context = useMenuContext();
|
|
24
|
+
const isSubmenu = context.triggerRef !== null;
|
|
25
|
+
const isOpenControlled = typeof props.open !== 'undefined';
|
|
26
|
+
const _container = useRef(null);
|
|
27
|
+
const [menuState, setMenuState] = React.useState(AndroidMenuStates.Hidden);
|
|
28
|
+
/**
|
|
29
|
+
* Call for useMenuCheckedState for identifying if any MenuItemCheckbox is checked or not
|
|
30
|
+
*/
|
|
31
|
+
const [checked, onCheckedChange] = useMenuCheckedState(props);
|
|
32
|
+
/**
|
|
33
|
+
* State Variables related to Height,Width and Position of the Menu Popover
|
|
34
|
+
*/
|
|
35
|
+
const [maxMenuHeight] = useState(250);
|
|
36
|
+
const [anchorWidth, setAnchorWidth] = React.useState(0);
|
|
37
|
+
const [left, setLeft] = React.useState(0);
|
|
38
|
+
const [menuHeight, setMenuHeight] = React.useState(0);
|
|
39
|
+
const [menuWidth, setMenuWidth] = React.useState(0);
|
|
40
|
+
const [top, setTop] = React.useState(0);
|
|
41
|
+
/**
|
|
42
|
+
* Animation value for the Menu popover show,hide and opacity values
|
|
141
43
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
44
|
+
const [menuSizeAnimation, setMenuSizeAnimation] = React.useState(new Animated.ValueXY({ x: 0, y: 0 }));
|
|
45
|
+
const [opacityAnimation, setOpacityAnimation] = React.useState(new Animated.Value(0));
|
|
46
|
+
/**
|
|
47
|
+
* RTL for the MenuItem needs to taken care as well.
|
|
48
|
+
*/
|
|
49
|
+
const { isRTL } = I18nManager;
|
|
50
|
+
/**
|
|
51
|
+
* Calcualations related to Menu Popver position and dimensions
|
|
52
|
+
*/
|
|
53
|
+
const dimensions = Dimensions.get('screen');
|
|
54
|
+
const { width: windowWidth } = dimensions;
|
|
55
|
+
const windowHeight = dimensions.height - (StatusBar.currentHeight || 0);
|
|
56
|
+
const menuSize = {
|
|
57
|
+
width: menuSizeAnimation.x,
|
|
58
|
+
height: menuSizeAnimation.y,
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* show function handles the opening of the Menu , it calcuates the position of the Anchor in the screen.
|
|
62
|
+
* It also sets the Anchor width and change the state of the Popover
|
|
63
|
+
*/ /**
|
|
64
|
+
* show function handles the opening of the Menu , it calcuates the position of the Anchor in the screen.
|
|
65
|
+
* It also sets the Anchor width and change the state of the Popover
|
|
66
|
+
*/
|
|
67
|
+
const show = React.useCallback(() => {
|
|
68
|
+
_container.current?.measureInWindow((left, top, buttonWidth, buttonHeight) => {
|
|
69
|
+
setAnchorWidth(buttonWidth);
|
|
70
|
+
setLeft(left);
|
|
71
|
+
setMenuState(AndroidMenuStates.Shown);
|
|
72
|
+
setTop(top + buttonHeight);
|
|
155
73
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
74
|
+
}, []);
|
|
75
|
+
/**
|
|
76
|
+
* hide function handles the hiding of the Menu when user clicks on the scrim outside Menu or MenuItems such as (MenuItemRadio, MenuItem)
|
|
77
|
+
*/
|
|
78
|
+
const hide = React.useCallback(() => {
|
|
79
|
+
Animated.timing(opacityAnimation, {
|
|
80
|
+
toValue: 0,
|
|
81
|
+
duration: 250,
|
|
82
|
+
easing: EASING,
|
|
83
|
+
useNativeDriver: false,
|
|
84
|
+
}).start(() => {
|
|
85
|
+
// Reset state
|
|
86
|
+
setMenuState(AndroidMenuStates.Hidden);
|
|
87
|
+
setMenuSizeAnimation(new Animated.ValueXY({ x: 0, y: 0 }));
|
|
88
|
+
setOpacityAnimation(new Animated.Value(0));
|
|
159
89
|
});
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
90
|
+
}, [opacityAnimation]);
|
|
91
|
+
// Hook to maintain the state of the Menu for non controlled and controlled components.
|
|
92
|
+
const [open, shouldFocusOnContainer, setOpen] = useMenuOpenState(isOpenControlled, props, context.setOpen, hide, show);
|
|
93
|
+
/**
|
|
94
|
+
* Checks the value of the open props and show the menu accordingly
|
|
95
|
+
*/
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (props.open) {
|
|
98
|
+
show();
|
|
99
|
+
}
|
|
100
|
+
}, [props.open, show]);
|
|
101
|
+
/**
|
|
102
|
+
* onMenuLayout handles the start of the Animation when anchor is clicked
|
|
103
|
+
*/
|
|
104
|
+
const onMenuLayout = React.useCallback((e) => {
|
|
105
|
+
if (menuState === AndroidMenuStates.Animating) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const { width, height } = e.nativeEvent.layout;
|
|
109
|
+
setMenuHeight(height);
|
|
110
|
+
setMenuWidth(width);
|
|
111
|
+
setMenuState(AndroidMenuStates.Animating);
|
|
112
|
+
Animated.parallel([
|
|
113
|
+
Animated.timing(menuSizeAnimation, {
|
|
114
|
+
toValue: { x: width, y: height },
|
|
115
|
+
duration: 100,
|
|
116
|
+
easing: EASING,
|
|
117
|
+
useNativeDriver: false,
|
|
118
|
+
}),
|
|
119
|
+
Animated.timing(opacityAnimation, {
|
|
120
|
+
toValue: 1,
|
|
121
|
+
duration: 100,
|
|
122
|
+
easing: EASING,
|
|
123
|
+
useNativeDriver: false,
|
|
124
|
+
}),
|
|
125
|
+
]).start();
|
|
126
|
+
}, [menuSizeAnimation, menuState, opacityAnimation]);
|
|
127
|
+
/**
|
|
128
|
+
* onRequestClose handles the closing of the Menu when the MenuItem or scrim or outside is clicked
|
|
129
|
+
*/
|
|
130
|
+
const onRequestClose = (e) => {
|
|
131
|
+
setOpen(e, false, false);
|
|
132
|
+
};
|
|
133
|
+
// Adjust position of menu - TODO: fix this warning removal, potentially adds extra re-renders
|
|
134
|
+
const transforms = [];
|
|
135
|
+
useMemo(() => {
|
|
136
|
+
/**
|
|
137
|
+
* If the Menu width and SCREEN_INDENT cross the screen width then the Menu will be adjusted to the oppostion left side of the screen
|
|
138
|
+
*/
|
|
139
|
+
if ((isRTL && left + anchorWidth - menuWidth > SCREEN_INDENT) || (!isRTL && left + menuWidth > windowWidth - SCREEN_INDENT)) {
|
|
140
|
+
transforms.push({
|
|
141
|
+
translateX: Animated.multiply(menuSizeAnimation.x, -1),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else if (left < SCREEN_INDENT) {
|
|
145
|
+
// Setting the left podition of the Menu if the left positon is less than screen indent
|
|
146
|
+
setLeft(SCREEN_INDENT);
|
|
147
|
+
}
|
|
148
|
+
// Flip by Y axis if menu hits bottom screen border
|
|
149
|
+
if (top + menuHeight + SCREEN_INDENT > windowHeight) {
|
|
150
|
+
if (menuHeight > maxMenuHeight) {
|
|
151
|
+
transforms.push({
|
|
152
|
+
translateY: Animated.multiply(menuSizeAnimation.y, -1),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
transforms.push({
|
|
157
|
+
translateY: Animated.multiply(menuSizeAnimation.y, -1),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (top < SCREEN_INDENT) {
|
|
162
|
+
setTop(SCREEN_INDENT);
|
|
163
|
+
}
|
|
164
|
+
}, [
|
|
165
|
+
anchorWidth,
|
|
166
|
+
isRTL,
|
|
167
|
+
left,
|
|
168
|
+
maxMenuHeight,
|
|
169
|
+
menuHeight,
|
|
170
|
+
menuSizeAnimation.x,
|
|
171
|
+
menuSizeAnimation.y,
|
|
172
|
+
menuWidth,
|
|
173
|
+
top,
|
|
174
|
+
transforms,
|
|
175
|
+
windowHeight,
|
|
176
|
+
windowWidth,
|
|
177
|
+
]);
|
|
178
|
+
/**
|
|
179
|
+
* Styles to be applied on the Modal Popover Animated.View
|
|
180
|
+
*/
|
|
181
|
+
const shadowMenuContainerStyle = useMemo(() => {
|
|
182
|
+
return {
|
|
183
|
+
opacity: opacityAnimation,
|
|
184
|
+
transform: transforms,
|
|
185
|
+
top,
|
|
186
|
+
// Switch left to right for rtl devices
|
|
187
|
+
...(isRTL ? { right: left } : { left }),
|
|
188
|
+
};
|
|
189
|
+
}, [isRTL, left, opacityAnimation, top, transforms]);
|
|
190
|
+
/**
|
|
191
|
+
* handles the state when menu is opening or closing with Animation
|
|
192
|
+
*/
|
|
193
|
+
const animationStarted = menuState === AndroidMenuStates.Animating;
|
|
194
|
+
const { testID } = props;
|
|
195
|
+
// Default behavior for submenu is to open on hover
|
|
196
|
+
// the ...props line below will override this behavior for a submenu
|
|
197
|
+
// or apply openOnHover if passed into a root Menu.
|
|
198
|
+
const openOnHover = isSubmenu;
|
|
199
|
+
// We need to be able to cancel the timer that gets set on
|
|
200
|
+
// hover out of the parent popover if the parent popover
|
|
201
|
+
// is also set to open/close on hover out. Otherwise
|
|
202
|
+
// the parent menu will close when the timeout passes.
|
|
203
|
+
const parentPopoverHoverOutTimer = isSubmenu ? context.popoverHoverOutTimer : undefined;
|
|
182
204
|
return {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
205
|
+
openOnHover,
|
|
206
|
+
...props,
|
|
207
|
+
open,
|
|
208
|
+
setOpen,
|
|
209
|
+
shouldFocusOnContainer,
|
|
210
|
+
triggerRef,
|
|
211
|
+
isSubmenu,
|
|
212
|
+
isControlled: isOpenControlled,
|
|
213
|
+
parentPopoverHoverOutTimer,
|
|
214
|
+
setAnchorWidth,
|
|
215
|
+
shadowMenuContainerStyle,
|
|
216
|
+
_container,
|
|
217
|
+
onRequestClose,
|
|
218
|
+
onMenuLayout,
|
|
219
|
+
checked,
|
|
220
|
+
onCheckedChange,
|
|
221
|
+
menuHeight,
|
|
222
|
+
maxMenuHeight,
|
|
223
|
+
animationStarted,
|
|
224
|
+
menuSize,
|
|
225
|
+
testID,
|
|
188
226
|
};
|
|
189
|
-
}, [isRTL, left, opacityAnimation, top, transforms]);
|
|
190
|
-
/**
|
|
191
|
-
* handles the state when menu is opening or closing with Animation
|
|
192
|
-
*/
|
|
193
|
-
const animationStarted = menuState === AndroidMenuStates.Animating;
|
|
194
|
-
const { testID } = props;
|
|
195
|
-
// Default behavior for submenu is to open on hover
|
|
196
|
-
// the ...props line below will override this behavior for a submenu
|
|
197
|
-
// or apply openOnHover if passed into a root Menu.
|
|
198
|
-
const openOnHover = isSubmenu;
|
|
199
|
-
// We need to be able to cancel the timer that gets set on
|
|
200
|
-
// hover out of the parent popover if the parent popover
|
|
201
|
-
// is also set to open/close on hover out. Otherwise
|
|
202
|
-
// the parent menu will close when the timeout passes.
|
|
203
|
-
const parentPopoverHoverOutTimer = isSubmenu ? context.popoverHoverOutTimer : undefined;
|
|
204
|
-
return {
|
|
205
|
-
openOnHover,
|
|
206
|
-
...props,
|
|
207
|
-
open,
|
|
208
|
-
setOpen,
|
|
209
|
-
shouldFocusOnContainer,
|
|
210
|
-
triggerRef,
|
|
211
|
-
isSubmenu,
|
|
212
|
-
isControlled: isOpenControlled,
|
|
213
|
-
parentPopoverHoverOutTimer,
|
|
214
|
-
setAnchorWidth,
|
|
215
|
-
shadowMenuContainerStyle,
|
|
216
|
-
_container,
|
|
217
|
-
onRequestClose,
|
|
218
|
-
onMenuLayout,
|
|
219
|
-
checked,
|
|
220
|
-
onCheckedChange,
|
|
221
|
-
menuHeight,
|
|
222
|
-
maxMenuHeight,
|
|
223
|
-
animationStarted,
|
|
224
|
-
menuSize,
|
|
225
|
-
testID,
|
|
226
|
-
};
|
|
227
227
|
};
|
|
228
228
|
/**
|
|
229
229
|
* useMenuOpenState handles the open and closing of the Menu based on the click
|
|
@@ -231,58 +231,52 @@ export const useMenu = (props) => {
|
|
|
231
231
|
*
|
|
232
232
|
*/
|
|
233
233
|
const useMenuOpenState = (isControlled, props, parentSetOpen, hide, show) => {
|
|
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
|
-
[state, onOpenChange, parentSetOpen, show, hide],
|
|
266
|
-
);
|
|
267
|
-
return [state, shouldFocusOnContainer, setOpen];
|
|
234
|
+
const { defaultOpen, onOpenChange, open } = props;
|
|
235
|
+
const initialState = typeof defaultOpen !== 'undefined' ? defaultOpen : !!open;
|
|
236
|
+
const [openInternal, setOpenInternal] = React.useState(initialState);
|
|
237
|
+
const [shouldFocusOnContainer, setShouldFocusOnContainer] = React.useState(undefined);
|
|
238
|
+
const state = isControlled ? open : openInternal;
|
|
239
|
+
const lastCloseTimestampRef = React.useRef(-1);
|
|
240
|
+
/**
|
|
241
|
+
* setOpen handles the open of the Menu and setting focus on the Popover container
|
|
242
|
+
*/
|
|
243
|
+
const setOpen = React.useCallback((e, isOpen, bubble) => {
|
|
244
|
+
const openPrev = state;
|
|
245
|
+
if (!isControlled && (!isOpen || lastCloseTimestampRef.current + delayOpen <= Date.now())) {
|
|
246
|
+
setOpenInternal(isOpen);
|
|
247
|
+
}
|
|
248
|
+
if (isOpen) {
|
|
249
|
+
show();
|
|
250
|
+
setShouldFocusOnContainer(true);
|
|
251
|
+
}
|
|
252
|
+
if (!isOpen) {
|
|
253
|
+
setShouldFocusOnContainer(undefined);
|
|
254
|
+
lastCloseTimestampRef.current = Date.now();
|
|
255
|
+
hide();
|
|
256
|
+
}
|
|
257
|
+
if (onOpenChange && openPrev !== isOpen) {
|
|
258
|
+
onOpenChange(e, isOpen);
|
|
259
|
+
}
|
|
260
|
+
if (bubble && parentSetOpen && !isControlled) {
|
|
261
|
+
parentSetOpen(e, isOpen, bubble);
|
|
262
|
+
}
|
|
263
|
+
}, [state, onOpenChange, parentSetOpen, show, hide]);
|
|
264
|
+
return [state, shouldFocusOnContainer, setOpen];
|
|
268
265
|
};
|
|
269
266
|
/**
|
|
270
267
|
* Call for useMenuCheckedState for identifying if any MenuItemCheckbox is checked or not
|
|
271
268
|
*/
|
|
272
269
|
const useMenuCheckedState = (props) => {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
[isControlled, setCheckedInternal, onCheckedChangeOriginal],
|
|
285
|
-
);
|
|
286
|
-
return [state, onCheckedChange];
|
|
270
|
+
const { checked, defaultChecked, onCheckedChange: onCheckedChangeOriginal } = props;
|
|
271
|
+
const [checkedInternal, setCheckedInternal] = React.useState(defaultChecked ?? checked ?? []);
|
|
272
|
+
const isControlled = typeof checked !== 'undefined';
|
|
273
|
+
const state = isControlled ? checked : checkedInternal;
|
|
274
|
+
const onCheckedChange = React.useCallback((e, checked) => {
|
|
275
|
+
if (!isControlled) {
|
|
276
|
+
setCheckedInternal(checked);
|
|
277
|
+
}
|
|
278
|
+
onCheckedChangeOriginal?.(e, checked);
|
|
279
|
+
}, [isControlled, setCheckedInternal, onCheckedChangeOriginal]);
|
|
280
|
+
return [state, onCheckedChange];
|
|
287
281
|
};
|
|
288
|
-
//# sourceMappingURL=useMenu.android.js.map
|
|
282
|
+
//# sourceMappingURL=useMenu.android.js.map
|
package/lib/Menu/useMenu.d.ts
CHANGED