@primer/components 31.2.0-rc.5ccefd7d → 31.2.0-rc.5e503f97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/.github/workflows/release.yml +1 -0
  2. package/.github/workflows/release_canary.yml +1 -0
  3. package/CHANGELOG.md +14 -0
  4. package/dist/browser.esm.js +626 -624
  5. package/dist/browser.esm.js.map +1 -1
  6. package/dist/browser.umd.js +196 -194
  7. package/dist/browser.umd.js.map +1 -1
  8. package/docs/content/ActionList2.mdx +360 -0
  9. package/docs/content/StateLabel.md +5 -4
  10. package/docs/content/getting-started.md +1 -1
  11. package/docs/src/@primer/gatsby-theme-doctocat/components/hero.js +1 -3
  12. package/docs/src/@primer/gatsby-theme-doctocat/components/live-preview-wrapper.js +1 -1
  13. package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +17 -0
  14. package/lib/ActionList2/Description.d.ts +12 -0
  15. package/lib/ActionList2/Description.js +53 -0
  16. package/lib/ActionList2/Divider.d.ts +5 -0
  17. package/lib/ActionList2/Divider.js +35 -0
  18. package/lib/ActionList2/Group.d.ts +11 -0
  19. package/lib/ActionList2/Group.js +57 -0
  20. package/lib/ActionList2/Header.d.ts +26 -0
  21. package/lib/ActionList2/Header.js +55 -0
  22. package/lib/ActionList2/Item.d.ts +63 -0
  23. package/lib/ActionList2/Item.js +244 -0
  24. package/lib/ActionList2/LinkItem.d.ts +17 -0
  25. package/lib/ActionList2/LinkItem.js +57 -0
  26. package/lib/ActionList2/List.d.ts +26 -0
  27. package/lib/ActionList2/List.js +59 -0
  28. package/lib/ActionList2/Selection.d.ts +5 -0
  29. package/lib/ActionList2/Selection.js +70 -0
  30. package/lib/ActionList2/Visuals.d.ts +9 -0
  31. package/lib/ActionList2/Visuals.js +90 -0
  32. package/lib/ActionList2/index.d.ts +36 -0
  33. package/lib/ActionList2/index.js +47 -0
  34. package/lib/Autocomplete/Autocomplete.d.ts +28 -28
  35. package/lib/Autocomplete/AutocompleteInput.d.ts +28 -28
  36. package/lib/Button/Button.d.ts +25 -25
  37. package/lib/Button/ButtonClose.d.ts +45 -45
  38. package/lib/Button/ButtonDanger.d.ts +25 -25
  39. package/lib/Button/ButtonInvisible.d.ts +25 -25
  40. package/lib/Button/ButtonOutline.d.ts +25 -25
  41. package/lib/Button/ButtonPrimary.d.ts +25 -25
  42. package/lib/CircleOcticon.d.ts +42 -42
  43. package/lib/Dialog.d.ts +45 -45
  44. package/lib/Dropdown.d.ts +176 -176
  45. package/lib/DropdownMenu/DropdownButton.d.ts +46 -46
  46. package/lib/FilterList.d.ts +42 -42
  47. package/lib/Overlay.js +3 -1
  48. package/lib/Portal/Portal.js +3 -2
  49. package/lib/Position.d.ts +4 -4
  50. package/lib/SelectMenu/SelectMenu.d.ts +246 -246
  51. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  52. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  53. package/lib/StateLabel.d.ts +1 -1
  54. package/lib/StateLabel.js +6 -1
  55. package/lib/TextInputWithTokens.d.ts +28 -28
  56. package/lib/Timeline.d.ts +43 -43
  57. package/lib/Token/AvatarToken.d.ts +1 -1
  58. package/lib/Token/IssueLabelToken.d.ts +1 -1
  59. package/lib/Token/Token.d.ts +1 -1
  60. package/lib/_TextInputWrapper.js +2 -2
  61. package/lib/__tests__/ActionList2.test.d.ts +1 -0
  62. package/lib/__tests__/ActionList2.test.js +53 -0
  63. package/lib/__tests__/AnchoredOverlay.test.js +4 -2
  64. package/lib/__tests__/TextInputWithTokens.test.js +1 -10
  65. package/lib/__tests__/utils/createSlots.test.d.ts +1 -0
  66. package/lib/__tests__/utils/createSlots.test.js +75 -0
  67. package/lib/drafts.d.ts +7 -0
  68. package/lib/drafts.js +18 -0
  69. package/lib/hooks/useAnchoredPosition.js +3 -2
  70. package/lib/hooks/useCombinedRefs.d.ts +2 -2
  71. package/lib/hooks/useCombinedRefs.js +4 -6
  72. package/lib/hooks/useResizeObserver.js +2 -2
  73. package/lib/stories/ActionList2.stories.js +907 -0
  74. package/lib/stories/TextInput.stories.js +144 -0
  75. package/lib/stories/Token.stories.js +19 -2
  76. package/lib/sx.d.ts +2 -0
  77. package/lib/sx.js +8 -0
  78. package/lib/theme-preval.js +81 -2
  79. package/lib/utils/create-slots.d.ts +17 -0
  80. package/lib/utils/create-slots.js +105 -0
  81. package/lib/utils/testing.d.ts +14 -1
  82. package/lib/utils/use-force-update.d.ts +1 -0
  83. package/lib/utils/use-force-update.js +19 -0
  84. package/lib/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  85. package/lib/utils/useIsomorphicLayoutEffect.js +12 -0
  86. package/lib-esm/ActionList2/Description.d.ts +12 -0
  87. package/lib-esm/ActionList2/Description.js +37 -0
  88. package/lib-esm/ActionList2/Divider.d.ts +5 -0
  89. package/lib-esm/ActionList2/Divider.js +23 -0
  90. package/lib-esm/ActionList2/Group.d.ts +11 -0
  91. package/lib-esm/ActionList2/Group.js +40 -0
  92. package/lib-esm/ActionList2/Header.d.ts +26 -0
  93. package/lib-esm/ActionList2/Header.js +44 -0
  94. package/lib-esm/ActionList2/Item.d.ts +63 -0
  95. package/lib-esm/ActionList2/Item.js +210 -0
  96. package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
  97. package/lib-esm/ActionList2/LinkItem.js +43 -0
  98. package/lib-esm/ActionList2/List.d.ts +26 -0
  99. package/lib-esm/ActionList2/List.js +37 -0
  100. package/lib-esm/ActionList2/Selection.d.ts +5 -0
  101. package/lib-esm/ActionList2/Selection.js +52 -0
  102. package/lib-esm/ActionList2/Visuals.d.ts +9 -0
  103. package/lib-esm/ActionList2/Visuals.js +68 -0
  104. package/lib-esm/ActionList2/index.d.ts +36 -0
  105. package/lib-esm/ActionList2/index.js +33 -0
  106. package/lib-esm/Autocomplete/Autocomplete.d.ts +28 -28
  107. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +28 -28
  108. package/lib-esm/Button/Button.d.ts +25 -25
  109. package/lib-esm/Button/ButtonClose.d.ts +45 -45
  110. package/lib-esm/Button/ButtonDanger.d.ts +25 -25
  111. package/lib-esm/Button/ButtonInvisible.d.ts +25 -25
  112. package/lib-esm/Button/ButtonOutline.d.ts +25 -25
  113. package/lib-esm/Button/ButtonPrimary.d.ts +25 -25
  114. package/lib-esm/CircleOcticon.d.ts +42 -42
  115. package/lib-esm/Dialog.d.ts +45 -45
  116. package/lib-esm/Dropdown.d.ts +176 -176
  117. package/lib-esm/DropdownMenu/DropdownButton.d.ts +46 -46
  118. package/lib-esm/FilterList.d.ts +42 -42
  119. package/lib-esm/Overlay.js +2 -1
  120. package/lib-esm/Portal/Portal.js +2 -1
  121. package/lib-esm/Position.d.ts +4 -4
  122. package/lib-esm/SelectMenu/SelectMenu.d.ts +246 -246
  123. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  124. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  125. package/lib-esm/StateLabel.d.ts +1 -1
  126. package/lib-esm/StateLabel.js +7 -2
  127. package/lib-esm/TextInputWithTokens.d.ts +28 -28
  128. package/lib-esm/Timeline.d.ts +43 -43
  129. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  130. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  131. package/lib-esm/Token/Token.d.ts +1 -1
  132. package/lib-esm/_TextInputWrapper.js +2 -2
  133. package/lib-esm/__tests__/ActionList2.test.d.ts +1 -0
  134. package/lib-esm/__tests__/ActionList2.test.js +41 -0
  135. package/lib-esm/__tests__/AnchoredOverlay.test.js +4 -2
  136. package/lib-esm/__tests__/TextInputWithTokens.test.js +1 -10
  137. package/lib-esm/__tests__/utils/createSlots.test.d.ts +1 -0
  138. package/lib-esm/__tests__/utils/createSlots.test.js +67 -0
  139. package/lib-esm/drafts.d.ts +7 -0
  140. package/lib-esm/drafts.js +8 -0
  141. package/lib-esm/hooks/useAnchoredPosition.js +2 -1
  142. package/lib-esm/hooks/useCombinedRefs.d.ts +2 -2
  143. package/lib-esm/hooks/useCombinedRefs.js +3 -2
  144. package/lib-esm/hooks/useResizeObserver.js +2 -2
  145. package/lib-esm/stories/ActionList2.stories.js +796 -0
  146. package/lib-esm/stories/TextInput.stories.js +117 -0
  147. package/lib-esm/stories/Token.stories.js +14 -1
  148. package/lib-esm/sx.d.ts +2 -0
  149. package/lib-esm/sx.js +3 -1
  150. package/lib-esm/theme-preval.js +81 -2
  151. package/lib-esm/utils/create-slots.d.ts +17 -0
  152. package/lib-esm/utils/create-slots.js +84 -0
  153. package/lib-esm/utils/testing.d.ts +14 -1
  154. package/lib-esm/utils/use-force-update.d.ts +1 -0
  155. package/lib-esm/utils/use-force-update.js +6 -0
  156. package/lib-esm/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  157. package/lib-esm/utils/useIsomorphicLayoutEffect.js +3 -0
  158. package/migrating.md +1 -1
  159. package/package-lock.json +153 -14
  160. package/package.json +6 -4
  161. package/script/build +2 -0
  162. package/src/ActionList2/Description.tsx +49 -0
  163. package/src/ActionList2/Divider.tsx +24 -0
  164. package/src/ActionList2/Group.tsx +34 -0
  165. package/src/ActionList2/Header.tsx +58 -0
  166. package/src/ActionList2/Item.tsx +245 -0
  167. package/src/ActionList2/LinkItem.tsx +49 -0
  168. package/src/ActionList2/List.tsx +55 -0
  169. package/src/ActionList2/Selection.tsx +40 -0
  170. package/src/ActionList2/Visuals.tsx +76 -0
  171. package/src/ActionList2/index.ts +39 -0
  172. package/src/Overlay.tsx +2 -1
  173. package/src/Portal/Portal.tsx +2 -1
  174. package/src/StateLabel.tsx +14 -2
  175. package/src/_TextInputWrapper.tsx +7 -0
  176. package/src/__tests__/ActionList2.test.tsx +47 -0
  177. package/src/__tests__/AnchoredOverlay.test.tsx +2 -2
  178. package/src/__tests__/TextInputWithTokens.test.tsx +0 -10
  179. package/src/__tests__/__snapshots__/ActionList2.test.tsx.snap +14 -0
  180. package/src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap +35 -135
  181. package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +1 -0
  182. package/src/__tests__/__snapshots__/CircleBadge.test.tsx.snap +1 -0
  183. package/src/__tests__/__snapshots__/CircleOcticon.test.tsx.snap +1 -0
  184. package/src/__tests__/__snapshots__/Dialog.test.tsx.snap +1 -0
  185. package/src/__tests__/__snapshots__/DropdownMenu.test.tsx.snap +1 -0
  186. package/src/__tests__/__snapshots__/SelectMenu.test.tsx.snap +4 -0
  187. package/src/__tests__/__snapshots__/SelectPanel.test.tsx.snap +1 -0
  188. package/src/__tests__/__snapshots__/StateLabel.test.tsx.snap +13 -6
  189. package/src/__tests__/__snapshots__/StyledOcticon.test.tsx.snap +1 -0
  190. package/src/__tests__/__snapshots__/TextInputWithTokens.test.tsx.snap +66 -0
  191. package/src/__tests__/__snapshots__/Token.test.tsx.snap +17 -0
  192. package/src/__tests__/utils/__snapshots__/createSlots.test.tsx.snap +55 -0
  193. package/src/__tests__/utils/createSlots.test.tsx +74 -0
  194. package/src/drafts.ts +9 -0
  195. package/src/hooks/useAnchoredPosition.ts +2 -1
  196. package/src/hooks/useCombinedRefs.ts +3 -3
  197. package/src/hooks/useResizeObserver.ts +2 -2
  198. package/src/stories/ActionList2.stories.tsx +1288 -0
  199. package/src/stories/TextInput.stories.tsx +113 -0
  200. package/src/stories/Token.stories.tsx +12 -1
  201. package/src/sx.ts +3 -0
  202. package/src/theme-preval.js +1 -0
  203. package/src/utils/create-slots.tsx +96 -0
  204. package/src/utils/use-force-update.ts +7 -0
  205. package/src/utils/useIsomorphicLayoutEffect.ts +10 -0
  206. package/stats.html +1 -1
