@primer/react 0.0.0-20260218182609 → 0.0.0-20260218205658

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 (58) hide show
  1. package/CHANGELOG.md +4 -24
  2. package/dist/ActionList/Description.js +35 -113
  3. package/dist/ActionList/Divider.js +11 -30
  4. package/dist/ActionList/Group.js +117 -294
  5. package/dist/ActionList/Heading.js +22 -77
  6. package/dist/ActionList/Item.d.ts.map +1 -1
  7. package/dist/ActionList/Item.js +209 -679
  8. package/dist/ActionList/LinkItem.js +24 -80
  9. package/dist/ActionList/List.d.ts.map +1 -1
  10. package/dist/ActionList/List.js +33 -144
  11. package/dist/ActionList/Selection.js +30 -78
  12. package/dist/ActionList/TrailingAction.js +23 -83
  13. package/dist/ActionList/Visuals.js +64 -162
  14. package/dist/Banner/Banner.d.ts.map +1 -1
  15. package/dist/Banner/Banner.js +62 -72
  16. package/dist/Button/Button.js +11 -34
  17. package/dist/Button/ButtonBase.d.ts.map +1 -1
  18. package/dist/Button/ButtonBase.js +14 -9
  19. package/dist/Button/IconButton.js +51 -140
  20. package/dist/Button/LinkButton.js +11 -39
  21. package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css +2 -0
  22. package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css.map +1 -0
  23. package/dist/FilteredActionList/FilteredActionList.module.css.js +2 -2
  24. package/dist/PageLayout/PageLayout-06f4c069.css +2 -0
  25. package/dist/PageLayout/PageLayout-06f4c069.css.map +1 -0
  26. package/dist/PageLayout/PageLayout.d.ts +71 -2
  27. package/dist/PageLayout/PageLayout.d.ts.map +1 -1
  28. package/dist/PageLayout/PageLayout.js +498 -44
  29. package/dist/PageLayout/PageLayout.module.css.js +2 -2
  30. package/dist/PageLayout/usePaneWidth.d.ts +16 -4
  31. package/dist/PageLayout/usePaneWidth.d.ts.map +1 -1
  32. package/dist/PageLayout/usePaneWidth.js +123 -109
  33. package/dist/SplitPageLayout/SplitPageLayout.d.ts +4 -1
  34. package/dist/SplitPageLayout/SplitPageLayout.d.ts.map +1 -1
  35. package/dist/SplitPageLayout/SplitPageLayout.js +54 -2
  36. package/dist/UnderlineNav/UnderlineNav.d.ts.map +1 -1
  37. package/dist/UnderlineNav/UnderlineNav.js +4 -11
  38. package/dist/experimental/SelectPanel2/SelectPanel-1f8c23b5.css +2 -0
  39. package/dist/experimental/SelectPanel2/{SelectPanel-f0c4b9ca.css.map → SelectPanel-1f8c23b5.css.map} +1 -1
  40. package/dist/experimental/SelectPanel2/SelectPanel.module.css.js +1 -1
  41. package/dist/hooks/useIsMacOS.d.ts +3 -15
  42. package/dist/hooks/useIsMacOS.d.ts.map +1 -1
  43. package/dist/hooks/useIsMacOS.js +26 -24
  44. package/dist/internal/components/UnderlineTabbedInterface-20c3ba3d.css +2 -0
  45. package/dist/internal/components/UnderlineTabbedInterface-20c3ba3d.css.map +1 -0
  46. package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
  47. package/dist/live-region/Announce.d.ts.map +1 -1
  48. package/dist/live-region/Announce.js +4 -7
  49. package/dist/utils/environment.js +9 -0
  50. package/generated/components.json +200 -2
  51. package/package.json +2 -2
  52. package/dist/FilteredActionList/FilteredActionList-02db90c6.css +0 -2
  53. package/dist/FilteredActionList/FilteredActionList-02db90c6.css.map +0 -1
  54. package/dist/PageLayout/PageLayout-cb491b47.css +0 -2
  55. package/dist/PageLayout/PageLayout-cb491b47.css.map +0 -1
  56. package/dist/experimental/SelectPanel2/SelectPanel-f0c4b9ca.css +0 -2
  57. package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css +0 -2
  58. package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css.map +0 -1
