@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
|
@@ -1,60 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
(Object.create
|
|
25
|
-
? function (o, v) {
|
|
26
|
-
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
27
|
-
}
|
|
28
|
-
: function (o, v) {
|
|
29
|
-
o['default'] = v;
|
|
30
|
-
});
|
|
31
|
-
var __importStar =
|
|
32
|
-
(this && this.__importStar) ||
|
|
33
|
-
(function () {
|
|
34
|
-
var ownKeys = function (o) {
|
|
35
|
-
ownKeys =
|
|
36
|
-
Object.getOwnPropertyNames ||
|
|
37
|
-
function (o) {
|
|
38
|
-
var ar = [];
|
|
39
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
40
|
-
return ar;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
41
24
|
};
|
|
42
|
-
|
|
25
|
+
return ownKeys(o);
|
|
43
26
|
};
|
|
44
27
|
return function (mod) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
50
33
|
};
|
|
51
|
-
|
|
52
|
-
Object.defineProperty(exports,
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
36
|
exports.useMenu = void 0;
|
|
54
|
-
const react_1 = __importStar(require(
|
|
55
|
-
const react_native_1 = require(
|
|
56
|
-
const Menu_types_1 = require(
|
|
57
|
-
const menuContext_1 = require(
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const react_native_1 = require("react-native");
|
|
39
|
+
const Menu_types_1 = require("./Menu.types");
|
|
40
|
+
const menuContext_1 = require("../context/menuContext");
|
|
58
41
|
// Due to how events get fired we get double notifications
|
|
59
42
|
// for the same event causing us to immediately reopen
|
|
60
43
|
// a menu when we close it. Adding in a delay to prevent
|
|
@@ -69,214 +52,214 @@ const EASING = react_native_1.Easing.bezier(0.4, 0, 0.2, 1);
|
|
|
69
52
|
// Screen indent is the fixed value according to Android guidelines which depicts the minimum distance from screen edge Menu should have
|
|
70
53
|
const SCREEN_INDENT = 16;
|
|
71
54
|
const useMenu = (props) => {
|
|
72
|
-
/**
|
|
73
|
-
* State , Ref and Context Values for Menu Container and Anchor
|
|
74
|
-
*/
|
|
75
|
-
const triggerRef = react_1.default.useRef(null);
|
|
76
|
-
const context = (0, menuContext_1.useMenuContext)();
|
|
77
|
-
const isSubmenu = context.triggerRef !== null;
|
|
78
|
-
const isOpenControlled = typeof props.open !== 'undefined';
|
|
79
|
-
const _container = (0, react_1.useRef)(null);
|
|
80
|
-
const [menuState, setMenuState] = react_1.default.useState(Menu_types_1.AndroidMenuStates.Hidden);
|
|
81
|
-
/**
|
|
82
|
-
* Call for useMenuCheckedState for identifying if any MenuItemCheckbox is checked or not
|
|
83
|
-
*/
|
|
84
|
-
const [checked, onCheckedChange] = useMenuCheckedState(props);
|
|
85
|
-
/**
|
|
86
|
-
* State Variables related to Height,Width and Position of the Menu Popover
|
|
87
|
-
*/
|
|
88
|
-
const [maxMenuHeight] = (0, react_1.useState)(250);
|
|
89
|
-
const [anchorWidth, setAnchorWidth] = react_1.default.useState(0);
|
|
90
|
-
const [left, setLeft] = react_1.default.useState(0);
|
|
91
|
-
const [menuHeight, setMenuHeight] = react_1.default.useState(0);
|
|
92
|
-
const [menuWidth, setMenuWidth] = react_1.default.useState(0);
|
|
93
|
-
const [top, setTop] = react_1.default.useState(0);
|
|
94
|
-
/**
|
|
95
|
-
* Animation value for the Menu popover show,hide and opacity values
|
|
96
|
-
*/
|
|
97
|
-
const [menuSizeAnimation, setMenuSizeAnimation] = react_1.default.useState(new react_native_1.Animated.ValueXY({ x: 0, y: 0 }));
|
|
98
|
-
const [opacityAnimation, setOpacityAnimation] = react_1.default.useState(new react_native_1.Animated.Value(0));
|
|
99
|
-
/**
|
|
100
|
-
* RTL for the MenuItem needs to taken care as well.
|
|
101
|
-
*/
|
|
102
|
-
const { isRTL } = react_native_1.I18nManager;
|
|
103
|
-
/**
|
|
104
|
-
* Calcualations related to Menu Popver position and dimensions
|
|
105
|
-
*/
|
|
106
|
-
const dimensions = react_native_1.Dimensions.get('screen');
|
|
107
|
-
const { width: windowWidth } = dimensions;
|
|
108
|
-
const windowHeight = dimensions.height - (react_native_1.StatusBar.currentHeight || 0);
|
|
109
|
-
const menuSize = {
|
|
110
|
-
width: menuSizeAnimation.x,
|
|
111
|
-
height: menuSizeAnimation.y,
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* show function handles the opening of the Menu , it calcuates the position of the Anchor in the screen.
|
|
115
|
-
* It also sets the Anchor width and change the state of the Popover
|
|
116
|
-
*/ /**
|
|
117
|
-
* show function handles the opening of the Menu , it calcuates the position of the Anchor in the screen.
|
|
118
|
-
* It also sets the Anchor width and change the state of the Popover
|
|
119
|
-
*/
|
|
120
|
-
const show = react_1.default.useCallback(() => {
|
|
121
|
-
_container.current?.measureInWindow((left, top, buttonWidth, buttonHeight) => {
|
|
122
|
-
setAnchorWidth(buttonWidth);
|
|
123
|
-
setLeft(left);
|
|
124
|
-
setMenuState(Menu_types_1.AndroidMenuStates.Shown);
|
|
125
|
-
setTop(top + buttonHeight);
|
|
126
|
-
});
|
|
127
|
-
}, []);
|
|
128
|
-
/**
|
|
129
|
-
* hide function handles the hiding of the Menu when user clicks on the scrim outside Menu or MenuItems such as (MenuItemRadio, MenuItem)
|
|
130
|
-
*/
|
|
131
|
-
const hide = react_1.default.useCallback(() => {
|
|
132
|
-
react_native_1.Animated.timing(opacityAnimation, {
|
|
133
|
-
toValue: 0,
|
|
134
|
-
duration: 250,
|
|
135
|
-
easing: EASING,
|
|
136
|
-
useNativeDriver: false,
|
|
137
|
-
}).start(() => {
|
|
138
|
-
// Reset state
|
|
139
|
-
setMenuState(Menu_types_1.AndroidMenuStates.Hidden);
|
|
140
|
-
setMenuSizeAnimation(new react_native_1.Animated.ValueXY({ x: 0, y: 0 }));
|
|
141
|
-
setOpacityAnimation(new react_native_1.Animated.Value(0));
|
|
142
|
-
});
|
|
143
|
-
}, [opacityAnimation]);
|
|
144
|
-
// Hook to maintain the state of the Menu for non controlled and controlled components.
|
|
145
|
-
const [open, shouldFocusOnContainer, setOpen] = useMenuOpenState(isOpenControlled, props, context.setOpen, hide, show);
|
|
146
|
-
/**
|
|
147
|
-
* Checks the value of the open props and show the menu accordingly
|
|
148
|
-
*/
|
|
149
|
-
(0, react_1.useEffect)(() => {
|
|
150
|
-
if (props.open) {
|
|
151
|
-
show();
|
|
152
|
-
}
|
|
153
|
-
}, [props.open, show]);
|
|
154
|
-
/**
|
|
155
|
-
* onMenuLayout handles the start of the Animation when anchor is clicked
|
|
156
|
-
*/
|
|
157
|
-
const onMenuLayout = react_1.default.useCallback(
|
|
158
|
-
(e) => {
|
|
159
|
-
if (menuState === Menu_types_1.AndroidMenuStates.Animating) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
const { width, height } = e.nativeEvent.layout;
|
|
163
|
-
setMenuHeight(height);
|
|
164
|
-
setMenuWidth(width);
|
|
165
|
-
setMenuState(Menu_types_1.AndroidMenuStates.Animating);
|
|
166
|
-
react_native_1.Animated.parallel([
|
|
167
|
-
react_native_1.Animated.timing(menuSizeAnimation, {
|
|
168
|
-
toValue: { x: width, y: height },
|
|
169
|
-
duration: 100,
|
|
170
|
-
easing: EASING,
|
|
171
|
-
useNativeDriver: false,
|
|
172
|
-
}),
|
|
173
|
-
react_native_1.Animated.timing(opacityAnimation, {
|
|
174
|
-
toValue: 1,
|
|
175
|
-
duration: 100,
|
|
176
|
-
easing: EASING,
|
|
177
|
-
useNativeDriver: false,
|
|
178
|
-
}),
|
|
179
|
-
]).start();
|
|
180
|
-
},
|
|
181
|
-
[menuSizeAnimation, menuState, opacityAnimation],
|
|
182
|
-
);
|
|
183
|
-
/**
|
|
184
|
-
* onRequestClose handles the closing of the Menu when the MenuItem or scrim or outside is clicked
|
|
185
|
-
*/
|
|
186
|
-
const onRequestClose = (e) => {
|
|
187
|
-
setOpen(e, false, false);
|
|
188
|
-
};
|
|
189
|
-
// Adjust position of menu - TODO: fix this warning removal, potentially adds extra re-renders
|
|
190
|
-
const transforms = [];
|
|
191
|
-
(0, react_1.useMemo)(() => {
|
|
192
55
|
/**
|
|
193
|
-
*
|
|
56
|
+
* State , Ref and Context Values for Menu Container and Anchor
|
|
194
57
|
*/
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
58
|
+
const triggerRef = react_1.default.useRef(null);
|
|
59
|
+
const context = (0, menuContext_1.useMenuContext)();
|
|
60
|
+
const isSubmenu = context.triggerRef !== null;
|
|
61
|
+
const isOpenControlled = typeof props.open !== 'undefined';
|
|
62
|
+
const _container = (0, react_1.useRef)(null);
|
|
63
|
+
const [menuState, setMenuState] = react_1.default.useState(Menu_types_1.AndroidMenuStates.Hidden);
|
|
64
|
+
/**
|
|
65
|
+
* Call for useMenuCheckedState for identifying if any MenuItemCheckbox is checked or not
|
|
66
|
+
*/
|
|
67
|
+
const [checked, onCheckedChange] = useMenuCheckedState(props);
|
|
68
|
+
/**
|
|
69
|
+
* State Variables related to Height,Width and Position of the Menu Popover
|
|
70
|
+
*/
|
|
71
|
+
const [maxMenuHeight] = (0, react_1.useState)(250);
|
|
72
|
+
const [anchorWidth, setAnchorWidth] = react_1.default.useState(0);
|
|
73
|
+
const [left, setLeft] = react_1.default.useState(0);
|
|
74
|
+
const [menuHeight, setMenuHeight] = react_1.default.useState(0);
|
|
75
|
+
const [menuWidth, setMenuWidth] = react_1.default.useState(0);
|
|
76
|
+
const [top, setTop] = react_1.default.useState(0);
|
|
77
|
+
/**
|
|
78
|
+
* Animation value for the Menu popover show,hide and opacity values
|
|
79
|
+
*/
|
|
80
|
+
const [menuSizeAnimation, setMenuSizeAnimation] = react_1.default.useState(new react_native_1.Animated.ValueXY({ x: 0, y: 0 }));
|
|
81
|
+
const [opacityAnimation, setOpacityAnimation] = react_1.default.useState(new react_native_1.Animated.Value(0));
|
|
82
|
+
/**
|
|
83
|
+
* RTL for the MenuItem needs to taken care as well.
|
|
84
|
+
*/
|
|
85
|
+
const { isRTL } = react_native_1.I18nManager;
|
|
86
|
+
/**
|
|
87
|
+
* Calcualations related to Menu Popver position and dimensions
|
|
88
|
+
*/
|
|
89
|
+
const dimensions = react_native_1.Dimensions.get('screen');
|
|
90
|
+
const { width: windowWidth } = dimensions;
|
|
91
|
+
const windowHeight = dimensions.height - (react_native_1.StatusBar.currentHeight || 0);
|
|
92
|
+
const menuSize = {
|
|
93
|
+
width: menuSizeAnimation.x,
|
|
94
|
+
height: menuSizeAnimation.y,
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* show function handles the opening of the Menu , it calcuates the position of the Anchor in the screen.
|
|
98
|
+
* It also sets the Anchor width and change the state of the Popover
|
|
99
|
+
*/ /**
|
|
100
|
+
* show function handles the opening of the Menu , it calcuates the position of the Anchor in the screen.
|
|
101
|
+
* It also sets the Anchor width and change the state of the Popover
|
|
102
|
+
*/
|
|
103
|
+
const show = react_1.default.useCallback(() => {
|
|
104
|
+
_container.current?.measureInWindow((left, top, buttonWidth, buttonHeight) => {
|
|
105
|
+
setAnchorWidth(buttonWidth);
|
|
106
|
+
setLeft(left);
|
|
107
|
+
setMenuState(Menu_types_1.AndroidMenuStates.Shown);
|
|
108
|
+
setTop(top + buttonHeight);
|
|
208
109
|
});
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
110
|
+
}, []);
|
|
111
|
+
/**
|
|
112
|
+
* hide function handles the hiding of the Menu when user clicks on the scrim outside Menu or MenuItems such as (MenuItemRadio, MenuItem)
|
|
113
|
+
*/
|
|
114
|
+
const hide = react_1.default.useCallback(() => {
|
|
115
|
+
react_native_1.Animated.timing(opacityAnimation, {
|
|
116
|
+
toValue: 0,
|
|
117
|
+
duration: 250,
|
|
118
|
+
easing: EASING,
|
|
119
|
+
useNativeDriver: false,
|
|
120
|
+
}).start(() => {
|
|
121
|
+
// Reset state
|
|
122
|
+
setMenuState(Menu_types_1.AndroidMenuStates.Hidden);
|
|
123
|
+
setMenuSizeAnimation(new react_native_1.Animated.ValueXY({ x: 0, y: 0 }));
|
|
124
|
+
setOpacityAnimation(new react_native_1.Animated.Value(0));
|
|
212
125
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
126
|
+
}, [opacityAnimation]);
|
|
127
|
+
// Hook to maintain the state of the Menu for non controlled and controlled components.
|
|
128
|
+
const [open, shouldFocusOnContainer, setOpen] = useMenuOpenState(isOpenControlled, props, context.setOpen, hide, show);
|
|
129
|
+
/**
|
|
130
|
+
* Checks the value of the open props and show the menu accordingly
|
|
131
|
+
*/
|
|
132
|
+
(0, react_1.useEffect)(() => {
|
|
133
|
+
if (props.open) {
|
|
134
|
+
show();
|
|
135
|
+
}
|
|
136
|
+
}, [props.open, show]);
|
|
137
|
+
/**
|
|
138
|
+
* onMenuLayout handles the start of the Animation when anchor is clicked
|
|
139
|
+
*/
|
|
140
|
+
const onMenuLayout = react_1.default.useCallback((e) => {
|
|
141
|
+
if (menuState === Menu_types_1.AndroidMenuStates.Animating) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const { width, height } = e.nativeEvent.layout;
|
|
145
|
+
setMenuHeight(height);
|
|
146
|
+
setMenuWidth(width);
|
|
147
|
+
setMenuState(Menu_types_1.AndroidMenuStates.Animating);
|
|
148
|
+
react_native_1.Animated.parallel([
|
|
149
|
+
react_native_1.Animated.timing(menuSizeAnimation, {
|
|
150
|
+
toValue: { x: width, y: height },
|
|
151
|
+
duration: 100,
|
|
152
|
+
easing: EASING,
|
|
153
|
+
useNativeDriver: false,
|
|
154
|
+
}),
|
|
155
|
+
react_native_1.Animated.timing(opacityAnimation, {
|
|
156
|
+
toValue: 1,
|
|
157
|
+
duration: 100,
|
|
158
|
+
easing: EASING,
|
|
159
|
+
useNativeDriver: false,
|
|
160
|
+
}),
|
|
161
|
+
]).start();
|
|
162
|
+
}, [menuSizeAnimation, menuState, opacityAnimation]);
|
|
163
|
+
/**
|
|
164
|
+
* onRequestClose handles the closing of the Menu when the MenuItem or scrim or outside is clicked
|
|
165
|
+
*/
|
|
166
|
+
const onRequestClose = (e) => {
|
|
167
|
+
setOpen(e, false, false);
|
|
168
|
+
};
|
|
169
|
+
// Adjust position of menu - TODO: fix this warning removal, potentially adds extra re-renders
|
|
170
|
+
const transforms = [];
|
|
171
|
+
(0, react_1.useMemo)(() => {
|
|
172
|
+
/**
|
|
173
|
+
* 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
|
|
174
|
+
*/
|
|
175
|
+
if ((isRTL && left + anchorWidth - menuWidth > SCREEN_INDENT) || (!isRTL && left + menuWidth > windowWidth - SCREEN_INDENT)) {
|
|
176
|
+
transforms.push({
|
|
177
|
+
translateX: react_native_1.Animated.multiply(menuSizeAnimation.x, -1),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
else if (left < SCREEN_INDENT) {
|
|
181
|
+
// Setting the left podition of the Menu if the left positon is less than screen indent
|
|
182
|
+
setLeft(SCREEN_INDENT);
|
|
183
|
+
}
|
|
184
|
+
// Flip by Y axis if menu hits bottom screen border
|
|
185
|
+
if (top + menuHeight + SCREEN_INDENT > windowHeight) {
|
|
186
|
+
if (menuHeight > maxMenuHeight) {
|
|
187
|
+
transforms.push({
|
|
188
|
+
translateY: react_native_1.Animated.multiply(menuSizeAnimation.y, -1),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
transforms.push({
|
|
193
|
+
translateY: react_native_1.Animated.multiply(menuSizeAnimation.y, -1),
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if (top < SCREEN_INDENT) {
|
|
198
|
+
setTop(SCREEN_INDENT);
|
|
199
|
+
}
|
|
200
|
+
}, [
|
|
201
|
+
anchorWidth,
|
|
202
|
+
isRTL,
|
|
203
|
+
left,
|
|
204
|
+
maxMenuHeight,
|
|
205
|
+
menuHeight,
|
|
206
|
+
menuSizeAnimation.x,
|
|
207
|
+
menuSizeAnimation.y,
|
|
208
|
+
menuWidth,
|
|
209
|
+
top,
|
|
210
|
+
transforms,
|
|
211
|
+
windowHeight,
|
|
212
|
+
windowWidth,
|
|
213
|
+
]);
|
|
214
|
+
/**
|
|
215
|
+
* Styles to be applied on the Modal Popover Animated.View
|
|
216
|
+
*/
|
|
217
|
+
const shadowMenuContainerStyle = (0, react_1.useMemo)(() => {
|
|
218
|
+
return {
|
|
219
|
+
opacity: opacityAnimation,
|
|
220
|
+
transform: transforms,
|
|
221
|
+
top,
|
|
222
|
+
// Switch left to right for rtl devices
|
|
223
|
+
...(isRTL ? { right: left } : { left }),
|
|
224
|
+
};
|
|
225
|
+
}, [isRTL, left, opacityAnimation, top, transforms]);
|
|
226
|
+
/**
|
|
227
|
+
* handles the state when menu is opening or closing with Animation
|
|
228
|
+
*/
|
|
229
|
+
const animationStarted = menuState === Menu_types_1.AndroidMenuStates.Animating;
|
|
230
|
+
const { testID } = props;
|
|
231
|
+
// Default behavior for submenu is to open on hover
|
|
232
|
+
// the ...props line below will override this behavior for a submenu
|
|
233
|
+
// or apply openOnHover if passed into a root Menu.
|
|
234
|
+
const openOnHover = isSubmenu;
|
|
235
|
+
// We need to be able to cancel the timer that gets set on
|
|
236
|
+
// hover out of the parent popover if the parent popover
|
|
237
|
+
// is also set to open/close on hover out. Otherwise
|
|
238
|
+
// the parent menu will close when the timeout passes.
|
|
239
|
+
const parentPopoverHoverOutTimer = isSubmenu ? context.popoverHoverOutTimer : undefined;
|
|
235
240
|
return {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
+
openOnHover,
|
|
242
|
+
...props,
|
|
243
|
+
open,
|
|
244
|
+
setOpen,
|
|
245
|
+
shouldFocusOnContainer,
|
|
246
|
+
triggerRef,
|
|
247
|
+
isSubmenu,
|
|
248
|
+
isControlled: isOpenControlled,
|
|
249
|
+
parentPopoverHoverOutTimer,
|
|
250
|
+
setAnchorWidth,
|
|
251
|
+
shadowMenuContainerStyle,
|
|
252
|
+
_container,
|
|
253
|
+
onRequestClose,
|
|
254
|
+
onMenuLayout,
|
|
255
|
+
checked,
|
|
256
|
+
onCheckedChange,
|
|
257
|
+
menuHeight,
|
|
258
|
+
maxMenuHeight,
|
|
259
|
+
animationStarted,
|
|
260
|
+
menuSize,
|
|
261
|
+
testID,
|
|
241
262
|
};
|
|
242
|
-
}, [isRTL, left, opacityAnimation, top, transforms]);
|
|
243
|
-
/**
|
|
244
|
-
* handles the state when menu is opening or closing with Animation
|
|
245
|
-
*/
|
|
246
|
-
const animationStarted = menuState === Menu_types_1.AndroidMenuStates.Animating;
|
|
247
|
-
const { testID } = props;
|
|
248
|
-
// Default behavior for submenu is to open on hover
|
|
249
|
-
// the ...props line below will override this behavior for a submenu
|
|
250
|
-
// or apply openOnHover if passed into a root Menu.
|
|
251
|
-
const openOnHover = isSubmenu;
|
|
252
|
-
// We need to be able to cancel the timer that gets set on
|
|
253
|
-
// hover out of the parent popover if the parent popover
|
|
254
|
-
// is also set to open/close on hover out. Otherwise
|
|
255
|
-
// the parent menu will close when the timeout passes.
|
|
256
|
-
const parentPopoverHoverOutTimer = isSubmenu ? context.popoverHoverOutTimer : undefined;
|
|
257
|
-
return {
|
|
258
|
-
openOnHover,
|
|
259
|
-
...props,
|
|
260
|
-
open,
|
|
261
|
-
setOpen,
|
|
262
|
-
shouldFocusOnContainer,
|
|
263
|
-
triggerRef,
|
|
264
|
-
isSubmenu,
|
|
265
|
-
isControlled: isOpenControlled,
|
|
266
|
-
parentPopoverHoverOutTimer,
|
|
267
|
-
setAnchorWidth,
|
|
268
|
-
shadowMenuContainerStyle,
|
|
269
|
-
_container,
|
|
270
|
-
onRequestClose,
|
|
271
|
-
onMenuLayout,
|
|
272
|
-
checked,
|
|
273
|
-
onCheckedChange,
|
|
274
|
-
menuHeight,
|
|
275
|
-
maxMenuHeight,
|
|
276
|
-
animationStarted,
|
|
277
|
-
menuSize,
|
|
278
|
-
testID,
|
|
279
|
-
};
|
|
280
263
|
};
|
|
281
264
|
exports.useMenu = useMenu;
|
|
282
265
|
/**
|
|
@@ -285,58 +268,52 @@ exports.useMenu = useMenu;
|
|
|
285
268
|
*
|
|
286
269
|
*/
|
|
287
270
|
const useMenuOpenState = (isControlled, props, parentSetOpen, hide, show) => {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
[state, onOpenChange, parentSetOpen, show, hide],
|
|
320
|
-
);
|
|
321
|
-
return [state, shouldFocusOnContainer, setOpen];
|
|
271
|
+
const { defaultOpen, onOpenChange, open } = props;
|
|
272
|
+
const initialState = typeof defaultOpen !== 'undefined' ? defaultOpen : !!open;
|
|
273
|
+
const [openInternal, setOpenInternal] = react_1.default.useState(initialState);
|
|
274
|
+
const [shouldFocusOnContainer, setShouldFocusOnContainer] = react_1.default.useState(undefined);
|
|
275
|
+
const state = isControlled ? open : openInternal;
|
|
276
|
+
const lastCloseTimestampRef = react_1.default.useRef(-1);
|
|
277
|
+
/**
|
|
278
|
+
* setOpen handles the open of the Menu and setting focus on the Popover container
|
|
279
|
+
*/
|
|
280
|
+
const setOpen = react_1.default.useCallback((e, isOpen, bubble) => {
|
|
281
|
+
const openPrev = state;
|
|
282
|
+
if (!isControlled && (!isOpen || lastCloseTimestampRef.current + delayOpen <= Date.now())) {
|
|
283
|
+
setOpenInternal(isOpen);
|
|
284
|
+
}
|
|
285
|
+
if (isOpen) {
|
|
286
|
+
show();
|
|
287
|
+
setShouldFocusOnContainer(true);
|
|
288
|
+
}
|
|
289
|
+
if (!isOpen) {
|
|
290
|
+
setShouldFocusOnContainer(undefined);
|
|
291
|
+
lastCloseTimestampRef.current = Date.now();
|
|
292
|
+
hide();
|
|
293
|
+
}
|
|
294
|
+
if (onOpenChange && openPrev !== isOpen) {
|
|
295
|
+
onOpenChange(e, isOpen);
|
|
296
|
+
}
|
|
297
|
+
if (bubble && parentSetOpen && !isControlled) {
|
|
298
|
+
parentSetOpen(e, isOpen, bubble);
|
|
299
|
+
}
|
|
300
|
+
}, [state, onOpenChange, parentSetOpen, show, hide]);
|
|
301
|
+
return [state, shouldFocusOnContainer, setOpen];
|
|
322
302
|
};
|
|
323
303
|
/**
|
|
324
304
|
* Call for useMenuCheckedState for identifying if any MenuItemCheckbox is checked or not
|
|
325
305
|
*/
|
|
326
306
|
const useMenuCheckedState = (props) => {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
[isControlled, setCheckedInternal, onCheckedChangeOriginal],
|
|
339
|
-
);
|
|
340
|
-
return [state, onCheckedChange];
|
|
307
|
+
const { checked, defaultChecked, onCheckedChange: onCheckedChangeOriginal } = props;
|
|
308
|
+
const [checkedInternal, setCheckedInternal] = react_1.default.useState(defaultChecked ?? checked ?? []);
|
|
309
|
+
const isControlled = typeof checked !== 'undefined';
|
|
310
|
+
const state = isControlled ? checked : checkedInternal;
|
|
311
|
+
const onCheckedChange = react_1.default.useCallback((e, checked) => {
|
|
312
|
+
if (!isControlled) {
|
|
313
|
+
setCheckedInternal(checked);
|
|
314
|
+
}
|
|
315
|
+
onCheckedChangeOriginal?.(e, checked);
|
|
316
|
+
}, [isControlled, setCheckedInternal, onCheckedChangeOriginal]);
|
|
317
|
+
return [state, onCheckedChange];
|
|
341
318
|
};
|
|
342
|
-
//# sourceMappingURL=useMenu.android.js.map
|
|
319
|
+
//# sourceMappingURL=useMenu.android.js.map
|