@primer/components 31.2.1-rc.18690e3f → 31.2.1-rc.a088bdc0

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 (76) hide show
  1. package/.github/workflows/release_canary.yml +1 -0
  2. package/CHANGELOG.md +7 -1
  3. package/dist/browser.esm.js +194 -190
  4. package/dist/browser.esm.js.map +1 -1
  5. package/dist/browser.umd.js +204 -200
  6. package/dist/browser.umd.js.map +1 -1
  7. package/docs/content/ActionList2.mdx +8 -7
  8. package/docs/content/{Box.md → Box.mdx} +22 -0
  9. package/docs/src/component-checklist.js +81 -0
  10. package/lib/ActionList/Item.js +27 -52
  11. package/lib/ActionList/Item.jsx +17 -40
  12. package/lib/ActionList2/Description.js +8 -4
  13. package/lib/ActionList2/Description.jsx +2 -3
  14. package/lib/ActionList2/Group.d.ts +28 -2
  15. package/lib/ActionList2/Group.js +55 -6
  16. package/lib/ActionList2/Group.jsx +33 -4
  17. package/lib/ActionList2/Item.js +6 -7
  18. package/lib/ActionList2/Item.jsx +5 -5
  19. package/lib/ActionList2/List.d.ts +1 -1
  20. package/lib/Autocomplete/Autocomplete.d.ts +3 -3
  21. package/lib/Autocomplete/AutocompleteInput.d.ts +3 -3
  22. package/lib/Button/ButtonClose.d.ts +2 -2
  23. package/lib/CircleOcticon.d.ts +1 -1
  24. package/lib/Dialog.d.ts +3 -3
  25. package/lib/Dropdown.d.ts +4 -4
  26. package/lib/DropdownMenu/DropdownButton.d.ts +2 -2
  27. package/lib/FilterList.d.ts +1 -1
  28. package/lib/NewButton/button.js +34 -42
  29. package/lib/NewButton/button.jsx +24 -23
  30. package/lib/Position.d.ts +4 -4
  31. package/lib/SelectMenu/SelectMenu.d.ts +11 -11
  32. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  33. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  34. package/lib/TextInputWithTokens.d.ts +3 -3
  35. package/lib/Timeline.d.ts +1 -1
  36. package/lib/Token/Token.d.ts +1 -1
  37. package/lib/stories/ActionList2.stories.js +4 -3
  38. package/lib/utils/testing.d.ts +6 -60
  39. package/lib-esm/ActionList/Item.js +28 -53
  40. package/lib-esm/ActionList2/Description.js +8 -4
  41. package/lib-esm/ActionList2/Group.d.ts +28 -2
  42. package/lib-esm/ActionList2/Group.js +52 -5
  43. package/lib-esm/ActionList2/Item.js +6 -7
  44. package/lib-esm/ActionList2/List.d.ts +1 -1
  45. package/lib-esm/Autocomplete/Autocomplete.d.ts +3 -3
  46. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +3 -3
  47. package/lib-esm/Button/ButtonClose.d.ts +2 -2
  48. package/lib-esm/CircleOcticon.d.ts +1 -1
  49. package/lib-esm/Dialog.d.ts +3 -3
  50. package/lib-esm/Dropdown.d.ts +4 -4
  51. package/lib-esm/DropdownMenu/DropdownButton.d.ts +2 -2
  52. package/lib-esm/FilterList.d.ts +1 -1
  53. package/lib-esm/NewButton/button.js +31 -42
  54. package/lib-esm/Position.d.ts +4 -4
  55. package/lib-esm/SelectMenu/SelectMenu.d.ts +11 -11
  56. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  57. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  58. package/lib-esm/TextInputWithTokens.d.ts +3 -3
  59. package/lib-esm/Timeline.d.ts +1 -1
  60. package/lib-esm/Token/Token.d.ts +1 -1
  61. package/lib-esm/stories/ActionList2.stories.js +4 -3
  62. package/lib-esm/theme-preval.js +66 -366
  63. package/lib-esm/utils/testing.d.ts +6 -60
  64. package/package-lock.json +7 -7
  65. package/package.json +2 -2
  66. package/src/ActionList/Item.tsx +17 -46
  67. package/src/ActionList2/Description.tsx +7 -4
  68. package/src/ActionList2/Group.tsx +76 -7
  69. package/src/ActionList2/Item.tsx +6 -5
  70. package/src/ActionList2/List.tsx +1 -1
  71. package/src/NewButton/button.tsx +82 -78
  72. package/src/__tests__/__snapshots__/ActionList.test.tsx.snap +5 -5
  73. package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +25 -25
  74. package/src/__tests__/__snapshots__/NewButton.test.tsx.snap +5 -0
  75. package/src/stories/ActionList2.stories.tsx +3 -3
  76. package/stats.html +1 -1
