@primer/components 32.1.1-rc.b4502a34 → 33.0.0-rc.9f3670b7
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 +15 -1
- package/contributor-docs/CONTRIBUTING.md +14 -58
- package/dist/browser.esm.js +104 -108
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +104 -108
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/BranchName.md +6 -5
- package/docs/content/Details.md +4 -8
- package/docs/content/Heading.md +5 -10
- package/docs/content/Label.md +6 -7
- package/docs/content/ProgressBar.mdx +7 -6
- package/docs/content/Text.md +0 -6
- package/docs/content/{ActionList2.mdx → drafts/ActionList2.mdx} +5 -9
- package/docs/content/drafts/ActionMenu2.mdx +251 -0
- package/docs/content/status.mdx +1 -1
- package/docs/content/system-props.mdx +1 -1
- package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +9 -1
- package/docs/src/@primer/gatsby-theme-doctocat/nav.yml +1 -1
- package/lib/ActionList2/Divider.d.ts +3 -2
- package/lib/ActionList2/Divider.js +10 -5
- package/lib/ActionList2/Item.js +21 -5
- package/lib/ActionList2/List.js +11 -1
- package/lib/ActionList2/MenuContext.d.ts +10 -0
- package/lib/ActionList2/MenuContext.js +15 -0
- package/lib/ActionList2/Selection.js +11 -0
- package/lib/ActionList2/index.d.ts +1 -2
- package/lib/ActionMenu2.d.ts +310 -0
- package/lib/ActionMenu2.js +91 -0
- package/lib/Avatar.d.ts +1 -2
- package/lib/Avatar.js +1 -1
- package/lib/BranchName.d.ts +1 -2
- package/lib/BranchName.js +1 -1
- package/lib/Details.d.ts +1 -2
- package/lib/Details.js +1 -3
- package/lib/Dropdown.d.ts +2 -66
- package/lib/Heading.d.ts +1 -2
- package/lib/Heading.js +1 -6
- package/lib/ProgressBar.d.ts +16 -11
- package/lib/ProgressBar.js +6 -10
- package/lib/Spinner.d.ts +1 -2
- package/lib/Spinner.js +1 -3
- package/lib/__tests__/Avatar.test.js +4 -2
- package/lib/__tests__/Avatar.types.test.d.ts +3 -0
- package/lib/__tests__/Avatar.types.test.js +31 -0
- package/lib/__tests__/BranchName.types.test.d.ts +3 -0
- package/lib/__tests__/BranchName.types.test.js +28 -0
- package/lib/__tests__/Details.types.test.d.ts +3 -0
- package/lib/__tests__/Details.types.test.js +28 -0
- package/lib/__tests__/Heading.test.js +63 -30
- package/lib/__tests__/Heading.types.test.d.ts +3 -0
- package/lib/__tests__/Heading.types.test.js +28 -0
- package/lib/drafts.d.ts +1 -0
- package/lib/drafts.js +13 -0
- package/lib/stories/ActionMenu2.stories.js +433 -0
- package/lib-esm/ActionList2/Divider.d.ts +3 -2
- package/lib-esm/ActionList2/Divider.js +8 -5
- package/lib-esm/ActionList2/Item.js +19 -5
- package/lib-esm/ActionList2/List.js +9 -1
- package/lib-esm/ActionList2/MenuContext.d.ts +10 -0
- package/lib-esm/ActionList2/MenuContext.js +3 -0
- package/lib-esm/ActionList2/Selection.js +9 -0
- package/lib-esm/ActionList2/index.d.ts +1 -2
- package/lib-esm/ActionMenu2.d.ts +310 -0
- package/lib-esm/ActionMenu2.js +67 -0
- package/lib-esm/Avatar.d.ts +1 -2
- package/lib-esm/Avatar.js +2 -2
- package/lib-esm/BranchName.d.ts +1 -2
- package/lib-esm/BranchName.js +2 -2
- package/lib-esm/Details.d.ts +1 -2
- package/lib-esm/Details.js +1 -2
- package/lib-esm/Dropdown.d.ts +2 -66
- package/lib-esm/Heading.d.ts +1 -2
- package/lib-esm/Heading.js +2 -6
- package/lib-esm/ProgressBar.d.ts +16 -11
- package/lib-esm/ProgressBar.js +7 -11
- package/lib-esm/Spinner.d.ts +1 -2
- package/lib-esm/Spinner.js +1 -2
- package/lib-esm/__tests__/Avatar.test.js +4 -2
- package/lib-esm/__tests__/Avatar.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Avatar.types.test.js +16 -0
- package/lib-esm/__tests__/BranchName.types.test.d.ts +3 -0
- package/lib-esm/__tests__/BranchName.types.test.js +13 -0
- package/lib-esm/__tests__/Details.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Details.types.test.js +13 -0
- package/lib-esm/__tests__/Heading.test.js +62 -30
- package/lib-esm/__tests__/Heading.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Heading.types.test.js +13 -0
- package/lib-esm/drafts.d.ts +1 -0
- package/lib-esm/drafts.js +2 -1
- package/lib-esm/stories/ActionMenu2.stories.js +376 -0
- package/package.json +1 -1
- package/src/ActionList2/Divider.tsx +13 -8
- package/src/ActionList2/Item.tsx +13 -3
- package/src/ActionList2/List.tsx +6 -2
- package/src/ActionList2/MenuContext.tsx +6 -0
- package/src/ActionList2/Selection.tsx +9 -0
- package/src/ActionMenu2.tsx +94 -0
- package/src/Avatar.tsx +2 -4
- package/src/BranchName.tsx +3 -3
- package/src/Details.tsx +1 -5
- package/src/Heading.tsx +2 -9
- package/src/ProgressBar.tsx +11 -10
- package/src/Spinner.tsx +1 -3
- package/src/__tests__/Avatar.test.tsx +1 -1
- package/src/__tests__/Avatar.types.test.tsx +11 -0
- package/src/__tests__/BranchName.types.test.tsx +11 -0
- package/src/__tests__/Details.types.test.tsx +11 -0
- package/src/__tests__/Heading.test.tsx +71 -25
- package/src/__tests__/Heading.types.test.tsx +11 -0
- package/src/drafts.ts +1 -0
- package/src/stories/ActionMenu2.stories.tsx +551 -0
- package/stats.html +1 -1
package/lib-esm/ProgressBar.d.ts
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { WidthProps } from 'styled-system';
|
3
|
-
import { SystemCommonProps } from './constants';
|
4
3
|
import { SxProp } from './sx';
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
|
14
|
-
|
4
|
+
declare type ProgressProp = {
|
5
|
+
progress?: string | number;
|
6
|
+
};
|
7
|
+
declare const sizeMap: {
|
8
|
+
small: string;
|
9
|
+
large: string;
|
10
|
+
default: string;
|
11
|
+
};
|
12
|
+
declare type StyledProgressContainerProps = {
|
13
|
+
inline?: boolean;
|
14
|
+
barSize?: keyof typeof sizeMap;
|
15
|
+
} & WidthProps & SxProp;
|
16
|
+
export declare type ProgressBarProps = {
|
17
|
+
bg: string;
|
18
|
+
} & StyledProgressContainerProps & ProgressProp;
|
19
|
+
declare function ProgressBar({ progress, bg, ...rest }: ProgressBarProps): JSX.Element;
|
15
20
|
declare namespace ProgressBar {
|
16
21
|
var defaultProps: {
|
17
22
|
bg: string;
|
package/lib-esm/ProgressBar.js
CHANGED
@@ -1,14 +1,12 @@
|
|
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
1
|
import React from 'react';
|
4
2
|
import styled from 'styled-components';
|
5
3
|
import { width } from 'styled-system';
|
6
|
-
import {
|
4
|
+
import { get } from './constants';
|
7
5
|
import sx from './sx';
|
8
6
|
const Bar = styled.span.withConfig({
|
9
7
|
displayName: "ProgressBar__Bar",
|
10
8
|
componentId: "sc-1tiva13-0"
|
11
|
-
})(["width:", ";", ""], props => props.progress ? `${props.progress}%` : 0,
|
9
|
+
})(["width:", ";", ";"], props => props.progress ? `${props.progress}%` : 0, sx);
|
12
10
|
const sizeMap = {
|
13
11
|
small: '5px',
|
14
12
|
large: '10px',
|
@@ -17,20 +15,18 @@ const sizeMap = {
|
|
17
15
|
const ProgressContainer = styled.span.withConfig({
|
18
16
|
displayName: "ProgressBar__ProgressContainer",
|
19
17
|
componentId: "sc-1tiva13-1"
|
20
|
-
})(["display:", ";overflow:hidden;background-color:", ";border-radius:", ";height:", ";", " ", "
|
18
|
+
})(["display:", ";overflow:hidden;background-color:", ";border-radius:", ";height:", ";", " ", ";"], props => props.inline ? 'inline-flex' : 'flex', get('colors.border.default'), get('radii.1'), props => sizeMap[props.barSize || 'default'], width, sx);
|
21
19
|
|
22
20
|
function ProgressBar({
|
23
21
|
progress,
|
24
22
|
bg,
|
25
|
-
theme,
|
26
23
|
...rest
|
27
24
|
}) {
|
28
|
-
return /*#__PURE__*/React.createElement(ProgressContainer,
|
29
|
-
theme: theme
|
30
|
-
}, rest), /*#__PURE__*/React.createElement(Bar, {
|
25
|
+
return /*#__PURE__*/React.createElement(ProgressContainer, rest, /*#__PURE__*/React.createElement(Bar, {
|
31
26
|
progress: progress,
|
32
|
-
|
33
|
-
|
27
|
+
sx: {
|
28
|
+
bg
|
29
|
+
}
|
34
30
|
}));
|
35
31
|
}
|
36
32
|
|
package/lib-esm/Spinner.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { SystemCommonProps } from './constants';
|
3
2
|
import { SxProp } from './sx';
|
4
3
|
import { ComponentProps } from './utils/types';
|
5
4
|
declare const sizeMap: {
|
@@ -12,6 +11,6 @@ export interface SpinnerInternalProps {
|
|
12
11
|
size?: keyof typeof sizeMap;
|
13
12
|
}
|
14
13
|
declare function Spinner({ size: sizeKey, ...props }: SpinnerInternalProps): JSX.Element;
|
15
|
-
declare const StyledSpinner: import("styled-components").StyledComponent<typeof Spinner, any,
|
14
|
+
declare const StyledSpinner: import("styled-components").StyledComponent<typeof Spinner, any, SxProp, never>;
|
16
15
|
export declare type SpinnerProps = ComponentProps<typeof StyledSpinner>;
|
17
16
|
export default StyledSpinner;
|
package/lib-esm/Spinner.js
CHANGED
@@ -2,7 +2,6 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
2
2
|
|
3
3
|
import React from 'react';
|
4
4
|
import styled from 'styled-components';
|
5
|
-
import { COMMON } from './constants';
|
6
5
|
import sx from './sx';
|
7
6
|
const sizeMap = {
|
8
7
|
small: '16px',
|
@@ -41,6 +40,6 @@ Spinner.displayName = "Spinner";
|
|
41
40
|
const StyledSpinner = styled(Spinner).withConfig({
|
42
41
|
displayName: "Spinner__StyledSpinner",
|
43
42
|
componentId: "sc-14tspit-0"
|
44
|
-
})(["@keyframes rotate-keyframes{100%{transform:rotate(360deg);}}animation:rotate-keyframes 1s linear infinite;", "
|
43
|
+
})(["@keyframes rotate-keyframes{100%{transform:rotate(360deg);}}animation:rotate-keyframes 1s linear infinite;", ""], sx);
|
45
44
|
StyledSpinner.displayName = 'Spinner';
|
46
45
|
export default StyledSpinner;
|
@@ -48,9 +48,11 @@ describe('Avatar', () => {
|
|
48
48
|
});
|
49
49
|
it('respects margin props', () => {
|
50
50
|
expect(render( /*#__PURE__*/React.createElement(Avatar, {
|
51
|
-
m: 2,
|
52
51
|
src: "primer.png",
|
53
|
-
alt: ""
|
52
|
+
alt: "",
|
53
|
+
sx: {
|
54
|
+
m: 2
|
55
|
+
}
|
54
56
|
}))).toHaveStyleRule('margin', px(theme.space[2]));
|
55
57
|
});
|
56
58
|
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import Avatar from '../Avatar';
|
3
|
+
export function shouldAcceptCallWithNoProps() {
|
4
|
+
return /*#__PURE__*/React.createElement(Avatar, {
|
5
|
+
src: "https://avatars.githubusercontent.com/primer"
|
6
|
+
});
|
7
|
+
}
|
8
|
+
shouldAcceptCallWithNoProps.displayName = "shouldAcceptCallWithNoProps";
|
9
|
+
export function shouldNotAcceptSystemProps() {
|
10
|
+
// @ts-expect-error system props should not be accepted
|
11
|
+
return /*#__PURE__*/React.createElement(Avatar, {
|
12
|
+
src: "https://avatars.githubusercontent.com/primer",
|
13
|
+
backgroundColor: "thistle"
|
14
|
+
});
|
15
|
+
}
|
16
|
+
shouldNotAcceptSystemProps.displayName = "shouldNotAcceptSystemProps";
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import BranchName from '../BranchName';
|
3
|
+
export function shouldAcceptCallWithNoProps() {
|
4
|
+
return /*#__PURE__*/React.createElement(BranchName, null);
|
5
|
+
}
|
6
|
+
shouldAcceptCallWithNoProps.displayName = "shouldAcceptCallWithNoProps";
|
7
|
+
export function shouldNotAcceptSystemProps() {
|
8
|
+
// @ts-expect-error system props should not be accepted
|
9
|
+
return /*#__PURE__*/React.createElement(BranchName, {
|
10
|
+
backgroundColor: "thistle"
|
11
|
+
});
|
12
|
+
}
|
13
|
+
shouldNotAcceptSystemProps.displayName = "shouldNotAcceptSystemProps";
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import Details from '../Details';
|
3
|
+
export function shouldAcceptCallWithNoProps() {
|
4
|
+
return /*#__PURE__*/React.createElement(Details, null);
|
5
|
+
}
|
6
|
+
shouldAcceptCallWithNoProps.displayName = "shouldAcceptCallWithNoProps";
|
7
|
+
export function shouldNotAcceptSystemProps() {
|
8
|
+
// @ts-expect-error system props should not be accepted
|
9
|
+
return /*#__PURE__*/React.createElement(Details, {
|
10
|
+
backgroundColor: "thistle"
|
11
|
+
});
|
12
|
+
}
|
13
|
+
shouldNotAcceptSystemProps.displayName = "shouldNotAcceptSystemProps";
|
@@ -4,6 +4,7 @@ import { render, behavesAsComponent, checkExports } from '../utils/testing';
|
|
4
4
|
import { render as HTMLRender, cleanup } from '@testing-library/react';
|
5
5
|
import { axe, toHaveNoViolations } from 'jest-axe';
|
6
6
|
import 'babel-polyfill';
|
7
|
+
import ThemeProvider from '../ThemeProvider';
|
7
8
|
expect.extend(toHaveNoViolations);
|
8
9
|
const theme = {
|
9
10
|
breakpoints: ['400px', '640px', '960px', '1280px'],
|
@@ -46,54 +47,85 @@ describe('Heading', () => {
|
|
46
47
|
cleanup();
|
47
48
|
});
|
48
49
|
it('respects fontWeight', () => {
|
49
|
-
expect(render( /*#__PURE__*/React.createElement(
|
50
|
-
fontWeight: "bold",
|
50
|
+
expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
|
51
51
|
theme: theme
|
52
|
-
}
|
53
|
-
|
54
|
-
|
52
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
53
|
+
sx: {
|
54
|
+
fontWeight: 'bold'
|
55
|
+
}
|
56
|
+
})))).toHaveStyleRule('font-weight', theme.fontWeights.bold);
|
57
|
+
expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
|
55
58
|
theme: theme
|
56
|
-
}
|
57
|
-
|
58
|
-
|
59
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
60
|
+
sx: {
|
61
|
+
fontWeight: 'normal'
|
62
|
+
}
|
63
|
+
})))).toHaveStyleRule('font-weight', theme.fontWeights.normal);
|
64
|
+
expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
|
59
65
|
theme: theme
|
60
|
-
}
|
61
|
-
|
62
|
-
|
66
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
67
|
+
sx: {
|
68
|
+
fontWeight: 'semibold'
|
69
|
+
}
|
70
|
+
})))).toHaveStyleRule('font-weight', theme.fontWeights.semibold);
|
71
|
+
expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
|
63
72
|
theme: theme
|
64
|
-
}
|
73
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
74
|
+
sx: {
|
75
|
+
fontWeight: 'light'
|
76
|
+
}
|
77
|
+
})))).toHaveStyleRule('font-weight', theme.fontWeights.light);
|
65
78
|
});
|
66
79
|
it('respects lineHeight', () => {
|
67
|
-
expect(render( /*#__PURE__*/React.createElement(
|
68
|
-
lineHeight: "normal",
|
80
|
+
expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
|
69
81
|
theme: theme
|
70
|
-
}
|
71
|
-
|
72
|
-
|
82
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
83
|
+
sx: {
|
84
|
+
lineHeight: 'normal'
|
85
|
+
}
|
86
|
+
})))).toHaveStyleRule('line-height', String(theme.lineHeights.normal));
|
87
|
+
expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
|
73
88
|
theme: theme
|
74
|
-
}
|
75
|
-
|
76
|
-
|
89
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
90
|
+
sx: {
|
91
|
+
lineHeight: 'condensed'
|
92
|
+
}
|
93
|
+
})))).toHaveStyleRule('line-height', String(theme.lineHeights.condensed));
|
94
|
+
expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
|
77
95
|
theme: theme
|
78
|
-
}
|
96
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
97
|
+
sx: {
|
98
|
+
lineHeight: 'condensedUltra'
|
99
|
+
}
|
100
|
+
})))).toHaveStyleRule('line-height', String(theme.lineHeights.condensedUltra));
|
79
101
|
});
|
80
102
|
it('respects fontFamily="mono"', () => {
|
81
|
-
expect(render( /*#__PURE__*/React.createElement(
|
82
|
-
fontFamily: "mono",
|
103
|
+
expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
|
83
104
|
theme: theme
|
84
|
-
}
|
105
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
106
|
+
sx: {
|
107
|
+
fontFamily: 'mono'
|
108
|
+
}
|
109
|
+
})))).toHaveStyleRule('font-family', theme.fonts.mono);
|
85
110
|
});
|
86
111
|
it('renders fontSize', () => {
|
87
112
|
for (const fontSize of theme.fontSizes) {
|
88
|
-
expect(render( /*#__PURE__*/React.createElement(
|
89
|
-
fontSize: fontSize,
|
113
|
+
expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
|
90
114
|
theme: theme
|
91
|
-
}
|
115
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
116
|
+
sx: {
|
117
|
+
fontSize
|
118
|
+
}
|
119
|
+
})))).toHaveStyleRule('font-size', `${fontSize}`);
|
92
120
|
}
|
93
121
|
});
|
94
122
|
it('respects the "fontStyle" prop', () => {
|
95
|
-
expect(render( /*#__PURE__*/React.createElement(
|
96
|
-
|
97
|
-
}
|
123
|
+
expect(render( /*#__PURE__*/React.createElement(ThemeProvider, {
|
124
|
+
theme: theme
|
125
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
126
|
+
sx: {
|
127
|
+
fontStyle: 'italic'
|
128
|
+
}
|
129
|
+
})))).toHaveStyleRule('font-style', 'italic');
|
98
130
|
});
|
99
131
|
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import Heading from '../Heading';
|
3
|
+
export function shouldAcceptCallWithNoProps() {
|
4
|
+
return /*#__PURE__*/React.createElement(Heading, null);
|
5
|
+
}
|
6
|
+
shouldAcceptCallWithNoProps.displayName = "shouldAcceptCallWithNoProps";
|
7
|
+
export function shouldNotAcceptSystemProps() {
|
8
|
+
// @ts-expect-error system props should not be accepted
|
9
|
+
return /*#__PURE__*/React.createElement(Heading, {
|
10
|
+
backgroundColor: "thistle"
|
11
|
+
});
|
12
|
+
}
|
13
|
+
shouldNotAcceptSystemProps.displayName = "shouldNotAcceptSystemProps";
|
package/lib-esm/drafts.d.ts
CHANGED
package/lib-esm/drafts.js
CHANGED