@fluentui-react-native/menu 0.14.8 → 0.15.2

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.
Files changed (78) hide show
  1. package/CHANGELOG.json +46 -1
  2. package/CHANGELOG.md +26 -2
  3. package/lib/Menu/Menu.types.d.ts +13 -0
  4. package/lib/Menu/Menu.types.d.ts.map +1 -1
  5. package/lib/MenuItem/MenuItem.d.ts +2 -0
  6. package/lib/MenuItem/MenuItem.d.ts.map +1 -1
  7. package/lib/MenuItem/MenuItem.js +18 -6
  8. package/lib/MenuItem/MenuItem.js.map +1 -1
  9. package/lib/MenuItem/MenuItem.types.d.ts +15 -5
  10. package/lib/MenuItem/MenuItem.types.d.ts.map +1 -1
  11. package/lib/MenuItem/useMenuItem.d.ts.map +1 -1
  12. package/lib/MenuItem/useMenuItem.js +1 -1
  13. package/lib/MenuItem/useMenuItem.js.map +1 -1
  14. package/lib/MenuItemCheckbox/MenuItemCheckbox.d.ts +1 -0
  15. package/lib/MenuItemCheckbox/MenuItemCheckbox.d.ts.map +1 -1
  16. package/lib/MenuItemCheckbox/MenuItemCheckbox.js +7 -5
  17. package/lib/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
  18. package/lib/MenuItemCheckbox/MenuItemCheckbox.types.d.ts +18 -5
  19. package/lib/MenuItemCheckbox/MenuItemCheckbox.types.d.ts.map +1 -1
  20. package/lib/MenuItemCheckbox/useMenuItemCheckbox.d.ts.map +1 -1
  21. package/lib/MenuItemCheckbox/useMenuItemCheckbox.js +2 -2
  22. package/lib/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
  23. package/lib/MenuList/MenuList.types.d.ts +17 -0
  24. package/lib/MenuList/MenuList.types.d.ts.map +1 -1
  25. package/lib/MenuTrigger/useMenuTrigger.d.ts.map +1 -1
  26. package/lib/MenuTrigger/useMenuTrigger.js +6 -6
  27. package/lib/MenuTrigger/useMenuTrigger.js.map +1 -1
  28. package/lib/__tests__/Menu.test.js +18 -18
  29. package/lib/__tests__/Menu.test.js.map +1 -1
  30. package/lib/consts.d.ts +1 -1
  31. package/lib/consts.d.ts.map +1 -1
  32. package/lib/consts.js +1 -1
  33. package/lib/consts.js.map +1 -1
  34. package/lib-commonjs/Menu/Menu.types.d.ts +13 -0
  35. package/lib-commonjs/Menu/Menu.types.d.ts.map +1 -1
  36. package/lib-commonjs/MenuItem/MenuItem.d.ts +2 -0
  37. package/lib-commonjs/MenuItem/MenuItem.d.ts.map +1 -1
  38. package/lib-commonjs/MenuItem/MenuItem.js +17 -5
  39. package/lib-commonjs/MenuItem/MenuItem.js.map +1 -1
  40. package/lib-commonjs/MenuItem/MenuItem.types.d.ts +15 -5
  41. package/lib-commonjs/MenuItem/MenuItem.types.d.ts.map +1 -1
  42. package/lib-commonjs/MenuItem/useMenuItem.d.ts.map +1 -1
  43. package/lib-commonjs/MenuItem/useMenuItem.js +1 -1
  44. package/lib-commonjs/MenuItem/useMenuItem.js.map +1 -1
  45. package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.d.ts +1 -0
  46. package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.d.ts.map +1 -1
  47. package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.js +6 -4
  48. package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.js.map +1 -1
  49. package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.types.d.ts +18 -5
  50. package/lib-commonjs/MenuItemCheckbox/MenuItemCheckbox.types.d.ts.map +1 -1
  51. package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.d.ts.map +1 -1
  52. package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.js +2 -2
  53. package/lib-commonjs/MenuItemCheckbox/useMenuItemCheckbox.js.map +1 -1
  54. package/lib-commonjs/MenuList/MenuList.types.d.ts +17 -0
  55. package/lib-commonjs/MenuList/MenuList.types.d.ts.map +1 -1
  56. package/lib-commonjs/MenuTrigger/useMenuTrigger.d.ts.map +1 -1
  57. package/lib-commonjs/MenuTrigger/useMenuTrigger.js +5 -5
  58. package/lib-commonjs/MenuTrigger/useMenuTrigger.js.map +1 -1
  59. package/lib-commonjs/__tests__/Menu.test.js +18 -18
  60. package/lib-commonjs/__tests__/Menu.test.js.map +1 -1
  61. package/lib-commonjs/consts.d.ts +1 -1
  62. package/lib-commonjs/consts.d.ts.map +1 -1
  63. package/lib-commonjs/consts.js +2 -2
  64. package/lib-commonjs/consts.js.map +1 -1
  65. package/package.json +1 -1
  66. package/src/Menu/Menu.types.ts +20 -0
  67. package/src/MenuItem/MenuItem.tsx +22 -5
  68. package/src/MenuItem/MenuItem.types.ts +18 -7
  69. package/src/MenuItem/useMenuItem.ts +0 -1
  70. package/src/MenuItemCheckbox/MenuItemCheckbox.tsx +8 -4
  71. package/src/MenuItemCheckbox/MenuItemCheckbox.types.ts +22 -7
  72. package/src/MenuItemCheckbox/useMenuItemCheckbox.ts +2 -1
  73. package/src/MenuList/MenuList.types.ts +20 -0
  74. package/src/MenuTrigger/useMenuTrigger.ts +15 -6
  75. package/src/__tests__/Menu.test.tsx +20 -18
  76. package/src/__tests__/__snapshots__/Menu.test.tsx.snap +0 -13
  77. package/src/consts.ts +1 -1
  78. package/SPEC.md +0 -344
