@primer/react 38.1.0-rc.86cc1e6a5 → 38.1.0-rc.8e0fa8938

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 (142) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +16 -11
  3. package/dist/ActionBar/ActionBar.d.ts +70 -0
  4. package/dist/ActionBar/ActionBar.d.ts.map +1 -1
  5. package/dist/ActionBar/ActionBar.js +529 -151
  6. package/dist/ActionBar/index.d.ts +17 -1
  7. package/dist/ActionBar/index.d.ts.map +1 -1
  8. package/dist/ActionBar/index.js +3 -2
  9. package/dist/ActionList/ActionList-46e9c2db.css +2 -0
  10. package/dist/ActionList/ActionList-46e9c2db.css.map +1 -0
  11. package/dist/ActionList/ActionList.module.css.js +1 -1
  12. package/dist/ActionList/Item.d.ts.map +1 -1
  13. package/dist/ActionList/Item.js +3 -1
  14. package/dist/ActionList/List.d.ts.map +1 -1
  15. package/dist/ActionMenu/ActionMenu.js +1 -1
  16. package/dist/AnchoredOverlay/AnchoredOverlay.d.ts +1 -0
  17. package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
  18. package/dist/Autocomplete/AutocompleteInput.d.ts.map +1 -1
  19. package/dist/Autocomplete/AutocompleteInput.js +0 -1
  20. package/dist/Autocomplete/AutocompleteMenu.js +334 -124
  21. package/dist/Avatar/Avatar.js +31 -23
  22. package/dist/Banner/Banner.d.ts.map +1 -1
  23. package/dist/Banner/Banner.js +0 -1
  24. package/dist/BaseStyles.d.ts +2 -2
  25. package/dist/BaseStyles.d.ts.map +1 -1
  26. package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  27. package/dist/Breadcrumbs/Breadcrumbs.js +1 -0
  28. package/dist/Button/ButtonBase.d.ts.map +1 -1
  29. package/dist/Button/ButtonBase.js +0 -1
  30. package/dist/Checkbox/Checkbox.d.ts.map +1 -1
  31. package/dist/DataTable/Pagination.js +296 -87
  32. package/dist/DataTable/Table.d.ts +13 -13
  33. package/dist/DataTable/Table.d.ts.map +1 -1
  34. package/dist/Dialog/Dialog.d.ts +3 -23
  35. package/dist/Dialog/Dialog.d.ts.map +1 -1
  36. package/dist/Dialog/Dialog.js +19 -4
  37. package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css +1 -1
  38. package/dist/FilteredActionList/FilteredActionList-f6c2dc7a.css.map +1 -1
  39. package/dist/FilteredActionList/FilteredActionList.d.ts +1 -0
  40. package/dist/FilteredActionList/FilteredActionList.d.ts.map +1 -1
  41. package/dist/FilteredActionList/FilteredActionListLoaders.d.ts +1 -0
  42. package/dist/FilteredActionList/FilteredActionListLoaders.d.ts.map +1 -1
  43. package/dist/FilteredActionList/useAnnouncements.d.ts.map +1 -1
  44. package/dist/FilteredActionList/useAnnouncements.js +1 -0
  45. package/dist/Heading/Heading.d.ts.map +1 -1
  46. package/dist/Heading/Heading.js +0 -1
  47. package/dist/LabelGroup/LabelGroup.d.ts.map +1 -1
  48. package/dist/LabelGroup/LabelGroup.js +1 -0
  49. package/dist/Link/Link-968346ff.css +2 -0
  50. package/dist/Link/Link-968346ff.css.map +1 -0
  51. package/dist/Link/Link.d.ts +0 -2
  52. package/dist/Link/Link.d.ts.map +1 -1
  53. package/dist/Link/Link.js +0 -3
  54. package/dist/Link/Link.module.css.js +1 -1
  55. package/dist/PageHeader/PageHeader-9f4a690a.css +2 -0
  56. package/dist/PageHeader/PageHeader-9f4a690a.css.map +1 -0
  57. package/dist/PageHeader/PageHeader.d.ts.map +1 -1
  58. package/dist/PageHeader/PageHeader.js +24 -16
  59. package/dist/PageHeader/PageHeader.module.css.js +1 -1
  60. package/dist/PageLayout/PageLayout-28a244f7.css +2 -0
  61. package/dist/PageLayout/PageLayout-28a244f7.css.map +1 -0
  62. package/dist/PageLayout/PageLayout.d.ts.map +1 -1
  63. package/dist/PageLayout/PageLayout.js +535 -448
  64. package/dist/PageLayout/PageLayout.module.css.js +1 -1
  65. package/dist/Portal/Portal.d.ts.map +1 -1
  66. package/dist/Portal/Portal.js +0 -1
  67. package/dist/SelectPanel/SelectPanel.d.ts +1 -1
  68. package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
  69. package/dist/SelectPanel/SelectPanel.js +0 -1
  70. package/dist/SkeletonAvatar/SkeletonAvatar.js +31 -23
  71. package/dist/ThemeProvider.d.ts.map +1 -1
  72. package/dist/ThemeProvider.js +1 -0
  73. package/dist/Timeline/Timeline-116393ee.css +2 -0
  74. package/dist/Timeline/Timeline-116393ee.css.map +1 -0
  75. package/dist/Timeline/Timeline.module.css.js +1 -1
  76. package/dist/ToggleSwitch/ToggleSwitch.d.ts.map +1 -1
  77. package/dist/Token/IssueLabelToken.js +280 -57
  78. package/dist/Token/_RemoveTokenButton.d.ts +1 -1
  79. package/dist/Token/_RemoveTokenButton.d.ts.map +1 -1
  80. package/dist/Token/_RemoveTokenButton.js +4 -3
  81. package/dist/TooltipV2/Tooltip.d.ts.map +1 -1
  82. package/dist/TooltipV2/Tooltip.js +28 -25
  83. package/dist/TreeView/TreeView.d.ts.map +1 -1
  84. package/dist/TreeView/TreeView.js +5 -1
  85. package/dist/UnderlineNav/UnderlineNav.d.ts.map +1 -1
  86. package/dist/UnderlineNav/UnderlineNav.js +0 -1
  87. package/dist/deprecated/ActionList/Divider.d.ts +1 -0
  88. package/dist/deprecated/ActionList/Divider.d.ts.map +1 -1
  89. package/dist/deprecated/ActionList/Group.d.ts +1 -0
  90. package/dist/deprecated/ActionList/Group.d.ts.map +1 -1
  91. package/dist/deprecated/ActionList/Header.d.ts +1 -0
  92. package/dist/deprecated/ActionList/Header.d.ts.map +1 -1
  93. package/dist/deprecated/ActionList/List.d.ts.map +1 -1
  94. package/dist/deprecated/ActionMenu.d.ts +2 -1
  95. package/dist/deprecated/ActionMenu.d.ts.map +1 -1
  96. package/dist/deprecated/utils/create-slots.d.ts.map +1 -1
  97. package/dist/experimental/SelectPanel2/SelectPanel.d.ts.map +1 -1
  98. package/dist/experimental/SelectPanel2/SelectPanel.js +4 -2
  99. package/dist/experimental/UnderlinePanels/UnderlinePanels.d.ts +4 -0
  100. package/dist/experimental/UnderlinePanels/UnderlinePanels.d.ts.map +1 -1
  101. package/dist/hooks/useAnchoredPosition.d.ts.map +1 -1
  102. package/dist/hooks/useAnchoredPosition.js +0 -1
  103. package/dist/hooks/useControllableState.d.ts.map +1 -1
  104. package/dist/hooks/useControllableState.js +2 -0
  105. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  106. package/dist/hooks/useFocusTrap.js +0 -1
  107. package/dist/hooks/useFocusZone.d.ts.map +1 -1
  108. package/dist/hooks/useFocusZone.js +0 -1
  109. package/dist/hooks/useIsMacOS.d.ts.map +1 -1
  110. package/dist/hooks/useIsMacOS.js +3 -1
  111. package/dist/hooks/useMedia.d.ts.map +1 -1
  112. package/dist/hooks/useMedia.js +12 -27
  113. package/dist/hooks/useMenuInitialFocus.d.ts.map +1 -1
  114. package/dist/hooks/useMenuInitialFocus.js +0 -1
  115. package/dist/hooks/useOnEscapePress.d.ts.map +1 -1
  116. package/dist/hooks/useOnEscapePress.js +0 -1
  117. package/dist/hooks/useRenderForcingRef.d.ts.map +1 -1
  118. package/dist/hooks/useRenderForcingRef.js +37 -7
  119. package/dist/hooks/useResizeObserver.d.ts.map +1 -1
  120. package/dist/hooks/useResizeObserver.js +0 -1
  121. package/dist/hooks/useSafeTimeout.d.ts.map +1 -1
  122. package/dist/hooks/useSafeTimeout.js +0 -1
  123. package/dist/hooks/useScrollFlash.d.ts.map +1 -1
  124. package/dist/internal/components/UnderlineTabbedInterface.js +1 -1
  125. package/dist/internal/components/ValidationAnimationContainer.d.ts.map +1 -1
  126. package/dist/internal/hooks/useFocus.d.ts.map +1 -1
  127. package/dist/internal/hooks/useMergedRefs.d.ts.map +1 -1
  128. package/dist/internal/hooks/useMergedRefs.js +0 -1
  129. package/dist/utils/polymorphic.d.ts +1 -0
  130. package/dist/utils/polymorphic.d.ts.map +1 -1
  131. package/generated/components.json +37 -32
  132. package/package.json +18 -17
  133. package/dist/ActionList/ActionList-167cf6c7.css +0 -2
  134. package/dist/ActionList/ActionList-167cf6c7.css.map +0 -1
  135. package/dist/Link/Link-e01bdaee.css +0 -2
  136. package/dist/Link/Link-e01bdaee.css.map +0 -1
  137. package/dist/PageHeader/PageHeader-4e1d8fee.css +0 -2
  138. package/dist/PageHeader/PageHeader-4e1d8fee.css.map +0 -1
  139. package/dist/PageLayout/PageLayout-1849f083.css +0 -2
  140. package/dist/PageLayout/PageLayout-1849f083.css.map +0 -1
  141. package/dist/Timeline/Timeline-e8e88a13.css +0 -2
  142. package/dist/Timeline/Timeline-e8e88a13.css.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { c } from 'react-compiler-runtime';