@@ -1,4 +1,3 @@
1
- import { c } from 'react-compiler-runtime';
2
1
  import React from 'react';
3
2
  import { useId } from '../hooks/useId.js';
4
3
  import { useSlots } from '../hooks/useSlots.js';
@@ -17,223 +16,81 @@ import { clsx } from 'clsx';
17
16
  import { fixedForwardRef } from '../utils/modern-polymorphic.js';
18
17
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
19
18
 
20
- const SubItem = t0 => {
21
- const $ = c(2);
22
- const {
23
- children
24
- } = t0;
25
- let t1;
26
- if ($[0] !== children) {
27
- t1 = /*#__PURE__*/jsx(Fragment, {
28
- children: children
29
- });
30
- $[0] = children;
31
- $[1] = t1;
32
- } else {
33
- t1 = $[1];
34
- }
35
- return t1;
19
+ const SubItem = ({
20
+ children
21
+ }) => {
22
+ return /*#__PURE__*/jsx(Fragment, {
23
+ children: children
24
+ });
36
25
  };
37
26
  SubItem.displayName = 'ActionList.SubItem';
38
- const ButtonItemContainerNoBox = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
39
- const $ = c(9);
40
- let children;
41
- let props;
42
- let style;
43
- if ($[0] !== t0) {
44
- ({
45
- children,
46
- style,
47
- ...props
48
- } = t0);
49
- $[0] = t0;
50
- $[1] = children;
51
- $[2] = props;
52
- $[3] = style;
53
- } else {
54
- children = $[1];
55
- props = $[2];
56
- style = $[3];
57
- }
58
- const t1 = forwardedRef;
59
- let t2;
60
- if ($[4] !== children || $[5] !== props || $[6] !== style || $[7] !== t1) {
61
- t2 = /*#__PURE__*/jsx("button", {
62
- type: "button",
63
- ref: t1,
64
- style: style,
65
- ...props,
66
- children: children
67
- });
68
- $[4] = children;
69
- $[5] = props;
70
- $[6] = style;
71
- $[7] = t1;
72
- $[8] = t2;
73
- } else {
74
- t2 = $[8];
75
- }
76
- return t2;
27
+ const ButtonItemContainerNoBox = /*#__PURE__*/React.forwardRef(({
28
+ children,
29
+ style,
30
+ ...props
31
+ }, forwardedRef) => {
32
+ return /*#__PURE__*/jsx("button", {
33
+ type: "button",
34
+ ref: forwardedRef,
35
+ style: style,
36
+ ...props,
37
+ children: children
38
+ });
77
39
  });
78
- const DivItemContainerNoBox = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
79
- const $ = c(7);
80
- let children;
81
- let props;
82
- if ($[0] !== t0) {
83
- ({
84
- children,
85
- ...props
86
- } = t0);
87
- $[0] = t0;
88
- $[1] = children;
89
- $[2] = props;
90
- } else {
91
- children = $[1];
92
- props = $[2];
93
- }
94
- const t1 = forwardedRef;
95
- let t2;
96
- if ($[3] !== children || $[4] !== props || $[5] !== t1) {
97
- t2 = /*#__PURE__*/jsx("div", {
98
- ref: t1,
99
- ...props,
100
- children: children
101
- });
102
- $[3] = children;
103
- $[4] = props;
104
- $[5] = t1;
105
- $[6] = t2;
106
- } else {
107
- t2 = $[6];
108
- }
109
- return t2;
40
+ const DivItemContainerNoBox = /*#__PURE__*/React.forwardRef(({
41
+ children,
42
+ ...props
43
+ }, forwardedRef) => {
44
+ return /*#__PURE__*/jsx("div", {
45
+ ref: forwardedRef,
46
+ ...props,
47
+ children: children
48
+ });
110
49
  });
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) => {
50
+ const UnwrappedItem = ({
51
+ variant = 'default',
52
+ size = 'medium',
53
+ disabled = false,
54
+ inactiveText,
55
+ selected = undefined,
56
+ active = false,
57
+ onSelect: onSelectUser,
58
+ id,
59
+ role,
60
+ loading,
61
+ _PrivateItemWrapper,
62
+ className,
63
+ groupId: _groupId,
64
+ renderItem: _renderItem,
65
+ handleAddItem: _handleAddItem,
66
+ ...props
67
+ }, forwardedRef) => {
126
68
  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;
69
+ const baseSlots = {
70
+ leadingVisual: LeadingVisual,
71
+ trailingVisual: TrailingVisual,
72
+ trailingAction: TrailingAction,
73
+ subItem: SubItem
74
+ };
75
+ const [partialSlots, childrenWithoutSlots] = useSlots(props.children, {
76
+ ...baseSlots,
77
+ description: Description
78
+ });
79
+ const slots = {
80
+ description: undefined,
81
+ ...partialSlots
82
+ };
220
83
  const {
221
84
  container,
222
85
  afterSelect,
223
86
  selectionAttribute,
224
87
  defaultTrailingVisual
225
88
  } = 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;
89
+
90
+ // Be sure to avoid rendering the container unless there is a default
91
+ const wrappedDefaultTrailingVisual = defaultTrailingVisual ? /*#__PURE__*/jsx(TrailingVisual, {
92
+ children: defaultTrailingVisual
93
+ }) : null;
237
94
  const trailingVisual = (_slots$trailingVisual = slots.trailingVisual) !== null && _slots$trailingVisual !== void 0 ? _slots$trailingVisual : wrappedDefaultTrailingVisual;
238
95
  const {
239
96
  role: listRole,
@@ -243,127 +100,57 @@ const UnwrappedItem = (t0, forwardedRef) => {
243
100
  selectionVariant: groupSelectionVariant
244
101
  } = React.useContext(GroupContext);
245
102
  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;
103
+ // TODO change `menuContext` check to ```listRole !== undefined && ['menu', 'listbox'].includes(listRole)```
104
+ // once we have a better way to handle existing usage in dotcom that incorrectly use ActionList.TrailingAction
105
+ const menuContext = container === 'ActionMenu' || container === 'SelectPanel' || container === 'FilteredActionList';
106
+ // TODO: when we change `menuContext` to check `listRole` instead of `container`
107
+ const showInactiveIndicator = inactive && !(listRole !== undefined && ['menu', 'listbox'].includes(listRole));
108
+ const onSelect = React.useCallback((event, afterSelect) => {
109
+ if (typeof onSelectUser === 'function') onSelectUser(event);
110
+ if (event.defaultPrevented) return;
111
+ if (typeof afterSelect === 'function') afterSelect(event);
112
+ }, [onSelectUser]);
276
113
  const selectionVariant = groupSelectionVariant ? groupSelectionVariant : listSelectionVariant;
114
+
115
+ /** Infer item role based on the container */
277
116
  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
- }
117
+ if (container === 'ActionMenu') {
118
+ if (selectionVariant === 'single') inferredItemRole = 'menuitemradio';else if (selectionVariant === 'multiple') inferredItemRole = 'menuitemcheckbox';else inferredItemRole = 'menuitem';
119
+ } else if (listRole === 'listbox') {
120
+ if (selectionVariant !== undefined && !role) inferredItemRole = 'option';
121
+ } else if (listRole === 'tablist') {
122
+ inferredItemRole = 'tab';
298
123
  }
299
124
  const itemRole = role || inferredItemRole;
300
125
  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;
126
+ !!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
127
  }
128
+
129
+ /** Infer the proper selection attribute based on the item's role */
303
130
  let inferredSelectionAttribute;
304
- if (itemRole === "menuitemradio" || itemRole === "menuitemcheckbox") {
305
- inferredSelectionAttribute = "aria-checked";
306
- } else {
307
- if (itemRole === "option") {
308
- inferredSelectionAttribute = "aria-selected";
309
- }
310
- }
131
+ if (itemRole === 'menuitemradio' || itemRole === 'menuitemcheckbox') inferredSelectionAttribute = 'aria-checked';else if (itemRole === 'option') inferredSelectionAttribute = 'aria-selected';
311
132
  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;
133
+ // Ensures ActionList.Item retains list item semantics if a valid ARIA role is applied, or if item is inactive
134
+ const listItemSemantics = itemRole === 'option' || itemRole === 'menuitem' || itemRole === 'menuitemradio' || itemRole === 'menuitemcheckbox' || itemRole === 'tab';
135
+ const listRoleTypes = ['listbox', 'menu', 'list'];
136
+ const listSemantics = listRole && listRoleTypes.includes(listRole) || inactive || listItemSemantics;
324
137
  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;
138
+ const clickHandler = React.useCallback(event => {
139
+ if (disabled || inactive || loading) return;
140
+ onSelect(event, afterSelect);
141
+ }, [onSelect, disabled, inactive, afterSelect, loading]);
142
+ const keyPressHandler = React.useCallback(event => {
143
+ if (disabled || inactive || loading) return;
144
+ if ([' ', 'Enter'].includes(event.key)) {
145
+ if (event.key === ' ') {
146
+ event.preventDefault(); // prevent scrolling on Space
147
+ // immediately reset defaultPrevented once its job is done
148
+ // so as to not disturb the functions that use that event after this
149
+ event.defaultPrevented = false;
348
150
  }
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);
355
- }
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;
151
+ onSelect(event, afterSelect);
152
+ }
153
+ }, [onSelect, disabled, loading, inactive, afterSelect]);
367
154
  const itemId = useId(id);