@@ -178,7 +178,6 @@ Array [
178
178
  }
179
179
  }
180
180
  accessible={true}
181
- content="Option 1"
182
181
  enableFocusRing={true}
183
182
  focusable={true}
184
183
  onAccessibilityTap={[Function]}
@@ -232,7 +231,6 @@ Array [
232
231
  }
233
232
  }
234
233
  accessible={true}
235
- content="Option 2"
236
234
  disabled={true}
237
235
  enableFocusRing={true}
238
236
  focusable={true}
@@ -400,7 +398,6 @@ Array [
400
398
  }
401
399
  }
402
400
  accessible={true}
403
- content="Option 1"
404
401
  enableFocusRing={true}
405
402
  focusable={true}
406
403
  onAccessibilityTap={[Function]}
@@ -574,7 +571,6 @@ Array [
574
571
  }
575
572
  }
576
573
  accessible={true}
577
- content="Option 1"
578
574
  enableFocusRing={true}
579
575
  focusable={true}
580
576
  onAccessibilityAction={[Function]}
@@ -700,7 +696,6 @@ Array [
700
696
  }
701
697
  }
702
698
  accessible={true}
703
- content="Option 2"
704
699
  disabled={true}
705
700
  enableFocusRing={true}
706
701
  focusable={true}
@@ -928,7 +923,6 @@ Array [
928
923
  }
929
924
  }
930
925
  accessible={true}
931
- content="Option 1"
932
926
  enableFocusRing={true}
933
927
  focusable={true}
934
928
  onAccessibilityAction={[Function]}
@@ -1054,7 +1048,6 @@ Array [
1054
1048
  }
1055
1049
  }
1056
1050
  accessible={true}
1057
- content="Option 2"
1058
1051
  enableFocusRing={true}
1059
1052
  focusable={true}
1060
1053
  onAccessibilityAction={[Function]}
