@primer/react 0.0.0-20260304223602 → 0.0.0-20260304232522
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 +3 -1
- package/dist/FormControl/FormControl.d.ts.map +1 -1
- package/dist/FormControl/FormControl.js +81 -64
- package/dist/FormControl/FormControlLabel.d.ts.map +1 -1
- package/dist/FormControl/FormControlLabel.js +20 -15
- package/dist/FormControl/_FormControlContext.d.ts +6 -0
- package/dist/FormControl/_FormControlContext.d.ts.map +1 -1
- package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
- package/dist/SelectPanel/SelectPanel.js +17 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260304232522
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
- Improves initial render performance for `ActionBar`
|
|
18
18
|
|
|
19
|
+
- [#7624](https://github.com/primer/react/pull/7624) [`640a24d`](https://github.com/primer/react/commit/640a24dec827ddb03209ccacf0462782881dff8d) Thanks [@llastflowers](https://github.com/llastflowers)! - Fix FormControl + SelectPanel accessible name to address SR issues
|
|
20
|
+
|
|
19
21
|
- [#7617](https://github.com/primer/react/pull/7617) [`79c855a`](https://github.com/primer/react/commit/79c855abeb6f46d3fefafb236f00ea65dfcd1ed4) Thanks [@llastflowers](https://github.com/llastflowers)! - Push margin-top of TimelineBody +1px
|
|
20
22
|
|
|
21
23
|
- [#7550](https://github.com/primer/react/pull/7550) [`9585669`](https://github.com/primer/react/commit/958566907a580b54b484ff2339b32315b8a3b4b7) Thanks [@hectahertz](https://github.com/hectahertz)! - perf(Spinner): replace Web Animations API with CSS animation-delay sync
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormControl.d.ts","sourceRoot":"","sources":["../../src/FormControl/FormControl.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAavC,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAA;AASvD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,CAAA;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"FormControl.d.ts","sourceRoot":"","sources":["../../src/FormControl/FormControl.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAavC,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAA;AASvD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,CAAA;;;;;;;;;;;;;;AAiMD,wBAME"}
|
|
@@ -25,7 +25,7 @@ import { SelectPanel } from '../SelectPanel/SelectPanel.js';
|
|
|
25
25
|
|
|
26
26
|
const FormControl = /*#__PURE__*/React.forwardRef((t0, ref) => {
|
|
27
27
|
var _slots$validation, _slots$label;
|
|
28
|
-
const $ = c(
|
|
28
|
+
const $ = c(32);
|
|
29
29
|
const {
|
|
30
30
|
children,
|
|
31
31
|
disabled: disabledProp,
|
|
@@ -60,6 +60,18 @@ const FormControl = /*#__PURE__*/React.forwardRef((t0, ref) => {
|
|
|
60
60
|
const inputProps = /*#__PURE__*/React.isValidElement(InputComponent) && InputComponent.props;
|
|
61
61
|
const isChoiceInput = /*#__PURE__*/React.isValidElement(InputComponent) && (InputComponent.type === Checkbox || InputComponent.type === Radio || isSlot(InputComponent, Checkbox) || isSlot(InputComponent, Radio));
|
|
62
62
|
const isRadioInput = /*#__PURE__*/React.isValidElement(InputComponent) && (InputComponent.type === Radio || isSlot(InputComponent, Radio));
|
|
63
|
+
const isSelectPanelInput = /*#__PURE__*/React.isValidElement(InputComponent) && (InputComponent.type === SelectPanel || isSlot(InputComponent, SelectPanel));
|
|
64
|
+
let t3;
|
|
65
|
+
if ($[1] !== id || $[2] !== slots.label) {
|
|
66
|
+
var _ref;
|
|
67
|
+
t3 = slots.label ? (_ref = /*#__PURE__*/React.isValidElement(slots.label) ? slots.label.props.id : undefined) !== null && _ref !== void 0 ? _ref : `${id}-label` : undefined;
|
|
68
|
+
$[1] = id;
|
|
69
|
+
$[2] = slots.label;
|
|
70
|
+
$[3] = t3;
|
|
71
|
+
} else {
|
|
72
|
+
t3 = $[3];
|
|
73
|
+
}
|
|
74
|
+
const labelId = t3;
|
|
63
75
|
if (InputComponent) {
|
|
64
76
|
process.env.NODE_ENV !== "production" ? warning(inputProps === null || inputProps === void 0 ? void 0 : inputProps.id, "instead of passing the 'id' prop directly to the input component, it should be passed to the parent component, <FormControl>") : void 0;
|
|
65
77
|
process.env.NODE_ENV !== "production" ? warning(inputProps === null || inputProps === void 0 ? void 0 : inputProps.disabled, "instead of passing the 'disabled' prop directly to the input component, it should be passed to the parent component, <FormControl>") : void 0;
|
|
@@ -75,92 +87,97 @@ const FormControl = /*#__PURE__*/React.forwardRef((t0, ref) => {
|
|
|
75
87
|
process.env.NODE_ENV !== "production" ? warning(!!slots.leadingVisual, "A leading visual is only rendered for a checkbox or radio form control. If you want to render a leading visual inside of your input, check if your input supports a leading visual.") : void 0;
|
|
76
88
|
}
|
|
77
89
|
const isLabelHidden = (_slots$label = slots.label) === null || _slots$label === void 0 ? void 0 : _slots$label.props.visuallyHidden;
|
|
78
|
-
const
|
|
90
|
+
const t4 = /*#__PURE__*/React.isValidElement(InputComponent) ? /*#__PURE__*/React.cloneElement(InputComponent, {
|
|
79
91
|
id,
|
|
80
92
|
disabled,
|
|
81
93
|
required: required && !isRadioInput,
|
|
82
94
|
"aria-describedby": captionId
|
|
83
95
|
}) : null;
|
|
84
|
-
let t4;
|
|
85
|
-
if ($[1] !== childrenWithoutSlots) {
|
|
86
|
-
t4 = childrenWithoutSlots.filter(_temp2);
|
|
87
|
-
$[1] = childrenWithoutSlots;
|
|
88
|
-
$[2] = t4;
|
|
89
|
-
} else {
|
|
90
|
-
t4 = $[2];
|
|
91
|
-
}
|
|
92
96
|
let t5;
|
|
93
|
-
if ($[
|
|
94
|
-
t5 =
|
|
95
|
-
|
|
96
|
-
children: [t3, t4]
|
|
97
|
-
});
|
|
98
|
-
$[3] = t3;
|
|
99
|
-
$[4] = t4;
|
|
97
|
+
if ($[4] !== childrenWithoutSlots) {
|
|
98
|
+
t5 = childrenWithoutSlots.filter(_temp2);
|
|
99
|
+
$[4] = childrenWithoutSlots;
|
|
100
100
|
$[5] = t5;
|
|
101
101
|
} else {
|
|
102
102
|
t5 = $[5];
|
|
103
103
|
}
|
|
104
104
|
let t6;
|
|
105
|
-
if ($[6] !==
|
|
106
|
-
t6 =
|
|
105
|
+
if ($[6] !== t4 || $[7] !== t5) {
|
|
106
|
+
t6 = /*#__PURE__*/jsxs("div", {
|
|
107
|
+
className: classes.ControlChoiceInputs,
|
|
108
|
+
children: [t4, t5]
|
|
109
|
+
});
|
|
110
|
+
$[6] = t4;
|
|
111
|
+
$[7] = t5;
|
|
112
|
+
$[8] = t6;
|
|
113
|
+
} else {
|
|
114
|
+
t6 = $[8];
|
|
115
|
+
}
|
|
116
|
+
let t7;
|
|
117
|
+
if ($[9] !== disabled || $[10] !== slots.caption || $[11] !== slots.leadingVisual) {
|
|
118
|
+
t7 = slots.leadingVisual ? /*#__PURE__*/jsx("div", {
|
|
107
119
|
className: classes.LeadingVisual,
|
|
108
120
|
"data-disabled": disabled ? "" : undefined,
|
|
109
121
|
"data-has-caption": slots.caption ? "" : undefined,
|
|
110
122
|
children: slots.leadingVisual
|
|
111
123
|
}) : null;
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
124
|
+
$[9] = disabled;
|
|
125
|
+
$[10] = slots.caption;
|
|
126
|
+
$[11] = slots.leadingVisual;
|
|
127
|
+
$[12] = t7;
|
|
116
128
|
} else {
|
|
117
|
-
|
|
129
|
+
t7 = $[12];
|
|
118
130
|
}
|
|
119
|
-
let
|
|
120
|
-
if ($[
|
|
121
|
-
|
|
131
|
+
let t8;
|
|
132
|
+
if ($[13] !== slots.caption || $[14] !== slots.label) {
|
|
133
|
+
t8 = /*#__PURE__*/jsxs("div", {
|
|
122
134
|
className: classes.LabelContainer,
|
|
123
135
|
children: [slots.label, slots.caption]
|
|
124
136
|
});
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
137
|
+
$[13] = slots.caption;
|
|
138
|
+
$[14] = slots.label;
|
|
139
|
+
$[15] = t8;
|
|
128
140
|
} else {
|
|
129
|
-
|
|
141
|
+
t8 = $[15];
|
|
130
142
|
}
|
|
131
|
-
let
|
|
132
|
-
if ($[
|
|
133
|
-
|
|
134
|
-
children: [
|
|
143
|
+
let t9;
|
|
144
|
+
if ($[16] !== t6 || $[17] !== t7 || $[18] !== t8) {
|
|
145
|
+
t9 = /*#__PURE__*/jsxs(Fragment, {
|
|
146
|
+
children: [t6, t7, t8]
|
|
135
147
|
});
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
148
|
+
$[16] = t6;
|
|
149
|
+
$[17] = t7;
|
|
150
|
+
$[18] = t8;
|
|
151
|
+
$[19] = t9;
|
|
140
152
|
} else {
|
|
141
|
-
|
|
153
|
+
t9 = $[19];
|
|
142
154
|
}
|
|
143
|
-
const InputChildren =
|
|
155
|
+
const InputChildren = t9;
|
|
144
156
|
const T0 = FormControlContextProvider;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
const t10 = !isSelectPanelInput;
|
|
158
|
+
let t11;
|
|
159
|
+
if ($[20] !== captionId || $[21] !== disabled || $[22] !== id || $[23] !== labelId || $[24] !== required || $[25] !== t10 || $[26] !== validationMessageId) {
|
|
160
|
+
t11 = {
|
|
148
161
|
captionId,
|
|
149
162
|
disabled,
|
|
150
163
|
id,
|
|
151
164
|
required,
|
|
152
|
-
validationMessageId
|
|
165
|
+
validationMessageId,
|
|
166
|
+
isReferenced: t10,
|
|
167
|
+
labelId
|
|
153
168
|
};
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
169
|
+
$[20] = captionId;
|
|
170
|
+
$[21] = disabled;
|
|
171
|
+
$[22] = id;
|
|
172
|
+
$[23] = labelId;
|
|
173
|
+
$[24] = required;
|
|
174
|
+
$[25] = t10;
|
|
175
|
+
$[26] = validationMessageId;
|
|
176
|
+
$[27] = t11;
|
|
160
177
|
} else {
|
|
161
|
-
|
|
178
|
+
t11 = $[27];
|
|
162
179
|
}
|
|
163
|
-
const
|
|
180
|
+
const t12 = isChoiceInput || layout === "horizontal" ? /*#__PURE__*/jsx("div", {
|
|
164
181
|
ref: ref,
|
|
165
182
|
"data-has-leading-visual": slots.leadingVisual ? "" : undefined,
|
|
166
183
|
className: clsx(className, classes.ControlHorizontalLayout),
|
|
@@ -182,20 +199,20 @@ const FormControl = /*#__PURE__*/React.forwardRef((t0, ref) => {
|
|
|
182
199
|
children: slots.validation
|
|
183
200
|
}) : null, slots.caption]
|
|
184
201
|
});
|
|
185
|
-
let
|
|
186
|
-
if ($[
|
|
187
|
-
|
|
188
|
-
value:
|
|
189
|
-
children:
|
|
202
|
+
let t13;
|
|
203
|
+
if ($[28] !== T0 || $[29] !== t11 || $[30] !== t12) {
|
|
204
|
+
t13 = /*#__PURE__*/jsx(T0, {
|
|
205
|
+
value: t11,
|
|
206
|
+
children: t12
|
|
190
207
|
});
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
208
|
+
$[28] = T0;
|
|
209
|
+
$[29] = t11;
|
|
210
|
+
$[30] = t12;
|
|
211
|
+
$[31] = t13;
|
|
195
212
|
} else {
|
|
196
|
-
|
|
213
|
+
t13 = $[31];
|
|
197
214
|
}
|
|
198
|
-
return
|
|
215
|
+
return t13;
|
|
199
216
|
});
|
|
200
217
|
var FormControl$1 = Object.assign(FormControl, {
|
|
201
218
|
__SLOT__: Symbol('FormControl'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormControlLabel.d.ts","sourceRoot":"","sources":["../../src/FormControl/FormControlLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAC,UAAU,EAAC,MAAM,mCAAmC,CAAA;AAC5D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAA;AAEpD,MAAM,MAAM,KAAK,GAAG;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,CAAA;AAED,QAAA,MAAM,gBAAgB,EAAE,gBAAgB,CACtC,KAAK,CAAC,iBAAiB,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,GAAG,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"FormControlLabel.d.ts","sourceRoot":"","sources":["../../src/FormControl/FormControlLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAC,UAAU,EAAC,MAAM,mCAAmC,CAAA;AAC5D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAA;AAEpD,MAAM,MAAM,KAAK,GAAG;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,CAAA;AAED,QAAA,MAAM,gBAAgB,EAAE,gBAAgB,CACtC,KAAK,CAAC,iBAAiB,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,GAAG,KAAK,CAAC,CAmC9F,CAAA;AAID,eAAe,gBAAgB,CAAA"}
|
|
@@ -4,7 +4,8 @@ import { InputLabel } from '../internal/components/InputLabel.js';
|
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
const FormControlLabel = t0 => {
|
|
7
|
-
|
|
7
|
+
var _id;
|
|
8
|
+
const $ = c(26);
|
|
8
9
|
let as;
|
|
9
10
|
let children;
|
|
10
11
|
let className;
|
|
@@ -51,13 +52,16 @@ const FormControlLabel = t0 => {
|
|
|
51
52
|
const {
|
|
52
53
|
disabled,
|
|
53
54
|
id: formControlId,
|
|
54
|
-
required
|
|
55
|
+
required,
|
|
56
|
+
isReferenced,
|
|
57
|
+
labelId
|
|
55
58
|
} = useFormControlContext();
|
|
59
|
+
const resolvedId = (_id = id) !== null && _id !== void 0 ? _id : labelId;
|
|
56
60
|
let t2;
|
|
57
|
-
if ($[10] !== as || $[11] !== className || $[12] !== disabled || $[13] !== formControlId || $[14] !== htmlFor || $[15] !==
|
|
61
|
+
if ($[10] !== as || $[11] !== className || $[12] !== disabled || $[13] !== formControlId || $[14] !== htmlFor || $[15] !== isReferenced || $[16] !== props || $[17] !== required || $[18] !== requiredIndicator || $[19] !== requiredText || $[20] !== resolvedId || $[21] !== visuallyHidden) {
|
|
58
62
|
t2 = as === "legend" || as === "span" ? {
|
|
59
63
|
as,
|
|
60
|
-
id,
|
|
64
|
+
id: resolvedId,
|
|
61
65
|
className,
|
|
62
66
|
visuallyHidden,
|
|
63
67
|
required,
|
|
@@ -67,10 +71,10 @@ const FormControlLabel = t0 => {
|
|
|
67
71
|
...props
|
|
68
72
|
} : {
|
|
69
73
|
as,
|
|
70
|
-
id,
|
|
74
|
+
id: resolvedId,
|
|
71
75
|
className,
|
|
72
76
|
visuallyHidden,
|
|
73
|
-
htmlFor: htmlFor || formControlId,
|
|
77
|
+
htmlFor: isReferenced === false ? undefined : htmlFor || formControlId,
|
|
74
78
|
required,
|
|
75
79
|
requiredText,
|
|
76
80
|
requiredIndicator,
|
|
@@ -82,28 +86,29 @@ const FormControlLabel = t0 => {
|
|
|
82
86
|
$[12] = disabled;
|
|
83
87
|
$[13] = formControlId;
|
|
84
88
|
$[14] = htmlFor;
|
|
85
|
-
$[15] =
|
|
89
|
+
$[15] = isReferenced;
|
|
86
90
|
$[16] = props;
|
|
87
91
|
$[17] = required;
|
|
88
92
|
$[18] = requiredIndicator;
|
|
89
93
|
$[19] = requiredText;
|
|
90
|
-
$[20] =
|
|
91
|
-
$[21] =
|
|
94
|
+
$[20] = resolvedId;
|
|
95
|
+
$[21] = visuallyHidden;
|
|
96
|
+
$[22] = t2;
|
|
92
97
|
} else {
|
|
93
|
-
t2 = $[
|
|
98
|
+
t2 = $[22];
|
|
94
99
|
}
|
|
95
100
|
const labelProps = t2;
|
|
96
101
|
let t3;
|
|
97
|
-
if ($[
|
|
102
|
+
if ($[23] !== children || $[24] !== labelProps) {
|
|
98
103
|
t3 = /*#__PURE__*/jsx(InputLabel, {
|
|
99
104
|
...labelProps,
|
|
100
105
|
children: children
|
|
101
106
|
});
|
|
102
|
-
$[
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
107
|
+
$[23] = children;
|
|
108
|
+
$[24] = labelProps;
|
|
109
|
+
$[25] = t3;
|
|
105
110
|
} else {
|
|
106
|
-
t3 = $[
|
|
111
|
+
t3 = $[25];
|
|
107
112
|
}
|
|
108
113
|
return t3;
|
|
109
114
|
};
|
|
@@ -4,6 +4,12 @@ interface FormControlContext extends Pick<FormControlProps, 'disabled' | 'id' |
|
|
|
4
4
|
captionId?: string;
|
|
5
5
|
validationMessageId?: string;
|
|
6
6
|
validationStatus?: FormValidationStatus;
|
|
7
|
+
/**
|
|
8
|
+
* Determines whether the label is referenced by a form control.
|
|
9
|
+
* This is used to determine whether the `htmlFor` attribute should be set on the label.
|
|
10
|
+
*/
|
|
11
|
+
isReferenced?: boolean;
|
|
12
|
+
labelId?: string;
|
|
7
13
|
}
|
|
8
14
|
declare const FormControlContext: import("react").Context<FormControlContext | null>;
|
|
9
15
|
export declare const FormControlContextProvider: import("react").Provider<FormControlContext | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_FormControlContext.d.ts","sourceRoot":"","sources":["../../src/FormControl/_FormControlContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,qCAAqC,CAAA;AAC7E,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAA;AAEnD,UAAU,kBAAmB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,IAAI,GAAG,UAAU,CAAC;IACzF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,gBAAgB,CAAC,EAAE,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"_FormControlContext.d.ts","sourceRoot":"","sources":["../../src/FormControl/_FormControlContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,qCAAqC,CAAA;AAC7E,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAA;AAEnD,UAAU,kBAAmB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,IAAI,GAAG,UAAU,CAAC;IACzF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,gBAAgB,CAAC,EAAE,oBAAoB,CAAA;IAEvC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,QAAA,MAAM,kBAAkB,oDAAiD,CAAA;AAEzE,eAAO,MAAM,0BAA0B,qDAA8B,CAAA;AAErE,iFAAiF;AACjF,wBAAgB,qBAAqB,IAAI,kBAAkB,CAE1D;AAED,UAAU,yBAA0B,SAAQ,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,IAAI,GAAG,UAAU,CAAC;IAChG,CAAC,kBAAkB,CAAC,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,GAAG,CAAC,GAAG,yBAAyB,CAW/F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPanel.d.ts","sourceRoot":"","sources":["../../src/SelectPanel/S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EACN,KAAK,EACL,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,OAAoB,EACpB,eAAe,EACf,wBAA+B,EAC/B,yBAAyB,EACzB,KAAK,EACL,aAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,GAAG,SAAS,EACb,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CA0yBhC;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAM1C,CAAA;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,GAAG,WAAW,CAM1D,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;CAItB,CAAA"}
|
|
@@ -15,7 +15,8 @@ import { debounce } from '@github/mini-throttle';
|
|
|
15
15
|
import { useResponsiveValue } from '../hooks/useResponsiveValue.js';
|
|
16
16
|
import { Banner } from '../Banner/index.js';
|
|
17
17
|
import { isAlphabetKey } from '../hooks/useMnemonics.js';
|
|
18
|
-
import {
|
|
18
|
+
import { useFormControlContext } from '../FormControl/_FormControlContext.js';
|
|
19
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
20
|
import { useFeatureFlag } from '../FeatureFlags/useFeatureFlag.js';
|
|
20
21
|
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
|
|
21
22
|
import { AnchoredOverlay } from '../AnchoredOverlay/AnchoredOverlay.js';
|
|
@@ -142,6 +143,11 @@ function Panel({
|
|
|
142
143
|
const featureFlagFullScreenOnNarrow = useFeatureFlag('primer_react_select_panel_fullscreen_on_narrow');
|
|
143
144
|
const usingFullScreenOnNarrow = disableFullscreenOnNarrow ? false : featureFlagFullScreenOnNarrow;
|
|
144
145
|
const shouldOrderSelectedFirst = useFeatureFlag('primer_react_select_panel_order_selected_at_top') && showSelectedOptionsFirst;
|
|
146
|
+
const {
|
|
147
|
+
isReferenced,
|
|
148
|
+
labelId
|
|
149
|
+
} = useFormControlContext();
|
|
150
|
+
const selectedValueId = id ? `${id}-selected-value` : undefined;
|
|
145
151
|
|
|
146
152
|
// Single select modals work differently, they have an intermediate state where the user has selected an item but
|
|
147
153
|
// has not yet confirmed the selection. This is the only time the user can cancel the selection.
|
|
@@ -396,13 +402,21 @@ function Panel({
|
|
|
396
402
|
return null;
|
|
397
403
|
}
|
|
398
404
|
const selectedItems = Array.isArray(selected) ? selected : [...(selected ? [selected] : [])];
|
|
405
|
+
const selectedValueText = selectedItems.length ? selectedItems.map(item => item.text).join(', ') : placeholder;
|
|
406
|
+
const shouldAutoWireLabel = isReferenced === false && Boolean(labelId) && Boolean(selectedValueId);
|
|
399
407
|
return props => {
|
|
400
408
|
return renderAnchor({
|
|
401
409
|
...props,
|
|
402
|
-
|
|
410
|
+
...(shouldAutoWireLabel ? {
|
|
411
|
+
'aria-labelledby': [labelId, selectedValueId].filter(Boolean).join(' ')
|
|
412
|
+
} : {}),
|
|
413
|
+
children: shouldAutoWireLabel ? /*#__PURE__*/jsx("span", {
|
|
414
|
+
id: selectedValueId,
|
|
415
|
+
children: selectedValueText
|
|
416
|
+
}) : selectedValueText
|
|
403
417
|
});
|
|
404
418
|
};
|
|
405
|
-
}, [placeholder, renderAnchor, selected]);
|
|
419
|
+
}, [placeholder, renderAnchor, selected, isReferenced, labelId, selectedValueId]);
|
|
406
420
|
|
|
407
421
|
// Pre-compute a Set of selected item IDs/references for O(1) lookups
|
|
408
422
|
// This optimizes isItemCurrentlySelected from O(m) to O(1) per call
|
package/package.json
CHANGED