@primer/components 0.0.0-2021108143759 → 0.0.0-2021108175016

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @primer/components
2
2
 
3
- ## 0.0.0-2021108143759
3
+ ## 0.0.0-2021108175016
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -1,32 +1,11 @@
1
1
  import React from 'react';
2
2
  import { SxProp } from '../sx';
3
+ import { HeaderProps } from './Header';
3
4
  import { ListProps } from './List';
4
- export declare type GroupProps = {
5
- /**
6
- * Style variations. Usage is discretionary.
7
- *
8
- * - `"filled"` - Superimposed on a background, offset from nearby content
9
- * - `"subtle"` - Relatively less offset from nearby content
10
- */
11
- variant?: 'subtle' | 'filled';
12
- /**
13
- * Primary text which names a `Group`.
14
- */
15
- title?: string;
16
- /**
17
- * Secondary text which provides additional information about a `Group`.
18
- */
19
- auxiliaryText?: string;
20
- } & SxProp & {
21
- /**
22
- * Whether multiple Items or a single Item can be selected in the Group. Overrides value on ActionList root.
23
- */
5
+ export declare type GroupProps = HeaderProps & SxProp & {
24
6
  selectionVariant?: ListProps['selectionVariant'] | false;
25
7
  };
26
8
  declare type ContextProps = Pick<GroupProps, 'selectionVariant'>;
27
9
  export declare const GroupContext: React.Context<ContextProps>;
28
10
  export declare const Group: React.FC<GroupProps>;
29
- export declare type HeaderProps = Pick<GroupProps, 'variant' | 'title' | 'auxiliaryText'> & {
30
- labelId: string;
31
- };
32
11
  export {};
@@ -7,11 +7,9 @@ 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
-
12
10
  var _Box = _interopRequireDefault(require("../Box"));
13
11
 
14
- var _List = require("./List");
12
+ var _Header = require("./Header");
15
13
 
16
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
15
 
@@ -23,13 +21,12 @@ exports.GroupContext = GroupContext;
23
21
 
24
22
  const Group = ({
25
23
  title,
26
- variant = 'subtle',
24
+ variant,
27
25
  auxiliaryText,
28
26
  selectionVariant,
29
27
  sx = {},
30
28
  ...props
31
29
  }) => {
32
- const labelId = (0, _ssr.useSSRSafeId)();
33
30
  return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
34
31
  as: "li",
35
32
  sx: {
@@ -40,11 +37,10 @@ const Group = ({
40
37
  // hide the ::marker inserted by browser's stylesheet
41
38
  ...sx
42
39
  }
43
- }, props), title && /*#__PURE__*/_react.default.createElement(Header, {
40
+ }, props), title && /*#__PURE__*/_react.default.createElement(_Header.Header, {
44
41
  title: title,
45
42
  variant: variant,
46
- auxiliaryText: auxiliaryText,
47
- labelId: labelId
43
+ auxiliaryText: auxiliaryText
48
44
  }), /*#__PURE__*/_react.default.createElement(GroupContext.Provider, {
49
45
  value: {
50
46
  selectionVariant
@@ -53,51 +49,9 @@ const Group = ({
53
49
  as: "ul",
54
50
  sx: {
55
51
  paddingInlineStart: 0
56
- },
57
- "aria-labelledby": title ? labelId : undefined
52
+ }
58
53
  }, props.children)));
59
54
  };
60
55
 
61
56
  exports.Group = Group;
62
- Group.displayName = "Group";
63
-
64
- /**
65
- * Displays the name and description of a `Group`.
66
- *
67
- * For visual presentation only. It's hidden from screen readers.
68
- */
69
- const Header = ({
70
- variant,
71
- title,
72
- auxiliaryText,
73
- labelId,
74
- ...props
75
- }) => {
76
- const {
77
- variant: listVariant
78
- } = _react.default.useContext(_List.ListContext);
79
-
80
- const styles = {
81
- paddingY: '6px',
82
- paddingX: listVariant === 'full' ? 2 : 3,
83
- fontSize: 0,
84
- fontWeight: 'bold',
85
- color: 'fg.muted',
86
- ...(variant === 'filled' && {
87
- backgroundColor: 'canvas.subtle',
88
- marginX: 0,
89
- marginBottom: 2,
90
- borderTop: '1px solid',
91
- borderBottom: '1px solid',
92
- borderColor: 'neutral.muted'
93
- })
94
- };
95
- return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
96
- sx: styles,
97
- "aria-hidden": "true"
98
- }, props), /*#__PURE__*/_react.default.createElement("span", {
99
- id: labelId
100
- }, title), auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, auxiliaryText));
101
- };
102
-
103
- Header.displayName = "Header";
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;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Header = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Box = _interopRequireDefault(require("../Box"));
11
+
12
+ var _List = require("./List");
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
+ /**
19
+ * Displays the name and description of a `Group`.
20
+ */
21
+ const Header = ({
22
+ variant = 'subtle',
23
+ title,
24
+ auxiliaryText,
25
+ sx = {},
26
+ ...props
27
+ }) => {
28
+ const {
29
+ variant: listVariant
30
+ } = _react.default.useContext(_List.ListContext);
31
+
32
+ const styles = {
33
+ paddingY: '6px',
34
+ paddingX: listVariant === 'full' ? 2 : 3,
35
+ fontSize: 0,
36
+ fontWeight: 'bold',
37
+ color: 'fg.muted',
38
+ ...(variant === 'filled' && {
39
+ backgroundColor: 'canvas.subtle',
40
+ marginX: 0,
41
+ marginBottom: 2,
42
+ borderTop: '1px solid',
43
+ borderBottom: '1px solid',
44
+ borderColor: 'neutral.muted'
45
+ }),
46
+ ...sx
47
+ };
48
+ return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
49
+ sx: styles,
50
+ role: "heading"
51
+ }, props), title, auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, auxiliaryText));
52
+ };
53
+
54
+ exports.Header = Header;
55
+ Header.displayName = "Header";
@@ -7,19 +7,11 @@ export declare const getVariantStyles: (variant: ItemProps['variant'], disabled:
7
7
  iconColor: string;
8
8
  annotationColor: string;
9
9
  hoverColor?: undefined;
10
- selectedBg?: undefined;
11
10
  } | {
12
11
  color: string;
13
12
  iconColor: string;
14
13
  annotationColor: string;
15
14
  hoverColor: string;
16
- selectedBg?: undefined;
17
- } | {
18
- color: string;
19
- iconColor: string;
20
- annotationColor: string;
21
- hoverColor: string;
22
- selectedBg: string;
23
15
  };
