@primer/components 33.0.0-rc.b495ba4a → 33.1.0-rc.6856bcf5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. package/.devcontainer/devcontainer.json +1 -1
  2. package/.github/workflows/ci.yml +1 -1
  3. package/.github/workflows/release.yml +6 -27
  4. package/.github/workflows/release_canary.yml +4 -60
  5. package/.github/workflows/release_candidate.yml +5 -51
  6. package/.github/workflows/statuses.yml +32 -0
  7. package/.gitignore +1 -0
  8. package/.nvmrc +1 -1
  9. package/CHANGELOG.md +20 -0
  10. package/contributor-docs/CONTRIBUTING.md +14 -61
  11. package/dist/browser.esm.js +2 -2209
  12. package/dist/browser.esm.js.map +1 -1
  13. package/dist/browser.umd.js +2 -2209
  14. package/dist/browser.umd.js.map +1 -1
  15. package/docs/content/AnchoredOverlay.mdx +121 -1
  16. package/docs/content/Avatar.mdx +29 -14
  17. package/docs/content/AvatarPair.mdx +47 -0
  18. package/docs/content/AvatarStack.mdx +14 -6
  19. package/docs/content/Box.mdx +13 -11
  20. package/docs/content/BranchName.mdx +52 -0
  21. package/docs/content/{Breadcrumbs.md → Breadcrumbs.mdx} +21 -13
  22. package/docs/content/Link.mdx +75 -0
  23. package/docs/content/Radio.md +90 -0
  24. package/docs/content/TextInput.mdx +125 -0
  25. package/docs/content/drafts/ActionList2.mdx +484 -0
  26. package/docs/content/drafts/ActionMenu2.mdx +302 -0
  27. package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +9 -1
  28. package/docs/src/@primer/gatsby-theme-doctocat/mdx-components.js +15 -2
  29. package/docs/src/@primer/gatsby-theme-doctocat/nav.yml +4 -0
  30. package/docs/src/component-checklist.js +10 -2
  31. package/docs/src/props-table.js +165 -0
  32. package/docs/src/props.js +14 -28
  33. package/lib/ActionList/Header.js +1 -1
  34. package/lib/ActionList/Item.js +10 -10
  35. package/lib/ActionList/List.js +1 -1
  36. package/lib/ActionList2/ActionListContainerContext.d.ts +10 -0
  37. package/lib/ActionList2/ActionListContainerContext.js +15 -0
  38. package/lib/ActionList2/Divider.d.ts +3 -2
  39. package/lib/ActionList2/Divider.js +10 -5
  40. package/lib/ActionList2/Item.js +22 -8
  41. package/lib/ActionList2/List.js +12 -2
  42. package/lib/ActionList2/Selection.js +11 -0
  43. package/lib/ActionList2/index.d.ts +1 -2
  44. package/lib/ActionMenu2.d.ts +317 -0
  45. package/lib/ActionMenu2.js +125 -0
  46. package/lib/Autocomplete/Autocomplete.d.ts +2 -1
  47. package/lib/Autocomplete/AutocompleteInput.d.ts +2 -1
  48. package/lib/BaseStyles.js +2 -20
  49. package/lib/BorderBox.js +1 -1
  50. package/lib/Box.js +1 -1
  51. package/lib/BranchName.js +1 -1
  52. package/lib/Breadcrumbs.js +3 -3
  53. package/lib/Button/Button.d.ts +2 -2
  54. package/lib/Button/Button.js +1 -1
  55. package/lib/Button/ButtonClose.d.ts +2 -2
  56. package/lib/Button/ButtonDanger.d.ts +2 -2
  57. package/lib/Button/ButtonGroup.js +1 -1
  58. package/lib/Button/ButtonInvisible.d.ts +2 -2
  59. package/lib/Button/ButtonOutline.d.ts +2 -2
  60. package/lib/Button/ButtonPrimary.d.ts +2 -2
  61. package/lib/Checkbox.d.ts +1 -1
  62. package/lib/Checkbox.js +1 -1
  63. package/lib/CircleOcticon.d.ts +35 -35
  64. package/lib/Details.js +1 -1
  65. package/lib/Dialog.d.ts +37 -37
  66. package/lib/Dropdown.d.ts +6 -6
  67. package/lib/DropdownMenu/DropdownButton.d.ts +6 -3
  68. package/lib/FilterList.d.ts +1 -1
  69. package/lib/FilteredActionList/FilteredActionList.js +1 -1
  70. package/lib/Flex.js +1 -1
  71. package/lib/LabelGroup.js +1 -1
  72. package/lib/Overlay.js +1 -1
  73. package/lib/Pagination/Pagination.js +2 -2
  74. package/lib/Position.d.ts +4 -4
  75. package/lib/Position.js +1 -1
  76. package/lib/Radio.d.ts +38 -0
  77. package/lib/Radio.js +55 -0
  78. package/lib/SelectMenu/SelectMenu.d.ts +11 -10
  79. package/lib/SelectMenu/SelectMenu.js +1 -1
  80. package/lib/SelectMenu/SelectMenuFilter.js +1 -1
  81. package/lib/SelectMenu/SelectMenuFooter.js +1 -1
  82. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  83. package/lib/SelectMenu/SelectMenuItem.js +1 -1
  84. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  85. package/lib/SelectMenu/SelectMenuTab.js +1 -1
  86. package/lib/SelectMenu/SelectMenuTabPanel.js +1 -1
  87. package/lib/SelectMenu/SelectMenuTabs.js +1 -1
  88. package/lib/StateLabel.js +1 -1
  89. package/lib/StyledOcticon.js +1 -1
  90. package/lib/SubNav.js +3 -3
  91. package/lib/TextInputWithTokens.d.ts +2 -1
  92. package/lib/ThemeProvider.d.ts +1 -0
  93. package/lib/ThemeProvider.js +17 -4
  94. package/lib/Timeline.js +4 -4
  95. package/lib/Token/AvatarToken.d.ts +1 -1
  96. package/lib/Token/AvatarToken.js +1 -1
  97. package/lib/Token/IssueLabelToken.d.ts +1 -1
  98. package/lib/Token/Token.d.ts +1 -1
  99. package/lib/Token/TokenBase.js +1 -1
  100. package/lib/Tooltip.js +1 -1
  101. package/lib/UnderlineNav.js +2 -2
  102. package/lib/__tests__/Radio.test.d.ts +2 -0
  103. package/lib/__tests__/Radio.test.js +202 -0
  104. package/lib/__tests__/ThemeProvider.test.js +114 -0
  105. package/lib/drafts.d.ts +1 -0
  106. package/lib/drafts.js +13 -0
  107. package/lib/hooks/index.d.ts +1 -0
  108. package/lib/hooks/index.js +9 -1
  109. package/lib/index.d.ts +2 -0
  110. package/lib/index.js +8 -0
  111. package/lib/stories/ActionList.stories.js +3 -3
  112. package/lib/stories/ActionList2.stories.js +1 -1
  113. package/lib/stories/ActionMenu2.stories.js +455 -0
  114. package/lib/stories/Checkbox.stories.js +4 -4
  115. package/lib/stories/Radio.stories.js +146 -0
  116. package/lib/stories/ThemeProvider.stories.js +1 -5
  117. package/lib/stories/useFocusTrap.stories.js +1 -11
  118. package/lib/stories/useFocusZone.stories.js +2 -6
  119. package/lib-esm/ActionList/Header.js +1 -1
  120. package/lib-esm/ActionList/Item.js +10 -10
  121. package/lib-esm/ActionList/List.js +1 -1
  122. package/lib-esm/ActionList2/ActionListContainerContext.d.ts +10 -0
  123. package/lib-esm/ActionList2/ActionListContainerContext.js +3 -0
  124. package/lib-esm/ActionList2/Divider.d.ts +3 -2
  125. package/lib-esm/ActionList2/Divider.js +8 -5
  126. package/lib-esm/ActionList2/Item.js +20 -8
  127. package/lib-esm/ActionList2/List.js +10 -2
  128. package/lib-esm/ActionList2/Selection.js +9 -0
  129. package/lib-esm/ActionList2/index.d.ts +1 -2
  130. package/lib-esm/ActionMenu2.d.ts +317 -0
  131. package/lib-esm/ActionMenu2.js +100 -0
  132. package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -1
  133. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -1
  134. package/lib-esm/BaseStyles.js +2 -20
  135. package/lib-esm/BorderBox.js +1 -1
  136. package/lib-esm/Box.js +1 -1
  137. package/lib-esm/BranchName.js +1 -1
  138. package/lib-esm/Breadcrumbs.js +3 -3
  139. package/lib-esm/Button/Button.d.ts +2 -2
  140. package/lib-esm/Button/Button.js +1 -1
  141. package/lib-esm/Button/ButtonClose.d.ts +2 -2
  142. package/lib-esm/Button/ButtonDanger.d.ts +2 -2
  143. package/lib-esm/Button/ButtonGroup.js +1 -1
  144. package/lib-esm/Button/ButtonInvisible.d.ts +2 -2
  145. package/lib-esm/Button/ButtonOutline.d.ts +2 -2
  146. package/lib-esm/Button/ButtonPrimary.d.ts +2 -2
  147. package/lib-esm/Checkbox.d.ts +1 -1
  148. package/lib-esm/Checkbox.js +1 -1
  149. package/lib-esm/CircleOcticon.d.ts +35 -35
  150. package/lib-esm/Details.js +1 -1
  151. package/lib-esm/Dialog.d.ts +37 -37
  152. package/lib-esm/Dropdown.d.ts +6 -6
  153. package/lib-esm/DropdownMenu/DropdownButton.d.ts +6 -3
  154. package/lib-esm/FilterList.d.ts +1 -1
  155. package/lib-esm/FilteredActionList/FilteredActionList.js +1 -1
  156. package/lib-esm/Flex.js +1 -1
  157. package/lib-esm/LabelGroup.js +1 -1
  158. package/lib-esm/Overlay.js +1 -1
  159. package/lib-esm/Pagination/Pagination.js +2 -2
  160. package/lib-esm/Position.d.ts +4 -4
  161. package/lib-esm/Position.js +1 -1
  162. package/lib-esm/Radio.d.ts +38 -0
  163. package/lib-esm/Radio.js +40 -0
  164. package/lib-esm/SelectMenu/SelectMenu.d.ts +11 -10
  165. package/lib-esm/SelectMenu/SelectMenu.js +1 -1
  166. package/lib-esm/SelectMenu/SelectMenuFilter.js +1 -1
  167. package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
  168. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  169. package/lib-esm/SelectMenu/SelectMenuItem.js +1 -1
  170. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  171. package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
  172. package/lib-esm/SelectMenu/SelectMenuTabPanel.js +1 -1
  173. package/lib-esm/SelectMenu/SelectMenuTabs.js +1 -1
  174. package/lib-esm/StateLabel.js +1 -1
  175. package/lib-esm/StyledOcticon.js +1 -1
  176. package/lib-esm/SubNav.js +3 -3
  177. package/lib-esm/TextInputWithTokens.d.ts +2 -1
  178. package/lib-esm/ThemeProvider.d.ts +1 -0
  179. package/lib-esm/ThemeProvider.js +17 -4
  180. package/lib-esm/Timeline.js +4 -4
  181. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  182. package/lib-esm/Token/AvatarToken.js +1 -1
  183. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  184. package/lib-esm/Token/Token.d.ts +1 -1
  185. package/lib-esm/Token/TokenBase.js +1 -1
  186. package/lib-esm/Tooltip.js +1 -1
  187. package/lib-esm/UnderlineNav.js +2 -2
  188. package/lib-esm/__tests__/Radio.test.d.ts +2 -0
  189. package/lib-esm/__tests__/Radio.test.js +183 -0
  190. package/lib-esm/__tests__/ThemeProvider.test.js +114 -0
  191. package/lib-esm/drafts.d.ts +1 -0
  192. package/lib-esm/drafts.js +2 -1
  193. package/lib-esm/hooks/index.d.ts +1 -0
  194. package/lib-esm/hooks/index.js +2 -1
  195. package/lib-esm/index.d.ts +2 -0
  196. package/lib-esm/index.js +1 -0
  197. package/lib-esm/stories/ActionList.stories.js +3 -3
  198. package/lib-esm/stories/ActionList2.stories.js +1 -1
  199. package/lib-esm/stories/ActionMenu2.stories.js +393 -0
  200. package/lib-esm/stories/Checkbox.stories.js +5 -5
  201. package/lib-esm/stories/Radio.stories.js +121 -0
  202. package/lib-esm/stories/ThemeProvider.stories.js +1 -5
  203. package/lib-esm/stories/useFocusTrap.stories.js +1 -11
  204. package/lib-esm/stories/useFocusZone.stories.js +2 -6
  205. package/package-lock.json +1366 -3544
  206. package/package.json +14 -8
  207. package/script/component-status-project/build.ts +100 -0
  208. package/script/component-status-project/deploy.rb +142 -0
  209. package/src/ActionList2/ActionListContainerContext.tsx +14 -0
  210. package/src/ActionList2/Divider.tsx +13 -8
  211. package/src/ActionList2/Item.tsx +14 -6
  212. package/src/ActionList2/List.tsx +6 -2
  213. package/src/ActionList2/Selection.tsx +9 -0
  214. package/src/ActionMenu2.tsx +116 -0
  215. package/src/BranchName.tsx +2 -1
  216. package/src/Radio.tsx +76 -0
  217. package/src/ThemeProvider.tsx +22 -5
  218. package/src/__tests__/Radio.test.tsx +174 -0
  219. package/src/__tests__/ThemeProvider.test.tsx +116 -0
  220. package/src/__tests__/__snapshots__/BranchName.test.tsx.snap +3 -1
  221. package/src/__tests__/__snapshots__/Radio.test.tsx.snap +16 -0
  222. package/src/drafts.ts +1 -0
  223. package/src/hooks/index.ts +1 -0
  224. package/src/index.ts +2 -0
  225. package/src/stories/ActionMenu2.stories.tsx +605 -0
  226. package/src/stories/Checkbox.stories.tsx +1 -3
  227. package/src/stories/Radio.stories.tsx +126 -0
  228. package/stats.html +1 -1
  229. package/tsconfig.build.json +1 -1
  230. package/tsconfig.json +1 -1
  231. package/docs/content/ActionList2.mdx +0 -379
  232. package/docs/content/BranchName.md +0 -39
  233. package/docs/content/Link.md +0 -29
  234. package/docs/content/TextInput.md +0 -42
