@primer/react 38.30.1-rc.2d1806208 → 38.30.1-rc.b8979ee01

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
@@ -4,6 +4,8 @@
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - [#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
+
7
9
  - [#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
10
 
9
11
  ## 38.30.0
@@ -1,3 +1,4 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import React from 'react';
2
3
  import ValidationAnimationContainer from '../ValidationAnimationContainer.js';
3
4
  import { useId } from '../../../hooks/useId.js';
@@ -9,22 +10,33 @@ import VisuallyHidden from '../../../_VisuallyHidden.js';
9
10
  import { useSlots } from '../../../hooks/useSlots.js';
10
11
  import classes from './CheckboxOrRadioGroup.module.css.js';
11
12
  import { clsx } from 'clsx';
12
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
13
14
 
14
- const CheckboxOrRadioGroup = ({
15
- 'aria-labelledby': ariaLabelledby,
16
- children,
17
- disabled = false,
18
- id: idProp,
19
- required = false,
20
- className,
21
- 'data-component': dataComponentProp
22
- }) => {
23
- const [slots, rest] = useSlots(children, {
24
- caption: CheckboxOrRadioGroupCaption,
25
- label: CheckboxOrRadioGroupLabel,
26
- validation: CheckboxOrRadioGroupValidation
27
- });
15
+ const CheckboxOrRadioGroup = t0 => {
16
+ const $ = c(51);
17
+ const {
18
+ "aria-labelledby": ariaLabelledby,
19
+ children,
20
+ disabled: t1,
21
+ id: idProp,
22
+ required: t2,
23
+ className,
24
+ "data-component": dataComponentProp
25
+ } = t0;
26
+ const disabled = t1 === undefined ? false : t1;
27
+ const required = t2 === undefined ? false : t2;
28
+ let t3;
29
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
30
+ t3 = {
31
+ caption: CheckboxOrRadioGroupCaption,
32
+ label: CheckboxOrRadioGroupLabel,
33
+ validation: CheckboxOrRadioGroupValidation
34
+ };
35
+ $[0] = t3;
36
+ } else {
37
+ t3 = $[0];
38
+ }
39
+ const [slots, rest] = useSlots(children, t3);
28
40
  const labelChild = slots.label;
29
41
  const validationChild = slots.validation;
30
42
  const captionChild = slots.caption;
@@ -33,78 +45,187 @@ const CheckboxOrRadioGroup = ({
33
45
  const captionId = captionChild ? `${id}-caption` : undefined;
34
46
  const requiredMessageId = required ? `${id}-requiredMessage` : undefined;
35
47
  if (!labelChild && !ariaLabelledby) {
36
- // eslint-disable-next-line no-console
37
- console.warn('A choice group must be labelled using a `CheckboxOrRadioGroup.Label` child, or by passing `aria-labelledby` to the CheckboxOrRadioGroup component.');
48
+ console.warn("A choice group must be labelled using a `CheckboxOrRadioGroup.Label` child, or by passing `aria-labelledby` to the CheckboxOrRadioGroup component.");
49
+ }
50
+ let t4;
51
+ if ($[1] !== labelChild) {
52
+ t4 = /*#__PURE__*/React.isValidElement(labelChild) && !labelChild.props.visuallyHidden;
53
+ $[1] = labelChild;
54
+ $[2] = t4;
55
+ } else {
56
+ t4 = $[2];
38
57
  }
39
- const isLegendVisible = /*#__PURE__*/React.isValidElement(labelChild) && !labelChild.props.visuallyHidden;
40
- const Component = labelChild ? 'fieldset' : 'div';
41
- return /*#__PURE__*/jsx(CheckboxOrRadioGroupContext.Provider, {
42
- value: {
58
+ const isLegendVisible = t4;
59
+ const Component = labelChild ? "fieldset" : "div";
60
+ let t5;
61
+ if ($[3] !== captionId || $[4] !== dataComponentProp || $[5] !== disabled || $[6] !== required || $[7] !== validationMessageId) {
62
+ t5 = {
43
63
  disabled,
44
64
  required,
45
65
  captionId,
46
66
  validationMessageId,
47
67
  parentName: dataComponentProp
48
- },
49
- children: /*#__PURE__*/jsxs("div", {
50
- children: [/*#__PURE__*/jsxs(Component, {
51
- "data-component": dataComponentProp,
52
- className: clsx(className, classes.GroupFieldset),
53
- "data-validation": validationChild ? '' : undefined,
54
- ...(labelChild ? {
55
- disabled
56
- } : {}),
57
- children: [labelChild ?
58
- /*#__PURE__*/
59
- /*
60
- Placing the caption text and validation text in the <legend> provides a better user
61
- experience for more screenreaders.
62
- Reference: https://blog.tenon.io/accessible-validation-of-checkbox-and-radiobutton-groups/
63
- */
64
- jsxs("legend", {
65
- className: classes.GroupLegend,
66
- "data-legend-visible": isLegendVisible ? '' : undefined,
67
- children: [slots.label, required && /*#__PURE__*/jsx(VisuallyHidden, {
68
- children: ", required"
69
- }), slots.caption, /*#__PURE__*/React.isValidElement(slots.validation) && slots.validation.props.children && /*#__PURE__*/jsx(VisuallyHidden, {
70
- children: slots.validation.props.children
71
- })]
72
- }) :
73
- /*#__PURE__*/
74
- /*
75
- If CheckboxOrRadioGroup.Label wasn't passed as a child, we don't render a <legend>
76
- but we still want to render a caption
77
- */
78
- jsxs(Fragment, {
79
- children: [slots.caption, required && requiredMessageId && /*#__PURE__*/jsx(VisuallyHidden, {
80
- id: requiredMessageId,
81
- children: "Required"
82
- })]
83
- }), /*#__PURE__*/jsx("div", {
84
- className: classes.Body,
85
- ...(!labelChild ? {
86
- ['aria-labelledby']: ariaLabelledby,
87
- ['aria-describedby']: [validationMessageId, captionId, requiredMessageId].filter(Boolean).join(' '),
88
- as: 'div',
89
- role: 'group'
90
- } : {}),
91
- children: React.Children.toArray(rest).filter(child => /*#__PURE__*/React.isValidElement(child))
92
- })]
93
- }), validationChild && /*#__PURE__*/jsx(ValidationAnimationContainer
94
- // If we have CheckboxOrRadioGroup.Label as a child, we render a screenreader-accessible validation message in the <legend>
95
- , {
96
- "aria-hidden": Boolean(labelChild),
97
- show: true,
98
- children: slots.validation
68
+ };
69
+ $[3] = captionId;
70
+ $[4] = dataComponentProp;
71
+ $[5] = disabled;
72
+ $[6] = required;
73
+ $[7] = validationMessageId;
74
+ $[8] = t5;
75
+ } else {
76
+ t5 = $[8];
77
+ }
78
+ let t6;
79
+ if ($[9] !== className) {
80
+ t6 = clsx(className, classes.GroupFieldset);
81
+ $[9] = className;
82
+ $[10] = t6;
83
+ } else {
84
+ t6 = $[10];
85
+ }
86
+ const t7 = validationChild ? "" : undefined;
87
+ let t8;
88
+ if ($[11] !== disabled || $[12] !== labelChild) {
89
+ t8 = labelChild ? {
90
+ disabled
91
+ } : {};
92
+ $[11] = disabled;
93
+ $[12] = labelChild;
94
+ $[13] = t8;
95
+ } else {
96
+ t8 = $[13];
97
+ }
98
+ let t9;
99
+ if ($[14] !== isLegendVisible || $[15] !== labelChild || $[16] !== required || $[17] !== requiredMessageId || $[18] !== slots.caption || $[19] !== slots.label || $[20] !== slots.validation) {
100
+ t9 = labelChild ? /*#__PURE__*/jsxs("legend", {
101
+ className: classes.GroupLegend,
102
+ "data-legend-visible": isLegendVisible ? "" : undefined,
103
+ children: [slots.label, required && /*#__PURE__*/jsx(VisuallyHidden, {
104
+ children: ", required"
105
+ }), slots.caption, /*#__PURE__*/React.isValidElement(slots.validation) && slots.validation.props.children && /*#__PURE__*/jsx(VisuallyHidden, {
106
+ children: slots.validation.props.children
107
+ })]
108
+ }) : /*#__PURE__*/jsxs(Fragment, {
109
+ children: [slots.caption, required && requiredMessageId && /*#__PURE__*/jsx(VisuallyHidden, {
110
+ id: requiredMessageId,
111
+ children: "Required"
99
112
  })]
100
- })
101
- });
113
+ });
114
+ $[14] = isLegendVisible;
115
+ $[15] = labelChild;
116
+ $[16] = required;
117
+ $[17] = requiredMessageId;
118
+ $[18] = slots.caption;
119
+ $[19] = slots.label;
120
+ $[20] = slots.validation;
121
+ $[21] = t9;
122
+ } else {
123
+ t9 = $[21];
124
+ }
125
+ let t10;
126
+ if ($[22] !== ariaLabelledby || $[23] !== captionId || $[24] !== labelChild || $[25] !== requiredMessageId || $[26] !== validationMessageId) {
127
+ t10 = !labelChild ? {
128
+ "aria-labelledby": ariaLabelledby,
129
+ "aria-describedby": [validationMessageId, captionId, requiredMessageId].filter(Boolean).join(" "),
130
+ as: "div",
131
+ role: "group"
132
+ } : {};
133
+ $[22] = ariaLabelledby;
134
+ $[23] = captionId;
135
+ $[24] = labelChild;
136
+ $[25] = requiredMessageId;
137
+ $[26] = validationMessageId;
138
+ $[27] = t10;
139
+ } else {
140
+ t10 = $[27];
141
+ }
142
+ let t11;
143
+ if ($[28] !== rest) {
144
+ t11 = React.Children.toArray(rest).filter(_temp);
145
+ $[28] = rest;
146
+ $[29] = t11;
147
+ } else {
148
+ t11 = $[29];
149
+ }
150
+ let t12;
151
+ if ($[30] !== t10 || $[31] !== t11) {
152
+ t12 = /*#__PURE__*/jsx("div", {
153
+ className: classes.Body,
154
+ ...t10,
155
+ children: t11
156
+ });
157
+ $[30] = t10;
158
+ $[31] = t11;
159
+ $[32] = t12;
160
+ } else {
161
+ t12 = $[32];
162
+ }
163
+ let t13;
164
+ if ($[33] !== Component || $[34] !== dataComponentProp || $[35] !== t12 || $[36] !== t6 || $[37] !== t7 || $[38] !== t8 || $[39] !== t9) {
165
+ t13 = /*#__PURE__*/jsxs(Component, {
166
+ "data-component": dataComponentProp,
167
+ className: t6,
168
+ "data-validation": t7,
169
+ ...t8,
170
+ children: [t9, t12]
171
+ });
172
+ $[33] = Component;
173
+ $[34] = dataComponentProp;
174
+ $[35] = t12;
175
+ $[36] = t6;
176
+ $[37] = t7;
177
+ $[38] = t8;
178
+ $[39] = t9;
179
+ $[40] = t13;
180
+ } else {
181
+ t13 = $[40];
182
+ }
183
+ let t14;
184
+ if ($[41] !== labelChild || $[42] !== slots.validation || $[43] !== validationChild) {
185
+ t14 = validationChild && /*#__PURE__*/jsx(ValidationAnimationContainer, {
186
+ "aria-hidden": Boolean(labelChild),
187
+ show: true,
188
+ children: slots.validation
189
+ });
190
+ $[41] = labelChild;
191
+ $[42] = slots.validation;
192
+ $[43] = validationChild;
193
+ $[44] = t14;
194
+ } else {
195
+ t14 = $[44];
196
+ }
197
+ let t15;
198
+ if ($[45] !== t13 || $[46] !== t14) {
199
+ t15 = /*#__PURE__*/jsxs("div", {
200
+ children: [t13, t14]
201
+ });
202
+ $[45] = t13;
203
+ $[46] = t14;
204
+ $[47] = t15;
205
+ } else {
206
+ t15 = $[47];
207
+ }
208
+ let t16;
209
+ if ($[48] !== t15 || $[49] !== t5) {
210
+ t16 = /*#__PURE__*/jsx(CheckboxOrRadioGroupContext.Provider, {
211
+ value: t5,
212
+ children: t15
213
+ });
214
+ $[48] = t15;
215
+ $[49] = t5;
216
+ $[50] = t16;
217
+ } else {
218
+ t16 = $[50];
219
+ }
220
+ return t16;
102
221
  };
103
- CheckboxOrRadioGroup.displayName = "CheckboxOrRadioGroup";
104
222
  var CheckboxOrRadioGroup$1 = Object.assign(CheckboxOrRadioGroup, {
105
223
  Caption: CheckboxOrRadioGroupCaption,
106
224
  Label: CheckboxOrRadioGroupLabel,
107
225
  Validation: CheckboxOrRadioGroupValidation
108
226
  });
227
+ function _temp(child) {
228
+ return /*#__PURE__*/React.isValidElement(child);
229
+ }
109
230
 
110
231
  export { CheckboxOrRadioGroup$1 as default };
@@ -1,3 +1,4 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import React from 'react';
2
3
  import CheckboxOrRadioGroupContext from './CheckboxOrRadioGroupContext.js';
3
4
  import classes from './CheckboxOrRadioGroup.module.css.js';
@@ -5,22 +6,43 @@ import { clsx } from 'clsx';
5
6
  import { jsx } from 'react/jsx-runtime';
6
7
  import Text from '../../../Text/Text.js';
7
8
 
8
- const CheckboxOrRadioGroupCaption = ({
9
- className,
10
- children
11
- }) => {
9
+ const CheckboxOrRadioGroupCaption = t0 => {
10
+ const $ = c(7);
11
+ const {
12
+ className,
13
+ children
14
+ } = t0;
12
15
  const {
13
16
  captionId,
14
17
  parentName
15
18
  } = React.useContext(CheckboxOrRadioGroupContext);
16
- return /*#__PURE__*/jsx(Text, {
17
- className: clsx(className, classes.CheckboxOrRadioGroupCaption),
18
- id: captionId,
19
- "data-component": parentName ? `${parentName}.Caption` : undefined,
20
- children: children
21
- });
19
+ let t1;
20
+ if ($[0] !== className) {
21
+ t1 = clsx(className, classes.CheckboxOrRadioGroupCaption);
22
+ $[0] = className;
23
+ $[1] = t1;
24
+ } else {
25
+ t1 = $[1];
26
+ }
27
+ const t2 = parentName ? `${parentName}.Caption` : undefined;
28
+ let t3;
29
+ if ($[2] !== captionId || $[3] !== children || $[4] !== t1 || $[5] !== t2) {
30
+ t3 = /*#__PURE__*/jsx(Text, {
31
+ className: t1,
32
+ id: captionId,
33
+ "data-component": t2,
34
+ children: children
35
+ });
36
+ $[2] = captionId;
37
+ $[3] = children;
38
+ $[4] = t1;
39
+ $[5] = t2;
40
+ $[6] = t3;
41
+ } else {
42
+ t3 = $[6];
43
+ }
44
+ return t3;
22
45
  };
23
- CheckboxOrRadioGroupCaption.displayName = "CheckboxOrRadioGroupCaption";
24
46
  CheckboxOrRadioGroupCaption.__SLOT__ = Symbol('CheckboxOrRadioGroup.Caption');
25
47
 
26
48
  export { CheckboxOrRadioGroupCaption as default };
@@ -1,28 +1,40 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import React from 'react';
2
3
  import VisuallyHidden from '../../../_VisuallyHidden.js';
3
4
  import CheckboxOrRadioGroupContext from './CheckboxOrRadioGroupContext.js';
4
5
  import classes from './CheckboxOrRadioGroup.module.css.js';
5
6
  import { Stack } from '../../../Stack/index.js';
6
7
  import { clsx } from 'clsx';
7
- import { jsx, jsxs } from 'react/jsx-runtime';
8
+ import { jsxs, jsx } from 'react/jsx-runtime';
8
9
 
9
- const CheckboxOrRadioGroupLabel = ({
10
- children,
11
- className,
12
- visuallyHidden = false
13
- }) => {
10
+ const CheckboxOrRadioGroupLabel = t0 => {
11
+ const $ = c(12);
12
+ const {
13
+ children,
14
+ className,
15
+ visuallyHidden: t1
16
+ } = t0;
17
+ const visuallyHidden = t1 === undefined ? false : t1;
14
18
  const {
15
19
  required,
16
20
  disabled,
17
21
  parentName
18
22
  } = React.useContext(CheckboxOrRadioGroupContext);
19
- return /*#__PURE__*/jsx(VisuallyHidden, {
20
- className: clsx(className, classes.RadioGroupLabel),
21
- isVisible: !visuallyHidden,
22
- title: required ? 'required field' : undefined,
23
- "data-label-disabled": disabled ? '' : undefined,
24
- "data-component": parentName ? `${parentName}.Label` : undefined,
25
- children: required ? /*#__PURE__*/jsxs(Stack, {
23
+ let t2;
24
+ if ($[0] !== className) {
25
+ t2 = clsx(className, classes.RadioGroupLabel);
26
+ $[0] = className;
27
+ $[1] = t2;
28
+ } else {
29
+ t2 = $[1];
30
+ }
31
+ const t3 = !visuallyHidden;
32
+ const t4 = required ? "required field" : undefined;
33
+ const t5 = disabled ? "" : undefined;
34
+ const t6 = parentName ? `${parentName}.Label` : undefined;
35
+ let t7;
36
+ if ($[2] !== children || $[3] !== required) {
37
+ t7 = required ? /*#__PURE__*/jsxs(Stack, {
26
38
  direction: "horizontal",
27
39
  gap: "none",
28
40
  children: [/*#__PURE__*/jsx("div", {
@@ -31,10 +43,35 @@ const CheckboxOrRadioGroupLabel = ({
31
43
  }), /*#__PURE__*/jsx("span", {
32
44
  children: "*"
33
45
  })]
34
- }) : children
35
- });
46
+ }) : children;
47
+ $[2] = children;
48
+ $[3] = required;
49
+ $[4] = t7;
50
+ } else {
51
+ t7 = $[4];
52
+ }
53
+ let t8;
54
+ if ($[5] !== t2 || $[6] !== t3 || $[7] !== t4 || $[8] !== t5 || $[9] !== t6 || $[10] !== t7) {
55
+ t8 = /*#__PURE__*/jsx(VisuallyHidden, {
56
+ className: t2,
57
+ isVisible: t3,
58
+ title: t4,
59
+ "data-label-disabled": t5,
60
+ "data-component": t6,
61
+ children: t7
62
+ });
63
+ $[5] = t2;
64
+ $[6] = t3;
65
+ $[7] = t4;
66
+ $[8] = t5;
67
+ $[9] = t6;
68
+ $[10] = t7;
69
+ $[11] = t8;
70
+ } else {
71
+ t8 = $[11];
72
+ }
73
+ return t8;
36
74
  };
37
- CheckboxOrRadioGroupLabel.displayName = "CheckboxOrRadioGroupLabel";
38
75
  CheckboxOrRadioGroupLabel.__SLOT__ = Symbol('CheckboxOrRadioGroup.Label');
39
76
 
40
77
  export { CheckboxOrRadioGroupLabel as default };
@@ -1,24 +1,39 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import React from 'react';
2
3
  import InputValidation from '../InputValidation.js';
3
4
  import CheckboxOrRadioGroupContext from './CheckboxOrRadioGroupContext.js';
4
5
  import { jsx } from 'react/jsx-runtime';
5
6
 
6
- const CheckboxOrRadioGroupValidation = ({
7
- children,
8
- variant
9
- }) => {
7
+ const CheckboxOrRadioGroupValidation = t0 => {
8
+ const $ = c(5);
10
9
  const {
11
- validationMessageId = '',
10
+ children,
11
+ variant
12
+ } = t0;
13
+ const {
14
+ validationMessageId: t1,
12
15
  parentName
13
16
  } = React.useContext(CheckboxOrRadioGroupContext);
14
- return /*#__PURE__*/jsx(InputValidation, {
15
- validationStatus: variant,
16
- id: validationMessageId,
17
- "data-component": parentName ? `${parentName}.Validation` : undefined,
18
- children: children
19
- });
17
+ const validationMessageId = t1 === undefined ? "" : t1;
18
+ const t2 = parentName ? `${parentName}.Validation` : undefined;
19
+ let t3;
20
+ if ($[0] !== children || $[1] !== t2 || $[2] !== validationMessageId || $[3] !== variant) {
21
+ t3 = /*#__PURE__*/jsx(InputValidation, {
22
+ validationStatus: variant,
23
+ id: validationMessageId,
24
+ "data-component": t2,
25
+ children: children
26
+ });
27
+ $[0] = children;
28
+ $[1] = t2;
29
+ $[2] = validationMessageId;
30
+ $[3] = variant;
31
+ $[4] = t3;
32
+ } else {
33
+ t3 = $[4];
34
+ }
35
+ return t3;
20
36
  };
21
- CheckboxOrRadioGroupValidation.displayName = "CheckboxOrRadioGroupValidation";
22
37
  CheckboxOrRadioGroupValidation.__SLOT__ = Symbol('CheckboxOrRadioGroup.Validation');
23
38
 
24
39
  export { CheckboxOrRadioGroupValidation as default };
@@ -2,7 +2,7 @@ import { c } from 'react-compiler-runtime';
2
2
  import { AlertFillIcon, CheckCircleFillIcon } from '@primer/octicons-react';
3
3
  import classes from './InputValidation.module.css.js';
4
4
  import { clsx } from 'clsx';
5
- import { jsxs, jsx } from 'react/jsx-runtime';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
6
  import Text from '../../Text/Text.js';
7
7
 
8
8
  const validationIconMap = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "38.30.1-rc.2d1806208",
4
+ "version": "38.30.1-rc.b8979ee01",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",