2
- import React, { forwardRef, useRef, useState, useCallback, useId } from 'react';
2
+ import React, { forwardRef, useRef, useState, useId } from 'react';
3
3
  import { KebabHorizontalIcon } from '@primer/octicons-react';
4
4
  import { ActionList } from '../ActionList/index.js';
5
5
  import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
@@ -10,7 +10,7 @@ import { IconButton } from '../Button/IconButton.js';
10
10
  import { useFocusZone } from '../hooks/useFocusZone.js';
11
11
  import styles from './ActionBar.module.css.js';
12
12
  import { clsx } from 'clsx';
13
- import { jsx, jsxs } from 'react/jsx-runtime';
13
+ import { jsxs, jsx } from 'react/jsx-runtime';
14
14
  import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js';
15
15
  import { FocusKeys } from '@primer/behaviors';
16
16
  import { ActionMenu } from '../ActionMenu/ActionMenu.js';
@@ -50,6 +50,54 @@ const calculatePossibleItems = (registryEntries, navWidth, gap, moreMenuWidth =
50
50
  }
51
51
  return breakpoint;
52
52
  };
53
+ const renderMenuItem = (item, index) => {
54
+ if (item.type === 'divider') {
55
+ return /*#__PURE__*/jsx(ActionList.Divider, {}, index);
56
+ }
57
+ const {
58
+ label,
59
+ onClick,
60
+ disabled,
61
+ trailingVisual: TrailingIcon,
62
+ leadingVisual: LeadingIcon,
63
+ items,
64
+ variant
65
+ } = item;
66
+ if (items && items.length > 0) {
67
+ return /*#__PURE__*/jsxs(ActionMenu, {
68
+ children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
69
+ children: /*#__PURE__*/jsxs(ActionList.Item, {
70
+ disabled: disabled,
71
+ variant: variant,
72
+ children: [LeadingIcon ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
73
+ children: /*#__PURE__*/jsx(LeadingIcon, {})
74
+ }) : null, label, TrailingIcon ? /*#__PURE__*/jsx(ActionList.TrailingVisual, {
75
+ children: typeof TrailingIcon === 'string' ? /*#__PURE__*/jsx("span", {
76
+ children: TrailingIcon
77
+ }) : /*#__PURE__*/jsx(TrailingIcon, {})
78
+ }) : null]
79
+ })
80
+ }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
81
+ children: /*#__PURE__*/jsx(ActionList, {
82
+ children: items.map((subItem, subIndex) => renderMenuItem(subItem, subIndex))
83
+ })
84
+ })]
85
+ }, label);
86
+ }
87
+ return /*#__PURE__*/jsxs(ActionList.Item, {
88
+ onSelect: onClick,
89
+ disabled: disabled,
90
+ variant: variant,
91
+ children: [LeadingIcon ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
92
+ children: /*#__PURE__*/jsx(LeadingIcon, {})
93
+ }) : null, label, TrailingIcon ? /*#__PURE__*/jsx(ActionList.TrailingVisual, {
94
+ children: typeof TrailingIcon === 'string' ? /*#__PURE__*/jsx("span", {
95
+ children: TrailingIcon
96
+ }) : /*#__PURE__*/jsx(TrailingIcon, {})
97
+ }) : null]
98
+ }, label);
99
+ };
100
+ renderMenuItem.displayName = "renderMenuItem";
53
101
  const getMenuItems = (navWidth, moreMenuWidth, childRegistry, hasActiveMenu, gap) => {
54
102
  const registryEntries = Array.from(childRegistry).filter(entry => entry[1] !== null && (entry[1].type !== 'action' || entry[1].groupId === undefined));
55
103
  if (registryEntries.length === 0) return new Set();
@@ -86,176 +134,350 @@ const getMenuItems = (navWidth, moreMenuWidth, childRegistry, hasActiveMenu, gap
86
134
  }
87
135
  };