@@ -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'), ({
@@ -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.
@@ -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
+ container?: string;
5
+ listRole?: string;
6
+ itemRole?: string;
7
+ afterSelect?: Function;
8
+ };
9
+ export declare const ActionListContainerContext: React.Context<ContextProps>;
10
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ActionListContainerContext = 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 ActionListContainerContext = /*#__PURE__*/_react.default.createContext({});
14
+
15
+ exports.ActionListContainerContext = ActionListContainerContext;
@@ -1,5 +1,6 @@
1
- /// <reference types="react" />
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 function Divider(): JSX.Element;
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 = 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
- function Divider() {
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";
@@ -21,6 +21,8 @@ var _createSlots = _interopRequireDefault(require("../utils/create-slots"));
21
21
 
22
22
  var _List = require("./List");
23
23
 
24
+ var _ActionListContainerContext = require("./ActionListContainerContext");
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); }
@@ -68,7 +70,7 @@ exports.Slot = Slot;
68
70
 
69
71
  const LiBox = _styledComponents.default.li.withConfig({
70
72
  displayName: "Item__LiBox",
71
- componentId: "c3scat-0"
73
+ componentId: "sc-c3scat-0"
72
74
  })(_sx.default);
73
75
 
74
76
  const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
@@ -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(_ActionListContainerContext.ActionListContainerContext);
100
+
93
101
  const {
94
102
  theme
95
103
  } = (0, _ThemeProvider.useTheme)();
