@primer/react 0.0.0-20260812113051 → 0.0.0-20260812225710

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
@@ -1,15 +1,15 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260812113051
3
+ ## 0.0.0-20260812225710
4
4
 
5
5
  ### Minor Changes
6
6
 
7
7
  - [#8212](https://github.com/primer/react/pull/8212) [`9ac9343`](https://github.com/primer/react/commit/9ac9343a70fd0f70413a42cd27baf562a74dd4fc) Thanks [@mattcosta7](https://github.com/mattcosta7)! - ThemeProvider: Add a CSS-variable-based implementation to `@primer/react/next`
8
8
  and deprecate the legacy JavaScript theme implementation.
9
9
 
10
- ### Patch Changes
10
+ - [#8303](https://github.com/primer/react/pull/8303) [`c4f1b35`](https://github.com/primer/react/commit/c4f1b35b258020461561d17b2c066f8766feb897) Thanks [@TylerJDev](https://github.com/TylerJDev)! - NavList: Add a `tooltipText` prop to items
11
11
 
12
- - [#8276](https://github.com/primer/react/pull/8276) [`d2b0e4c`](https://github.com/primer/react/commit/d2b0e4cc059dc6826d70383173b96cdfb4970a93) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Portal: Render nothing while server rendering and during hydration instead of accessing the DOM during render, fixing server rendering support. Client-only renders are unchanged and still mount portaled content in the same commit.
12
+ ### Patch Changes
13
13
 
14
14
  - Fake entry to force publishing
15
15
 
@@ -138,9 +138,10 @@ const listRoleTypes = [
138
138
  "tree"
139
139
  ];
140
140
  const UnwrappedItem = (t0, forwardedRef) => {
141
- var _slots$trailingVisual, _slots$description$pr, _slots$description, _slots$trailingAction;
142
- const $ = c(161);
141
+ var _slots$trailingVisual, _slots$description$pr, _slots$description, _slots$trailingAction, _PrivateTooltipText2;
142
+ const $ = c(162);
143
143
  let _PrivateItemWrapper;
144
+ let _PrivateTooltipText;
144
145
  let className;
145
146
  let id;
146
147
  let inactiveText;
@@ -154,7 +155,7 @@ const UnwrappedItem = (t0, forwardedRef) => {
154
155
  let t4;
155
156
  let t5;
156
157
  if ($[0] !== t0) {
157
- const { variant: t6, size: t7, disabled: t8, inactiveText: t9, selected: t10, active: t11, onSelect: t12, id: t13, role: t14, loading: t15, _PrivateItemWrapper: t16, className: t17, groupId: _groupId, renderItem: _renderItem, handleAddItem: _handleAddItem, ...t18 } = t0;
158
+ const { variant: t6, size: t7, disabled: t8, inactiveText: t9, selected: t10, active: t11, onSelect: t12, id: t13, role: t14, loading: t15, _PrivateItemWrapper: t16, _PrivateTooltipText: t17, className: t18, groupId: _groupId, renderItem: _renderItem, handleAddItem: _handleAddItem, ...t19 } = t0;
158
159
  t1 = t6;
159
160
  t2 = t7;
160
161
  t3 = t8;
@@ -166,36 +167,39 @@ const UnwrappedItem = (t0, forwardedRef) => {
166
167
  role = t14;
167
168
  loading = t15;
168
169
  _PrivateItemWrapper = t16;
169
- className = t17;
170
- props = t18;
170
+ _PrivateTooltipText = t17;
171
+ className = t18;
172
+ props = t19;
171
173
  $[0] = t0;
172
174
  $[1] = _PrivateItemWrapper;
173
- $[2] = className;
174
- $[3] = id;
175
- $[4] = inactiveText;
176
- $[5] = loading;
177
- $[6] = onSelectUser;
178
- $[7] = props;
179
- $[8] = role;
180
- $[9] = t1;
181
- $[10] = t2;
182
- $[11] = t3;
183
- $[12] = t4;
184
- $[13] = t5;
175
+ $[2] = _PrivateTooltipText;
176
+ $[3] = className;
177
+ $[4] = id;
178
+ $[5] = inactiveText;
179
+ $[6] = loading;
180
+ $[7] = onSelectUser;
181
+ $[8] = props;
182
+ $[9] = role;
183
+ $[10] = t1;
184
+ $[11] = t2;
185
+ $[12] = t3;
186
+ $[13] = t4;
187
+ $[14] = t5;
185
188
  } else {
186
189
  _PrivateItemWrapper = $[1];
187
- className = $[2];
188
- id = $[3];
189
- inactiveText = $[4];
190
- loading = $[5];
191
- onSelectUser = $[6];
192
- props = $[7];
193
- role = $[8];
194
- t1 = $[9];
195
- t2 = $[10];
196
- t3 = $[11];
197
- t4 = $[12];
198
- t5 = $[13];
190
+ _PrivateTooltipText = $[2];
191
+ className = $[3];
192
+ id = $[4];
193
+ inactiveText = $[5];
194
+ loading = $[6];
195
+ onSelectUser = $[7];
196
+ props = $[8];
197
+ role = $[9];
198
+ t1 = $[10];
199
+ t2 = $[11];
200
+ t3 = $[12];
201
+ t4 = $[13];
202
+ t5 = $[14];
199
203
  }
200
204
  const variant = t1 === void 0 ? "default" : t1;
201
205
  const size = t2 === void 0 ? "medium" : t2;
@@ -204,22 +208,22 @@ const UnwrappedItem = (t0, forwardedRef) => {
204
208
  const active = t5 === void 0 ? false : t5;
205
209
  const [partialSlots, childrenWithoutSlots] = useSlots(props.children, slotsConfig);
206
210
  let t6;
207
- if ($[14] !== partialSlots) {
211
+ if ($[15] !== partialSlots) {
208
212
  t6 = {
209
213
  description: void 0,
210
214
  ...partialSlots
211
215
  };
212
- $[14] = partialSlots;
213
- $[15] = t6;
214
- } else t6 = $[15];
216
+ $[15] = partialSlots;
217
+ $[16] = t6;
218
+ } else t6 = $[16];
215
219
  const slots = t6;
216
220
  const { container, afterSelect, selectionAttribute, defaultTrailingVisual } = React.useContext(ActionListContainerContext);
217
221
  let t7;
218
- if ($[16] !== defaultTrailingVisual) {
222
+ if ($[17] !== defaultTrailingVisual) {
219
223
  t7 = defaultTrailingVisual ? /*#__PURE__*/ jsx(TrailingVisual, { children: defaultTrailingVisual }) : null;
220
- $[16] = defaultTrailingVisual;
221
- $[17] = t7;
222
- } else t7 = $[17];
224
+ $[17] = defaultTrailingVisual;
225
+ $[18] = t7;
226
+ } else t7 = $[18];
223
227
  const wrappedDefaultTrailingVisual = t7;
224
228
  const trailingVisual = (_slots$trailingVisual = slots.trailingVisual) !== null && _slots$trailingVisual !== void 0 ? _slots$trailingVisual : wrappedDefaultTrailingVisual;
225
229
  const { role: listRole, selectionVariant: listSelectionVariant } = React.useContext(ListContext);
@@ -227,23 +231,23 @@ const UnwrappedItem = (t0, forwardedRef) => {
227
231
  const inactive = Boolean(inactiveText);
228
232
  const menuContext = container === "ActionMenu" || container === "SelectPanel" || container === "FilteredActionList";
229
233
  let t8;
230
- if ($[18] !== inactive || $[19] !== listRole) {
234
+ if ($[19] !== inactive || $[20] !== listRole) {
231
235
  t8 = inactive && !(listRole !== void 0 && ["menu", "listbox"].includes(listRole));
232
- $[18] = inactive;
233
- $[19] = listRole;
234
- $[20] = t8;
235
- } else t8 = $[20];
236
+ $[19] = inactive;
237
+ $[20] = listRole;
238
+ $[21] = t8;
239
+ } else t8 = $[21];
236
240
  const showInactiveIndicator = t8;
237
241
  let t9;
238
- if ($[21] !== onSelectUser) {
242
+ if ($[22] !== onSelectUser) {
239
243
  t9 = (event, afterSelect_0) => {
240
244
  if (typeof onSelectUser === "function") onSelectUser(event);
241
245
  if (event.defaultPrevented) return;
242
246
  if (typeof afterSelect_0 === "function") afterSelect_0(event);
243
247
  };
244
- $[21] = onSelectUser;
245
- $[22] = t9;
246
- } else t9 = $[22];
248
+ $[22] = onSelectUser;
249
+ $[23] = t9;
250
+ } else t9 = $[23];
247
251
  const onSelect = t9;
248
252
  const selectionVariant = groupSelectionVariant ? groupSelectionVariant : listSelectionVariant;
249
253
  let inferredItemRole;
@@ -261,31 +265,31 @@ const UnwrappedItem = (t0, forwardedRef) => {
261
265
  const itemSelectionAttribute = selectionAttribute || inferredSelectionAttribute;
262
266
  const listItemSemantics = itemRole === "option" || itemRole === "menuitem" || itemRole === "menuitemradio" || itemRole === "menuitemcheckbox" || itemRole === "tab";
263
267
  let t10;
264
- if ($[23] !== inactive || $[24] !== listItemSemantics || $[25] !== listRole) {
268
+ if ($[24] !== inactive || $[25] !== listItemSemantics || $[26] !== listRole) {
265
269
  t10 = listRole && listRoleTypes.includes(listRole) || inactive || listItemSemantics;
266
- $[23] = inactive;
267
- $[24] = listItemSemantics;
268
- $[25] = listRole;
269
- $[26] = t10;
270
- } else t10 = $[26];
270
+ $[24] = inactive;
271
+ $[25] = listItemSemantics;
272
+ $[26] = listRole;
273
+ $[27] = t10;
274
+ } else t10 = $[27];
271
275
  const listSemantics = t10;
272
276
  const buttonSemantics = !listSemantics && !_PrivateItemWrapper;
273
277
  let t11;
274
- if ($[27] !== afterSelect || $[28] !== disabled || $[29] !== inactive || $[30] !== loading || $[31] !== onSelect) {
278
+ if ($[28] !== afterSelect || $[29] !== disabled || $[30] !== inactive || $[31] !== loading || $[32] !== onSelect) {
275
279
  t11 = (event_0) => {
276
280
  if (disabled || inactive || loading) return;
277
281
  onSelect(event_0, afterSelect);
278
282
  };
279
- $[27] = afterSelect;
280
- $[28] = disabled;
281
- $[29] = inactive;
282
- $[30] = loading;
283
- $[31] = onSelect;
284
- $[32] = t11;
285
- } else t11 = $[32];
283
+ $[28] = afterSelect;
284
+ $[29] = disabled;
285
+ $[30] = inactive;
286
+ $[31] = loading;
287
+ $[32] = onSelect;
288
+ $[33] = t11;
289
+ } else t11 = $[33];
286
290
  const clickHandler = t11;
287
291
  let t12;
288
- if ($[33] !== afterSelect || $[34] !== disabled || $[35] !== inactive || $[36] !== loading || $[37] !== onSelect) {
292
+ if ($[34] !== afterSelect || $[35] !== disabled || $[36] !== inactive || $[37] !== loading || $[38] !== onSelect) {
289
293
  t12 = (event_1) => {
290
294
  if (disabled || inactive || loading) return;
291
295
  if (event_1.key === " " || event_1.key === "Enter") {
@@ -296,13 +300,13 @@ const UnwrappedItem = (t0, forwardedRef) => {
296
300
  onSelect(event_1, afterSelect);
297
301
  }
298
302
  };
299
- $[33] = afterSelect;
300
- $[34] = disabled;
301
- $[35] = inactive;
302
- $[36] = loading;
303
- $[37] = onSelect;
304
- $[38] = t12;
305
- } else t12 = $[38];
303
+ $[34] = afterSelect;
304
+ $[35] = disabled;
305
+ $[36] = inactive;
306
+ $[37] = loading;
307
+ $[38] = onSelect;
308
+ $[39] = t12;
309
+ } else t12 = $[39];
306
310
  const keyPressHandler = t12;
307
311
  const itemId = useId$1(id);
308
312
  const labelId = `${itemId}--label`;
@@ -313,40 +317,40 @@ const UnwrappedItem = (t0, forwardedRef) => {
313
317
  const [truncatedText, setTruncatedText] = React.useState(void 0);
314
318
  const ItemWrapper = _PrivateItemWrapper || (listSemantics ? DivItemContainer : ButtonItemContainer);
315
319
  let t13;
316
- if ($[39] !== itemRole || $[40] !== itemSelectionAttribute) {
320
+ if ($[40] !== itemRole || $[41] !== itemSelectionAttribute) {
317
321
  t13 = itemSelectionAttribute && itemRole && selectableRoles.includes(itemRole);
318
- $[39] = itemRole;
319
- $[40] = itemSelectionAttribute;
320
- $[41] = t13;
321
- } else t13 = $[41];
322
+ $[40] = itemRole;
323
+ $[41] = itemSelectionAttribute;
324
+ $[42] = t13;
325
+ } else t13 = $[42];
322
326
  const includeSelectionAttribute = t13;
323
327
  const focusable = showInactiveIndicator ? true : void 0;
324
328
  const descriptionVariant = (_slots$description$pr = (_slots$description = slots.description) === null || _slots$description === void 0 ? void 0 : _slots$description.props.variant) !== null && _slots$description$pr !== void 0 ? _slots$description$pr : "inline";
325
329
  const hasTrailingVisualSlot = Boolean(slots.trailingVisual);
326
330
  const hasDescriptionSlot = Boolean(slots.description);
327
331
  let parts;
328
- if ($[42] !== hasTrailingVisualSlot || $[43] !== labelId || $[44] !== trailingVisualId) {
332
+ if ($[43] !== hasTrailingVisualSlot || $[44] !== labelId || $[45] !== trailingVisualId) {
329
333
  parts = [labelId];
330
334
  if (hasTrailingVisualSlot) parts.push(trailingVisualId);
331
- $[42] = hasTrailingVisualSlot;
332
- $[43] = labelId;
333
- $[44] = trailingVisualId;
334
- $[45] = parts;
335
- } else parts = $[45];
335
+ $[43] = hasTrailingVisualSlot;
336
+ $[44] = labelId;
337
+ $[45] = trailingVisualId;
338
+ $[46] = parts;
339
+ } else parts = $[46];
336
340
  const ariaLabelledBy = parts.join(" ");
337
341
  let parts_0;
338
- if ($[46] !== blockDescriptionId || $[47] !== descriptionVariant || $[48] !== hasDescriptionSlot || $[49] !== inactiveWarningId || $[50] !== inlineDescriptionId) {
342
+ if ($[47] !== blockDescriptionId || $[48] !== descriptionVariant || $[49] !== hasDescriptionSlot || $[50] !== inactiveWarningId || $[51] !== inlineDescriptionId) {
339
343
  parts_0 = [];
340
344
  if (hasDescriptionSlot && descriptionVariant === "block") parts_0.push(blockDescriptionId);
341
345
  if (hasDescriptionSlot && descriptionVariant === "inline") parts_0.push(inlineDescriptionId);
342
346
  if (inactiveWarningId) parts_0.push(inactiveWarningId);
343
- $[46] = blockDescriptionId;
344
- $[47] = descriptionVariant;
345
- $[48] = hasDescriptionSlot;
346
- $[49] = inactiveWarningId;
347
- $[50] = inlineDescriptionId;
348
- $[51] = parts_0;
349
- } else parts_0 = $[51];
347
+ $[47] = blockDescriptionId;
348
+ $[48] = descriptionVariant;
349
+ $[49] = hasDescriptionSlot;
350
+ $[50] = inactiveWarningId;
351
+ $[51] = inlineDescriptionId;
352
+ $[52] = parts_0;
353
+ } else parts_0 = $[52];
350
354
  const ariaDescribedBy = parts_0.length > 0 ? parts_0.join(" ") : void 0;
351
355
  const t14 = !buttonSemantics ? keyPressHandler : void 0;
352
356
  const t15 = disabled ? true : void 0;
@@ -354,15 +358,15 @@ const UnwrappedItem = (t0, forwardedRef) => {
354
358
  const t17 = loading && !inactive ? true : void 0;
355
359
  const t18 = focusable ? void 0 : 0;
356
360
  let t19;
357
- if ($[52] !== includeSelectionAttribute || $[53] !== itemSelectionAttribute || $[54] !== selected) {
361
+ if ($[53] !== includeSelectionAttribute || $[54] !== itemSelectionAttribute || $[55] !== selected) {
358
362
  t19 = includeSelectionAttribute && { [itemSelectionAttribute]: selected };
359
- $[52] = includeSelectionAttribute;
360
- $[53] = itemSelectionAttribute;
361
- $[54] = selected;
362
- $[55] = t19;
363
- } else t19 = $[55];
363
+ $[53] = includeSelectionAttribute;
364
+ $[54] = itemSelectionAttribute;
365
+ $[55] = selected;
366
+ $[56] = t19;
367
+ } else t19 = $[56];
364
368
  let t20;
365
- if ($[56] !== ariaDescribedBy || $[57] !== ariaLabelledBy || $[58] !== clickHandler || $[59] !== itemId || $[60] !== itemRole || $[61] !== t14 || $[62] !== t15 || $[63] !== t16 || $[64] !== t17 || $[65] !== t18 || $[66] !== t19) {
369
+ if ($[57] !== ariaDescribedBy || $[58] !== ariaLabelledBy || $[59] !== clickHandler || $[60] !== itemId || $[61] !== itemRole || $[62] !== t14 || $[63] !== t15 || $[64] !== t16 || $[65] !== t17 || $[66] !== t18 || $[67] !== t19) {
366
370
  t20 = {
367
371
  onClick: clickHandler,
368
372
  onKeyPress: t14,
@@ -376,22 +380,22 @@ const UnwrappedItem = (t0, forwardedRef) => {
376
380
  role: itemRole,
377
381
  id: itemId
378
382
  };
379
- $[56] = ariaDescribedBy;
380
- $[57] = ariaLabelledBy;
381
- $[58] = clickHandler;
382
- $[59] = itemId;
383
- $[60] = itemRole;
384
- $[61] = t14;
385
- $[62] = t15;
386
- $[63] = t16;
387
- $[64] = t17;
388
- $[65] = t18;
389
- $[66] = t19;
390
- $[67] = t20;
391
- } else t20 = $[67];
383
+ $[57] = ariaDescribedBy;
384
+ $[58] = ariaLabelledBy;
385
+ $[59] = clickHandler;
386
+ $[60] = itemId;
387
+ $[61] = itemRole;
388
+ $[62] = t14;
389
+ $[63] = t15;
390
+ $[64] = t16;
391
+ $[65] = t17;
392
+ $[66] = t18;
393
+ $[67] = t19;
394
+ $[68] = t20;
395
+ } else t20 = $[68];
392
396
  const menuItemProps = t20;
393
397
  let t21;
394
- if ($[68] !== _PrivateItemWrapper || $[69] !== forwardedRef || $[70] !== itemRole || $[71] !== listSemantics || $[72] !== menuItemProps || $[73] !== props) {
398
+ if ($[69] !== _PrivateItemWrapper || $[70] !== forwardedRef || $[71] !== itemRole || $[72] !== listSemantics || $[73] !== menuItemProps || $[74] !== props) {
395
399
  t21 = _PrivateItemWrapper ? {
396
400
  role: itemRole ? "none" : void 0,
397
401
  ...props
@@ -400,34 +404,34 @@ const UnwrappedItem = (t0, forwardedRef) => {
400
404
  ...props,
401
405
  ref: forwardedRef
402
406
  } || {};
403
- $[68] = _PrivateItemWrapper;
404
- $[69] = forwardedRef;
405
- $[70] = itemRole;
406
- $[71] = listSemantics;
407
- $[72] = menuItemProps;
408
- $[73] = props;
409
- $[74] = t21;
410
- } else t21 = $[74];
407
+ $[69] = _PrivateItemWrapper;
408
+ $[70] = forwardedRef;
409
+ $[71] = itemRole;
410
+ $[72] = listSemantics;
411
+ $[73] = menuItemProps;
412
+ $[74] = props;
413
+ $[75] = t21;
414
+ } else t21 = $[75];
411
415
  const containerProps = t21;
412
416
  let t22;
413
- if ($[75] !== _PrivateItemWrapper || $[76] !== forwardedRef || $[77] !== listSemantics || $[78] !== menuItemProps || $[79] !== props) {
417
+ if ($[76] !== _PrivateItemWrapper || $[77] !== forwardedRef || $[78] !== listSemantics || $[79] !== menuItemProps || $[80] !== props) {
414
418
  t22 = _PrivateItemWrapper ? menuItemProps : !listSemantics && {
415
419
  ...menuItemProps,
416
420
  ...props,
417
421
  ref: forwardedRef
418
422
  };
419
- $[75] = _PrivateItemWrapper;
420
- $[76] = forwardedRef;
421
- $[77] = listSemantics;
422
- $[78] = menuItemProps;
423
- $[79] = props;
424
- $[80] = t22;
425
- } else t22 = $[80];
423
+ $[76] = _PrivateItemWrapper;
424
+ $[77] = forwardedRef;
425
+ $[78] = listSemantics;
426
+ $[79] = menuItemProps;
427
+ $[80] = props;
428
+ $[81] = t22;
429
+ } else t22 = $[81];
426
430
  const wrapperProps = t22;
427
431
  const t23 = Boolean(inactiveText);
428
432
  const t24 = buttonSemantics ? setTruncatedText : void 0;
429
433
  let t25;
430
- if ($[81] !== blockDescriptionId || $[82] !== disabled || $[83] !== inlineDescriptionId || $[84] !== size || $[85] !== t23 || $[86] !== t24 || $[87] !== trailingVisualId || $[88] !== variant) {
434
+ if ($[82] !== blockDescriptionId || $[83] !== disabled || $[84] !== inlineDescriptionId || $[85] !== size || $[86] !== t23 || $[87] !== t24 || $[88] !== trailingVisualId || $[89] !== variant) {
431
435
  t25 = {
432
436
  variant,
433
437
  size,
@@ -438,16 +442,16 @@ const UnwrappedItem = (t0, forwardedRef) => {
438
442
  trailingVisualId,
439
443
  setTruncatedText: t24
440
444
  };
441
- $[81] = blockDescriptionId;
442
- $[82] = disabled;
443
- $[83] = inlineDescriptionId;
444
- $[84] = size;
445
- $[85] = t23;
446
- $[86] = t24;
447
- $[87] = trailingVisualId;
448
- $[88] = variant;
449
- $[89] = t25;
450
- } else t25 = $[89];
445
+ $[82] = blockDescriptionId;
446
+ $[83] = disabled;
447
+ $[84] = inlineDescriptionId;
448
+ $[85] = size;
449
+ $[86] = t23;
450
+ $[87] = t24;
451
+ $[88] = trailingVisualId;
452
+ $[89] = variant;
453
+ $[90] = t25;
454
+ } else t25 = $[90];
451
455
  const itemContextValue = t25;
452
456
  const trailingActionRendered = !inactive && !loading && !menuContext && Boolean(slots.trailingAction);
453
457
  const t26 = listSemantics ? forwardedRef : null;
@@ -460,182 +464,183 @@ const UnwrappedItem = (t0, forwardedRef) => {
460
464
  const t33 = trailingActionRendered ? true : void 0;
461
465
  const t34 = trailingActionRendered && (_slots$trailingAction = slots.trailingAction) !== null && _slots$trailingAction !== void 0 && _slots$trailingAction.props.loading ? true : void 0;
462
466
  let t35;
463
- if ($[90] !== className) {
467
+ if ($[91] !== className) {
464
468
  t35 = clsx(ActionList_module_css_default.ActionListItem, className);
465
- $[90] = className;
466
- $[91] = t35;
467
- } else t35 = $[91];
468
- let t36;
469
+ $[91] = className;
470
+ $[92] = t35;
471
+ } else t35 = $[92];
472
+ const t36 = (_PrivateTooltipText2 = _PrivateTooltipText) !== null && _PrivateTooltipText2 !== void 0 ? _PrivateTooltipText2 : truncatedText;
469
473
  let t37;
470
- if ($[92] === Symbol.for("react.memo_cache_sentinel")) {
471
- t36 = {};
472
- t37 = /*#__PURE__*/ jsx("span", { className: ActionList_module_css_default.Spacer });
473
- $[92] = t36;
474
+ let t38;
475
+ if ($[93] === Symbol.for("react.memo_cache_sentinel")) {
476
+ t37 = {};
477
+ t38 = /*#__PURE__*/ jsx("span", { className: ActionList_module_css_default.Spacer });
474
478
  $[93] = t37;
479
+ $[94] = t38;
475
480
  } else {
476
- t36 = $[92];
477
481
  t37 = $[93];
482
+ t38 = $[94];
478
483
  }
479
- let t38;
480
- if ($[94] !== selected) {
481
- t38 = /*#__PURE__*/ jsx(Selection, {
484
+ let t39;
485
+ if ($[95] !== selected) {
486
+ t39 = /*#__PURE__*/ jsx(Selection, {
482
487
  selected,
483
488
  className: ActionList_module_css_default.LeadingAction
484
489
  });
485
- $[94] = selected;
486
- $[95] = t38;
487
- } else t38 = $[95];
488
- const t39 = showInactiveIndicator ? inactiveText : void 0;
489
- const t40 = Boolean(slots.leadingVisual);
490
- let t41;
491
- if ($[96] !== labelId || $[97] !== loading || $[98] !== slots.leadingVisual || $[99] !== t39 || $[100] !== t40) {
492
- t41 = /*#__PURE__*/ jsx(VisualOrIndicator, {
493
- inactiveText: t39,
494
- itemHasLeadingVisual: t40,
490
+ $[95] = selected;
491
+ $[96] = t39;
492
+ } else t39 = $[96];
493
+ const t40 = showInactiveIndicator ? inactiveText : void 0;
494
+ const t41 = Boolean(slots.leadingVisual);
495
+ let t42;
496
+ if ($[97] !== labelId || $[98] !== loading || $[99] !== slots.leadingVisual || $[100] !== t40 || $[101] !== t41) {
497
+ t42 = /*#__PURE__*/ jsx(VisualOrIndicator, {
498
+ inactiveText: t40,
499
+ itemHasLeadingVisual: t41,
495
500
  labelId,
496
501
  loading,
497
502
  position: "leading",
498
503
  children: slots.leadingVisual
499
504
  });
500
- $[96] = labelId;
501
- $[97] = loading;
502
- $[98] = slots.leadingVisual;
503
- $[99] = t39;
505
+ $[97] = labelId;
506
+ $[98] = loading;
507
+ $[99] = slots.leadingVisual;
504
508
  $[100] = t40;
505
509
  $[101] = t41;
506
- } else t41 = $[101];
507
- const t42 = !!slots.description;
508
- let t43;
509
- if ($[102] !== inactive || $[103] !== loading) {
510
- t43 = loading === true && !inactive && /*#__PURE__*/ jsx(VisuallyHidden, { children: "Loading" });
511
- $[102] = inactive;
512
- $[103] = loading;
513
- $[104] = t43;
514
- } else t43 = $[104];
510
+ $[102] = t42;
511
+ } else t42 = $[102];
512
+ const t43 = !!slots.description;
515
513
  let t44;
516
- if ($[105] !== childrenWithoutSlots || $[106] !== labelId || $[107] !== t43) {
517
- t44 = /*#__PURE__*/ jsxs("span", {
514
+ if ($[103] !== inactive || $[104] !== loading) {
515
+ t44 = loading === true && !inactive && /*#__PURE__*/ jsx(VisuallyHidden, { children: "Loading" });
516
+ $[103] = inactive;
517
+ $[104] = loading;
518
+ $[105] = t44;
519
+ } else t44 = $[105];
520
+ let t45;
521
+ if ($[106] !== childrenWithoutSlots || $[107] !== labelId || $[108] !== t44) {
522
+ t45 = /*#__PURE__*/ jsxs("span", {
518
523
  id: labelId,
519
524
  className: ActionList_module_css_default.ItemLabel,
520
525
  "data-component": "ActionList.Item.Label",
521
- children: [childrenWithoutSlots, t43]
526
+ children: [childrenWithoutSlots, t44]
522
527
  });
523
- $[105] = childrenWithoutSlots;
524
- $[106] = labelId;
525
- $[107] = t43;
528
+ $[106] = childrenWithoutSlots;
529
+ $[107] = labelId;
526
530
  $[108] = t44;
527
- } else t44 = $[108];
528
- let t45;
529
- if ($[109] !== descriptionVariant || $[110] !== slots.description || $[111] !== t42 || $[112] !== t44) {
530
- t45 = /*#__PURE__*/ jsxs(ConditionalWrapper, {
531
- if: t42,
531
+ $[109] = t45;
532
+ } else t45 = $[109];
533
+ let t46;
534
+ if ($[110] !== descriptionVariant || $[111] !== slots.description || $[112] !== t43 || $[113] !== t45) {
535
+ t46 = /*#__PURE__*/ jsxs(ConditionalWrapper, {
536
+ if: t43,
532
537
  className: ActionList_module_css_default.ItemDescriptionWrap,
533
538
  "data-description-variant": descriptionVariant,
534
- children: [t44, slots.description]
539
+ children: [t45, slots.description]
535
540
  });
536
- $[109] = descriptionVariant;
537
- $[110] = slots.description;
538
- $[111] = t42;
539
- $[112] = t44;
541
+ $[110] = descriptionVariant;
542
+ $[111] = slots.description;
543
+ $[112] = t43;
540
544
  $[113] = t45;
541
- } else t45 = $[113];
542
- const t46 = showInactiveIndicator ? inactiveText : void 0;
543
- const t47 = Boolean(slots.leadingVisual);
544
- let t48;
545
- if ($[114] !== labelId || $[115] !== loading || $[116] !== t46 || $[117] !== t47 || $[118] !== trailingVisual) {
546
- t48 = /*#__PURE__*/ jsx(VisualOrIndicator, {
547
- inactiveText: t46,
548
- itemHasLeadingVisual: t47,
545
+ $[114] = t46;
546
+ } else t46 = $[114];
547
+ const t47 = showInactiveIndicator ? inactiveText : void 0;
548
+ const t48 = Boolean(slots.leadingVisual);
549
+ let t49;
550
+ if ($[115] !== labelId || $[116] !== loading || $[117] !== t47 || $[118] !== t48 || $[119] !== trailingVisual) {
551
+ t49 = /*#__PURE__*/ jsx(VisualOrIndicator, {
552
+ inactiveText: t47,
553
+ itemHasLeadingVisual: t48,
549
554
  labelId,
550
555
  loading,
551
556
  position: "trailing",
552
557
  children: trailingVisual
553
558
  });
554
- $[114] = labelId;
555
- $[115] = loading;
556
- $[116] = t46;
559
+ $[115] = labelId;
560
+ $[116] = loading;
557
561
  $[117] = t47;
558
- $[118] = trailingVisual;
559
- $[119] = t48;
560
- } else t48 = $[119];
561
- let t49;
562
- if ($[120] !== inactiveText || $[121] !== inactiveWarningId || $[122] !== showInactiveIndicator) {
563
- t49 = !showInactiveIndicator && inactiveText ? /*#__PURE__*/ jsx("span", {
562
+ $[118] = t48;
563
+ $[119] = trailingVisual;
564
+ $[120] = t49;
565
+ } else t49 = $[120];
566
+ let t50;
567
+ if ($[121] !== inactiveText || $[122] !== inactiveWarningId || $[123] !== showInactiveIndicator) {
568
+ t50 = !showInactiveIndicator && inactiveText ? /*#__PURE__*/ jsx("span", {
564
569
  className: ActionList_module_css_default.InactiveWarning,
565
570
  id: inactiveWarningId,
566
571
  children: inactiveText
567
572
  }) : null;
568
- $[120] = inactiveText;
569
- $[121] = inactiveWarningId;
570
- $[122] = showInactiveIndicator;
571
- $[123] = t49;
572
- } else t49 = $[123];
573
- let t50;
574
- if ($[124] !== t45 || $[125] !== t48 || $[126] !== t49) {
575
- t50 = /*#__PURE__*/ jsxs("span", {
573
+ $[121] = inactiveText;
574
+ $[122] = inactiveWarningId;
575
+ $[123] = showInactiveIndicator;
576
+ $[124] = t50;
577
+ } else t50 = $[124];
578
+ let t51;
579
+ if ($[125] !== t46 || $[126] !== t49 || $[127] !== t50) {
580
+ t51 = /*#__PURE__*/ jsxs("span", {
576
581
  className: ActionList_module_css_default.ActionListSubContent,
577
582
  "data-component": "ActionList.Item--DividerContainer",
578
583
  children: [
579
- t45,
580
- t48,
581
- t49
584
+ t46,
585
+ t49,
586
+ t50
582
587
  ]
583
588
  });
584
- $[124] = t45;
585
- $[125] = t48;
589
+ $[125] = t46;
586
590
  $[126] = t49;
587
591
  $[127] = t50;
588
- } else t50 = $[127];
589
- let t51;
590
- if ($[128] !== t38 || $[129] !== t41 || $[130] !== t50) {
591
- t51 = /*#__PURE__*/ jsxs(TooltipContext.Provider, {
592
- value: t36,
592
+ $[128] = t51;
593
+ } else t51 = $[128];
594
+ let t52;
595
+ if ($[129] !== t39 || $[130] !== t42 || $[131] !== t51) {
596
+ t52 = /*#__PURE__*/ jsxs(TooltipContext.Provider, {
597
+ value: t37,
593
598
  children: [
594
- t37,
595
599
  t38,
596
- t41,
597
- t50
600
+ t39,
601
+ t42,
602
+ t51
598
603
  ]
599
604
  });
600
- $[128] = t38;
601
- $[129] = t41;
602
- $[130] = t50;
605
+ $[129] = t39;
606
+ $[130] = t42;
603
607
  $[131] = t51;
604
- } else t51 = $[131];
605
- let t52;
606
- if ($[132] !== ItemWrapper || $[133] !== forwardedRef || $[134] !== size || $[135] !== t51 || $[136] !== wrapperProps) {
607
- t52 = /*#__PURE__*/ jsx(ItemWrapper, {
608
+ $[132] = t52;
609
+ } else t52 = $[132];
610
+ let t53;
611
+ if ($[133] !== ItemWrapper || $[134] !== forwardedRef || $[135] !== size || $[136] !== t52 || $[137] !== wrapperProps) {
612
+ t53 = /*#__PURE__*/ jsx(ItemWrapper, {
608
613
  ...wrapperProps,
609
614
  className: ActionList_module_css_default.ActionListContent,
610
615
  "data-size": size,
611
616
  ref: forwardedRef,
612
- children: t51
617
+ children: t52
613
618
  });
614
- $[132] = ItemWrapper;
615
- $[133] = forwardedRef;
616
- $[134] = size;
617
- $[135] = t51;
618
- $[136] = wrapperProps;
619
- $[137] = t52;
620
- } else t52 = $[137];
621
- let t53;
622
- if ($[138] !== buttonSemantics || $[139] !== forwardedRef || $[140] !== t52 || $[141] !== truncatedText) {
623
- t53 = /*#__PURE__*/ jsx(ConditionalTooltip, {
619
+ $[133] = ItemWrapper;
620
+ $[134] = forwardedRef;
621
+ $[135] = size;
622
+ $[136] = t52;
623
+ $[137] = wrapperProps;
624
+ $[138] = t53;
625
+ } else t53 = $[138];
626
+ let t54;
627
+ if ($[139] !== buttonSemantics || $[140] !== forwardedRef || $[141] !== t36 || $[142] !== t53) {
628
+ t54 = /*#__PURE__*/ jsx(ConditionalTooltip, {
624
629
  ref: forwardedRef,
625
- text: truncatedText,
630
+ text: t36,
626
631
  enabled: buttonSemantics,
627
- children: t52
632
+ children: t53
628
633
  });
629
- $[138] = buttonSemantics;
630
- $[139] = forwardedRef;
631
- $[140] = t52;
632
- $[141] = truncatedText;
634
+ $[139] = buttonSemantics;
635
+ $[140] = forwardedRef;
636
+ $[141] = t36;
633
637
  $[142] = t53;
634
- } else t53 = $[142];
635
- const t54 = !inactive && !loading && !menuContext && Boolean(slots.trailingAction) && slots.trailingAction;
636
- let t55;
637
- if ($[143] !== containerProps || $[144] !== slots.subItem || $[145] !== t26 || $[146] !== t27 || $[147] !== t28 || $[148] !== t29 || $[149] !== t30 || $[150] !== t31 || $[151] !== t32 || $[152] !== t33 || $[153] !== t34 || $[154] !== t35 || $[155] !== t53 || $[156] !== t54) {
638
- t55 = /*#__PURE__*/ jsxs("li", {
638
+ $[143] = t54;
639
+ } else t54 = $[143];
640
+ const t55 = !inactive && !loading && !menuContext && Boolean(slots.trailingAction) && slots.trailingAction;
641
+ let t56;
642
+ if ($[144] !== containerProps || $[145] !== slots.subItem || $[146] !== t26 || $[147] !== t27 || $[148] !== t28 || $[149] !== t29 || $[150] !== t30 || $[151] !== t31 || $[152] !== t32 || $[153] !== t33 || $[154] !== t34 || $[155] !== t35 || $[156] !== t54 || $[157] !== t55) {
643
+ t56 = /*#__PURE__*/ jsxs("li", {
639
644
  ...containerProps,
640
645
  ref: t26,
641
646
  "data-component": "ActionList.Item",
@@ -649,38 +654,38 @@ const UnwrappedItem = (t0, forwardedRef) => {
649
654
  "data-trailing-action-loading": t34,
650
655
  className: t35,
651
656
  children: [
652
- t53,
653
657
  t54,
658
+ t55,
654
659
  slots.subItem
655
660
  ]
656
661
  });
657
- $[143] = containerProps;
658
- $[144] = slots.subItem;
659
- $[145] = t26;
660
- $[146] = t27;
661
- $[147] = t28;
662
- $[148] = t29;
663
- $[149] = t30;
664
- $[150] = t31;
665
- $[151] = t32;
666
- $[152] = t33;
667
- $[153] = t34;
668
- $[154] = t35;
669
- $[155] = t53;
662
+ $[144] = containerProps;
663
+ $[145] = slots.subItem;
664
+ $[146] = t26;
665
+ $[147] = t27;
666
+ $[148] = t28;
667
+ $[149] = t29;
668
+ $[150] = t30;
669
+ $[151] = t31;
670
+ $[152] = t32;
671
+ $[153] = t33;
672
+ $[154] = t34;
673
+ $[155] = t35;
670
674
  $[156] = t54;
671
675
  $[157] = t55;
672
- } else t55 = $[157];
673
- let t56;
674
- if ($[158] !== itemContextValue || $[159] !== t55) {
675
- t56 = /*#__PURE__*/ jsx(ItemContext.Provider, {
676
+ $[158] = t56;
677
+ } else t56 = $[158];
678
+ let t57;
679
+ if ($[159] !== itemContextValue || $[160] !== t56) {
680
+ t57 = /*#__PURE__*/ jsx(ItemContext.Provider, {
676
681
  value: itemContextValue,
677
- children: t55
682
+ children: t56
678
683
  });
679
- $[158] = itemContextValue;
680
- $[159] = t55;
684
+ $[159] = itemContextValue;
681
685
  $[160] = t56;
682
- } else t56 = $[160];
683
- return t56;
686
+ $[161] = t57;
687
+ } else t57 = $[161];
688
+ return t57;
684
689
  };
685
690
  const Item = Object.assign(fixedForwardRef(UnwrappedItem), {
686
691
  displayName: "ActionList.Item",
@@ -1,9 +1,10 @@
1
1
  import { fixedForwardRef } from "../utils/modern-polymorphic.js";
2
+ import { Tooltip } from "../TooltipV2/Tooltip.js";
2
3
  import { Item } from "./Item.js";
3
4
  import Link from "../Link/Link.js";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  //#region src/ActionList/LinkItem.tsx
6
- const LinkItemComponent = fixedForwardRef(({ active, inactiveText, variant, size, as: Component, className, ...props }, forwardedRef) => {
7
+ const LinkItemComponent = fixedForwardRef(({ active, inactiveText, variant, size, as: Component, className, _PrivateTooltipText, ...props }, forwardedRef) => {
7
8
  return /*#__PURE__*/ jsx(Item, {
8
9
  className,
9
10
  active,
@@ -20,7 +21,7 @@ const LinkItemComponent = fixedForwardRef(({ active, inactiveText, variant, size
20
21
  ...rest,
21
22
  children
22
23
  });
23
- return /*#__PURE__*/ jsx(Link, {
24
+ const link = /*#__PURE__*/ jsx(Link, {
24
25
  as: Component,
25
26
  ...rest,
26
27
  ...props,
@@ -28,6 +29,12 @@ const LinkItemComponent = fixedForwardRef(({ active, inactiveText, variant, size
28
29
  ref: forwardedRef,
29
30
  children
30
31
  });
32
+ return _PrivateTooltipText ? /*#__PURE__*/ jsx(Tooltip, {
33
+ ref: forwardedRef,
34
+ text: _PrivateTooltipText,
35
+ direction: "e",
36
+ children: link
37
+ }) : link;
31
38
  },
32
39
  children: props.children
33
40
  });
@@ -60,6 +60,7 @@ declare const ActionList: (<As extends React.ElementType = "ul">(props: Distribu
60
60
  role?: string;
61
61
  className?: string;
62
62
  }>>;
63
+ _PrivateTooltipText?: string;
63
64
  className?: string;
64
65
  groupId?: string;
65
66
  renderItem?: (item: React.FC<React.PropsWithChildren<{
@@ -100,6 +101,8 @@ declare const ActionList: (<As extends React.ElementType = "ul">(props: Distribu
100
101
  className?: string;
101
102
  }, "as"> & {
102
103
  as?: As | undefined;
104
+ } & {
105
+ _PrivateTooltipText?: string;
103
106
  } & import("react").RefAttributes<unknown>) => React.ReactNode)>; /** Visually separates `Item`s or `Group`s in an `ActionList`. */
104
107
  Divider: FCWithSlotMarker<import("react").PropsWithChildren<ActionListDividerProps>>; /** Secondary text which provides additional information about an `Item`. */
105
108
  Description: FCWithSlotMarker<import("react").PropsWithChildren<ActionListDescriptionProps>>; /** Icon (or similar) positioned before `Item` text. */
@@ -55,6 +55,10 @@ type ActionListItemProps<As extends React.ElementType = 'li'> = ExcludeSelectEve
55
55
  * Private API for use internally only. Used by LinkItem to wrap contents in an anchor
56
56
  */
57
57
  _PrivateItemWrapper?: React.FC<React.PropsWithChildren<MenuItemProps>>;
58
+ /**
59
+ * Private API for use internally only. Adds a tooltip to the interactive item.
60
+ */
61
+ _PrivateTooltipText?: string;
58
62
  className?: string;
59
63
  groupId?: string;
60
64
  renderItem?: (item: React.FC<React.PropsWithChildren<MenuItemProps>>) => React.ReactNode;
@@ -24,6 +24,7 @@ type NavListItemProps<As extends React.ElementType = React.ElementType> = Polymo
24
24
  href?: string;
25
25
  'aria-current'?: 'page' | 'step' | 'location' | 'date' | 'time' | 'true' | 'false' | boolean;
26
26
  inactiveText?: string;
27
+ tooltipText?: string;
27
28
  }>;
28
29
  type NavListSubNavProps = {
29
30
  children: React.ReactNode;
@@ -59,6 +60,7 @@ declare const NavList: React.ForwardRefExoticComponent<Omit<NavListProps, "ref">
59
60
  href?: string;
60
61
  'aria-current'?: "page" | "step" | "location" | "date" | "time" | "true" | "false" | boolean;
61
62
  inactiveText?: string;
63
+ tooltipText?: string;
62
64
  }, "as"> & {
63
65
  as?: As | undefined;
64
66
  } & React.RefAttributes<unknown>) => React.ReactNode) & {
@@ -165,7 +165,7 @@ const Heading = (t0) => {
165
165
  };
166
166
  Heading.displayName = "NavList.Heading";
167
167
  Heading.__SLOT__ = Symbol("NavList.Heading");
168
- const ItemComponent = fixedForwardRef(({ "aria-current": ariaCurrent, children, defaultOpen, as: Component, ...props }, ref) => {
168
+ const ItemComponent = fixedForwardRef(({ "aria-current": ariaCurrent, children, defaultOpen, tooltipText, as: Component, ...props }, ref) => {
169
169
  const { depth } = React.useContext(SubNavContext);
170
170
  const [slots, childrenWithoutSubNavOrTrailingAction] = useSlots(children, {
171
171
  subNav: SubNav,
@@ -177,6 +177,7 @@ const ItemComponent = fixedForwardRef(({ "aria-current": ariaCurrent, children,
177
177
  subNav,
178
178
  depth,
179
179
  defaultOpen,
180
+ tooltipText,
180
181
  style: { "--subitem-depth": depth },
181
182
  children: childrenWithoutSubNavOrTrailingAction
182
183
  });
@@ -188,6 +189,7 @@ const ItemComponent = fixedForwardRef(({ "aria-current": ariaCurrent, children,
188
189
  active: Boolean(ariaCurrent) && ariaCurrent !== "false",
189
190
  style: { "--subitem-depth": depth },
190
191
  "data-component": "NavList.Item",
192
+ _PrivateTooltipText: tooltipText,
191
193
  ...props,
192
194
  children
193
195
  });
@@ -207,8 +209,8 @@ function hasCurrentNavItem(node) {
207
209
  }
208
210
  function ItemWithSubNav(t0) {
209
211
  var _ref;
210
- const $ = c(29);
211
- const { children, subNav, defaultOpen, style } = t0;
212
+ const $ = c(30);
213
+ const { children, subNav, defaultOpen, tooltipText, style } = t0;
212
214
  const buttonId = useId$1();
213
215
  const subNavId = useId$1();
214
216
  let t1;
@@ -281,7 +283,7 @@ function ItemWithSubNav(t0) {
281
283
  $[17] = t9;
282
284
  } else t9 = $[17];
283
285
  let t10;
284
- if ($[18] !== buttonId || $[19] !== children || $[20] !== isOpen || $[21] !== style || $[22] !== subNavId || $[23] !== t5 || $[24] !== t9) {
286
+ if ($[18] !== buttonId || $[19] !== children || $[20] !== isOpen || $[21] !== style || $[22] !== subNavId || $[23] !== t5 || $[24] !== t9 || $[25] !== tooltipText) {
285
287
  t10 = /*#__PURE__*/ jsxs(ActionList.Item, {
286
288
  id: buttonId,
287
289
  "aria-expanded": isOpen,
@@ -290,6 +292,7 @@ function ItemWithSubNav(t0) {
290
292
  onSelect: t6,
291
293
  style,
292
294
  "data-component": "NavList.Item",
295
+ _PrivateTooltipText: tooltipText,
293
296
  children: [
294
297
  children,
295
298
  t7,
@@ -303,18 +306,19 @@ function ItemWithSubNav(t0) {
303
306
  $[22] = subNavId;
304
307
  $[23] = t5;
305
308
  $[24] = t9;
306
- $[25] = t10;
307
- } else t10 = $[25];
309
+ $[25] = tooltipText;
310
+ $[26] = t10;
311
+ } else t10 = $[26];
308
312
  let t11;
309
- if ($[26] !== t10 || $[27] !== t4) {
313
+ if ($[27] !== t10 || $[28] !== t4) {
310
314
  t11 = /*#__PURE__*/ jsx(ItemWithSubNavContext.Provider, {
311
315
  value: t4,
312
316
  children: t10
313
317
  });
314
- $[26] = t10;
315
- $[27] = t4;
316
- $[28] = t11;
317
- } else t11 = $[28];
318
+ $[27] = t10;
319
+ $[28] = t4;
320
+ $[29] = t11;
321
+ } else t11 = $[29];
318
322
  return t11;
319
323
  }
320
324
  function _temp(open) {
@@ -1,105 +1,43 @@
1
1
  import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
2
2
  import { PortalContext } from "./PortalContext.js";
3
3
  import { DEFAULT_PORTAL_CONTAINER_NAME, ensureDefaultPortal, getPortalRoot } from "./portalRoot.js";
4
- import { c } from "react-compiler-runtime";
5
- import React, { useContext, useSyncExternalStore } from "react";
4
+ import React, { useContext } from "react";
6
5
  import { createPortal } from "react-dom";
7
6
  //#region src/Portal/Portal.tsx
8
- const subscribe = () => () => {};
9
- const getSnapshot = () => true;
10
- const getServerSnapshot = () => false;
11
- /**
12
- * Returns `true` only when React is rendering on the client, and not as part of
13
- * hydrating server-rendered markup.
14
- *
15
- * `Portal` needs this because React's server renderer throws when it encounters a
16
- * portal, and portaled content is never part of the server-rendered markup.
17
- *
18
- * `useSyncExternalStore` is used rather than a `useEffect`/`useState` "is mounted"
19
- * flag because it only defers the portal for the renders that need it: it returns
20
- * `false` while server rendering and for the hydration pass (keeping hydration
21
- * consistent with the server markup), but `true` from the very first render of a
22
- * client-only render. That way client-rendered portals — the overwhelmingly common
23
- * case for overlays, dialogs and menus — still mount their children in the same
24
- * commit as the `Portal` itself, so refs into portaled content are populated by the
25
- * time the parent's layout effects run.
26
- */
27
- function useIsClientRender() {
28
- return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
29
- }
30
7
  /**
31
8
  * Creates a React Portal, placing all children in a separate physical DOM root node.
32
9
  * @see https://reactjs.org/docs/portals.html
33
10
  */
34
- const Portal = (t0) => {
35
- const $ = c(12);
36
- const { children, onMount, containerName: _containerName } = t0;
11
+ const Portal = ({ children, onMount, containerName: _containerName }) => {
37
12
  const { portalContainerName } = useContext(PortalContext);
38
- const isClientRender = useIsClientRender();
39
- const onMountRef = React.useRef(onMount);
40
- let t1;
41
- if ($[0] !== onMount) {
42
- t1 = () => {
43
- onMountRef.current = onMount;
44
- };
45
- $[0] = onMount;
46
- $[1] = t1;
47
- } else t1 = $[1];
48
- useIsomorphicLayoutEffect(t1);
49
- const [element] = React.useState(_temp);
50
- let t2;
51
- let t3;
52
- if ($[2] !== _containerName || $[3] !== element || $[4] !== isClientRender || $[5] !== portalContainerName) {
53
- t2 = () => {
54
- var _onMountRef$current;
55
- if (!element || !isClientRender) return;
56
- let containerName = _containerName !== null && _containerName !== void 0 ? _containerName : portalContainerName;
57
- if (containerName === void 0) {
58
- containerName = DEFAULT_PORTAL_CONTAINER_NAME;
59
- ensureDefaultPortal();
60
- }
61
- const parentElement = getPortalRoot(containerName);
62
- if (!parentElement) throw new Error(`Portal container '${containerName}' is not yet registered. Container must be registered with registerPortalRoot before use.`);
63
- parentElement.appendChild(element);
64
- (_onMountRef$current = onMountRef.current) === null || _onMountRef$current === void 0 || _onMountRef$current.call(onMountRef);
65
- return () => {
66
- parentElement.removeChild(element);
67
- };
68
- };
69
- t3 = [
70
- element,
71
- isClientRender,
72
- _containerName,
73
- portalContainerName
74
- ];
75
- $[2] = _containerName;
76
- $[3] = element;
77
- $[4] = isClientRender;
78
- $[5] = portalContainerName;
79
- $[6] = t2;
80
- $[7] = t3;
81
- } else {
82
- t2 = $[6];
83
- t3 = $[7];
13
+ const elementRef = React.useRef(null);
14
+ if (!elementRef.current) {
15
+ const div = document.createElement("div");
16
+ div.setAttribute("data-component", "Portal");
17
+ div.style.position = "relative";
18
+ div.style.zIndex = "1";
19
+ elementRef.current = div;
84
20
  }
85
- useIsomorphicLayoutEffect(t2, t3);
86
- let t4;
87
- if ($[8] !== children || $[9] !== element || $[10] !== isClientRender) {
88
- t4 = element && isClientRender ? /*#__PURE__*/ createPortal(children, element) : null;
89
- $[8] = children;
90
- $[9] = element;
91
- $[10] = isClientRender;
92
- $[11] = t4;
93
- } else t4 = $[11];
94
- return t4;
21
+ const element = elementRef.current;
22
+ useIsomorphicLayoutEffect(() => {
23
+ let containerName = _containerName !== null && _containerName !== void 0 ? _containerName : portalContainerName;
24
+ if (containerName === void 0) {
25
+ containerName = DEFAULT_PORTAL_CONTAINER_NAME;
26
+ ensureDefaultPortal();
27
+ }
28
+ const parentElement = getPortalRoot(containerName);
29
+ if (!parentElement) throw new Error(`Portal container '${containerName}' is not yet registered. Container must be registered with registerPortalRoot before use.`);
30
+ parentElement.appendChild(element);
31
+ onMount === null || onMount === void 0 || onMount();
32
+ return () => {
33
+ parentElement.removeChild(element);
34
+ };
35
+ }, [
36
+ element,
37
+ _containerName,
38
+ portalContainerName
39
+ ]);
40
+ return /*#__PURE__*/ createPortal(children, element);
95
41
  };
96
- function _temp() {
97
- if (typeof document === "undefined") return null;
98
- const div = document.createElement("div");
99
- div.setAttribute("data-component", "Portal");
100
- div.style.position = "relative";
101
- div.style.zIndex = "1";
102
- return div;
103
- }
104
42
  //#endregion
105
43
  export { Portal };
@@ -1,83 +1,68 @@
1
- import { c } from "react-compiler-runtime";
2
1
  import React from "react";
3
2
  import { iterateFocusableElements } from "@primer/behaviors/utils";
4
3
  //#region src/hooks/useMenuInitialFocus.ts
5
4
  const useMenuInitialFocus = (open, containerRef, anchorRef) => {
6
- const $ = c(9);
5
+ /**
6
+ * We need to pick the first element to focus based on how the menu was opened,
7
+ * however, we need to wait for the menu to be open to set focus.
8
+ * This is why we use set openingKey in state and have 2 effects
9
+ */
7
10
  const [openingGesture, setOpeningGesture] = React.useState(void 0);
8
- let t0;
9
- let t1;
10
- if ($[0] !== anchorRef) {
11
- t0 = function inferOpeningKey() {
12
- const anchorElement = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current;
13
- const clickHandler = (event) => {
14
- if (event.detail !== 0) setOpeningGesture("mouse-click");
15
- };
16
- const keydownHandler = (event_0) => {
17
- if ([
18
- "Space",
19
- "Enter",
20
- "ArrowDown",
21
- "ArrowUp"
22
- ].includes(event_0.code)) setOpeningGesture(event_0.code);
23
- };
24
- anchorElement === null || anchorElement === void 0 || anchorElement.addEventListener("click", clickHandler);
25
- anchorElement === null || anchorElement === void 0 || anchorElement.addEventListener("keydown", keydownHandler);
26
- return () => {
27
- anchorElement === null || anchorElement === void 0 || anchorElement.removeEventListener("click", clickHandler);
28
- anchorElement === null || anchorElement === void 0 || anchorElement.removeEventListener("keydown", keydownHandler);
29
- };
11
+ React.useEffect(function inferOpeningKey() {
12
+ const anchorElement = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current;
13
+ const clickHandler = (event) => {
14
+ if (event.detail !== 0) setOpeningGesture("mouse-click");
30
15
  };
31
- t1 = [anchorRef];
32
- $[0] = anchorRef;
33
- $[1] = t0;
34
- $[2] = t1;
35
- } else {
36
- t0 = $[1];
37
- t1 = $[2];
38
- }
39
- React.useEffect(t0, t1);
40
- let t2;
41
- let t3;
42
- if ($[3] !== anchorRef || $[4] !== containerRef || $[5] !== open || $[6] !== openingGesture) {
43
- t2 = function moveFocusOnOpen() {
44
- if (!open || !(containerRef !== null && containerRef !== void 0 && containerRef.current)) return;
45
- const iterable = iterateFocusableElements(containerRef.current);
46
- if (openingGesture === "mouse-click") if (anchorRef !== null && anchorRef !== void 0 && anchorRef.current) anchorRef.current.focus();
47
- else throw new Error("For focus management, please attach anchorRef");
48
- else if (openingGesture && [
49
- "ArrowDown",
16
+ const keydownHandler = (event) => {
17
+ if ([
50
18
  "Space",
51
- "Enter"
52
- ].includes(openingGesture)) {
53
- const firstElement = iterable.next().value;
54
- setTimeout(() => firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus());
55
- } else if ("ArrowUp" === openingGesture) {
56
- const elements = [...iterable];
57
- const lastElement = elements[elements.length - 1];
58
- setTimeout(() => lastElement.focus());
59
- } else {
60
- const firstElement_0 = iterable.next().value;
61
- setTimeout(() => firstElement_0 === null || firstElement_0 === void 0 ? void 0 : firstElement_0.focus());
62
- }
19
+ "Enter",
20
+ "ArrowDown",
21
+ "ArrowUp"
22
+ ].includes(event.code)) setOpeningGesture(event.code);
23
+ };
24
+ anchorElement === null || anchorElement === void 0 || anchorElement.addEventListener("click", clickHandler);
25
+ anchorElement === null || anchorElement === void 0 || anchorElement.addEventListener("keydown", keydownHandler);
26
+ return () => {
27
+ anchorElement === null || anchorElement === void 0 || anchorElement.removeEventListener("click", clickHandler);
28
+ anchorElement === null || anchorElement === void 0 || anchorElement.removeEventListener("keydown", keydownHandler);
63
29
  };
64
- t3 = [
65
- open,
66
- openingGesture,
67
- anchorRef,
68
- containerRef
69
- ];
70
- $[3] = anchorRef;
71
- $[4] = containerRef;
72
- $[5] = open;
73
- $[6] = openingGesture;
74
- $[7] = t2;
75
- $[8] = t3;
76
- } else {
77
- t2 = $[7];
78
- t3 = $[8];
79
- }
80
- React.useEffect(t2, t3);
30
+ }, [anchorRef]);
31
+ /**
32
+ * Pick the first element to focus based on the key used to open the Menu
33
+ * Click: anchor
34
+ * ArrowDown | Space | Enter: first element
35
+ * ArrowUp: last element
36
+ */
37
+ React.useEffect(function moveFocusOnOpen() {
38
+ if (!open || !(containerRef !== null && containerRef !== void 0 && containerRef.current)) return;
39
+ const iterable = iterateFocusableElements(containerRef.current);
40
+ if (openingGesture === "mouse-click") if (anchorRef !== null && anchorRef !== void 0 && anchorRef.current) anchorRef.current.focus();
41
+ else throw new Error("For focus management, please attach anchorRef");
42
+ else if (openingGesture && [
43
+ "ArrowDown",
44
+ "Space",
45
+ "Enter"
46
+ ].includes(openingGesture)) {
47
+ const firstElement = iterable.next().value;
48
+ /** We push imperative focus to the next tick to prevent React's batching */
49
+ setTimeout(() => firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus());
50
+ } else if ("ArrowUp" === openingGesture) {
51
+ const elements = [...iterable];
52
+ const lastElement = elements[elements.length - 1];
53
+ setTimeout(() => lastElement.focus());
54
+ } else {
55
+ /** if the menu was not opened with the anchor, we default to the first element
56
+ * for example: with keyboard shortcut (see stories/fixtures)
57
+ */
58
+ const firstElement = iterable.next().value;
59
+ setTimeout(() => firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus());
60
+ }
61
+ }, [
62
+ open,
63
+ openingGesture,
64
+ anchorRef
65
+ ]);
81
66
  };
82
67
  //#endregion
83
68
  export { useMenuInitialFocus };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260812113051",
4
+ "version": "0.0.0-20260812225710",
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",