88
136
  const ActionBar = props => {
137
+ const $ = c(43);
89
138
  const {
90
- size = 'medium',
139
+ size: t0,
91
140
  children,
92
- 'aria-label': ariaLabel,
93
- 'aria-labelledby': ariaLabelledBy,
94
- flush = false,
141
+ "aria-label": ariaLabel,
142
+ "aria-labelledby": ariaLabelledBy,
143
+ flush: t1,
95
144
  className,
96
- gap = 'condensed'
145
+ gap: t2
97
146
  } = props;
98
-
99
- // We derive the numeric gap from computed style so layout math stays in sync with CSS
147
+ const size = t0 === undefined ? "medium" : t0;
148
+ const flush = t1 === undefined ? false : t1;
149
+ const gap = t2 === undefined ? "condensed" : t2;
100
150
  const listRef = useRef(null);
101
151
  const [computedGap, setComputedGap] = useState(ACTIONBAR_ITEM_GAP);
102
- const [childRegistry, setChildRegistry] = useState(() => new Map());
103
- const registerChild = useCallback((id, childProps) => setChildRegistry(prev => new Map(prev).set(id, childProps)), []);
104
- const unregisterChild = useCallback(id_0 => setChildRegistry(prev_0 => new Map(prev_0).set(id_0, null)), []);
105
- const [menuItemIds, setMenuItemIds] = useState(() => new Set());
152
+ const [childRegistry, setChildRegistry] = useState(_temp);
153
+ let t3;
154
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
155
+ t3 = (id, childProps) => setChildRegistry(prev => new Map(prev).set(id, childProps));
156
+ $[0] = t3;
157
+ } else {
158
+ t3 = $[0];
159
+ }
160
+ const registerChild = t3;
161
+ let t4;
162
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
163
+ t4 = id_0 => setChildRegistry(prev_0 => new Map(prev_0).set(id_0, null));
164
+ $[1] = t4;
165
+ } else {
166
+ t4 = $[1];
167
+ }
168
+ const unregisterChild = t4;
169
+ const [menuItemIds, setMenuItemIds] = useState(_temp2);
106
170
  const navRef = useRef(null);