368
155
  const labelId = `${itemId}--label`;
369
156
  const inlineDescriptionId = `${itemId}--inline-description`;
@@ -372,377 +159,120 @@ const UnwrappedItem = (t0, forwardedRef) => {
372
159
  const inactiveWarningId = inactive && !showInactiveIndicator ? `${itemId}--warning-message` : undefined;
373
160
  const DefaultItemWrapper = listSemantics ? DivItemContainerNoBox : ButtonItemContainerNoBox;
374
161
  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];
162
+
163
+ // only apply aria-selected and aria-checked to selectable items
164
+ const selectableRoles = ['menuitemradio', 'menuitemcheckbox', 'option'];
165
+ const includeSelectionAttribute = itemSelectionAttribute && itemRole && selectableRoles.includes(itemRole);
166
+ let focusable;
167
+ if (showInactiveIndicator) {
168
+ focusable = true;
425
169
  }
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 && {
170
+
171
+ // Extract the variant prop value from the description slot component
172
+ 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';
173
+ const menuItemProps = {
174
+ onClick: clickHandler,
175
+ onKeyPress: !buttonSemantics ? keyPressHandler : undefined,
176
+ 'aria-disabled': disabled ? true : undefined,
177
+ 'data-inactive': inactive ? true : undefined,
178
+ 'data-loading': loading && !inactive ? true : undefined,
179
+ tabIndex: focusable ? undefined : 0,
180
+ 'aria-labelledby': `${labelId} ${slots.trailingVisual ? trailingVisualId : ''} ${slots.description && descriptionVariant === 'inline' ? inlineDescriptionId : ''}`,
181
+ 'aria-describedby': [slots.description && descriptionVariant === 'block' ? blockDescriptionId : undefined, inactiveWarningId !== null && inactiveWarningId !== void 0 ? inactiveWarningId : undefined].filter(String).join(' ').trim() || undefined,
182
+ ...(includeSelectionAttribute && {
435
183
  [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 = {
184
+ }),
185
+ role: itemRole,
186
+ id: itemId
187
+ };
188
+ const containerProps = _PrivateItemWrapper ? {
189
+ role: itemRole ? 'none' : undefined,
190
+ ...props
191
+ } :
192
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
193
+ listSemantics && {
194
+ ...menuItemProps,
195
+ ...props,
196
+ ref: forwardedRef
197
+ } || {};
198
+ const wrapperProps = _PrivateItemWrapper ? menuItemProps : !listSemantics && {
199
+ ...menuItemProps,
200
+ ...props,
201
+ ref: forwardedRef
202
+ };
203
+ return /*#__PURE__*/jsx(ItemContext.Provider, {
204
+ value: {
517
205
  variant,
518
206
  size,
519
207
  disabled,
520
- inactive: t23,
208
+ inactive: Boolean(inactiveText),
521
209
  inlineDescriptionId,
522
210
  blockDescriptionId,
523
211
  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", {
212
+ },
213
+ children: /*#__PURE__*/jsxs("li", {
707
214
  ...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;
215
+ ref: listSemantics ? forwardedRef : null,
216
+ "data-variant": variant === 'danger' ? variant : undefined,
217
+ "data-active": active ? true : undefined,
218
+ "data-inactive": inactiveText ? true : undefined,
219
+ "data-has-subitem": slots.subItem ? true : undefined,
220
+ "data-has-description": slots.description ? true : false,
221
+ className: clsx(classes.ActionListItem, className),
222
+ children: [/*#__PURE__*/jsxs(ItemWrapper, {
223
+ ...wrapperProps,
224
+ className: classes.ActionListContent,
225
+ "data-size": size
226
+ // @ts-ignore: ItemWrapper is polymorphic and the ref type depends on the rendered element ('button' or 'li')
227
+ ,
228
+ ref: forwardedRef,
229
+ children: [/*#__PURE__*/jsx("span", {
230
+ className: classes.Spacer
231
+ }), /*#__PURE__*/jsx(Selection, {
232
+ selected: selected,
233
+ className: classes.LeadingAction
234
+ }), /*#__PURE__*/jsx(VisualOrIndicator, {
235
+ inactiveText: showInactiveIndicator ? inactiveText : undefined,
236
+ itemHasLeadingVisual: Boolean(slots.leadingVisual),
237
+ labelId: labelId,
238
+ loading: loading,
239
+ position: "leading",
240
+ children: slots.leadingVisual
241
+ }), /*#__PURE__*/jsxs("span", {
242
+ className: classes.ActionListSubContent,
243
+ "data-component": "ActionList.Item--DividerContainer",
244
+ children: [/*#__PURE__*/jsxs(ConditionalWrapper, {
245
+ if: !!slots.description,
246
+ className: classes.ItemDescriptionWrap,
247
+ "data-description-variant": descriptionVariant,
248
+ children: [/*#__PURE__*/jsxs("span", {
249
+ id: labelId,
250
+ className: classes.ItemLabel,
251
+ children: [childrenWithoutSlots, loading === true && !inactive && /*#__PURE__*/jsx(VisuallyHidden, {
252
+ children: "Loading"
253
+ })]
254
+ }), slots.description]
255
+ }), /*#__PURE__*/jsx(VisualOrIndicator, {
256
+ inactiveText: showInactiveIndicator ? inactiveText : undefined,
257
+ itemHasLeadingVisual: Boolean(slots.leadingVisual),
258
+ labelId: labelId,
259
+ loading: loading,
260
+ position: "trailing",
261
+ children: trailingVisual
262
+ }),
263
+ // If the item is inactive, but it's not in an overlay (e.g. ActionMenu, SelectPanel),
264
+ // render the inactive warning message directly in the item.
265
+ !showInactiveIndicator && inactiveText ? /*#__PURE__*/jsx("span", {
266
+ className: classes.InactiveWarning,
267
+ id: inactiveWarningId,
268
+ children: inactiveText
269
+ }) : null]
270
+ })]
271
+ }), !inactive && !loading && !menuContext && Boolean(slots.trailingAction) && slots.trailingAction, slots.subItem]
272
+ })
273
+ });
745
274
  };
275
+ UnwrappedItem.displayName = "UnwrappedItem";
746
276
  const Item = Object.assign(fixedForwardRef(UnwrappedItem), {
747
277
  displayName: 'ActionList.Item',
748
278
  __SLOT__: Symbol('ActionList.Item')