@primer/react 0.0.0-20260218182609 → 0.0.0-20260218210324

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +1 -3
  2. package/dist/ActionList/Item.d.ts.map +1 -1
  3. package/dist/ActionList/Item.js +182 -591
  4. package/dist/ActionList/List.d.ts.map +1 -1
  5. package/dist/ActionList/List.js +5 -6
  6. package/dist/UnderlineNav/UnderlineNav-e56ca858.css +2 -0
  7. package/dist/UnderlineNav/UnderlineNav-e56ca858.css.map +1 -0
  8. package/dist/UnderlineNav/UnderlineNav.d.ts.map +1 -1
  9. package/dist/UnderlineNav/UnderlineNav.js +82 -324
  10. package/dist/UnderlineNav/UnderlineNav.module.css.js +2 -2
  11. package/dist/UnderlineNav/UnderlineNavContext.d.ts +4 -11
  12. package/dist/UnderlineNav/UnderlineNavContext.d.ts.map +1 -1
  13. package/dist/UnderlineNav/UnderlineNavContext.js +2 -3
  14. package/dist/UnderlineNav/UnderlineNavItem-db9dc5d0.css +2 -0
  15. package/dist/UnderlineNav/UnderlineNavItem-db9dc5d0.css.map +1 -0
  16. package/dist/UnderlineNav/UnderlineNavItem.d.ts.map +1 -1
  17. package/dist/UnderlineNav/UnderlineNavItem.js +94 -85
  18. package/dist/UnderlineNav/UnderlineNavItem.module.css.js +1 -1
  19. package/dist/internal/components/UnderlineTabbedInterface-135d7279.css +2 -0
  20. package/dist/internal/components/UnderlineTabbedInterface-135d7279.css.map +1 -0
  21. package/dist/internal/components/UnderlineTabbedInterface.d.ts +0 -1
  22. package/dist/internal/components/UnderlineTabbedInterface.d.ts.map +1 -1
  23. package/dist/internal/components/UnderlineTabbedInterface.js +41 -48
  24. package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
  25. package/package.json +1 -1
  26. package/dist/UnderlineNav/UnderlineNav-4344d9b0.css +0 -2
  27. package/dist/UnderlineNav/UnderlineNav-4344d9b0.css.map +0 -1
  28. package/dist/UnderlineNav/UnderlineNavItem-b65e8fd3.css +0 -2
  29. package/dist/UnderlineNav/UnderlineNavItem-b65e8fd3.css.map +0 -1
  30. package/dist/UnderlineNav/styles.d.ts +0 -16
  31. package/dist/UnderlineNav/styles.d.ts.map +0 -1
  32. package/dist/UnderlineNav/styles.js +0 -19
  33. package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css +0 -2
  34. package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css.map +0 -1
@@ -108,132 +108,50 @@ const DivItemContainerNoBox = /*#__PURE__*/React.forwardRef((t0, forwardedRef) =
108
108
  }
109
109
  return t2;
110
110
  });
