@primer/react 0.0.0-20260218210324 → 0.0.0-20260218211332

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 (77) hide show
  1. package/CHANGELOG.md +4 -22
  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.js +37 -98
  7. package/dist/ActionList/LinkItem.js +24 -80
  8. package/dist/ActionList/List.js +33 -143
  9. package/dist/ActionList/Selection.js +30 -78
  10. package/dist/ActionList/TrailingAction.js +23 -83
  11. package/dist/ActionList/Visuals.js +64 -162
  12. package/dist/Banner/Banner.d.ts.map +1 -1
  13. package/dist/Banner/Banner.js +62 -72
  14. package/dist/Button/Button.js +11 -34
  15. package/dist/Button/ButtonBase.d.ts.map +1 -1
  16. package/dist/Button/ButtonBase.js +14 -9
  17. package/dist/Button/IconButton.js +51 -140
  18. package/dist/Button/LinkButton.js +11 -39
  19. package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css +2 -0
  20. package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css.map +1 -0
  21. package/dist/FilteredActionList/FilteredActionList.module.css.js +2 -2
  22. package/dist/PageLayout/PageLayout-06f4c069.css +2 -0
  23. package/dist/PageLayout/PageLayout-06f4c069.css.map +1 -0
  24. package/dist/PageLayout/PageLayout.d.ts +71 -2
  25. package/dist/PageLayout/PageLayout.d.ts.map +1 -1
  26. package/dist/PageLayout/PageLayout.js +498 -44
  27. package/dist/PageLayout/PageLayout.module.css.js +2 -2
  28. package/dist/PageLayout/usePaneWidth.d.ts +16 -4
  29. package/dist/PageLayout/usePaneWidth.d.ts.map +1 -1
  30. package/dist/PageLayout/usePaneWidth.js +123 -109
  31. package/dist/SplitPageLayout/SplitPageLayout.d.ts +4 -1
  32. package/dist/SplitPageLayout/SplitPageLayout.d.ts.map +1 -1
  33. package/dist/SplitPageLayout/SplitPageLayout.js +54 -2
  34. package/dist/UnderlineNav/UnderlineNav-4344d9b0.css +2 -0
  35. package/dist/UnderlineNav/UnderlineNav-4344d9b0.css.map +1 -0
  36. package/dist/UnderlineNav/UnderlineNav.d.ts.map +1 -1
  37. package/dist/UnderlineNav/UnderlineNav.js +317 -82
  38. package/dist/UnderlineNav/UnderlineNav.module.css.js +2 -2
  39. package/dist/UnderlineNav/UnderlineNavContext.d.ts +11 -4
  40. package/dist/UnderlineNav/UnderlineNavContext.d.ts.map +1 -1
  41. package/dist/UnderlineNav/UnderlineNavContext.js +3 -2
  42. package/dist/UnderlineNav/UnderlineNavItem-b65e8fd3.css +2 -0
  43. package/dist/UnderlineNav/UnderlineNavItem-b65e8fd3.css.map +1 -0
  44. package/dist/UnderlineNav/UnderlineNavItem.d.ts.map +1 -1
  45. package/dist/UnderlineNav/UnderlineNavItem.js +85 -94
  46. package/dist/UnderlineNav/UnderlineNavItem.module.css.js +1 -1
  47. package/dist/UnderlineNav/styles.d.ts +16 -0
  48. package/dist/UnderlineNav/styles.d.ts.map +1 -0
  49. package/dist/UnderlineNav/styles.js +19 -0
  50. package/dist/experimental/SelectPanel2/SelectPanel-1f8c23b5.css +2 -0
  51. package/dist/experimental/SelectPanel2/{SelectPanel-f0c4b9ca.css.map → SelectPanel-1f8c23b5.css.map} +1 -1
  52. package/dist/experimental/SelectPanel2/SelectPanel.module.css.js +1 -1
  53. package/dist/hooks/useIsMacOS.d.ts +3 -15
  54. package/dist/hooks/useIsMacOS.d.ts.map +1 -1
  55. package/dist/hooks/useIsMacOS.js +26 -24
  56. package/dist/internal/components/UnderlineTabbedInterface-20c3ba3d.css +2 -0
  57. package/dist/internal/components/UnderlineTabbedInterface-20c3ba3d.css.map +1 -0
  58. package/dist/internal/components/UnderlineTabbedInterface.d.ts +1 -0
  59. package/dist/internal/components/UnderlineTabbedInterface.d.ts.map +1 -1
  60. package/dist/internal/components/UnderlineTabbedInterface.js +48 -41
  61. package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
  62. package/dist/live-region/Announce.d.ts.map +1 -1
  63. package/dist/live-region/Announce.js +4 -7
  64. package/dist/utils/environment.js +9 -0
  65. package/generated/components.json +200 -2
  66. package/package.json +2 -2
  67. package/dist/FilteredActionList/FilteredActionList-02db90c6.css +0 -2
  68. package/dist/FilteredActionList/FilteredActionList-02db90c6.css.map +0 -1
  69. package/dist/PageLayout/PageLayout-cb491b47.css +0 -2
  70. package/dist/PageLayout/PageLayout-cb491b47.css.map +0 -1
  71. package/dist/UnderlineNav/UnderlineNav-e56ca858.css +0 -2
  72. package/dist/UnderlineNav/UnderlineNav-e56ca858.css.map +0 -1
  73. package/dist/UnderlineNav/UnderlineNavItem-db9dc5d0.css +0 -2
  74. package/dist/UnderlineNav/UnderlineNavItem-db9dc5d0.css.map +0 -1
  75. package/dist/experimental/SelectPanel2/SelectPanel-f0c4b9ca.css +0 -2
  76. package/dist/internal/components/UnderlineTabbedInterface-135d7279.css +0 -2
  77. package/dist/internal/components/UnderlineTabbedInterface-135d7279.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,96 +16,36 @@ 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
