@primer/components 32.1.1-rc.b4502a34 → 33.0.0-rc.9f3670b7
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 +15 -1
- package/contributor-docs/CONTRIBUTING.md +14 -58
- package/dist/browser.esm.js +104 -108
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +104 -108
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/BranchName.md +6 -5
- package/docs/content/Details.md +4 -8
- package/docs/content/Heading.md +5 -10
- package/docs/content/Label.md +6 -7
- package/docs/content/ProgressBar.mdx +7 -6
- package/docs/content/Text.md +0 -6
- package/docs/content/{ActionList2.mdx → drafts/ActionList2.mdx} +5 -9
- package/docs/content/drafts/ActionMenu2.mdx +251 -0
- package/docs/content/status.mdx +1 -1
- package/docs/content/system-props.mdx +1 -1
- package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +9 -1
- package/docs/src/@primer/gatsby-theme-doctocat/nav.yml +1 -1
- package/lib/ActionList2/Divider.d.ts +3 -2
- package/lib/ActionList2/Divider.js +10 -5
- package/lib/ActionList2/Item.js +21 -5
- package/lib/ActionList2/List.js +11 -1
- package/lib/ActionList2/MenuContext.d.ts +10 -0
- package/lib/ActionList2/MenuContext.js +15 -0
- package/lib/ActionList2/Selection.js +11 -0
- package/lib/ActionList2/index.d.ts +1 -2
- package/lib/ActionMenu2.d.ts +310 -0
- package/lib/ActionMenu2.js +91 -0
- package/lib/Avatar.d.ts +1 -2
- package/lib/Avatar.js +1 -1
- package/lib/BranchName.d.ts +1 -2
- package/lib/BranchName.js +1 -1
- package/lib/Details.d.ts +1 -2
- package/lib/Details.js +1 -3
- package/lib/Dropdown.d.ts +2 -66
- package/lib/Heading.d.ts +1 -2
- package/lib/Heading.js +1 -6
- package/lib/ProgressBar.d.ts +16 -11
- package/lib/ProgressBar.js +6 -10
- package/lib/Spinner.d.ts +1 -2
- package/lib/Spinner.js +1 -3
- package/lib/__tests__/Avatar.test.js +4 -2
- package/lib/__tests__/Avatar.types.test.d.ts +3 -0
- package/lib/__tests__/Avatar.types.test.js +31 -0
- package/lib/__tests__/BranchName.types.test.d.ts +3 -0
- package/lib/__tests__/BranchName.types.test.js +28 -0
- package/lib/__tests__/Details.types.test.d.ts +3 -0
- package/lib/__tests__/Details.types.test.js +28 -0
- package/lib/__tests__/Heading.test.js +63 -30
- package/lib/__tests__/Heading.types.test.d.ts +3 -0
- package/lib/__tests__/Heading.types.test.js +28 -0
- package/lib/drafts.d.ts +1 -0
- package/lib/drafts.js +13 -0
- package/lib/stories/ActionMenu2.stories.js +433 -0
- package/lib-esm/ActionList2/Divider.d.ts +3 -2
- package/lib-esm/ActionList2/Divider.js +8 -5
- package/lib-esm/ActionList2/Item.js +19 -5
- package/lib-esm/ActionList2/List.js +9 -1
- package/lib-esm/ActionList2/MenuContext.d.ts +10 -0
- package/lib-esm/ActionList2/MenuContext.js +3 -0
- package/lib-esm/ActionList2/Selection.js +9 -0
- package/lib-esm/ActionList2/index.d.ts +1 -2
- package/lib-esm/ActionMenu2.d.ts +310 -0
- package/lib-esm/ActionMenu2.js +67 -0
- package/lib-esm/Avatar.d.ts +1 -2
- package/lib-esm/Avatar.js +2 -2
- package/lib-esm/BranchName.d.ts +1 -2
- package/lib-esm/BranchName.js +2 -2
- package/lib-esm/Details.d.ts +1 -2
- package/lib-esm/Details.js +1 -2
- package/lib-esm/Dropdown.d.ts +2 -66
- package/lib-esm/Heading.d.ts +1 -2
- package/lib-esm/Heading.js +2 -6
- package/lib-esm/ProgressBar.d.ts +16 -11
- package/lib-esm/ProgressBar.js +7 -11
- package/lib-esm/Spinner.d.ts +1 -2
- package/lib-esm/Spinner.js +1 -2
- package/lib-esm/__tests__/Avatar.test.js +4 -2
- package/lib-esm/__tests__/Avatar.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Avatar.types.test.js +16 -0
- package/lib-esm/__tests__/BranchName.types.test.d.ts +3 -0
- package/lib-esm/__tests__/BranchName.types.test.js +13 -0
- package/lib-esm/__tests__/Details.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Details.types.test.js +13 -0
- package/lib-esm/__tests__/Heading.test.js +62 -30
- package/lib-esm/__tests__/Heading.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Heading.types.test.js +13 -0
- package/lib-esm/drafts.d.ts +1 -0
- package/lib-esm/drafts.js +2 -1
- package/lib-esm/stories/ActionMenu2.stories.js +376 -0
- package/package.json +1 -1
- package/src/ActionList2/Divider.tsx +13 -8
- package/src/ActionList2/Item.tsx +13 -3
- package/src/ActionList2/List.tsx +6 -2
- package/src/ActionList2/MenuContext.tsx +6 -0
- package/src/ActionList2/Selection.tsx +9 -0
- package/src/ActionMenu2.tsx +94 -0
- package/src/Avatar.tsx +2 -4
- package/src/BranchName.tsx +3 -3
- package/src/Details.tsx +1 -5
- package/src/Heading.tsx +2 -9
- package/src/ProgressBar.tsx +11 -10
- package/src/Spinner.tsx +1 -3
- package/src/__tests__/Avatar.test.tsx +1 -1
- package/src/__tests__/Avatar.types.test.tsx +11 -0
- package/src/__tests__/BranchName.types.test.tsx +11 -0
- package/src/__tests__/Details.types.test.tsx +11 -0
- package/src/__tests__/Heading.test.tsx +71 -25
- package/src/__tests__/Heading.types.test.tsx +11 -0
- package/src/drafts.ts +1 -0
- package/src/stories/ActionMenu2.stories.tsx +551 -0
- package/stats.html +1 -1
@@ -12,15 +12,16 @@ BranchName is a label-type component rendered as an `<a>` tag by default with mo
|
|
12
12
|
|
13
13
|
## Props
|
14
14
|
|
15
|
-
| Name | Type
|
16
|
-
| :--- |
|
17
|
-
| as | String
|
18
|
-
| href | String
|
15
|
+
| Name | Type | Default | Description |
|
16
|
+
| :--- | :---------------- | :-----: | :----------------------------------- |
|
17
|
+
| as | String | `<a>` | sets the HTML tag for the component |
|
18
|
+
| href | String | | a URL to link the component to |
|
19
|
+
| sx | SystemStyleObject | {} | Style to be applied to the component |
|
19
20
|
|
20
21
|
## Component status
|
21
22
|
|
22
23
|
<ComponentChecklist
|
23
|
-
|
24
|
+
items={{
|
24
25
|
propsDocumented: true,
|
25
26
|
noUnnecessaryDeps: true,
|
26
27
|
adaptsToThemes: true,
|
package/docs/content/Details.md
CHANGED
@@ -79,15 +79,11 @@ In previous versions of Primer React Components, we allowed users to pass in a c
|
|
79
79
|
</State>
|
80
80
|
```
|
81
81
|
|
82
|
-
##
|
82
|
+
## Details props
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
</Note>
|
89
|
-
|
90
|
-
Details components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
|
84
|
+
| Name | Type | Default | Description |
|
85
|
+
| :--- | :---------------- | :-----: | :----------------------------------- |
|
86
|
+
| sx | SystemStyleObject | {} | Style to be applied to the component |
|
91
87
|
|
92
88
|
## `useDetails` hook configuration options
|
93
89
|
|
package/docs/content/Heading.md
CHANGED
@@ -10,17 +10,12 @@ The Heading component will render an html `h2` tag without any default styling.
|
|
10
10
|
## Default example
|
11
11
|
|
12
12
|
```jsx live
|
13
|
-
<Heading
|
14
|
-
H2 heading with fontSize={1}
|
15
|
-
</Heading>
|
13
|
+
<Heading sx={{fontSize: 1, mb: 2}}>H2 heading with fontSize={1}</Heading>
|
16
14
|
```
|
17
15
|
|
18
|
-
## System props
|
19
|
-
|
20
|
-
Heading components get `TYPOGRAPHY` and `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
|
21
|
-
|
22
16
|
## Component props
|
23
17
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
| as
|
18
|
+
| Name | Type | Default | Description |
|
19
|
+
| :--- | :---------------------- | :-----: | :----------------------------------- |
|
20
|
+
| as | String or React element | | sets the HTML tag for the component |
|
21
|
+
| sx | SystemStyleObject | {} | Style to be applied to the component |
|
package/docs/content/Label.md
CHANGED
@@ -41,10 +41,9 @@ The Label component is used to add contextual metadata to a design. Visually it
|
|
41
41
|
|
42
42
|
## Component props
|
43
43
|
|
44
|
-
| Name | Type |
|
45
|
-
| :--------- | :---------------- |
|
46
|
-
| outline | Boolean |
|
47
|
-
| variant | String |
|
48
|
-
| dropshadow | Boolean |
|
49
|
-
|
|
50
|
-
| sx | SystemStyleObject | {} | Style to be applied to the component |
|
44
|
+
| Name | Type | Default | Description |
|
45
|
+
| :--------- | :---------------- | :------: | :----------------------------------------------------------- |
|
46
|
+
| outline | Boolean | | Creates an outline style label |
|
47
|
+
| variant | String | 'medium' | Can be one of `small`, `medium` (default), `large` or `xl` . |
|
48
|
+
| dropshadow | Boolean | | Adds a dropshadow to the label |
|
49
|
+
| sx | SystemStyleObject | {} | Style to be applied to the component |
|
@@ -22,9 +22,10 @@ If you'd like to use ProgressBar inline, pass the `inline` boolean prop & **be s
|
|
22
22
|
|
23
23
|
## Component props
|
24
24
|
|
25
|
-
| Name | Type
|
26
|
-
| :------- |
|
27
|
-
| progress | Number
|
28
|
-
| barSize | String
|
29
|
-
| inline | Boolean
|
30
|
-
| bg | String
|
25
|
+
| Name | Type | Default | Description |
|
26
|
+
| :------- | :---------------- | :-----------------: | :------------------------------------------------------------------------------------------------------------------------------- |
|
27
|
+
| progress | Number | | Used to set the size of the green bar |
|
28
|
+
| barSize | String | 'default' | Controls the height of the progress bar. Can be 'small', 'large', or 'default'. If omitted, height is set to the default height. |
|
29
|
+
| inline | Boolean | false | Styles the progress bar inline |
|
30
|
+
| bg | String | 'bg.successInverse' | Set the progress bar color, defaults to bg-green |
|
31
|
+
| sx | SystemStyleObject | {} | Style to be applied to the component |
|
package/docs/content/Text.md
CHANGED
@@ -23,12 +23,6 @@ The Text component is a wrapper component that will apply typography styles to t
|
|
23
23
|
|
24
24
|
## System props
|
25
25
|
|
26
|
-
<Note variant="warning">
|
27
|
-
|
28
|
-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
|
29
|
-
|
30
|
-
</Note>
|
31
|
-
|
32
26
|
Text components get `TYPOGRAPHY` and `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
|
33
27
|
|
34
28
|
## Component props
|
@@ -6,16 +6,13 @@ storybook: '/react/storybook?path=/story/composite-components-actionlist2'
|
|
6
6
|
description: An ActionList is a list of items that can be activated or selected. ActionList is the base component for many menu-type components, including DropdownMenu and ActionMenu.
|
7
7
|
---
|
8
8
|
|
9
|
-
import {
|
9
|
+
import {Box, Avatar} from '@primer/components'
|
10
10
|
import {ActionList} from '@primer/components/drafts'
|
11
|
-
import {ComponentChecklist} from '../src/component-checklist'
|
12
|
-
|
13
|
-
import {ImageContainer} from '@primer/gatsby-theme-doctocat'
|
14
11
|
import {LinkIcon, AlertIcon, ArrowRightIcon} from '@primer/octicons-react'
|
15
12
|
|
16
13
|
<br />
|
17
14
|
|
18
|
-
<
|
15
|
+
<Box sx={{border: '1px solid', borderColor: 'border.default', borderRadius: 2, padding: 6}}>
|
19
16
|
<ActionList sx={{width: 320}}>
|
20
17
|
<ActionList.Item>
|
21
18
|
<ActionList.LeadingVisual>
|
@@ -43,7 +40,7 @@ import {LinkIcon, AlertIcon, ArrowRightIcon} from '@primer/octicons-react'
|
|
43
40
|
</ActionList.TrailingVisual>
|
44
41
|
</ActionList.Item>
|
45
42
|
</ActionList>
|
46
|
-
</
|
43
|
+
</Box>
|
47
44
|
|
48
45
|
<br />
|
49
46
|
|
@@ -351,11 +348,10 @@ render(<SelectFields />)
|
|
351
348
|
|
352
349
|
- [Interface guidelines: Action List](https://primer.style/design/components/action-list)
|
353
350
|
|
354
|
-
<br />
|
355
|
-
|
356
351
|
## Related components
|
357
352
|
|
358
|
-
- [ActionMenu](/
|
353
|
+
- [ActionMenu](/drafts/ActionMenu2)
|
354
|
+
- [DropdownMenu](/DropdownMenu)
|
359
355
|
- [SelectPanel](/SelectPanel)
|
360
356
|
|
361
357
|
## Component status
|
@@ -0,0 +1,251 @@
|
|
1
|
+
---
|
2
|
+
title: ActionMenu
|
3
|
+
status: Alpha
|
4
|
+
source: https://github.com/primer/react/tree/main/src/ActionMenu
|
5
|
+
storybook: '/react/storybook?path=/story/composite-components-actionmenu2'
|
6
|
+
description: An ActionMenu is an ActionList-based component for creating a menu of actions that expands through a trigger button.
|
7
|
+
---
|
8
|
+
|
9
|
+
import {Box, Avatar} from '@primer/components'
|
10
|
+
import {ActionMenu, ActionList} from '@primer/components/drafts'
|
11
|
+
import {Props} from '../../src/props'
|
12
|
+
|
13
|
+
<br />
|
14
|
+
|
15
|
+
<Box sx={{border: '1px solid', borderColor: 'border.default', borderRadius: 2, padding: 6}}>
|
16
|
+
<ActionMenu>
|
17
|
+
<ActionMenu.Button>Menu</ActionMenu.Button>
|
18
|
+
<ActionList>
|
19
|
+
<ActionList.Item onSelect={() => onSelect('Copy link')}>
|
20
|
+
Copy link
|
21
|
+
<ActionList.TrailingVisual>⌘C</ActionList.TrailingVisual>
|
22
|
+
</ActionList.Item>
|
23
|
+
<ActionList.Item onSelect={() => onSelect('Quote reply')}>
|
24
|
+
Quote reply
|
25
|
+
<ActionList.TrailingVisual>⌘Q</ActionList.TrailingVisual>
|
26
|
+
</ActionList.Item>
|
27
|
+
<ActionList.Item onSelect={() => onSelect('Edit comment')}>
|
28
|
+
Edit comment
|
29
|
+
<ActionList.TrailingVisual>⌘E</ActionList.TrailingVisual>
|
30
|
+
</ActionList.Item>
|
31
|
+
<ActionList.Divider />
|
32
|
+
<ActionList.Item variant="danger" onSelect={() => onSelect('Delete file')}>
|
33
|
+
Delete file
|
34
|
+
<ActionList.TrailingVisual>⌘D</ActionList.TrailingVisual>
|
35
|
+
</ActionList.Item>
|
36
|
+
</ActionList>
|
37
|
+
|
38
|
+
</ActionMenu>
|
39
|
+
</Box>
|
40
|
+
|
41
|
+
<br />
|
42
|
+
|
43
|
+
```js
|
44
|
+
import {ActionMenu} from '@primer/components/drafts'
|
45
|
+
```
|
46
|
+
|
47
|
+
<br />
|
48
|
+
|
49
|
+
## Examples
|
50
|
+
|
51
|
+
### Minimal example
|
52
|
+
|
53
|
+
`ActionMenu` ships with `ActionMenu.Button` which is an accessible trigger for the overlay. It's recommended to compose `ActionList` with this component.
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```javascript live noinline
|
58
|
+
// import {ActionMenu, ActionList} from '@primer/components/drafts'
|
59
|
+
const {ActionMenu, ActionList} = drafts // ignore docs silliness; import like that ↑
|
60
|
+
|
61
|
+
render(
|
62
|
+
<ActionMenu>
|
63
|
+
<ActionMenu.Button>Menu</ActionMenu.Button>
|
64
|
+
|
65
|
+
<ActionList>
|
66
|
+
<ActionList.Item onSelect={event => console.log('New file')}>New file</ActionList.Item>
|
67
|
+
<ActionList.Item>Copy link</ActionList.Item>
|
68
|
+
<ActionList.Item>Edit file</ActionList.Item>
|
69
|
+
<ActionList.Divider />
|
70
|
+
<ActionList.Item variant="danger">Delete file</ActionList.Item>
|
71
|
+
</ActionList>
|
72
|
+
</ActionMenu>
|
73
|
+
)
|
74
|
+
```
|
75
|
+
|
76
|
+
### With a custom anchor
|
77
|
+
|
78
|
+
You can choose to have a different _anchor_ for the Menu dependending on the application's context.
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
```javascript live noinline
|
83
|
+
// import {ActionMenu, ActionList} from '@primer/components/drafts'
|
84
|
+
const {ActionMenu, ActionList} = drafts // ignore docs silliness; import like that ↑
|
85
|
+
|
86
|
+
render(
|
87
|
+
<ActionMenu>
|
88
|
+
<ActionMenu.Anchor>
|
89
|
+
<ButtonInvisible aria-label="Open column options">
|
90
|
+
<KebabHorizontalIcon />
|
91
|
+
</ButtonInvisible>
|
92
|
+
</ActionMenu.Anchor>
|
93
|
+
|
94
|
+
<ActionList>
|
95
|
+
<ActionList.Item>
|
96
|
+
<ActionList.LeadingVisual>
|
97
|
+
<PencilIcon />
|
98
|
+
</ActionList.LeadingVisual>
|
99
|
+
Rename
|
100
|
+
</ActionList.Item>
|
101
|
+
<ActionList.Item>
|
102
|
+
<ActionList.LeadingVisual>
|
103
|
+
<ArchiveIcon />
|
104
|
+
</ActionList.LeadingVisual>
|
105
|
+
Archive all cards
|
106
|
+
</ActionList.Item>
|
107
|
+
<ActionList.Item variant="danger">
|
108
|
+
<ActionList.LeadingVisual>
|
109
|
+
<TrashIcon />
|
110
|
+
</ActionList.LeadingVisual>
|
111
|
+
Delete
|
112
|
+
</ActionList.Item>
|
113
|
+
</ActionList>
|
114
|
+
</ActionMenu>
|
115
|
+
)
|
116
|
+
```
|
117
|
+
|
118
|
+
### With Groups
|
119
|
+
|
120
|
+
```javascript live noinline
|
121
|
+
// import {ActionMenu, ActionList} from '@primer/components/drafts'
|
122
|
+
const {ActionMenu, ActionList} = drafts // ignore docs silliness; import like that ↑
|
123
|
+
|
124
|
+
render(
|
125
|
+
<ActionMenu>
|
126
|
+
<ActionMenu.Button>Open column menu</ActionMenu.Button>
|
127
|
+
|
128
|
+
<ActionList showDividers>
|
129
|
+
<ActionList.Group title="Live query">
|
130
|
+
<ActionList.Item>
|
131
|
+
<ActionList.LeadingVisual>
|
132
|
+
<SearchIcon />
|
133
|
+
</ActionList.LeadingVisual>
|
134
|
+
repo:github/memex,github/github
|
135
|
+
</ActionList.Item>
|
136
|
+
</ActionList.Group>
|
137
|
+
<ActionList.Divider />
|
138
|
+
<ActionList.Group title="Layout" variant="subtle">
|
139
|
+
<ActionList.Item>
|
140
|
+
<ActionList.LeadingVisual>
|
141
|
+
<NoteIcon />
|
142
|
+
</ActionList.LeadingVisual>
|
143
|
+
Table
|
144
|
+
<ActionList.Description variant="block">
|
145
|
+
Information-dense table optimized for operations across teams
|
146
|
+
</ActionList.Description>
|
147
|
+
</ActionList.Item>
|
148
|
+
<ActionList.Item role="listitem">
|
149
|
+
<ActionList.LeadingVisual>
|
150
|
+
<ProjectIcon />
|
151
|
+
</ActionList.LeadingVisual>
|
152
|
+
Board
|
153
|
+
<ActionList.Description variant="block">Kanban-style board focused on visual states</ActionList.Description>
|
154
|
+
</ActionList.Item>
|
155
|
+
</ActionList.Group>
|
156
|
+
<ActionList.Divider />
|
157
|
+
<ActionList.Group>
|
158
|
+
<ActionList.Item>
|
159
|
+
<ActionList.LeadingVisual>
|
160
|
+
<FilterIcon />
|
161
|
+
</ActionList.LeadingVisual>
|
162
|
+
Save sort and filters to current view
|
163
|
+
</ActionList.Item>
|
164
|
+
<ActionList.Item>
|
165
|
+
<ActionList.LeadingVisual>
|
166
|
+
<FilterIcon />
|
167
|
+
</ActionList.LeadingVisual>
|
168
|
+
Save sort and filters to new view
|
169
|
+
</ActionList.Item>
|
170
|
+
</ActionList.Group>
|
171
|
+
<ActionList.Divider />
|
172
|
+
<ActionList.Group>
|
173
|
+
<ActionList.Item>
|
174
|
+
<ActionList.LeadingVisual>
|
175
|
+
<GearIcon />
|
176
|
+
</ActionList.LeadingVisual>
|
177
|
+
View settings
|
178
|
+
</ActionList.Item>
|
179
|
+
</ActionList.Group>
|
180
|
+
</ActionList>
|
181
|
+
</ActionMenu>
|
182
|
+
)
|
183
|
+
```
|
184
|
+
|
185
|
+
### With External Anchor
|
186
|
+
|
187
|
+
To create an anchor outside of the menu, you need to switch to controlled mode for the menu and pass it as `anchorRef` to `ActionMenu`:
|
188
|
+
|
189
|
+
```javascript live noinline
|
190
|
+
// import {ActionMenu, ActionList} from '@primer/components/drafts'
|
191
|
+
const {ActionMenu, ActionList} = drafts // ignore docs silliness; import like that ↑
|
192
|
+
|
193
|
+
const Example = () => {
|
194
|
+
const [open, setOpen] = React.useState(false)
|
195
|
+
const anchorRef = React.createRef()
|
196
|
+
|
197
|
+
return (
|
198
|
+
<>
|
199
|
+
<Button ref={anchorRef} onClick={() => setOpen(!open)}>
|
200
|
+
{open ? 'Close Menu' : 'Open Menu'}
|
201
|
+
</Button>
|
202
|
+
|
203
|
+
<ActionMenu open={open} onOpenChange={setOpen} anchorRef={anchorRef}>
|
204
|
+
<ActionList>
|
205
|
+
<ActionList.Item>Copy link</ActionList.Item>
|
206
|
+
<ActionList.Item>Quote reply</ActionList.Item>
|
207
|
+
<ActionList.Item>Edit comment</ActionList.Item>
|
208
|
+
<ActionList.Divider />
|
209
|
+
<ActionList.Item variant="danger">Delete file</ActionList.Item>
|
210
|
+
</ActionList>
|
211
|
+
</ActionMenu>
|
212
|
+
</>
|
213
|
+
)
|
214
|
+
}
|
215
|
+
|
216
|
+
render(<Example />)
|
217
|
+
```
|
218
|
+
|
219
|
+
## Props / API reference
|
220
|
+
|
221
|
+
### ActionMenu
|
222
|
+
|
223
|
+
| Name | Type | Default | Description |
|
224
|
+
| :----------- | :-------------------------------------------------- | :-----: | :----------------------------------------------------------------------------------------------------------------------- |
|
225
|
+
| children\* | `React.ReactElement[]` | - | Required. Recommended: `ActionMenu.Button` or `ActionMenu.Anchor` with [`ActionList`](/drafts/ActionList2) |
|
226
|
+
| open | `boolean` | - | Optional. If defined, will control the open/closed state of the overlay. Must be used in conjuction with `onOpenChange`. |
|
227
|
+
| onOpenChange | `(open: boolean) => void` | - | Optional. If defined, will control the open/closed state of the overlay. Must be used in conjuction with `open`. |
|
228
|
+
| anchorRef | `React.RefObject<HTMLElement>` | - | Optional. Useful for defining an external anchor |
|
229
|
+
| overlayProps | [`Partial<OverlayProps>`](/Overlay#component-props) | - | Optional. Props to be spread on the internal [`AnchoredOverlay`](/AnchoredOverlay) component. |
|
230
|
+
|
231
|
+
### ActionMenu.Button
|
232
|
+
|
233
|
+
| Type | Default | Description |
|
234
|
+
| :-------------------------------------- | :-----: | :------------------------------------------------------------------------------------------------------------------- |
|
235
|
+
| [ButtonProps](/Buttons#component-props) | - | Optional. You can pass all of the props that you would pass to a [`Button`](/Buttons) component like `variant`, `sx` |
|
236
|
+
|
237
|
+
### ActionMenu.Anchor
|
238
|
+
|
239
|
+
| Name | Type | Default | Description |
|
240
|
+
| :--------- | :------------------- | :-----: | :-------------------------------- |
|
241
|
+
| children\* | `React.ReactElement` | - | Required. Accepts a single child. |
|
242
|
+
|
243
|
+
## Further reading
|
244
|
+
|
245
|
+
[Interface guidelines: Action List + Menu](https://primer.style/design/components/action-list)
|
246
|
+
|
247
|
+
## Related components
|
248
|
+
|
249
|
+
- [ActionList](/drafts/ActionList2)
|
250
|
+
- [DropdownMenu](/DropdownMenu)
|
251
|
+
- [SelectPanel](/SelectPanel)
|
package/docs/content/status.mdx
CHANGED
@@ -6,7 +6,7 @@ import {PropsList, COMMON, LAYOUT, BORDER, TYPOGRAPHY, FLEX, POSITION, GRID} fro
|
|
6
6
|
|
7
7
|
<Note variant="warning">
|
8
8
|
|
9
|
-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
|
9
|
+
System props are deprecated in all components except [Box](/Box) and [Text](/Text). Please use the [`sx` prop](/overriding-styles) instead.
|
10
10
|
|
11
11
|
</Note>
|
12
12
|
|
@@ -24,7 +24,11 @@ import {
|
|
24
24
|
LawIcon,
|
25
25
|
StarIcon,
|
26
26
|
AlertIcon,
|
27
|
-
ArrowRightIcon
|
27
|
+
ArrowRightIcon,
|
28
|
+
KebabHorizontalIcon,
|
29
|
+
PencilIcon,
|
30
|
+
ArchiveIcon,
|
31
|
+
TrashIcon
|
28
32
|
} from '@primer/octicons-react'
|
29
33
|
import State from '../../../components/State'
|
30
34
|
import {Dialog as Dialog2} from '../../../../src/Dialog/Dialog'
|
@@ -65,6 +69,10 @@ export default {
|
|
65
69
|
StarIcon,
|
66
70
|
AlertIcon,
|
67
71
|
ArrowRightIcon,
|
72
|
+
KebabHorizontalIcon,
|
73
|
+
PencilIcon,
|
74
|
+
ArchiveIcon,
|
75
|
+
TrashIcon,
|
68
76
|
Dialog2,
|
69
77
|
ConfirmationDialog,
|
70
78
|
useConfirm,
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
import React from 'react';
|
2
|
+
import { SxProp } from '../sx';
|
2
3
|
/**
|
3
4
|
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
4
5
|
*/
|
5
|
-
export declare
|
6
|
+
export declare const Divider: React.FC<SxProp>;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.Divider =
|
6
|
+
exports.Divider = void 0;
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
@@ -11,25 +11,30 @@ var _Box = _interopRequireDefault(require("../Box"));
|
|
11
11
|
|
12
12
|
var _constants = require("../constants");
|
13
13
|
|
14
|
+
var _sx = require("../sx");
|
15
|
+
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
17
|
|
16
18
|
/**
|
17
19
|
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
18
20
|
*/
|
19
|
-
|
21
|
+
const Divider = ({
|
22
|
+
sx = {}
|
23
|
+
}) => {
|
20
24
|
return /*#__PURE__*/_react.default.createElement(_Box.default, {
|
21
25
|
as: "li",
|
22
26
|
role: "separator",
|
23
|
-
sx: {
|
27
|
+
sx: (0, _sx.merge)({
|
24
28
|
height: 1,
|
25
29
|
backgroundColor: 'actionListItem.inlineDivider',
|
26
30
|
marginTop: theme => `calc(${(0, _constants.get)('space.2')(theme)} - 1px)`,
|
27
31
|
marginBottom: 2,
|
28
32
|
listStyle: 'none' // hide the ::marker inserted by browser's stylesheet
|
29
33
|
|
30
|
-
},
|
34
|
+
}, sx),
|
31
35
|
"data-component": "ActionList.Divider"
|
32
36
|
});
|
33
|
-
}
|
37
|
+
};
|
34
38
|
|
39
|
+
exports.Divider = Divider;
|
35
40
|
Divider.displayName = "Divider";
|
package/lib/ActionList2/Item.js
CHANGED
@@ -21,6 +21,8 @@ var _createSlots = _interopRequireDefault(require("../utils/create-slots"));
|
|
21
21
|
|
22
22
|
var _List = require("./List");
|
23
23
|
|
24
|
+
var _MenuContext = require("./MenuContext");
|
25
|
+
|
24
26
|
var _Selection = require("./Selection");
|
25
27
|
|
26
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -82,6 +84,7 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
|
|
82
84
|
onSelect,
|
83
85
|
sx: sxProp = {},
|
84
86
|
id,
|
87
|
+
role,
|
85
88
|
_PrivateItemWrapper,
|
86
89
|
...props
|
87
90
|
}, forwardedRef) => {
|
@@ -90,6 +93,11 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
|
|
90
93
|
showDividers
|
91
94
|
} = _react.default.useContext(_List.ListContext);
|
92
95
|
|
96
|
+
const {
|
97
|
+
itemRole,
|
98
|
+
afterSelect
|
99
|
+
} = _react.default.useContext(_MenuContext.MenuContext);
|
100
|
+
|
93
101
|
const {
|
94
102
|
theme
|
95
103
|
} = (0, _ThemeProvider.useTheme)();
|
@@ -165,17 +173,24 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
|
|
165
173
|
const clickHandler = _react.default.useCallback(event => {
|
166
174
|
if (typeof onSelect !== 'function') return;
|
167
175
|
if (disabled) return;
|
168
|
-
|
169
|
-
|
176
|
+
|
177
|
+
if (!event.defaultPrevented) {
|
178
|
+
onSelect(event); // if this Item is inside a Menu, close the Menu
|
179
|
+
|
180
|
+
if (typeof afterSelect === 'function') afterSelect();
|
181
|
+
}
|
182
|
+
}, [onSelect, disabled, afterSelect]);
|
170
183
|
|
171
184
|
const keyPressHandler = _react.default.useCallback(event => {
|
172
185
|
if (typeof onSelect !== 'function') return;
|
173
186
|
if (disabled) return;
|
174
187
|
|
175
188
|
if (!event.defaultPrevented && [' ', 'Enter'].includes(event.key)) {
|
176
|
-
onSelect(event);
|
189
|
+
onSelect(event); // if this Item is inside a Menu, close the Menu
|
190
|
+
|
191
|
+
if (typeof afterSelect === 'function') afterSelect();
|
177
192
|
}
|
178
|
-
}, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
|
193
|
+
}, [onSelect, disabled, afterSelect]); // use props.id if provided, otherwise generate one.
|
179
194
|
|
180
195
|
|
181
196
|
const labelId = (0, _ssr.useSSRSafeId)(id);
|
@@ -198,7 +213,8 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
|
|
198
213
|
"aria-disabled": disabled ? true : undefined,
|
199
214
|
tabIndex: disabled || _PrivateItemWrapper ? undefined : 0,
|
200
215
|
"aria-labelledby": `${labelId} ${slots.InlineDescription ? inlineDescriptionId : ''}`,
|
201
|
-
"aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined
|
216
|
+
"aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined,
|
217
|
+
role: role || itemRole
|
202
218
|
}, props), /*#__PURE__*/_react.default.createElement(ItemWrapper, null, /*#__PURE__*/_react.default.createElement(_Selection.Selection, {
|
203
219
|
selected: selected
|
204
220
|
}), slots.LeadingVisual, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
package/lib/ActionList2/List.js
CHANGED
@@ -11,6 +11,8 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
11
|
|
12
12
|
var _sx = _interopRequireWildcard(require("../sx"));
|
13
13
|
|
14
|
+
var _MenuContext = require("./MenuContext");
|
15
|
+
|
14
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
15
17
|
|
16
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -32,6 +34,7 @@ const List = /*#__PURE__*/_react.default.forwardRef(({
|
|
32
34
|
variant = 'inset',
|
33
35
|
selectionVariant,
|
34
36
|
showDividers = false,
|
37
|
+
role,
|
35
38
|
sx: sxProp = {},
|
36
39
|
...props
|
37
40
|
}, forwardedRef) => {
|
@@ -41,8 +44,15 @@ const List = /*#__PURE__*/_react.default.forwardRef(({
|
|
41
44
|
// reset ul styles
|
42
45
|
paddingY: variant === 'inset' ? 2 : 0
|
43
46
|
};
|
47
|
+
/** if list is inside a Menu, it will get a role from the Menu */
|
48
|
+
|
49
|
+
const {
|
50
|
+
listRole
|
51
|
+
} = _react.default.useContext(_MenuContext.MenuContext);
|
52
|
+
|
44
53
|
return /*#__PURE__*/_react.default.createElement(ListBox, _extends({
|
45
|
-
sx: (0, _sx.merge)(styles, sxProp)
|
54
|
+
sx: (0, _sx.merge)(styles, sxProp),
|
55
|
+
role: role || listRole
|
46
56
|
}, props, {
|
47
57
|
ref: forwardedRef
|
48
58
|
}), /*#__PURE__*/_react.default.createElement(ListContext.Provider, {
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/** This context can be used by components that compose ActionList inside a Menu */
|
2
|
+
import React from 'react';
|
3
|
+
declare type ContextProps = {
|
4
|
+
parent?: string;
|
5
|
+
listRole?: string;
|
6
|
+
itemRole?: string;
|
7
|
+
afterSelect?: () => void;
|
8
|
+
};
|
9
|
+
export declare const MenuContext: React.Context<ContextProps>;
|
10
|
+
export {};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.MenuContext = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
/** This context can be used by components that compose ActionList inside a Menu */
|
13
|
+
const MenuContext = /*#__PURE__*/_react.default.createContext({});
|
14
|
+
|
15
|
+
exports.MenuContext = MenuContext;
|