@wordpress/components 29.1.0 → 29.2.0

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 (220) hide show
  1. package/CHANGELOG.md +19 -6
  2. package/CONTRIBUTING.md +4 -4
  3. package/README.md +1 -1
  4. package/build/badge/index.js +26 -22
  5. package/build/badge/index.js.map +1 -1
  6. package/build/circular-option-picker/circular-option-picker-option.js +9 -7
  7. package/build/circular-option-picker/circular-option-picker-option.js.map +1 -1
  8. package/build/circular-option-picker/circular-option-picker.js +0 -1
  9. package/build/circular-option-picker/circular-option-picker.js.map +1 -1
  10. package/build/color-palette/index.js +1 -6
  11. package/build/color-palette/index.js.map +1 -1
  12. package/build/font-size-picker/index.native.js +1 -1
  13. package/build/font-size-picker/index.native.js.map +1 -1
  14. package/build/higher-order/with-focus-return/index.js +1 -1
  15. package/build/higher-order/with-focus-return/index.js.map +1 -1
  16. package/build/input-control/styles/input-control-styles.js +22 -22
  17. package/build/input-control/styles/input-control-styles.js.map +1 -1
  18. package/build/menu/checkbox-item.js +6 -6
  19. package/build/menu/checkbox-item.js.map +1 -1
  20. package/build/menu/context.js +2 -2
  21. package/build/menu/context.js.map +1 -1
  22. package/build/menu/group-label.js +4 -4
  23. package/build/menu/group-label.js.map +1 -1
  24. package/build/menu/group.js +4 -4
  25. package/build/menu/group.js.map +1 -1
  26. package/build/menu/index.js +87 -14
  27. package/build/menu/index.js.map +1 -1
  28. package/build/menu/item-help-text.js +4 -4
  29. package/build/menu/item-help-text.js.map +1 -1
  30. package/build/menu/item-label.js +4 -4
  31. package/build/menu/item-label.js.map +1 -1
  32. package/build/menu/item.js +6 -6
  33. package/build/menu/item.js.map +1 -1
  34. package/build/menu/popover.js +5 -5
  35. package/build/menu/popover.js.map +1 -1
  36. package/build/menu/radio-item.js +6 -6
  37. package/build/menu/radio-item.js.map +1 -1
  38. package/build/menu/separator.js +4 -4
  39. package/build/menu/separator.js.map +1 -1
  40. package/build/menu/styles.js +41 -41
  41. package/build/menu/styles.js.map +1 -1
  42. package/build/menu/submenu-trigger-item.js +5 -5
  43. package/build/menu/submenu-trigger-item.js.map +1 -1
  44. package/build/menu/trigger-button.js +3 -3
  45. package/build/menu/trigger-button.js.map +1 -1
  46. package/build/menu/types.js.map +1 -1
  47. package/build/mobile/bottom-sheet/nav-bar/action-button.native.js +1 -1
  48. package/build/mobile/bottom-sheet/nav-bar/action-button.native.js.map +1 -1
  49. package/build/mobile/utils/get-px-from-css-unit.native.js +3 -3
  50. package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -1
  51. package/build/notice/types.js.map +1 -1
  52. package/build/search-control/index.js +1 -1
  53. package/build/search-control/index.js.map +1 -1
  54. package/build/text/hook.js +8 -6
  55. package/build/text/hook.js.map +1 -1
  56. package/build/text/utils.js +1 -1
  57. package/build/text/utils.js.map +1 -1
  58. package/build-module/badge/index.js +28 -22
  59. package/build-module/badge/index.js.map +1 -1
  60. package/build-module/circular-option-picker/circular-option-picker-option.js +9 -7
  61. package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -1
  62. package/build-module/circular-option-picker/circular-option-picker.js +0 -1
  63. package/build-module/circular-option-picker/circular-option-picker.js.map +1 -1
  64. package/build-module/color-palette/index.js +1 -6
  65. package/build-module/color-palette/index.js.map +1 -1
  66. package/build-module/font-size-picker/index.native.js +1 -1
  67. package/build-module/font-size-picker/index.native.js.map +1 -1
  68. package/build-module/higher-order/with-focus-return/index.js +1 -1
  69. package/build-module/higher-order/with-focus-return/index.js.map +1 -1
  70. package/build-module/input-control/styles/input-control-styles.js +22 -22
  71. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  72. package/build-module/menu/checkbox-item.js +6 -6
  73. package/build-module/menu/checkbox-item.js.map +1 -1
  74. package/build-module/menu/context.js +1 -1
  75. package/build-module/menu/context.js.map +1 -1
  76. package/build-module/menu/group-label.js +4 -4
  77. package/build-module/menu/group-label.js.map +1 -1
  78. package/build-module/menu/group.js +4 -4
  79. package/build-module/menu/group.js.map +1 -1
  80. package/build-module/menu/index.js +99 -26
  81. package/build-module/menu/index.js.map +1 -1
  82. package/build-module/menu/item-help-text.js +4 -4
  83. package/build-module/menu/item-help-text.js.map +1 -1
  84. package/build-module/menu/item-label.js +4 -4
  85. package/build-module/menu/item-label.js.map +1 -1
  86. package/build-module/menu/item.js +6 -6
  87. package/build-module/menu/item.js.map +1 -1
  88. package/build-module/menu/popover.js +5 -5
  89. package/build-module/menu/popover.js.map +1 -1
  90. package/build-module/menu/radio-item.js +6 -6
  91. package/build-module/menu/radio-item.js.map +1 -1
  92. package/build-module/menu/separator.js +4 -4
  93. package/build-module/menu/separator.js.map +1 -1
  94. package/build-module/menu/styles.js +40 -40
  95. package/build-module/menu/styles.js.map +1 -1
  96. package/build-module/menu/submenu-trigger-item.js +6 -6
  97. package/build-module/menu/submenu-trigger-item.js.map +1 -1
  98. package/build-module/menu/trigger-button.js +3 -3
  99. package/build-module/menu/trigger-button.js.map +1 -1
  100. package/build-module/menu/types.js.map +1 -1
  101. package/build-module/mobile/bottom-sheet/nav-bar/action-button.native.js +1 -1
  102. package/build-module/mobile/bottom-sheet/nav-bar/action-button.native.js.map +1 -1
  103. package/build-module/mobile/utils/get-px-from-css-unit.native.js +3 -3
  104. package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -1
  105. package/build-module/notice/types.js.map +1 -1
  106. package/build-module/search-control/index.js +1 -1
  107. package/build-module/search-control/index.js.map +1 -1
  108. package/build-module/text/hook.js +8 -6
  109. package/build-module/text/hook.js.map +1 -1
  110. package/build-module/text/utils.js +1 -1
  111. package/build-module/text/utils.js.map +1 -1
  112. package/build-style/style-rtl.css +89 -170
  113. package/build-style/style.css +89 -170
  114. package/build-types/badge/index.d.ts.map +1 -1
  115. package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -1
  116. package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -1
  117. package/build-types/circular-option-picker/stories/index.story.d.ts.map +1 -1
  118. package/build-types/color-palette/index.d.ts.map +1 -1
  119. package/build-types/higher-order/with-focus-return/index.d.ts +1 -1
  120. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  121. package/build-types/menu/checkbox-item.d.ts +2 -2
  122. package/build-types/menu/checkbox-item.d.ts.map +1 -1
  123. package/build-types/menu/context.d.ts +2 -2
  124. package/build-types/menu/context.d.ts.map +1 -1
  125. package/build-types/menu/group-label.d.ts +2 -2
  126. package/build-types/menu/group-label.d.ts.map +1 -1
  127. package/build-types/menu/group.d.ts +2 -2
  128. package/build-types/menu/group.d.ts.map +1 -1
  129. package/build-types/menu/index.d.ts +84 -12
  130. package/build-types/menu/index.d.ts.map +1 -1
  131. package/build-types/menu/item-help-text.d.ts +1 -1
  132. package/build-types/menu/item-help-text.d.ts.map +1 -1
  133. package/build-types/menu/item-label.d.ts +1 -1
  134. package/build-types/menu/item-label.d.ts.map +1 -1
  135. package/build-types/menu/item.d.ts +2 -2
  136. package/build-types/menu/item.d.ts.map +1 -1
  137. package/build-types/menu/popover.d.ts +2 -2
  138. package/build-types/menu/popover.d.ts.map +1 -1
  139. package/build-types/menu/radio-item.d.ts +2 -2
  140. package/build-types/menu/radio-item.d.ts.map +1 -1
  141. package/build-types/menu/separator.d.ts +2 -2
  142. package/build-types/menu/separator.d.ts.map +1 -1
  143. package/build-types/menu/styles.d.ts +15 -15
  144. package/build-types/menu/styles.d.ts.map +1 -1
  145. package/build-types/menu/submenu-trigger-item.d.ts +2 -2
  146. package/build-types/menu/submenu-trigger-item.d.ts.map +1 -1
  147. package/build-types/menu/trigger-button.d.ts +2 -2
  148. package/build-types/menu/trigger-button.d.ts.map +1 -1
  149. package/build-types/menu/types.d.ts +10 -10
  150. package/build-types/menu/types.d.ts.map +1 -1
  151. package/build-types/menu-group/stories/index.story.d.ts +1 -1
  152. package/build-types/notice/types.d.ts +1 -1
  153. package/build-types/progress-bar/stories/index.story.d.ts +1 -1
  154. package/build-types/tabs/stories/index.story.d.ts +0 -3
  155. package/build-types/tabs/stories/index.story.d.ts.map +1 -1
  156. package/build-types/text/hook.d.ts.map +1 -1
  157. package/build-types/text/utils.d.ts +1 -1
  158. package/package.json +19 -19
  159. package/src/animate/style.scss +16 -12
  160. package/src/badge/index.tsx +28 -27
  161. package/src/border-control/test/index.js +12 -4
  162. package/src/button/style.scss +15 -12
  163. package/src/checkbox-control/style.scss +4 -2
  164. package/src/circular-option-picker/README.md +1 -2
  165. package/src/circular-option-picker/circular-option-picker-option.tsx +17 -10
  166. package/src/circular-option-picker/circular-option-picker.tsx +0 -1
  167. package/src/circular-option-picker/stories/index.story.tsx +0 -1
  168. package/src/circular-option-picker/style.scss +10 -5
  169. package/src/color-palette/index.tsx +0 -7
  170. package/src/color-palette/test/index.tsx +2 -8
  171. package/src/combobox-control/test/index.tsx +1 -1
  172. package/src/drop-zone/style.scss +6 -9
  173. package/src/font-size-picker/index.native.js +1 -1
  174. package/src/form-toggle/style.scss +17 -10
  175. package/src/form-token-field/style.scss +9 -4
  176. package/src/higher-order/navigate-regions/style.scss +2 -2
  177. package/src/higher-order/with-focus-return/index.tsx +1 -1
  178. package/src/input-control/styles/input-control-styles.tsx +6 -0
  179. package/src/menu/README.md +421 -174
  180. package/src/menu/checkbox-item.tsx +12 -12
  181. package/src/menu/context.tsx +2 -4
  182. package/src/menu/docs-manifest.json +62 -0
  183. package/src/menu/group-label.tsx +7 -7
  184. package/src/menu/group.tsx +7 -11
  185. package/src/menu/index.tsx +101 -31
  186. package/src/menu/item-help-text.tsx +5 -7
  187. package/src/menu/item-label.tsx +5 -7
  188. package/src/menu/item.tsx +12 -12
  189. package/src/menu/popover.tsx +9 -9
  190. package/src/menu/radio-item.tsx +12 -12
  191. package/src/menu/separator.tsx +7 -7
  192. package/src/menu/stories/best-practices.mdx +38 -0
  193. package/src/menu/stories/index.story.tsx +8 -8
  194. package/src/menu/styles.ts +24 -24
  195. package/src/menu/submenu-trigger-item.tsx +9 -9
  196. package/src/menu/trigger-button.tsx +6 -6
  197. package/src/menu/types.ts +10 -10
  198. package/src/menu-group/stories/index.story.tsx +2 -2
  199. package/src/mobile/bottom-sheet/nav-bar/action-button.native.js +1 -1
  200. package/src/mobile/utils/get-px-from-css-unit.native.js +3 -3
  201. package/src/modal/style.scss +4 -2
  202. package/src/modal/test/index.tsx +5 -4
  203. package/src/notice/README.md +3 -3
  204. package/src/notice/types.ts +1 -1
  205. package/src/palette-edit/test/index.tsx +1 -1
  206. package/src/panel/style.scss +14 -6
  207. package/src/placeholder/style.scss +5 -3
  208. package/src/progress-bar/stories/index.story.tsx +1 -1
  209. package/src/resizable-box/style.scss +14 -9
  210. package/src/search-control/index.tsx +1 -1
  211. package/src/tab-panel/style.scss +6 -4
  212. package/src/tabs/stories/index.story.tsx +0 -131
  213. package/src/text/README.md +1 -1
  214. package/src/text/hook.ts +3 -2
  215. package/src/text/stories/index.story.tsx +2 -2
  216. package/src/text/test/index.tsx +1 -1
  217. package/src/text/utils.ts +1 -1
  218. package/src/text-highlight/test/index.tsx +3 -3
  219. package/src/toolbar/toolbar/style.scss +4 -3
  220. package/tsconfig.tsbuildinfo +1 -1
