@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.
- package/CHANGELOG.md +19 -6
- package/CONTRIBUTING.md +4 -4
- package/README.md +1 -1
- package/build/badge/index.js +26 -22
- package/build/badge/index.js.map +1 -1
- package/build/circular-option-picker/circular-option-picker-option.js +9 -7
- package/build/circular-option-picker/circular-option-picker-option.js.map +1 -1
- package/build/circular-option-picker/circular-option-picker.js +0 -1
- package/build/circular-option-picker/circular-option-picker.js.map +1 -1
- package/build/color-palette/index.js +1 -6
- package/build/color-palette/index.js.map +1 -1
- package/build/font-size-picker/index.native.js +1 -1
- package/build/font-size-picker/index.native.js.map +1 -1
- package/build/higher-order/with-focus-return/index.js +1 -1
- package/build/higher-order/with-focus-return/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +22 -22
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/menu/checkbox-item.js +6 -6
- package/build/menu/checkbox-item.js.map +1 -1
- package/build/menu/context.js +2 -2
- package/build/menu/context.js.map +1 -1
- package/build/menu/group-label.js +4 -4
- package/build/menu/group-label.js.map +1 -1
- package/build/menu/group.js +4 -4
- package/build/menu/group.js.map +1 -1
- package/build/menu/index.js +87 -14
- package/build/menu/index.js.map +1 -1
- package/build/menu/item-help-text.js +4 -4
- package/build/menu/item-help-text.js.map +1 -1
- package/build/menu/item-label.js +4 -4
- package/build/menu/item-label.js.map +1 -1
- package/build/menu/item.js +6 -6
- package/build/menu/item.js.map +1 -1
- package/build/menu/popover.js +5 -5
- package/build/menu/popover.js.map +1 -1
- package/build/menu/radio-item.js +6 -6
- package/build/menu/radio-item.js.map +1 -1
- package/build/menu/separator.js +4 -4
- package/build/menu/separator.js.map +1 -1
- package/build/menu/styles.js +41 -41
- package/build/menu/styles.js.map +1 -1
- package/build/menu/submenu-trigger-item.js +5 -5
- package/build/menu/submenu-trigger-item.js.map +1 -1
- package/build/menu/trigger-button.js +3 -3
- package/build/menu/trigger-button.js.map +1 -1
- package/build/menu/types.js.map +1 -1
- package/build/mobile/bottom-sheet/nav-bar/action-button.native.js +1 -1
- package/build/mobile/bottom-sheet/nav-bar/action-button.native.js.map +1 -1
- package/build/mobile/utils/get-px-from-css-unit.native.js +3 -3
- package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -1
- package/build/notice/types.js.map +1 -1
- package/build/search-control/index.js +1 -1
- package/build/search-control/index.js.map +1 -1
- package/build/text/hook.js +8 -6
- package/build/text/hook.js.map +1 -1
- package/build/text/utils.js +1 -1
- package/build/text/utils.js.map +1 -1
- package/build-module/badge/index.js +28 -22
- package/build-module/badge/index.js.map +1 -1
- package/build-module/circular-option-picker/circular-option-picker-option.js +9 -7
- package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -1
- package/build-module/circular-option-picker/circular-option-picker.js +0 -1
- package/build-module/circular-option-picker/circular-option-picker.js.map +1 -1
- package/build-module/color-palette/index.js +1 -6
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/font-size-picker/index.native.js +1 -1
- package/build-module/font-size-picker/index.native.js.map +1 -1
- package/build-module/higher-order/with-focus-return/index.js +1 -1
- package/build-module/higher-order/with-focus-return/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +22 -22
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/menu/checkbox-item.js +6 -6
- package/build-module/menu/checkbox-item.js.map +1 -1
- package/build-module/menu/context.js +1 -1
- package/build-module/menu/context.js.map +1 -1
- package/build-module/menu/group-label.js +4 -4
- package/build-module/menu/group-label.js.map +1 -1
- package/build-module/menu/group.js +4 -4
- package/build-module/menu/group.js.map +1 -1
- package/build-module/menu/index.js +99 -26
- package/build-module/menu/index.js.map +1 -1
- package/build-module/menu/item-help-text.js +4 -4
- package/build-module/menu/item-help-text.js.map +1 -1
- package/build-module/menu/item-label.js +4 -4
- package/build-module/menu/item-label.js.map +1 -1
- package/build-module/menu/item.js +6 -6
- package/build-module/menu/item.js.map +1 -1
- package/build-module/menu/popover.js +5 -5
- package/build-module/menu/popover.js.map +1 -1
- package/build-module/menu/radio-item.js +6 -6
- package/build-module/menu/radio-item.js.map +1 -1
- package/build-module/menu/separator.js +4 -4
- package/build-module/menu/separator.js.map +1 -1
- package/build-module/menu/styles.js +40 -40
- package/build-module/menu/styles.js.map +1 -1
- package/build-module/menu/submenu-trigger-item.js +6 -6
- package/build-module/menu/submenu-trigger-item.js.map +1 -1
- package/build-module/menu/trigger-button.js +3 -3
- package/build-module/menu/trigger-button.js.map +1 -1
- package/build-module/menu/types.js.map +1 -1
- package/build-module/mobile/bottom-sheet/nav-bar/action-button.native.js +1 -1
- package/build-module/mobile/bottom-sheet/nav-bar/action-button.native.js.map +1 -1
- package/build-module/mobile/utils/get-px-from-css-unit.native.js +3 -3
- package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -1
- package/build-module/notice/types.js.map +1 -1
- package/build-module/search-control/index.js +1 -1
- package/build-module/search-control/index.js.map +1 -1
- package/build-module/text/hook.js +8 -6
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/utils.js +1 -1
- package/build-module/text/utils.js.map +1 -1
- package/build-style/style-rtl.css +89 -170
- package/build-style/style.css +89 -170
- package/build-types/badge/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -1
- package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -1
- package/build-types/circular-option-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/higher-order/with-focus-return/index.d.ts +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/menu/checkbox-item.d.ts +2 -2
- package/build-types/menu/checkbox-item.d.ts.map +1 -1
- package/build-types/menu/context.d.ts +2 -2
- package/build-types/menu/context.d.ts.map +1 -1
- package/build-types/menu/group-label.d.ts +2 -2
- package/build-types/menu/group-label.d.ts.map +1 -1
- package/build-types/menu/group.d.ts +2 -2
- package/build-types/menu/group.d.ts.map +1 -1
- package/build-types/menu/index.d.ts +84 -12
- package/build-types/menu/index.d.ts.map +1 -1
- package/build-types/menu/item-help-text.d.ts +1 -1
- package/build-types/menu/item-help-text.d.ts.map +1 -1
- package/build-types/menu/item-label.d.ts +1 -1
- package/build-types/menu/item-label.d.ts.map +1 -1
- package/build-types/menu/item.d.ts +2 -2
- package/build-types/menu/item.d.ts.map +1 -1
- package/build-types/menu/popover.d.ts +2 -2
- package/build-types/menu/popover.d.ts.map +1 -1
- package/build-types/menu/radio-item.d.ts +2 -2
- package/build-types/menu/radio-item.d.ts.map +1 -1
- package/build-types/menu/separator.d.ts +2 -2
- package/build-types/menu/separator.d.ts.map +1 -1
- package/build-types/menu/styles.d.ts +15 -15
- package/build-types/menu/styles.d.ts.map +1 -1
- package/build-types/menu/submenu-trigger-item.d.ts +2 -2
- package/build-types/menu/submenu-trigger-item.d.ts.map +1 -1
- package/build-types/menu/trigger-button.d.ts +2 -2
- package/build-types/menu/trigger-button.d.ts.map +1 -1
- package/build-types/menu/types.d.ts +10 -10
- package/build-types/menu/types.d.ts.map +1 -1
- package/build-types/menu-group/stories/index.story.d.ts +1 -1
- package/build-types/notice/types.d.ts +1 -1
- package/build-types/progress-bar/stories/index.story.d.ts +1 -1
- package/build-types/tabs/stories/index.story.d.ts +0 -3
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/text/hook.d.ts.map +1 -1
- package/build-types/text/utils.d.ts +1 -1
- package/package.json +19 -19
- package/src/animate/style.scss +16 -12
- package/src/badge/index.tsx +28 -27
- package/src/border-control/test/index.js +12 -4
- package/src/button/style.scss +15 -12
- package/src/checkbox-control/style.scss +4 -2
- package/src/circular-option-picker/README.md +1 -2
- package/src/circular-option-picker/circular-option-picker-option.tsx +17 -10
- package/src/circular-option-picker/circular-option-picker.tsx +0 -1
- package/src/circular-option-picker/stories/index.story.tsx +0 -1
- package/src/circular-option-picker/style.scss +10 -5
- package/src/color-palette/index.tsx +0 -7
- package/src/color-palette/test/index.tsx +2 -8
- package/src/combobox-control/test/index.tsx +1 -1
- package/src/drop-zone/style.scss +6 -9
- package/src/font-size-picker/index.native.js +1 -1
- package/src/form-toggle/style.scss +17 -10
- package/src/form-token-field/style.scss +9 -4
- package/src/higher-order/navigate-regions/style.scss +2 -2
- package/src/higher-order/with-focus-return/index.tsx +1 -1
- package/src/input-control/styles/input-control-styles.tsx +6 -0
- package/src/menu/README.md +421 -174
- package/src/menu/checkbox-item.tsx +12 -12
- package/src/menu/context.tsx +2 -4
- package/src/menu/docs-manifest.json +62 -0
- package/src/menu/group-label.tsx +7 -7
- package/src/menu/group.tsx +7 -11
- package/src/menu/index.tsx +101 -31
- package/src/menu/item-help-text.tsx +5 -7
- package/src/menu/item-label.tsx +5 -7
- package/src/menu/item.tsx +12 -12
- package/src/menu/popover.tsx +9 -9
- package/src/menu/radio-item.tsx +12 -12
- package/src/menu/separator.tsx +7 -7
- package/src/menu/stories/best-practices.mdx +38 -0
- package/src/menu/stories/index.story.tsx +8 -8
- package/src/menu/styles.ts +24 -24
- package/src/menu/submenu-trigger-item.tsx +9 -9
- package/src/menu/trigger-button.tsx +6 -6
- package/src/menu/types.ts +10 -10
- package/src/menu-group/stories/index.story.tsx +2 -2
- package/src/mobile/bottom-sheet/nav-bar/action-button.native.js +1 -1
- package/src/mobile/utils/get-px-from-css-unit.native.js +3 -3
- package/src/modal/style.scss +4 -2
- package/src/modal/test/index.tsx +5 -4
- package/src/notice/README.md +3 -3
- package/src/notice/types.ts +1 -1
- package/src/palette-edit/test/index.tsx +1 -1
- package/src/panel/style.scss +14 -6
- package/src/placeholder/style.scss +5 -3
- package/src/progress-bar/stories/index.story.tsx +1 -1
- package/src/resizable-box/style.scss +14 -9
- package/src/search-control/index.tsx +1 -1
- package/src/tab-panel/style.scss +6 -4
- package/src/tabs/stories/index.story.tsx +0 -131
- package/src/text/README.md +1 -1
- package/src/text/hook.ts +3 -2
- package/src/text/stories/index.story.tsx +2 -2
- package/src/text/test/index.tsx +1 -1
- package/src/text/utils.ts +1 -1
- package/src/text-highlight/test/index.tsx +3 -3
- package/src/toolbar/toolbar/style.scss +4 -3
- package/tsconfig.tsbuildinfo +1 -1
package/src/menu/README.md
CHANGED
|
@@ -1,344 +1,591 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Menu
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
18
|
+
## Props
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
- Only see the available choices contextually.
|
|
20
|
+
### `as`
|
|
19
21
|
|
|
20
|
-
`
|
|
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
|
-
|
|
25
|
+
The HTML element or React component to render the component as.
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
Use a `Menu` to display a list of actions after the user interacts with an icon.
|
|
27
|
+
### `children`
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
- Type: `ReactNode`
|
|
30
|
+
- Required: No
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
35
|
+
### `defaultOpen`
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
- Type: `boolean`
|
|
38
|
+
- Required: No
|
|
39
|
+
- Default: `false`
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
Whether the menu popover and its contents should be visible by default.
|
|
37
42
|
|
|
38
|
-
|
|
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
|
-
|
|
46
|
+
### `open`
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
- Type: `boolean`
|
|
49
|
+
- Required: No
|
|
43
50
|
|
|
44
|
-
|
|
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
|
-
|
|
55
|
+
Note: this prop will set the component in "controlled" mode, and it will
|
|
56
|
+
override the `defaultOpen` prop.
|
|
47
57
|
|
|
48
|
-
### `
|
|
58
|
+
### `onOpenChange`
|
|
49
59
|
|
|
50
|
-
|
|
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
|
-
|
|
82
|
+
##### `accessibleWhenDisabled`
|
|
55
83
|
|
|
56
|
-
|
|
84
|
+
- Type: `boolean`
|
|
85
|
+
- Required: No
|
|
57
86
|
|
|
58
|
-
|
|
87
|
+
Indicates whether the element should be focusable even when it is
|
|
88
|
+
`disabled`.
|
|
59
89
|
|
|
60
|
-
|
|
90
|
+
This is important when discoverability is a concern. For example:
|
|
61
91
|
|
|
62
|
-
|
|
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
|
-
|
|
98
|
+
Learn more on [Focusability of disabled
|
|
99
|
+
controls](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols).
|
|
65
100
|
|
|
66
|
-
|
|
101
|
+
##### `children`
|
|
67
102
|
|
|
68
|
-
|
|
103
|
+
- Type: `ReactNode`
|
|
104
|
+
- Required: No
|
|
69
105
|
|
|
70
|
-
The
|
|
106
|
+
The contents of the menu trigger button.
|
|
71
107
|
|
|
72
|
-
|
|
73
|
-
- Default: `false`
|
|
108
|
+
##### `disabled`
|
|
74
109
|
|
|
75
|
-
|
|
110
|
+
- Type: `boolean`
|
|
111
|
+
- Required: No
|
|
112
|
+
- Default: `false`
|
|
76
113
|
|
|
77
|
-
|
|
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
|
-
|
|
118
|
+
This feature can be combined with the `accessibleWhenDisabled` prop to
|
|
119
|
+
make disabled elements still accessible via keyboard.
|
|
80
120
|
|
|
81
|
-
##### `
|
|
121
|
+
##### `render`
|
|
82
122
|
|
|
83
|
-
|
|
123
|
+
- Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
|
|
124
|
+
- Required: No
|
|
84
125
|
|
|
85
|
-
|
|
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
|
-
|
|
131
|
+
### Menu.Popover
|
|
88
132
|
|
|
89
|
-
|
|
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
|
-
|
|
92
|
-
|
|
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
|
-
|
|
141
|
+
#### Props
|
|
95
142
|
|
|
96
|
-
|
|
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
|
-
|
|
99
|
-
|
|
166
|
+
Determines if the menu popover will hide when the user presses the
|
|
167
|
+
Escape key.
|
|
100
168
|
|
|
101
|
-
|
|
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
|
-
|
|
174
|
+
##### `modal`
|
|
104
175
|
|
|
105
|
-
-
|
|
106
|
-
|
|
176
|
+
- Type: `boolean`
|
|
177
|
+
- Required: No
|
|
178
|
+
- Default: `true`
|
|
107
179
|
|
|
108
|
-
|
|
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
|
-
|
|
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
|
-
|
|
113
|
-
- Default: `0` for root-level menus, `-8` for nested menus
|
|
190
|
+
##### `shift`
|
|
114
191
|
|
|
115
|
-
|
|
192
|
+
- Type: `number`
|
|
193
|
+
- Required: No
|
|
194
|
+
- Default: `0 for root-level menus, -8 for nested menus`
|
|
116
195
|
|
|
117
|
-
|
|
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
|
-
|
|
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
|
-
##### `
|
|
217
|
+
##### `disabled`
|
|
124
218
|
|
|
125
|
-
|
|
219
|
+
- Type: `boolean`
|
|
220
|
+
- Required: No
|
|
221
|
+
- Default: `false`
|
|
126
222
|
|
|
127
|
-
-
|
|
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
|
-
##### `
|
|
227
|
+
##### `hideOnClick`
|
|
130
228
|
|
|
131
|
-
|
|
229
|
+
- Type: `BooleanOrCallback<MouseEvent<HTMLElement, MouseEvent>>`
|
|
230
|
+
- Required: No
|
|
231
|
+
- Default: `true`
|
|
132
232
|
|
|
133
|
-
|
|
233
|
+
Determines if the menu should hide when this item is clicked.
|
|
134
234
|
|
|
135
|
-
|
|
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
|
-
|
|
239
|
+
##### `prefix`
|
|
138
240
|
|
|
139
|
-
-
|
|
241
|
+
- Type: `ReactNode`
|
|
242
|
+
- Required: No
|
|
140
243
|
|
|
141
|
-
|
|
244
|
+
The contents of the menu item's prefix, such as an icon.
|
|
142
245
|
|
|
143
|
-
|
|
246
|
+
##### `render`
|
|
144
247
|
|
|
145
|
-
-
|
|
146
|
-
-
|
|
248
|
+
- Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
|
|
249
|
+
- Required: No
|
|
147
250
|
|
|
148
|
-
|
|
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
|
-
|
|
256
|
+
##### `suffix`
|
|
151
257
|
|
|
152
|
-
-
|
|
153
|
-
-
|
|
258
|
+
- Type: `ReactNode`
|
|
259
|
+
- Required: No
|
|
154
260
|
|
|
155
|
-
|
|
261
|
+
The contents of the menu item's suffix, such as a keyboard shortcut.
|
|
156
262
|
|
|
157
|
-
|
|
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
|
-
|
|
273
|
+
##### `children`
|
|
162
274
|
|
|
163
|
-
|
|
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
|
-
|
|
282
|
+
##### `checked`
|
|
168
283
|
|
|
169
|
-
|
|
284
|
+
- Type: `boolean`
|
|
285
|
+
- Required: No
|
|
170
286
|
|
|
171
|
-
The
|
|
287
|
+
The controlled checked state of the radio menu item.
|
|
172
288
|
|
|
173
|
-
|
|
289
|
+
Note: this prop will override the `defaultChecked` prop.
|
|
174
290
|
|
|
175
|
-
##### `
|
|
291
|
+
##### `disabled`
|
|
176
292
|
|
|
177
|
-
|
|
293
|
+
- Type: `boolean`
|
|
294
|
+
- Required: No
|
|
295
|
+
- Default: `false`
|
|
178
296
|
|
|
179
|
-
-
|
|
180
|
-
|
|
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
|
-
##### `
|
|
301
|
+
##### `defaultChecked`
|
|
183
302
|
|
|
184
|
-
|
|
303
|
+
- Type: `boolean`
|
|
304
|
+
- Required: No
|
|
185
305
|
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
309
|
+
Note: this prop will be overriden by the `checked` prop, if it is defined.
|
|
190
310
|
|
|
191
|
-
|
|
311
|
+
##### `hideOnClick`
|
|
192
312
|
|
|
193
|
-
-
|
|
313
|
+
- Type: `BooleanOrCallback<MouseEvent<HTMLElement, MouseEvent>>`
|
|
314
|
+
- Required: No
|
|
315
|
+
- Default: `false`
|
|
194
316
|
|
|
195
|
-
|
|
317
|
+
Determines if the menu should hide when this item is clicked.
|
|
196
318
|
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
323
|
+
##### `name`
|
|
201
324
|
|
|
202
|
-
|
|
325
|
+
- Type: `string`
|
|
326
|
+
- Required: Yes
|
|
203
327
|
|
|
204
|
-
The
|
|
205
|
-
|
|
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
|
-
|
|
337
|
+
##### `render`
|
|
208
338
|
|
|
209
|
-
|
|
339
|
+
- Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
|
|
340
|
+
- Required: No
|
|
210
341
|
|
|
211
|
-
|
|
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
|
-
|
|
347
|
+
##### `suffix`
|
|
214
348
|
|
|
215
|
-
|
|
349
|
+
- Type: `ReactNode`
|
|
350
|
+
- Required: No
|
|
216
351
|
|
|
217
|
-
|
|
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
|
-
|
|
361
|
+
### Menu.CheckboxItem
|
|
220
362
|
|
|
221
|
-
|
|
363
|
+
Renders a checkbox menu item inside the `Menu.Popover` or `Menu.Group`
|
|
364
|
+
components.
|
|
222
365
|
|
|
223
|
-
|
|
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
|
-
|
|
371
|
+
##### `children`
|
|
228
372
|
|
|
229
|
-
|
|
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
|
-
|
|
380
|
+
##### `checked`
|
|
234
381
|
|
|
235
|
-
|
|
382
|
+
- Type: `boolean`
|
|
383
|
+
- Required: No
|
|
236
384
|
|
|
237
|
-
The
|
|
385
|
+
The controlled checked state of the checkbox menu item.
|
|
238
386
|
|
|
239
|
-
|
|
387
|
+
Note: this prop will override the `defaultChecked` prop.
|
|
240
388
|
|
|
241
|
-
##### `
|
|
389
|
+
##### `disabled`
|
|
242
390
|
|
|
243
|
-
|
|
391
|
+
- Type: `boolean`
|
|
392
|
+
- Required: No
|
|
393
|
+
- Default: `false`
|
|
244
394
|
|
|
245
|
-
-
|
|
246
|
-
|
|
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
|
-
##### `
|
|
399
|
+
##### `defaultChecked`
|
|
249
400
|
|
|
250
|
-
|
|
401
|
+
- Type: `boolean`
|
|
402
|
+
- Required: No
|
|
251
403
|
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
407
|
+
Note: this prop will be overriden by the `checked` prop, if it is defined.
|
|
256
408
|
|
|
257
|
-
|
|
409
|
+
##### `hideOnClick`
|
|
258
410
|
|
|
259
|
-
-
|
|
411
|
+
- Type: `BooleanOrCallback<MouseEvent<HTMLElement, MouseEvent>>`
|
|
412
|
+
- Required: No
|
|
413
|
+
- Default: `false`
|
|
260
414
|
|
|
261
|
-
|
|
415
|
+
Determines if the menu should hide when this item is clicked.
|
|
262
416
|
|
|
263
|
-
|
|
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
|
-
|
|
421
|
+
##### `name`
|
|
266
422
|
|
|
267
|
-
|
|
423
|
+
- Type: `string`
|
|
424
|
+
- Required: Yes
|
|
268
425
|
|
|
269
|
-
The checkbox item's
|
|
270
|
-
|
|
426
|
+
The checkbox menu item's name.
|
|
427
|
+
|
|
428
|
+
##### `onChange`
|
|
429
|
+
|
|
430
|
+
- Type: `ChangeEventHandler<HTMLInputElement>`
|
|
431
|
+
- Required: No
|
|
271
432
|
|
|
272
|
-
|
|
433
|
+
A function that is called when the checkbox's checked state changes.
|
|
273
434
|
|
|
274
|
-
##### `
|
|
435
|
+
##### `render`
|
|
275
436
|
|
|
276
|
-
|
|
437
|
+
- Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
|
|
438
|
+
- Required: No
|
|
277
439
|
|
|
278
|
-
|
|
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
|
-
##### `
|
|
445
|
+
##### `suffix`
|
|
281
446
|
|
|
282
|
-
|
|
447
|
+
- Type: `ReactNode`
|
|
448
|
+
- Required: No
|
|
283
449
|
|
|
284
|
-
|
|
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
|
-
###
|
|
460
|
+
### Menu.ItemLabel
|
|
287
461
|
|
|
288
|
-
|
|
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
|
-
|
|
467
|
+
##### `as`
|
|
293
468
|
|
|
294
|
-
|
|
469
|
+
- Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | ...`
|
|
470
|
+
- Required: No
|
|
295
471
|
|
|
296
|
-
The
|
|
472
|
+
The HTML element or React component to render the component as.
|
|
297
473
|
|
|
298
|
-
|
|
474
|
+
### Menu.ItemHelpText
|
|
299
475
|
|
|
300
|
-
|
|
476
|
+
Renders a menu item's help text. It should be wrapped with `Menu.Item`,
|
|
477
|
+
`Menu.RadioItem`, or `Menu.CheckboxItem`.
|
|
301
478
|
|
|
302
|
-
|
|
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
|
-
|
|
497
|
+
##### `children`
|
|
307
498
|
|
|
308
|
-
|
|
499
|
+
- Type: `ReactNode`
|
|
500
|
+
- Required: Yes
|
|
309
501
|
|
|
310
|
-
The
|
|
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
|
-
|
|
506
|
+
### Menu.GroupLabel
|
|
313
507
|
|
|
314
|
-
|
|
508
|
+
Renders a label in a menu group.
|
|
315
509
|
|
|
316
|
-
|
|
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
|
-
|
|
515
|
+
##### `children`
|
|
321
516
|
|
|
322
|
-
|
|
517
|
+
- Type: `ReactNode`
|
|
518
|
+
- Required: Yes
|
|
323
519
|
|
|
324
|
-
The contents of the menu group
|
|
520
|
+
The contents of the menu group label, which should provide an accessible
|
|
521
|
+
label for the menu group.
|
|
325
522
|
|
|
326
|
-
|
|
523
|
+
### Menu.Separator
|
|
327
524
|
|
|
328
|
-
|
|
525
|
+
Renders a divider between menu items or menu groups.
|
|
329
526
|
|
|
330
|
-
|
|
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
|
-
|
|
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
|
-
|
|
578
|
+
- Type: `ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>`
|
|
579
|
+
- Required: No
|
|
337
580
|
|
|
338
|
-
|
|
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
|
-
|
|
586
|
+
##### `suffix`
|
|
341
587
|
|
|
342
|
-
|
|
588
|
+
- Type: `ReactNode`
|
|
589
|
+
- Required: No
|
|
343
590
|
|
|
344
|
-
|
|
591
|
+
The contents of the menu item's suffix, such as a keyboard shortcut.
|