@@ -163,19 +171,24 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
163
171
  };
164
172
 
165
173
  const clickHandler = _react.default.useCallback(event => {
166
- if (typeof onSelect !== 'function') return;
167
174
  if (disabled) return;
168
- if (!event.defaultPrevented) onSelect(event);
169
- }, [onSelect, disabled]);
175
+
176
+ if (!event.defaultPrevented) {
177
+ if (typeof onSelect === 'function') onSelect(event); // if this Item is inside a Menu, close the Menu
178
+
179
+ if (typeof afterSelect === 'function') afterSelect();
180
+ }
181
+ }, [onSelect, disabled, afterSelect]);
170
182
 
171
183
  const keyPressHandler = _react.default.useCallback(event => {
172
- if (typeof onSelect !== 'function') return;
173
184
  if (disabled) return;
174
185
 
175
186
  if (!event.defaultPrevented && [' ', 'Enter'].includes(event.key)) {
176
- onSelect(event);
187
+ if (typeof onSelect === 'function') onSelect(event); // if this Item is inside a Menu, close the Menu
188
+
189
+ if (typeof afterSelect === 'function') afterSelect();
177
190
  }
178
- }, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
191
+ }, [onSelect, disabled, afterSelect]); // use props.id if provided, otherwise generate one.
179
192
 