111
- const baseSlots = {
112
- leadingVisual: LeadingVisual,
113
- trailingVisual: TrailingVisual,
114
- trailingAction: TrailingAction,
115
- subItem: SubItem
116
- };
117
- const slotsConfig = {
118
- ...baseSlots,
119
- description: Description
120
- };
121
-
122
- // Pre-allocated array for selectableRoles check, avoids per-render allocation
123
- const selectableRoles = ['menuitemradio', 'menuitemcheckbox', 'option'];
124
- const listRoleTypes = ['listbox', 'menu', 'list'];
125
- const UnwrappedItem = (t0, forwardedRef) => {
111
+ const UnwrappedItem = ({
112
+ variant = 'default',
113
+ size = 'medium',
114
+ disabled = false,
115
+ inactiveText,
116
+ selected = undefined,
117
+ active = false,
118
+ onSelect: onSelectUser,
119
+ id,
120
+ role,
121
+ loading,
122
+ _PrivateItemWrapper,
123
+ className,
124
+ groupId: _groupId,
125
+ renderItem: _renderItem,
126
+ handleAddItem: _handleAddItem,
127
+ ...props
128
+ }, forwardedRef) => {
126
129
  var _slots$trailingVisual, _slots$description$pr, _slots$description;
127
- const $ = c(151);
128
- let _PrivateItemWrapper;
129
- let className;
130
- let id;
131
- let inactiveText;
132
- let loading;
133
- let onSelectUser;
134
- let props;
135
- let role;
136
- let t1;
137
- let t2;
138
- let t3;
139
- let t4;
140
- let t5;
141
- if ($[0] !== t0) {
142
- const {
143
- variant: t6,
144
- size: t7,
145
- disabled: t8,
146
- inactiveText: t9,
147
- selected: t10,
148
- active: t11,
149
- onSelect: t12,
150
- id: t13,
151
- role: t14,
152
- loading: t15,
153
- _PrivateItemWrapper: t16,
154
- className: t17,
155
- groupId: _groupId,
156
- renderItem: _renderItem,
157
- handleAddItem: _handleAddItem,
158
- ...t18
159
- } = t0;
160
- t1 = t6;
161
- t2 = t7;
162
- t3 = t8;
163
- inactiveText = t9;
164
- t4 = t10;
165
- t5 = t11;
166
- onSelectUser = t12;
167
- id = t13;
168
- role = t14;
169
- loading = t15;
170
- _PrivateItemWrapper = t16;
171
- className = t17;
172
- props = t18;
173
- $[0] = t0;
174
- $[1] = _PrivateItemWrapper;
175
- $[2] = className;
176
- $[3] = id;
177
- $[4] = inactiveText;
178
- $[5] = loading;
179
- $[6] = onSelectUser;
180
- $[7] = props;
181
- $[8] = role;
182
- $[9] = t1;
183
- $[10] = t2;
184
- $[11] = t3;
185
- $[12] = t4;
186
- $[13] = t5;
187
- } else {
188
- _PrivateItemWrapper = $[1];
189
- className = $[2];
190
- id = $[3];
191
- inactiveText = $[4];
192
- loading = $[5];
193
- onSelectUser = $[6];
194
- props = $[7];
195
- role = $[8];
196
- t1 = $[9];
197
- t2 = $[10];
198
- t3 = $[11];
199
- t4 = $[12];
200
- t5 = $[13];
201
- }
202
- const variant = t1 === undefined ? "default" : t1;
203
- const size = t2 === undefined ? "medium" : t2;
204
- const disabled = t3 === undefined ? false : t3;
205
- const selected = t4 === undefined ? undefined : t4;
206
- const active = t5 === undefined ? false : t5;
207
- const [partialSlots, childrenWithoutSlots] = useSlots(props.children, slotsConfig);
208
- let t6;
209
- if ($[14] !== partialSlots) {
210
- t6 = {
211
- description: undefined,
212
- ...partialSlots
213
- };
214
- $[14] = partialSlots;
215
- $[15] = t6;
216
- } else {
217
- t6 = $[15];
218
- }
219
- const slots = t6;
130
+ const baseSlots = {
131
+ leadingVisual: LeadingVisual,
132
+ trailingVisual: TrailingVisual,
133
+ trailingAction: TrailingAction,
134
+ subItem: SubItem
135
+ };
136
+ const [partialSlots, childrenWithoutSlots] = useSlots(props.children, {
137
+ ...baseSlots,
138
+ description: Description
139
+ });
140
+ const slots = {
141
+ description: undefined,
142
+ ...partialSlots
143
+ };
220
144
  const {
221
145
  container,
222
146
  afterSelect,
223
147
  selectionAttribute,
224
148
  defaultTrailingVisual
225
149
  } = React.useContext(ActionListContainerContext);
226
- let t7;
227
- if ($[16] !== defaultTrailingVisual) {
228
- t7 = defaultTrailingVisual ? /*#__PURE__*/jsx(TrailingVisual, {
229
- children: defaultTrailingVisual
230
- }) : null;
231
- $[16] = defaultTrailingVisual;
232
- $[17] = t7;
233
- } else {
234
- t7 = $[17];
235
- }
236
- const wrappedDefaultTrailingVisual = t7;
150
+
151
+ // Be sure to avoid rendering the container unless there is a default
152
+ const wrappedDefaultTrailingVisual = defaultTrailingVisual ? /*#__PURE__*/jsx(TrailingVisual, {
153
+ children: defaultTrailingVisual
154
+ }) : null;
237
155
  const trailingVisual = (_slots$trailingVisual = slots.trailingVisual) !== null && _slots$trailingVisual !== void 0 ? _slots$trailingVisual : wrappedDefaultTrailingVisual;
238
156
  const {
239
157
  role: listRole,
@@ -243,127 +161,57 @@ const UnwrappedItem = (t0, forwardedRef) => {
243
161
  selectionVariant: groupSelectionVariant
244
162
  } = React.useContext(GroupContext);
245
163
  const inactive = Boolean(inactiveText);
246
- const menuContext = container === "ActionMenu" || container === "SelectPanel" || container === "FilteredActionList";
247
- let t8;
248
- if ($[18] !== inactive || $[19] !== listRole) {
249
- t8 = inactive && !(listRole !== undefined && ["menu", "listbox"].includes(listRole));
250
- $[18] = inactive;
251
- $[19] = listRole;
252
- $[20] = t8;
253
- } else {
254
- t8 = $[20];
255
- }
256
- const showInactiveIndicator = t8;
257
- let t9;
258
- if ($[21] !== onSelectUser) {
259
- t9 = (event, afterSelect_0) => {
260
- if (typeof onSelectUser === "function") {
261
- onSelectUser(event);
262
- }
263
- if (event.defaultPrevented) {
264
- return;
265
- }
266
- if (typeof afterSelect_0 === "function") {
267
- afterSelect_0(event);
268
- }
269
- };
270
- $[21] = onSelectUser;
271
- $[22] = t9;
272
- } else {
273
- t9 = $[22];
274
- }
275
- const onSelect = t9;
164
+ // TODO change `menuContext` check to ```listRole !== undefined && ['menu', 'listbox'].includes(listRole)```
165
+ // once we have a better way to handle existing usage in dotcom that incorrectly use ActionList.TrailingAction
166
+ const menuContext = container === 'ActionMenu' || container === 'SelectPanel' || container === 'FilteredActionList';
167
+ // TODO: when we change `menuContext` to check `listRole` instead of `container`
168
+ const showInactiveIndicator = inactive && !(listRole !== undefined && ['menu', 'listbox'].includes(listRole));
169
+ const onSelect = React.useCallback((event, afterSelect_0) => {
170
+ if (typeof onSelectUser === 'function') onSelectUser(event);
171
+ if (event.defaultPrevented) return;
172
+ if (typeof afterSelect_0 === 'function') afterSelect_0(event);
173
+ }, [onSelectUser]);
276
174
  const selectionVariant = groupSelectionVariant ? groupSelectionVariant : listSelectionVariant;
175
+
176
+ /** Infer item role based on the container */
277
177
  let inferredItemRole;
278
- if (container === "ActionMenu") {
279
- if (selectionVariant === "single") {
280
- inferredItemRole = "menuitemradio";
281
- } else {
282
- if (selectionVariant === "multiple") {
283
- inferredItemRole = "menuitemcheckbox";
284
- } else {
285
- inferredItemRole = "menuitem";
286
- }
287
- }
288
- } else {
289
- if (listRole === "listbox") {
290
- if (selectionVariant !== undefined && !role) {
291
- inferredItemRole = "option";
292
- }
293
- } else {
294
- if (listRole === "tablist") {
295
- inferredItemRole = "tab";
296
- }
297
- }
178
+ if (container === 'ActionMenu') {
179
+ if (selectionVariant === 'single') inferredItemRole = 'menuitemradio';else if (selectionVariant === 'multiple') inferredItemRole = 'menuitemcheckbox';else inferredItemRole = 'menuitem';
180
+ } else if (listRole === 'listbox') {
181
+ if (selectionVariant !== undefined && !role) inferredItemRole = 'option';
182
+ } else if (listRole === 'tablist') {
183
+ inferredItemRole = 'tab';
298
184
  }
299
185
  const itemRole = role || inferredItemRole;
300
186
  if (slots.trailingAction) {
301
- !!menuContext ? process.env.NODE_ENV !== "production" ? invariant(false, "ActionList.TrailingAction can not be used within a list with an ARIA role of \"menu\" or \"listbox\".") : invariant(false) : void 0;
187
+ !!menuContext ? process.env.NODE_ENV !== "production" ? invariant(false, `ActionList.TrailingAction can not be used within a list with an ARIA role of "menu" or "listbox".`) : invariant(false) : void 0;
302
188
  }
189
+
190
+ /** Infer the proper selection attribute based on the item's role */
303
191
  let inferredSelectionAttribute;
304
- if (itemRole === "menuitemradio" || itemRole === "menuitemcheckbox") {
305
- inferredSelectionAttribute = "aria-checked";
306
- } else {
307
- if (itemRole === "option") {
308
- inferredSelectionAttribute = "aria-selected";
309
- }
310
- }
192
+ if (itemRole === 'menuitemradio' || itemRole === 'menuitemcheckbox') inferredSelectionAttribute = 'aria-checked';else if (itemRole === 'option') inferredSelectionAttribute = 'aria-selected';
311
193
  const itemSelectionAttribute = selectionAttribute || inferredSelectionAttribute;
312
- const listItemSemantics = itemRole === "option" || itemRole === "menuitem" || itemRole === "menuitemradio" || itemRole === "menuitemcheckbox" || itemRole === "tab";
313
- let t10;
314
- if ($[23] !== inactive || $[24] !== listItemSemantics || $[25] !== listRole) {
315
- t10 = listRole && listRoleTypes.includes(listRole) || inactive || listItemSemantics;
316
- $[23] = inactive;
317
- $[24] = listItemSemantics;
318
- $[25] = listRole;
319
- $[26] = t10;
320
- } else {
321
- t10 = $[26];
322
- }
323
- const listSemantics = t10;
194
+ // Ensures ActionList.Item retains list item semantics if a valid ARIA role is applied, or if item is inactive
195
+ const listItemSemantics = itemRole === 'option' || itemRole === 'menuitem' || itemRole === 'menuitemradio' || itemRole === 'menuitemcheckbox' || itemRole === 'tab';
196
+ const listRoleTypes = ['listbox', 'menu', 'list'];
197
+ const listSemantics = listRole && listRoleTypes.includes(listRole) || inactive || listItemSemantics;
324
198
  const buttonSemantics = !listSemantics && !_PrivateItemWrapper;
325
- let t11;
326
- if ($[27] !== afterSelect || $[28] !== disabled || $[29] !== inactive || $[30] !== loading || $[31] !== onSelect) {
327
- t11 = event_0 => {
328
- if (disabled || inactive || loading) {
329
- return;
330
- }
331
- onSelect(event_0, afterSelect);
332
- };
333
- $[27] = afterSelect;
334
- $[28] = disabled;
335
- $[29] = inactive;
336
- $[30] = loading;
337
- $[31] = onSelect;
338
- $[32] = t11;
339
- } else {
340
- t11 = $[32];
341
- }
342
- const clickHandler = t11;
343
- let t12;
344
- if ($[33] !== afterSelect || $[34] !== disabled || $[35] !== inactive || $[36] !== loading || $[37] !== onSelect) {
345
- t12 = event_1 => {
346
- if (disabled || inactive || loading) {
347
- return;
348
- }
349
- if (event_1.key === " " || event_1.key === "Enter") {
350
- if (event_1.key === " ") {
351
- event_1.preventDefault();
352
- event_1.defaultPrevented = false;
353
- }
354
- onSelect(event_1, afterSelect);
199
+ const clickHandler = React.useCallback(event_0 => {
200
+ if (disabled || inactive || loading) return;
201
+ onSelect(event_0, afterSelect);
202
+ }, [onSelect, disabled, inactive, afterSelect, loading]);
203
+ const keyPressHandler = React.useCallback(event_1 => {
204
+ if (disabled || inactive || loading) return;
205
+ if ([' ', 'Enter'].includes(event_1.key)) {
206
+ if (event_1.key === ' ') {
207
+ event_1.preventDefault(); // prevent scrolling on Space
208
+ // immediately reset defaultPrevented once its job is done
209
+ // so as to not disturb the functions that use that event after this
210
+ event_1.defaultPrevented = false;
355
211
  }
356
- };
357
- $[33] = afterSelect;
358
- $[34] = disabled;
359
- $[35] = inactive;
360
- $[36] = loading;
361
- $[37] = onSelect;
362
- $[38] = t12;
363
- } else {
364
- t12 = $[38];
365
- }
366
- const keyPressHandler = t12;
212
+ onSelect(event_1, afterSelect);
213
+ }
214
+ }, [onSelect, disabled, loading, inactive, afterSelect]);
367
215
  const itemId = useId(id);
368
216
  const labelId = `${itemId}--label`;
369
217
  const inlineDescriptionId = `${itemId}--inline-description`;
@@ -372,377 +220,120 @@ const UnwrappedItem = (t0, forwardedRef) => {
372
220
  const inactiveWarningId = inactive && !showInactiveIndicator ? `${itemId}--warning-message` : undefined;
373
221
  const DefaultItemWrapper = listSemantics ? DivItemContainerNoBox : ButtonItemContainerNoBox;
374
222
  const ItemWrapper = _PrivateItemWrapper || DefaultItemWrapper;
375
- let t13;
376
- if ($[39] !== itemRole || $[40] !== itemSelectionAttribute) {
377
- t13 = itemSelectionAttribute && itemRole && selectableRoles.includes(itemRole);
378
- $[39] = itemRole;
379
- $[40] = itemSelectionAttribute;
380
- $[41] = t13;
381
- } else {
382
- t13 = $[41];
383
- }
384
- const includeSelectionAttribute = t13;
385
- const focusable = showInactiveIndicator ? true : undefined;
386
- 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";
387
- const hasTrailingVisualSlot = Boolean(slots.trailingVisual);
388
- const hasDescriptionSlot = Boolean(slots.description);
389
- let parts;
390
- if ($[42] !== descriptionVariant || $[43] !== hasDescriptionSlot || $[44] !== hasTrailingVisualSlot || $[45] !== inlineDescriptionId || $[46] !== labelId || $[47] !== trailingVisualId) {
391
- parts = [labelId];
392
- if (hasTrailingVisualSlot) {
393
- parts.push(trailingVisualId);
394
- }
395
- if (hasDescriptionSlot && descriptionVariant === "inline") {
396
- parts.push(inlineDescriptionId);
397
- }
398
- $[42] = descriptionVariant;
399
- $[43] = hasDescriptionSlot;
400
- $[44] = hasTrailingVisualSlot;
401
- $[45] = inlineDescriptionId;
402
- $[46] = labelId;
403
- $[47] = trailingVisualId;
404
- $[48] = parts;
405
- } else {
406
- parts = $[48];
407
- }
408
- const ariaLabelledBy = parts.join(" ");
409
- let parts_0;
410
- if ($[49] !== blockDescriptionId || $[50] !== descriptionVariant || $[51] !== hasDescriptionSlot || $[52] !== inactiveWarningId) {
411
- parts_0 = [];
412
- if (hasDescriptionSlot && descriptionVariant === "block") {
413
- parts_0.push(blockDescriptionId);
414
- }
415
- if (inactiveWarningId) {
416
- parts_0.push(inactiveWarningId);
417
- }
418
- $[49] = blockDescriptionId;
419
- $[50] = descriptionVariant;
420
- $[51] = hasDescriptionSlot;
421
- $[52] = inactiveWarningId;
422
- $[53] = parts_0;
423
- } else {
424
- parts_0 = $[53];
223
+
224
+ // only apply aria-selected and aria-checked to selectable items
225
+ const selectableRoles = ['menuitemradio', 'menuitemcheckbox', 'option'];
226
+ const includeSelectionAttribute = itemSelectionAttribute && itemRole && selectableRoles.includes(itemRole);
227
+ let focusable;
228
+ if (showInactiveIndicator) {
229
+ focusable = true;
425
230
  }
426
- const ariaDescribedBy = parts_0.length > 0 ? parts_0.join(" ") : undefined;
427
- const t14 = !buttonSemantics ? keyPressHandler : undefined;
428
- const t15 = disabled ? true : undefined;
429
- const t16 = inactive ? true : undefined;
430
- const t17 = loading && !inactive ? true : undefined;
431
- const t18 = focusable ? undefined : 0;
432
- let t19;
433
- if ($[54] !== includeSelectionAttribute || $[55] !== itemSelectionAttribute || $[56] !== selected) {
434
- t19 = includeSelectionAttribute && {
231
+
232
+ // Extract the variant prop value from the description slot component
233
+ 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';
234
+ const menuItemProps = {
235
+ onClick: clickHandler,
236
+ onKeyPress: !buttonSemantics ? keyPressHandler : undefined,
237
+ 'aria-disabled': disabled ? true : undefined,
238
+ 'data-inactive': inactive ? true : undefined,
239
+ 'data-loading': loading && !inactive ? true : undefined,
240
+ tabIndex: focusable ? undefined : 0,
241
+ 'aria-labelledby': `${labelId} ${slots.trailingVisual ? trailingVisualId : ''} ${slots.description && descriptionVariant === 'inline' ? inlineDescriptionId : ''}`,
242
+ 'aria-describedby': [slots.description && descriptionVariant === 'block' ? blockDescriptionId : undefined, inactiveWarningId !== null && inactiveWarningId !== void 0 ? inactiveWarningId : undefined].filter(String).join(' ').trim() || undefined,
243
+ ...(includeSelectionAttribute && {
435
244
  [itemSelectionAttribute]: selected
436
- };
437
- $[54] = includeSelectionAttribute;
438
- $[55] = itemSelectionAttribute;
439
- $[56] = selected;
440
- $[57] = t19;
441
- } else {
442
- t19 = $[57];
443
- }
444
- let t20;
445
- if ($[58] !== ariaDescribedBy || $[59] !== ariaLabelledBy || $[60] !== clickHandler || $[61] !== itemId || $[62] !== itemRole || $[63] !== t14 || $[64] !== t15 || $[65] !== t16 || $[66] !== t17 || $[67] !== t18 || $[68] !== t19) {
446
- t20 = {
447
- onClick: clickHandler,
448
- onKeyPress: t14,
449
- "aria-disabled": t15,
450
- "data-inactive": t16,
451
- "data-loading": t17,
452
- tabIndex: t18,
453
- "aria-labelledby": ariaLabelledBy,
454
- "aria-describedby": ariaDescribedBy,
455
- ...t19,
456
- role: itemRole,
457
- id: itemId
458
- };
459
- $[58] = ariaDescribedBy;
460
- $[59] = ariaLabelledBy;
461
- $[60] = clickHandler;
462
- $[61] = itemId;
463
- $[62] = itemRole;
464
- $[63] = t14;
465
- $[64] = t15;
466
- $[65] = t16;
467
- $[66] = t17;
468
- $[67] = t18;
469
- $[68] = t19;
470
- $[69] = t20;
471
- } else {
472
- t20 = $[69];
473
- }
474
- const menuItemProps = t20;
475
- let t21;
476
- if ($[70] !== _PrivateItemWrapper || $[71] !== forwardedRef || $[72] !== itemRole || $[73] !== listSemantics || $[74] !== menuItemProps || $[75] !== props) {
477
- t21 = _PrivateItemWrapper ? {
478
- role: itemRole ? "none" : undefined,
479
- ...props
480
- } : listSemantics && {
481
- ...menuItemProps,
482
- ...props,
483
- ref: forwardedRef
484
- } || {};
485
- $[70] = _PrivateItemWrapper;
486
- $[71] = forwardedRef;
487
- $[72] = itemRole;
488
- $[73] = listSemantics;
489
- $[74] = menuItemProps;
490
- $[75] = props;
491
- $[76] = t21;
492
- } else {
493
- t21 = $[76];
494
- }
495
- const containerProps = t21;
496
- let t22;
497
- if ($[77] !== _PrivateItemWrapper || $[78] !== forwardedRef || $[79] !== listSemantics || $[80] !== menuItemProps || $[81] !== props) {
498
- t22 = _PrivateItemWrapper ? menuItemProps : !listSemantics && {
499
- ...menuItemProps,
500
- ...props,
501
- ref: forwardedRef
502
- };
503
- $[77] = _PrivateItemWrapper;
504
- $[78] = forwardedRef;
505
- $[79] = listSemantics;
506
- $[80] = menuItemProps;
507
- $[81] = props;
508
- $[82] = t22;
509
- } else {
510
- t22 = $[82];
511
- }
512
- const wrapperProps = t22;
513
- const t23 = Boolean(inactiveText);
514
- let t24;
515
- if ($[83] !== blockDescriptionId || $[84] !== disabled || $[85] !== inlineDescriptionId || $[86] !== size || $[87] !== t23 || $[88] !== trailingVisualId || $[89] !== variant) {
516
- t24 = {
245
+ }),
246
+ role: itemRole,
247
+ id: itemId
248
+ };
249
+ const containerProps = _PrivateItemWrapper ? {
250
+ role: itemRole ? 'none' : undefined,
251
+ ...props
252
+ } :
253
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
254
+ listSemantics && {
255
+ ...menuItemProps,
256
+ ...props,
257
+ ref: forwardedRef
258
+ } || {};
259
+ const wrapperProps = _PrivateItemWrapper ? menuItemProps : !listSemantics && {
260
+ ...menuItemProps,
261
+ ...props,
262
+ ref: forwardedRef
263
+ };
264
+ return /*#__PURE__*/jsx(ItemContext.Provider, {
265
+ value: {
517
266
  variant,
518
267
  size,
519
268
  disabled,
520
- inactive: t23,
269
+ inactive: Boolean(inactiveText),
521
270
  inlineDescriptionId,
522
271
  blockDescriptionId,
523
272
  trailingVisualId
524
- };
525
- $[83] = blockDescriptionId;
526
- $[84] = disabled;
527
- $[85] = inlineDescriptionId;
528
- $[86] = size;
529
- $[87] = t23;
530
- $[88] = trailingVisualId;
531
- $[89] = variant;
532
- $[90] = t24;
533
- } else {
534
- t24 = $[90];
535
- }
536
- const itemContextValue = t24;
537
- const t25 = listSemantics ? forwardedRef : null;
538
- const t26 = variant === "danger" ? variant : undefined;
539
- const t27 = active ? true : undefined;
540
- const t28 = inactiveText ? true : undefined;
541
- const t29 = slots.subItem ? true : undefined;
542
- const t30 = slots.description ? true : false;
543
- let t31;
544
- if ($[91] !== className) {
545
- t31 = clsx(classes.ActionListItem, className);
546
- $[91] = className;
547
- $[92] = t31;
548
- } else {
549
- t31 = $[92];
550
- }
551
- let t32;
552
- if ($[93] === Symbol.for("react.memo_cache_sentinel")) {
553
- t32 = /*#__PURE__*/jsx("span", {
554
- className: classes.Spacer
555
- });
556
- $[93] = t32;
557
- } else {
558
- t32 = $[93];
559
- }
560
- let t33;
561
- if ($[94] !== selected) {
562
- t33 = /*#__PURE__*/jsx(Selection, {
563
- selected: selected,
564
- className: classes.LeadingAction
565
- });
566
- $[94] = selected;
567
- $[95] = t33;
568
- } else {
569
- t33 = $[95];
570
- }
571
- const t34 = showInactiveIndicator ? inactiveText : undefined;
572
- const t35 = Boolean(slots.leadingVisual);
573
- let t36;
574
- if ($[96] !== labelId || $[97] !== loading || $[98] !== slots.leadingVisual || $[99] !== t34 || $[100] !== t35) {
575
- t36 = /*#__PURE__*/jsx(VisualOrIndicator, {
576
- inactiveText: t34,
577
- itemHasLeadingVisual: t35,
578
- labelId: labelId,
579
- loading: loading,
580
- position: "leading",
581
- children: slots.leadingVisual
582
- });
583
- $[96] = labelId;
584
- $[97] = loading;
585
- $[98] = slots.leadingVisual;
586
- $[99] = t34;
587
- $[100] = t35;
588
- $[101] = t36;
589
- } else {
590
- t36 = $[101];
591
- }
592
- const t37 = !!slots.description;
593
- let t38;
594
- if ($[102] !== inactive || $[103] !== loading) {
595
- t38 = loading === true && !inactive && /*#__PURE__*/jsx(VisuallyHidden, {
596
- children: "Loading"
597
- });
598
- $[102] = inactive;
599
- $[103] = loading;
600
- $[104] = t38;
601
- } else {
602
- t38 = $[104];
603
- }
604
- let t39;
605
- if ($[105] !== childrenWithoutSlots || $[106] !== labelId || $[107] !== t38) {
606
- t39 = /*#__PURE__*/jsxs("span", {
607
- id: labelId,
608
- className: classes.ItemLabel,
609
- children: [childrenWithoutSlots, t38]
610
- });
611
- $[105] = childrenWithoutSlots;
612
- $[106] = labelId;
613
- $[107] = t38;
614
- $[108] = t39;
615
- } else {
616
- t39 = $[108];
617
- }
618
- let t40;
619
- if ($[109] !== descriptionVariant || $[110] !== slots.description || $[111] !== t37 || $[112] !== t39) {
620
- t40 = /*#__PURE__*/jsxs(ConditionalWrapper, {
621
- if: t37,
622
- className: classes.ItemDescriptionWrap,
623
- "data-description-variant": descriptionVariant,
624
- children: [t39, slots.description]
625
- });
626
- $[109] = descriptionVariant;
627
- $[110] = slots.description;
628
- $[111] = t37;
629
- $[112] = t39;
630
- $[113] = t40;
631
- } else {
632
- t40 = $[113];
633
- }
634
- const t41 = showInactiveIndicator ? inactiveText : undefined;
635
- const t42 = Boolean(slots.leadingVisual);
636
- let t43;
637
- if ($[114] !== labelId || $[115] !== loading || $[116] !== t41 || $[117] !== t42 || $[118] !== trailingVisual) {
638
- t43 = /*#__PURE__*/jsx(VisualOrIndicator, {
639
- inactiveText: t41,
640
- itemHasLeadingVisual: t42,
641
- labelId: labelId,
642
- loading: loading,
643
- position: "trailing",
644
- children: trailingVisual
645
- });
646
- $[114] = labelId;
647
- $[115] = loading;
648
- $[116] = t41;
649
- $[117] = t42;
650
- $[118] = trailingVisual;
651
- $[119] = t43;
652
- } else {
653
- t43 = $[119];
654
- }
655
- let t44;
656
- if ($[120] !== inactiveText || $[121] !== inactiveWarningId || $[122] !== showInactiveIndicator) {
657
- t44 = !showInactiveIndicator && inactiveText ? /*#__PURE__*/jsx("span", {
658
- className: classes.InactiveWarning,
659
- id: inactiveWarningId,
660
- children: inactiveText
661
- }) : null;
662
- $[120] = inactiveText;
663
- $[121] = inactiveWarningId;
664
- $[122] = showInactiveIndicator;
665
- $[123] = t44;
666
- } else {
667
- t44 = $[123];
668
- }
669
- let t45;
670
- if ($[124] !== t40 || $[125] !== t43 || $[126] !== t44) {
671
- t45 = /*#__PURE__*/jsxs("span", {
672
- className: classes.ActionListSubContent,
673
- "data-component": "ActionList.Item--DividerContainer",
674
- children: [t40, t43, t44]
675
- });
676
- $[124] = t40;
677
- $[125] = t43;
678
- $[126] = t44;
679
- $[127] = t45;
680
- } else {
681
- t45 = $[127];
682
- }
683
- let t46;
684
- if ($[128] !== ItemWrapper || $[129] !== forwardedRef || $[130] !== size || $[131] !== t33 || $[132] !== t36 || $[133] !== t45 || $[134] !== wrapperProps) {
685
- t46 = /*#__PURE__*/jsxs(ItemWrapper, {
686
- ...wrapperProps,
687
- className: classes.ActionListContent,
688
- "data-size": size,
689
- ref: forwardedRef,
690
- children: [t32, t33, t36, t45]
691
- });
692
- $[128] = ItemWrapper;
693
- $[129] = forwardedRef;
694
- $[130] = size;
695
- $[131] = t33;
696
- $[132] = t36;
697
- $[133] = t45;
698
- $[134] = wrapperProps;
699
- $[135] = t46;
700
- } else {
701
- t46 = $[135];
702
- }
703
- const t47 = !inactive && !loading && !menuContext && Boolean(slots.trailingAction) && slots.trailingAction;
704
- let t48;
705
- if ($[136] !== containerProps || $[137] !== slots.subItem || $[138] !== t25 || $[139] !== t26 || $[140] !== t27 || $[141] !== t28 || $[142] !== t29 || $[143] !== t30 || $[144] !== t31 || $[145] !== t46 || $[146] !== t47) {
706
- t48 = /*#__PURE__*/jsxs("li", {
273
+ },
274
+ children: /*#__PURE__*/jsxs("li", {
707
275
  ...containerProps,
708
- ref: t25,
709
- "data-variant": t26,
710
- "data-active": t27,
711
- "data-inactive": t28,
712
- "data-has-subitem": t29,
713
- "data-has-description": t30,
714
- className: t31,
715
- children: [t46, t47, slots.subItem]
716
- });
717
- $[136] = containerProps;
718
- $[137] = slots.subItem;
719
- $[138] = t25;
720
- $[139] = t26;
721
- $[140] = t27;
722
- $[141] = t28;
723
- $[142] = t29;
724
- $[143] = t30;
725
- $[144] = t31;
726
- $[145] = t46;
727
- $[146] = t47;
728
- $[147] = t48;
729
- } else {
730
- t48 = $[147];
731
- }
732
- let t49;
733
- if ($[148] !== itemContextValue || $[149] !== t48) {
734
- t49 = /*#__PURE__*/jsx(ItemContext.Provider, {
735
- value: itemContextValue,
736
- children: t48
737
- });
738
- $[148] = itemContextValue;
739
- $[149] = t48;
740
- $[150] = t49;
741
- } else {
742
- t49 = $[150];
743
- }
744
- return t49;
276
+ ref: listSemantics ? forwardedRef : null,
277
+ "data-variant": variant === 'danger' ? variant : undefined,
278
+ "data-active": active ? true : undefined,
279
+ "data-inactive": inactiveText ? true : undefined,
280
+ "data-has-subitem": slots.subItem ? true : undefined,
281
+ "data-has-description": slots.description ? true : false,
282
+ className: clsx(classes.ActionListItem, className),
283
+ children: [/*#__PURE__*/jsxs(ItemWrapper, {
284
+ ...wrapperProps,
285
+ className: classes.ActionListContent,
286
+ "data-size": size
287
+ // @ts-ignore: ItemWrapper is polymorphic and the ref type depends on the rendered element ('button' or 'li')
288
+ ,
289
+ ref: forwardedRef,
290
+ children: [/*#__PURE__*/jsx("span", {
291
+ className: classes.Spacer
292
+ }), /*#__PURE__*/jsx(Selection, {
293
+ selected: selected,
294
+ className: classes.LeadingAction
295
+ }), /*#__PURE__*/jsx(VisualOrIndicator, {
296
+ inactiveText: showInactiveIndicator ? inactiveText : undefined,
297
+ itemHasLeadingVisual: Boolean(slots.leadingVisual),
298
+ labelId: labelId,
299
+ loading: loading,
300
+ position: "leading",
301
+ children: slots.leadingVisual
302
+ }), /*#__PURE__*/jsxs("span", {
303
+ className: classes.ActionListSubContent,
304
+ "data-component": "ActionList.Item--DividerContainer",
305
+ children: [/*#__PURE__*/jsxs(ConditionalWrapper, {
306
+ if: !!slots.description,
307
+ className: classes.ItemDescriptionWrap,
308
+ "data-description-variant": descriptionVariant,
309
+ children: [/*#__PURE__*/jsxs("span", {
310
+ id: labelId,
311
+ className: classes.ItemLabel,
312
+ children: [childrenWithoutSlots, loading === true && !inactive && /*#__PURE__*/jsx(VisuallyHidden, {
313
+ children: "Loading"
314
+ })]
315
+ }), slots.description]
316
+ }), /*#__PURE__*/jsx(VisualOrIndicator, {
317
+ inactiveText: showInactiveIndicator ? inactiveText : undefined,
318
+ itemHasLeadingVisual: Boolean(slots.leadingVisual),
319
+ labelId: labelId,
320
+ loading: loading,
321
+ position: "trailing",
322
+ children: trailingVisual
323
+ }),
324
+ // If the item is inactive, but it's not in an overlay (e.g. ActionMenu, SelectPanel),
325
+ // render the inactive warning message directly in the item.
326
+ !showInactiveIndicator && inactiveText ? /*#__PURE__*/jsx("span", {
327
+ className: classes.InactiveWarning,
328
+ id: inactiveWarningId,
329
+ children: inactiveText
330
+ }) : null]
331
+ })]
332
+ }), !inactive && !loading && !menuContext && Boolean(slots.trailingAction) && slots.trailingAction, slots.subItem]
333
+ })
334
+ });
745
335
  };
336
+ UnwrappedItem.displayName = "UnwrappedItem";
746
337
  const Item = Object.assign(fixedForwardRef(UnwrappedItem), {
747
338
  displayName: 'ActionList.Item',
748
339
  __SLOT__: Symbol('ActionList.Item')