@primer/components 32.1.1-rc.b4502a34 → 33.0.0-rc.956a1af6
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/.devcontainer/devcontainer.json +1 -1
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/.github/workflows/release_canary.yml +1 -1
- package/.github/workflows/release_candidate.yml +1 -1
- package/.github/workflows/statuses.yml +32 -0
- package/.gitignore +1 -0
- package/.nvmrc +1 -1
- package/CHANGELOG.md +17 -1
- package/contributor-docs/CONTRIBUTING.md +14 -58
- package/dist/browser.esm.js +2 -2213
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +2 -2213
- 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/docs/src/component-checklist.js +10 -2
- package/lib/ActionList/Header.js +1 -1
- package/lib/ActionList/Item.js +10 -10
- package/lib/ActionList/List.js +1 -1
- package/lib/ActionList2/Divider.d.ts +3 -2
- package/lib/ActionList2/Divider.js +10 -5
- package/lib/ActionList2/Item.js +22 -6
- package/lib/ActionList2/List.js +12 -2
- 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 +313 -0
- package/lib/ActionMenu2.js +91 -0
- package/lib/Autocomplete/Autocomplete.d.ts +2 -1
- package/lib/Autocomplete/AutocompleteInput.d.ts +2 -1
- package/lib/Avatar.d.ts +1 -2
- package/lib/Avatar.js +1 -1
- package/lib/BaseStyles.js +2 -20
- package/lib/BorderBox.js +1 -1
- package/lib/Box.js +1 -1
- package/lib/BranchName.d.ts +1 -2
- package/lib/BranchName.js +1 -1
- package/lib/Breadcrumbs.js +3 -3
- package/lib/Button/Button.d.ts +2 -2
- package/lib/Button/Button.js +1 -1
- package/lib/Button/ButtonClose.d.ts +2 -2
- package/lib/Button/ButtonDanger.d.ts +2 -2
- package/lib/Button/ButtonGroup.js +1 -1
- package/lib/Button/ButtonInvisible.d.ts +2 -2
- package/lib/Button/ButtonOutline.d.ts +2 -2
- package/lib/Button/ButtonPrimary.d.ts +2 -2
- package/lib/Checkbox.js +1 -1
- package/lib/CircleOcticon.d.ts +35 -35
- package/lib/Details.d.ts +1 -2
- package/lib/Details.js +2 -4
- package/lib/Dialog.d.ts +37 -37
- package/lib/Dropdown.d.ts +8 -72
- package/lib/DropdownMenu/DropdownButton.d.ts +6 -3
- package/lib/FilterList.d.ts +1 -1
- package/lib/FilteredActionList/FilteredActionList.js +1 -1
- package/lib/Flex.js +1 -1
- package/lib/Heading.d.ts +1 -2
- package/lib/Heading.js +1 -6
- package/lib/LabelGroup.js +1 -1
- package/lib/Overlay.js +1 -1
- package/lib/Pagination/Pagination.js +2 -2
- package/lib/Position.d.ts +4 -4
- package/lib/Position.js +1 -1
- package/lib/ProgressBar.d.ts +16 -11
- package/lib/ProgressBar.js +6 -10
- package/lib/SelectMenu/SelectMenu.d.ts +11 -10
- package/lib/SelectMenu/SelectMenu.js +1 -1
- package/lib/SelectMenu/SelectMenuFilter.js +1 -1
- package/lib/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuItem.js +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuTab.js +1 -1
- package/lib/SelectMenu/SelectMenuTabPanel.js +1 -1
- package/lib/SelectMenu/SelectMenuTabs.js +1 -1
- package/lib/Spinner.d.ts +1 -2
- package/lib/Spinner.js +1 -3
- package/lib/StateLabel.js +1 -1
- package/lib/StyledOcticon.js +1 -1
- package/lib/SubNav.js +3 -3
- package/lib/TextInputWithTokens.d.ts +2 -1
- package/lib/Timeline.js +4 -4
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/AvatarToken.js +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/Token/TokenBase.js +1 -1
- package/lib/Tooltip.js +1 -1
- package/lib/UnderlineNav.js +2 -2
- 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/ActionList.stories.js +3 -3
- package/lib/stories/ActionList2.stories.js +1 -1
- package/lib/stories/ActionMenu2.stories.js +433 -0
- package/lib/stories/Checkbox.stories.js +2 -2
- package/lib/stories/ThemeProvider.stories.js +1 -5
- package/lib/stories/useFocusTrap.stories.js +1 -11
- package/lib/stories/useFocusZone.stories.js +2 -6
- package/lib-esm/ActionList/Header.js +1 -1
- package/lib-esm/ActionList/Item.js +10 -10
- package/lib-esm/ActionList/List.js +1 -1
- package/lib-esm/ActionList2/Divider.d.ts +3 -2
- package/lib-esm/ActionList2/Divider.js +8 -5
- package/lib-esm/ActionList2/Item.js +20 -6
- package/lib-esm/ActionList2/List.js +10 -2
- 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 +313 -0
- package/lib-esm/ActionMenu2.js +67 -0
- package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -1
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -1
- package/lib-esm/Avatar.d.ts +1 -2
- package/lib-esm/Avatar.js +2 -2
- package/lib-esm/BaseStyles.js +2 -20
- package/lib-esm/BorderBox.js +1 -1
- package/lib-esm/Box.js +1 -1
- package/lib-esm/BranchName.d.ts +1 -2
- package/lib-esm/BranchName.js +2 -2
- package/lib-esm/Breadcrumbs.js +3 -3
- package/lib-esm/Button/Button.d.ts +2 -2
- package/lib-esm/Button/Button.js +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +2 -2
- package/lib-esm/Button/ButtonDanger.d.ts +2 -2
- package/lib-esm/Button/ButtonGroup.js +1 -1
- package/lib-esm/Button/ButtonInvisible.d.ts +2 -2
- package/lib-esm/Button/ButtonOutline.d.ts +2 -2
- package/lib-esm/Button/ButtonPrimary.d.ts +2 -2
- package/lib-esm/Checkbox.js +1 -1
- package/lib-esm/CircleOcticon.d.ts +35 -35
- package/lib-esm/Details.d.ts +1 -2
- package/lib-esm/Details.js +2 -3
- package/lib-esm/Dialog.d.ts +37 -37
- package/lib-esm/Dropdown.d.ts +8 -72
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +6 -3
- package/lib-esm/FilterList.d.ts +1 -1
- package/lib-esm/FilteredActionList/FilteredActionList.js +1 -1
- package/lib-esm/Flex.js +1 -1
- package/lib-esm/Heading.d.ts +1 -2
- package/lib-esm/Heading.js +2 -6
- package/lib-esm/LabelGroup.js +1 -1
- package/lib-esm/Overlay.js +1 -1
- package/lib-esm/Pagination/Pagination.js +2 -2
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/Position.js +1 -1
- package/lib-esm/ProgressBar.d.ts +16 -11
- package/lib-esm/ProgressBar.js +7 -11
- package/lib-esm/SelectMenu/SelectMenu.d.ts +11 -10
- package/lib-esm/SelectMenu/SelectMenu.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuFilter.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuItem.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuTabPanel.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuTabs.js +1 -1
- package/lib-esm/Spinner.d.ts +1 -2
- package/lib-esm/Spinner.js +1 -2
- package/lib-esm/StateLabel.js +1 -1
- package/lib-esm/StyledOcticon.js +1 -1
- package/lib-esm/SubNav.js +3 -3
- package/lib-esm/TextInputWithTokens.d.ts +2 -1
- package/lib-esm/Timeline.js +4 -4
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/AvatarToken.js +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/Token/TokenBase.js +1 -1
- package/lib-esm/Tooltip.js +1 -1
- package/lib-esm/UnderlineNav.js +2 -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/ActionList.stories.js +3 -3
- package/lib-esm/stories/ActionList2.stories.js +1 -1
- package/lib-esm/stories/ActionMenu2.stories.js +376 -0
- package/lib-esm/stories/Checkbox.stories.js +2 -2
- package/lib-esm/stories/ThemeProvider.stories.js +1 -5
- package/lib-esm/stories/useFocusTrap.stories.js +1 -11
- package/lib-esm/stories/useFocusZone.stories.js +2 -6
- package/package-lock.json +1366 -3544
- package/package.json +14 -8
- package/script/component-status-project/build.ts +100 -0
- package/script/component-status-project/deploy.rb +142 -0
- 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
- package/tsconfig.build.json +1 -1
- package/tsconfig.json +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,
|
@@ -9,7 +9,9 @@ export function ComponentChecklist({items}) {
|
|
9
9
|
<>
|
10
10
|
<H3>Alpha</H3>
|
11
11
|
<Checklist aria-describedby="alpha">
|
12
|
-
<Checklist.Item checked={items.propsDocumented}>
|
12
|
+
<Checklist.Item checked={items.propsDocumented}>
|
13
|
+
Component props are documented on <Link href="https://primer.style/react/">primer.style/react</Link>.
|
14
|
+
</Checklist.Item>
|
13
15
|
<Checklist.Item checked={items.noUnnecessaryDeps}>
|
14
16
|
Component does not have any unnecessary third-party dependencies.
|
15
17
|
</Checklist.Item>
|
@@ -22,7 +24,13 @@ export function ComponentChecklist({items}) {
|
|
22
24
|
<H3>Beta</H3>
|
23
25
|
<Checklist aria-describedby="beta">
|
24
26
|
<Checklist.Item checked={items.usedInProduction}>Component is used in a production application.</Checklist.Item>
|
25
|
-
<Checklist.Item checked={items.usageExamplesDocumented}>
|
27
|
+
<Checklist.Item checked={items.usageExamplesDocumented}>
|
28
|
+
Common usage examples are documented on <Link href="https://primer.style/react/">primer.style/react</Link>.
|
29
|
+
</Checklist.Item>
|
30
|
+
<Checklist.Item checked={items.hasStorybookStories}>
|
31
|
+
Common usage examples are documented in <Link href="https://primer.style/react/storybook">storybook</Link>{' '}
|
32
|
+
stories.
|
33
|
+
</Checklist.Item>
|
26
34
|
<Checklist.Item checked={items.designReviewed}>
|
27
35
|
Component has been reviewed by a systems designer and any resulting issues have been addressed.
|
28
36
|
</Checklist.Item>
|
package/lib/ActionList/Header.js
CHANGED
@@ -24,7 +24,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
24
24
|
|
25
25
|
const StyledHeader = _styledComponents.default.div.withConfig({
|
26
26
|
displayName: "Header__StyledHeader",
|
27
|
-
componentId: "qmofje-0"
|
27
|
+
componentId: "sc-qmofje-0"
|
28
28
|
})(["{}padding:6px ", ";font-size:", ";font-weight:", ";color:", ";", " ", ""], (0, _constants.get)('space.3'), (0, _constants.get)('fontSizes.0'), (0, _constants.get)('fontWeights.bold'), (0, _constants.get)('colors.fg.muted'), ({
|
29
29
|
variant
|
30
30
|
}) => variant === 'filled' && (0, _styledComponents.css)(["background:", ";margin:", " 0;border-top:1px solid ", ";border-bottom:1px solid ", ";&:first-child{margin-top:0;}"], (0, _constants.get)('colors.canvas.subtle'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.neutral.muted'), (0, _constants.get)('colors.neutral.muted')), _sx.default);
|
package/lib/ActionList/Item.js
CHANGED
@@ -71,17 +71,17 @@ const getItemVariant = (variant = 'default', disabled) => {
|
|
71
71
|
|
72
72
|
const DividedContent = _styledComponents.default.div.withConfig({
|
73
73
|
displayName: "Item__DividedContent",
|
74
|
-
componentId: "jqpvy8-0"
|
74
|
+
componentId: "sc-jqpvy8-0"
|
75
75
|
})(["display:flex;min-width:0;position:relative;flex-grow:1;"]);
|
76
76
|
|
77
77
|
const MainContent = _styledComponents.default.div.withConfig({
|
78
78
|
displayName: "Item__MainContent",
|
79
|
-
componentId: "jqpvy8-1"
|
79
|
+
componentId: "sc-jqpvy8-1"
|
80
80
|
})(["align-items:baseline;display:flex;min-width:0;flex-direction:var(--main-content-flex-direction);flex-grow:1;"]);
|
81
81
|
|
82
82
|
const StyledItem = _styledComponents.default.div.withConfig({
|
83
83
|
displayName: "Item__StyledItem",
|
84
|
-
componentId: "jqpvy8-2"
|
84
|
+
componentId: "sc-jqpvy8-2"
|
85
85
|
})(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear;text-decoration:none;@media (hover:hover) and (pointer:fine){:hover{background:var( --item-hover-bg-override,", " );color:", ";cursor:", ";}}:not(:first-of-type):not(", " + &):not(", " + &){margin-top:", ";", "::before{content:' ';display:block;position:absolute;width:100%;top:-7px;border:0 solid ", ";border-top-width:", ";}}&:hover ", "::before,:hover + * ", "::before{border-color:var(--item-hover-divider-border-color-override,transparent) !important;}&:focus ", "::before,:focus + * ", "::before,&[", "] ", "::before,[", "] + & ", "::before{border-color:transparent !important;}&[", "='", "']{background:", ";}&[", "='", "']{background:", ";}&:focus{background:", ";outline:none;}&:active{background:", ";}", ""], (0, _constants.get)('space.2'), (0, _constants.get)('radii.2'), ({
|
86
86
|
variant,
|
87
87
|
item
|
@@ -114,30 +114,30 @@ const StyledItem = _styledComponents.default.div.withConfig({
|
|
114
114
|
|
115
115
|
const TextContainer = _styledComponents.default.span.withConfig({
|
116
116
|
displayName: "Item__TextContainer",
|
117
|
-
componentId: "jqpvy8-3"
|
117
|
+
componentId: "sc-jqpvy8-3"
|
118
118
|
})([""]);
|
119
119
|
|
120
120
|
exports.TextContainer = TextContainer;
|
121
121
|
|
122
122
|
const BaseVisualContainer = _styledComponents.default.div.withConfig({
|
123
123
|
displayName: "Item__BaseVisualContainer",
|
124
|
-
componentId: "jqpvy8-4"
|
124
|
+
componentId: "sc-jqpvy8-4"
|
125
125
|
})(["height:20px;width:", ";margin-right:", ";display:flex;justify-content:center;align-items:center;flex-shrink:0;"], (0, _constants.get)('space.3'), (0, _constants.get)('space.2'));
|
126
126
|
|
127
127
|
const ColoredVisualContainer = (0, _styledComponents.default)(BaseVisualContainer).withConfig({
|
128
128
|
displayName: "Item__ColoredVisualContainer",
|
129
|
-
componentId: "jqpvy8-5"
|
129
|
+
componentId: "sc-jqpvy8-5"
|
130
130
|
})(["svg{fill:", ";font-size:", ";}"], ({
|
131
131
|
variant,
|
132
132
|
disabled
|
133
133
|
}) => getItemVariant(variant, disabled).iconColor, (0, _constants.get)('fontSizes.0'));
|
134
134
|
const LeadingVisualContainer = (0, _styledComponents.default)(ColoredVisualContainer).withConfig({
|
135
135
|
displayName: "Item__LeadingVisualContainer",
|
136
|
-
componentId: "jqpvy8-6"
|
136
|
+
componentId: "sc-jqpvy8-6"
|
137
137
|
})(["display:flex;flex-direction:column;justify-content:center;"]);
|
138
138
|
const TrailingContent = (0, _styledComponents.default)(ColoredVisualContainer).withConfig({
|
139
139
|
displayName: "Item__TrailingContent",
|
140
|
-
componentId: "jqpvy8-7"
|
140
|
+
componentId: "sc-jqpvy8-7"
|
141
141
|
})(["color:", "};margin-left:", ";margin-right:0;width:auto;div:nth-child(2){margin-left:", ";}"], ({
|
142
142
|
variant,
|
143
143
|
disabled
|
@@ -145,12 +145,12 @@ const TrailingContent = (0, _styledComponents.default)(ColoredVisualContainer).w
|
|
145
145
|
|
146
146
|
const DescriptionContainer = _styledComponents.default.span.withConfig({
|
147
147
|
displayName: "Item__DescriptionContainer",
|
148
|
-
componentId: "jqpvy8-8"
|
148
|
+
componentId: "sc-jqpvy8-8"
|
149
149
|
})(["color:", ";font-size:", ";line-height:16px;margin-left:var(--description-container-margin-left);min-width:0;flex-grow:1;flex-basis:var(--description-container-flex-basis);"], (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('fontSizes.0'));
|
150
150
|
|
151
151
|
const MultiSelectIcon = _styledComponents.default.svg.withConfig({
|
152
152
|
displayName: "Item__MultiSelectIcon",
|
153
|
-
componentId: "jqpvy8-9"
|
153
|
+
componentId: "sc-jqpvy8-9"
|
154
154
|
})(["rect{fill:", ";stroke:", ";shape-rendering:auto;}path{fill:", ";boxshadow:", ";opacity:", ";}"], ({
|
155
155
|
selected
|
156
156
|
}) => selected ? (0, _constants.get)('colors.accent.fg') : (0, _constants.get)('colors.canvas.default'), ({
|
package/lib/ActionList/List.js
CHANGED
@@ -37,7 +37,7 @@ function isGroupedListProps(props) {
|
|
37
37
|
|
38
38
|
const StyledList = _styledComponents.default.div.withConfig({
|
39
39
|
displayName: "List__StyledList",
|
40
|
-
componentId: "yr2k7d-0"
|
40
|
+
componentId: "sc-yr2k7d-0"
|
41
41
|
})(["font-size:", ";line-height:20px;&[", "],&:focus-within{--item-hover-bg-override:none;--item-hover-divider-border-color-override:", ";}"], (0, _constants.get)('fontSizes.1'), _focusZone.hasActiveDescendantAttribute, (0, _constants.get)('colors.border.muted'));
|
42
42
|
/**
|
43
43
|
* Returns `sx` prop values for `List` children matching the given `List` style variation.
|
@@ -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";
|