180
193
 
181
194
  const labelId = (0, _ssr.useSSRSafeId)(id);
@@ -198,7 +211,8 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
198
211
  "aria-disabled": disabled ? true : undefined,
199
212
  tabIndex: disabled || _PrivateItemWrapper ? undefined : 0,
200
213
  "aria-labelledby": `${labelId} ${slots.InlineDescription ? inlineDescriptionId : ''}`,
201
- "aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined
214
+ "aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined,
215
+ role: role || itemRole
202
216
  }, props), /*#__PURE__*/_react.default.createElement(ItemWrapper, null, /*#__PURE__*/_react.default.createElement(_Selection.Selection, {
203
217
  selected: selected
204
218
  }), slots.LeadingVisual, /*#__PURE__*/_react.default.createElement(_Box.default, {
@@ -11,6 +11,8 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
11
 
12
12
  var _sx = _interopRequireWildcard(require("../sx"));
13
13
 
14
+ var _ActionListContainerContext = require("./ActionListContainerContext");
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; }
@@ -25,13 +27,14 @@ exports.ListContext = ListContext;
25
27
 
26
28
  const ListBox = _styledComponents.default.ul.withConfig({
27
29
  displayName: "List__ListBox",
28
- componentId: "cvbq60-0"
30
+ componentId: "sc-cvbq60-0"
29
31
  })(_sx.default);
30
32
 
31
33
  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(_ActionListContainerContext.ActionListContainerContext);
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, {
@@ -13,6 +13,8 @@ var _List = require("./List");
13
13
 
14
14
  var _Group = require("./Group");
15
15
 
16
+ var _ActionListContainerContext = require("./ActionListContainerContext");
17
+
16
18
  var _Visuals = require("./Visuals");
17
19
 
18
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -27,6 +29,10 @@ const Selection = ({
27
29
  const {
28
30
  selectionVariant: groupSelectionVariant
29
31
  } = _react.default.useContext(_Group.GroupContext);
32
+
33
+ const {
34
+ container
35
+ } = _react.default.useContext(_ActionListContainerContext.ActionListContainerContext);
30
36
  /** selectionVariant in Group can override the selectionVariant in List root */
31
37
 
32
38
 
@@ -38,6 +44,11 @@ const Selection = ({
38
44
  return null;
39
45
  }
40
46
 
47
+ if (container === 'ActionMenu') {
48
+ throw new Error('ActionList cannot have a selectionVariant inside ActionMenu, please use DropdownMenu or SelectPanel instead. More information: https://primer.style/design/components/action-list#application');
49
+ return null;
50
+ }
51
+
41
52
  if (selectionVariant === 'single') {
42
53
  return /*#__PURE__*/_react.default.createElement(_Visuals.LeadingVisualContainer, null, selected && /*#__PURE__*/_react.default.createElement(_octiconsReact.CheckIcon, null));
43
54
  }
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { Divider } from './Divider';
3
2
  export type { ListProps as ActionListProps } from './List';
4
3
  export type { GroupProps } from './Group';
5
4
  export type { ItemProps } from './Item';
@@ -26,7 +25,7 @@ export declare const ActionList: import("@radix-ui/react-polymorphic").ForwardRe
26
25
  referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
27
26
  }>;
28
27
  /** Visually separates `Item`s or `Group`s in an `ActionList`. */
29
- Divider: typeof Divider;
28
+ Divider: import("react").FC<import("../sx").SxProp>;
30
29
  /** Secondary text which provides additional information about an `Item`. */
31
30
  Description: import("react").FC<import("./Description").DescriptionProps>;
32
31
  /** Icon (or similar) positioned before `Item` text. */