@@ -0,0 +1,360 @@
1
+ ---
2
+ title: ActionList
3
+ status: Alpha
4
+ source: https://github.com/primer/react/tree/main/src/ActionList2
5
+ storybook: '/react/storybook?path=/story/composite-components-actionlist2'
6
+ description: An ActionList is a list of items which can be activated or selected. ActionList is the base component for many of our menu-type components, including DropdownMenu and ActionMenu.
7
+ ---
8
+
9
+ import {BorderBox, Avatar} from '@primer/components'
10
+ import {ActionList} from '@primer/components/drafts'
11
+ import {Props} from '../src/props'
12
+
13
+ import {ImageContainer} from '@primer/gatsby-theme-doctocat'
14
+ import {LinkIcon, AlertIcon, ArrowRightIcon} from '@primer/octicons-react'
15
+
16
+ <br />
17
+
18
+ <BorderBox sx={{padding: 6}}>
19
+ <ActionList sx={{width: 320}}>
20
+ <ActionList.Item>
21
+ <ActionList.LeadingVisual>
22
+ <LinkIcon />
23
+ </ActionList.LeadingVisual>
24
+ github.com/primer
25
+ <ActionList.Description variant="block">
26
+ A React implementation of GitHub's Primer Design System
27
+ </ActionList.Description>
28
+ </ActionList.Item>
29
+ <ActionList.Item>
30
+ <ActionList.LeadingVisual>
31
+ <Avatar src="https://github.com/mona.png" />
32
+ </ActionList.LeadingVisual>
33
+ mona
34
+ <ActionList.Description>Monalisa Octocat</ActionList.Description>
35
+ </ActionList.Item>
36
+ <ActionList.Item variant="danger">
37
+ <ActionList.LeadingVisual>
38
+ <AlertIcon />
39
+ </ActionList.LeadingVisual>
40
+ 4 vulnerabilities
41
+ <ActionList.TrailingVisual>
42
+ <ArrowRightIcon />
43
+ </ActionList.TrailingVisual>
44
+ </ActionList.Item>
45
+ </ActionList>
46
+ </BorderBox>
47
+
48
+ <br />
49
+
50
+ ```js
51
+ import {ActionList} from '@primer/components/drafts'
52
+ ```
53
+
54
+ <br />
55
+
56
+ ## Examples
57
+
58
+ ## Minimal example
59
+
60
+ ```javascript live noinline
61
+ // import {ActionList} from '@primer/components/drafts'
62
+ const {ActionList} = drafts // ignore docs silliness; import like that ↑
63
+
64
+ render(
65
+ <ActionList>
66
+ <ActionList.Item>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
+ )
73
+ ```
74
+
75
+ <br />
76
+
77
+ ## With Leading Visual
78
+
79
+ Leading visuals are optional and appear at the start of an item. They can be octicons, avatars, and other custom visuals that fit a small area.
80
+
81
+ <!-- prettier-ignore -->
82
+ ```javascript live noinline
83
+ // import {ActionList} from '@primer/components/drafts'
84
+ const {ActionList} = drafts // ignore docs silliness; import like that ↑
85
+
86
+ render(
87
+ <ActionList>
88
+ <ActionList.Item>
89
+ <ActionList.LeadingVisual><LinkIcon /></ActionList.LeadingVisual>
90
+ github.com/primer
91
+ </ActionList.Item>
92
+ <ActionList.Item variant="danger">
93
+ <ActionList.LeadingVisual><AlertIcon /></ActionList.LeadingVisual>
94
+ 4 vulnerabilities
95
+ </ActionList.Item>
96
+ <ActionList.Item>
97
+ <ActionList.LeadingVisual><Avatar src="https://github.com/mona.png" /></ActionList.LeadingVisual>
98
+ mona
99
+ </ActionList.Item>
100
+ </ActionList>
101
+ )
102
+ ```
103
+
104
+ <br />
105
+
106
+ ## With Trailing Visual
107
+
108
+ Trailing visual and trailing text can display auxiliary information. They're placed at the right of the item, and can denote status, keyboard shortcuts, or be used to set expectations about what the action does.
109
+
110
+ ```javascript live noinline
111
+ // import {ActionList} from '@primer/components/drafts'
112
+ const {ActionList} = drafts // ignore docs silliness; import like that ↑
113
+
114
+ render(
115
+ <ActionList>
116
+ <ActionList.Item>
117
+ New file
118
+ <ActionList.TrailingVisual>⌘ + N</ActionList.TrailingVisual>
119
+ </ActionList.Item>
120
+ <ActionList.Item>
121
+ Copy link
122
+ <ActionList.TrailingVisual>⌘ + C</ActionList.TrailingVisual>
123
+ </ActionList.Item>
124
+ <ActionList.Item>
125
+ Edit file
126
+ <ActionList.TrailingVisual>⌘ + E</ActionList.TrailingVisual>
127
+ </ActionList.Item>
128
+ <ActionList.Item variant="danger">
129
+ Delete file
130
+ <ActionList.TrailingVisual>⌫</ActionList.TrailingVisual>
131
+ </ActionList.Item>
132
+ </ActionList>
133
+ )
134
+ ```
135
+
136
+ <br />
137
+
138
+ ## With Description and Dividers
139
+
140
+ Item dividers allow users to parse heavier amounts of information. They're placed between items and are useful in complex lists, particularly when descriptions or multi-line text is present.
141
+
142
+ ```javascript live noinline
143
+ // import {ActionList} from '@primer/components/drafts'
144
+ const {ActionList} = drafts // ignore docs silliness; import like that ↑
145
+
146
+ render(
147
+ <ActionList showDividers>
148
+ <ActionList.Item>
149
+ <ActionList.LeadingVisual>
150
+ <Avatar src="https://github.com/mona.png" />
151
+ </ActionList.LeadingVisual>
152
+ mona
153
+ <ActionList.Description>Monalisa Octocat</ActionList.Description>
154
+ </ActionList.Item>
155
+ <ActionList.Item>
156
+ <ActionList.LeadingVisual>
157
+ <Avatar src="https://github.com/hubot.png" />
158
+ </ActionList.LeadingVisual>
159
+ hubot
160
+ <ActionList.Description>Hubot</ActionList.Description>
161
+ </ActionList.Item>
162
+ <ActionList.Item>
163
+ <ActionList.LeadingVisual>
164
+ <Avatar src="https://github.com/primer-css.png" />
165
+ </ActionList.LeadingVisual>
166
+ primer-css
167
+ <ActionList.Description>GitHub Design Systems Bot</ActionList.Description>
168
+ </ActionList.Item>
169
+ </ActionList>
170
+ )
171
+ ```
172
+
173
+ ## With Links
174
+
175
+ When you want to add links to the List instead of actions, use `ActionList.LinkItem`
176
+
177
+ <!-- prettier-ignore -->
178
+ ```javascript live noinline
179
+ // import {ActionList} from '@primer/components/drafts'
180
+ const {ActionList} = drafts // ignore docs silliness; import like that ↑
181
+
182
+ render(
183
+ <ActionList>
184
+ <ActionList.LinkItem href="https://github.com/primer">
185
+ <ActionList.LeadingVisual>
186
+ <LinkIcon />
187
+ </ActionList.LeadingVisual>
188
+ github/primer
189
+ </ActionList.LinkItem>
190
+ <ActionList.LinkItem as={ReactRouterLink} to="/">
191
+ <ActionList.LeadingVisual>
192
+ <LawIcon />
193
+ </ActionList.LeadingVisual>
194
+ MIT License
195
+ </ActionList.LinkItem>
196
+ <ActionList.LinkItem
197
+ href="https://github.com/primer/react/stargazers"
198
+ target="_blank"
199
+ rel="noopener noreferrer"
200
+ >
201
+ <ActionList.LeadingVisual>
202
+ <StarIcon />
203
+ </ActionList.LeadingVisual>
204
+ 1.4k stars
205
+ </ActionList.LinkItem>
206
+ </ActionList>
207
+ )
208
+ ```
209
+
210
+ <br />
211
+
212
+ ## With Groups
213
+
214
+ ```javascript live noinline
215
+ // import {ActionList} from '@primer/components/drafts'
216
+ const {ActionList} = drafts // ignore docs silliness; import like that ↑
217
+
218
+ const SelectFields = () => {
219
+ const [options, setOptions] = React.useState([
220
+ {text: 'Status', selected: true},
221
+ {text: 'Stage', selected: true},
222
+ {text: 'Assignee', selected: true},
223
+ {text: 'Team', selected: true},
224
+ {text: 'Estimate', selected: false},
225
+ {text: 'Due Date', selected: false}
226
+ ])
227
+
228
+ const visibleOptions = options.filter(option => option.selected)
229
+ const hiddenOptions = options.filter(option => !option.selected)
230
+
231
+ const toggle = text => {
232
+ setOptions(
233
+ options.map(option => {
234
+ if (option.text === text) option.selected = !option.selected
235
+ return option
236
+ })
237
+ )
238
+ }
239
+
240
+ return (
241
+ <ActionList selectionVariant="multiple">
242
+ <ActionList.Group title="Visible fields (can be reordered)">
243
+ {visibleOptions.map(option => (
244
+ <ActionList.Item key={option.text} selected={true} onSelect={() => toggle(option.text)}>
245
+ {option.text}
246
+ </ActionList.Item>
247
+ ))}
248
+ </ActionList.Group>
249
+ <ActionList.Group
250
+ title="Hidden fields"
251
+ selectionVariant={
252
+ /** selectionVariant override on Group: disable selection if there are no options */
253
+ hiddenOptions.length ? 'multiple' : false
254
+ }
255
+ >
256
+ {hiddenOptions.map((option, index) => (
257
+ <ActionList.Item key={option.text} selected={false} onSelect={() => toggle(option.text)}>
258
+ {option.text}
259
+ </ActionList.Item>
260
+ ))}
261
+ {hiddenOptions.length === 0 && <ActionList.Item disabled>No hidden fields</ActionList.Item>}
262
+ </ActionList.Group>
263
+ </ActionList>
264
+ )
265
+ }
266
+
267
+ render(<SelectFields />)
268
+ ```
269
+
270
+ <br />
271
+
272
+ ## Props / API reference
273
+
274
+ ## ActionList
275
+
276
+ | Name | Type | Default | Description |
277
+ | :--------------- | :------------------------------------------------------------------------------------------------ | :-----: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
278
+ | children\* | `ActionList.Item[]` or ActionList.LinkItem[] or `ActionList.Group[]` | - | Required. |
279
+ | variant | `'inset'` or `'full'` | 'inset' | Optional. Usage is discretionary, `inset` children are offset (vertically and horizontally) from `List`’s edges, `full` children are flush (vertically and horizontally) with `List` edges |
280
+ | selectionVariant | `'single'` or `'multiple'` | - | Optional. Whether multiple Items or a single Item can be selected. |
281
+ | showDivider | boolean | false | Optional. Display a divider above each `Item` in this `List` when it does not follow a `Header` or `Divider`. |
282
+ | sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
283
+ | role | [AriaRole](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles) | - | Optional. The ARIA role describing the function of `List` component. `listbox` or `menu` are a common values. |
284
+
285
+ <br />
286
+
287
+ ## ActionList.Item
288
+
289
+ | Name | Type | Default | Description |
290
+ | :--------- | :------------------------------------------------------------------------------------------------------------ | :---------: | :----------------------------------------------------------------------------------------------- |
291
+ | children\* | one of [`React.ReactNode`, `ActionList.LeadingVisual`, `ActionList.Description`, `ActionList.TrailingVisual`] | - | Required. |
292
+ | variant | `'default'` or `'danger'` | `'default'` | Optional. variant="danger" creates a destructive action `Item`. |
293
+ | onSelect | Function | - | Optional. Callback that will trigger both on click selection and keyboard selection. |
294
+ | selected | boolean | false | Optional. For `Item`s which can be selected, whether the `Item` is currently selected. |
295
+ | disabled | boolean | false | Optional. Items that are disabled can not be clicked, selected, or navigated through. |
296
+ | role | [AriaRole](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles) | - | Optional. The ARIA role describing the function of `Item` component. `option` is a common value. |
297
+ | sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
298
+
299
+ <br />
300
+
301
+ ## ActionList.LinkItem
302
+
303
+ | Name | Type | Default | Description |
304
+ | :-------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ | :-----: | :------------------------------------------------------------- |
305
+ | children\* | one of [`React.ReactNode`, `ActionList.LeadingVisual`, `ActionList.Description`, `ActionList.TrailingVisual`] | - | Required. |
306
+ | sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
307
+ | + AnchorHTMLAttributes like href, target, rel, etc. | | | |
308
+
309
+ <br />
310
+
311
+ ## ActionList.LeadingVisual
312
+
313
+ | Name | Type | Default | Description |
314
+ | :--------- | :------------------ | :-----: | :------------------------------------------------------------- |
315
+ | children\* | `React.ReactNode` - | - | Required. Icon (or similar) positioned before `Item` text. |
316
+ | sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
317
+
318
+ ## ActionList.TrailingVisual
319
+
320
+ | Name | Type | Default | Description |
321
+ | :--------- | :------------------ | :-----: | :------------------------------------------------------------- |
322
+ | children\* | `React.ReactNode` - | - | Required. Visual positioned after `Item` text. |
323
+ | sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
324
+
325
+ <br />
326
+
327
+ ## ActionList.Description
328
+
329
+ | Name | Type | Default | Description |
330
+ | :--------- | :---------------------- | :--------: | :-------------------------------------------------------------------------------------------------------------------------------- |
331
+ | children\* | `React.ReactNode` - | - | Required. Visual positioned after `Item` text. |
332
+ | variant | `'inline'` or `'block'` | `'inline'` | Optional. `"inline"` secondary text is positioned beside primary text. `"block"` secondary text is positioned below primary text. |
333
+ | sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
334
+
335
+ <br />
336
+
337
+ ## ActionList.Group
338
+
339
+ | Name | Type | Default | Description |
340
+ | :--------------- | :------------------------------------------- | :--------: | :--------------------------------------------------------------------------------------------------------------------------------------- |
341
+ | children\* | `ActionList.Item[] or ActionList.LinkItem[]` | - | Required. |
342
+ | title | string | - | Optional. Primary text which names a `Group` |
343
+ | auxiliaryText | string | - | Optional. Secondary text which provides additional information about a `Group`. |
344
+ | variant | `'filled'` or `'subtle'` | `'subtle'` | Optional. `"filled"` - Superimposed on a background, offset from nearby content, `"subtle"` - Relatively less offset from nearby content |
345
+ | selectionVariant | `'single'` or `'multiple'` or `false` | - | Optional. Set `selectionVariant` at the group level |
346
+
347
+ <br />
348
+
349
+ ## Further reading
350
+
351
+ [Interface guidelines: Action List](https://primer.style/design/components/action-list)
352
+
353
+ <br />
354
+
355
+ ## Related components
356
+
357
+ - [ActionMenu](/ActionMenu)
358
+ - [SelectPanel](/SelectPanel)
359
+
360
+ <br />
@@ -14,6 +14,7 @@ Use StateLabel components to show the status of an issue or pull request.
14
14
  <StateLabel status="pullClosed">Closed</StateLabel>
15
15
  <StateLabel status="pullMerged">Merged</StateLabel>
16
16
  <StateLabel status="draft">Draft</StateLabel>
17
+ <StateLabel status="issueDraft">Draft</StateLabel>
17
18
  </>
18
19
  ```
19
20
 
@@ -29,7 +30,7 @@ StateLabel components get `COMMON` system props. Read our [System Props](/system
29
30
 
30
31
  ## Component props
31
32
 
32
- | Name | Type | Default | Description |
33
- | :------ | :----- | :------: | :------------------------------------------------------------------------------------------------ |
34
- | variant | String | 'normal' | a value of `small` or `normal` results in a smaller or larger version of the StateLabel. |
35
- | status | String | | Can be one of `issueOpened`, `issueClosed`, `pullOpened`, `pullClosed`, `pullMerged`, or `draft`. |
33
+ | Name | Type | Default | Description |
34
+ | :------ | :----- | :------: | :------------------------------------------------------------------------------------------------------------- |
35
+ | variant | String | 'normal' | a value of `small` or `normal` results in a smaller or larger version of the StateLabel. |
36
+ | status | String | | Can be one of `issueOpened`, `issueClosed`, `pullOpened`, `pullClosed`, `pullMerged`, `draft` or `issueDraft`. |
@@ -105,7 +105,7 @@ If you're rendering React components both server- and client-side, we suggest fo
105
105
 
106
106
  ## TypeScript
107
107
 
108
- Primer React includes TypeScript support and ships with its own typings. You will need still need to to install type typings for the peer dependencies if you import those in your own application code.
108
+ Primer React includes TypeScript support and ships with its own typings. You will still need to install type definitions for the peer dependencies if you import those in your own application code.
109
109
 
110
110
  Once installed, you can import components and their prop type interfaces from the `@primer/components` package:
111
111
 
@@ -9,9 +9,7 @@ export default function Hero() {
9
9
  <ThemeProvider colorMode="night" nightScheme="dark_dimmed">
10
10
  <Box bg="canvas.default" py={6}>
11
11
  <Container>
12
- <Heading color="accent.fg" fontSize={7} lineHeight="condensed" pb={3} m={0}>
13
- Primer React
14
- </Heading>
12
+ <Heading sx={{color: 'accent.fg', fontSize: 7, lineHeight: 'condensed', pb: 3, m: 0}}>Primer React</Heading>
15
13
  <Text as="p" fontFamily="mono" mt={0} mb={2} color="fg.default" fontSize={2}>
16
14
  v{version}
17
15
  </Text>
@@ -8,7 +8,7 @@ function ThemeSwitcher() {
8
8
  return (
9
9
  <DropdownMenu
10
10
  renderAnchor={({children, ...anchorProps}) => (
11
- <DropdownButton variant="small" {...anchorProps}>
11
+ <DropdownButton {...anchorProps} sx={{variant: 'small'}}>
12
12
  {children}
13
13
  </DropdownButton>
14
14
  )}
@@ -1,4 +1,6 @@
1
+ import React from 'react'
1
2
  import * as primerComponents from '@primer/components'
3
+ import * as drafts from '@primer/components/drafts'
2
4
  import * as doctocatComponents from '@primer/gatsby-theme-doctocat'
3
5
  import {
4
6
  CheckIcon,
@@ -18,6 +20,10 @@ import {
18
20
  GearIcon,
19
21
  TypographyIcon,
20
22
  VersionsIcon,
23
+ LinkIcon,
24
+ LawIcon,
25
+ StarIcon,
26
+ AlertIcon,
21
27
  ArrowRightIcon
22
28
  } from '@primer/octicons-react'
23
29
  import State from '../../../components/State'
@@ -26,9 +32,16 @@ import {AnchoredOverlay} from '../../../../src/AnchoredOverlay'
26
32
  import {ConfirmationDialog, useConfirm} from '../../../../src/Dialog/ConfirmationDialog'
27
33
  import {SelectPanel} from '../../../../src/SelectPanel/SelectPanel'
28
34
 
35
+ const ReactRouterLink = ({to, ...props}) => {
36
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
37
+ return <a href={to} {...props} />
38
+ }
39
+
29
40
  export default {
30
41
  ...doctocatComponents,
31
42
  ...primerComponents,
43
+ drafts,
44
+ ReactRouterLink,
32
45
  State,
33
46
  CheckIcon,
34
47
  SearchIcon,
@@ -47,6 +60,10 @@ export default {
47
60
  GearIcon,
48
61
  TypographyIcon,
49
62
  VersionsIcon,
63
+ LinkIcon,
64
+ LawIcon,
65
+ StarIcon,
66
+ AlertIcon,
50
67
  ArrowRightIcon,
51
68
  Dialog2,
52
69
  ConfirmationDialog,
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { SxProp } from '../sx';
3
+ export declare type DescriptionProps = {
4
+ /**
5
+ * Secondary text style variations.
6
+ *
7
+ * - `"inline"` - Secondary text is positioned beside primary text.
8
+ * - `"block"` - Secondary text is positioned below primary text.
9
+ */
10
+ variant?: 'inline' | 'block';
11
+ } & SxProp;
12
+ export declare const Description: React.FC<DescriptionProps>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Description = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Box = _interopRequireDefault(require("../Box"));
11
+
12
+ var _sx = require("../sx");
13
+
14
+ var _Truncate = _interopRequireDefault(require("../Truncate"));
15
+
16
+ var _Item = require("./Item");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const Description = ({
21
+ variant = 'inline',
22
+ sx = {},
23
+ ...props
24
+ }) => {
25
+ const styles = {
26
+ color: 'fg.muted',
27
+ fontSize: 0,
28
+ lineHeight: '16px',
29
+ flexGrow: 1,
30
+ flexBasis: 0,
31
+ minWidth: 0,
32
+ marginLeft: variant === 'block' ? 0 : 2
33
+ };
34
+ return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
35
+ name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
36
+ }, ({
37
+ blockDescriptionId,
38
+ inlineDescriptionId
39
+ }) => variant === 'block' ? /*#__PURE__*/_react.default.createElement(_Box.default, {
40
+ as: "span",
41
+ sx: (0, _sx.merge)(styles, sx),
42
+ id: blockDescriptionId
43
+ }, props.children) : /*#__PURE__*/_react.default.createElement(_Truncate.default, {
44
+ id: inlineDescriptionId,
45
+ sx: (0, _sx.merge)(styles, sx),
46
+ title: props.children,
47
+ inline: true,
48
+ maxWidth: "100%"
49
+ }, props.children));
50
+ };
51
+
52
+ exports.Description = Description;
53
+ Description.displayName = "Description";
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Visually separates `Item`s or `Group`s in an `ActionList`.
4
+ */
5
+ export declare function Divider(): JSX.Element;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Divider = Divider;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Box = _interopRequireDefault(require("../Box"));
11
+
12
+ var _constants = require("../constants");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ /**
17
+ * Visually separates `Item`s or `Group`s in an `ActionList`.
18
+ */
19
+ function Divider() {
20
+ return /*#__PURE__*/_react.default.createElement(_Box.default, {
21
+ as: "li",
22
+ role: "separator",
23
+ sx: {
24
+ height: 1,
25
+ backgroundColor: 'actionListItem.inlineDivider',
26
+ marginTop: theme => `calc(${(0, _constants.get)('space.2')(theme)} - 1px)`,
27
+ marginBottom: 2,
28
+ listStyle: 'none' // hide the ::marker inserted by browser's stylesheet
29
+
30
+ },
31
+ "data-component": "ActionList.Divider"
32
+ });
33
+ }
34
+
35
+ Divider.displayName = "Divider";
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { SxProp } from '../sx';
3
+ import { HeaderProps } from './Header';
4
+ import { ListProps } from './List';
5
+ export declare type GroupProps = HeaderProps & SxProp & {
6
+ selectionVariant?: ListProps['selectionVariant'] | false;
7
+ };
8
+ declare type ContextProps = Pick<GroupProps, 'selectionVariant'>;
9
+ export declare const GroupContext: React.Context<ContextProps>;
10
+ export declare const Group: React.FC<GroupProps>;
11
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Group = exports.GroupContext = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Box = _interopRequireDefault(require("../Box"));
11
+
12
+ var _Header = require("./Header");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
+
18
+ const GroupContext = /*#__PURE__*/_react.default.createContext({});
19
+
20
+ exports.GroupContext = GroupContext;
21
+
22
+ const Group = ({
23
+ title,
24
+ variant,
25
+ auxiliaryText,
26
+ selectionVariant,
27
+ sx = {},
28
+ ...props
29
+ }) => {
30
+ return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
31
+ as: "li",
32
+ sx: {
33
+ '&:not(:first-child)': {
34
+ marginTop: 2
35
+ },
36
+ listStyle: 'none',
37
+ // hide the ::marker inserted by browser's stylesheet
38
+ ...sx
39
+ }
40
+ }, props), title && /*#__PURE__*/_react.default.createElement(_Header.Header, {
41
+ title: title,
42
+ variant: variant,
43
+ auxiliaryText: auxiliaryText
44
+ }), /*#__PURE__*/_react.default.createElement(GroupContext.Provider, {
45
+ value: {
46
+ selectionVariant
47
+ }
48
+ }, /*#__PURE__*/_react.default.createElement(_Box.default, {
49
+ as: "ul",
50
+ sx: {
51
+ paddingInlineStart: 0
52
+ }
53
+ }, props.children)));
54
+ };
55
+
56
+ exports.Group = Group;
57
+ Group.displayName = "Group";
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ import { SxProp } from '../sx';
3
+ /**
4
+ * Contract for props passed to the `Header` component.
5
+ */
6
+ export declare type HeaderProps = {
7
+ /**
8
+ * Style variations. Usage is discretionary.
9
+ *
10
+ * - `"filled"` - Superimposed on a background, offset from nearby content
11
+ * - `"subtle"` - Relatively less offset from nearby content
12
+ */
13
+ variant?: 'subtle' | 'filled';
14
+ /**
15
+ * Primary text which names a `Group`.
16
+ */
17
+ title?: string;
18
+ /**
19
+ * Secondary text which provides additional information about a `Group`.
20
+ */
21
+ auxiliaryText?: string;
22
+ } & SxProp;
23
+ /**
24
+ * Displays the name and description of a `Group`.
25
+ */
26
+ export declare const Header: ({ variant, title, auxiliaryText, sx, ...props }: HeaderProps) => JSX.Element;