@@ -1281,7 +1274,6 @@ Array [
1281
1274
  }
1282
1275
  }
1283
1276
  accessible={true}
1284
- content="Option 1"
1285
1277
  enableFocusRing={true}
1286
1278
  focusable={true}
1287
1279
  onAccessibilityAction={[Function]}
@@ -1407,7 +1399,6 @@ Array [
1407
1399
  }
1408
1400
  }
1409
1401
  accessible={true}
1410
- content="Option 2"
1411
1402
  enableFocusRing={true}
1412
1403
  focusable={true}
1413
1404
  onAccessibilityAction={[Function]}
@@ -1634,7 +1625,6 @@ Array [
1634
1625
  }
1635
1626
  }
1636
1627
  accessible={true}
1637
- content="Option 1"
1638
1628
  enableFocusRing={true}
1639
1629
  focusable={true}
1640
1630
  onAccessibilityAction={[Function]}
@@ -1748,7 +1738,6 @@ Array [
1748
1738
  }
1749
1739
  }
1750
1740
  accessible={true}
1751
- content="Option 2"
1752
1741
  enableFocusRing={true}
1753
1742
  focusable={true}
1754
1743
  onAccessibilityAction={[Function]}
@@ -1967,7 +1956,6 @@ Array [
1967
1956
  }
1968
1957
  }
1969
1958
  accessible={true}
1970
- content="Option 1"
1971
1959
  enableFocusRing={true}
1972
1960
  focusable={true}
1973
1961
  onAccessibilityTap={[Function]}
@@ -2023,7 +2011,6 @@ Array [
2023
2011
  }
2024
2012
  }
2025
2013
  accessible={true}
2026
- content="Option 2"
2027
2014
  enableFocusRing={true}
2028
2015
  focusable={true}
2029
2016
  onAccessibilityAction={[Function]}
package/src/consts.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Platform } from 'react-native';
2
2
 