@@ -336,13 +336,14 @@ render(<SelectFields />)
336
336
 
337
337
  ### ActionList.Group
338
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 |
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
+ | role | [AriaRole](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles) | - | Optional. \* The ARIA role describing the function of the list inside `Group` component. `listbox` or `menu` are a common values. |
346
347
 
347
348
  <br />
348
349
 
@@ -1,10 +1,12 @@
1
1
  ---
2
2
  title: Box
3
+ status: Beta
3
4
  description: A low-level utility component that accepts styled system props to enable custom theme-aware styling
4
5
  source: https://github.com/primer/react/blob/main/src/Box.tsx
5
6
  ---
6
7
 
7
8
  import {Props} from '../src/props'
9
+ import {ComponentChecklist} from '../src/component-checklist'
8
10
  import {Box} from '@primer/components'
9
11
 
10
12
  ```jsx live
@@ -72,3 +74,23 @@ Use Box to create [grid](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_
72
74
  </Box>
73
75
  </Box>
74
76
  ```
77
+
78
+ ## Component status
79
+
80
+ <ComponentChecklist
81
+ items={{
82
+ propsDocumented: true,
83
+ noUnnecessaryDeps: true,
84
+ adaptsToThemes: true,
85
+ adaptsToScreenSizes: true,
86
+ fullTestCoverage: true,
87
+ usedInProduction: true,
88
+ usageExamplesDocumented: true,
89
+ designReviewed: null,
90
+ a11yReviewed: null,
91
+ stableApi: false,
92
+ addressedApiFeedback: false,
93
+ hasDesignGuidelines: null,
94
+ hasFigmaComponent: null
95
+ }}
96
+ />
@@ -0,0 +1,81 @@
1
+ import {Box, StyledOcticon, Link, Text} from '@primer/components'
2
+ import {H3} from '@primer/gatsby-theme-doctocat/src/components/heading'
3
+ import {CheckCircleFillIcon, CircleIcon, SkipIcon} from '@primer/octicons-react'
4
+ import React from 'react'
5
+
6
+ /** Render component status checklist in documentation pages */
7
+ export function ComponentChecklist({items}) {
8
+ return (
9
+ <>
10
+ <H3>Alpha</H3>
11
+ <Checklist aria-describedby="alpha">
12
+ <Checklist.Item checked={items.propsDocumented}>Component props are documented.</Checklist.Item>
13
+ <Checklist.Item checked={items.noUnnecessaryDeps}>
14
+ Component does not have any unnecessary third-party dependencies.
15
+ </Checklist.Item>
16
+ <Checklist.Item checked={items.adaptsToThemes}>Component can adapt to different themes.</Checklist.Item>
17
+ <Checklist.Item checked={items.adaptsToScreenSizes}>
18
+ Component can adapt to different screen sizes.
19
+ </Checklist.Item>
20
+ <Checklist.Item checked={items.fullTestCoverage}>Component has 100% test coverage.</Checklist.Item>
21
+ </Checklist>
22
+ <H3>Beta</H3>
23
+ <Checklist aria-describedby="beta">
24
+ <Checklist.Item checked={items.usedInProduction}>Component is used in a production application.</Checklist.Item>
25
+ <Checklist.Item checked={items.usageExamplesDocumented}>Common usage examples are documented.</Checklist.Item>
26
+ <Checklist.Item checked={items.designReviewed}>
27
+ Component has been reviewed by a systems designer and any resulting issues have been addressed.
28
+ </Checklist.Item>
29
+ <Checklist.Item checked={items.a11yReviewed}>
30
+ Component has been manually reviewed by the accessibility team and any resulting issues have been addressed.
31
+ </Checklist.Item>
32
+ </Checklist>
33
+ <H3>Stable</H3>
34
+ <Checklist aria-describedby="stable">
35
+ <Checklist.Item checked={items.apiIsStable}>
36
+ Component API has been stable with no breaking changes for at least one month.
37
+ </Checklist.Item>
38
+ <Checklist.Item checked={items.addressedApiFeedback}>
39
+ Feedback on API usability has been sought from developers using the component and any resulting issues have
40
+ been addressed.
41
+ </Checklist.Item>
42
+ <Checklist.Item checked={items.hasDesignGuidelines}>
43
+ Component has corresponding design guidelines documented in the{' '}
44
+ <Link href="https://primer.style/design/">interface guidelines</Link>.
45
+ </Checklist.Item>
46
+ <Checklist.Item checked={items.hasFigmaComponent}>
47
+ Component has corresponding Figma component in the Primer Web library.
48
+ </Checklist.Item>
49
+ </Checklist>
50
+ </>
51
+ )
52
+ }
53
+
54
+ // TODO: This component should live in Doctocat
55
+ function Checklist({'aria-describedby': ariaDescribedby, children}) {
56
+ return (
57
+ <Box aria-describedby={ariaDescribedby} as="ul" display="grid" gridGap={2} p={0} m={0} mb={3}>
58
+ {children}
59
+ </Box>
60
+ )
61
+ }
62
+
63
+ Checklist.Item = ({checked, children}) => {
64
+ return (
65
+ <Box as="li" display="grid" gridTemplateColumns="auto 1fr" gridGap={2} sx={{listStyleType: 'none'}}>
66
+ <Box height="24px" display="flex" alignItems="center">
67
+ {checked ? (
68
+ <StyledOcticon aria-label="Completed" icon={CheckCircleFillIcon} sx={{color: 'success.fg'}} />
69
+ ) : checked === null ? (
70
+ <StyledOcticon icon={SkipIcon} sx={{color: 'fg.subtle'}} />
71
+ ) : (
72
+ <StyledOcticon aria-label="To do" icon={CircleIcon} sx={{color: 'fg.subtle'}} />
73
+ )}
74
+ </Box>
75
+ <Text color={checked === null ? 'fg.subtle' : 'fg.default'}>
76
+ {checked === null ? <Text color="fg.subtle">N/A: </Text> : null}
77
+ {children}
78
+ </Text>
79
+ </Box>
80
+ )
81
+ }
@@ -35,39 +35,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
35
35
 