107
- // measure gap after first render & whenever gap scale changes
108
- useIsomorphicLayoutEffect(() => {
109
- if (!listRef.current) return;
110
- const g = window.getComputedStyle(listRef.current).gap;
111
- const parsed = parseFloat(g);
112
- if (!Number.isNaN(parsed)) setComputedGap(parsed);
113
- }, [gap]);
171
+ let t5;
172
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
173
+ t5 = () => {
174
+ if (!listRef.current) {
175
+ return;
176
+ }
177
+ const g = window.getComputedStyle(listRef.current).gap;
178
+ const parsed = parseFloat(g);
179
+ if (!Number.isNaN(parsed)) {
180
+ setComputedGap(parsed);
181
+ }
182
+ };
183
+ $[2] = t5;
184
+ } else {
185
+ t5 = $[2];
186
+ }
187
+ let t6;
188
+ if ($[3] !== gap) {
189
+ t6 = [gap];
190
+ $[3] = gap;
191
+ $[4] = t6;
192
+ } else {
193
+ t6 = $[4];
194
+ }
195
+ useIsomorphicLayoutEffect(t5, t6);
114
196
  const moreMenuRef = useRef(null);
115
197
  const moreMenuBtnRef = useRef(null);
116
198
  const containerRef = React.useRef(null);
117
- useResizeObserver(resizeObserverEntries => {
118
- var _moreMenuRef$current$, _moreMenuRef$current;
119
- const navWidth = resizeObserverEntries[0].contentRect.width;
120
- const moreMenuWidth = (_moreMenuRef$current$ = (_moreMenuRef$current = moreMenuRef.current) === null || _moreMenuRef$current === void 0 ? void 0 : _moreMenuRef$current.getBoundingClientRect().width) !== null && _moreMenuRef$current$ !== void 0 ? _moreMenuRef$current$ : 0;
121
- const hasActiveMenu = menuItemIds.size > 0;
122
- if (navWidth > 0) {
123
- const newMenuItemIds = getMenuItems(navWidth, moreMenuWidth, childRegistry, hasActiveMenu, computedGap);
124
- if (newMenuItemIds) setMenuItemIds(newMenuItemIds);
125
- }
126
- }, navRef);
127
- const isVisibleChild = useCallback(id_1 => {
128
- return !menuItemIds.has(id_1);
129
- }, [menuItemIds]);
199
+ let t7;
200
+ if ($[5] !== childRegistry || $[6] !== computedGap || $[7] !== menuItemIds.size) {
201
+ t7 = resizeObserverEntries => {
202
+ var _moreMenuRef$current$, _moreMenuRef$current;
203
+ const navWidth = resizeObserverEntries[0].contentRect.width;
204
+ const moreMenuWidth = (_moreMenuRef$current$ = (_moreMenuRef$current = moreMenuRef.current) === null || _moreMenuRef$current === void 0 ? void 0 : _moreMenuRef$current.getBoundingClientRect().width) !== null && _moreMenuRef$current$ !== void 0 ? _moreMenuRef$current$ : 0;
205
+ const hasActiveMenu = menuItemIds.size > 0;
206
+ if (navWidth > 0) {
207
+ const newMenuItemIds = getMenuItems(navWidth, moreMenuWidth, childRegistry, hasActiveMenu, computedGap);
208
+ if (newMenuItemIds) {
209
+ setMenuItemIds(newMenuItemIds);
210
+ }
211
+ }
212
+ };
213
+ $[5] = childRegistry;
214
+ $[6] = computedGap;
215
+ $[7] = menuItemIds.size;
216
+ $[8] = t7;
217
+ } else {
218
+ t7 = $[8];
219
+ }
220
+ useResizeObserver(t7, navRef);
221
+ let t8;
222
+ if ($[9] !== menuItemIds) {
223
+ t8 = id_1 => !menuItemIds.has(id_1);
224
+ $[9] = menuItemIds;
225
+ $[10] = t8;
226
+ } else {
227
+ t8 = $[10];
228
+ }
229
+ const isVisibleChild = t8;
130
230
  const [isWidgetOpen, setIsWidgetOpen] = useState(false);