3
- export const delayHover = Platform.select({
3
+ export const hoverDelayDefault = Platform.select({
4
4
  macos: 100,
5
5
  default: 500, // win32
6
6
  });
package/SPEC.md DELETED
@@ -1,344 +0,0 @@
1
- # Menu
2
-
3
- ## Background
4
-
5
- A `Menu` is an component that displays a list of options on a temporary surface. They are invoked when users interact with a button, action, or other control.
6
-
7
- ## Requirements
8
-
9
- If using FURN's theming, the `Menu` and its sub-components require use of the `ThemeProvider` from `@fluentui-react-native/theme` to work properly with themes. Please see [this page](../../../docs/pages/Guides/UpdateThemeProvider.md) for information on updating your `ThemeProvider` if using the version from `@uifabricshared/theming-react-native`.
10
-
11
- ## Sample code
12
-
13
- The below samples do not represent the definitive props of the final implemented component, but represent the ideal final implementations. Can be subject to change during the implementation phase.
14
-
15
- ### Basic Menu
16
-
17
- ```tsx
18
- const menu = (
19
- <Menu>
20
- <MenuTrigger><Button>Open menu</Button></MenuTrigger>
21
- <MenuPopover>
22
- <MenuList>
23
- <MenuItem>Option 1</MenuItem>
24
- <MenuItem>Option 2</MenuItem>
25
- <MenuItem>Option 3</MenuItem>
26
- </MenuList>
27
- </MenuPopover>
28
- <Menu>
29
- )
30
- ```
31
-
32
- ### Submenus
33
-
34
- ```tsx
35
- const menu = (
36
- <Menu>
37
- <MenuTrigger><Button>Open menu</Button></MenuTrigger>
38
- <MenuPopover>
39
- <MenuList>
40
- <MenuItem>Option 1</MenuItem>
41
- <Menu>
42
- <MenuTrigger>
43
- <MenuItem>Open submenu</MenuItem>
44
- </MenuTrigger>
45
- <MenuPopover>
46
- <MenuList>
47
- <MenuItem>Option 1</MenuItem>
48
- <MenuItem>Option 2</MenuItem>
49
- <MenuItem>Option 3</MenuItem>
50
- </MenuList>
51
- </MenuPopover>
52
- </Menu>
53
- </MenuList>
54
- </MenuPopover>
55
- <Menu>
56
- )
57
- ```
58
-
59
- ### Selection
60
-
61
- ```tsx
62
- const [selectedItems, setSelectedItems] = React.useState([]);
63
- const menuCheckbox = (
64
- <Menu
65
- selectedItems={selectedItems}
66
- onSelectionChange={setSeelctedItems}
67
- >
68
- <MenuTrigger><Button>Open menu</Button></MenuTrigger>
69
- <MenuPopover>
70
- <MenuList>
71
- <MenuItemCheckbox name="checkbox1">Option 1</MenuItemCheckbox>
72
- <MenuItemCheckbox name="checkbox2">Option 2</MenuItemCheckbox>
73
- <MenuItemCheckbox name="checkbox3">Option 3</MenuItemCheckbox>
74
- </MenuList>
75
- </MenuPopover>
76
- <Menu>
77
- )
78
- ```
79
-
80
- ## Visual Examples
81
-
82
- Coming soon
83
-
84
- ## Variants
85
-
86
- ### Nested menus
87
-
88
- A `Menu` should be able to trigger a submenu, or an additional instance of `Menu`, as a part of one or more of its options. The nested `Menu` component should have the same functional capabilities as the root `Menu` component, however it will have some default behavioral differences.
89
-
90
- Nested menus are by default triggered by hovering over a trigger, but can also be opened by invoking the trigger component for the nested `Menu`.
91
-
92
- ### Selection state
93
-
94
- A `Menu` should be able to track and represent the selection, or checked, state of its options.
95
-
96
- When an option has a configurable selection state, it does not dismiss the `Menu` when toggled, as opposed to other options which close the `Menu` on being invoked by default.
97
-
98
- ### Sections
99
-
100
- A `Menu` can be divided into sections using dividers. The `Menu` does not support `MenuGroups` yet, but can visually represent sections using `MenuDividers`.
101
-
102
- ### Disabled option(s)
103
-
104
- All options in a `Menu` component can be disabled and should provide a visible indication for this purpose. Although disabled actions cannot be invoked, they are keyboard focusable for the purposes of accessibility.
105
-
106
- ## API
107
-
108
- ### Menu
109
-
110
- The root level component serves as a simplified interface for configuring the triggering of a Menu.
111
-
112
- ```ts
113
- export interface MenuProps extends MenuListProps {
114
- /**
115
- * Whether the popup is open
116
- */
117
- open?: boolean;
118
-
119
- /**
120
- * Call back when the component requests to change value
121
- */
122
- onOpenChange?: (e: InteractionEvent, isOpen: boolean) => void;
123
-
124
- /**
125
- * Whether the popup is open by default
126
- */
127
- defaultOpen?: boolean;
128
-
129
- /*
130
- * Opens the menu on hover
131
- */
132
- openOnHover?: boolean;
133
- }
134
- ```
135
-
136
- ### MenuTrigger
137
-
138
- A non-visual component that wraps its child and configures them to be the trigger that will open a menu. This component should only accept one child. Accepts no other props.
139
-
140
- ### MenuPopover
141
-
142
- This component provides the temporary surface that will host the `Menu`'s options.
143
-
144
- ```ts
145
- export type MenuPopoverProps = ICalloutProps;
146
- ```
147
-
148
- ### MenuList
149
-
150
- This component is used internally by `Menu` and manages the context and layout of its items.
151
-
152
- #### MenuList Props
153
-
154
- ```ts
155
- export type MenuListProps = {
156
- /**
157
- * Callback when checked items change for value with a name
158
- *
159
- * @param checked Array of all checked values
160
- */
161
- onCheckedChange?: (e: InteractionEvent, checked[]) => void;
162
-
163
- /**
164
- * Array of all checked items
165
- */
166
- checked?: string[];
167
-
168
- /**
169
- * Default items to be checked on mount
170
- */
171
- defaultChecked?: string[];
172
-
173
- /**
174
- * States that menu items can contain selectable items and reserve slots for item alignment
175
- */
176
- hasCheckmarks?: boolean;
177
- };
178
- ```
179
-
180
- #### MenuList Tokens
181
-
182
- ```ts
183
- export interface MenuListTokens extends LayoutTokens, IBackgroundColorTokens {
184
- /**
185
- * Space between items in pixels
186
- */
187
- gap?: number;
188
- }
189
- ```
190
-
191
- #### MenuList Slots
192
-
193
- - `root` - The container of the `Menu`'s options that wraps all `children`.
194
-
195
- ### MenuDivider
196
-
197
- Creates a divider element in the `MenuList`. This divider is purely visual and does not handle any grouping logic of the options in the `MenuList`.
198
-
199
- ### MenuItem
200
-
201
- #### MenuItem Props
202
-
203
- ```ts
204
- export interface MenuItemProps extends Omit<IWithPressableOptions<ViewProps>, 'onPress'> {
205
- /**
206
- * Text to show for the item
207
- */
208
- content: string;
209
-
210
- /**
211
- * A RefObject to access the IButton interface. Use this to access the public methods and properties of the component.
212
- */
213
- componentRef?: React.RefObject<IFocusable>;
214
-
215
- /**
216
- * A callback to call on button click event
217
- */
218
- onClick?: (e: InteractionEvent) => void;
219
- }
220
- ```
221
-
222
- #### MenuItem Tokens
223
-
224
- ```ts
225
- export interface MenuItemTokens extends LayoutTokens, FontTokens, IBorderTokens, IColorTokens {
226
- checkmarkSize?: number;
227
- submenuIndicatorPadding?: number;
228
- submenuIndicatorSize?: number;
229
- gap?: number;
230
-
231
- disabled?: MenuItemTokens;
232
- focused?: MenuItemTokens;
233
- hovered?: MenuItemTokens;
234
- pressed?: MenuItemTokens;
235
- }
236
- ```
237
-
238
- #### MenuItem Slots
239
-
240
- - `root` - The outer container representing the `MenuItem` itself that wraps everything passed via the `children` prop.
241
- - `content` - If specified, renders the `content` prop as text.
242
- - `checkmark` - If specified, renders space such that the `content` aligns with other items which have checkmarks. Only used when the `Menu` has `hasCheckmarks`.
243
- - `submenuIndicator` - If specified, renders an SVG which indicates that the `MenuItem` is a trigger for a nested `Menu`.
244
-
245
- ### MenuItemCheckbox/Radio
246
-
247
- Variants of `MenuItem` that allows a single or multiple selection state based on the value that it represents. These `MenuItems` do not support submenus. `MenuItemCheckbox` and `MenuItemRadio` share the same types for props, tokens, and slots.
248
-
249
- #### MenuItemCheckbox/Radio Props
250
-
251
- ```ts
252
- export interface MenuItemCheckboxProps extends Omit<IWithPressableOptions<ViewProps>, 'onPress'> {
253
- content: string;
254
-
255
- /**
256
- * Applies disabled styles to menu item but remains focusable
257
- */
258
- disabled?: boolean;
259
-
260
- /**
261
- * A RefObject to access the IButton interface. Use this to access the public methods and properties of the component.
262
- */
263
- componentRef?: React.RefObject<IFocusable>;
264
-
265
- /**
266
- * Identifier for the control
267
- */
268
- name: string;
269
- }
270
- ```
271
-
272
- #### MenuItemCheckbox/Radio Tokens
273
-
274
- ```ts
275
- export interface MenuItemCheckboxTokens extends LayoutTokens, FontTokens, IBorderTokens, IColorTokens {
276
- checkmarkColor?: ColorValue;
277
- checkmarkPadding?: number;
278
- checkmarkSize?: number;
279
- checkmarkVisibility?: number;
280
- gap?: number;
281
-
282
- checked?: MenuItemCheckboxTokens;
283
- disabled?: MenuItemCheckboxTokens;
284
- focused?: MenuItemCheckboxTokens;
285
- hovered?: MenuItemCheckboxTokens;
286
- pressed?: MenuItemCheckboxTokens;
287
- }
288
- ```
289
-
290
- #### MenuItemCheckbox/Radio Slots
291
-
292
- - `root` - The outer container representing the `MenuItem` itself that wraps everything passed via the `children` prop.
293
- - `content` - If specified, renders the `content` prop as text.
294
- - `checkmark` - If specified, renders an SVG which indicates that the `MenuItem` is selected.
295
-
296
- ## Behaviors
297
-
298
- ### Mouse interactions
299
-
300
- - Clicking on a menu's trigger will open the menu
301
- - Clicking outside of a menu's trigger and popover will light dismiss the menu
302
- - Clicking on a `MenuItem` which is not configured to track selection will invoke the `MenuItem` and close the menu by default
303
- - Clicking on a `MenuItem` variant which is configured to track selection will toggle its selection state in the configured way and not close the menu.
304
- - If the menu is configured to open on hover, it will only close once the mouse leaves both the trigger and the popover. There is a delay for this behavior.
305
- - Submenus are configured to open on hover by default. If the mouse stops hovering over the submenu, only the submenu will close.
306
-
307
- ### Keyboard interactions
308
-
309
- - When a menu is invoked via keyboard, open the menu and place focus on the first focusable element by default.
310
- - Up and down inside of the menu that has focus should navigate vertically between keyboard focusable elements
311
- - On win32, up and down should circularly navigate through a list of menu items. On MacOS, circular navigation does not occur.
312
- - Right key on a menu item that has an available submenu or split button should invoke the submenu, and move focus into it onto the first focusable item (Left in RTL)
313
- - Left key when in a submenu should close the submenu and place focus back on the parent menu's item that opened the submenu. (Right in RTL)
314
- - ESC on a menu should close the currently focused menu. If focus is in a submenu and ESC is hit, it should only close the current submenu and return focus to the parent's element where focus was previously.
315
- - Space and Enter key execute the action that is currently focused in the menu.
316
-
317
- ### MenuItem selection
318
-
319
- Below are the interactions that should be supported for all menu items that are required to handle a selection state.
320
-
321
- In the event that the selection method is a radio, the previous selected item must be unselected.
322
-
323
- | Type | Action | Result | Details |
324
- | ------------- | ------ | ------ | -------------------------------------------- |
325
- | Keyboard | Space | Toggle | Toggle the selection status of the menu item |
326
- | Keyboard | Enter | Toggle | Toggle the selection status of the menu item |
327
- | Mouse | Click | Toggle | Toggle the selection status of the menu item |
328
- | Accessibility | Toggle | Toggle | Toggle the selection status of the menu item |
329
-
330
- ### Positioning
331
-
332
- #### Menu positioning
333
-
334
- The default positioning for the root `Menu` is below the trigger and aligned with the left (or right in RTL) edge.
335
-
336
- #### Submenu positioning
337
-
338
- The default positioning for a submenu is to the right of the menu item trigger (or left in RTL) and aligned with the top edge.
339
-
340
- ## Accessibility
341
-
342
- The `MenuTrigger` will set `expand` or `collapsed` state and will respond to actions which explicitly tell it to expand or collapse (win32 only)
343
- The `MenuPopover` has its role set to `menu`, and `MenuItmes` and variants have their role set to `menuitem`.
344
- The `MenuItem` variants which track selection have the `Toggle` pattern available.