36
36
  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); }
37
37
 
38
- /**
39
- * These colors are not yet in our default theme. Need to remove this once they are added.
40
- */
41
- const customItemThemes = {
42
- default: {
43
- hover: {
44
- light: 'rgba(46, 77, 108, 0.06)',
45
- dark: 'rgba(201, 206, 212, 0.12)',
46
- dark_dimmed: 'rgba(201, 206, 212, 0.12)'
47
- },
48
- focus: {
49
- light: 'rgba(54, 77, 100, 0.16)',
50
- dark: 'rgba(201, 206, 212, 0.24)',
51
- dark_dimmed: 'rgba(201, 206, 212, 0.24)'
52
- }
53
- },
54
- danger: {
55
- hover: {
56
- light: 'rgba(234, 74, 90, 0.08)',
57
- dark: 'rgba(248, 81, 73, 0.16)',
58
- dark_dimmed: 'rgba(248, 81, 73, 0.16)'
59
- },
60
- focus: {
61
- light: 'rgba(234, 74, 90, 0.14)',
62
- dark: 'rgba(248, 81, 73, 0.24)',
63
- dark_dimmed: 'rgba(248, 81, 73, 0.24)'
64
- }
65
- }
66
- };
67
- /**
68
- * Contract for props passed to the `Item` component.
69
- */
70
-
71
38
  const getItemVariant = (variant = 'default', disabled) => {
72
39
  if (disabled) {
73
40
  return {
@@ -84,7 +51,10 @@ const getItemVariant = (variant = 'default', disabled) => {
84
51
  color: (0, _constants.get)('colors.danger.fg'),
85
52
  iconColor: (0, _constants.get)('colors.danger.fg'),
86
53
  annotationColor: (0, _constants.get)('colors.fg.muted'),
87
- hoverCursor: 'pointer'
54
+ hoverCursor: 'pointer',
55
+ hoverBg: (0, _constants.get)('colors.actionListItem.danger.hoverBg'),
56
+ focusBg: (0, _constants.get)('colors.actionListItem.danger.activeBg'),
57
+ hoverText: (0, _constants.get)('colors.actionListItem.danger.hoverText')
88
58
  };
89
59
 
90
60
  default:
@@ -92,7 +62,9 @@ const getItemVariant = (variant = 'default', disabled) => {
92
62
  color: (0, _constants.get)('colors.fg.default'),
93
63
  iconColor: (0, _constants.get)('colors.fg.muted'),
94
64
  annotationColor: (0, _constants.get)('colors.fg.muted'),
95
- hoverCursor: 'pointer'
65
+ hoverCursor: 'pointer',
66
+ hoverBg: (0, _constants.get)('colors.actionListItem.default.hoverBg'),
67
+ focusBg: (0, _constants.get)('colors.actionListItem.default.activeBg')
96
68
  };
97
69
  }
98
70
  };
@@ -110,12 +82,16 @@ const MainContent = _styledComponents.default.div.withConfig({
110
82
  const StyledItem = _styledComponents.default.div.withConfig({
111
83
  displayName: "Item__StyledItem",
112
84
  componentId: "jqpvy8-2"
113
- })(["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,", ");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'), ({
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'), ({
114
86
  variant,
115
87
  item
116
88
  }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).color, ({
117
- hoverBackground
118
- }) => hoverBackground, ({
89
+ variant,
90
+ item
91
+ }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).hoverBg, ({
92
+ variant,
93
+ item
94
+ }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).hoverText, ({
119
95
  variant,
120
96
  item
121
97
  }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).hoverCursor, _Divider.StyledDivider, _Header.StyledHeader, ({
@@ -123,14 +99,18 @@ const StyledItem = _styledComponents.default.div.withConfig({
123
99
  }) => showDivider ? `1px` : '0', DividedContent, (0, _constants.get)('colors.border.muted'), ({
124
100
  showDivider
125
101
  }) => showDivider ? `1px` : '0', DividedContent, DividedContent, DividedContent, DividedContent, _focusZone.isActiveDescendantAttribute, DividedContent, _focusZone.isActiveDescendantAttribute, DividedContent, _focusZone.isActiveDescendantAttribute, _focusZone.activeDescendantActivatedDirectly, ({
126
- focusBackground
127
- }) => focusBackground, _focusZone.isActiveDescendantAttribute, _focusZone.activeDescendantActivatedIndirectly, ({
128
- hoverBackground
129
- }) => hoverBackground, ({
130
- focusBackground
131
- }) => focusBackground, ({
132
- focusBackground
133
- }) => focusBackground, _sx.default);
102
+ variant,
103
+ item
104
+ }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).focusBg, _focusZone.isActiveDescendantAttribute, _focusZone.activeDescendantActivatedIndirectly, ({
105
+ variant,
106
+ item
107
+ }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).hoverBg, ({
108
+ variant,
109
+ item
110
+ }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).focusBg, ({
111
+ variant,
112
+ item
113
+ }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).focusBg, _sx.default);
134
114
 
135
115
  const TextContainer = _styledComponents.default.span.withConfig({
136
116
  displayName: "Item__TextContainer",
@@ -229,9 +209,6 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
229
209
  onAction === null || onAction === void 0 ? void 0 : onAction(itemProps, event);
230
210
  }
231
211
  }, [onAction, disabled, itemProps, onClick]);
