Menu Button on macOS (Initial check in) (#827)

### Platforms Impacted
- [ ] iOS
- [x] macOS
- [ ] win32 (Office)
- [ ] windows
- [ ] android

### Description of changes

This change introduces macOS support for the MenuButton component. As it is, it only supports a limited subset of the component's features, and lacks customization. I would like to add this initial version so that we can integrate it downstream and get feedback from clients. I tried to make no changes to the win32 implementation so as to not break compatibility.

I elected to implement this as a native module rather than composed of a `Button` and `ContextualMenu` component because I had a lot of trouble standing up the `ContextualMenu` component on macOS. `ContextualMenu` depends on `Callout`, which is only implemented for win32 and has a win32 specific API. On macOS, contextualMenus are generally not hosted in the equivalent of a `Callout` anyway; they are their own objects altogether. 

Future followups can/wil include:
- Extending the functionality of this component to support more of the props available on win32
- Standing up `ContextualMenu` for macOS (new API and all), and then rewriting this component to actually be composed of `Button` and `ContextualMenu`. 
- Porting this component to the new compose framework, along with ContextualMenu.

**Supported props:**
- menuItems,
  -  title, 
  - tooltip, 
  - submenus, 
  - disabled,
  - onItemClick (only 1 subMenu level deep)
- content, 
- Icon (png only)
- disabled, 
- onItemClick

**Unsupported but next planned to be added**
- Layout (Right now the widht/height are hard coded. I looked into it and I'll probably need to implement a shadow view to get the proper layout).

### Verification

https://user-images.githubusercontent.com/6722175/127942675-2b912247-4044-4219-a84d-28cdb3be5daa.mov

### Pull request checklist

This PR has considered (when applicable):
- [ ] Automated Tests
- [ ] Documentation and examples
- [ ] Keyboard Accessibility
- [ ] Voiceover
- [ ] Internationalization and Right-to-left Layouts
This commit is contained in:
Saad Najmi 2021-08-03 19:43:59 -05:00 коммит произвёл GitHub
Родитель 5dcb6b838d
Коммит b3ba12a567
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 602 добавлений и 256 удалений

Просмотреть файл

@ -15,6 +15,7 @@ import { HOMEPAGE_SEPARATOR_BUTTON, SeparatorTest } from './TestComponents/Separ
import { HOMEPAGE_SVG_BUTTON, SvgTest } from './TestComponents/Svg';
import { HOMEPAGE_TEXT_BUTTON, TextTest } from './TestComponents/Text';
import { HOMEPAGE_THEME_BUTTON, ThemeTest } from './TestComponents/Theme';
import { HOMEPAGE_MENU_BUTTON, MenuButtonTest } from './TestComponents/MenuButton';
import { HOMEPAGE_TOKEN_BUTTON, TokenTest } from './TestComponents/Tokens';
export const tests: TestDescription[] = [
@ -43,6 +44,11 @@ export const tests: TestDescription[] = [
component: LinkTest,
testPage: HOMEPAGE_LINK_BUTTON,
},
{
name: 'MenuButton Test',
component: MenuButtonTest,
testPage: HOMEPAGE_MENU_BUTTON,
},
{
name: 'Native Button Test',
component: NativeButtonTest,

Просмотреть файл

@ -9,14 +9,14 @@ PODS:
- React-Core (= 0.63.4)
- React-jsi (= 0.63.4)
- ReactCommon/turbomodule/core (= 0.63.4)
- FluentUI-React-Native-Avatar (0.9.6):
- FluentUI-React-Native-Avatar (0.9.14):
- MicrosoftFluentUI (~> 0.2.2)
- MicrosoftFluentUI (~> 0.2.6)
- React
- FluentUI-React-Native-Button (0.6.8):
- FluentUI-React-Native-Button (0.6.16):
- MicrosoftFluentUI (~> 0.2.2)
- React
- FluentUI-React-Native-Date-Picker (0.2.1):
- FluentUI-React-Native-Date-Picker (0.2.2):
- MicrosoftFluentUI/Calendar_ios (~> 0.2.7)
- React
- Folly (2020.01.13.00):
@ -401,7 +401,7 @@ PODS:
- React-Core (= 0.63.4)
- React-cxxreact (= 0.63.4)
- React-jsi (= 0.63.4)
- ReactTestApp-DevSupport (0.6.12)
- ReactTestApp-DevSupport (0.7.1)
- ReactTestApp-Resources (1.0.0-dev)
- RNSVG (12.1.1):
- React
@ -530,9 +530,9 @@ SPEC CHECKSUMS:
DoubleConversion: cde416483dac037923206447da6e1454df403714
FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e
FluentUI-React-Native-Avatar: 63ff6d85a5ac741d5d3963457a1d717352a686d6
FluentUI-React-Native-Button: 9f6970b0f3461f181ae6e845c8f17af5b2f683b4
FluentUI-React-Native-Date-Picker: d83563ff5c59d8960220ed8f92d05d5ec625ca19
FluentUI-React-Native-Avatar: 7dd785b4410681d8496e8111ef0c29d9cc0165e5
FluentUI-React-Native-Button: a97bb75baa0e5856dd9b7d739fd9d88856ce35ad
FluentUI-React-Native-Date-Picker: 24155baa77ada9fd81252f6bde95ef616d5b355c
Folly: b73c3869541e86821df3c387eb0af5f65addfab4
glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
MicrosoftFluentUI: 6b3bfd52b232e9abc5cb228b9761a5f42869f4d3
@ -559,7 +559,7 @@ SPEC CHECKSUMS:
React-RCTText: 5c51df3f08cb9dedc6e790161195d12bac06101c
React-RCTVibration: ae4f914cfe8de7d4de95ae1ea6cc8f6315d73d9d
ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b
ReactTestApp-DevSupport: 6464c326eccaa285191eb394b2b18d0663e40e10
ReactTestApp-DevSupport: 058444bc8d4df209aabc6a5f54a73bfd9a114f94
ReactTestApp-Resources: 5950ae44720217c6778ff03fb1d906c8fb3ce483
RNSVG: 551acb6562324b1d52a4e0758f7ca0ec234e278f
SwiftLint: 0c645fdc6feed3e390c1701ab3cc669f88b42752

Просмотреть файл

@ -27,6 +27,7 @@ use_test_app! do |target|
pod 'FluentUI-React-Native-Button', :path => '../../../packages/experimental/NativeButton/FluentUIReactNativeButton.podspec'
pod 'FluentUI-React-Native-Avatar', :path => '../../../packages/experimental/Avatar/FluentUIReactNativeAvatar.podspec'
pod 'FluentUI-React-Native-FocusZone', :path => '../../../packages/components/FocusZone/FluentUIReactNativeFocusZone.podspec'
pod 'FluentUI-React-Native-MenuButton', :path => '../../../packages/components/MenuButton/FluentUIReactNativeMenuButton.podspec'
pod 'RNCPicker', :path => '../../../node_modules/@react-native-picker/picker'
pod 'RNSVG', :path => '../../../node_modules/react-native-svg'

Просмотреть файл

@ -1,83 +1,87 @@
PODS:
- boost-for-react-native (1.63.0)
- DoubleConversion (1.1.6)
- FBLazyVector (0.63.36)
- FBReactNativeSpec (0.63.36):
- FBLazyVector (0.63.37)
- FBReactNativeSpec (0.63.37):
- RCT-Folly (= 2020.01.13.00)
- RCTRequired (= 0.63.36)
- RCTTypeSafety (= 0.63.36)
- React-Core (= 0.63.36)
- React-jsi (= 0.63.36)
- ReactCommon/turbomodule/core (= 0.63.36)
- FluentUI-React-Native-Avatar (0.9.6):
- RCTRequired (= 0.63.37)
- RCTTypeSafety (= 0.63.37)
- React-Core (= 0.63.37)
- React-jsi (= 0.63.37)
- ReactCommon/turbomodule/core (= 0.63.37)
- FluentUI-React-Native-Avatar (0.9.15):
- MicrosoftFluentUI (~> 0.2.2)
- MicrosoftFluentUI (~> 0.2.6)
- React
- FluentUI-React-Native-Button (0.6.8):
- FluentUI-React-Native-Button (0.6.18):
- MicrosoftFluentUI (~> 0.2.2)
- React
- FluentUI-React-Native-FocusZone (0.6.0):
- FluentUI-React-Native-FocusZone (0.6.10):
- React
- FluentUI-React-Native-MenuButton (0.2.17):
- React
- glog (0.3.5)
- MicrosoftFluentUI (0.2.7):
- MicrosoftFluentUI/ActivityIndicator_ios (= 0.2.7)
- MicrosoftFluentUI/ActivityViewAnimating_ios (= 0.2.7)
- MicrosoftFluentUI/Appearance_mac (= 0.2.7)
- MicrosoftFluentUI/Avatar_ios (= 0.2.7)
- MicrosoftFluentUI/AvatarView_mac (= 0.2.7)
- MicrosoftFluentUI/BadgeField_ios (= 0.2.7)
- MicrosoftFluentUI/BarButtonItems_ios (= 0.2.7)
- MicrosoftFluentUI/Button_ios (= 0.2.7)
- MicrosoftFluentUI/Button_mac (= 0.2.7)
- MicrosoftFluentUI/Calendar_ios (= 0.2.7)
- MicrosoftFluentUI/Card_ios (= 0.2.7)
- MicrosoftFluentUI/CommandBar_ios (= 0.2.7)
- MicrosoftFluentUI/Core_ios (= 0.2.7)
- MicrosoftFluentUI/Core_mac (= 0.2.7)
- MicrosoftFluentUI/DatePicker_mac (= 0.2.7)
- MicrosoftFluentUI/DotView_ios (= 0.2.7)
- MicrosoftFluentUI/Drawer_ios (= 0.2.7)
- MicrosoftFluentUI/DynamicColor_mac (= 0.2.7)
- MicrosoftFluentUI/EasyTapButton_ios (= 0.2.7)
- MicrosoftFluentUI/HUD_ios (= 0.2.7)
- MicrosoftFluentUI/IndeterminateProgressBar_ios (= 0.2.7)
- MicrosoftFluentUI/Label_ios (= 0.2.7)
- MicrosoftFluentUI/Link_mac (= 0.2.7)
- MicrosoftFluentUI/Navigation_ios (= 0.2.7)
- MicrosoftFluentUI/Notification_ios (= 0.2.7)
- MicrosoftFluentUI/Obscurable_ios (= 0.2.7)
- MicrosoftFluentUI/OtherCells_ios (= 0.2.7)
- MicrosoftFluentUI/PeoplePicker_ios (= 0.2.7)
- MicrosoftFluentUI/PillButtonBar_ios (= 0.2.7)
- MicrosoftFluentUI/PopupMenu_ios (= 0.2.7)
- MicrosoftFluentUI/Presenters_ios (= 0.2.7)
- MicrosoftFluentUI/ResizingHandleView_ios (= 0.2.7)
- MicrosoftFluentUI/ScrollView_ios (= 0.2.7)
- MicrosoftFluentUI/SegmentedControl_ios (= 0.2.7)
- MicrosoftFluentUI/Separator_ios (= 0.2.7)
- MicrosoftFluentUI/Separator_mac (= 0.2.7)
- MicrosoftFluentUI/Shimmer_ios (= 0.2.7)
- MicrosoftFluentUI/TabBar_ios (= 0.2.7)
- MicrosoftFluentUI/TableView_ios (= 0.2.7)
- MicrosoftFluentUI/Tooltip_ios (= 0.2.7)
- MicrosoftFluentUI/TouchForwardingView_ios (= 0.2.7)
- MicrosoftFluentUI/TwoLineTitleView_ios (= 0.2.7)
- MicrosoftFluentUI/Utilities_ios (= 0.2.7)
- MicrosoftFluentUI/Appearance_mac (0.2.7)
- MicrosoftFluentUI/AvatarView_mac (0.2.7):
- MicrosoftFluentUI (0.2.8):
- MicrosoftFluentUI/ActivityIndicator_ios (= 0.2.8)
- MicrosoftFluentUI/ActivityViewAnimating_ios (= 0.2.8)
- MicrosoftFluentUI/Appearance_mac (= 0.2.8)
- MicrosoftFluentUI/Avatar_ios (= 0.2.8)
- MicrosoftFluentUI/AvatarView_mac (= 0.2.8)
- MicrosoftFluentUI/BadgeField_ios (= 0.2.8)
- MicrosoftFluentUI/BarButtonItems_ios (= 0.2.8)
- MicrosoftFluentUI/BottomCommanding_ios (= 0.2.8)
- MicrosoftFluentUI/BottomSheet_ios (= 0.2.8)
- MicrosoftFluentUI/Button_ios (= 0.2.8)
- MicrosoftFluentUI/Button_mac (= 0.2.8)
- MicrosoftFluentUI/Calendar_ios (= 0.2.8)
- MicrosoftFluentUI/Card_ios (= 0.2.8)
- MicrosoftFluentUI/CommandBar_ios (= 0.2.8)
- MicrosoftFluentUI/Core_ios (= 0.2.8)
- MicrosoftFluentUI/Core_mac (= 0.2.8)
- MicrosoftFluentUI/DatePicker_mac (= 0.2.8)
- MicrosoftFluentUI/DotView_ios (= 0.2.8)
- MicrosoftFluentUI/Drawer_ios (= 0.2.8)
- MicrosoftFluentUI/DynamicColor_mac (= 0.2.8)
- MicrosoftFluentUI/EasyTapButton_ios (= 0.2.8)
- MicrosoftFluentUI/HUD_ios (= 0.2.8)
- MicrosoftFluentUI/IndeterminateProgressBar_ios (= 0.2.8)
- MicrosoftFluentUI/Label_ios (= 0.2.8)
- MicrosoftFluentUI/Link_mac (= 0.2.8)
- MicrosoftFluentUI/Navigation_ios (= 0.2.8)
- MicrosoftFluentUI/Notification_ios (= 0.2.8)
- MicrosoftFluentUI/Obscurable_ios (= 0.2.8)
- MicrosoftFluentUI/OtherCells_ios (= 0.2.8)
- MicrosoftFluentUI/PeoplePicker_ios (= 0.2.8)
- MicrosoftFluentUI/PillButtonBar_ios (= 0.2.8)
- MicrosoftFluentUI/PopupMenu_ios (= 0.2.8)
- MicrosoftFluentUI/Presenters_ios (= 0.2.8)
- MicrosoftFluentUI/ResizingHandleView_ios (= 0.2.8)
- MicrosoftFluentUI/ScrollView_ios (= 0.2.8)
- MicrosoftFluentUI/SegmentedControl_ios (= 0.2.8)
- MicrosoftFluentUI/Separator_ios (= 0.2.8)
- MicrosoftFluentUI/Separator_mac (= 0.2.8)
- MicrosoftFluentUI/Shimmer_ios (= 0.2.8)
- MicrosoftFluentUI/TabBar_ios (= 0.2.8)
- MicrosoftFluentUI/TableView_ios (= 0.2.8)
- MicrosoftFluentUI/Tooltip_ios (= 0.2.8)
- MicrosoftFluentUI/TouchForwardingView_ios (= 0.2.8)
- MicrosoftFluentUI/TwoLineTitleView_ios (= 0.2.8)
- MicrosoftFluentUI/Utilities_ios (= 0.2.8)
- MicrosoftFluentUI/Appearance_mac (0.2.8)
- MicrosoftFluentUI/AvatarView_mac (0.2.8):
- MicrosoftFluentUI/Core_mac
- MicrosoftFluentUI/DynamicColor_mac
- MicrosoftFluentUI/Button_mac (0.2.7):
- MicrosoftFluentUI/Button_mac (0.2.8):
- MicrosoftFluentUI/Core_mac
- MicrosoftFluentUI/Core_mac (0.2.7)
- MicrosoftFluentUI/DatePicker_mac (0.2.7):
- MicrosoftFluentUI/Core_mac (0.2.8)
- MicrosoftFluentUI/DatePicker_mac (0.2.8):
- MicrosoftFluentUI/Appearance_mac
- MicrosoftFluentUI/Core_mac
- MicrosoftFluentUI/DynamicColor_mac (0.2.7):
- MicrosoftFluentUI/DynamicColor_mac (0.2.8):
- MicrosoftFluentUI/Appearance_mac
- MicrosoftFluentUI/Link_mac (0.2.7):
- MicrosoftFluentUI/Link_mac (0.2.8):
- MicrosoftFluentUI/Core_mac
- MicrosoftFluentUI/Separator_mac (0.2.7):
- MicrosoftFluentUI/Separator_mac (0.2.8):
- MicrosoftFluentUI/Core_mac
- RCT-Folly (2020.01.13.00):
- boost-for-react-native
@ -88,239 +92,239 @@ PODS:
- boost-for-react-native
- DoubleConversion
- glog
- RCTRequired (0.63.36)
- RCTTypeSafety (0.63.36):
- FBLazyVector (= 0.63.36)
- RCTRequired (0.63.37)
- RCTTypeSafety (0.63.37):
- FBLazyVector (= 0.63.37)
- RCT-Folly (= 2020.01.13.00)
- RCTRequired (= 0.63.36)
- React-Core (= 0.63.36)
- React (0.63.36):
- React-Core (= 0.63.36)
- React-Core/DevSupport (= 0.63.36)
- React-Core/RCTWebSocket (= 0.63.36)
- React-RCTActionSheet (= 0.63.36)
- React-RCTAnimation (= 0.63.36)
- React-RCTBlob (= 0.63.36)
- React-RCTImage (= 0.63.36)
- React-RCTLinking (= 0.63.36)
- React-RCTNetwork (= 0.63.36)
- React-RCTSettings (= 0.63.36)
- React-RCTText (= 0.63.36)
- React-RCTVibration (= 0.63.36)
- React-callinvoker (0.63.36)
- React-Core (0.63.36):
- RCTRequired (= 0.63.37)
- React-Core (= 0.63.37)
- React (0.63.37):
- React-Core (= 0.63.37)
- React-Core/DevSupport (= 0.63.37)
- React-Core/RCTWebSocket (= 0.63.37)
- React-RCTActionSheet (= 0.63.37)
- React-RCTAnimation (= 0.63.37)
- React-RCTBlob (= 0.63.37)
- React-RCTImage (= 0.63.37)
- React-RCTLinking (= 0.63.37)
- React-RCTNetwork (= 0.63.37)
- React-RCTSettings (= 0.63.37)
- React-RCTText (= 0.63.37)
- React-RCTVibration (= 0.63.37)
- React-callinvoker (0.63.37)
- React-Core (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default (= 0.63.36)
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-Core/Default (= 0.63.37)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/CoreModulesHeaders (0.63.36):
- React-Core/CoreModulesHeaders (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/Default (0.63.36):
- React-Core/Default (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/DevSupport (0.63.36):
- React-Core/DevSupport (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default (= 0.63.36)
- React-Core/RCTWebSocket (= 0.63.36)
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-jsinspector (= 0.63.36)
- React-Core/Default (= 0.63.37)
- React-Core/RCTWebSocket (= 0.63.37)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- React-jsinspector (= 0.63.37)
- Yoga
- React-Core/RCTActionSheetHeaders (0.63.36):
- React-Core/RCTActionSheetHeaders (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/RCTAnimationHeaders (0.63.36):
- React-Core/RCTAnimationHeaders (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/RCTBlobHeaders (0.63.36):
- React-Core/RCTBlobHeaders (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/RCTImageHeaders (0.63.36):
- React-Core/RCTImageHeaders (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/RCTLinkingHeaders (0.63.36):
- React-Core/RCTLinkingHeaders (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/RCTNetworkHeaders (0.63.36):
- React-Core/RCTNetworkHeaders (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/RCTSettingsHeaders (0.63.36):
- React-Core/RCTSettingsHeaders (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/RCTTextHeaders (0.63.36):
- React-Core/RCTTextHeaders (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/RCTVibrationHeaders (0.63.36):
- React-Core/RCTVibrationHeaders (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-Core/RCTWebSocket (0.63.36):
- React-Core/RCTWebSocket (0.63.37):
- glog
- RCT-Folly (= 2020.01.13.00)
- React-Core/Default (= 0.63.36)
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsiexecutor (= 0.63.36)
- React-Core/Default (= 0.63.37)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsiexecutor (= 0.63.37)
- Yoga
- React-CoreModules (0.63.36):
- FBReactNativeSpec (= 0.63.36)
- React-CoreModules (0.63.37):
- FBReactNativeSpec (= 0.63.37)
- RCT-Folly (= 2020.01.13.00)
- RCTTypeSafety (= 0.63.36)
- React-Core/CoreModulesHeaders (= 0.63.36)
- React-jsi (= 0.63.36)
- React-RCTImage (= 0.63.36)
- ReactCommon/turbomodule/core (= 0.63.36)
- React-cxxreact (0.63.36):
- RCTTypeSafety (= 0.63.37)
- React-Core/CoreModulesHeaders (= 0.63.37)
- React-jsi (= 0.63.37)
- React-RCTImage (= 0.63.37)
- ReactCommon/turbomodule/core (= 0.63.37)
- React-cxxreact (0.63.37):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- glog
- RCT-Folly (= 2020.01.13.00)
- React-callinvoker (= 0.63.36)
- React-jsinspector (= 0.63.36)
- React-jsi (0.63.36):
- React-callinvoker (= 0.63.37)
- React-jsinspector (= 0.63.37)
- React-jsi (0.63.37):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- glog
- RCT-Folly (= 2020.01.13.00)
- React-jsi/Default (= 0.63.36)
- React-jsi/Default (0.63.36):
- React-jsi/Default (= 0.63.37)
- React-jsi/Default (0.63.37):
- boost-for-react-native (= 1.63.0)
- DoubleConversion
- glog
- RCT-Folly (= 2020.01.13.00)
- React-jsiexecutor (0.63.36):
- React-jsiexecutor (0.63.37):
- DoubleConversion
- glog
- RCT-Folly (= 2020.01.13.00)
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- React-jsinspector (0.63.36)
- React-RCTActionSheet (0.63.36):
- React-Core/RCTActionSheetHeaders (= 0.63.36)
- React-RCTAnimation (0.63.36):
- FBReactNativeSpec (= 0.63.36)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- React-jsinspector (0.63.37)
- React-RCTActionSheet (0.63.37):
- React-Core/RCTActionSheetHeaders (= 0.63.37)
- React-RCTAnimation (0.63.37):
- FBReactNativeSpec (= 0.63.37)
- RCT-Folly (= 2020.01.13.00)
- RCTTypeSafety (= 0.63.36)
- React-Core/RCTAnimationHeaders (= 0.63.36)
- React-jsi (= 0.63.36)
- ReactCommon/turbomodule/core (= 0.63.36)
- React-RCTBlob (0.63.36):
- FBReactNativeSpec (= 0.63.36)
- RCTTypeSafety (= 0.63.37)
- React-Core/RCTAnimationHeaders (= 0.63.37)
- React-jsi (= 0.63.37)
- ReactCommon/turbomodule/core (= 0.63.37)
- React-RCTBlob (0.63.37):
- FBReactNativeSpec (= 0.63.37)
- RCT-Folly (= 2020.01.13.00)
- React-Core/RCTBlobHeaders (= 0.63.36)
- React-Core/RCTWebSocket (= 0.63.36)
- React-jsi (= 0.63.36)
- React-RCTNetwork (= 0.63.36)
- ReactCommon/turbomodule/core (= 0.63.36)
- React-RCTImage (0.63.36):
- FBReactNativeSpec (= 0.63.36)
- React-Core/RCTBlobHeaders (= 0.63.37)
- React-Core/RCTWebSocket (= 0.63.37)
- React-jsi (= 0.63.37)
- React-RCTNetwork (= 0.63.37)
- ReactCommon/turbomodule/core (= 0.63.37)
- React-RCTImage (0.63.37):
- FBReactNativeSpec (= 0.63.37)
- RCT-Folly (= 2020.01.13.00)
- RCTTypeSafety (= 0.63.36)
- React-Core/RCTImageHeaders (= 0.63.36)
- React-jsi (= 0.63.36)
- React-RCTNetwork (= 0.63.36)
- ReactCommon/turbomodule/core (= 0.63.36)
- React-RCTLinking (0.63.36):
- FBReactNativeSpec (= 0.63.36)
- React-Core/RCTLinkingHeaders (= 0.63.36)
- React-jsi (= 0.63.36)
- ReactCommon/turbomodule/core (= 0.63.36)
- React-RCTNetwork (0.63.36):
- FBReactNativeSpec (= 0.63.36)
- RCTTypeSafety (= 0.63.37)
- React-Core/RCTImageHeaders (= 0.63.37)
- React-jsi (= 0.63.37)
- React-RCTNetwork (= 0.63.37)
- ReactCommon/turbomodule/core (= 0.63.37)
- React-RCTLinking (0.63.37):
- FBReactNativeSpec (= 0.63.37)
- React-Core/RCTLinkingHeaders (= 0.63.37)
- React-jsi (= 0.63.37)
- ReactCommon/turbomodule/core (= 0.63.37)
- React-RCTNetwork (0.63.37):
- FBReactNativeSpec (= 0.63.37)
- RCT-Folly (= 2020.01.13.00)
- RCTTypeSafety (= 0.63.36)
- React-Core/RCTNetworkHeaders (= 0.63.36)
- React-jsi (= 0.63.36)
- ReactCommon/turbomodule/core (= 0.63.36)
- React-RCTSettings (0.63.36):
- FBReactNativeSpec (= 0.63.36)
- RCTTypeSafety (= 0.63.37)
- React-Core/RCTNetworkHeaders (= 0.63.37)
- React-jsi (= 0.63.37)
- ReactCommon/turbomodule/core (= 0.63.37)
- React-RCTSettings (0.63.37):
- FBReactNativeSpec (= 0.63.37)
- RCT-Folly (= 2020.01.13.00)
- RCTTypeSafety (= 0.63.36)
- React-Core/RCTSettingsHeaders (= 0.63.36)
- React-jsi (= 0.63.36)
- ReactCommon/turbomodule/core (= 0.63.36)
- React-RCTText (0.63.36):
- React-Core/RCTTextHeaders (= 0.63.36)
- React-RCTVibration (0.63.36):
- FBReactNativeSpec (= 0.63.36)
- RCTTypeSafety (= 0.63.37)
- React-Core/RCTSettingsHeaders (= 0.63.37)
- React-jsi (= 0.63.37)
- ReactCommon/turbomodule/core (= 0.63.37)
- React-RCTText (0.63.37):
- React-Core/RCTTextHeaders (= 0.63.37)
- React-RCTVibration (0.63.37):
- FBReactNativeSpec (= 0.63.37)
- RCT-Folly (= 2020.01.13.00)
- React-Core/RCTVibrationHeaders (= 0.63.36)
- React-jsi (= 0.63.36)
- ReactCommon/turbomodule/core (= 0.63.36)
- ReactCommon/turbomodule/core (0.63.36):
- React-Core/RCTVibrationHeaders (= 0.63.37)
- React-jsi (= 0.63.37)
- ReactCommon/turbomodule/core (= 0.63.37)
- ReactCommon/turbomodule/core (0.63.37):
- DoubleConversion
- glog
- RCT-Folly (= 2020.01.13.00)
- React-callinvoker (= 0.63.36)
- React-Core (= 0.63.36)
- React-cxxreact (= 0.63.36)
- React-jsi (= 0.63.36)
- ReactTestApp-DevSupport (0.6.12)
- React-callinvoker (= 0.63.37)
- React-Core (= 0.63.37)
- React-cxxreact (= 0.63.37)
- React-jsi (= 0.63.37)
- ReactTestApp-DevSupport (0.7.1)
- ReactTestApp-Resources (1.0.0-dev)
- RNCPicker (1.9.11):
- React-Core
- RNSVG (12.1.1):
- React
- SwiftLint (0.43.0)
- SwiftLint (0.43.1)
- Yoga (1.14.0)
DEPENDENCIES:
@ -331,6 +335,7 @@ DEPENDENCIES:
- FluentUI-React-Native-Avatar (from `../../../packages/experimental/Avatar/FluentUIReactNativeAvatar.podspec`)
- FluentUI-React-Native-Button (from `../../../packages/experimental/NativeButton/FluentUIReactNativeButton.podspec`)
- FluentUI-React-Native-FocusZone (from `../../../packages/components/FocusZone/FluentUIReactNativeFocusZone.podspec`)
- FluentUI-React-Native-MenuButton (from `../../../packages/components/MenuButton/FluentUIReactNativeMenuButton.podspec`)
- glog (from `../../../node_modules/react-native-macos/third-party-podspecs/glog.podspec`)
- RCT-Folly (from `../../../node_modules/react-native-macos/third-party-podspecs/RCT-Folly.podspec`)
- RCTRequired (from `../../../node_modules/react-native-macos/Libraries/RCTRequired`)
@ -382,6 +387,8 @@ EXTERNAL SOURCES:
:path: "../../../packages/experimental/NativeButton/FluentUIReactNativeButton.podspec"
FluentUI-React-Native-FocusZone:
:path: "../../../packages/components/FocusZone/FluentUIReactNativeFocusZone.podspec"
FluentUI-React-Native-MenuButton:
:path: "../../../packages/components/MenuButton/FluentUIReactNativeMenuButton.podspec"
glog:
:podspec: "../../../node_modules/react-native-macos/third-party-podspecs/glog.podspec"
RCT-Folly:
@ -440,41 +447,42 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost-for-react-native: dabda8622e76020607c2ae1e65cc0cda8b61479d
DoubleConversion: 56a44bcfd14ab2ff66f5a146b2e875eb4b69b19b
FBLazyVector: 0a9070829baaf7af315d4b85e992f24315ee0588
FBReactNativeSpec: e41705afe0a17d636081a7c077d34caf205ca13d
FluentUI-React-Native-Avatar: 63ff6d85a5ac741d5d3963457a1d717352a686d6
FluentUI-React-Native-Button: 9f6970b0f3461f181ae6e845c8f17af5b2f683b4
FluentUI-React-Native-FocusZone: 52fefa442f6ea2bd00bf0f4afa7172a486d85d76
FBLazyVector: 9d69690b3a1ca272ca0c0cee76ffcb6cf36d77af
FBReactNativeSpec: 8b671febd2393669947b56e8d8f53a54185dd0b7
FluentUI-React-Native-Avatar: a7275761d6214cc87f76d5d7cdb3fc72d8eb808a
FluentUI-React-Native-Button: eacc1e98bb859eb81dade960f2fe2c9e42247a35
FluentUI-React-Native-FocusZone: 97591670a320d6d5a0bfe4667f4d55a661403685
FluentUI-React-Native-MenuButton: 150192069c3b6666bb3659283884cb33a8e7a878
glog: 1cb7c408c781ae8f35bbababe459b45e3dee4ec1
MicrosoftFluentUI: 6b3bfd52b232e9abc5cb228b9761a5f42869f4d3
MicrosoftFluentUI: f0f620bb76ad355ca74b3dd7b1bd2e1ae41f0152
RCT-Folly: 1347093ffe75e152d846f7e45a3ef901b60021aa
RCTRequired: f84e12b899c38552d6a29f143cd45e2457d8b291
RCTTypeSafety: 8eeb4763b9abca903bee88705b1c9d49d1793751
React: 39d7e85e83660b53e35a0992b8c7e02069786df2
React-callinvoker: b17367fc9df0be66f294a7d9f216f6e7fee0bdc3
React-Core: 7d5192635b2a1e339ece8568f6d28822b5692b07
React-CoreModules: 743a1e48d6f4c122865ad4d5ef9e4d5b5c959b8f
React-cxxreact: 94f493f48dea13e07ffb8ea202db49adad4c15ac
React-jsi: 6b7c2a4bf424c349d54de60388f4df6f06b42b3b
React-jsiexecutor: f4b3fdea0937ad930eec939e49341a26ae181240
React-jsinspector: 7237cfc1cea329713ee5079d824f6f73d8a84c21
React-RCTActionSheet: 2590694b11874f5e4557925b44602944e57dbde0
React-RCTAnimation: 5b2544feae919c11a0979c08cd85cef00029073b
React-RCTBlob: 633728c1c1a88bfb9a940188077e58e6e8224d28
React-RCTImage: 6aa8710e711c564fa5753dafd04cfd2b41b98bc7
React-RCTLinking: cdcd75833512de57b527c15d4c0c0204d76071c8
React-RCTNetwork: 4b93b2006a32825cc80d7deda1f0c9454dcff921
React-RCTSettings: ff204d18857b0b8b8dd2f186db2ce2fead4a20d7
React-RCTText: b5613f3b26ce07497fbcb0f4c8496c1c4fcb3405
React-RCTVibration: e5464e5e9dd67b4f5c6983046be2e941708343f8
ReactCommon: 85b3897abcb25a478b26cda3154a51fb56f405d2
ReactTestApp-DevSupport: 6464c326eccaa285191eb394b2b18d0663e40e10
RCTRequired: 34869e88152b553afc0c7bde31b7b95f626ae367
RCTTypeSafety: a7e07dddefa291537fa86c996b19bbbeda9db88e
React: 4b1d4533300d5ffecadd5966efad43aae87d0dcb
React-callinvoker: f6cc4222b47cfbea310047e92fec23d454029595
React-Core: bf15e114c68922342fa1c77a7582458086931f50
React-CoreModules: 00bbdffe53f364828dcf56c0c8ed58502a67757a
React-cxxreact: a6ae61aee087fb51956642ec9e45f0f5cc50e488
React-jsi: 95337001f7c137cb7aa17b39a05b654b54ddcccb
React-jsiexecutor: 6dcf6fb045190e13ab29d5a3eed010aaecd934be
React-jsinspector: df2c5f97e26ffc68bea06c4aae11e4ce09e53e3e
React-RCTActionSheet: faf3d96046a0fa2b40c3c1bd0c36be860b42f2a1
React-RCTAnimation: 7e62b31253f45c752f7593cff24a8845557b4d13
React-RCTBlob: 8a1c648f7887d850972233f742589e67d52357bb
React-RCTImage: d40614e39fc3186a0b406ceb13fd1903880dec96
React-RCTLinking: a0906eb0f0169f881a0637cbb9999fb4881ee200
React-RCTNetwork: b1baf2d42aa5dc7157c57c7cc7ca548b9eeadaee
React-RCTSettings: a21555584a097f61277b9ed97c00091da9beaa61
React-RCTText: 2f9504b1157ccce317774eb3ca935a923ddc95d7
React-RCTVibration: db89493e2520ad419eeb59e40059e246d9e71607
ReactCommon: 014dd1ff02eab367fa6676b7b408d1a08893a98d
ReactTestApp-DevSupport: 058444bc8d4df209aabc6a5f54a73bfd9a114f94
ReactTestApp-Resources: 5950ae44720217c6778ff03fb1d906c8fb3ce483
RNCPicker: 6780c753e9e674065db90d9c965920516402579d
RNSVG: 551acb6562324b1d52a4e0758f7ca0ec234e278f
SwiftLint: 0c645fdc6feed3e390c1701ab3cc669f88b42752
Yoga: f2da5366fe2be821a64c84a2e455042eab763cf5
SwiftLint: 99f82d07b837b942dd563c668de129a03fc3fb52
Yoga: 77d9987384e26b4aaf3e7a01808838cc2d4304f2
PODFILE CHECKSUM: a71337fd6df579c22ae17c48d85b9f981ac8c11e
PODFILE CHECKSUM: 36b7c6fb3b19c51edd97ade626978c94f016faf3
COCOAPODS: 1.10.1
COCOAPODS: 1.10.2

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Add MenuButton for macOS",
"packageName": "@fluentui-react-native/menu-button",
"email": "sanajmi@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Add MenuButton for macOS",
"packageName": "@fluentui-react-native/tester",
"email": "sanajmi@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -29,11 +29,13 @@
<!-- macOS debug -->
<file src="DerivedData\Build\Products\Debug\FluentUI-React-Native-Avatar\libFluentUI-React-Native-Avatar.a" target="Debug-macosx"/>
<file src="DerivedData\Build\Products\Debug\FluentUI-React-Native-Button\libFluentUI-React-Native-Button.a" target="Debug-macosx"/>
<file src="DerivedData\Build\Products\Debug\FluentUI-React-Native-FocusZone\libFluentUI-React-Native-FocusZone.a" target="Debug-macosx"/>
<file src="DerivedData\Build\Products\Debug\FluentUI-React-Native-FocusZone\libFluentUI-React-Native-FocusZone.a" target="Debug-macosx"/>
<file src="DerivedData\Build\Products\Debug\FluentUI-React-Native-FocusZone\libFluentUI-React-Native-MenuButton.a" target="Debug-macosx"/>
<!-- macOS ship -->
<file src="DerivedData\Build\Products\Release\FluentUI-React-Native-Avatar\libFluentUI-React-Native-Avatar.a" target="Ship-macosx"/>
<file src="DerivedData\Build\Products\Release\FluentUI-React-Native-Button\libFluentUI-React-Native-Button.a" target="Ship-macosx"/>
<file src="DerivedData\Build\Products\Release\FluentUI-React-Native-FocusZone\libFluentUI-React-Native-FocusZone.a" target="Ship-macosx"/>
<file src="DerivedData\Build\Products\Release\FluentUI-React-Native-FocusZone\libFluentUI-React-Native-FocusZone.a" target="Ship-macosx"/>
<file src="DerivedData\Build\Products\Release\FluentUI-React-Native-FocusZone\libFluentUI-React-Native-MenuButton.a" target="Ship-macosx"/>
<!-- iOS Release jsbundle -->
<file src="apps\ios\dist\index.ios.jsbundle" />

Просмотреть файл

@ -0,0 +1,21 @@
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Pod::Spec.new do |s|
s.name = 'FluentUI-React-Native-MenuButton'
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.authors = package['author']
s.homepage = package['homepage']
s.source = { :git => "https://github.com/microsoft/fluentui-react-native.git", :tag => "#{s.version}" }
s.swift_version = "5.0"
s.osx.deployment_target = "10.14"
s.osx.source_files = "macos/*.{swift,h,m,mm}"
s.dependency 'React'
end

Просмотреть файл

@ -0,0 +1,5 @@
# MenuButton
MenuButton is a wrapper control that combines and simplifies the API of Button and ContextualMenu.
On macOS, it is implemented as a native module, and thus lacks the same level of customization as its win32 counterpart.

Просмотреть файл

@ -0,0 +1,63 @@
#import <React/RCTComponent.h>
#import <React/RCTViewManager.h>
@implementation RCTConvert (MSFMenuButtonAdditions)
+ (NSMenuItem *)menuItem:(id)json
{
NSMenuItem *menuItem = [[NSMenuItem alloc] init];
[menuItem setTitle:[RCTConvert NSString:json[@"text"]]];
[menuItem setEnabled:![RCTConvert BOOL:json[@"disabled"]]];
[menuItem setToolTip:[RCTConvert NSString:json[@"title"]]];
[menuItem setIdentifier:[RCTConvert NSString:json[@"itemKey"]]];
return menuItem;
}
+ (NSMenu *)NSMenu:(id)json
{
NSMenu *menu = [[NSMenu alloc] init];
[menu setAutoenablesItems:NO];
NSArray *menuItems = [RCTConvert NSArray:json];
for (NSDictionary *menuItemJson in menuItems) {
NSMenuItem *menuItem = [RCTConvert menuItem:menuItemJson];
if ([menuItemJson objectForKey:@"hasSubmenu"])
{
BOOL hasSubmenu = [RCTConvert BOOL:menuItemJson[@"hasSubmenu"]];
if (hasSubmenu) {
NSMenu *submenu = [RCTConvert NSMenu:menuItemJson[@"submenuItems"]];
[menu setSubmenu:submenu forItem:menuItem];
}
}
[menu addItem:menuItem];
}
return menu;
}
@end
@interface RCT_EXTERN_MODULE(MSFMenuButtonManager, RCTViewManager)
RCT_EXPORT_VIEW_PROPERTY(onItemClick, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onSubmenuItemClick, RCTBubblingEventBlock)
RCT_REMAP_VIEW_PROPERTY(content, title, NSString)
RCT_EXPORT_VIEW_PROPERTY(image, UIImage)
RCT_CUSTOM_VIEW_PROPERTY(disabled, BOOL, NSPopUpButton)
{
BOOL disabled = ![RCTConvert BOOL:json];
[view setEnabled:disabled];
}
RCT_REMAP_VIEW_PROPERTY(menuItems, menu, NSMenu)
@end

Просмотреть файл

@ -0,0 +1 @@
#import <React/RCTViewManager.h>

Просмотреть файл

@ -0,0 +1,131 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
import AppKit
@objc(MSFMenuButton)
open class MenuButton: NSPopUpButton {
public override init(frame buttonFrame: NSRect, pullsDown flag: Bool) {
super.init(frame: buttonFrame, pullsDown: flag)
imagePosition = .imageLeading
bezelStyle = .recessed
if #available(OSX 11.0, *) {
controlSize = .large
}
guard let dropDownCell = cell as? NSPopUpButtonCell else {
preconditionFailure()
}
dropDownCell.imagePosition = .imageLeading
dropDownCell.arrowPosition = .arrowAtBottom
}
@available(*, unavailable)
required public init?(coder decoder: NSCoder) {
preconditionFailure()
}
@objc public convenience init() {
self.init(frame: .zero, pullsDown: true)
}
@objc public var OnItemClick: RCTBubblingEventBlock?
@objc public var OnSubmenuItemClick: RCTBubblingEventBlock?
open override var menu: NSMenu? {
didSet {
updateMenu()
}
}
open override var image: NSImage? {
get {
return menuButtonImage
}
set {
// We must set the image on the dropdown cell rather than the button.
// If we set the image on Button itself, no image is displayed.
menuButtonImage = newValue
updateDropDownCell()
}
}
open override var title: String {
didSet {
updateDropDownCell()
}
}
// MARK: - Private Methods
private func updateMenu() {
guard let menu = menu else {
return
}
for (index, menuItem) in menu.items.enumerated() {
menuItem.target = self
menuItem.action = #selector(sendOnItemClickEvent)
if let submenu = menuItem.submenu {
//Add actions to one level of submenu items to support the `onSubmenuItemClick` callback
for subMenuItem in submenu.items {
subMenuItem.tag = index //store the index of the "super" menuItem for lookup in the action
subMenuItem.target = self
subMenuItem.action = #selector(sendOnSubItemClickEvent)
}
}
}
// Insert an initial empty item into index 0, since index 0 is never displayed.
// We must do this after we assign the tags to the submenuItems to preserve index order.
let initialEmptyItem = NSMenuItem()
menu.insertItem(initialEmptyItem, at: 0)
}
private func updateDropDownCell() {
guard let dropDownCell = cell as? NSPopUpButtonCell else {
preconditionFailure()
}
// MenuButton needs a MenuItem set on its cell to display the title and image properly
let dropdownCellItem = NSMenuItem()
dropdownCellItem.image = image
dropdownCellItem.title = title
dropDownCell.usesItemFromMenu = false
dropDownCell.menuItem = dropdownCellItem
}
@objc(sendOnItemClickEvent:)
private func sendOnItemClickEvent(sender: NSMenuItem) {
if OnItemClick != nil {
guard let identifier = sender.identifier else {
preconditionFailure("itemKey not set on Menu Item")
}
OnItemClick!(["key": identifier])
}
}
@objc(sendOnSubItemClickEvent:)
private func sendOnSubItemClickEvent(sender: NSMenuItem) {
if OnSubmenuItemClick != nil {
guard let identifier = sender.identifier else {
preconditionFailure("itemKey not set on Menu Item")
}
OnSubmenuItemClick!(["index": sender.tag,"key": identifier])
}
}
private var menuButtonImage: NSImage? {
didSet {
updateDropDownCell()
}
};
}

Просмотреть файл

@ -0,0 +1,12 @@
import Foundation
@objc(MSFMenuButtonManager)
class MenuButtonManager: RCTViewManager {
override func view()->NSView! {
return MenuButton()
}
override class func requiresMainQueueSetup() -> Bool {
return true
}
}

Просмотреть файл

@ -2,6 +2,9 @@
"name": "@fluentui-react-native/menu-button",
"version": "0.2.19",
"description": "A cross-platform MenuButton component using the Fluent Design System",
"license": "MIT",
"author": "Microsoft <fluentuinativeowners@microsoft.com>",
"homepage": "https://github.com/microsoft/fluentui-react-native",
"main": "src/index.ts",
"module": "src/index.ts",
"typings": "lib/index.d.ts",
@ -24,6 +27,7 @@
},
"dependencies": {
"@fluentui-react-native/button": "^0.17.21",
"@fluentui-react-native/component-cache": "^1.2.2",
"@fluentui-react-native/contextual-menu": "^0.9.17",
"@fluentui-react-native/tokens": "^0.9.12",
"@uifabricshared/foundation-composable": ">=0.8.6 <1.0.0",
@ -39,7 +43,5 @@
"peerDependencies": {
"react": ">=16.13.1",
"react-native": ">=0.63.4"
},
"author": "",
"license": "MIT"
}
}

Просмотреть файл

@ -0,0 +1,80 @@
/** @jsx withSlots */
import { IUseComposeStyling, compose } from '@uifabricshared/foundation-compose';
import { mergeSettings } from '@uifabricshared/foundation-settings';
import { ISlots, withSlots } from '@uifabricshared/foundation-composable';
import { backgroundColorTokens, borderTokens } from '@fluentui-react-native/tokens';
import { ensureNativeComponent } from '@fluentui-react-native/component-cache';
const NativeMenuButton = ensureNativeComponent('MSFMenuButton');
import {
MenuButtonName,
MenuButtonProps,
MenuButtonSlotProps,
MenuButtonType,
MenuButtonRenderData,
MenuButtonState,
} from './MenuButton.types';
export const MenuButton = compose<MenuButtonType>({
displayName: MenuButtonName,
usePrepareProps: (userProps: MenuButtonProps, useStyling: IUseComposeStyling<MenuButtonType>) => {
const { menuItems, content, icon, disabled, onItemClick } = userProps;
const state: MenuButtonState = {
context: {},
};
// reroute the native component's OnItemClick event to MenuButtons's onItemClick
const OnItemClickRerouted = (event: any) => {
if (onItemClick != null) {
onItemClick(event.nativeEvent.key);
}
};
// reroute the native component's onSubmenuItemClick event to each MenuButtonItem's onItemClick
const OnSubmenuItemClickRerouted = (event: any) => {
// Grab the index of the menu item that hosts the submenu to look up the correct callback
const menuItemIndex = event.nativeEvent.index;
const onSubmenuItemClick = menuItems[menuItemIndex].submenuProps?.onItemClick;
if (onSubmenuItemClick != null) {
onSubmenuItemClick(event.nativeEvent.key);
}
};
const styleProps = useStyling(userProps, (override: string) => state[override] || userProps[override]);
const slotProps = mergeSettings<MenuButtonSlotProps>(styleProps, {
root: {
content: content,
disabled: disabled,
image: icon,
menuItems: menuItems,
onItemClick: OnItemClickRerouted,
onSubmenuItemClick: OnSubmenuItemClickRerouted,
style: {
width: 160,
height: 32,
},
},
});
return { slotProps, state };
},
slots: {
root: NativeMenuButton,
},
styles: {
contextualMenu: [backgroundColorTokens, borderTokens],
button: [backgroundColorTokens, borderTokens],
},
render: (Slots: ISlots<MenuButtonSlotProps>, renderData: MenuButtonRenderData) => {
if (!(renderData.state && renderData.slotProps)) {
return null;
}
return <Slots.root />;
},
});
export default MenuButton;