@primer/react 38.32.0-rc.5a40d42f8 → 38.32.0-rc.7fd08e0cc
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
|
@@ -21,14 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
- [#8115](https://github.com/primer/react/pull/8115) [`07c530a`](https://github.com/primer/react/commit/07c530a1686ef16b68b2f2fe692b7a3327bdc02b) Thanks [@mattcosta7](https://github.com/mattcosta7)! - Improve rendering performance in Safari by removing expensive `:has()` selectors from ActionList/NavList, Breadcrumbs, SelectPanel, and SegmentedControl. No visual or API changes.
|
|
23
23
|
|
|
24
|
-
- [#8024](https://github.com/primer/react/pull/8024) [`18e3b7d`](https://github.com/primer/react/commit/18e3b7d7a7b54275b99d2562eb279722f5cdd60e) Thanks [@mattcosta7](https://github.com/mattcosta7)! - ToggleSwitch: Fire `onChange` from the user interaction instead of an effect, so it no longer fires on mount or when a controlled `checked` value changes externally.
|
|
25
|
-
|
|
26
24
|
- [#8035](https://github.com/primer/react/pull/8035) [`723f4d6`](https://github.com/primer/react/commit/723f4d6db12710e2b94f56b945a937158fcbb127) Thanks [@mattcosta7](https://github.com/mattcosta7)! - UnderlineNav, ActionBar: Detect item overflow with a single shared IntersectionObserver per component instead of one observer per item, reducing observer churn during resize. No public API changes.
|
|
27
25
|
|
|
28
|
-
- [#8001](https://github.com/primer/react/pull/8001) [`4edc824`](https://github.com/primer/react/commit/4edc8242da557eedd41d71b242674b33254029ec) Thanks [@mattcosta7](https://github.com/mattcosta7)! - `useMedia` now reads the live `matchMedia` value on the first client render instead of after an effect, removing a redundant render pass. `defaultState` is only used for the SSR/hydration snapshot (no public API changes).
|
|
29
|
-
|
|
30
|
-
- [#8023](https://github.com/primer/react/pull/8023) [`71fa75c`](https://github.com/primer/react/commit/71fa75c861c55bf29dd30ddf4a83549bf81369f8) Thanks [@mattcosta7](https://github.com/mattcosta7)! - FormControl: Avoid an extra re-render when showing a validation message.
|
|
31
|
-
|
|
32
26
|
## 38.31.0
|
|
33
27
|
|
|
34
28
|
### Minor Changes
|
|
@@ -72,7 +72,7 @@ const LineIcon = (t0) => {
|
|
|
72
72
|
};
|
|
73
73
|
const ToggleSwitch = /*#__PURE__*/ React.forwardRef(function ToggleSwitch(props, ref) {
|
|
74
74
|
var _buttonLabelOn, _buttonLabelOff;
|
|
75
|
-
const $ = c(
|
|
75
|
+
const $ = c(95);
|
|
76
76
|
let ariaDescribedby;
|
|
77
77
|
let ariaLabelledby;
|
|
78
78
|
let buttonLabelOff;
|
|
@@ -141,74 +141,93 @@ const ToggleSwitch = /*#__PURE__*/ React.forwardRef(function ToggleSwitch(props,
|
|
|
141
141
|
const loadingLabelId = useId$1("loadingLabel");
|
|
142
142
|
const { safeSetTimeout } = useSafeTimeout();
|
|
143
143
|
let t5;
|
|
144
|
-
if ($[18] !== disabled || $[19] !== isControlled || $[20] !== isOn || $[21] !== loading || $[22] !==
|
|
144
|
+
if ($[18] !== disabled || $[19] !== isControlled || $[20] !== isOn || $[21] !== loading || $[22] !== onClick || $[23] !== setIsOn) {
|
|
145
145
|
t5 = (e) => {
|
|
146
146
|
if (disabled || loading) return;
|
|
147
|
-
if (isControlled)
|
|
148
|
-
var _onChange;
|
|
149
|
-
(_onChange = onChange) === null || _onChange === void 0 || _onChange(!isOn);
|
|
150
|
-
} else setIsOn(!isOn);
|
|
147
|
+
if (!isControlled) setIsOn(!isOn);
|
|
151
148
|
onClick && onClick(e);
|
|
152
149
|
};
|
|
153
150
|
$[18] = disabled;
|
|
154
151
|
$[19] = isControlled;
|
|
155
152
|
$[20] = isOn;
|
|
156
153
|
$[21] = loading;
|
|
157
|
-
$[22] =
|
|
158
|
-
$[23] =
|
|
159
|
-
$[24] =
|
|
160
|
-
|
|
161
|
-
} else t5 = $[25];
|
|
154
|
+
$[22] = onClick;
|
|
155
|
+
$[23] = setIsOn;
|
|
156
|
+
$[24] = t5;
|
|
157
|
+
} else t5 = $[24];
|
|
162
158
|
const handleToggleClick = t5;
|
|
163
159
|
let t6;
|
|
164
160
|
let t7;
|
|
165
|
-
if ($[
|
|
161
|
+
if ($[25] !== checked || $[26] !== disabled || $[27] !== isControlled || $[28] !== onChange) {
|
|
166
162
|
t6 = () => {
|
|
163
|
+
if (onChange && isControlled && !disabled) onChange(Boolean(checked));
|
|
164
|
+
};
|
|
165
|
+
t7 = [
|
|
166
|
+
onChange,
|
|
167
|
+
checked,
|
|
168
|
+
isControlled,
|
|
169
|
+
disabled
|
|
170
|
+
];
|
|
171
|
+
$[25] = checked;
|
|
172
|
+
$[26] = disabled;
|
|
173
|
+
$[27] = isControlled;
|
|
174
|
+
$[28] = onChange;
|
|
175
|
+
$[29] = t6;
|
|
176
|
+
$[30] = t7;
|
|
177
|
+
} else {
|
|
178
|
+
t6 = $[29];
|
|
179
|
+
t7 = $[30];
|
|
180
|
+
}
|
|
181
|
+
useEffect(t6, t7);
|
|
182
|
+
let t8;
|
|
183
|
+
let t9;
|
|
184
|
+
if ($[31] !== isLoadingLabelVisible || $[32] !== loading || $[33] !== loadingLabelDelay || $[34] !== safeSetTimeout) {
|
|
185
|
+
t8 = () => {
|
|
167
186
|
if (!loading && isLoadingLabelVisible) setIsLoadingLabelVisible(false);
|
|
168
187
|
else if (loading && !isLoadingLabelVisible) safeSetTimeout(() => {
|
|
169
188
|
setIsLoadingLabelVisible(true);
|
|
170
189
|
}, loadingLabelDelay);
|
|
171
190
|
};
|
|
172
|
-
|
|
191
|
+
t9 = [
|
|
173
192
|
loading,
|
|
174
193
|
isLoadingLabelVisible,
|
|
175
194
|
loadingLabelDelay,
|
|
176
195
|
safeSetTimeout
|
|
177
196
|
];
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
197
|
+
$[31] = isLoadingLabelVisible;
|
|
198
|
+
$[32] = loading;
|
|
199
|
+
$[33] = loadingLabelDelay;
|
|
200
|
+
$[34] = safeSetTimeout;
|
|
201
|
+
$[35] = t8;
|
|
202
|
+
$[36] = t9;
|
|
184
203
|
} else {
|
|
185
|
-
|
|
186
|
-
|
|
204
|
+
t8 = $[35];
|
|
205
|
+
t9 = $[36];
|
|
187
206
|
}
|
|
188
|
-
useEffect(
|
|
207
|
+
useEffect(t8, t9);
|
|
189
208
|
let switchButtonDescribedBy = loadingLabelId;
|
|
190
209
|
if (ariaDescribedby) switchButtonDescribedBy = `${switchButtonDescribedBy} ${ariaDescribedby}`;
|
|
191
|
-
let t8;
|
|
192
|
-
if ($[32] !== className) {
|
|
193
|
-
t8 = clsx(ToggleSwitch_module_css_default.ToggleSwitch, className);
|
|
194
|
-
$[32] = className;
|
|
195
|
-
$[33] = t8;
|
|
196
|
-
} else t8 = $[33];
|
|
197
|
-
const t9 = isLoadingLabelVisible && loadingLabel;
|
|
198
210
|
let t10;
|
|
199
|
-
if ($[
|
|
200
|
-
t10 =
|
|
211
|
+
if ($[37] !== className) {
|
|
212
|
+
t10 = clsx(ToggleSwitch_module_css_default.ToggleSwitch, className);
|
|
213
|
+
$[37] = className;
|
|
214
|
+
$[38] = t10;
|
|
215
|
+
} else t10 = $[38];
|
|
216
|
+
const t11 = isLoadingLabelVisible && loadingLabel;
|
|
217
|
+
let t12;
|
|
218
|
+
if ($[39] !== loadingLabelId || $[40] !== t11) {
|
|
219
|
+
t12 = /*#__PURE__*/ jsx(VisuallyHidden, { children: /*#__PURE__*/ jsx(AriaStatus, {
|
|
201
220
|
announceOnShow: true,
|
|
202
221
|
id: loadingLabelId,
|
|
203
|
-
children:
|
|
222
|
+
children: t11
|
|
204
223
|
}) });
|
|
205
|
-
$[
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
} else
|
|
209
|
-
let
|
|
210
|
-
if ($[
|
|
211
|
-
|
|
224
|
+
$[39] = loadingLabelId;
|
|
225
|
+
$[40] = t11;
|
|
226
|
+
$[41] = t12;
|
|
227
|
+
} else t12 = $[41];
|
|
228
|
+
let t13;
|
|
229
|
+
if ($[42] !== loading || $[43] !== statusLabelPosition) {
|
|
230
|
+
t13 = loading ? /*#__PURE__*/ jsx("div", {
|
|
212
231
|
className: ToggleSwitch_module_css_default.LoadingSpinner,
|
|
213
232
|
"data-status-label-position": statusLabelPosition,
|
|
214
233
|
children: /*#__PURE__*/ jsx(Spinner, {
|
|
@@ -216,172 +235,172 @@ const ToggleSwitch = /*#__PURE__*/ React.forwardRef(function ToggleSwitch(props,
|
|
|
216
235
|
srText: null
|
|
217
236
|
})
|
|
218
237
|
}) : null;
|
|
219
|
-
$[
|
|
220
|
-
$[
|
|
221
|
-
$[
|
|
222
|
-
} else
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
let t15;
|
|
227
|
-
if ($[40] !== t13 || $[41] !== t14) {
|
|
228
|
-
t15 = /*#__PURE__*/ jsx("span", {
|
|
229
|
-
className: ToggleSwitch_module_css_default.StatusTextItem,
|
|
230
|
-
"data-hidden": t13,
|
|
231
|
-
children: t14
|
|
232
|
-
});
|
|
233
|
-
$[40] = t13;
|
|
234
|
-
$[41] = t14;
|
|
235
|
-
$[42] = t15;
|
|
236
|
-
} else t15 = $[42];
|
|
237
|
-
const t16 = (_buttonLabelOff = buttonLabelOff) !== null && _buttonLabelOff !== void 0 ? _buttonLabelOff : "Off";
|
|
238
|
+
$[42] = loading;
|
|
239
|
+
$[43] = statusLabelPosition;
|
|
240
|
+
$[44] = t13;
|
|
241
|
+
} else t13 = $[44];
|
|
242
|
+
const t14 = !acceptsInteraction;
|
|
243
|
+
const t15 = !isOn;
|
|
244
|
+
const t16 = (_buttonLabelOn = buttonLabelOn) !== null && _buttonLabelOn !== void 0 ? _buttonLabelOn : "On";
|
|
238
245
|
let t17;
|
|
239
|
-
if ($[
|
|
246
|
+
if ($[45] !== t15 || $[46] !== t16) {
|
|
240
247
|
t17 = /*#__PURE__*/ jsx("span", {
|
|
241
248
|
className: ToggleSwitch_module_css_default.StatusTextItem,
|
|
242
|
-
"data-hidden":
|
|
249
|
+
"data-hidden": t15,
|
|
243
250
|
children: t16
|
|
244
251
|
});
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
} else t17 = $[
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
+
$[45] = t15;
|
|
253
|
+
$[46] = t16;
|
|
254
|
+
$[47] = t17;
|
|
255
|
+
} else t17 = $[47];
|
|
256
|
+
const t18 = (_buttonLabelOff = buttonLabelOff) !== null && _buttonLabelOff !== void 0 ? _buttonLabelOff : "Off";
|
|
257
|
+
let t19;
|
|
258
|
+
if ($[48] !== isOn || $[49] !== t18) {
|
|
259
|
+
t19 = /*#__PURE__*/ jsx("span", {
|
|
260
|
+
className: ToggleSwitch_module_css_default.StatusTextItem,
|
|
261
|
+
"data-hidden": isOn,
|
|
262
|
+
children: t18
|
|
263
|
+
});
|
|
264
|
+
$[48] = isOn;
|
|
265
|
+
$[49] = t18;
|
|
266
|
+
$[50] = t19;
|
|
267
|
+
} else t19 = $[50];
|
|
268
|
+
let t20;
|
|
269
|
+
if ($[51] !== handleToggleClick || $[52] !== size || $[53] !== t14 || $[54] !== t17 || $[55] !== t19) {
|
|
270
|
+
t20 = /*#__PURE__*/ jsxs("span", {
|
|
252
271
|
className: ToggleSwitch_module_css_default.StatusText,
|
|
253
272
|
"data-size": size,
|
|
254
|
-
"data-disabled":
|
|
273
|
+
"data-disabled": t14,
|
|
255
274
|
"aria-hidden": "true",
|
|
256
275
|
onClick: handleToggleClick,
|
|
257
|
-
children: [
|
|
276
|
+
children: [t17, t19]
|
|
258
277
|
});
|
|
259
|
-
$[
|
|
260
|
-
$[47] = size;
|
|
261
|
-
$[48] = t12;
|
|
262
|
-
$[49] = t15;
|
|
263
|
-
$[50] = t17;
|
|
264
|
-
$[51] = t18;
|
|
265
|
-
} else t18 = $[51];
|
|
266
|
-
const t19 = !acceptsInteraction;
|
|
267
|
-
const t20 = isLoadingLabelVisible || ariaDescribedby ? switchButtonDescribedBy : void 0;
|
|
268
|
-
const t21 = !acceptsInteraction;
|
|
269
|
-
const t22 = !acceptsInteraction;
|
|
270
|
-
let t23;
|
|
271
|
-
if ($[52] !== size) {
|
|
272
|
-
t23 = /*#__PURE__*/ jsx(LineIcon, { size });
|
|
278
|
+
$[51] = handleToggleClick;
|
|
273
279
|
$[52] = size;
|
|
274
|
-
$[53] =
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
$[
|
|
287
|
-
$[
|
|
288
|
-
} else
|
|
289
|
-
const t25 = !acceptsInteraction;
|
|
280
|
+
$[53] = t14;
|
|
281
|
+
$[54] = t17;
|
|
282
|
+
$[55] = t19;
|
|
283
|
+
$[56] = t20;
|
|
284
|
+
} else t20 = $[56];
|
|
285
|
+
const t21 = !acceptsInteraction;
|
|
286
|
+
const t22 = isLoadingLabelVisible || ariaDescribedby ? switchButtonDescribedBy : void 0;
|
|
287
|
+
const t23 = !acceptsInteraction;
|
|
288
|
+
const t24 = !acceptsInteraction;
|
|
289
|
+
let t25;
|
|
290
|
+
if ($[57] !== size) {
|
|
291
|
+
t25 = /*#__PURE__*/ jsx(LineIcon, { size });
|
|
292
|
+
$[57] = size;
|
|
293
|
+
$[58] = t25;
|
|
294
|
+
} else t25 = $[58];
|
|
290
295
|
let t26;
|
|
291
|
-
if ($[
|
|
292
|
-
t26 = /*#__PURE__*/ jsx(
|
|
293
|
-
|
|
294
|
-
$[59] = t26;
|
|
295
|
-
} else t26 = $[59];
|
|
296
|
-
let t27;
|
|
297
|
-
if ($[60] !== isOn || $[61] !== t25 || $[62] !== t26) {
|
|
298
|
-
t27 = /*#__PURE__*/ jsx("div", {
|
|
299
|
-
className: `${ToggleSwitch_module_css_default.IconContainer} ${ToggleSwitch_module_css_default.CircleIconContainer}`,
|
|
296
|
+
if ($[59] !== isOn || $[60] !== t24 || $[61] !== t25) {
|
|
297
|
+
t26 = /*#__PURE__*/ jsx("div", {
|
|
298
|
+
className: `${ToggleSwitch_module_css_default.IconContainer} ${ToggleSwitch_module_css_default.LineIconContainer}`,
|
|
300
299
|
"data-checked": isOn,
|
|
301
|
-
"data-disabled":
|
|
302
|
-
children:
|
|
300
|
+
"data-disabled": t24,
|
|
301
|
+
children: t25
|
|
303
302
|
});
|
|
304
|
-
$[
|
|
303
|
+
$[59] = isOn;
|
|
304
|
+
$[60] = t24;
|
|
305
305
|
$[61] = t25;
|
|
306
306
|
$[62] = t26;
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
} else t26 = $[62];
|
|
308
|
+
const t27 = !acceptsInteraction;
|
|
309
309
|
let t28;
|
|
310
|
-
if ($[
|
|
311
|
-
t28 = /*#__PURE__*/
|
|
310
|
+
if ($[63] !== size) {
|
|
311
|
+
t28 = /*#__PURE__*/ jsx(CircleIcon, { size });
|
|
312
|
+
$[63] = size;
|
|
313
|
+
$[64] = t28;
|
|
314
|
+
} else t28 = $[64];
|
|
315
|
+
let t29;
|
|
316
|
+
if ($[65] !== isOn || $[66] !== t27 || $[67] !== t28) {
|
|
317
|
+
t29 = /*#__PURE__*/ jsx("div", {
|
|
318
|
+
className: `${ToggleSwitch_module_css_default.IconContainer} ${ToggleSwitch_module_css_default.CircleIconContainer}`,
|
|
319
|
+
"data-checked": isOn,
|
|
320
|
+
"data-disabled": t27,
|
|
321
|
+
children: t28
|
|
322
|
+
});
|
|
323
|
+
$[65] = isOn;
|
|
324
|
+
$[66] = t27;
|
|
325
|
+
$[67] = t28;
|
|
326
|
+
$[68] = t29;
|
|
327
|
+
} else t29 = $[68];
|
|
328
|
+
let t30;
|
|
329
|
+
if ($[69] !== t26 || $[70] !== t29) {
|
|
330
|
+
t30 = /*#__PURE__*/ jsxs("div", {
|
|
312
331
|
className: ToggleSwitch_module_css_default.SwitchButtonContent,
|
|
313
332
|
"aria-hidden": "true",
|
|
314
|
-
children: [
|
|
333
|
+
children: [t26, t29]
|
|
315
334
|
});
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
319
|
-
} else
|
|
320
|
-
const
|
|
321
|
-
let
|
|
322
|
-
if ($[
|
|
323
|
-
|
|
335
|
+
$[69] = t26;
|
|
336
|
+
$[70] = t29;
|
|
337
|
+
$[71] = t30;
|
|
338
|
+
} else t30 = $[71];
|
|
339
|
+
const t31 = !acceptsInteraction;
|
|
340
|
+
let t32;
|
|
341
|
+
if ($[72] !== isOn || $[73] !== t31) {
|
|
342
|
+
t32 = /*#__PURE__*/ jsx("div", {
|
|
324
343
|
className: ToggleSwitch_module_css_default.ToggleKnob,
|
|
325
344
|
"data-checked": isOn,
|
|
326
|
-
"data-disabled":
|
|
345
|
+
"data-disabled": t31,
|
|
327
346
|
"aria-hidden": "true"
|
|
328
347
|
});
|
|
329
|
-
$[
|
|
330
|
-
$[
|
|
331
|
-
$[
|
|
332
|
-
} else
|
|
333
|
-
let
|
|
334
|
-
if ($[
|
|
335
|
-
|
|
348
|
+
$[72] = isOn;
|
|
349
|
+
$[73] = t31;
|
|
350
|
+
$[74] = t32;
|
|
351
|
+
} else t32 = $[74];
|
|
352
|
+
let t33;
|
|
353
|
+
if ($[75] !== ariaLabelledby || $[76] !== buttonType || $[77] !== handleToggleClick || $[78] !== isOn || $[79] !== ref || $[80] !== size || $[81] !== t21 || $[82] !== t22 || $[83] !== t23 || $[84] !== t30 || $[85] !== t32) {
|
|
354
|
+
t33 = /*#__PURE__*/ jsxs("button", {
|
|
336
355
|
ref,
|
|
337
356
|
type: buttonType,
|
|
338
357
|
className: ToggleSwitch_module_css_default.SwitchButton,
|
|
339
358
|
"data-size": size,
|
|
340
359
|
"data-checked": isOn,
|
|
341
|
-
"data-disabled":
|
|
360
|
+
"data-disabled": t21,
|
|
342
361
|
onClick: handleToggleClick,
|
|
343
362
|
"aria-labelledby": ariaLabelledby,
|
|
344
|
-
"aria-describedby":
|
|
363
|
+
"aria-describedby": t22,
|
|
345
364
|
"aria-pressed": isOn,
|
|
346
|
-
"aria-disabled":
|
|
347
|
-
children: [
|
|
365
|
+
"aria-disabled": t23,
|
|
366
|
+
children: [t30, t32]
|
|
348
367
|
});
|
|
349
|
-
$[
|
|
350
|
-
$[
|
|
351
|
-
$[
|
|
352
|
-
$[
|
|
353
|
-
$[
|
|
354
|
-
$[
|
|
355
|
-
$[
|
|
356
|
-
$[
|
|
357
|
-
$[
|
|
358
|
-
$[
|
|
359
|
-
$[
|
|
360
|
-
$[
|
|
361
|
-
} else
|
|
362
|
-
let
|
|
363
|
-
if ($[
|
|
364
|
-
|
|
365
|
-
className:
|
|
368
|
+
$[75] = ariaLabelledby;
|
|
369
|
+
$[76] = buttonType;
|
|
370
|
+
$[77] = handleToggleClick;
|
|
371
|
+
$[78] = isOn;
|
|
372
|
+
$[79] = ref;
|
|
373
|
+
$[80] = size;
|
|
374
|
+
$[81] = t21;
|
|
375
|
+
$[82] = t22;
|
|
376
|
+
$[83] = t23;
|
|
377
|
+
$[84] = t30;
|
|
378
|
+
$[85] = t32;
|
|
379
|
+
$[86] = t33;
|
|
380
|
+
} else t33 = $[86];
|
|
381
|
+
let t34;
|
|
382
|
+
if ($[87] !== rest || $[88] !== statusLabelPosition || $[89] !== t10 || $[90] !== t12 || $[91] !== t13 || $[92] !== t20 || $[93] !== t33) {
|
|
383
|
+
t34 = /*#__PURE__*/ jsxs("div", {
|
|
384
|
+
className: t10,
|
|
366
385
|
"data-status-label-position": statusLabelPosition,
|
|
367
386
|
...rest,
|
|
368
387
|
children: [
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
388
|
+
t12,
|
|
389
|
+
t13,
|
|
390
|
+
t20,
|
|
391
|
+
t33
|
|
373
392
|
]
|
|
374
393
|
});
|
|
375
|
-
$[
|
|
376
|
-
$[
|
|
377
|
-
$[
|
|
378
|
-
$[
|
|
379
|
-
$[
|
|
380
|
-
$[
|
|
381
|
-
$[
|
|
382
|
-
$[
|
|
383
|
-
} else
|
|
384
|
-
return
|
|
394
|
+
$[87] = rest;
|
|
395
|
+
$[88] = statusLabelPosition;
|
|
396
|
+
$[89] = t10;
|
|
397
|
+
$[90] = t12;
|
|
398
|
+
$[91] = t13;
|
|
399
|
+
$[92] = t20;
|
|
400
|
+
$[93] = t33;
|
|
401
|
+
$[94] = t34;
|
|
402
|
+
} else t34 = $[94];
|
|
403
|
+
return t34;
|
|
385
404
|
});
|
|
386
405
|
ToggleSwitch.displayName = "ToggleSwitch";
|
|
387
406
|
//#endregion
|
package/dist/hooks/useMedia.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { canUseDOM } from "../utils/environment.js";
|
|
1
2
|
import { warning } from "../utils/warning.js";
|
|
2
3
|
import { MatchMediaContext } from "./MatchMediaContext.js";
|
|
3
4
|
import { c } from "react-compiler-runtime";
|
|
4
|
-
import { useContext,
|
|
5
|
+
import React, { useContext, useEffect } from "react";
|
|
5
6
|
//#region src/hooks/useMedia.ts
|
|
6
7
|
/**
|
|
7
8
|
* `useMedia` will use the given `mediaQueryString` with `matchMedia` to
|
|
@@ -17,54 +18,52 @@ import { useContext, useSyncExternalStore } from "react";
|
|
|
17
18
|
* }
|
|
18
19
|
*/
|
|
19
20
|
function useMedia(mediaQueryString, defaultState) {
|
|
20
|
-
const $ = c(
|
|
21
|
-
const
|
|
21
|
+
const $ = c(8);
|
|
22
|
+
const features = useContext(MatchMediaContext);
|
|
22
23
|
let t0;
|
|
23
|
-
if ($[0] !==
|
|
24
|
-
t0 = (
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
mediaQueryList.removeEventListener("change", onStoreChange);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
mediaQueryList.addListener(onStoreChange);
|
|
34
|
-
return () => {
|
|
35
|
-
mediaQueryList.removeListener(onStoreChange);
|
|
36
|
-
};
|
|
24
|
+
if ($[0] !== defaultState || $[1] !== features || $[2] !== mediaQueryString) {
|
|
25
|
+
t0 = () => {
|
|
26
|
+
if (features[mediaQueryString] !== void 0) return features[mediaQueryString];
|
|
27
|
+
if (defaultState !== void 0) return defaultState;
|
|
28
|
+
if (canUseDOM) return window.matchMedia(mediaQueryString).matches;
|
|
29
|
+
warning(true, "`useMedia` When server side rendering, defaultState should be defined to prevent a hydration mismatches.");
|
|
30
|
+
return false;
|
|
37
31
|
};
|
|
38
|
-
$[0] =
|
|
39
|
-
$[1] =
|
|
40
|
-
$[2] =
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
$[0] = defaultState;
|
|
33
|
+
$[1] = features;
|
|
34
|
+
$[2] = mediaQueryString;
|
|
35
|
+
$[3] = t0;
|
|
36
|
+
} else t0 = $[3];
|
|
37
|
+
const [matches, setMatches] = React.useState(t0);
|
|
38
|
+
if (features[mediaQueryString] !== void 0 && matches !== features[mediaQueryString]) setMatches(features[mediaQueryString]);
|
|
43
39
|
let t1;
|
|
44
|
-
if ($[3] !== contextValue || $[4] !== mediaQueryString) {
|
|
45
|
-
t1 = () => {
|
|
46
|
-
if (contextValue !== void 0) return contextValue;
|
|
47
|
-
return window.matchMedia(mediaQueryString).matches;
|
|
48
|
-
};
|
|
49
|
-
$[3] = contextValue;
|
|
50
|
-
$[4] = mediaQueryString;
|
|
51
|
-
$[5] = t1;
|
|
52
|
-
} else t1 = $[5];
|
|
53
|
-
const getSnapshot = t1;
|
|
54
40
|
let t2;
|
|
55
|
-
if ($[
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
if ($[4] !== features || $[5] !== mediaQueryString) {
|
|
42
|
+
t1 = () => {
|
|
43
|
+
if (features[mediaQueryString] !== void 0) return;
|
|
44
|
+
const listener = function listener(event) {
|
|
45
|
+
setMatches(event.matches);
|
|
46
|
+
};
|
|
47
|
+
const mediaQueryList = window.matchMedia(mediaQueryString);
|
|
48
|
+
if (mediaQueryList.addEventListener) mediaQueryList.addEventListener("change", listener);
|
|
49
|
+
else mediaQueryList.addListener(listener);
|
|
50
|
+
setMatches(mediaQueryList.matches);
|
|
51
|
+
return () => {
|
|
52
|
+
if (mediaQueryList.addEventListener) mediaQueryList.removeEventListener("change", listener);
|
|
53
|
+
else mediaQueryList.removeListener(listener);
|
|
54
|
+
};
|
|
61
55
|
};
|
|
62
|
-
|
|
63
|
-
$[
|
|
64
|
-
$[
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
t2 = [features, mediaQueryString];
|
|
57
|
+
$[4] = features;
|
|
58
|
+
$[5] = mediaQueryString;
|
|
59
|
+
$[6] = t1;
|
|
60
|
+
$[7] = t2;
|
|
61
|
+
} else {
|
|
62
|
+
t1 = $[6];
|
|
63
|
+
t2 = $[7];
|
|
64
|
+
}
|
|
65
|
+
useEffect(t1, t2);
|
|
66
|
+
return matches;
|
|
67
67
|
}
|
|
68
|
-
function _temp() {}
|
|
69
68
|
//#endregion
|
|
70
69
|
export { useMedia };
|
|
@@ -1,44 +1,40 @@
|
|
|
1
1
|
import ValidationAnimationContainer_module_css_default from "./ValidationAnimationContainer.module.css.js";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { useState } from "react";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
5
|
//#region src/internal/components/ValidationAnimationContainer.tsx
|
|
6
6
|
const ValidationAnimationContainer = (t0) => {
|
|
7
|
-
const $ = c(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let show;
|
|
11
|
-
let style;
|
|
12
|
-
if ($[0] !== t0) {
|
|
13
|
-
({show, children, style, ...rest} = t0);
|
|
14
|
-
$[0] = t0;
|
|
15
|
-
$[1] = children;
|
|
16
|
-
$[2] = rest;
|
|
17
|
-
$[3] = show;
|
|
18
|
-
$[4] = style;
|
|
19
|
-
} else {
|
|
20
|
-
children = $[1];
|
|
21
|
-
rest = $[2];
|
|
22
|
-
show = $[3];
|
|
23
|
-
style = $[4];
|
|
24
|
-
}
|
|
25
|
-
const [shouldRender, setRender] = useState(Boolean(show));
|
|
26
|
-
if (show && !shouldRender) setRender(true);
|
|
7
|
+
const $ = c(10);
|
|
8
|
+
const { show, children } = t0;
|
|
9
|
+
const [shouldRender, setRender] = useState(show);
|
|
27
10
|
let t1;
|
|
28
|
-
|
|
11
|
+
let t2;
|
|
12
|
+
if ($[0] !== show) {
|
|
29
13
|
t1 = () => {
|
|
14
|
+
if (show) setRender(true);
|
|
15
|
+
};
|
|
16
|
+
t2 = [show];
|
|
17
|
+
$[0] = show;
|
|
18
|
+
$[1] = t1;
|
|
19
|
+
$[2] = t2;
|
|
20
|
+
} else {
|
|
21
|
+
t1 = $[1];
|
|
22
|
+
t2 = $[2];
|
|
23
|
+
}
|
|
24
|
+
useEffect(t1, t2);
|
|
25
|
+
let t3;
|
|
26
|
+
if ($[3] !== show) {
|
|
27
|
+
t3 = () => {
|
|
30
28
|
if (!show) setRender(false);
|
|
31
29
|
};
|
|
32
|
-
$[
|
|
33
|
-
$[
|
|
34
|
-
} else
|
|
35
|
-
const onAnimationEnd =
|
|
36
|
-
let
|
|
37
|
-
if ($[
|
|
38
|
-
|
|
39
|
-
...rest,
|
|
30
|
+
$[3] = show;
|
|
31
|
+
$[4] = t3;
|
|
32
|
+
} else t3 = $[4];
|
|
33
|
+
const onAnimationEnd = t3;
|
|
34
|
+
let t4;
|
|
35
|
+
if ($[5] !== children || $[6] !== onAnimationEnd || $[7] !== shouldRender || $[8] !== show) {
|
|
36
|
+
t4 = shouldRender ? /*#__PURE__*/ jsx("div", {
|
|
40
37
|
style: {
|
|
41
|
-
...style,
|
|
42
38
|
height: show ? "auto" : 0,
|
|
43
39
|
overflow: "hidden"
|
|
44
40
|
},
|
|
@@ -49,15 +45,13 @@ const ValidationAnimationContainer = (t0) => {
|
|
|
49
45
|
children
|
|
50
46
|
})
|
|
51
47
|
}) : null;
|
|
52
|
-
$[
|
|
53
|
-
$[
|
|
54
|
-
$[
|
|
55
|
-
$[
|
|
56
|
-
$[
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
} else t2 = $[13];
|
|
60
|
-
return t2;
|
|
48
|
+
$[5] = children;
|
|
49
|
+
$[6] = onAnimationEnd;
|
|
50
|
+
$[7] = shouldRender;
|
|
51
|
+
$[8] = show;
|
|
52
|
+
$[9] = t4;
|
|
53
|
+
} else t4 = $[9];
|
|
54
|
+
return t4;
|
|
61
55
|
};
|
|
62
56
|
//#endregion
|
|
63
57
|
export { ValidationAnimationContainer as default };
|
package/package.json
CHANGED