@fluentui-react-native/menu 1.0.53 → 1.0.55
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.json +57 -1
- package/CHANGELOG.md +21 -2
- package/lib/MenuItem/MenuItem.js +4 -4
- package/lib/MenuItem/MenuItem.js.map +1 -1
- package/lib/MenuItem/MenuItem.types.d.ts +8 -4
- package/lib/MenuItem/MenuItem.types.d.ts.map +1 -1
- package/lib/MenuItem/index.d.ts +1 -1
- package/lib/MenuItem/index.d.ts.map +1 -1
- package/lib/MenuItem/useMenuItem.d.ts +2 -2
- package/lib/MenuItem/useMenuItem.d.ts.map +1 -1
- package/lib/MenuItem/useMenuItem.js +4 -6
- package/lib/MenuItem/useMenuItem.js.map +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckbox.d.ts +2 -2
- package/lib/MenuItemCheckbox/MenuItemCheckbox.d.ts.map +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckbox.js +2 -2
- package/lib/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckbox.types.d.ts +5 -4
- package/lib/MenuItemCheckbox/MenuItemCheckbox.types.d.ts.map +1 -1
- package/lib/MenuItemCheckbox/MenuItemCheckbox.types.js.map +1 -1
- package/lib/MenuItemCheckbox/index.d.ts +1 -1
- package/lib/MenuItemCheckbox/index.d.ts.map +1 -1
- package/lib/MenuItemCheckbox/useMenuItemCheckbox.d.ts +3 -3
- package/lib/MenuItemCheckbox/useMenuItemCheckbox.d.ts.map +1 -1
- package/lib/MenuItemCheckbox/useMenuItemCheckbox.js +4 -4
- package/lib/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib/MenuItemRadio/useMenuItemRadio.d.ts +2 -2
- package/lib/MenuItemRadio/useMenuItemRadio.d.ts.map +1 -1
- package/lib/MenuTrigger/MenuTrigger.d.ts.map +1 -1
- package/lib/MenuTrigger/MenuTrigger.js +2 -19
- package/lib/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib/MenuTrigger/getRevisedProps.d.ts +11 -0
- package/lib/MenuTrigger/getRevisedProps.d.ts.map +1 -0
- package/lib/MenuTrigger/getRevisedProps.js +47 -0
- package/lib/MenuTrigger/getRevisedProps.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/MenuItem/MenuItem.js +3 -3
- package/lib-commonjs/MenuItem/MenuItem.js.map +1 -1
- package/lib-commonjs/MenuItem/MenuItem.types.d.ts +8 -4
- package/lib-commonjs/MenuItem/MenuItem.types.d.ts.map +1 -1
- package/lib-commonjs/MenuItem/index.d.ts +1 -1
- package/lib-commonjs/MenuItem/index.d.ts.map +1 -1
- package/lib-commonjs/MenuItem/useMenuItem.d.ts +2 -2
- package/lib-commonjs/MenuItem/useMenuItem.d.ts.map +1 -1
- package/lib-commonjs/MenuItem/useMenuItem.js +3 -5
- package/lib-commonjs/MenuItem/useMenuItem.js.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.d.ts +2 -2
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.d.ts.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.js +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.types.d.ts +5 -4
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.types.d.ts.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.types.js.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/index.d.ts +1 -1
- package/lib-commonjs/MenuItemCheckbox/index.d.ts.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.d.ts +3 -3
- package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.d.ts.map +1 -1
- package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.js +3 -3
- package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
- package/lib-commonjs/MenuItemRadio/useMenuItemRadio.d.ts +2 -2
- package/lib-commonjs/MenuItemRadio/useMenuItemRadio.d.ts.map +1 -1
- package/lib-commonjs/MenuTrigger/MenuTrigger.d.ts.map +1 -1
- package/lib-commonjs/MenuTrigger/MenuTrigger.js +2 -18
- package/lib-commonjs/MenuTrigger/MenuTrigger.js.map +1 -1
- package/lib-commonjs/MenuTrigger/getRevisedProps.d.ts +11 -0
- package/lib-commonjs/MenuTrigger/getRevisedProps.d.ts.map +1 -0
- package/lib-commonjs/MenuTrigger/getRevisedProps.js +50 -0
- package/lib-commonjs/MenuTrigger/getRevisedProps.js.map +1 -0
- package/lib-commonjs/index.d.ts +2 -2
- package/lib-commonjs/index.d.ts.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +4 -4
- package/src/MenuItem/MenuItem.tsx +4 -4
- package/src/MenuItem/MenuItem.types.ts +9 -4
- package/src/MenuItem/index.ts +1 -1
- package/src/MenuItem/useMenuItem.ts +10 -7
- package/src/MenuItemCheckbox/MenuItemCheckbox.tsx +4 -4
- package/src/MenuItemCheckbox/MenuItemCheckbox.types.ts +6 -5
- package/src/MenuItemCheckbox/index.ts +1 -1
- package/src/MenuItemCheckbox/useMenuItemCheckbox.ts +7 -6
- package/src/MenuItemRadio/useMenuItemRadio.ts +2 -2
- package/src/MenuTrigger/MenuTrigger.tsx +3 -24
- package/src/MenuTrigger/getRevisedProps.ts +54 -0
- package/src/__tests__/__snapshots__/Menu.test.tsx.snap +13 -17
- package/src/index.ts +3 -2
|
@@ -3,7 +3,7 @@ import { ColorValue } from 'react-native';
|
|
|
3
3
|
import { XmlProps } from 'react-native-svg';
|
|
4
4
|
import type { IViewProps } from '@fluentui-react-native/adapters';
|
|
5
5
|
import { TextProps } from '@fluentui-react-native/text';
|
|
6
|
-
import { IFocusable, InteractionEvent,
|
|
6
|
+
import { IFocusable, InteractionEvent, PressablePropsExtended, PressableState } from '@fluentui-react-native/interactive-hooks';
|
|
7
7
|
import { FontTokens, IBorderTokens, IColorTokens, LayoutTokens } from '@fluentui-react-native/tokens';
|
|
8
8
|
|
|
9
9
|
export const menuItemName = 'MenuItem';
|
|
@@ -43,7 +43,7 @@ export interface MenuItemTokens extends LayoutTokens, FontTokens, IBorderTokens,
|
|
|
43
43
|
pressed?: MenuItemTokens;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export interface MenuItemProps extends Omit<
|
|
46
|
+
export interface MenuItemProps extends Omit<PressablePropsExtended, 'onPress'> {
|
|
47
47
|
/**
|
|
48
48
|
* A RefObject to access the IButton interface. Use this to access the public methods and properties of the component.
|
|
49
49
|
*/
|
|
@@ -60,7 +60,7 @@ export interface MenuItemProps extends Omit<IWithPressableOptions<IViewProps>, '
|
|
|
60
60
|
persistOnClick?: boolean;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export interface MenuItemState extends
|
|
63
|
+
export interface MenuItemState extends PressableState {
|
|
64
64
|
hasCheckmarks?: boolean;
|
|
65
65
|
|
|
66
66
|
/**
|
|
@@ -69,8 +69,13 @@ export interface MenuItemState extends IPressableHooks<MenuItemProps & React.Com
|
|
|
69
69
|
hasSubmenu?: boolean;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
export interface MenuItemInfo {
|
|
73
|
+
props: MenuItemProps & React.ComponentPropsWithRef<any>;
|
|
74
|
+
state: MenuItemState;
|
|
75
|
+
}
|
|
76
|
+
|
|
72
77
|
export interface MenuItemSlotProps {
|
|
73
|
-
root: React.PropsWithRef<
|
|
78
|
+
root: React.PropsWithRef<PressablePropsExtended>;
|
|
74
79
|
content?: TextProps;
|
|
75
80
|
checkmark?: React.PropsWithRef<IViewProps>;
|
|
76
81
|
submenuIndicator?: XmlProps;
|
package/src/MenuItem/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { MenuItem } from './MenuItem';
|
|
2
2
|
export { menuItemName } from './MenuItem.types';
|
|
3
|
-
export type { MenuItemProps, MenuItemState, MenuItemTokens, MenuItemSlotProps, MenuItemType } from './MenuItem.types';
|
|
3
|
+
export type { MenuItemProps, MenuItemState, MenuItemInfo, MenuItemTokens, MenuItemSlotProps, MenuItemType } from './MenuItem.types';
|
|
4
4
|
export { useMenuItem } from './useMenuItem';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { AccessibilityState, I18nManager, Platform } from 'react-native';
|
|
3
|
-
import { MenuItemProps,
|
|
3
|
+
import { MenuItemProps, MenuItemInfo } from './MenuItem.types';
|
|
4
4
|
import { memoize } from '@fluentui-react-native/framework';
|
|
5
5
|
import {
|
|
6
6
|
InteractionEvent,
|
|
7
7
|
isKeyPressEvent,
|
|
8
|
-
|
|
8
|
+
usePressableState,
|
|
9
9
|
useKeyDownProps,
|
|
10
10
|
useViewCommandFocus,
|
|
11
11
|
} from '@fluentui-react-native/interactive-hooks';
|
|
@@ -16,7 +16,7 @@ import { useMenuTriggerContext } from '../context/menuTriggerContext';
|
|
|
16
16
|
export const triggerKeys = [' ', 'Enter'];
|
|
17
17
|
export const submenuTriggerKeys = [...triggerKeys, 'ArrowLeft', 'ArrowRight'];
|
|
18
18
|
|
|
19
|
-
export const useMenuItem = (props: MenuItemProps):
|
|
19
|
+
export const useMenuItem = (props: MenuItemProps): MenuItemInfo => {
|
|
20
20
|
// attach the pressable state handlers
|
|
21
21
|
const defaultComponentRef = React.useRef(null);
|
|
22
22
|
const { onClick, accessibilityState, componentRef = defaultComponentRef, disabled, persistOnClick, ...rest } = props;
|
|
@@ -54,7 +54,7 @@ export const useMenuItem = (props: MenuItemProps): MenuItemState => {
|
|
|
54
54
|
[disabled, hasSubmenu, onArrowClose, onClick, setOpen, shouldPersist],
|
|
55
55
|
);
|
|
56
56
|
|
|
57
|
-
const pressable =
|
|
57
|
+
const pressable = usePressableState({ ...rest, onPress: onInvoke });
|
|
58
58
|
const itemRef = useViewCommandFocus(componentRef);
|
|
59
59
|
const keys = isSubmenu ? submenuTriggerKeys : triggerKeys;
|
|
60
60
|
|
|
@@ -70,6 +70,7 @@ export const useMenuItem = (props: MenuItemProps): MenuItemState => {
|
|
|
70
70
|
accessibilityRole: 'menuitem',
|
|
71
71
|
onAccessibilityTap: props.onAccessibilityTap || onInvoke,
|
|
72
72
|
accessibilityState: getAccessibilityState(disabled, accessibilityState),
|
|
73
|
+
disabled,
|
|
73
74
|
enableFocusRing: Platform.select({
|
|
74
75
|
macos: false,
|
|
75
76
|
default: !pressable.state.hovered, // win32
|
|
@@ -81,9 +82,11 @@ export const useMenuItem = (props: MenuItemProps): MenuItemState => {
|
|
|
81
82
|
ref: itemRef,
|
|
82
83
|
...onKeyDownProps,
|
|
83
84
|
},
|
|
84
|
-
state:
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
state: {
|
|
86
|
+
...pressable.state,
|
|
87
|
+
hasSubmenu,
|
|
88
|
+
hasCheckmarks,
|
|
89
|
+
},
|
|
87
90
|
};
|
|
88
91
|
};
|
|
89
92
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx withSlots */
|
|
2
|
-
import {
|
|
2
|
+
import { Pressable } from 'react-native';
|
|
3
3
|
import { SvgXml } from 'react-native-svg';
|
|
4
4
|
import { compose, mergeProps, Slots, UseSlots, withSlots } from '@fluentui-react-native/framework';
|
|
5
5
|
import { TextV1 as Text } from '@fluentui-react-native/text';
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
menuItemCheckboxName,
|
|
8
8
|
MenuItemCheckboxProps,
|
|
9
9
|
MenuItemCheckboxSlotProps,
|
|
10
|
-
|
|
10
|
+
MenuItemCheckboxInfo,
|
|
11
11
|
MenuItemCheckboxType,
|
|
12
12
|
} from './MenuItemCheckbox.types';
|
|
13
13
|
import { useMenuItemCheckbox } from './useMenuItemCheckbox';
|
|
@@ -19,7 +19,7 @@ export const MenuItemCheckbox = compose<MenuItemCheckboxType>({
|
|
|
19
19
|
displayName: menuItemCheckboxName,
|
|
20
20
|
...stylingSettings,
|
|
21
21
|
slots: {
|
|
22
|
-
root:
|
|
22
|
+
root: Pressable,
|
|
23
23
|
checkmark: SvgXml,
|
|
24
24
|
content: Text,
|
|
25
25
|
},
|
|
@@ -32,7 +32,7 @@ export const MenuItemCheckbox = compose<MenuItemCheckboxType>({
|
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
export const menuItemFinalRender = (
|
|
35
|
-
menuItem:
|
|
35
|
+
menuItem: MenuItemCheckboxInfo,
|
|
36
36
|
Slots: Slots<MenuItemCheckboxSlotProps>,
|
|
37
37
|
): React.FunctionComponent<MenuItemCheckboxProps> => {
|
|
38
38
|
return (final: MenuItemCheckboxProps, children: React.ReactNode) => {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ColorValue } from 'react-native';
|
|
3
3
|
import { XmlProps } from 'react-native-svg';
|
|
4
|
-
import type { IViewProps } from '@fluentui-react-native/adapters';
|
|
5
4
|
import { TextProps } from '@fluentui-react-native/text';
|
|
6
|
-
import {
|
|
5
|
+
import { PressablePropsExtended, PressableState } from '@fluentui-react-native/interactive-hooks';
|
|
7
6
|
import { MenuItemProps, MenuItemTokens } from '../MenuItem/MenuItem.types';
|
|
8
7
|
|
|
9
8
|
export const menuItemCheckboxName = 'MenuItemCheckbox';
|
|
@@ -41,11 +40,13 @@ export interface MenuItemCheckboxProps extends MenuItemProps {
|
|
|
41
40
|
*/
|
|
42
41
|
name: string;
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
export interface MenuItemCheckboxInfo {
|
|
44
|
+
props: MenuItemCheckboxProps & React.ComponentPropsWithRef<any>;
|
|
45
|
+
state: PressableState;
|
|
46
|
+
}
|
|
46
47
|
|
|
47
48
|
export interface MenuItemCheckboxSlotProps {
|
|
48
|
-
root: React.PropsWithRef<
|
|
49
|
+
root: React.PropsWithRef<PressablePropsExtended>;
|
|
49
50
|
checkmark?: XmlProps;
|
|
50
51
|
content?: TextProps;
|
|
51
52
|
}
|
|
@@ -2,7 +2,7 @@ export { MenuItemCheckbox } from './MenuItemCheckbox';
|
|
|
2
2
|
export { menuItemCheckboxName } from './MenuItemCheckbox.types';
|
|
3
3
|
export type {
|
|
4
4
|
MenuItemCheckboxProps,
|
|
5
|
-
|
|
5
|
+
MenuItemCheckboxInfo,
|
|
6
6
|
MenuItemCheckboxTokens,
|
|
7
7
|
MenuItemCheckboxSlotProps,
|
|
8
8
|
MenuItemCheckboxType,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { AccessibilityActionEvent, AccessibilityState, I18nManager, Platform } from 'react-native';
|
|
3
|
-
import { MenuItemCheckboxProps,
|
|
3
|
+
import { MenuItemCheckboxProps, MenuItemCheckboxInfo } from './MenuItemCheckbox.types';
|
|
4
4
|
import { memoize } from '@fluentui-react-native/framework';
|
|
5
5
|
import {
|
|
6
6
|
InteractionEvent,
|
|
7
7
|
KeyPressEvent,
|
|
8
|
-
|
|
8
|
+
usePressableState,
|
|
9
9
|
useKeyDownProps,
|
|
10
10
|
useOnPressWithFocus,
|
|
11
11
|
useViewCommandFocus,
|
|
@@ -16,7 +16,7 @@ import { useMenuContext } from '../context/menuContext';
|
|
|
16
16
|
|
|
17
17
|
const defaultAccessibilityActions = [{ name: 'Toggle' }];
|
|
18
18
|
|
|
19
|
-
export const useMenuItemCheckbox = (props: MenuItemCheckboxProps):
|
|
19
|
+
export const useMenuItemCheckbox = (props: MenuItemCheckboxProps): MenuItemCheckboxInfo => {
|
|
20
20
|
const { disabled, name } = props;
|
|
21
21
|
const context = useMenuListContext();
|
|
22
22
|
const checked = context.checked?.[name];
|
|
@@ -53,7 +53,7 @@ function getAccessibilityStateWorker(disabled: boolean, checked: boolean, access
|
|
|
53
53
|
export const useMenuCheckboxInteraction = (
|
|
54
54
|
props: MenuItemCheckboxProps,
|
|
55
55
|
toggleCallback: (e: InteractionEvent) => void,
|
|
56
|
-
):
|
|
56
|
+
): MenuItemCheckboxInfo => {
|
|
57
57
|
const defaultComponentRef = React.useRef(null);
|
|
58
58
|
const {
|
|
59
59
|
accessibilityActions,
|
|
@@ -74,7 +74,7 @@ export const useMenuCheckboxInteraction = (
|
|
|
74
74
|
// Ensure focus is placed on checkbox after click
|
|
75
75
|
const toggleCheckedWithFocus = useOnPressWithFocus(componentRef, toggleCallback);
|
|
76
76
|
|
|
77
|
-
const pressable =
|
|
77
|
+
const pressable = usePressableState({ ...rest, onPress: toggleCheckedWithFocus });
|
|
78
78
|
const buttonRef = useViewCommandFocus(componentRef);
|
|
79
79
|
|
|
80
80
|
const onKeysPressed = React.useCallback(
|
|
@@ -117,8 +117,8 @@ export const useMenuCheckboxInteraction = (
|
|
|
117
117
|
|
|
118
118
|
const state = {
|
|
119
119
|
...pressable.state,
|
|
120
|
-
disabled: !!props.disabled,
|
|
121
120
|
checked: isChecked,
|
|
121
|
+
disabled,
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
return {
|
|
@@ -129,6 +129,7 @@ export const useMenuCheckboxInteraction = (
|
|
|
129
129
|
accessibilityLabel,
|
|
130
130
|
accessibilityRole: 'menuitem',
|
|
131
131
|
accessibilityState: getAccessibilityState(disabled, state.checked, accessibilityState),
|
|
132
|
+
disabled,
|
|
132
133
|
enableFocusRing: Platform.select({
|
|
133
134
|
macos: false,
|
|
134
135
|
default: !pressable.state.hovered, // win32
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { InteractionEvent } from '@fluentui-react-native/interactive-hooks';
|
|
3
3
|
import { useMenuListContext } from '../context/menuListContext';
|
|
4
|
-
import { MenuItemCheckboxProps,
|
|
4
|
+
import { MenuItemCheckboxProps, MenuItemCheckboxInfo } from '../MenuItemCheckbox/MenuItemCheckbox.types';
|
|
5
5
|
import { useMenuCheckboxInteraction } from '../MenuItemCheckbox/useMenuItemCheckbox';
|
|
6
6
|
import { useMenuContext } from '../context/menuContext';
|
|
7
7
|
|
|
8
|
-
export const useMenuItemRadio = (props: MenuItemCheckboxProps):
|
|
8
|
+
export const useMenuItemRadio = (props: MenuItemCheckboxProps): MenuItemCheckboxInfo => {
|
|
9
9
|
const { disabled, name, persistOnClick } = props;
|
|
10
10
|
const context = useMenuContext();
|
|
11
11
|
const listContext = useMenuListContext();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { menuTriggerName
|
|
2
|
+
import { stagedComponent } from '@fluentui-react-native/framework';
|
|
3
|
+
import { menuTriggerName } from './MenuTrigger.types';
|
|
4
4
|
import { useMenuTrigger } from './useMenuTrigger';
|
|
5
|
-
import { AccessibilityActionEvent } from 'react-native';
|
|
6
5
|
import { MenuTriggerProvider } from '../context/menuTriggerContext';
|
|
6
|
+
import { getRevisedProps } from './getRevisedProps';
|
|
7
7
|
|
|
8
8
|
export const MenuTrigger = stagedComponent((_props: React.PropsWithChildren<Record<never, any>>) => {
|
|
9
9
|
const menuTrigger = useMenuTrigger();
|
|
@@ -29,25 +29,4 @@ export const MenuTrigger = stagedComponent((_props: React.PropsWithChildren<Reco
|
|
|
29
29
|
});
|
|
30
30
|
MenuTrigger.displayName = menuTriggerName;
|
|
31
31
|
|
|
32
|
-
const getRevisedProps = memoize(getRevisedPropsWorker);
|
|
33
|
-
function getRevisedPropsWorker(state: MenuTriggerState, props: any): MenuTriggerChildProps {
|
|
34
|
-
const revisedProps = state.props;
|
|
35
|
-
if (props.accessibilityState) {
|
|
36
|
-
revisedProps.accessibilityState = { ...revisedProps.accessibilityState, ...props.accessibilityState };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (props.accessibilityActions) {
|
|
40
|
-
revisedProps.accessibilityActions = [...revisedProps.accessibilityActions, ...props.accessibilityActions];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (props.onAccessibilityAction) {
|
|
44
|
-
revisedProps.onAccessibilityAction = (e: AccessibilityActionEvent) => {
|
|
45
|
-
revisedProps.onAccessibilityAction(e);
|
|
46
|
-
props.onAccessibilityAction(e);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return revisedProps;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
32
|
export default MenuTrigger;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AccessibilityActionEvent } from 'react-native';
|
|
2
|
+
import { memoize } from '@fluentui-react-native/framework';
|
|
3
|
+
import { InteractionEvent, isMouseEvent } from '@fluentui-react-native/interactive-hooks';
|
|
4
|
+
import { MenuTriggerChildProps, MenuTriggerState } from './MenuTrigger.types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a merged set of props between the MenuTrigger's child component's props
|
|
8
|
+
* and the props that the MenuTrigger wants its child to have.
|
|
9
|
+
*
|
|
10
|
+
* Because children are not accessible in the outer render, we deal with the merge in this function.
|
|
11
|
+
*/
|
|
12
|
+
export const getRevisedProps = memoize(getRevisedPropsWorker);
|
|
13
|
+
function getRevisedPropsWorker(state: MenuTriggerState, props: any): MenuTriggerChildProps {
|
|
14
|
+
const revisedProps = { ...state.props };
|
|
15
|
+
if (props.accessibilityState) {
|
|
16
|
+
revisedProps.accessibilityState = { ...state.props.accessibilityState, ...props.accessibilityState };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (props.accessibilityActions) {
|
|
20
|
+
revisedProps.accessibilityActions = [...state.props.accessibilityActions, ...props.accessibilityActions];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (props.onAccessibilityAction) {
|
|
24
|
+
revisedProps.onAccessibilityAction = (e: AccessibilityActionEvent) => {
|
|
25
|
+
state.props.onAccessibilityAction(e);
|
|
26
|
+
props.onAccessibilityAction(e);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (props.onClick) {
|
|
31
|
+
revisedProps.onClick = (e: InteractionEvent) => {
|
|
32
|
+
state.props.onClick(e);
|
|
33
|
+
props.onClick(e);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let onHoverIn = undefined;
|
|
38
|
+
if (props.onHoverIn) {
|
|
39
|
+
onHoverIn = (e: InteractionEvent) => {
|
|
40
|
+
state.props.onHoverIn(isMouseEvent(e) && e);
|
|
41
|
+
props.onHoverIn(e);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let onHoverOut = undefined;
|
|
46
|
+
if (props.onHoverOut) {
|
|
47
|
+
onHoverOut = (e: InteractionEvent) => {
|
|
48
|
+
state.props.onHoverOut(isMouseEvent(e) && e);
|
|
49
|
+
props.onHoverOut(e);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return { ...revisedProps, onHoverIn, onHoverOut };
|
|
54
|
+
}
|
|
@@ -171,13 +171,13 @@ Array [
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
accessible={true}
|
|
174
|
+
collapsable={false}
|
|
174
175
|
enableFocusRing={true}
|
|
175
176
|
focusable={true}
|
|
176
177
|
onAccessibilityTap={[Function]}
|
|
177
178
|
onBlur={[Function]}
|
|
178
179
|
onClick={[Function]}
|
|
179
180
|
onFocus={[Function]}
|
|
180
|
-
onPress={[Function]}
|
|
181
181
|
onResponderGrant={[Function]}
|
|
182
182
|
onResponderMove={[Function]}
|
|
183
183
|
onResponderRelease={[Function]}
|
|
@@ -224,14 +224,13 @@ Array [
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
accessible={true}
|
|
227
|
-
|
|
227
|
+
collapsable={false}
|
|
228
228
|
enableFocusRing={true}
|
|
229
229
|
focusable={true}
|
|
230
230
|
onAccessibilityTap={[Function]}
|
|
231
231
|
onBlur={[Function]}
|
|
232
232
|
onClick={[Function]}
|
|
233
233
|
onFocus={[Function]}
|
|
234
|
-
onPress={[Function]}
|
|
235
234
|
onResponderGrant={[Function]}
|
|
236
235
|
onResponderMove={[Function]}
|
|
237
236
|
onResponderRelease={[Function]}
|
|
@@ -388,13 +387,13 @@ Array [
|
|
|
388
387
|
}
|
|
389
388
|
}
|
|
390
389
|
accessible={true}
|
|
390
|
+
collapsable={false}
|
|
391
391
|
enableFocusRing={true}
|
|
392
392
|
focusable={true}
|
|
393
393
|
onAccessibilityTap={[Function]}
|
|
394
394
|
onBlur={[Function]}
|
|
395
395
|
onClick={[Function]}
|
|
396
396
|
onFocus={[Function]}
|
|
397
|
-
onPress={[Function]}
|
|
398
397
|
onResponderGrant={[Function]}
|
|
399
398
|
onResponderMove={[Function]}
|
|
400
399
|
onResponderRelease={[Function]}
|
|
@@ -558,13 +557,13 @@ Array [
|
|
|
558
557
|
}
|
|
559
558
|
}
|
|
560
559
|
accessible={true}
|
|
560
|
+
collapsable={false}
|
|
561
561
|
enableFocusRing={true}
|
|
562
562
|
focusable={true}
|
|
563
563
|
onAccessibilityAction={[Function]}
|
|
564
564
|
onBlur={[Function]}
|
|
565
565
|
onClick={[Function]}
|
|
566
566
|
onFocus={[Function]}
|
|
567
|
-
onPress={[Function]}
|
|
568
567
|
onResponderGrant={[Function]}
|
|
569
568
|
onResponderMove={[Function]}
|
|
570
569
|
onResponderRelease={[Function]}
|
|
@@ -683,14 +682,13 @@ Array [
|
|
|
683
682
|
}
|
|
684
683
|
}
|
|
685
684
|
accessible={true}
|
|
686
|
-
|
|
685
|
+
collapsable={false}
|
|
687
686
|
enableFocusRing={true}
|
|
688
687
|
focusable={true}
|
|
689
688
|
onAccessibilityAction={[Function]}
|
|
690
689
|
onBlur={[Function]}
|
|
691
690
|
onClick={[Function]}
|
|
692
691
|
onFocus={[Function]}
|
|
693
|
-
onPress={[Function]}
|
|
694
692
|
onResponderGrant={[Function]}
|
|
695
693
|
onResponderMove={[Function]}
|
|
696
694
|
onResponderRelease={[Function]}
|
|
@@ -907,13 +905,13 @@ Array [
|
|
|
907
905
|
}
|
|
908
906
|
}
|
|
909
907
|
accessible={true}
|
|
908
|
+
collapsable={false}
|
|
910
909
|
enableFocusRing={true}
|
|
911
910
|
focusable={true}
|
|
912
911
|
onAccessibilityAction={[Function]}
|
|
913
912
|
onBlur={[Function]}
|
|
914
913
|
onClick={[Function]}
|
|
915
914
|
onFocus={[Function]}
|
|
916
|
-
onPress={[Function]}
|
|
917
915
|
onResponderGrant={[Function]}
|
|
918
916
|
onResponderMove={[Function]}
|
|
919
917
|
onResponderRelease={[Function]}
|
|
@@ -1032,13 +1030,13 @@ Array [
|
|
|
1032
1030
|
}
|
|
1033
1031
|
}
|
|
1034
1032
|
accessible={true}
|
|
1033
|
+
collapsable={false}
|
|
1035
1034
|
enableFocusRing={true}
|
|
1036
1035
|
focusable={true}
|
|
1037
1036
|
onAccessibilityAction={[Function]}
|
|
1038
1037
|
onBlur={[Function]}
|
|
1039
1038
|
onClick={[Function]}
|
|
1040
1039
|
onFocus={[Function]}
|
|
1041
|
-
onPress={[Function]}
|
|
1042
1040
|
onResponderGrant={[Function]}
|
|
1043
1041
|
onResponderMove={[Function]}
|
|
1044
1042
|
onResponderRelease={[Function]}
|
|
@@ -1255,13 +1253,13 @@ Array [
|
|
|
1255
1253
|
}
|
|
1256
1254
|
}
|
|
1257
1255
|
accessible={true}
|
|
1256
|
+
collapsable={false}
|
|
1258
1257
|
enableFocusRing={true}
|
|
1259
1258
|
focusable={true}
|
|
1260
1259
|
onAccessibilityAction={[Function]}
|
|
1261
1260
|
onBlur={[Function]}
|
|
1262
1261
|
onClick={[Function]}
|
|
1263
1262
|
onFocus={[Function]}
|
|
1264
|
-
onPress={[Function]}
|
|
1265
1263
|
onResponderGrant={[Function]}
|
|
1266
1264
|
onResponderMove={[Function]}
|
|
1267
1265
|
onResponderRelease={[Function]}
|
|
@@ -1380,13 +1378,13 @@ Array [
|
|
|
1380
1378
|
}
|
|
1381
1379
|
}
|
|
1382
1380
|
accessible={true}
|
|
1381
|
+
collapsable={false}
|
|
1383
1382
|
enableFocusRing={true}
|
|
1384
1383
|
focusable={true}
|
|
1385
1384
|
onAccessibilityAction={[Function]}
|
|
1386
1385
|
onBlur={[Function]}
|
|
1387
1386
|
onClick={[Function]}
|
|
1388
1387
|
onFocus={[Function]}
|
|
1389
|
-
onPress={[Function]}
|
|
1390
1388
|
onResponderGrant={[Function]}
|
|
1391
1389
|
onResponderMove={[Function]}
|
|
1392
1390
|
onResponderRelease={[Function]}
|
|
@@ -1603,13 +1601,13 @@ Array [
|
|
|
1603
1601
|
}
|
|
1604
1602
|
}
|
|
1605
1603
|
accessible={true}
|
|
1604
|
+
collapsable={false}
|
|
1606
1605
|
enableFocusRing={true}
|
|
1607
1606
|
focusable={true}
|
|
1608
1607
|
onAccessibilityAction={[Function]}
|
|
1609
1608
|
onBlur={[Function]}
|
|
1610
1609
|
onClick={[Function]}
|
|
1611
1610
|
onFocus={[Function]}
|
|
1612
|
-
onPress={[Function]}
|
|
1613
1611
|
onResponderGrant={[Function]}
|
|
1614
1612
|
onResponderMove={[Function]}
|
|
1615
1613
|
onResponderRelease={[Function]}
|
|
@@ -1716,13 +1714,13 @@ Array [
|
|
|
1716
1714
|
}
|
|
1717
1715
|
}
|
|
1718
1716
|
accessible={true}
|
|
1717
|
+
collapsable={false}
|
|
1719
1718
|
enableFocusRing={true}
|
|
1720
1719
|
focusable={true}
|
|
1721
1720
|
onAccessibilityAction={[Function]}
|
|
1722
1721
|
onBlur={[Function]}
|
|
1723
1722
|
onClick={[Function]}
|
|
1724
1723
|
onFocus={[Function]}
|
|
1725
|
-
onPress={[Function]}
|
|
1726
1724
|
onResponderGrant={[Function]}
|
|
1727
1725
|
onResponderMove={[Function]}
|
|
1728
1726
|
onResponderRelease={[Function]}
|
|
@@ -1931,13 +1929,13 @@ Array [
|
|
|
1931
1929
|
}
|
|
1932
1930
|
}
|
|
1933
1931
|
accessible={true}
|
|
1932
|
+
collapsable={false}
|
|
1934
1933
|
enableFocusRing={true}
|
|
1935
1934
|
focusable={true}
|
|
1936
1935
|
onAccessibilityTap={[Function]}
|
|
1937
1936
|
onBlur={[Function]}
|
|
1938
1937
|
onClick={[Function]}
|
|
1939
1938
|
onFocus={[Function]}
|
|
1940
|
-
onPress={[Function]}
|
|
1941
1939
|
onResponderGrant={[Function]}
|
|
1942
1940
|
onResponderMove={[Function]}
|
|
1943
1941
|
onResponderRelease={[Function]}
|
|
@@ -1986,6 +1984,7 @@ Array [
|
|
|
1986
1984
|
}
|
|
1987
1985
|
}
|
|
1988
1986
|
accessible={true}
|
|
1987
|
+
collapsable={false}
|
|
1989
1988
|
enableFocusRing={true}
|
|
1990
1989
|
focusable={true}
|
|
1991
1990
|
onAccessibilityAction={[Function]}
|
|
@@ -1993,9 +1992,6 @@ Array [
|
|
|
1993
1992
|
onBlur={[Function]}
|
|
1994
1993
|
onClick={[Function]}
|
|
1995
1994
|
onFocus={[Function]}
|
|
1996
|
-
onHoverIn={[Function]}
|
|
1997
|
-
onHoverOut={[Function]}
|
|
1998
|
-
onPress={[Function]}
|
|
1999
1995
|
onResponderGrant={[Function]}
|
|
2000
1996
|
onResponderMove={[Function]}
|
|
2001
1997
|
onResponderRelease={[Function]}
|
package/src/index.ts
CHANGED
|
@@ -18,8 +18,9 @@ export {
|
|
|
18
18
|
MenuItem,
|
|
19
19
|
menuItemName,
|
|
20
20
|
MenuItemProps,
|
|
21
|
-
MenuItemSlotProps,
|
|
22
21
|
MenuItemState,
|
|
22
|
+
MenuItemInfo,
|
|
23
|
+
MenuItemSlotProps,
|
|
23
24
|
MenuItemTokens,
|
|
24
25
|
MenuItemType,
|
|
25
26
|
useMenuItem,
|
|
@@ -28,8 +29,8 @@ export {
|
|
|
28
29
|
MenuItemCheckbox,
|
|
29
30
|
menuItemCheckboxName,
|
|
30
31
|
MenuItemCheckboxProps,
|
|
32
|
+
MenuItemCheckboxInfo,
|
|
31
33
|
MenuItemCheckboxSlotProps,
|
|
32
|
-
MenuItemCheckboxState,
|
|
33
34
|
MenuItemCheckboxTokens,
|
|
34
35
|
MenuItemCheckboxType,
|
|
35
36
|
useMenuCheckboxInteraction,
|