131
- const closeOverlay = React.useCallback(() => {
132
- setIsWidgetOpen(false);
133
- }, [setIsWidgetOpen]);
134
- const focusOnMoreMenuBtn = React.useCallback(() => {
135
- var _moreMenuBtnRef$curre;
136
- (_moreMenuBtnRef$curre = moreMenuBtnRef.current) === null || _moreMenuBtnRef$curre === void 0 ? void 0 : _moreMenuBtnRef$curre.focus();
137
- }, []);
138
- useOnEscapePress(event => {
139
- if (isWidgetOpen) {
140
- event.preventDefault();
141
- closeOverlay();
142
- focusOnMoreMenuBtn();
143
- }
144
- }, [isWidgetOpen]);
145
- useOnOutsideClick({
146
- onClickOutside: closeOverlay,
147
- containerRef,
148
- ignoreClickRefs: [moreMenuBtnRef]
149
- });
150
- useFocusZone({
151
- containerRef: listRef,
152
- bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
153
- focusOutBehavior: 'wrap'
154
- });
155
- const groupedItems = React.useMemo(() => {
156
- const groupedItemsMap = new Map();
231
+ let t9;
232
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
233
+ t9 = () => {
234
+ setIsWidgetOpen(false);
235
+ };
236
+ $[11] = t9;
237
+ } else {
238
+ t9 = $[11];
239
+ }
240
+ const closeOverlay = t9;
241
+ let t10;
242
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
243
+ t10 = () => {
244
+ var _moreMenuBtnRef$curre;
245
+ (_moreMenuBtnRef$curre = moreMenuBtnRef.current) === null || _moreMenuBtnRef$curre === void 0 ? void 0 : _moreMenuBtnRef$curre.focus();
246
+ };
247
+ $[12] = t10;
248
+ } else {
249
+ t10 = $[12];
250
+ }
251
+ const focusOnMoreMenuBtn = t10;
252
+ let t11;
253
+ let t12;
254
+ if ($[13] !== isWidgetOpen) {
255
+ t11 = event => {
256
+ if (isWidgetOpen) {
257
+ event.preventDefault();
258
+ closeOverlay();
259
+ focusOnMoreMenuBtn();
260
+ }
261
+ };
262
+ t12 = [isWidgetOpen];
263
+ $[13] = isWidgetOpen;
264
+ $[14] = t11;
265
+ $[15] = t12;
266
+ } else {
267
+ t11 = $[14];
268
+ t12 = $[15];
269
+ }
270
+ useOnEscapePress(t11, t12);
271
+ let t13;
272
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
273
+ t13 = {
274
+ onClickOutside: closeOverlay,
275
+ containerRef,
276
+ ignoreClickRefs: [moreMenuBtnRef]
277
+ };
278
+ $[16] = t13;
279
+ } else {
280
+ t13 = $[16];
281
+ }
282
+ useOnOutsideClick(t13);
283
+ let t14;
284
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
285
+ t14 = {
286
+ containerRef: listRef,
287
+ bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
288
+ focusOutBehavior: "wrap"
289
+ };
290
+ $[17] = t14;
291
+ } else {
292
+ t14 = $[17];
293
+ }
294
+ useFocusZone(t14);
295
+ let groupedItemsMap;
296
+ if ($[18] !== childRegistry) {
297
+ groupedItemsMap = new Map();
157
298
  for (const [key, childProps_0] of childRegistry) {
158
- if ((childProps_0 === null || childProps_0 === void 0 ? void 0 : childProps_0.type) === 'action' && childProps_0.groupId) {
299
+ if ((childProps_0 === null || childProps_0 === void 0 ? void 0 : childProps_0.type) === "action" && childProps_0.groupId) {
159
300
  const existingGroup = groupedItemsMap.get(childProps_0.groupId) || [];
160
301
  existingGroup.push([key, childProps_0]);
161
302
  groupedItemsMap.set(childProps_0.groupId, existingGroup);
162
303
  }
163
304
  }
164
- return groupedItemsMap;
165
- }, [childRegistry]);
166
- return /*#__PURE__*/jsx(ActionBarContext.Provider, {
167
- value: {
305
+ $[18] = childRegistry;
306
+ $[19] = groupedItemsMap;
307
+ } else {
308
+ groupedItemsMap = $[19];
309
+ }
310
+ const groupedItems = groupedItemsMap;
311
+ let t15;
312
+ if ($[20] !== isVisibleChild || $[21] !== size) {
313
+ t15 = {
168
314
  size,
169
315
  registerChild,
170
316
  unregisterChild,
171
317
  isVisibleChild
172
- },
173
- children: /*#__PURE__*/jsx("div", {
318
+ };
319
+ $[20] = isVisibleChild;
320
+ $[21] = size;
321
+ $[22] = t15;
322
+ } else {
323
+ t15 = $[22];
324
+ }
325
+ let t16;
326
+ if ($[23] !== className) {
327
+ t16 = clsx(className, styles.Nav);
328
+ $[23] = className;
329
+ $[24] = t16;
330
+ } else {
331
+ t16 = $[24];
332
+ }
333
+ let t17;
334
+ if ($[25] !== ariaLabel || $[26] !== childRegistry || $[27] !== groupedItems || $[28] !== menuItemIds) {
335
+ t17 = menuItemIds.size > 0 && /*#__PURE__*/jsxs(ActionMenu, {
336
+ children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
337
+ children: /*#__PURE__*/jsx(IconButton, {
338
+ variant: "invisible",
339
+ "aria-label": `More ${ariaLabel} items`,
340
+ icon: KebabHorizontalIcon
341
+ })
342
+ }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
343
+ children: /*#__PURE__*/jsx(ActionList, {
344
+ children: Array.from(menuItemIds).map(id_2 => {
345
+ const menuItem = childRegistry.get(id_2);
346
+ if (!menuItem) {
347
+ return null;
348
+ }
349
+ if (menuItem.type === "divider") {
350
+ return /*#__PURE__*/jsx(ActionList.Divider, {}, id_2);
351
+ } else {
352
+ if (menuItem.type === "action") {
353
+ const {
354
+ onClick,
355
+ icon: Icon,
356
+ label,
357
+ disabled
358
+ } = menuItem;
359
+ return /*#__PURE__*/jsxs(ActionList.Item, {
360
+ onClick: event_0 => {
361
+ closeOverlay();
362
+ focusOnMoreMenuBtn();
363
+ typeof onClick === "function" && onClick(event_0);
364
+ },
365
+ disabled: disabled,
366
+ children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
367
+ children: /*#__PURE__*/jsx(Icon, {})
368
+ }), label]
369
+ }, label);
370
+ }
371
+ }
372
+ if (menuItem.type === "menu") {
373
+ const menuItems = menuItem.items;
374
+ const {
375
+ icon: Icon_0,
376
+ label: label_0
377
+ } = menuItem;
378
+ return /*#__PURE__*/jsxs(ActionMenu, {
379
+ children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
380
+ children: /*#__PURE__*/jsxs(ActionList.Item, {
381
+ children: [Icon_0 !== "none" ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
382
+ children: /*#__PURE__*/jsx(Icon_0, {})
383
+ }) : null, label_0]
384
+ })
385
+ }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
386
+ children: /*#__PURE__*/jsx(ActionList, {
387
+ children: menuItems.map(_temp3)
388
+ })
389
+ })]
390
+ }, id_2);
391
+ }
392
+ const groupedMenuItems = groupedItems.get(id_2) || [];
393
+ if (menuItem.type === "group") {
394
+ return /*#__PURE__*/jsx(React.Fragment, {
395
+ children: groupedMenuItems.map(t18 => {
396
+ const [key_0, childProps_1] = t18;
397
+ if (childProps_1.type === "action") {
398
+ const {
399
+ onClick: onClick_0,
400
+ icon: Icon_1,
401
+ label: label_1,
402
+ disabled: disabled_0
403
+ } = childProps_1;
404
+ return /*#__PURE__*/jsxs(ActionList.Item, {
405
+ onSelect: event_1 => {
406
+ closeOverlay();
407
+ focusOnMoreMenuBtn();
408
+ typeof onClick_0 === "function" && onClick_0(event_1);
409
+ },
410
+ disabled: disabled_0,
411
+ children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
412
+ children: /*#__PURE__*/jsx(Icon_1, {})
413
+ }), label_1]
414
+ }, key_0);
415
+ }
416
+ return null;
417
+ })
418
+ }, id_2);
419
+ }
420
+ })
421
+ })
422
+ })]
423
+ });
424
+ $[25] = ariaLabel;
425
+ $[26] = childRegistry;
426
+ $[27] = groupedItems;
427
+ $[28] = menuItemIds;
428
+ $[29] = t17;
429
+ } else {
430
+ t17 = $[29];
431
+ }
432
+ let t18;
433
+ if ($[30] !== ariaLabel || $[31] !== ariaLabelledBy || $[32] !== children || $[33] !== gap || $[34] !== t17) {
434
+ t18 = /*#__PURE__*/jsxs("div", {
435
+ ref: listRef,
436
+ role: "toolbar",
437
+ className: styles.List,
438
+ "aria-label": ariaLabel,
439
+ "aria-labelledby": ariaLabelledBy,
440
+ "data-gap": gap,
441
+ children: [children, t17]
442
+ });
443
+ $[30] = ariaLabel;
444
+ $[31] = ariaLabelledBy;
445
+ $[32] = children;
446
+ $[33] = gap;
447
+ $[34] = t17;
448
+ $[35] = t18;
449
+ } else {
450
+ t18 = $[35];
451
+ }
452
+ let t19;
453
+ if ($[36] !== flush || $[37] !== t16 || $[38] !== t18) {
454
+ t19 = /*#__PURE__*/jsx("div", {
174
455
  ref: navRef,
175
- className: clsx(className, styles.Nav),
456
+ className: t16,
176
457
  "data-flush": flush,
177
- children: /*#__PURE__*/jsxs("div", {
178
- ref: listRef,
179
- role: "toolbar",
180
- className: styles.List,
181
- "aria-label": ariaLabel,
182
- "aria-labelledby": ariaLabelledBy,
183
- "data-gap": gap,
184
- children: [children, menuItemIds.size > 0 && /*#__PURE__*/jsxs(ActionMenu, {
185
- children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
186
- children: /*#__PURE__*/jsx(IconButton, {
187
- variant: "invisible",
188
- "aria-label": `More ${ariaLabel} items`,
189
- icon: KebabHorizontalIcon
190
- })
191
- }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
192
- children: /*#__PURE__*/jsx(ActionList, {
193
- children: Array.from(menuItemIds).map(id_2 => {
194
- const menuItem = childRegistry.get(id_2);
195
- if (!menuItem) return null;
196
- if (menuItem.type === 'divider') {
197
- return /*#__PURE__*/jsx(ActionList.Divider, {}, id_2);
198
- } else if (menuItem.type === 'action') {
199
- const {
200
- onClick,
201
- icon: Icon,
202
- label,
203
- disabled
204
- } = menuItem;
205
- return /*#__PURE__*/jsxs(ActionList.Item, {
206
- // eslint-disable-next-line primer-react/prefer-action-list-item-onselect
207
- onClick: event_0 => {
208
- closeOverlay();
209
- focusOnMoreMenuBtn();
210
- typeof onClick === 'function' && onClick(event_0);
211
- },
212
- disabled: disabled,
213
- children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
214
- children: /*#__PURE__*/jsx(Icon, {})
215
- }), label]
216
- }, label);
217
- }
218
-
219
- // Use the memoized map instead of filtering each time
220
- const groupedMenuItems = groupedItems.get(id_2) || [];
221
-
222
- // If we ever add additional types, this condition will be necessary
223
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
224
- if (menuItem.type === 'group') {
225
- return /*#__PURE__*/jsx(React.Fragment, {
226
- children: groupedMenuItems.map(([key_0, childProps_1]) => {
227
- if (childProps_1.type === 'action') {
228
- const {
229
- onClick: onClick_0,
230
- icon: Icon_0,
231
- label: label_0,
232
- disabled: disabled_0
233
- } = childProps_1;
234
- return /*#__PURE__*/jsxs(ActionList.Item, {
235
- onSelect: event_1 => {
236
- closeOverlay();
237
- focusOnMoreMenuBtn();
238
- typeof onClick_0 === 'function' && onClick_0(event_1);
239
- },
240
- disabled: disabled_0,
241
- children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
242
- children: /*#__PURE__*/jsx(Icon_0, {})
243
- }), label_0]
244
- }, key_0);
245
- }
246
- return null;
247
- })
248
- }, id_2);
249
- }
250
- })
251
- })
252
- })]
253
- })]
254
- })
255
- })
256
- });
458
+ children: t18
459
+ });
460
+ $[36] = flush;
461
+ $[37] = t16;
462
+ $[38] = t18;
463
+ $[39] = t19;
464
+ } else {
465
+ t19 = $[39];
466
+ }
467
+ let t20;
468
+ if ($[40] !== t15 || $[41] !== t19) {
469
+ t20 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
470
+ value: t15,
471
+ children: t19
472
+ });
473
+ $[40] = t15;
474
+ $[41] = t19;
475
+ $[42] = t20;
476
+ } else {
477
+ t20 = $[42];
478
+ }
479
+ return t20;
257
480
  };
