@primer/components 0.0.0-20211081215 → 0.0.0-2021108143910
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 +1 -1
- package/lib/ActionList2/Group.d.ts +23 -2
- package/lib/ActionList2/Group.js +53 -6
- package/lib-esm/ActionList2/Group.d.ts +23 -2
- package/lib-esm/ActionList2/Group.js +50 -5
- package/package.json +1 -1
- package/lib/ActionList2/Header.d.ts +0 -26
- package/lib/ActionList2/Header.js +0 -55
- package/lib-esm/ActionList2/Header.d.ts +0 -26
- package/lib-esm/ActionList2/Header.js +0 -44
package/CHANGELOG.md
CHANGED
@@ -1,11 +1,32 @@
|
|
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 =
|
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
|
+
*/
|
6
24
|
selectionVariant?: ListProps['selectionVariant'] | false;
|
7
25
|
};
|
8
26
|
declare type ContextProps = Pick<GroupProps, 'selectionVariant'>;
|
9
27
|
export declare const GroupContext: React.Context<ContextProps>;
|
10
28
|
export declare const Group: React.FC<GroupProps>;
|
29
|
+
export declare type HeaderProps = Pick<GroupProps, 'variant' | 'title' | 'auxiliaryText'> & {
|
30
|
+
labelId: string;
|
31
|
+
};
|
11
32
|
export {};
|
package/lib/ActionList2/Group.js
CHANGED
@@ -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
|
14
|
+
var _List = require("./List");
|
13
15
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
17
|
|
@@ -21,12 +23,13 @@ exports.GroupContext = GroupContext;
|
|
21
23
|
|
22
24
|
const Group = ({
|
23
25
|
title,
|
24
|
-
variant,
|
26
|
+
variant = 'subtle',
|
25
27
|
auxiliaryText,
|
26
28
|
selectionVariant,
|
27
29
|
sx = {},
|
28
30
|
...props
|
29
31
|
}) => {
|
32
|
+
const labelId = (0, _ssr.useSSRSafeId)();
|
30
33
|
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
31
34
|
as: "li",
|
32
35
|
sx: {
|
@@ -37,10 +40,11 @@ const Group = ({
|
|
37
40
|
// hide the ::marker inserted by browser's stylesheet
|
38
41
|
...sx
|
39
42
|
}
|
40
|
-
}, props), title && /*#__PURE__*/_react.default.createElement(
|
43
|
+
}, props), title && /*#__PURE__*/_react.default.createElement(Header, {
|
41
44
|
title: title,
|
42
45
|
variant: variant,
|
43
|
-
auxiliaryText: auxiliaryText
|
46
|
+
auxiliaryText: auxiliaryText,
|
47
|
+
labelId: labelId
|
44
48
|
}), /*#__PURE__*/_react.default.createElement(GroupContext.Provider, {
|
45
49
|
value: {
|
46
50
|
selectionVariant
|
@@ -49,9 +53,52 @@ const Group = ({
|
|
49
53
|
as: "ul",
|
50
54
|
sx: {
|
51
55
|
paddingInlineStart: 0
|
52
|
-
}
|
56
|
+
},
|
57
|
+
"aria-labelledby": title ? labelId : undefined
|
53
58
|
}, props.children)));
|
54
59
|
};
|
55
60
|
|
56
61
|
exports.Group = Group;
|
57
|
-
Group.displayName = "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
|
+
role: "presentation",
|
98
|
+
"aria-hidden": "true"
|
99
|
+
}, props), /*#__PURE__*/_react.default.createElement("span", {
|
100
|
+
id: labelId
|
101
|
+
}, title), auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, auxiliaryText));
|
102
|
+
};
|
103
|
+
|
104
|
+
Header.displayName = "Header";
|
@@ -1,11 +1,32 @@
|
|
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 =
|
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
|
+
*/
|
6
24
|
selectionVariant?: ListProps['selectionVariant'] | false;
|
7
25
|
};
|
8
26
|
declare type ContextProps = Pick<GroupProps, 'selectionVariant'>;
|
9
27
|
export declare const GroupContext: React.Context<ContextProps>;
|
10
28
|
export declare const Group: React.FC<GroupProps>;
|
29
|
+
export declare type HeaderProps = Pick<GroupProps, 'variant' | 'title' | 'auxiliaryText'> & {
|
30
|
+
labelId: string;
|
31
|
+
};
|
11
32
|
export {};
|
@@ -1,17 +1,19 @@
|
|
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';
|
4
5
|
import Box from '../Box';
|
5
|
-
import {
|
6
|
+
import { ListContext } from './List';
|
6
7
|
export const GroupContext = /*#__PURE__*/React.createContext({});
|
7
8
|
export const Group = ({
|
8
9
|
title,
|
9
|
-
variant,
|
10
|
+
variant = 'subtle',
|
10
11
|
auxiliaryText,
|
11
12
|
selectionVariant,
|
12
13
|
sx = {},
|
13
14
|
...props
|
14
15
|
}) => {
|
16
|
+
const labelId = useSSRSafeId();
|
15
17
|
return /*#__PURE__*/React.createElement(Box, _extends({
|
16
18
|
as: "li",
|
17
19
|
sx: {
|
@@ -25,7 +27,8 @@ export const Group = ({
|
|
25
27
|
}, props), title && /*#__PURE__*/React.createElement(Header, {
|
26
28
|
title: title,
|
27
29
|
variant: variant,
|
28
|
-
auxiliaryText: auxiliaryText
|
30
|
+
auxiliaryText: auxiliaryText,
|
31
|
+
labelId: labelId
|
29
32
|
}), /*#__PURE__*/React.createElement(GroupContext.Provider, {
|
30
33
|
value: {
|
31
34
|
selectionVariant
|
@@ -34,7 +37,49 @@ export const Group = ({
|
|
34
37
|
as: "ul",
|
35
38
|
sx: {
|
36
39
|
paddingInlineStart: 0
|
37
|
-
}
|
40
|
+
},
|
41
|
+
"aria-labelledby": title ? labelId : undefined
|
38
42
|
}, props.children)));
|
39
43
|
};
|
40
|
-
Group.displayName = "Group";
|
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
|
+
role: "presentation",
|
79
|
+
"aria-hidden": "true"
|
80
|
+
}, props), /*#__PURE__*/React.createElement("span", {
|
81
|
+
id: labelId
|
82
|
+
}, title), auxiliaryText && /*#__PURE__*/React.createElement("span", null, auxiliaryText));
|
83
|
+
};
|
84
|
+
|
85
|
+
Header.displayName = "Header";
|
package/package.json
CHANGED
@@ -1,26 +0,0 @@
|
|
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;
|
@@ -1,55 +0,0 @@
|
|
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";
|
@@ -1,26 +0,0 @@
|
|
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;
|
@@ -1,44 +0,0 @@
|
|
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";
|