232
- const customItemTheme = customItemThemes[variant];
233
- const hoverBackground = (0, _ThemeProvider.useColorSchemeVar)(customItemTheme.hover, 'inherit');
234
- const focusBackground = (0, _ThemeProvider.useColorSchemeVar)(customItemTheme.focus, 'inherit');
235
212
  const {
236
213
  theme
237
214
  } = (0, _ThemeProvider.useTheme)();
@@ -247,9 +224,7 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
247
224
  }, props, {
248
225
  "data-id": id,
249
226
  onKeyPress: keyPressHandler,
250
- onClick: clickHandler,
251
- hoverBackground: disabled ? 'inherit' : hoverBackground,
252
- focusBackground: disabled ? 'inherit' : focusBackground
227
+ onClick: clickHandler
253
228
  }), !!selected === selected && /*#__PURE__*/_react.default.createElement(BaseVisualContainer, null, selectionVariant === 'multiple' ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(MultiSelectIcon, {
254
229
  selected: selected,
255
230
  width: "16",
@@ -34,35 +34,6 @@ const Divider_1 = require("./Divider");
34
34
  const ThemeProvider_1 = require("../ThemeProvider");
35
35
  const focusZone_1 = require("../behaviors/focusZone");
36
36
  const ssr_1 = require("@react-aria/ssr");
37
- /**
38
- * These colors are not yet in our default theme. Need to remove this once they are added.
39
- */
40
- const customItemThemes = {
41
- default: {
42
- hover: {
43
- light: 'rgba(46, 77, 108, 0.06)',
44
- dark: 'rgba(201, 206, 212, 0.12)',
45
- dark_dimmed: 'rgba(201, 206, 212, 0.12)'
46
- },
47
- focus: {
48
- light: 'rgba(54, 77, 100, 0.16)',
49
- dark: 'rgba(201, 206, 212, 0.24)',
50
- dark_dimmed: 'rgba(201, 206, 212, 0.24)'
51
- }
52
- },
53
- danger: {
54
- hover: {
55
- light: 'rgba(234, 74, 90, 0.08)',
56
- dark: 'rgba(248, 81, 73, 0.16)',
57
- dark_dimmed: 'rgba(248, 81, 73, 0.16)'
58
- },
59
- focus: {
60
- light: 'rgba(234, 74, 90, 0.14)',
61
- dark: 'rgba(248, 81, 73, 0.24)',
62
- dark_dimmed: 'rgba(248, 81, 73, 0.24)'
63
- }
64
- }
65
- };
66
37
  const getItemVariant = (variant = 'default', disabled) => {
67
38
  if (disabled) {
68
39
  return {
@@ -78,14 +49,19 @@ const getItemVariant = (variant = 'default', disabled) => {
78
49
  color: constants_1.get('colors.danger.fg'),
79
50
  iconColor: constants_1.get('colors.danger.fg'),
80
51
  annotationColor: constants_1.get('colors.fg.muted'),
81
- hoverCursor: 'pointer'
52
+ hoverCursor: 'pointer',
53
+ hoverBg: constants_1.get('colors.actionListItem.danger.hoverBg'),
54
+ focusBg: constants_1.get('colors.actionListItem.danger.activeBg'),
55
+ hoverText: constants_1.get('colors.actionListItem.danger.hoverText')
82
56
  };
83
57
  default:
84
58
  return {
85
59
  color: constants_1.get('colors.fg.default'),
86
60
  iconColor: constants_1.get('colors.fg.muted'),
87
61
  annotationColor: constants_1.get('colors.fg.muted'),
88
- hoverCursor: 'pointer'
62
+ hoverCursor: 'pointer',
63
+ hoverBg: constants_1.get('colors.actionListItem.default.hoverBg'),
64
+ focusBg: constants_1.get('colors.actionListItem.default.activeBg')
89
65
  };
90
66
  }
91
67
  };
@@ -121,7 +97,11 @@ const StyledItem = styled_components_1.default.div `
121
97
  @media (hover: hover) and (pointer: fine) {
122
98
  :hover {
123
99
  // allow override in case another item in the list is active/focused
124
- background: var(--item-hover-bg-override, ${({ hoverBackground }) => hoverBackground});
100
+ background: var(
101
+ --item-hover-bg-override,
102
+ ${({ variant, item }) => getItemVariant(variant, item?.disabled).hoverBg}
103
+ );
104
+ color: ${({ variant, item }) => getItemVariant(variant, item?.disabled).hoverText};
125
105
  cursor: ${({ variant, item }) => getItemVariant(variant, item?.disabled).hoverCursor};
126
106
  }
127
107
  }
@@ -167,19 +147,19 @@ const StyledItem = styled_components_1.default.div `
167
147
 
168
148
  // Active Descendant
169
149
  &[${focusZone_1.isActiveDescendantAttribute}='${focusZone_1.activeDescendantActivatedDirectly}'] {
170
- background: ${({ focusBackground }) => focusBackground};
150
+ background: ${({ variant, item }) => getItemVariant(variant, item?.disabled).focusBg};
171
151
  }
172
152
  &[${focusZone_1.isActiveDescendantAttribute}='${focusZone_1.activeDescendantActivatedIndirectly}'] {
173
- background: ${({ hoverBackground }) => hoverBackground};
153
+ background: ${({ variant, item }) => getItemVariant(variant, item?.disabled).hoverBg};
174
154
  }
175
155
 
176
156
  &:focus {
177
- background: ${({ focusBackground }) => focusBackground};
157
+ background: ${({ variant, item }) => getItemVariant(variant, item?.disabled).focusBg};
178
158
  outline: none;
179
159
  }
180
160
 
181
161
  &:active {
182
- background: ${({ focusBackground }) => focusBackground};
162
+ background: ${({ variant, item }) => getItemVariant(variant, item?.disabled).focusBg};
183
163
  }
184
164
 
185
165
  ${sx_1.default}
@@ -264,11 +244,8 @@ exports.Item = react_1.default.forwardRef((itemProps, ref) => {
264
244
  onAction?.(itemProps, event);
265
245
  }
266
246
  }, [onAction, disabled, itemProps, onClick]);
267
- const customItemTheme = customItemThemes[variant];
268
- const hoverBackground = ThemeProvider_1.useColorSchemeVar(customItemTheme.hover, 'inherit');
269
- const focusBackground = ThemeProvider_1.useColorSchemeVar(customItemTheme.focus, 'inherit');
270
247
  const { theme } = ThemeProvider_1.useTheme();
271
- return (<StyledItem ref={ref} as={Component} tabIndex={disabled ? undefined : -1} variant={variant} showDivider={showDivider} aria-selected={selected} aria-labelledby={text ? labelId : undefined} aria-describedby={description ? descriptionId : undefined} {...props} data-id={id} onKeyPress={keyPressHandler} onClick={clickHandler} hoverBackground={disabled ? 'inherit' : hoverBackground} focusBackground={disabled ? 'inherit' : focusBackground}>
248
+ return (<StyledItem ref={ref} as={Component} tabIndex={disabled ? undefined : -1} variant={variant} showDivider={showDivider} aria-selected={selected} aria-labelledby={text ? labelId : undefined} aria-describedby={description ? descriptionId : undefined} {...props} data-id={id} onKeyPress={keyPressHandler} onClick={clickHandler}>
272
249
  {!!selected === selected && (<BaseVisualContainer>
273
250
  {selectionVariant === 'multiple' ? (<>
274
251
  {/**
@@ -23,7 +23,6 @@ const Description = ({
23
23
  ...props
24
24
  }) => {
25
25
  const styles = {
26
- color: 'fg.muted',
27
26
  fontSize: 0,
28
27
  lineHeight: '16px',
29
28
  flexGrow: 1,
@@ -35,14 +34,19 @@ const Description = ({
35
34
  name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
36
35
  }, ({
37
36
  blockDescriptionId,
38
- inlineDescriptionId
37
+ inlineDescriptionId,
38
+ disabled
39
39
  }) => variant === 'block' ? /*#__PURE__*/_react.default.createElement(_Box.default, {
40
40
  as: "span",
41
- sx: (0, _sx.merge)(styles, sx),
41
+ sx: (0, _sx.merge)({ ...styles,
42
+ color: disabled ? 'fg.disabled' : 'fg.muted'
43
+ }, sx),
42
44
  id: blockDescriptionId
43
45
  }, props.children) : /*#__PURE__*/_react.default.createElement(_Truncate.default, {
44
46
  id: inlineDescriptionId,
45
- sx: (0, _sx.merge)(styles, sx),
47
+ sx: (0, _sx.merge)({ ...styles,
48
+ color: disabled ? 'fg.disabled' : 'fg.muted'
49
+ }, sx),
46
50
  title: props.children,
47
51
  inline: true,
48
52
  maxWidth: "100%"
@@ -11,7 +11,6 @@ const Truncate_1 = __importDefault(require("../Truncate"));
11
11
  const Item_1 = require("./Item");
12
12
  const Description = ({ variant = 'inline', sx = {}, ...props }) => {
13
13
  const styles = {
14
- color: 'fg.muted',
15
14
  fontSize: 0,
16
15
  lineHeight: '16px',
17
16
  flexGrow: 1,
@@ -20,9 +19,9 @@ const Description = ({ variant = 'inline', sx = {}, ...props }) => {
20
19
  marginLeft: variant === 'block' ? 0 : 2
21
20
  };
22
21
  return (<Item_1.Slot name={variant === 'block' ? 'BlockDescription' : 'InlineDescription'}>
23
- {({ blockDescriptionId, inlineDescriptionId }) => variant === 'block' ? (<Box_1.default as="span" sx={sx_1.merge(styles, sx)} id={blockDescriptionId}>
22
+ {({ blockDescriptionId, inlineDescriptionId, disabled }) => variant === 'block' ? (<Box_1.default as="span" sx={sx_1.merge({ ...styles, color: disabled ? 'fg.disabled' : 'fg.muted' }, sx)} id={blockDescriptionId}>
24
23
  {props.children}
25
- </Box_1.default>) : (<Truncate_1.default id={inlineDescriptionId} sx={sx_1.merge(styles, sx)} title={props.children} inline={true} maxWidth="100%">
24
+ </Box_1.default>) : (<Truncate_1.default id={inlineDescriptionId} sx={sx_1.merge({ ...styles, color: disabled ? 'fg.disabled' : 'fg.muted' }, sx)} title={props.children} inline={true} maxWidth="100%">
26
25
  {props.children}
27
26
  </Truncate_1.default>)}
28
27
  </Item_1.Slot>);
@@ -1,11 +1,37 @@
1
1
  import React from 'react';
2
2
  import { SxProp } from '../sx';
3
- import { HeaderProps } from './Header';
4
3
  import { ListProps } from './List';
5
- export declare type GroupProps = HeaderProps & SxProp & {
4
+ import { AriaRole } from '../utils/types';
5
+ export declare type GroupProps = {
6
+ /**
7
+ * Style variations. Usage is discretionary.
8
+ *
9
+ * - `"filled"` - Superimposed on a background, offset from nearby content
10
+ * - `"subtle"` - Relatively less offset from nearby content
11
+ */
12
+ variant?: 'subtle' | 'filled';
13
+ /**
14
+ * Primary text which names a `Group`.
15
+ */
16
+ title?: string;
17
+ /**
18
+ * Secondary text which provides additional information about a `Group`.
19
+ */
20
+ auxiliaryText?: string;
21
+ /**
22
+ * The ARIA role describing the function of the list inside `Group` component. `listbox` or `menu` are a common values.
23
+ */
24
+ role?: AriaRole;
25
+ } & SxProp & {
26
+ /**
27
+ * Whether multiple Items or a single Item can be selected in the Group. Overrides value on ActionList root.
28
+ */
6
29
  selectionVariant?: ListProps['selectionVariant'] | false;
7
30
  };
8
31
  declare type ContextProps = Pick<GroupProps, 'selectionVariant'>;
9
32
  export declare const GroupContext: React.Context<ContextProps>;
10
33
  export declare const Group: React.FC<GroupProps>;
34
+ export declare type HeaderProps = Pick<GroupProps, 'variant' | 'title' | 'auxiliaryText'> & {
35
+ labelId: string;
36
+ };
11
37
  export {};
@@ -7,9 +7,11 @@ exports.Group = exports.GroupContext = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
+ var _ssr = require("@react-aria/ssr");
11
+
10
12
  var _Box = _interopRequireDefault(require("../Box"));
11
13
 
12
- var _Header = require("./Header");
14
+ var _List = require("./List");
13
15
 
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
 
@@ -21,12 +23,14 @@ exports.GroupContext = GroupContext;
21
23
 
22
24
  const Group = ({
23
25
  title,
24
- variant,
26
+ variant = 'subtle',
25
27
  auxiliaryText,
26
28
  selectionVariant,
29
+ role,
27
30
  sx = {},
28
31
  ...props
29
32
  }) => {
33
+ const labelId = (0, _ssr.useSSRSafeId)();
30
34
  return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
31
35
  as: "li",
32
36
  sx: {
@@ -37,10 +41,11 @@ const Group = ({
37
41
  // hide the ::marker inserted by browser's stylesheet
38
42
  ...sx
39
43
  }
40
- }, props), title && /*#__PURE__*/_react.default.createElement(_Header.Header, {
44
+ }, props), title && /*#__PURE__*/_react.default.createElement(Header, {
41
45
  title: title,
42
46
  variant: variant,
43
- auxiliaryText: auxiliaryText
47
+ auxiliaryText: auxiliaryText,
48
+ labelId: labelId
44
49
  }), /*#__PURE__*/_react.default.createElement(GroupContext.Provider, {
45
50
  value: {
46
51
  selectionVariant
@@ -49,9 +54,53 @@ const Group = ({
49
54
  as: "ul",
50
55
  sx: {
51
56
  paddingInlineStart: 0
52
- }
57
+ },
58
+ "aria-labelledby": title ? labelId : undefined,
59
+ role: role
53
60
  }, props.children)));
54
61
  };
55
62
 
56
63
  exports.Group = Group;
57
- Group.displayName = "Group";
64
+ Group.displayName = "Group";
65
+
66
+ /**
67
+ * Displays the name and description of a `Group`.
68
+ *
69
+ * For visual presentation only. It's hidden from screen readers.
70
+ */
71
+ const Header = ({
72
+ variant,
73
+ title,
74
+ auxiliaryText,
75
+ labelId,
76
+ ...props
77
+ }) => {
78
+ const {
79
+ variant: listVariant
80
+ } = _react.default.useContext(_List.ListContext);
81
+
82
+ const styles = {
83
+ paddingY: '6px',
84
+ paddingX: listVariant === 'full' ? 2 : 3,
85
+ fontSize: 0,
86
+ fontWeight: 'bold',
87
+ color: 'fg.muted',
88
+ ...(variant === 'filled' && {
89
+ backgroundColor: 'canvas.subtle',
90
+ marginX: 0,
91
+ marginBottom: 2,
92
+ borderTop: '1px solid',
93
+ borderBottom: '1px solid',
94
+ borderColor: 'neutral.muted'
95
+ })
96
+ };
97
+ return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
98
+ sx: styles,
99
+ role: "presentation",
100
+ "aria-hidden": "true"
101
+ }, props), /*#__PURE__*/_react.default.createElement("span", {
102
+ id: labelId
103
+ }, title), auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, auxiliaryText));
104
+ };
105
+
106
+ Header.displayName = "Header";
@@ -5,21 +5,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Group = exports.GroupContext = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
+ const ssr_1 = require("@react-aria/ssr");
8
9
  const Box_1 = __importDefault(require("../Box"));
9
- const Header_1 = require("./Header");
10
+ const List_1 = require("./List");
10
11
  exports.GroupContext = react_1.default.createContext({});
11
- const Group = ({ title, variant, auxiliaryText, selectionVariant, sx = {}, ...props }) => {
12
+ const Group = ({ title, variant = 'subtle', auxiliaryText, selectionVariant, role, sx = {}, ...props }) => {
13
+ const labelId = ssr_1.useSSRSafeId();
12
14
  return (<Box_1.default as="li" sx={{
13
15
  '&:not(:first-child)': { marginTop: 2 },
14
16
  listStyle: 'none',
15
17
  ...sx
16
18
  }} {...props}>
17
- {title && <Header_1.Header title={title} variant={variant} auxiliaryText={auxiliaryText}/>}
19
+ {title && <Header title={title} variant={variant} auxiliaryText={auxiliaryText} labelId={labelId}/>}
18
20
  <exports.GroupContext.Provider value={{ selectionVariant }}>
19
- <Box_1.default as="ul" sx={{ paddingInlineStart: 0 }}>
21
+ <Box_1.default as="ul" sx={{ paddingInlineStart: 0 }} aria-labelledby={title ? labelId : undefined} role={role}>
20
22
  {props.children}
21
23
  </Box_1.default>
22
24
  </exports.GroupContext.Provider>
23
25
  </Box_1.default>);
24
26
  };
25
27
  exports.Group = Group;
28
+ /**
29
+ * Displays the name and description of a `Group`.
30
+ *
31
+ * For visual presentation only. It's hidden from screen readers.
32
+ */
33
+ const Header = ({ variant, title, auxiliaryText, labelId, ...props }) => {
34
+ const { variant: listVariant } = react_1.default.useContext(List_1.ListContext);
35
+ const styles = {
36
+ paddingY: '6px',
37
+ paddingX: listVariant === 'full' ? 2 : 3,
38
+ fontSize: 0,
39
+ fontWeight: 'bold',
40
+ color: 'fg.muted',
41
+ ...(variant === 'filled' && {
42
+ backgroundColor: 'canvas.subtle',
43
+ marginX: 0,
44
+ marginBottom: 2,
45
+ borderTop: '1px solid',
46
+ borderBottom: '1px solid',
47
+ borderColor: 'neutral.muted'
48
+ })
49
+ };
50
+ return (<Box_1.default sx={styles} role="presentation" aria-hidden="true" {...props}>
51
+ <span id={labelId}>{title}</span>
52
+ {auxiliaryText && <span>{auxiliaryText}</span>}
53
+ </Box_1.default>);
54
+ };
@@ -34,9 +34,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
34
34
  const getVariantStyles = (variant, disabled) => {
35
35
  if (disabled) {
36
36
  return {
37
- color: 'fg.muted',
38
- iconColor: 'fg.muted',
39
- annotationColor: 'fg.muted'
37
+ color: 'primer.fg.disabled',
38
+ iconColor: 'primer.fg.disabled',
39
+ annotationColor: 'primer.fg.disabled'
40
40
  };
41
41
  }
42
42
 
@@ -105,10 +105,9 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
105
105
  borderRadius: listVariant === 'inset' ? 2 : 0,
106
106
  transition: 'background 33.333ms linear',
107
107
  color: getVariantStyles(variant, disabled).color,
108
- textDecoration: 'none',
109
- // for as="a"
110
- ':not([aria-disabled])': {
111
- cursor: 'pointer'
108
+ cursor: 'pointer',
109
+ '&[aria-disabled]': {
110
+ cursor: 'not-allowed'
112
111
  },
113
112
  '@media (hover: hover) and (pointer: fine)': {
114
113
  ':hover:not([aria-disabled])': {