258
- ActionBar.displayName = "ActionBar";
259
481
  const ActionBarIconButton = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
260
482
  const $ = c(28);
261
483
  let disabled;
@@ -470,6 +692,150 @@ const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
470
692
  }
471
693
  return t5;
472
694
  });
695
+ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
696
+ const $ = c(35);
697
+ let ariaLabel;
698
+ let icon;
699
+ let items;
700
+ let overflowIcon;
701
+ let props;
702
+ if ($[0] !== t0) {
703
+ ({
704
+ "aria-label": ariaLabel,
705
+ icon,
706
+ overflowIcon,
707
+ items,
708
+ ...props
709
+ } = t0);
710
+ $[0] = t0;
711
+ $[1] = ariaLabel;
712
+ $[2] = icon;
713
+ $[3] = items;
714
+ $[4] = overflowIcon;
715
+ $[5] = props;
716
+ } else {
717
+ ariaLabel = $[1];
718
+ icon = $[2];
719
+ items = $[3];
720
+ overflowIcon = $[4];
721
+ props = $[5];
722
+ }
723
+ const backupRef = useRef(null);
724
+ const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
725
+ const id = useId();
726
+ const {
727
+ registerChild,
728
+ unregisterChild,
729
+ isVisibleChild
730
+ } = React.useContext(ActionBarContext);
731
+ const [menuOpen, setMenuOpen] = useState(false);
732
+ const widthRef = useRef();
733
+ let t1;
734
+ if ($[6] !== ariaLabel || $[7] !== icon || $[8] !== id || $[9] !== items || $[10] !== overflowIcon || $[11] !== ref || $[12] !== registerChild || $[13] !== unregisterChild) {
735
+ t1 = () => {
736
+ var _ref$current3;
737
+ const width = (_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.getBoundingClientRect().width;
738
+ if (width) {
739
+ widthRef.current = width;
740
+ }
741
+ if (!widthRef.current) {
742
+ return;
743
+ }
744
+ registerChild(id, {
745
+ type: "menu",
746
+ width: widthRef.current,
747
+ label: ariaLabel,
748
+ icon: overflowIcon ? overflowIcon : icon,
749
+ items
750
+ });
751
+ return () => {
752
+ unregisterChild(id);
753
+ };
754
+ };
755
+ $[6] = ariaLabel;
756
+ $[7] = icon;
757
+ $[8] = id;
758
+ $[9] = items;
759
+ $[10] = overflowIcon;
760
+ $[11] = ref;
761
+ $[12] = registerChild;
762
+ $[13] = unregisterChild;
763
+ $[14] = t1;
764
+ } else {
765
+ t1 = $[14];
766
+ }
767
+ let t2;
768
+ if ($[15] !== ariaLabel || $[16] !== icon || $[17] !== items || $[18] !== overflowIcon || $[19] !== registerChild || $[20] !== unregisterChild) {
769
+ t2 = [registerChild, unregisterChild, ariaLabel, overflowIcon, icon, items];
770
+ $[15] = ariaLabel;
771
+ $[16] = icon;
772
+ $[17] = items;
773
+ $[18] = overflowIcon;
774
+ $[19] = registerChild;
775
+ $[20] = unregisterChild;
776
+ $[21] = t2;
777
+ } else {
778
+ t2 = $[21];
779
+ }
780
+ useIsomorphicLayoutEffect(t1, t2);
781
+ if (!isVisibleChild(id)) {
782
+ return null;
783
+ }
784
+ let t3;
785
+ if ($[22] !== ariaLabel || $[23] !== icon || $[24] !== props) {
786
+ t3 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
787
+ children: /*#__PURE__*/jsx(IconButton, {
788
+ variant: "invisible",
789
+ "aria-label": ariaLabel,
790
+ icon: icon,
791
+ ...props
792
+ })
793
+ });
794
+ $[22] = ariaLabel;
795
+ $[23] = icon;
796
+ $[24] = props;
797
+ $[25] = t3;
798
+ } else {
799
+ t3 = $[25];
800
+ }
801
+ let t4;
802
+ if ($[26] !== items) {
803
+ t4 = items.map(_temp4);
804
+ $[26] = items;
805
+ $[27] = t4;
806
+ } else {
807
+ t4 = $[27];
808
+ }
809
+ let t5;
810
+ if ($[28] !== t4) {
811
+ t5 = /*#__PURE__*/jsx(ActionMenu.Overlay, {
812
+ children: /*#__PURE__*/jsx(ActionList, {
813
+ children: t4
814
+ })
815
+ });
816
+ $[28] = t4;
817
+ $[29] = t5;
818
+ } else {
819
+ t5 = $[29];
820
+ }
821
+ let t6;
822
+ if ($[30] !== menuOpen || $[31] !== ref || $[32] !== t3 || $[33] !== t5) {
823
+ t6 = /*#__PURE__*/jsxs(ActionMenu, {
824
+ anchorRef: ref,
825
+ open: menuOpen,
826
+ onOpenChange: setMenuOpen,
827
+ children: [t3, t5]
828
+ });
829
+ $[30] = menuOpen;
830
+ $[31] = ref;
831
+ $[32] = t3;
832
+ $[33] = t5;
833
+ $[34] = t6;
834
+ } else {
835
+ t6 = $[34];
836
+ }
837
+ return t6;
838
+ });
473
839
  const VerticalDivider = () => {
474
840
  const $ = c(8);
475
841
  const ref = useRef(null);
@@ -483,8 +849,8 @@ const VerticalDivider = () => {
483
849
  let t0;
484
850
  if ($[0] !== id || $[1] !== registerChild || $[2] !== unregisterChild) {
485
851
  t0 = () => {
486
- var _ref$current3;
487
- const width = (_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.getBoundingClientRect().width;
852
+ var _ref$current4;
853
+ const width = (_ref$current4 = ref.current) === null || _ref$current4 === void 0 ? void 0 : _ref$current4.getBoundingClientRect().width;
488
854
  if (width) {
489
855
  widthRef.current = width;
490
856
  }
@@ -531,5 +897,17 @@ const VerticalDivider = () => {
531
897
  }
532
898
  return t2;
533
899
  };
900
+ function _temp() {
901
+ return new Map();
902
+ }
903
+ function _temp2() {
904
+ return new Set();
905
+ }
906
+ function _temp3(item, index) {
907
+ return renderMenuItem(item, index);
908
+ }
909
+ function _temp4(item, index) {
910
+ return renderMenuItem(item, index);
911
+ }
534
912
 
535
- export { ActionBar, ActionBarGroup, ActionBarIconButton, VerticalDivider };
913
+ export { ActionBar, ActionBarGroup, ActionBarIconButton, ActionBarMenu, VerticalDivider };