50
  const UnwrappedItem = ({
112
51
  variant = 'default',
@@ -166,10 +105,10 @@ const UnwrappedItem = ({
166
105
  const menuContext = container === 'ActionMenu' || container === 'SelectPanel' || container === 'FilteredActionList';
167
106
  // TODO: when we change `menuContext` to check `listRole` instead of `container`
168
107
  const showInactiveIndicator = inactive && !(listRole !== undefined && ['menu', 'listbox'].includes(listRole));
169
- const onSelect = React.useCallback((event, afterSelect_0) => {
108
+ const onSelect = React.useCallback((event, afterSelect) => {
170
109
  if (typeof onSelectUser === 'function') onSelectUser(event);
171
110
  if (event.defaultPrevented) return;
172
- if (typeof afterSelect_0 === 'function') afterSelect_0(event);
111
+ if (typeof afterSelect === 'function') afterSelect(event);
173
112
  }, [onSelectUser]);
174
113
  const selectionVariant = groupSelectionVariant ? groupSelectionVariant : listSelectionVariant;
175
114
 
@@ -196,20 +135,20 @@ const UnwrappedItem = ({
196
135
  const listRoleTypes = ['listbox', 'menu', 'list'];
197
136
  const listSemantics = listRole && listRoleTypes.includes(listRole) || inactive || listItemSemantics;
198
137
  const buttonSemantics = !listSemantics && !_PrivateItemWrapper;
199
- const clickHandler = React.useCallback(event_0 => {
138
+ const clickHandler = React.useCallback(event => {
200
139
  if (disabled || inactive || loading) return;
201
- onSelect(event_0, afterSelect);
140
+ onSelect(event, afterSelect);
202
141
  }, [onSelect, disabled, inactive, afterSelect, loading]);
203
- const keyPressHandler = React.useCallback(event_1 => {
142
+ const keyPressHandler = React.useCallback(event => {
204
143
  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
144
+ if ([' ', 'Enter'].includes(event.key)) {
145
+ if (event.key === ' ') {
146
+ event.preventDefault(); // prevent scrolling on Space
208
147
  // immediately reset defaultPrevented once its job is done
209
148
  // so as to not disturb the functions that use that event after this
210
- event_1.defaultPrevented = false;
149
+ event.defaultPrevented = false;
211
150
  }
212
- onSelect(event_1, afterSelect);
151
+ onSelect(event, afterSelect);
213
152
  }
214
153
  }, [onSelect, disabled, loading, inactive, afterSelect]);
215
154
  const itemId = useId(id);
@@ -1,54 +1,29 @@
1
- import { c } from 'react-compiler-runtime';
2
1
  import React from 'react';
3
2
  import { Item } from './Item.js';
4
3
  import { jsx } from 'react/jsx-runtime';
5
4
  import Link from '../Link/Link.js';
6
5
 
7
- const LinkItem = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
8
- const $ = c(22);
9
- let Component;
10
- let active;
11
- let className;
12
- let inactiveText;
13
- let props;
14
- let size;
15
- let variant;
16
- if ($[0] !== t0) {
17
- ({
18
- active,
19
- inactiveText,
20
- variant,
21
- size,
22
- as: Component,
23
- className,
24
- ...props
25
- } = t0);
26
- $[0] = t0;
27
- $[1] = Component;
28
- $[2] = active;
29
- $[3] = className;
30
- $[4] = inactiveText;
31
- $[5] = props;
32
- $[6] = size;
33
- $[7] = variant;
34
- } else {
35
- Component = $[1];
36
- active = $[2];
37
- className = $[3];
38
- inactiveText = $[4];
39
- props = $[5];
40
- size = $[6];
41
- variant = $[7];
42
- }
43
- const t1 = inactiveText ? true : undefined;
44
- let t2;
45
- if ($[8] !== Component || $[9] !== forwardedRef || $[10] !== inactiveText || $[11] !== props) {
46
- t2 = t3 => {
47
- const {
48
- children,
49
- onClick,
50
- ...rest
51
- } = t3;
6
+ const LinkItem = /*#__PURE__*/React.forwardRef(({
7
+ active,
8
+ inactiveText,
9
+ variant,
10
+ size,
11
+ as: Component,
12
+ className,
13
+ ...props
14
+ }, forwardedRef) => {
15
+ return /*#__PURE__*/jsx(Item, {
16
+ className: className,
17
+ active: active,
18
+ inactiveText: inactiveText,
19
+ "data-inactive": inactiveText ? true : undefined,
20
+ variant: variant,
21
+ size: size,
22
+ _PrivateItemWrapper: ({
23
+ children,
24
+ onClick,
25
+ ...rest
26
+ }) => {
52
27
  const clickHandler = event => {
53
28
  onClick && onClick(event);
54
29
  props.onClick && props.onClick(event);
@@ -64,40 +39,9 @@ const LinkItem = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
64
39
  ref: forwardedRef,
65
40
  children: children
66
41
  });
67
- };
68
- $[8] = Component;
69
- $[9] = forwardedRef;
70
- $[10] = inactiveText;
71
- $[11] = props;
72
- $[12] = t2;
73
- } else {
74
- t2 = $[12];
75
- }
76
- let t3;
77
- if ($[13] !== active || $[14] !== className || $[15] !== inactiveText || $[16] !== props.children || $[17] !== size || $[18] !== t1 || $[19] !== t2 || $[20] !== variant) {
78
- t3 = /*#__PURE__*/jsx(Item, {
79
- className: className,
80
- active: active,
81
- inactiveText: inactiveText,
82
- "data-inactive": t1,
83
- variant: variant,
84
- size: size,
85
- _PrivateItemWrapper: t2,
86
- children: props.children
87
- });
88
- $[13] = active;
89
- $[14] = className;
90
- $[15] = inactiveText;
91
- $[16] = props.children;
92
- $[17] = size;
93
- $[18] = t1;
94
- $[19] = t2;
95
- $[20] = variant;
96
- $[21] = t3;
97
- } else {
98
- t3 = $[21];
99
- }
100
- return t3;
42
+ },
43
+ children: props.children
44
+ });
101
45
  });
102
46
  LinkItem.displayName = 'ActionList.LinkItem';
103
47
  LinkItem.__SLOT__ = Symbol('ActionList.LinkItem');
@@ -1,4 +1,3 @@
1
- import { c } from 'react-compiler-runtime';
2
1
  import React from 'react';
3
2
  import { fixedForwardRef } from '../utils/modern-polymorphic.js';
4
3
  import { ActionListContainerContext } from './ActionListContainerContext.js';
@@ -9,70 +8,33 @@ import { ListContext } from './shared.js';
9
8
  import { useFocusZone } from '../hooks/useFocusZone.js';
10
9
  import { clsx } from 'clsx';
11
10
  import classes from './ActionList.module.css.js';
12
- import { jsx, jsxs } from 'react/jsx-runtime';
11
+ import { jsxs, jsx } from 'react/jsx-runtime';
13
12
  import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
14
13
  import { FocusKeys } from '@primer/behaviors';
15
14
 
16
15
  const UnwrappedList = (props, forwardedRef) => {
17
16
  var _slots$heading$props$;
18
- const $ = c(37);
19
- let className;
20
- let restProps;
21
- let role;
22
- let selectionVariant;
23
- let t0;
24
- let t1;
25
- let t2;
26
- let t3;
27
- if ($[0] !== props) {
28
- ({
29
- as: t0,
30
- variant: t1,
31
- selectionVariant,
32
- showDividers: t2,
33
- role,
34
- disableFocusZone: t3,
35
- className,
36
- ...restProps
37
- } = props);
38
- $[0] = props;
39
- $[1] = className;
40
- $[2] = restProps;
41
- $[3] = role;
42
- $[4] = selectionVariant;
43
- $[5] = t0;
44
- $[6] = t1;
45
- $[7] = t2;
46
- $[8] = t3;
47
- } else {
48
- className = $[1];
49
- restProps = $[2];
50
- role = $[3];
51
- selectionVariant = $[4];
52
- t0 = $[5];
53
- t1 = $[6];
54
- t2 = $[7];
55
- t3 = $[8];
56
- }
57
- const Component = t0 === undefined ? "ul" : t0;
58
- const variant = t1 === undefined ? "inset" : t1;
59
- const showDividers = t2 === undefined ? false : t2;
60
- const disableFocusZone = t3 === undefined ? false : t3;
61
- let t4;
62
- if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
63
- t4 = {
64
- heading: Heading
65
- };
66
- $[9] = t4;
67
- } else {
68
- t4 = $[9];
69
- }
70
- const [slots, childrenWithoutSlots] = useSlots(restProps.children, t4);
17
+ const {
18
+ as: Component = 'ul',
19
+ variant = 'inset',
20
+ selectionVariant,
21
+ showDividers = false,
22
+ role,
23
+ disableFocusZone = false,
24
+ className,
25
+ ...restProps
26
+ } = props;
27
+ const [slots, childrenWithoutSlots] = useSlots(restProps.children, {
28
+ heading: Heading
29
+ });
71
30
  const headingId = useId();
31
+
32
+ /** if list is inside a Menu, it will get a role from the Menu */
72
33
  const {
73
34
  listRole: listRoleFromContainer,
74
35
  listLabelledBy,
75
36
  selectionVariant: containerSelectionVariant,
37
+ // TODO: Remove after DropdownMenu2 deprecation
76
38
  enableFocusZone: enableFocusZoneFromContainer,
77
39
  container
78
40
  } = React.useContext(ActionListContainerContext);
@@ -80,70 +42,23 @@ const UnwrappedList = (props, forwardedRef) => {
80
42
  const listRole = role || listRoleFromContainer;
81
43
  const listRef = useProvidedRefOrCreate(forwardedRef);
82
44
  let enableFocusZone = false;
83
- if (enableFocusZoneFromContainer !== undefined) {
84
- enableFocusZone = enableFocusZoneFromContainer;
85
- } else {
86
- if (listRole && !disableFocusZone) {
87
- let t5;
88
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
89
- t5 = ["menu", "menubar", "listbox"];
90
- $[10] = t5;
91
- } else {
92
- t5 = $[10];
93
- }
94
- enableFocusZone = t5.includes(listRole);
95
- }
96
- }
97
- const t5 = !enableFocusZone;
98
- const t6 = listRole === "menu" || container === "SelectPanel" || container === "FilteredActionList" ? "wrap" : undefined;
99
- let t7;
100
- if ($[11] !== listRef || $[12] !== t5 || $[13] !== t6) {
101
- t7 = {
102
- disabled: t5,
103
- containerRef: listRef,
104
- bindKeys: FocusKeys.ArrowVertical | FocusKeys.HomeAndEnd | FocusKeys.PageUpDown,
105
- focusOutBehavior: t6
106
- };
107
- $[11] = listRef;
108
- $[12] = t5;
109
- $[13] = t6;
110
- $[14] = t7;
111
- } else {
112
- t7 = $[14];
113
- }
114
- useFocusZone(t7);
115
- const t8 = selectionVariant || containerSelectionVariant;
116
- let t9;
117
- if ($[15] !== headingId || $[16] !== listRole || $[17] !== showDividers || $[18] !== t8 || $[19] !== variant) {
118
- t9 = {
45
+ if (enableFocusZoneFromContainer !== undefined) enableFocusZone = enableFocusZoneFromContainer;else if (listRole && !disableFocusZone) enableFocusZone = ['menu', 'menubar', 'listbox'].includes(listRole);
46
+ useFocusZone({
47
+ disabled: !enableFocusZone,
48
+ containerRef: listRef,
49
+ bindKeys: FocusKeys.ArrowVertical | FocusKeys.HomeAndEnd | FocusKeys.PageUpDown,
50
+ focusOutBehavior: listRole === 'menu' || container === 'SelectPanel' || container === 'FilteredActionList' ? 'wrap' : undefined
51
+ });
52
+ return /*#__PURE__*/jsxs(ListContext.Provider, {
53
+ value: {
119
54
  variant,
120
- selectionVariant: t8,
55
+ selectionVariant: selectionVariant || containerSelectionVariant,
121
56
  showDividers,
122
57
  role: listRole,
123
58
  headingId
124
- };
125
- $[15] = headingId;
126
- $[16] = listRole;
127
- $[17] = showDividers;
128
- $[18] = t8;
129
- $[19] = variant;
130
- $[20] = t9;
131
- } else {
132
- t9 = $[20];
133
- }
134
- const t10 = slots.heading;
135
- let t11;
136
- if ($[21] !== className) {
137
- t11 = clsx(classes.ActionList, className);
138
- $[21] = className;
139
- $[22] = t11;
140
- } else {
141
- t11 = $[22];
142
- }
143
- let t12;
144
- if ($[23] !== Component || $[24] !== ariaLabelledBy || $[25] !== childrenWithoutSlots || $[26] !== listRef || $[27] !== listRole || $[28] !== restProps || $[29] !== showDividers || $[30] !== t11 || $[31] !== variant) {
145
- t12 = /*#__PURE__*/jsx(Component, {
146
- className: t11,
59
+ },
60
+ children: [slots.heading, /*#__PURE__*/jsx(Component, {
61
+ className: clsx(classes.ActionList, className),
147
62
  role: listRole,
148
63
  "aria-labelledby": ariaLabelledBy,
149
64
  ref: listRef,
@@ -151,35 +66,10 @@ const UnwrappedList = (props, forwardedRef) => {
151
66
  "data-variant": variant,
152
67
  ...restProps,
153
68
  children: childrenWithoutSlots
154
- });
155
- $[23] = Component;
156
- $[24] = ariaLabelledBy;
157
- $[25] = childrenWithoutSlots;
158
- $[26] = listRef;
159
- $[27] = listRole;
160
- $[28] = restProps;
161
- $[29] = showDividers;
162
- $[30] = t11;
163
- $[31] = variant;
164
- $[32] = t12;
165
- } else {
166
- t12 = $[32];
167
- }
168
- let t13;
169
- if ($[33] !== slots.heading || $[34] !== t12 || $[35] !== t9) {
170
- t13 = /*#__PURE__*/jsxs(ListContext.Provider, {
171
- value: t9,
172
- children: [t10, t12]
173
- });
174
- $[33] = slots.heading;
175
- $[34] = t12;
176
- $[35] = t9;
177
- $[36] = t13;
178
- } else {
179
- t13 = $[36];
180
- }
181
- return t13;
69
+ })]
70
+ });
182
71
  };
72
+ UnwrappedList.displayName = "UnwrappedList";
183
73
  const List = fixedForwardRef(UnwrappedList);
184
74
  Object.assign(List, {
185
75
  displayName: 'ActionList'
@@ -1,4 +1,3 @@
1
- import { c } from 'react-compiler-runtime';
2
1
  import React from 'react';
3
2
  import { CheckIcon } from '@primer/octicons-react';
4
3
  import { GroupContext } from './Group.js';
@@ -9,12 +8,10 @@ import { warning } from '../utils/warning.js';
9
8
  import { jsx } from 'react/jsx-runtime';
10
9
  import Radio from '../Radio/Radio.js';
11
10
 
12
- const Selection = t0 => {
13
- const $ = c(11);
14
- const {
15
- selected,
16
- className
17
- } = t0;
11
+ const Selection = ({
12
+ selected,
13
+ className
14
+ }) => {
18
15
  const {
19
16
  selectionVariant: listSelectionVariant,
20
17
  role: listRole
@@ -22,93 +19,48 @@ const Selection = t0 => {
22
19
  const {
23
20
  selectionVariant: groupSelectionVariant
24
21
  } = React.useContext(GroupContext);
22
+
23
+ /** selectionVariant in Group can override the selectionVariant in List root */
24
+ /** fallback to selectionVariant from container menu if any (ActionMenu, SelectPanel ) */
25
25
  let selectionVariant;
26
- if (typeof groupSelectionVariant !== "undefined") {
27
- selectionVariant = groupSelectionVariant;
28
- } else {
29
- selectionVariant = listSelectionVariant;
30
- }
26
+ if (typeof groupSelectionVariant !== 'undefined') selectionVariant = groupSelectionVariant;else selectionVariant = listSelectionVariant;
31
27
  if (!selectionVariant) {
28
+ // if selectionVariant is not set on List, but Item is selected
29
+ // warn in development
32
30
  if (selected) {
33
- process.env.NODE_ENV !== "production" ? warning(true, "For Item to be selected, ActionList or ActionList.Group should have a selectionVariant defined.") : void 0;
31
+ process.env.NODE_ENV !== "production" ? warning(true, 'For Item to be selected, ActionList or ActionList.Group should have a selectionVariant defined.') : void 0;
34
32
  }
35
33
  return null;
36
34
  }
37
- if (selectionVariant === "radio") {
38
- let t1;
39
- if ($[0] !== selected) {
40
- t1 = /*#__PURE__*/jsx(Radio, {
35
+ if (selectionVariant === 'radio') {
36
+ return /*#__PURE__*/jsx(VisualContainer, {
37
+ className: className,
38
+ "data-component": "ActionList.Selection",
39
+ children: /*#__PURE__*/jsx(Radio, {
41
40
  value: "unused",
42
41
  checked: selected,
43
42
  "aria-hidden": true,
44
43
  tabIndex: -1
45
- });
46
- $[0] = selected;
47
- $[1] = t1;
48
- } else {
49
- t1 = $[1];
50
- }
51
- let t2;
52
- if ($[2] !== className || $[3] !== t1) {
53
- t2 = /*#__PURE__*/jsx(VisualContainer, {
54
- className: className,
55
- "data-component": "ActionList.Selection",
56
- children: t1
57
- });
58
- $[2] = className;
59
- $[3] = t1;
60
- $[4] = t2;
61
- } else {
62
- t2 = $[4];
63
- }
64
- return t2;
65
- }
66
- if (selectionVariant === "single" || listRole === "menu") {
67
- let t1;
68
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
69
- t1 = /*#__PURE__*/jsx(CheckIcon, {
70
- className: classes.SingleSelectCheckmark
71
- });
72
- $[5] = t1;
73
- } else {
74
- t1 = $[5];
75
- }
76
- let t2;
77
- if ($[6] !== className) {
78
- t2 = /*#__PURE__*/jsx(VisualContainer, {
79
- className: className,
80
- "data-component": "ActionList.Selection",
81
- children: t1
82
- });
83
- $[6] = className;
84
- $[7] = t2;
85
- } else {
86
- t2 = $[7];
87
- }
88
- return t2;
89
- }
90
- let t1;
91
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
92
- t1 = /*#__PURE__*/jsx("div", {
93
- className: classes.MultiSelectCheckbox
44
+ })
94
45
  });
95
- $[8] = t1;
96
- } else {
97
- t1 = $[8];
98
46
  }
99
- let t2;
100
- if ($[9] !== className) {
101
- t2 = /*#__PURE__*/jsx(VisualContainer, {
47
+ if (selectionVariant === 'single' || listRole === 'menu') {
48
+ return /*#__PURE__*/jsx(VisualContainer, {
102
49
  className: className,
103
50
  "data-component": "ActionList.Selection",
104
- children: t1
51
+ children: /*#__PURE__*/jsx(CheckIcon, {
52
+ className: classes.SingleSelectCheckmark
53
+ })
105
54
  });
106
- $[9] = className;
107
- $[10] = t2;
108
- } else {
109
- t2 = $[10];
110
55
  }
111
- return t2;
56
+ return /*#__PURE__*/jsx(VisualContainer, {
57
+ className: className,
58
+ "data-component": "ActionList.Selection",
59
+ children: /*#__PURE__*/jsx("div", {
60
+ className: classes.MultiSelectCheckbox
61
+ })
62
+ });
112
63
  };
64
+ Selection.displayName = "Selection";
113
65
 
114
66
  export { Selection };