@primer/react 38.30.1-rc.b8979ee01 → 38.30.1-rc.bce2a87c7
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 +2 -0
- package/dist/AvatarStack/AvatarStack.js +231 -117
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- [#8054](https://github.com/primer/react/pull/8054) [`1775f2e`](https://github.com/primer/react/commit/1775f2e8b968d59a1189456b14cff15e527937cb) Thanks [@joshblack](https://github.com/joshblack)! - AvatarStack: Improve rendering performance with React Compiler support
|
|
8
|
+
|
|
7
9
|
- [#8053](https://github.com/primer/react/pull/8053) [`b2151ae`](https://github.com/primer/react/commit/b2151ae2d5719f09efb0b89731e52e4ca50e8bf1) Thanks [@joshblack](https://github.com/joshblack)! - Checkbox, CheckboxGroup, and RadioGroup: Improve rendering performance with React Compiler support
|
|
8
10
|
|
|
9
11
|
- [#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
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
1
2
|
import { clsx } from 'clsx';
|
|
2
3
|
import React, { useState, useRef, useEffect } from 'react';
|
|
3
4
|
import { DEFAULT_AVATAR_SIZE } from '../Avatar/Avatar.js';
|
|
4
5
|
import { isResponsiveValue } from '../hooks/useResponsiveValue.js';
|
|
5
6
|
import classes from './AvatarStack.module.css.js';
|
|
6
7
|
import { hasInteractiveNodes } from '../internal/utils/hasInteractiveNodes.js';
|
|
7
|
-
import {
|
|
8
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
9
|
|
|
9
10
|
const transformChildren = (children, shape) => {
|
|
10
11
|
return React.Children.map(children, child => {
|
|
@@ -16,136 +17,249 @@ const transformChildren = (children, shape) => {
|
|
|
16
17
|
});
|
|
17
18
|
});
|
|
18
19
|
};
|
|
19
|
-
const AvatarStackBody =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
const AvatarStackBody = t0 => {
|
|
21
|
+
const $ = c(8);
|
|
22
|
+
const {
|
|
23
|
+
disableExpand,
|
|
24
|
+
hasInteractiveChildren,
|
|
25
|
+
stackContainer,
|
|
26
|
+
children
|
|
27
|
+
} = t0;
|
|
28
|
+
const t1 = disableExpand ? "" : undefined;
|
|
29
|
+
let t2;
|
|
30
|
+
if ($[0] !== disableExpand) {
|
|
31
|
+
t2 = clsx({
|
|
32
|
+
"pc-AvatarStack--disableExpand": disableExpand
|
|
33
|
+
}, "pc-AvatarStackBody", classes.AvatarStackBody);
|
|
34
|
+
$[0] = disableExpand;
|
|
35
|
+
$[1] = t2;
|
|
36
|
+
} else {
|
|
37
|
+
t2 = $[1];
|
|
38
|
+
}
|
|
39
|
+
const t3 = !hasInteractiveChildren && !disableExpand ? 0 : undefined;
|
|
40
|
+
let t4;
|
|
41
|
+
if ($[2] !== children || $[3] !== stackContainer || $[4] !== t1 || $[5] !== t2 || $[6] !== t3) {
|
|
42
|
+
t4 = /*#__PURE__*/jsx("div", {
|
|
43
|
+
"data-component": "AvatarStack.Body",
|
|
44
|
+
"data-disable-expand": t1,
|
|
45
|
+
className: t2,
|
|
46
|
+
tabIndex: t3,
|
|
47
|
+
ref: stackContainer,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
$[2] = children;
|
|
51
|
+
$[3] = stackContainer;
|
|
52
|
+
$[4] = t1;
|
|
53
|
+
$[5] = t2;
|
|
54
|
+
$[6] = t3;
|
|
55
|
+
$[7] = t4;
|
|
56
|
+
} else {
|
|
57
|
+
t4 = $[7];
|
|
58
|
+
}
|
|
59
|
+
return t4;
|
|
35
60
|
};
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
const AvatarStack = t0 => {
|
|
62
|
+
const $ = c(36);
|
|
63
|
+
const {
|
|
64
|
+
children,
|
|
65
|
+
variant: t1,
|
|
66
|
+
shape: t2,
|
|
67
|
+
alignRight,
|
|
68
|
+
disableExpand,
|
|
69
|
+
size,
|
|
70
|
+
className,
|
|
71
|
+
style
|
|
72
|
+
} = t0;
|
|
73
|
+
const variant = t1 === undefined ? "cascade" : t1;
|
|
74
|
+
const shape = t2 === undefined ? "circle" : t2;
|
|
47
75
|
const [hasInteractiveChildren, setHasInteractiveChildren] = useState(false);
|
|
48
76
|
const stackContainer = useRef(null);
|
|
49
77
|
const count = React.Children.count(children);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (isResponsiveValue(child.props.size)) {
|
|
62
|
-
avatarSizeMap[responsiveKey].push(child.props.size[responsiveKey] || DEFAULT_AVATAR_SIZE);
|
|
78
|
+
let t3;
|
|
79
|
+
if ($[0] !== children) {
|
|
80
|
+
const getAvatarChildSizes = () => {
|
|
81
|
+
const avatarSizeMap = {
|
|
82
|
+
narrow: [],
|
|
83
|
+
regular: [],
|
|
84
|
+
wide: []
|
|
85
|
+
};
|
|
86
|
+
return React.Children.toArray(children).reduce((acc, child) => {
|
|
87
|
+
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
88
|
+
return acc;
|
|
63
89
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
90
|
+
for (const responsiveKey of Object.keys(avatarSizeMap)) {
|
|
91
|
+
if (isResponsiveValue(child.props.size)) {
|
|
92
|
+
avatarSizeMap[responsiveKey].push(child.props.size[responsiveKey] || DEFAULT_AVATAR_SIZE);
|
|
93
|
+
} else {
|
|
94
|
+
avatarSizeMap[responsiveKey].push(child.props.size || DEFAULT_AVATAR_SIZE);
|
|
95
|
+
}
|
|
96
|
+
acc[responsiveKey] = Math.min(...avatarSizeMap[responsiveKey]);
|
|
67
97
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, {
|
|
74
|
-
narrow: DEFAULT_AVATAR_SIZE,
|
|
75
|
-
regular: DEFAULT_AVATAR_SIZE,
|
|
76
|
-
wide: DEFAULT_AVATAR_SIZE
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
const childSizes = getAvatarChildSizes();
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
if (stackContainer.current) {
|
|
82
|
-
const interactiveChildren = () => {
|
|
83
|
-
setHasInteractiveChildren(hasInteractiveNodes(stackContainer.current));
|
|
84
|
-
};
|
|
85
|
-
const observer = new MutationObserver(interactiveChildren);
|
|
86
|
-
observer.observe(stackContainer.current, {
|
|
87
|
-
childList: true
|
|
98
|
+
return acc;
|
|
99
|
+
}, {
|
|
100
|
+
narrow: DEFAULT_AVATAR_SIZE,
|
|
101
|
+
regular: DEFAULT_AVATAR_SIZE,
|
|
102
|
+
wide: DEFAULT_AVATAR_SIZE
|
|
88
103
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
};
|
|
105
|
+
t3 = getAvatarChildSizes();
|
|
106
|
+
$[0] = children;
|
|
107
|
+
$[1] = t3;
|
|
108
|
+
} else {
|
|
109
|
+
t3 = $[1];
|
|
110
|
+
}
|
|
111
|
+
const childSizes = t3;
|
|
112
|
+
let t4;
|
|
113
|
+
let t5;
|
|
114
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
115
|
+
t4 = () => {
|
|
116
|
+
if (stackContainer.current) {
|
|
117
|
+
const interactiveChildren = () => {
|
|
118
|
+
setHasInteractiveChildren(hasInteractiveNodes(stackContainer.current));
|
|
119
|
+
};
|
|
120
|
+
const observer = new MutationObserver(interactiveChildren);
|
|
121
|
+
observer.observe(stackContainer.current, {
|
|
122
|
+
childList: true
|
|
123
|
+
});
|
|
124
|
+
interactiveChildren();
|
|
125
|
+
return () => {
|
|
126
|
+
observer.disconnect();
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
t5 = [];
|
|
131
|
+
$[2] = t4;
|
|
132
|
+
$[3] = t5;
|
|
133
|
+
} else {
|
|
134
|
+
t4 = $[2];
|
|
135
|
+
t5 = $[3];
|
|
136
|
+
}
|
|
137
|
+
useEffect(t4, t5);
|
|
138
|
+
let t6;
|
|
139
|
+
if ($[4] !== childSizes || $[5] !== size) {
|
|
140
|
+
t6 = () => {
|
|
141
|
+
if (!size) {
|
|
142
|
+
return {
|
|
143
|
+
"--stackSize-narrow": `${childSizes.narrow}px`,
|
|
144
|
+
"--stackSize-regular": `${childSizes.regular}px`,
|
|
145
|
+
"--stackSize-wide": `${childSizes.wide}px`
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (isResponsiveValue(size)) {
|
|
149
|
+
return {
|
|
150
|
+
"--stackSize-narrow": `${size.narrow || DEFAULT_AVATAR_SIZE}px`,
|
|
151
|
+
"--stackSize-regular": `${size.regular || DEFAULT_AVATAR_SIZE}px`,
|
|
152
|
+
"--stackSize-wide": `${size.wide || DEFAULT_AVATAR_SIZE}px`
|
|
153
|
+
};
|
|
154
|
+
}
|
|
110
155
|
return {
|
|
111
|
-
|
|
112
|
-
'--stackSize-regular': `${size.regular || DEFAULT_AVATAR_SIZE}px`,
|
|
113
|
-
'--stackSize-wide': `${size.wide || DEFAULT_AVATAR_SIZE}px`
|
|
156
|
+
"--avatar-stack-size": `${size}px`
|
|
114
157
|
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// if the `size` prop is set and not responsive, it is a number, so we can just set the `--avatar-stack-size` CSS variable to that number
|
|
118
|
-
return {
|
|
119
|
-
'--avatar-stack-size': `${size}px`
|
|
120
158
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
159
|
+
$[4] = childSizes;
|
|
160
|
+
$[5] = size;
|
|
161
|
+
$[6] = t6;
|
|
162
|
+
} else {
|
|
163
|
+
t6 = $[6];
|
|
164
|
+
}
|
|
165
|
+
const getResponsiveAvatarSizeStyles = t6;
|
|
166
|
+
const t7 = count > 3 ? "3+" : count;
|
|
167
|
+
const t8 = alignRight ? "" : undefined;
|
|
168
|
+
const t9 = !size || isResponsiveValue(size) ? "" : undefined;
|
|
169
|
+
const t10 = count === 2;
|
|
170
|
+
const t11 = count === 3;
|
|
171
|
+
const t12 = count > 3;
|
|
172
|
+
let t13;
|
|
173
|
+
if ($[7] !== alignRight || $[8] !== className || $[9] !== shape || $[10] !== t10 || $[11] !== t11 || $[12] !== t12 || $[13] !== variant) {
|
|
174
|
+
t13 = clsx({
|
|
175
|
+
"pc-AvatarStack--variant": variant,
|
|
176
|
+
"pc-AvatarStack--shape": shape,
|
|
177
|
+
"pc-AvatarStack--two": t10,
|
|
178
|
+
"pc-AvatarStack--three": t11,
|
|
179
|
+
"pc-AvatarStack--three-plus": t12,
|
|
180
|
+
"pc-AvatarStack--right": alignRight
|
|
181
|
+
}, className, classes.AvatarStack);
|
|
182
|
+
$[7] = alignRight;
|
|
183
|
+
$[8] = className;
|
|
184
|
+
$[9] = shape;
|
|
185
|
+
$[10] = t10;
|
|
186
|
+
$[11] = t11;
|
|
187
|
+
$[12] = t12;
|
|
188
|
+
$[13] = variant;
|
|
189
|
+
$[14] = t13;
|
|
190
|
+
} else {
|
|
191
|
+
t13 = $[14];
|
|
192
|
+
}
|
|
193
|
+
let t14;
|
|
194
|
+
if ($[15] !== getResponsiveAvatarSizeStyles) {
|
|
195
|
+
t14 = getResponsiveAvatarSizeStyles();
|
|
196
|
+
$[15] = getResponsiveAvatarSizeStyles;
|
|
197
|
+
$[16] = t14;
|
|
198
|
+
} else {
|
|
199
|
+
t14 = $[16];
|
|
200
|
+
}
|
|
201
|
+
let t15;
|
|
202
|
+
if ($[17] !== style || $[18] !== t14) {
|
|
203
|
+
t15 = {
|
|
204
|
+
...t14,
|
|
139
205
|
...style
|
|
140
|
-
}
|
|
141
|
-
|
|
206
|
+
};
|
|
207
|
+
$[17] = style;
|
|
208
|
+
$[18] = t14;
|
|
209
|
+
$[19] = t15;
|
|
210
|
+
} else {
|
|
211
|
+
t15 = $[19];
|
|
212
|
+
}
|
|
213
|
+
let t16;
|
|
214
|
+
if ($[20] !== children || $[21] !== shape) {
|
|
215
|
+
t16 = transformChildren(children, shape);
|
|
216
|
+
$[20] = children;
|
|
217
|
+
$[21] = shape;
|
|
218
|
+
$[22] = t16;
|
|
219
|
+
} else {
|
|
220
|
+
t16 = $[22];
|
|
221
|
+
}
|
|
222
|
+
let t17;
|
|
223
|
+
if ($[23] !== disableExpand || $[24] !== hasInteractiveChildren || $[25] !== t16) {
|
|
224
|
+
t17 = /*#__PURE__*/jsxs(AvatarStackBody, {
|
|
142
225
|
disableExpand: disableExpand,
|
|
143
226
|
hasInteractiveChildren: hasInteractiveChildren,
|
|
144
227
|
stackContainer: stackContainer,
|
|
145
|
-
children: [
|
|
146
|
-
})
|
|
147
|
-
|
|
228
|
+
children: [" ", t16]
|
|
229
|
+
});
|
|
230
|
+
$[23] = disableExpand;
|
|
231
|
+
$[24] = hasInteractiveChildren;
|
|
232
|
+
$[25] = t16;
|
|
233
|
+
$[26] = t17;
|
|
234
|
+
} else {
|
|
235
|
+
t17 = $[26];
|
|
236
|
+
}
|
|
237
|
+
let t18;
|
|
238
|
+
if ($[27] !== shape || $[28] !== t13 || $[29] !== t15 || $[30] !== t17 || $[31] !== t7 || $[32] !== t8 || $[33] !== t9 || $[34] !== variant) {
|
|
239
|
+
t18 = /*#__PURE__*/jsx("span", {
|
|
240
|
+
"data-component": "AvatarStack",
|
|
241
|
+
"data-variant": variant,
|
|
242
|
+
"data-shape": shape,
|
|
243
|
+
"data-avatar-count": t7,
|
|
244
|
+
"data-align-right": t8,
|
|
245
|
+
"data-responsive": t9,
|
|
246
|
+
className: t13,
|
|
247
|
+
style: t15,
|
|
248
|
+
children: t17
|
|
249
|
+
});
|
|
250
|
+
$[27] = shape;
|
|
251
|
+
$[28] = t13;
|
|
252
|
+
$[29] = t15;
|
|
253
|
+
$[30] = t17;
|
|
254
|
+
$[31] = t7;
|
|
255
|
+
$[32] = t8;
|
|
256
|
+
$[33] = t9;
|
|
257
|
+
$[34] = variant;
|
|
258
|
+
$[35] = t18;
|
|
259
|
+
} else {
|
|
260
|
+
t18 = $[35];
|
|
261
|
+
}
|
|
262
|
+
return t18;
|
|
148
263
|
};
|
|
149
|
-
AvatarStack.displayName = "AvatarStack";
|
|
150
264
|
|
|
151
265
|
export { AvatarStack as default };
|
package/package.json
CHANGED