@primer/react 38.30.0 → 38.30.1-rc.2d1806208
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 +6 -0
- package/dist/Heading/Heading.js +69 -19
- package/dist/Link/Link.js +81 -25
- package/dist/Pagehead/Pagehead.js +45 -11
- package/dist/SideNav.js +112 -41
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
+
## 38.30.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#8052](https://github.com/primer/react/pull/8052) [`a1b24cf`](https://github.com/primer/react/commit/a1b24cf3411566641aeb846e62069dc26505da6b) Thanks [@joshblack](https://github.com/joshblack)! - Heading, Link, Pagehead, Portal, and SideNav: Improve rendering performance with React Compiler support
|
|
8
|
+
|
|
3
9
|
## 38.30.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/Heading/Heading.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
1
2
|
import { clsx } from 'clsx';
|
|
2
3
|
import React, { forwardRef } from 'react';
|
|
3
4
|
import { useDevOnlyEffect } from '../internal/hooks/useDevOnlyEffect.js';
|
|
@@ -5,27 +6,76 @@ import classes from './Heading.module.css.js';
|
|
|
5
6
|
import { jsx } from 'react/jsx-runtime';
|
|
6
7
|
import { useMergedRefs } from '../hooks/useMergedRefs.js';
|
|
7
8
|
|
|
8
|
-
const Heading = /*#__PURE__*/forwardRef(({
|
|
9
|
-
|
|
10
|
-
className
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const Heading = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
|
|
10
|
+
const $ = c(15);
|
|
11
|
+
let className;
|
|
12
|
+
let props;
|
|
13
|
+
let t1;
|
|
14
|
+
let variant;
|
|
15
|
+
if ($[0] !== t0) {
|
|
16
|
+
({
|
|
17
|
+
as: t1,
|
|
18
|
+
className,
|
|
19
|
+
variant,
|
|
20
|
+
...props
|
|
21
|
+
} = t0);
|
|
22
|
+
$[0] = t0;
|
|
23
|
+
$[1] = className;
|
|
24
|
+
$[2] = props;
|
|
25
|
+
$[3] = t1;
|
|
26
|
+
$[4] = variant;
|
|
27
|
+
} else {
|
|
28
|
+
className = $[1];
|
|
29
|
+
props = $[2];
|
|
30
|
+
t1 = $[3];
|
|
31
|
+
variant = $[4];
|
|
32
|
+
}
|
|
33
|
+
const Component = t1 === undefined ? "h2" : t1;
|
|
14
34
|
const innerRef = React.useRef(null);
|
|
15
35
|
const mergedRef = useMergedRefs(forwardedRef, innerRef);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
let t2;
|
|
37
|
+
let t3;
|
|
38
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
39
|
+
t2 = () => {
|
|
40
|
+
if (innerRef.current && !(innerRef.current instanceof HTMLHeadingElement)) {
|
|
41
|
+
console.warn("This Heading component should be an instanceof of h1-h6");
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
t3 = [innerRef];
|
|
45
|
+
$[5] = t2;
|
|
46
|
+
$[6] = t3;
|
|
47
|
+
} else {
|
|
48
|
+
t2 = $[5];
|
|
49
|
+
t3 = $[6];
|
|
50
|
+
}
|
|
51
|
+
useDevOnlyEffect(t2, t3);
|
|
52
|
+
let t4;
|
|
53
|
+
if ($[7] !== className) {
|
|
54
|
+
t4 = clsx(className, classes.Heading);
|
|
55
|
+
$[7] = className;
|
|
56
|
+
$[8] = t4;
|
|
57
|
+
} else {
|
|
58
|
+
t4 = $[8];
|
|
59
|
+
}
|
|
60
|
+
let t5;
|
|
61
|
+
if ($[9] !== Component || $[10] !== mergedRef || $[11] !== props || $[12] !== t4 || $[13] !== variant) {
|
|
62
|
+
t5 = /*#__PURE__*/jsx(Component, {
|
|
63
|
+
className: t4,
|
|
64
|
+
"data-variant": variant,
|
|
65
|
+
"data-component": "Heading",
|
|
66
|
+
...props,
|
|
67
|
+
ref: mergedRef
|
|
68
|
+
});
|
|
69
|
+
$[9] = Component;
|
|
70
|
+
$[10] = mergedRef;
|
|
71
|
+
$[11] = props;
|
|
72
|
+
$[12] = t4;
|
|
73
|
+
$[13] = variant;
|
|
74
|
+
$[14] = t5;
|
|
75
|
+
} else {
|
|
76
|
+
t5 = $[14];
|
|
77
|
+
}
|
|
78
|
+
return t5;
|
|
29
79
|
});
|
|
30
80
|
Heading.displayName = 'Heading';
|
|
31
81
|
|
package/dist/Link/Link.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
1
2
|
import { clsx } from 'clsx';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { useDevOnlyEffect } from '../internal/hooks/useDevOnlyEffect.js';
|
|
@@ -7,34 +8,89 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
7
8
|
import { useMergedRefs } from '../hooks/useMergedRefs.js';
|
|
8
9
|
|
|
9
10
|
const UnwrappedLink = (props, ref) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const $ = c(19);
|
|
12
|
+
let className;
|
|
13
|
+
let hoverColor;
|
|
14
|
+
let inline;
|
|
15
|
+
let muted;
|
|
16
|
+
let restProps;
|
|
17
|
+
let t0;
|
|
18
|
+
if ($[0] !== props) {
|
|
19
|
+
({
|
|
20
|
+
as: t0,
|
|
21
|
+
className,
|
|
22
|
+
inline,
|
|
23
|
+
muted,
|
|
24
|
+
hoverColor,
|
|
25
|
+
...restProps
|
|
26
|
+
} = props);
|
|
27
|
+
$[0] = props;
|
|
28
|
+
$[1] = className;
|
|
29
|
+
$[2] = hoverColor;
|
|
30
|
+
$[3] = inline;
|
|
31
|
+
$[4] = muted;
|
|
32
|
+
$[5] = restProps;
|
|
33
|
+
$[6] = t0;
|
|
34
|
+
} else {
|
|
35
|
+
className = $[1];
|
|
36
|
+
hoverColor = $[2];
|
|
37
|
+
inline = $[3];
|
|
38
|
+
muted = $[4];
|
|
39
|
+
restProps = $[5];
|
|
40
|
+
t0 = $[6];
|
|
41
|
+
}
|
|
42
|
+
const Component = t0 === undefined ? "a" : t0;
|
|
18
43
|
const innerRef = React.useRef(null);
|
|
19
44
|
const mergedRef = useMergedRefs(ref, innerRef);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
45
|
+
let t1;
|
|
46
|
+
let t2;
|
|
47
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
48
|
+
t1 = () => {
|
|
49
|
+
if (innerRef.current && !(innerRef.current instanceof HTMLButtonElement) && !(innerRef.current instanceof HTMLAnchorElement)) {
|
|
50
|
+
console.error("Error: Found `Link` component that renders an inaccessible element", innerRef.current, "Please ensure `Link` always renders as <a> or <button>");
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
t2 = [innerRef];
|
|
54
|
+
$[7] = t1;
|
|
55
|
+
$[8] = t2;
|
|
56
|
+
} else {
|
|
57
|
+
t1 = $[7];
|
|
58
|
+
t2 = $[8];
|
|
59
|
+
}
|
|
60
|
+
useDevOnlyEffect(t1, t2);
|
|
61
|
+
let t3;
|
|
62
|
+
if ($[9] !== className) {
|
|
63
|
+
t3 = clsx(className, classes.Link);
|
|
64
|
+
$[9] = className;
|
|
65
|
+
$[10] = t3;
|
|
66
|
+
} else {
|
|
67
|
+
t3 = $[10];
|
|
68
|
+
}
|
|
69
|
+
const t4 = mergedRef;
|
|
70
|
+
let t5;
|
|
71
|
+
if ($[11] !== Component || $[12] !== hoverColor || $[13] !== inline || $[14] !== muted || $[15] !== restProps || $[16] !== t3 || $[17] !== t4) {
|
|
72
|
+
t5 = /*#__PURE__*/jsx(Component, {
|
|
73
|
+
className: t3,
|
|
74
|
+
"data-component": "Link",
|
|
75
|
+
"data-muted": muted,
|
|
76
|
+
"data-inline": inline,
|
|
77
|
+
"data-hover-color": hoverColor,
|
|
78
|
+
...restProps,
|
|
79
|
+
ref: t4
|
|
80
|
+
});
|
|
81
|
+
$[11] = Component;
|
|
82
|
+
$[12] = hoverColor;
|
|
83
|
+
$[13] = inline;
|
|
84
|
+
$[14] = muted;
|
|
85
|
+
$[15] = restProps;
|
|
86
|
+
$[16] = t3;
|
|
87
|
+
$[17] = t4;
|
|
88
|
+
$[18] = t5;
|
|
89
|
+
} else {
|
|
90
|
+
t5 = $[18];
|
|
91
|
+
}
|
|
92
|
+
return t5;
|
|
36
93
|
};
|
|
37
|
-
UnwrappedLink.displayName = "UnwrappedLink";
|
|
38
94
|
const LinkComponent = fixedForwardRef(UnwrappedLink);
|
|
39
95
|
const Link = Object.assign(LinkComponent, {
|
|
40
96
|
displayName: 'Link'
|
|
@@ -1,18 +1,52 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
1
2
|
import { clsx } from 'clsx';
|
|
2
3
|
import classes from './Pagehead.module.css.js';
|
|
3
4
|
import { jsx } from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
|
-
const Pagehead =
|
|
6
|
-
|
|
7
|
-
className
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const Pagehead = t0 => {
|
|
7
|
+
const $ = c(10);
|
|
8
|
+
let className;
|
|
9
|
+
let rest;
|
|
10
|
+
let t1;
|
|
11
|
+
if ($[0] !== t0) {
|
|
12
|
+
({
|
|
13
|
+
as: t1,
|
|
14
|
+
className,
|
|
15
|
+
...rest
|
|
16
|
+
} = t0);
|
|
17
|
+
$[0] = t0;
|
|
18
|
+
$[1] = className;
|
|
19
|
+
$[2] = rest;
|
|
20
|
+
$[3] = t1;
|
|
21
|
+
} else {
|
|
22
|
+
className = $[1];
|
|
23
|
+
rest = $[2];
|
|
24
|
+
t1 = $[3];
|
|
25
|
+
}
|
|
26
|
+
const BaseComponent = t1 === undefined ? "div" : t1;
|
|
27
|
+
let t2;
|
|
28
|
+
if ($[4] !== className) {
|
|
29
|
+
t2 = clsx(classes.Pagehead, className);
|
|
30
|
+
$[4] = className;
|
|
31
|
+
$[5] = t2;
|
|
32
|
+
} else {
|
|
33
|
+
t2 = $[5];
|
|
34
|
+
}
|
|
35
|
+
let t3;
|
|
36
|
+
if ($[6] !== BaseComponent || $[7] !== rest || $[8] !== t2) {
|
|
37
|
+
t3 = /*#__PURE__*/jsx(BaseComponent, {
|
|
38
|
+
className: t2,
|
|
39
|
+
"data-component": "Pagehead",
|
|
40
|
+
...rest
|
|
41
|
+
});
|
|
42
|
+
$[6] = BaseComponent;
|
|
43
|
+
$[7] = rest;
|
|
44
|
+
$[8] = t2;
|
|
45
|
+
$[9] = t3;
|
|
46
|
+
} else {
|
|
47
|
+
t3 = $[9];
|
|
48
|
+
}
|
|
49
|
+
return t3;
|
|
15
50
|
};
|
|
16
|
-
Pagehead.displayName = "Pagehead";
|
|
17
51
|
|
|
18
52
|
export { Pagehead as default };
|
package/dist/SideNav.js
CHANGED
|
@@ -1,51 +1,122 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
1
2
|
import { clsx } from 'clsx';
|
|
2
3
|
import classes from './SideNav.module.css.js';
|
|
3
4
|
import { jsx } from 'react/jsx-runtime';
|
|
4
5
|
import Link from './Link/Link.js';
|
|
5
6
|
|
|
6
|
-
function SideNav({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
function SideNav(t0) {
|
|
8
|
+
const $ = c(10);
|
|
9
|
+
const {
|
|
10
|
+
as: t1,
|
|
11
|
+
variant: t2,
|
|
12
|
+
className,
|
|
13
|
+
bordered,
|
|
14
|
+
children,
|
|
15
|
+
"aria-label": ariaLabel
|
|
16
|
+
} = t0;
|
|
17
|
+
const Component = t1 === undefined ? "nav" : t1;
|
|
18
|
+
const variant = t2 === undefined ? "normal" : t2;
|
|
19
|
+
const variantClassName = variant === "lightweight" ? "lightweight" : "normal";
|
|
20
|
+
const t3 = classes[`SideNavVariant--${variantClassName}`];
|
|
21
|
+
const t4 = `variant-${variantClassName}`;
|
|
22
|
+
let t5;
|
|
23
|
+
if ($[0] !== bordered || $[1] !== className || $[2] !== t3 || $[3] !== t4) {
|
|
24
|
+
t5 = clsx(classes.SideNav, t3, "sidenav", t4, className, {
|
|
25
|
+
[classes.SideNavBordered]: bordered
|
|
26
|
+
});
|
|
27
|
+
$[0] = bordered;
|
|
28
|
+
$[1] = className;
|
|
29
|
+
$[2] = t3;
|
|
30
|
+
$[3] = t4;
|
|
31
|
+
$[4] = t5;
|
|
32
|
+
} else {
|
|
33
|
+
t5 = $[4];
|
|
34
|
+
}
|
|
35
|
+
const newClassName = t5;
|
|
36
|
+
let t6;
|
|
37
|
+
if ($[5] !== Component || $[6] !== ariaLabel || $[7] !== children || $[8] !== newClassName) {
|
|
38
|
+
t6 = /*#__PURE__*/jsx(Component, {
|
|
39
|
+
className: newClassName,
|
|
40
|
+
"aria-label": ariaLabel,
|
|
41
|
+
"data-component": "SideNav",
|
|
42
|
+
children: children
|
|
43
|
+
});
|
|
44
|
+
$[5] = Component;
|
|
45
|
+
$[6] = ariaLabel;
|
|
46
|
+
$[7] = children;
|
|
47
|
+
$[8] = newClassName;
|
|
48
|
+
$[9] = t6;
|
|
49
|
+
} else {
|
|
50
|
+
t6 = $[9];
|
|
51
|
+
}
|
|
52
|
+
return t6;
|
|
24
53
|
}
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
const SideNavLink = t0 => {
|
|
55
|
+
const $ = c(15);
|
|
56
|
+
let children;
|
|
57
|
+
let className;
|
|
58
|
+
let rest;
|
|
59
|
+
let selected;
|
|
60
|
+
let to;
|
|
61
|
+
let variant;
|
|
62
|
+
if ($[0] !== t0) {
|
|
63
|
+
({
|
|
64
|
+
selected,
|
|
65
|
+
to,
|
|
66
|
+
variant,
|
|
67
|
+
className,
|
|
68
|
+
children,
|
|
69
|
+
...rest
|
|
70
|
+
} = t0);
|
|
71
|
+
$[0] = t0;
|
|
72
|
+
$[1] = children;
|
|
73
|
+
$[2] = className;
|
|
74
|
+
$[3] = rest;
|
|
75
|
+
$[4] = selected;
|
|
76
|
+
$[5] = to;
|
|
77
|
+
$[6] = variant;
|
|
78
|
+
} else {
|
|
79
|
+
children = $[1];
|
|
80
|
+
className = $[2];
|
|
81
|
+
rest = $[3];
|
|
82
|
+
selected = $[4];
|
|
83
|
+
to = $[5];
|
|
84
|
+
variant = $[6];
|
|
85
|
+
}
|
|
86
|
+
const isReactRouter = typeof to === "string";
|
|
87
|
+
const t1 = variant === "full";
|
|
88
|
+
let t2;
|
|
89
|
+
if ($[7] !== className || $[8] !== t1) {
|
|
90
|
+
t2 = clsx(classes.SideNavLink, className, {
|
|
91
|
+
[classes.SideNavLinkFull]: t1
|
|
92
|
+
});
|
|
93
|
+
$[7] = className;
|
|
94
|
+
$[8] = t1;
|
|
95
|
+
$[9] = t2;
|
|
96
|
+
} else {
|
|
97
|
+
t2 = $[9];
|
|
98
|
+
}
|
|
99
|
+
const newClassName = t2;
|
|
100
|
+
const t3 = isReactRouter || selected ? "page" : undefined;
|
|
101
|
+
let t4;
|
|
102
|
+
if ($[10] !== children || $[11] !== newClassName || $[12] !== rest || $[13] !== t3) {
|
|
103
|
+
t4 = /*#__PURE__*/jsx(Link, {
|
|
104
|
+
"aria-current": t3,
|
|
105
|
+
className: newClassName,
|
|
106
|
+
...rest,
|
|
107
|
+
"data-component": "SideNav.Link",
|
|
108
|
+
children: children
|
|
109
|
+
});
|
|
110
|
+
$[10] = children;
|
|
111
|
+
$[11] = newClassName;
|
|
112
|
+
$[12] = rest;
|
|
113
|
+
$[13] = t3;
|
|
114
|
+
$[14] = t4;
|
|
115
|
+
} else {
|
|
116
|
+
t4 = $[14];
|
|
117
|
+
}
|
|
118
|
+
return t4;
|
|
47
119
|
};
|
|
48
|
-
SideNavLink.displayName = "SideNavLink";
|
|
49
120
|
SideNavLink.displayName = 'SideNav.Link';
|
|
50
121
|
/** @deprecated Use [NavList](https://primer.style/react/NavList) instead */
|
|
51
122
|
var SideNav_default = Object.assign(SideNav, {
|
package/package.json
CHANGED