24
16
  export declare type ItemProps = {
25
17
  /**
@@ -54,8 +54,7 @@ const getVariantStyles = (variant, disabled) => {
54
54
  color: 'fg.default',
55
55
  iconColor: 'fg.muted',
56
56
  annotationColor: 'fg.muted',
57
- hoverColor: 'fg.default',
58
- selectedBg: 'actionListItem.default.selectedBg'
57
+ hoverColor: 'fg.default'
59
58
  };
60
59
  }
61
60
  };
@@ -110,9 +109,6 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
110
109
  color: getVariantStyles(variant, disabled).color,
111
110
  textDecoration: 'none',
112
111
  // for as="a"
113
- '&[aria-selected=true]': {
114
- backgroundColor: getVariantStyles(variant, disabled).selectedBg
115
- },
116
112
  ':not([aria-disabled])': {
117
113
  cursor: 'pointer'
118
114
  },
@@ -122,9 +118,13 @@ const Item = /*#__PURE__*/_react.default.forwardRef(({
122
118
  color: getVariantStyles(variant, disabled).hoverColor
123
119
  },
124
120
  ':focus:not([aria-disabled])': {
125
- backgroundColor: `actionListItem.${variant}.activeBg`,
121
+ backgroundColor: `actionListItem.${variant}.selectedBg`,
126
122
  color: getVariantStyles(variant, disabled).hoverColor,
127
123
  outline: 'none'
124
+ },
125
+ ':active:not([aria-disabled])': {
126
+ backgroundColor: `actionListItem.${variant}.activeBg`,
127
+ color: getVariantStyles(variant, disabled).hoverColor
128
128
  }
129
129
  },
130
130
 
@@ -1,32 +1,11 @@
1
1
  import React from 'react';
2
2
  import { SxProp } from '../sx';
3
+ import { HeaderProps } from './Header';
3
4
  import { ListProps } from './List';
4
- export declare type GroupProps = {
5
- /**
6
- * Style variations. Usage is discretionary.
7
- *
8
- * - `"filled"` - Superimposed on a background, offset from nearby content
9
- * - `"subtle"` - Relatively less offset from nearby content
10
- */
11
- variant?: 'subtle' | 'filled';
12
- /**
13
- * Primary text which names a `Group`.
14
- */
15
- title?: string;
16
- /**
17
- * Secondary text which provides additional information about a `Group`.
18
- */
19
- auxiliaryText?: string;
20
- } & SxProp & {
21
- /**
22
- * Whether multiple Items or a single Item can be selected in the Group. Overrides value on ActionList root.
23
- */
5
+ export declare type GroupProps = HeaderProps & SxProp & {
24
6
  selectionVariant?: ListProps['selectionVariant'] | false;
25
7
  };
26
8
  declare type ContextProps = Pick<GroupProps, 'selectionVariant'>;
27
9
  export declare const GroupContext: React.Context<ContextProps>;
28
10
  export declare const Group: React.FC<GroupProps>;
29
- export declare type HeaderProps = Pick<GroupProps, 'variant' | 'title' | 'auxiliaryText'> & {
30
- labelId: string;
31
- };
32
11
  export {};
@@ -1,19 +1,17 @@
1
1
  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); }
2
2
 
3
3
  import React from 'react';
4
- import { useSSRSafeId } from '@react-aria/ssr';
5
4
  import Box from '../Box';
6
- import { ListContext } from './List';
5
+ import { Header } from './Header';
7
6
  export const GroupContext = /*#__PURE__*/React.createContext({});
8
7
  export const Group = ({
9
8
  title,
10
- variant = 'subtle',
9
+ variant,
11
10
  auxiliaryText,
12
11
  selectionVariant,
13
12
  sx = {},
14
13
  ...props
15
14
  }) => {
16
- const labelId = useSSRSafeId();
17
15
  return /*#__PURE__*/React.createElement(Box, _extends({
18
16
  as: "li",
19
17
  sx: {
@@ -27,8 +25,7 @@ export const Group = ({
27
25
  }, props), title && /*#__PURE__*/React.createElement(Header, {
28
26
  title: title,
29
27
  variant: variant,
30
- auxiliaryText: auxiliaryText,
31
- labelId: labelId
28
+ auxiliaryText: auxiliaryText
32
29
  }), /*#__PURE__*/React.createElement(GroupContext.Provider, {
33
30
  value: {
34
31
  selectionVariant
@@ -37,48 +34,7 @@ export const Group = ({
37
34
  as: "ul",
38
35
  sx: {
39
36
  paddingInlineStart: 0
40
- },
41
- "aria-labelledby": title ? labelId : undefined
37
+ }
42
38
  }, props.children)));
43
39
  };
44
- Group.displayName = "Group";
45
-
46
- /**
47
- * Displays the name and description of a `Group`.
48
- *
49
- * For visual presentation only. It's hidden from screen readers.
50
- */
51
- const Header = ({
52
- variant,
53
- title,
54
- auxiliaryText,
55
- labelId,
56
- ...props
57
- }) => {
58
- const {
59
- variant: listVariant
60
- } = React.useContext(ListContext);
61
- const styles = {
62
- paddingY: '6px',
63
- paddingX: listVariant === 'full' ? 2 : 3,
64
- fontSize: 0,
65
- fontWeight: 'bold',
66
- color: 'fg.muted',
67
- ...(variant === 'filled' && {
68
- backgroundColor: 'canvas.subtle',
69
- marginX: 0,
70
- marginBottom: 2,
71
- borderTop: '1px solid',
72
- borderBottom: '1px solid',
73
- borderColor: 'neutral.muted'
74
- })
75
- };
76
- return /*#__PURE__*/React.createElement(Box, _extends({
77
- sx: styles,
78
- "aria-hidden": "true"
79
- }, props), /*#__PURE__*/React.createElement("span", {
80
- id: labelId
81
- }, title), auxiliaryText && /*#__PURE__*/React.createElement("span", null, auxiliaryText));
82
- };
83
-
84
- Header.displayName = "Header";
40
+ 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;
@@ -0,0 +1,44 @@
1
+ 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); }
2
+
3
+ import React from 'react';
4
+ import Box from '../Box';
5
+ import { ListContext } from './List';
6
+ /**
7
+ * Contract for props passed to the `Header` component.
8
+ */
9
+
10
+ /**
11
+ * Displays the name and description of a `Group`.
12
+ */
13
+ export const Header = ({
14
+ variant = 'subtle',
15
+ title,
16
+ auxiliaryText,
17
+ sx = {},
18
+ ...props
19
+ }) => {
20
+ const {
21
+ variant: listVariant
22
+ } = React.useContext(ListContext);
23
+ const styles = {
24
+ paddingY: '6px',
25
+ paddingX: listVariant === 'full' ? 2 : 3,
26
+ fontSize: 0,
27
+ fontWeight: 'bold',
28
+ color: 'fg.muted',
29
+ ...(variant === 'filled' && {
30
+ backgroundColor: 'canvas.subtle',
31
+ marginX: 0,
32
+ marginBottom: 2,
33
+ borderTop: '1px solid',
34
+ borderBottom: '1px solid',
35
+ borderColor: 'neutral.muted'
36
+ }),
37
+ ...sx
38
+ };
39
+ return /*#__PURE__*/React.createElement(Box, _extends({
40
+ sx: styles,
41
+ role: "heading"
42
+ }, props), title, auxiliaryText && /*#__PURE__*/React.createElement("span", null, auxiliaryText));
43
+ };
44
+ Header.displayName = "Header";
@@ -7,19 +7,11 @@ export declare const getVariantStyles: (variant: ItemProps['variant'], disabled:
7
7
  iconColor: string;
8
8
  annotationColor: string;
9
9
  hoverColor?: undefined;
10
- selectedBg?: undefined;
11
10
  } | {
12
11
  color: string;
13
12
  iconColor: string;
14
13
  annotationColor: string;
15
14
  hoverColor: string;
16
- selectedBg?: undefined;
17
- } | {
18
- color: string;
19
- iconColor: string;
20
- annotationColor: string;
21
- hoverColor: string;
22
- selectedBg: string;
23
15
  };
24
16
  export declare type ItemProps = {
25
17
  /**
@@ -32,8 +32,7 @@ export const getVariantStyles = (variant, disabled) => {
32
32
  color: 'fg.default',
33
33
  iconColor: 'fg.muted',
34
34
  annotationColor: 'fg.muted',
35
- hoverColor: 'fg.default',
36
- selectedBg: 'actionListItem.default.selectedBg'
35
+ hoverColor: 'fg.default'
37
36
  };
38
37
  }
39
38
  };
@@ -81,9 +80,6 @@ export const Item = /*#__PURE__*/React.forwardRef(({
81
80
  color: getVariantStyles(variant, disabled).color,
82
81
  textDecoration: 'none',
83
82
  // for as="a"
84
- '&[aria-selected=true]': {
85
- backgroundColor: getVariantStyles(variant, disabled).selectedBg
86
- },
87
83
  ':not([aria-disabled])': {
88
84
  cursor: 'pointer'
89
85
  },
@@ -93,9 +89,13 @@ export const Item = /*#__PURE__*/React.forwardRef(({
93
89
  color: getVariantStyles(variant, disabled).hoverColor
94
90
  },
95
91
  ':focus:not([aria-disabled])': {
96
- backgroundColor: `actionListItem.${variant}.activeBg`,
92
+ backgroundColor: `actionListItem.${variant}.selectedBg`,
97
93
  color: getVariantStyles(variant, disabled).hoverColor,
98
94
  outline: 'none'
95
+ },
96
+ ':active:not([aria-disabled])': {
97
+ backgroundColor: `actionListItem.${variant}.activeBg`,
98
+ color: getVariantStyles(variant, disabled).hoverColor
99
99
  }
100
100
  },
101
101
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/components",
3
- "version": "0.0.0-2021108143759",
3
+ "version": "0.0.0-2021108175016",
4
4
  "description": "Primer react components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",