@@ -1,344 +1,591 @@
1
- # `Menu`
1
+ # Menu
2
2
 
3
- <div class="callout callout-alert">
4
- This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
5
- </div>
3
+ <!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->
6
4
 
7
- `Menu` displays a menu to the user (such as a set of actions or functions). The menu is rendered in a popover (this pattern is also known as a "Dropdown menu"), which is triggered by a button.
5
+ 🔒 This component is locked as a [private API](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-private-apis/). We do not yet recommend using this outside of the Gutenberg project.
8
6
 
9
- ## Design guidelines
7
+ <p class="callout callout-info">See the <a href="https://wordpress.github.io/gutenberg/?path=/docs/components-menu--docs">WordPress Storybook</a> for more detailed, interactive documentation.</p>
10
8
 
11
- ### Usage
9
+ Menu is a collection of React components that combine to render
10
+ ARIA-compliant [menu](https://www.w3.org/WAI/ARIA/apg/patterns/menu/) and
11
+ [menu button](https://www.w3.org/WAI/ARIA/apg/patterns/menubutton/) patterns.
12
12
 
13
- #### When to use a `Menu`
13
+ `Menu` itself is a wrapper component and context provider.
14
+ It is responsible for managing the state of the menu and its items, and for
15
+ rendering the `Menu.TriggerButton` (or the `Menu.SubmenuTriggerItem`)
16
+ component, and the `Menu.Popover` component.
14
17
 
15
- Use a `Menu` when you want users to:
18
+ ## Props
16
19
 
17
- - Choose an action or change a setting from a list, AND
18
- - Only see the available choices contextually.
20
+ ### `as`
19
21
 
20
- `Menu` is a React component to render an expandable menu of buttons. It is similar in purpose to a `<select>` element, with the distinction that it does not maintain a value. Instead, each option behaves as an action button.
22
+ - Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | ... 516 more ... | ("view" & FunctionComponent<...>)`
23
+ - Required: No
21
24
 
22
- If you need to display all the available options at all times, consider using a Toolbar instead. Use a `Menu` to display a list of actions after the user interacts with a button.
25
+ The HTML element or React component to render the component as.
23
26
 
24
- **Do**
25
- Use a `Menu` to display a list of actions after the user interacts with an icon.
27
+ ### `children`
26
28
 
27
- **Don’t** use a `Menu` for important actions that should always be visible. Use a `Toolbar` instead.
29
+ - Type: `ReactNode`
30
+ - Required: No
28
31
 
29
- **Don’t**
30
- Don’t use a `Menu` for frequently used actions. Use a `Toolbar` instead.
32
+ The elements, which should include one instance of the `Menu.TriggerButton`
33
+ component and one instance of the `Menu.Popover` component.
31
34
 
32
- #### Behavior
35
+ ### `defaultOpen`
33
36
 
34
- Generally, the parent button should indicate that interacting with it will show a `Menu`.
37
+ - Type: `boolean`
38
+ - Required: No
39
+ - Default: `false`
35
40
 
36
- The parent button should retain the same visual styling regardless of whether the `Menu` is displayed or not.
41
+ Whether the menu popover and its contents should be visible by default.
37
42
 
38
- #### Placement
43
+ Note: this prop will be overridden by the `open` prop if it is
44
+ provided (meaning the component will be used in "controlled" mode).
39
45
 
40
- The `Menu` should typically appear directly below, or below and to the left of, the parent button. If there isn’t enough space below to display the full `Menu`, it can be displayed instead above the parent button.
46
+ ### `open`
41
47
 
42
- ## Development guidelines
48
+ - Type: `boolean`
49
+ - Required: No
43
50
 
44
- This component is still highly experimental, and it's not normally accessible to consumers of the `@wordpress/components` package.
51
+ Whether the menu popover and its contents should be visible.
52
+ Should be used in conjunction with `onOpenChange` in order to control
53
+ the open state of the menu popover.
45
54
 
46
- The component exposes a set of components that are meant to be used in combination with each other in order to implement a `Menu` correctly.
55
+ Note: this prop will set the component in "controlled" mode, and it will
56
+ override the `defaultOpen` prop.
47
57
 
48
- ### `Menu`
58
+ ### `onOpenChange`
49
59
 
50
- The root component, used to specify the menu's trigger and its contents.
60
+ - Type: `(open: boolean) => void`
61
+ - Required: No
62
+
63
+ A callback that gets called when the `open` state changes.
64
+
65
+ ### `placement`
66
+
67
+ - Type: `"top" | "bottom" | "left" | "right" | "top-start" | "bottom-start" | "left-start" | "right-start" | "top-end" | "bottom-end" | ...`
68
+ - Required: No
69
+ - Default: `'bottom-start' for root-level menus, 'right-start' for submenus`
70
+
71
+ The placement of the menu popover.
72
+
73
+ ## Subcomponents
74
+
75
+ ### Menu.TriggerButton
76
+
77
+ Renders a menu button that toggles the visibility of a sibling
78
+ `Menu.Popover` component when clicked or when using arrow keys.
51
79
 
52
80
  #### Props
53
81
 
54
- The component accepts the following props:
82
+ ##### `accessibleWhenDisabled`
55
83
 
56
- ##### `trigger`: `React.ReactNode`
84
+ - Type: `boolean`
85
+ - Required: No
57
86
 
58
- The button triggering the menu popover.
87
+ Indicates whether the element should be focusable even when it is
88
+ `disabled`.
59
89
 
60
- - Required: yes
90
+ This is important when discoverability is a concern. For example:
61
91
 
62
- ##### `children`: `React.ReactNode`
92
+ > A toolbar in an editor contains a set of special smart paste functions
93
+ that are disabled when the clipboard is empty or when the function is not
94
+ applicable to the current content of the clipboard. It could be helpful to
95
+ keep the disabled buttons focusable if the ability to discover their
96
+ functionality is primarily via their presence on the toolbar.
63
97
 
64
- The contents of the menu (ie. one or more menu items).
98
+ Learn more on [Focusability of disabled
99
+ controls](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols).
65
100
 
66
- - Required: yes
101
+ ##### `children`
67
102
 
68
- ##### `defaultOpen`: `boolean`
103
+ - Type: `ReactNode`
104
+ - Required: No
69
105
 
70
- The open state of the menu popover when it is initially rendered. Use when not wanting to control its open state.
106
+ The contents of the menu trigger button.
71
107
 
72
- - Required: no
73
- - Default: `false`
108
+ ##### `disabled`
74
109
 
75
- ##### `open`: `boolean`
110
+ - Type: `boolean`
111
+ - Required: No
112
+ - Default: `false`
76
113
 
77
- The controlled open state of the menu popover. Must be used in conjunction with `onOpenChange`.
114
+ Determines if the element is disabled. This sets the `aria-disabled`
115
+ attribute accordingly, enabling support for all elements, including those
116
+ that don't support the native `disabled` attribute.
78
117
 
79
- - Required: no
118
+ This feature can be combined with the `accessibleWhenDisabled` prop to
119
+ make disabled elements still accessible via keyboard.
80
120
 
81
- ##### `onOpenChange`: `(open: boolean) => void`
121
+ ##### `render`
82
122
 
83
- Event handler called when the open state of the menu popover changes.
123
+ - Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
124
+ - Required: No
84
125
 
85
- - Required: no
126
+ Allows the component to be rendered as a different HTML element or React
127
+ component. The value can be a React element or a function that takes in the
128
+ original component props and gives back a React element with the props
129
+ merged.
86
130
 
87
- ##### `modal`: `boolean`
131
+ ### Menu.Popover
88
132
 
89
- The modality of the menu popover. When set to true, interaction with outside elements will be disabled and only menu content will be visible to screen readers.
133
+ Renders a dropdown menu element that's controlled by a sibling
134
+ `Menu.TriggerButton` component. It renders a popover and automatically
135
+ focuses on items when the menu is shown.
90
136
 
91
- - Required: no
92
- - Default: `true`
137
+ The only valid children of `Menu.Popover` are `Menu.Item`,
138
+ `Menu.RadioItem`, `Menu.CheckboxItem`, `Menu.Group`, `Menu.Separator`,
139
+ and `Menu` (for nested dropdown menus).
93
140
 
94
- ##### `placement`: ``'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end'`
141
+ #### Props
95
142
 
96
- The placement of the menu popover.
143
+ ##### `children`
144
+
145
+ - Type: `ReactNode`
146
+ - Required: No
147
+
148
+ The contents of the menu popover, which should include instances of the
149
+ `Menu.Item`, `Menu.CheckboxItem`, `Menu.RadioItem`, `Menu.Group`, and
150
+ `Menu.Separator` components.
151
+
152
+ ##### `gutter`
153
+
154
+ - Type: `number`
155
+ - Required: No
156
+ - Default: `8 for root-level menus, 16 for nested menus`
157
+
158
+ The distance between the popover and the anchor element.
159
+
160
+ ##### `hideOnEscape`
161
+
162
+ - Type: `BooleanOrCallback<KeyboardEvent | React.KeyboardEvent<Element>>`
163
+ - Required: No
164
+ - Default: ``( event ) => { event.preventDefault(); return true; }``
97
165
 
98
- - Required: no
99
- - Default: `'bottom-start'` for root-level menus, `'right-start'` for nested menus
166
+ Determines if the menu popover will hide when the user presses the
167
+ Escape key.
100
168
 
101
- ##### `gutter`: `number`
169
+ This prop can be either a boolean or a function that accepts an event as an
170
+ argument and returns a boolean. The event object represents the keydown
171
+ event that initiated the hide action, which could be either a native
172
+ keyboard event or a React synthetic event.
102
173
 
103
- The distance in pixels from the trigger.
174
+ ##### `modal`
104
175
 
105
- - Required: no
106
- - Default: `8` for root-level menus, `16` for nested menus
176
+ - Type: `boolean`
177
+ - Required: No
178
+ - Default: `true`
107
179
 
108
- ##### `shift`: `number`
180
+ The modality of the menu popover. When set to true, interaction with
181
+ outside elements will be disabled and only menu content will be visible to
182
+ screen readers.
109
183
 
110
- The skidding of the popover along the anchor element. Can be set to negative values to make the popover shift to the opposite side.
184
+ Determines whether the menu popover is modal. Modal dialogs have distinct
185
+ states and behaviors:
186
+ - The `portal` and `preventBodyScroll` props are set to `true`. They can
187
+ still be manually set to `false`.
188
+ - When the dialog is open, element tree outside it will be inert.
111
189
 
112
- - Required: no
113
- - Default: `0` for root-level menus, `-8` for nested menus
190
+ ##### `shift`
114
191
 
115
- ### `Menu.Item`
192
+ - Type: `number`
193
+ - Required: No
194
+ - Default: `0 for root-level menus, -8 for nested menus`
116
195
 
117
- Used to render a menu item.
196
+ The skidding of the popover along the anchor element. Can be set to
197
+ negative values to make the popover shift to the opposite side.
198
+
199
+ ### Menu.Item
200
+
201
+ Renders a menu item inside the `Menu.Popover` or `Menu.Group` components.
202
+
203
+ It can optionally contain one instance of the `Menu.ItemLabel` component
204
+ and one instance of the `Menu.ItemHelpText` component.
118
205
 
119
206
  #### Props
120
207
 
121
- The component accepts the following props:
208
+ ##### `children`
209
+
210
+ - Type: `ReactNode`
211
+ - Required: Yes
212
+
213
+ The contents of the menu item, which could include one instance of the
214
+ `Menu.ItemLabel` component and/or one instance of the `Menu.ItemHelpText`
215
+ component.
122
216
 
123
- ##### `children`: `React.ReactNode`
217
+ ##### `disabled`
124
218
 
125
- The contents of the item
219
+ - Type: `boolean`
220
+ - Required: No
221
+ - Default: `false`
126
222
 
127
- - Required: yes
223
+ Determines if the element is disabled. This sets the `aria-disabled`
224
+ attribute accordingly, enabling support for all elements, including those
225
+ that don't support the native `disabled` attribute.
128
226
 
129
- ##### `prefix`: `React.ReactNode`
227
+ ##### `hideOnClick`
130
228
 
131
- The contents of the item's prefix.
229
+ - Type: `BooleanOrCallback<MouseEvent<HTMLElement, MouseEvent>>`
230
+ - Required: No
231
+ - Default: `true`
132
232
 
133
- - Required: no
233
+ Determines if the menu should hide when this item is clicked.
134
234
 
135
- ##### `suffix`: `React.ReactNode`
235
+ **Note**: This behavior isn't triggered if this menu item is rendered as a
236
+ link and modifier keys are used to either open the link in a new tab or
237
+ download it.
136
238
 
137
- The contents of the item's suffix.
239
+ ##### `prefix`
138
240
 
139
- - Required: no
241
+ - Type: `ReactNode`
242
+ - Required: No
140
243
 
141
- ##### `hideOnClick`: `boolean`
244
+ The contents of the menu item's prefix, such as an icon.
142
245
 
143
- Whether to hide the menu popover when the menu item is clicked.
246
+ ##### `render`
144
247
 
145
- - Required: no
146
- - Default: `true`
248
+ - Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
249
+ - Required: No
147
250
 
148
- ##### `disabled`: `boolean`
251
+ Allows the component to be rendered as a different HTML element or React
252
+ component. The value can be a React element or a function that takes in the
253
+ original component props and gives back a React element with the props
254
+ merged.
149
255
 
150
- Determines if the element is disabled.
256
+ ##### `suffix`
151
257
 
152
- - Required: no
153
- - Default: `false`
258
+ - Type: `ReactNode`
259
+ - Required: No
154
260
 
155
- ### `Menu.CheckboxItem`
261
+ The contents of the menu item's suffix, such as a keyboard shortcut.
156
262
 
157
- Used to render a checkbox item.
263
+ ### Menu.RadioItem
264
+
265
+ Renders a radio menu item inside the `Menu.Popover` or `Menu.Group`
266
+ components.
267
+
268
+ It can optionally contain one instance of the `Menu.ItemLabel` component
269
+ and one instance of the `Menu.ItemHelpText` component.
158
270
 
159
271
  #### Props
160
272
 
161
- The component accepts the following props:
273
+ ##### `children`
162
274
 
163
- ##### `children`: `React.ReactNode`
275
+ - Type: `ReactNode`
276
+ - Required: Yes
164
277
 
165
- The contents of the item
278
+ The contents of the menu item, which could include one instance of the
279
+ `Menu.ItemLabel` component and/or one instance of the `Menu.ItemHelpText`
280
+ component.
166
281
 
167
- - Required: yes
282
+ ##### `checked`
168
283
 
169
- ##### `suffix`: `React.ReactNode`
284
+ - Type: `boolean`
285
+ - Required: No
170
286
 
171
- The contents of the item's suffix.
287
+ The controlled checked state of the radio menu item.
172
288
 
173
- - Required: no
289
+ Note: this prop will override the `defaultChecked` prop.
174
290
 
175
- ##### `hideOnClick`: `boolean`
291
+ ##### `disabled`
176
292
 
177
- Whether to hide the menu popover when the menu item is clicked.
293
+ - Type: `boolean`
294
+ - Required: No
295
+ - Default: `false`
178
296
 
179
- - Required: no
180
- - Default: `false`
297
+ Determines if the element is disabled. This sets the `aria-disabled`
298
+ attribute accordingly, enabling support for all elements, including those
299
+ that don't support the native `disabled` attribute.
181
300
 
182
- ##### `disabled`: `boolean`
301
+ ##### `defaultChecked`
183
302
 
184
- Determines if the element is disabled.
303
+ - Type: `boolean`
304
+ - Required: No
185
305
 
186
- - Required: no
187
- - Default: `false`
306
+ The checked state of the radio menu item when it is initially rendered.
307
+ Use when not wanting to control its checked state.
188
308
 
189
- ##### `name`: `string`
309
+ Note: this prop will be overriden by the `checked` prop, if it is defined.
190
310
 
191
- The checkbox item's name.
311
+ ##### `hideOnClick`
192
312
 
193
- - Required: yes
313
+ - Type: `BooleanOrCallback<MouseEvent<HTMLElement, MouseEvent>>`
314
+ - Required: No
315
+ - Default: `false`
194
316
 
195
- ##### `value`: `string`
317
+ Determines if the menu should hide when this item is clicked.
196
318
 
197
- The checkbox item's value, useful when using multiple checkbox items
198
- associated to the same `name`.
319
+ **Note**: This behavior isn't triggered if this menu item is rendered as a
320
+ link and modifier keys are used to either open the link in a new tab or
321
+ download it.
199
322
 
200
- - Required: no
323
+ ##### `name`
201
324
 
202
- ##### `checked`: `boolean`
325
+ - Type: `string`
326
+ - Required: Yes
203
327
 
204
- The checkbox item's value, useful when using multiple checkbox items
205
- associated to the same `name`.
328
+ The radio item's name.
329
+
330
+ ##### `onChange`
331
+
332
+ - Type: `BivariantCallback<(event: ChangeEvent<HTMLInputElement>) => void>`
333
+ - Required: No
334
+
335
+ A function that is called when the checkbox's checked state changes.
206
336
 
207
- - Required: no
337
+ ##### `render`
208
338
 
209
- ##### `defaultChecked`: `boolean`
339
+ - Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
340
+ - Required: No
210
341
 
211
- The checked state of the checkbox menu item when it is initially rendered. Use when not wanting to control its checked state.
342
+ Allows the component to be rendered as a different HTML element or React
343
+ component. The value can be a React element or a function that takes in the
344
+ original component props and gives back a React element with the props
345
+ merged.
212
346
 
213
- - Required: no
347
+ ##### `suffix`
214
348
 
215
- ##### `onChange`: `( event: React.ChangeEvent< HTMLInputElement > ) => void;`
349
+ - Type: `ReactNode`
350
+ - Required: No
216
351
 
217
- Event handler called when the checked state of the checkbox menu item changes.
352
+ The contents of the menu item's suffix, such as a keyboard shortcut.
353
+
354
+ ##### `value`
355
+
356
+ - Type: `string | number`
357
+ - Required: Yes
358
+
359
+ The radio item's value.
218
360
 
219
- - Required: no
361
+ ### Menu.CheckboxItem
220
362
 
221
- ### `Menu.RadioItem`
363
+ Renders a checkbox menu item inside the `Menu.Popover` or `Menu.Group`
364
+ components.
222
365
 
223
- Used to render a radio item.
366
+ It can optionally contain one instance of the `Menu.ItemLabel` component
367
+ and one instance of the `Menu.ItemHelpText` component.
224
368
 
225
369
  #### Props
226
370
 
227
- The component accepts the following props:
371
+ ##### `children`
228
372
 
229
- ##### `children`: `React.ReactNode`
373
+ - Type: `ReactNode`
374
+ - Required: Yes
230
375
 
231
- The contents of the item
376
+ The contents of the menu item, which could include one instance of the
377
+ `Menu.ItemLabel` component and/or one instance of the `Menu.ItemHelpText`
378
+ component.
232
379
 
233
- - Required: yes
380
+ ##### `checked`
234
381
 
235
- ##### `suffix`: `React.ReactNode`
382
+ - Type: `boolean`
383
+ - Required: No
236
384
 
237
- The contents of the item's suffix.
385
+ The controlled checked state of the checkbox menu item.
238
386
 
239
- - Required: no
387
+ Note: this prop will override the `defaultChecked` prop.
240
388
 
241
- ##### `hideOnClick`: `boolean`
389
+ ##### `disabled`
242
390
 
243
- Whether to hide the menu popover when the menu item is clicked.
391
+ - Type: `boolean`
392
+ - Required: No
393
+ - Default: `false`
244
394
 
245
- - Required: no
246
- - Default: `false`
395
+ Determines if the element is disabled. This sets the `aria-disabled`
396
+ attribute accordingly, enabling support for all elements, including those
397
+ that don't support the native `disabled` attribute.
247
398
 
248
- ##### `disabled`: `boolean`
399
+ ##### `defaultChecked`
249
400
 
250
- Determines if the element is disabled.
401
+ - Type: `boolean`
402
+ - Required: No
251
403
 
252
- - Required: no
253
- - Default: `false`
404
+ The checked state of the checkbox menu item when it is initially rendered.
405
+ Use when not wanting to control its checked state.
254
406
 
255
- ##### `name`: `string`
407
+ Note: this prop will be overriden by the `checked` prop, if it is defined.
256
408
 
257
- The radio item's name.
409
+ ##### `hideOnClick`
258
410
 
259
- - Required: yes
411
+ - Type: `BooleanOrCallback<MouseEvent<HTMLElement, MouseEvent>>`
412
+ - Required: No
413
+ - Default: `false`
260
414
 
261
- ##### `value`: `string | number`
415
+ Determines if the menu should hide when this item is clicked.
262
416
 
263
- The radio item's value.
417
+ **Note**: This behavior isn't triggered if this menu item is rendered as a
418
+ link and modifier keys are used to either open the link in a new tab or
419
+ download it.
264
420
 
265
- - Required: yes
421
+ ##### `name`
266
422
 
267
- ##### `checked`: `boolean`
423
+ - Type: `string`
424
+ - Required: Yes
268
425
 
269
- The checkbox item's value, useful when using multiple checkbox items
270
- associated to the same `name`.
426
+ The checkbox menu item's name.
427
+
428
+ ##### `onChange`
429
+
430
+ - Type: `ChangeEventHandler<HTMLInputElement>`
431
+ - Required: No
271
432
 
272
- - Required: no
433
+ A function that is called when the checkbox's checked state changes.
273
434
 
274
- ##### `defaultChecked`: `boolean`
435
+ ##### `render`
275
436
 
276
- The checked state of the radio menu item when it is initially rendered. Use when not wanting to control its checked state.
437
+ - Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
438
+ - Required: No
277
439
 
278
- - Required: no
440
+ Allows the component to be rendered as a different HTML element or React
441
+ component. The value can be a React element or a function that takes in the
442
+ original component props and gives back a React element with the props
443
+ merged.
279
444
 
280
- ##### `onChange`: `( event: React.ChangeEvent< HTMLInputElement > ) => void;`
445
+ ##### `suffix`
281
446
 
282
- Event handler called when the checked radio menu item changes.
447
+ - Type: `ReactNode`
448
+ - Required: No
283
449
 
284
- - Required: no
450
+ The contents of the menu item's suffix, such as a keyboard shortcut.
451
+
452
+ ##### `value`
453
+
454
+ - Type: `string | number | readonly string[]`
455
+ - Required: No
456
+
457
+ The checkbox item's value, useful when using multiple checkbox menu items
458
+ associated to the same `name`.
285
459
 
286
- ### `Menu.ItemLabel`
460
+ ### Menu.ItemLabel
287
461
 
288
- Used to render the menu item's label.
462
+ Renders a menu item's label text. It should be wrapped with `Menu.Item`,
463
+ `Menu.RadioItem`, or `Menu.CheckboxItem`.
289
464
 
290
465
  #### Props
291
466
 
292
- The component accepts the following props:
467
+ ##### `as`
293
468
 
294
- ##### `children`: `React.ReactNode`
469
+ - Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | ...`
470
+ - Required: No
295
471
 
296
- The label contents.
472
+ The HTML element or React component to render the component as.
297
473
 
298
- - Required: yes
474
+ ### Menu.ItemHelpText
299
475
 
300
- ### `Menu.ItemHelpText`
476
+ Renders a menu item's help text. It should be wrapped with `Menu.Item`,
477
+ `Menu.RadioItem`, or `Menu.CheckboxItem`.
301
478
 
302
- Used to render the menu item's help text.
479
+ #### Props
480
+
481
+ ##### `as`
482
+
483
+ - Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | ...`
484
+ - Required: No
485
+
486
+ The HTML element or React component to render the component as.
487
+
488
+ ### Menu.Group
489
+
490
+ Renders a group for menu items.
491
+
492
+ It should contain one instance of `Menu.GroupLabel` and one or more
493
+ instances of `Menu.Item`, `Menu.RadioItem`, or `Menu.CheckboxItem`.
303
494
 
304
495
  #### Props
305
496
 
306
- The component accepts the following props:
497
+ ##### `children`
307
498
 
308
- ##### `children`: `React.ReactNode`
499
+ - Type: `ReactNode`
500
+ - Required: Yes
309
501
 
310
- The help text contents.
502
+ The contents of the menu group, which should include one instance of the
503
+ `Menu.GroupLabel` component and one or more instances of `Menu.Item`,
504
+ `Menu.CheckboxItem`, and `Menu.RadioItem`.
311
505
 
312
- - Required: yes
506
+ ### Menu.GroupLabel
313
507
 
314
- ### `Menu.Group`
508
+ Renders a label in a menu group.
315
509
 
316
- Used to group menu items.
510
+ This component should be wrapped with `Menu.Group` so the
511
+ `aria-labelledby` is correctly set on the group element.
317
512
 
318
513
  #### Props
319
514
 
320
- The component accepts the following props:
515
+ ##### `children`
321
516
 
322
- ##### `children`: `React.ReactNode`
517
+ - Type: `ReactNode`
518
+ - Required: Yes
323
519
 
324
- The contents of the menu group (ie. an optional menu group label and one or more menu items).
520
+ The contents of the menu group label, which should provide an accessible
521
+ label for the menu group.
325
522
 
326
- - Required: yes
523
+ ### Menu.Separator
327
524
 
328
- ### `Menu.GroupLabel`
525
+ Renders a divider between menu items or menu groups.
329
526
 
330
- Used to render a group label. The label text should be kept as short as possible.
527
+ #### Props
528
+
529
+ ### Menu.SubmenuTriggerItem
530
+
531
+ Renders a menu item that toggles the visibility of a sibling
532
+ `Menu.Popover` component when clicked or when using arrow keys.
533
+
534
+ This component is used to create a nested dropdown menu.
331
535
 
332
536
  #### Props
333
537
 
334
- The component accepts the following props:
538
+ ##### `children`
539
+
540
+ - Type: `ReactNode`
541
+ - Required: Yes
542
+
543
+ The contents of the menu item, which could include one instance of the
544
+ `Menu.ItemLabel` component and/or one instance of the `Menu.ItemHelpText`
545
+ component.
546
+
547
+ ##### `disabled`
548
+
549
+ - Type: `boolean`
550
+ - Required: No
551
+ - Default: `false`
552
+
553
+ Determines if the element is disabled. This sets the `aria-disabled`
554
+ attribute accordingly, enabling support for all elements, including those
555
+ that don't support the native `disabled` attribute.
556
+
557
+ ##### `hideOnClick`
558
+
559
+ - Type: `BooleanOrCallback<MouseEvent<HTMLElement, MouseEvent>>`
560
+ - Required: No
561
+ - Default: `true`
562
+
563
+ Determines if the menu should hide when this item is clicked.
564
+
565
+ **Note**: This behavior isn't triggered if this menu item is rendered as a
566
+ link and modifier keys are used to either open the link in a new tab or
567
+ download it.
568
+
569
+ ##### `prefix`
570
+
571
+ - Type: `ReactNode`
572
+ - Required: No
573
+
574
+ The contents of the menu item's prefix, such as an icon.
575
+
576
+ ##### `render`
335
577
 
336
- ##### `children`: `React.ReactNode`
578
+ - Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
579
+ - Required: No
337
580
 
338
- The contents of the menu group label.
581
+ Allows the component to be rendered as a different HTML element or React
582
+ component. The value can be a React element or a function that takes in the
583
+ original component props and gives back a React element with the props
584
+ merged.
339
585
 
340
- - Required: yes
586
+ ##### `suffix`
341
587
 
342
- ### `Menu.Separator`
588
+ - Type: `ReactNode`
589
+ - Required: No
343
590
 
344
- Used to render a visual separator.
591
+ The contents of the menu item's suffix, such as a keyboard shortcut.