@primer/react 0.0.0-20260408160728 → 0.0.0-20260408162035

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.
@@ -1,29 +1,19 @@
1
1
  import { c } from 'react-compiler-runtime';
2
- import React, { useRef, useState, forwardRef, useMemo, useCallback } from 'react';
2
+ import React, { useRef, forwardRef, useState, useMemo, useCallback, useContext, useSyncExternalStore } from 'react';
3
3
  import { KebabHorizontalIcon } from '@primer/octicons-react';
4
4
  import { ActionList } from '../ActionList/index.js';
5
- import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
6
- import { useResizeObserver } from '../hooks/useResizeObserver.js';
7
5
  import { IconButton } from '../Button/IconButton.js';
8
6
  import { useFocusZone } from '../hooks/useFocusZone.js';
9
7
  import styles from './ActionBar.module.css.js';
10
8
  import { clsx } from 'clsx';
11
9
  import { createDescendantRegistry } from '../utils/descendant-registry.js';
12
- import { jsxs, jsx } from 'react/jsx-runtime';
13
- import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js';
10
+ import { jsx, jsxs } from 'react/jsx-runtime';
11
+ import { useMergedRefs } from '../hooks/useMergedRefs.js';
14
12
  import { FocusKeys } from '@primer/behaviors';
15
13
  import { ActionMenu } from '../ActionMenu/ActionMenu.js';
16
14
 
17
- const ACTIONBAR_ITEM_GAP = 8;
18
-
19
- /**
20
- * Registry of descendants to render in the list or menu. To preserve insertion order across updates, children are
21
- * set to `null` when unregistered rather than fully dropped from the map.
22
- */
23
-
24
15
  const ActionBarContext = /*#__PURE__*/React.createContext({
25
16
  size: 'medium',
26
- isVisibleChild: () => true,
27
17
  groupId: undefined
28
18
  });
29
19
 
@@ -31,23 +21,8 @@ const ActionBarContext = /*#__PURE__*/React.createContext({
31
21
  small (28px), medium (32px), large (40px)
32
22
  */
33
23
 
34
- const MORE_BTN_WIDTH = 32;
35
24
  const ActionBarItemsRegistry = createDescendantRegistry();
36
- const calculatePossibleItems = (registryEntries, navWidth, gap, moreMenuWidth = 0) => {
37
- const widthToFit = navWidth - moreMenuWidth;
38
- let breakpoint = registryEntries.length; // assume all items will fit
39
- let sumsOfChildWidth = 0;
40
- for (const [index, [, child]] of registryEntries.entries()) {
41
- sumsOfChildWidth += index > 0 ? child.width + gap : child.width;
42
- if (sumsOfChildWidth > widthToFit) {
43
- breakpoint = index;
44
- break;
45
- } else {
46
- continue;
47
- }
48
- }
49
- return breakpoint;
50
- };
25
+ const FOCUSABLE_ITEM_SELECTOR = ':is(button, a, input, [tabindex]):not(:disabled):not([data-overflowing]):not([data-more-button-inactive])';
51
26
  const renderMenuItem = (item, index) => {
52
27
  if (item.type === 'divider') {
53
28
  return /*#__PURE__*/jsx(ActionList.Divider, {}, index);
@@ -96,44 +71,8 @@ const renderMenuItem = (item, index) => {
96
71
  }, label);
97
72
  };
98
73
  renderMenuItem.displayName = "renderMenuItem";
99
- const getMenuItems = (navWidth, moreMenuWidth, childRegistry, hasActiveMenu, gap) => {
100
- var _childRegistry$entrie;
101
- const registryEntries = Array.from((_childRegistry$entrie = childRegistry === null || childRegistry === void 0 ? void 0 : childRegistry.entries()) !== null && _childRegistry$entrie !== void 0 ? _childRegistry$entrie : []).filter(entry => entry[1] !== null && (entry[1].type !== 'action' || entry[1].groupId === undefined));
102
- if (registryEntries.length === 0) return new Set();
103
- const numberOfItemsPossible = calculatePossibleItems(registryEntries, navWidth, gap);
104
- const numberOfItemsPossibleWithMoreMenu = calculatePossibleItems(registryEntries, navWidth, gap, moreMenuWidth || MORE_BTN_WIDTH);
105
- const menuItems = new Set();
106
-
107
- // First, we check if we can fit all the items with their icons
108
- if (registryEntries.length >= numberOfItemsPossible) {
109
- /* Below is an accessibility requirement. Never show only one item in the overflow menu.
110
- * If there is only one item left to display in the overflow menu according to the calculation,
111
- * we need to pull another item from the list into the overflow menu.
112
- */
113
- const numberOfItemsInMenu = registryEntries.length - numberOfItemsPossibleWithMoreMenu;
114
- const numberOfListItems = numberOfItemsInMenu === 1 ? numberOfItemsPossibleWithMoreMenu - 1 : numberOfItemsPossibleWithMoreMenu;
115
- for (const [index, [id, child]] of registryEntries.entries()) {
116
- if (index < numberOfListItems) {
117
- continue;
118
- //if the last item is a divider
119
- } else if (child.type === 'divider') {
120
- if (index === numberOfListItems - 1 || index === numberOfListItems) {
121
- continue;
122
- } else {
123
- menuItems.add(id);
124
- }
125
- } else {
126
- menuItems.add(id);
127
- }
128
- }
129
- return menuItems;
130
- } else if (numberOfItemsPossible > registryEntries.length && hasActiveMenu) {
131
- /* If the items fit in the list and there are items in the overflow menu, we need to move them back to the list */
132
- return new Set();
133
- }
134
- };
135
74
  const ActionBar = props => {
136
- const $ = c(38);
75
+ const $ = c(37);
137
76
  const {
138
77
  size: t0,
139
78
  children,
@@ -147,322 +86,295 @@ const ActionBar = props => {
147
86
  const flush = t1 === undefined ? false : t1;
148
87
  const gap = t2 === undefined ? "condensed" : t2;
149
88
  const listRef = useRef(null);
150
- const [computedGap, setComputedGap] = useState(ACTIONBAR_ITEM_GAP);
151
89
  const [childRegistry, setChildRegistry] = ActionBarItemsRegistry.useRegistryState();
152
- const [menuItemIds, setMenuItemIds] = useState(_temp);
153
90
  const navRef = useRef(null);
154
91
  let t3;
155
92
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
156
- t3 = () => {
157
- if (!listRef.current) {
158
- return;
159
- }
160
- const g = window.getComputedStyle(listRef.current).gap;
161
- const parsed = parseFloat(g);
162
- if (!Number.isNaN(parsed)) {
163
- setComputedGap(parsed);
93
+ t3 = {
94
+ containerRef: listRef,
95
+ bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
96
+ focusOutBehavior: "wrap",
97
+ strict: true,
98
+ getNextFocusable: (direction, from) => {
99
+ var _listRef$current$quer, _listRef$current;
100
+ const items = Array.from((_listRef$current$quer = (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.querySelectorAll(FOCUSABLE_ITEM_SELECTOR)) !== null && _listRef$current$quer !== void 0 ? _listRef$current$quer : []);
101
+ const fromIndex = from ? items.indexOf(from) : -1;
102
+ switch (direction) {
103
+ case "start":
104
+ {
105
+ return items[0];
106
+ }
107
+ case "end":
108
+ {
109
+ return items.at(-1);
110
+ }
111
+ case "next":
112
+ {
113
+ var _items;
114
+ return (_items = items[fromIndex + 1]) !== null && _items !== void 0 ? _items : items[0];
115
+ }
116
+ case "previous":
117
+ {
118
+ var _items2;
119
+ return (_items2 = items[fromIndex - 1]) !== null && _items2 !== void 0 ? _items2 : items.at(-1);
120
+ }
121
+ }
164
122
  }
165
123
  };
166
124
  $[0] = t3;
167
125
  } else {
168
126
  t3 = $[0];
169
127
  }
128
+ useFocusZone(t3);
170
129
  let t4;
171
- if ($[1] !== gap) {
172
- t4 = [gap];
173
- $[1] = gap;
130
+ if ($[1] !== childRegistry) {
131
+ t4 = childRegistry && Array.from(childRegistry.entries()).filter(_temp);
132
+ $[1] = childRegistry;
174
133
  $[2] = t4;
175
134
  } else {
176
135
  t4 = $[2];
177
136
  }
178
- useIsomorphicLayoutEffect(t3, t4);
179
- const moreMenuRef = useRef(null);
137
+ const overflowItems = t4;
180
138
  let t5;
181
- if ($[3] !== childRegistry || $[4] !== computedGap || $[5] !== menuItemIds.size) {
182
- t5 = resizeObserverEntries => {
183
- var _moreMenuRef$current$, _moreMenuRef$current;
184
- const navWidth = resizeObserverEntries[0].contentRect.width;
185
- 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;
186
- const hasActiveMenu = menuItemIds.size > 0;
187
- if (navWidth > 0) {
188
- const newMenuItemIds = getMenuItems(navWidth, moreMenuWidth, childRegistry, hasActiveMenu, computedGap);
189
- if (newMenuItemIds) {
190
- setMenuItemIds(newMenuItemIds);
191
- }
192
- }
139
+ if ($[3] !== size) {
140
+ t5 = {
141
+ size
193
142
  };
194
- $[3] = childRegistry;
195
- $[4] = computedGap;
196
- $[5] = menuItemIds.size;
197
- $[6] = t5;
143
+ $[3] = size;
144
+ $[4] = t5;
198
145
  } else {
199
- t5 = $[6];
146
+ t5 = $[4];
200
147
  }
201
- useResizeObserver(t5, navRef);
202
148
  let t6;
203
- if ($[7] !== menuItemIds) {
204
- t6 = id => !menuItemIds.has(id);
205
- $[7] = menuItemIds;
206
- $[8] = t6;
149
+ if ($[5] !== className) {
150
+ t6 = clsx(className, styles.Nav);
151
+ $[5] = className;
152
+ $[6] = t6;
207
153
  } else {
208
- t6 = $[8];
154
+ t6 = $[6];
209
155
  }
210
- const isVisibleChild = t6;
211
- let t7;
212
- if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
213
- t7 = {
214
- containerRef: listRef,
215
- bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
216
- focusOutBehavior: "wrap"
217
- };
218
- $[9] = t7;
156
+ const t7 = overflowItems ? overflowItems.length > 0 : undefined;
157
+ let t8;
158
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
159
+ t8 = /*#__PURE__*/jsx("div", {});
160
+ $[7] = t8;
219
161
  } else {
220
- t7 = $[9];
221
- }
222
- useFocusZone(t7);
223
- let groupedItemsMap;
224
- if ($[10] !== childRegistry) {
225
- groupedItemsMap = new Map();
226
- for (const [key, childProps] of childRegistry !== null && childRegistry !== void 0 ? childRegistry : []) {
227
- if (childProps.type === "action" && childProps.groupId) {
228
- const existingGroup = groupedItemsMap.get(childProps.groupId) || [];
229
- existingGroup.push([key, childProps]);
230
- groupedItemsMap.set(childProps.groupId, existingGroup);
231
- }
232
- }
233
- $[10] = childRegistry;
234
- $[11] = groupedItemsMap;
162
+ t8 = $[7];
163
+ }
164
+ let t9;
165
+ if ($[8] !== children || $[9] !== setChildRegistry) {
166
+ t9 = /*#__PURE__*/jsxs("div", {
167
+ className: styles.OverflowContainer,
168
+ children: [t8, /*#__PURE__*/jsx(ActionBarItemsRegistry.Provider, {
169
+ setRegistry: setChildRegistry,
170
+ children: children
171
+ })]
172
+ });
173
+ $[8] = children;
174
+ $[9] = setChildRegistry;
175
+ $[10] = t9;
235
176
  } else {
236
- groupedItemsMap = $[11];
177
+ t9 = $[10];
237
178
  }
238
- const groupedItems = groupedItemsMap;
239
- let t8;
240
- if ($[12] !== isVisibleChild || $[13] !== size) {
241
- t8 = {
242
- size,
243
- isVisibleChild
244
- };
245
- $[12] = isVisibleChild;
246
- $[13] = size;
247
- $[14] = t8;
179
+ const t10 = `More ${ariaLabel} items ${overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.length}`;
180
+ const t11 = overflowItems !== null && overflowItems !== void 0 && overflowItems.length ? undefined : true;
181
+ let t12;
182
+ if ($[11] !== size || $[12] !== t10 || $[13] !== t11) {
183
+ t12 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
184
+ children: /*#__PURE__*/jsx(IconButton, {
185
+ variant: "invisible",
186
+ "aria-label": t10,
187
+ icon: KebabHorizontalIcon,
188
+ className: styles.MoreButton,
189
+ "data-more-button-inactive": t11,
190
+ size: size
191
+ })
192
+ });
193
+ $[11] = size;
194
+ $[12] = t10;
195
+ $[13] = t11;
196
+ $[14] = t12;
248
197
  } else {
249
- t8 = $[14];
198
+ t12 = $[14];
250
199
  }
251
- let t9;
252
- if ($[15] !== className) {
253
- t9 = clsx(className, styles.Nav);
254
- $[15] = className;
255
- $[16] = t9;
200
+ let t13;
201
+ if ($[15] !== overflowItems) {
202
+ t13 = overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.map(_temp3);
203
+ $[15] = overflowItems;
204
+ $[16] = t13;
256
205
  } else {
257
- t9 = $[16];
206
+ t13 = $[16];
258
207
  }
259
- let t10;
260
- if ($[17] !== children || $[18] !== setChildRegistry) {
261
- t10 = /*#__PURE__*/jsx(ActionBarItemsRegistry.Provider, {
262
- setRegistry: setChildRegistry,
263
- children: children
208
+ let t14;
209
+ if ($[17] !== t13) {
210
+ t14 = /*#__PURE__*/jsx(ActionMenu.Overlay, {
211
+ children: /*#__PURE__*/jsx(ActionList, {
212
+ children: t13
213
+ })
264
214
  });
265
- $[17] = children;
266
- $[18] = setChildRegistry;
267
- $[19] = t10;
215
+ $[17] = t13;
216
+ $[18] = t14;
268
217
  } else {
269
- t10 = $[19];
218
+ t14 = $[18];
270
219
  }
271
- let t11;
272
- if ($[20] !== ariaLabel || $[21] !== childRegistry || $[22] !== groupedItems || $[23] !== menuItemIds) {
273
- t11 = menuItemIds.size > 0 && /*#__PURE__*/jsxs(ActionMenu, {
274
- children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
275
- children: /*#__PURE__*/jsx(IconButton, {
276
- variant: "invisible",
277
- "aria-label": `More ${ariaLabel} items`,
278
- icon: KebabHorizontalIcon
279
- })
280
- }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
281
- children: /*#__PURE__*/jsx(ActionList, {
282
- children: Array.from(menuItemIds).map(id_0 => {
283
- const menuItem = childRegistry === null || childRegistry === void 0 ? void 0 : childRegistry.get(id_0);
284
- if (!menuItem) {
285
- return null;
286
- }
287
- if (menuItem.type === "divider") {
288
- return /*#__PURE__*/jsx(ActionList.Divider, {}, id_0);
289
- } else {
290
- if (menuItem.type === "action") {
291
- const {
292
- onClick,
293
- icon: Icon,
294
- label,
295
- disabled
296
- } = menuItem;
297
- return /*#__PURE__*/jsxs(ActionList.Item, {
298
- onSelect: event => {
299
- typeof onClick === "function" && onClick(event);
300
- },
301
- disabled: disabled,
302
- children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
303
- children: /*#__PURE__*/jsx(Icon, {})
304
- }), label]
305
- }, label);
306
- }
307
- }
308
- if (menuItem.type === "menu") {
309
- const menuItems = menuItem.items;
310
- const {
311
- icon: Icon_0,
312
- label: label_0,
313
- returnFocusRef
314
- } = menuItem;
315
- return /*#__PURE__*/jsxs(ActionMenu, {
316
- children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
317
- children: /*#__PURE__*/jsxs(ActionList.Item, {
318
- children: [Icon_0 !== "none" ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
319
- children: /*#__PURE__*/jsx(Icon_0, {})
320
- }) : null, label_0]
321
- })
322
- }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
323
- ...(returnFocusRef && {
324
- returnFocusRef
325
- }),
326
- children: /*#__PURE__*/jsx(ActionList, {
327
- children: menuItems.map(_temp2)
328
- })
329
- })]
330
- }, id_0);
331
- }
332
- const groupedMenuItems = groupedItems.get(id_0) || [];
333
- if (menuItem.type === "group") {
334
- return /*#__PURE__*/jsx(React.Fragment, {
335
- children: groupedMenuItems.map(_temp3)
336
- }, id_0);
337
- }
338
- })
339
- })
340
- })]
220
+ let t15;
221
+ if ($[19] !== t12 || $[20] !== t14) {
222
+ t15 = /*#__PURE__*/jsxs(ActionMenu, {
223
+ children: [t12, t14]
341
224
  });
342
- $[20] = ariaLabel;
343
- $[21] = childRegistry;
344
- $[22] = groupedItems;
345
- $[23] = menuItemIds;
346
- $[24] = t11;
225
+ $[19] = t12;
226
+ $[20] = t14;
227
+ $[21] = t15;
347
228
  } else {
348
- t11 = $[24];
229
+ t15 = $[21];
349
230
  }
350
- let t12;
351
- if ($[25] !== ariaLabel || $[26] !== ariaLabelledBy || $[27] !== gap || $[28] !== t10 || $[29] !== t11) {
352
- t12 = /*#__PURE__*/jsxs("div", {
231
+ let t16;
232
+ if ($[22] !== ariaLabel || $[23] !== ariaLabelledBy || $[24] !== gap || $[25] !== size || $[26] !== t15 || $[27] !== t7 || $[28] !== t9) {
233
+ t16 = /*#__PURE__*/jsxs("div", {
353
234
  ref: listRef,
354
235
  role: "toolbar",
355
236
  className: styles.List,
356
237
  "aria-label": ariaLabel,
357
238
  "aria-labelledby": ariaLabelledBy,
358
239
  "data-gap": gap,
359
- children: [t10, t11]
240
+ "data-size": size,
241
+ "data-has-overflow": t7,
242
+ children: [t9, t15]
360
243
  });
361
- $[25] = ariaLabel;
362
- $[26] = ariaLabelledBy;
363
- $[27] = gap;
364
- $[28] = t10;
365
- $[29] = t11;
366
- $[30] = t12;
244
+ $[22] = ariaLabel;
245
+ $[23] = ariaLabelledBy;
246
+ $[24] = gap;
247
+ $[25] = size;
248
+ $[26] = t15;
249
+ $[27] = t7;
250
+ $[28] = t9;
251
+ $[29] = t16;
367
252
  } else {
368
- t12 = $[30];
253
+ t16 = $[29];
369
254
  }
370
- let t13;
371
- if ($[31] !== flush || $[32] !== t12 || $[33] !== t9) {
372
- t13 = /*#__PURE__*/jsx("div", {
255
+ let t17;
256
+ if ($[30] !== flush || $[31] !== t16 || $[32] !== t6) {
257
+ t17 = /*#__PURE__*/jsx("div", {
373
258
  ref: navRef,
374
- className: t9,
259
+ className: t6,
375
260
  "data-flush": flush,
376
- children: t12
261
+ children: t16
377
262
  });
378
- $[31] = flush;
379
- $[32] = t12;
380
- $[33] = t9;
381
- $[34] = t13;
263
+ $[30] = flush;
264
+ $[31] = t16;
265
+ $[32] = t6;
266
+ $[33] = t17;
382
267
  } else {
383
- t13 = $[34];
268
+ t17 = $[33];
384
269
  }
385
- let t14;
386
- if ($[35] !== t13 || $[36] !== t8) {
387
- t14 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
388
- value: t8,
389
- children: t13
270
+ let t18;
271
+ if ($[34] !== t17 || $[35] !== t5) {
272
+ t18 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
273
+ value: t5,
274
+ children: t17
390
275
  });
391
- $[35] = t13;
392
- $[36] = t8;
393
- $[37] = t14;
276
+ $[34] = t17;
277
+ $[35] = t5;
278
+ $[36] = t18;
394
279
  } else {
395
- t14 = $[37];
280
+ t18 = $[36];
396
281
  }
397
- return t14;
282
+ return t18;
398
283
  };
399
- function useWidth(ref) {
400
- const $ = c(3);
401
- const [width, setWidth] = useState(-1);
284
+ function useActionBarItem(ref, registryProps) {
285
+ var _useContext;
286
+ const $ = c(8);
287
+ const isGroupOverflowing = (_useContext = useContext(ActionBarGroupContext)) === null || _useContext === void 0 ? void 0 : _useContext.isOverflowing;
288
+ const isInGroup = isGroupOverflowing !== undefined;
402
289
  let t0;
290
+ if ($[0] !== isInGroup || $[1] !== ref) {
291
+ t0 = onChange => {
292
+ if (isInGroup) {
293
+ return _temp4;
294
+ }
295
+ const observer = new IntersectionObserver(() => onChange(), {
296
+ threshold: 1
297
+ });
298
+ if (ref.current) {
299
+ observer.observe(ref.current);
300
+ }
301
+ return () => observer.disconnect();
302
+ };
303
+ $[0] = isInGroup;
304
+ $[1] = ref;
305
+ $[2] = t0;
306
+ } else {
307
+ t0 = $[2];
308
+ }
309
+ const subscribeIntersectionObserver = t0;
403
310
  let t1;
404
- if ($[0] !== ref) {
405
- t0 = () => {
406
- var _ref$current$getBound, _ref$current;
407
- return setWidth((_ref$current$getBound = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect().width) !== null && _ref$current$getBound !== void 0 ? _ref$current$getBound : -1);
311
+ if ($[3] !== ref) {
312
+ t1 = () => ref.current ? ref.current.offsetTop > 0 : false;
313
+ $[3] = ref;
314
+ $[4] = t1;
315
+ } else {
316
+ t1 = $[4];
317
+ }
318
+ const isItemOverflowing = useSyncExternalStore(subscribeIntersectionObserver, t1, _temp5);
319
+ const isOverflowing = isGroupOverflowing || isItemOverflowing;
320
+ ActionBarItemsRegistry.useRegisterDescendant(isOverflowing ? registryProps : null);
321
+ const t2 = isOverflowing ? "" : undefined;
322
+ let t3;
323
+ if ($[5] !== isOverflowing || $[6] !== t2) {
324
+ t3 = {
325
+ isOverflowing,
326
+ dataOverflowingAttr: t2
408
327
  };
409
- t1 = [ref];
410
- $[0] = ref;
411
- $[1] = t0;
412
- $[2] = t1;
328
+ $[5] = isOverflowing;
329
+ $[6] = t2;
330
+ $[7] = t3;
413
331
  } else {
414
- t0 = $[1];
415
- t1 = $[2];
332
+ t3 = $[7];
416
333
  }
417
- useIsomorphicLayoutEffect(t0, t1);
418
- return width;
334
+ return t3;
335
+ }
336
+ function _temp5() {
337
+ return false;
419
338
  }
339
+ function _temp4() {}
420
340
  const ActionBarIconButton = /*#__PURE__*/forwardRef(({
421
341
  disabled,
422
342
  onClick,
423
343
  ...props
424
344
  }, forwardedRef) => {
425
345
  const ref = useRef(null);
426
- useRefObjectAsForwardedRef(forwardedRef, ref);
346
+ const mergedRef = useMergedRefs(ref, forwardedRef);
427
347
  const {
428
- size,
429
- isVisibleChild
348
+ size
430
349
  } = React.useContext(ActionBarContext);
431
- const {
432
- groupId
433
- } = React.useContext(ActionBarGroupContext);
434
- const width = useWidth(ref);
435
350
  const {
436
351
  ['aria-label']: ariaLabel,
437
352
  icon
438
353
  } = props;
439
- const registryProps = useMemo(() => ({
354
+ const {
355
+ dataOverflowingAttr
356
+ } = useActionBarItem(ref, useMemo(() => ({
440
357
  type: 'action',
441
358
  label: ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : '',
442
359
  icon,
443
360
  disabled: !!disabled,
444
- onClick: onClick,
445
- width,
446
- groupId: groupId !== null && groupId !== void 0 ? groupId : undefined
447
- }), [ariaLabel, icon, disabled, onClick, groupId, width]);
448
- const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
361
+ onClick: onClick
362
+ }), [ariaLabel, icon, disabled, onClick]));
449
363
  const clickHandler = useCallback(event => {
450
364
  if (disabled) return;
451
365
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
452
366
  }, [disabled, onClick]);
453
- if (!isVisibleChild(id) || groupId && !isVisibleChild(groupId)) return null;
454
367
  return /*#__PURE__*/jsx(IconButton, {
455
368
  "aria-disabled": disabled,
456
- ref: ref,
369
+ ref: mergedRef,
457
370
  size: size,
458
371
  onClick: clickHandler,
459
372
  ...props,
460
- variant: "invisible"
373
+ variant: "invisible",
374
+ "data-overflowing": dataOverflowingAttr
461
375
  });
462
376
  });
463
- const ActionBarGroupContext = /*#__PURE__*/React.createContext({
464
- groupId: null
465
- });
377
+ const ActionBarGroupContext = /*#__PURE__*/React.createContext(null);
466
378
  const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
467
379
  const $ = c(10);
468
380
  const {
@@ -470,38 +382,39 @@ const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
470
382
  } = t0;
471
383
  const backupRef = useRef(null);
472
384
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
473
- const width = useWidth(ref);
474
385
  let t1;
475
- if ($[0] !== width) {
386
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
476
387
  t1 = {
477
- type: "group",
478
- width
388
+ type: "group"
479
389
  };
480
- $[0] = width;
481
- $[1] = t1;
390
+ $[0] = t1;
482
391
  } else {
483
- t1 = $[1];
392
+ t1 = $[0];
484
393
  }
485
- const registryProps = t1;
486
- const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
394
+ const {
395
+ dataOverflowingAttr,
396
+ isOverflowing
397
+ } = useActionBarItem(ref, t1);
487
398
  let t2;
488
- if ($[2] !== id) {
399
+ if ($[1] !== isOverflowing) {
489
400
  t2 = {
490
- groupId: id
401
+ isOverflowing
491
402
  };
492
- $[2] = id;
493
- $[3] = t2;
403
+ $[1] = isOverflowing;
404
+ $[2] = t2;
494
405
  } else {
495
- t2 = $[3];
406
+ t2 = $[2];
496
407
  }
497
408
  let t3;
498
- if ($[4] !== children || $[5] !== ref) {
409
+ if ($[3] !== children || $[4] !== dataOverflowingAttr || $[5] !== ref) {
499
410
  t3 = /*#__PURE__*/jsx("div", {
500
411
  className: styles.Group,
501
412
  ref: ref,
413
+ "data-overflowing": dataOverflowingAttr,
502
414
  children: children
503
415
  });
504
- $[4] = children;
416
+ $[3] = children;
417
+ $[4] = dataOverflowingAttr;
505
418
  $[5] = ref;
506
419
  $[6] = t3;
507
420
  } else {
@@ -555,17 +468,12 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
555
468
  }
556
469
  const backupRef = useRef(null);
557
470
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
558
- const {
559
- isVisibleChild
560
- } = React.useContext(ActionBarContext);
561
471
  const [menuOpen, setMenuOpen] = useState(false);
562
- const width = useWidth(ref);
563
472
  const t1 = overflowIcon ? overflowIcon : icon;
564
473
  let t2;
565
- if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1 || $[11] !== width) {
474
+ if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1) {
566
475
  t2 = {
567
476
  type: "menu",
568
- width,
569
477
  label: ariaLabel,
570
478
  icon: t1,
571
479
  returnFocusRef,
@@ -575,27 +483,26 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
575
483
  $[8] = items;
576
484
  $[9] = returnFocusRef;
577
485
  $[10] = t1;
578
- $[11] = width;
579
- $[12] = t2;
486
+ $[11] = t2;
580
487
  } else {
581
- t2 = $[12];
582
- }
583
- const registryProps = t2;
584
- const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
585
- if (!isVisibleChild(id)) {
586
- return null;
488
+ t2 = $[11];
587
489
  }
490
+ const {
491
+ dataOverflowingAttr
492
+ } = useActionBarItem(ref, t2);
588
493
  let t3;
589
- if ($[13] !== ariaLabel || $[14] !== icon || $[15] !== props) {
494
+ if ($[12] !== ariaLabel || $[13] !== dataOverflowingAttr || $[14] !== icon || $[15] !== props) {
590
495
  t3 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
591
496
  children: /*#__PURE__*/jsx(IconButton, {
592
497
  variant: "invisible",
593
498
  "aria-label": ariaLabel,
594
499
  icon: icon,
595
- ...props
500
+ ...props,
501
+ "data-overflowing": dataOverflowingAttr
596
502
  })
597
503
  });
598
- $[13] = ariaLabel;
504
+ $[12] = ariaLabel;
505
+ $[13] = dataOverflowingAttr;
599
506
  $[14] = icon;
600
507
  $[15] = props;
601
508
  $[16] = t3;
@@ -614,7 +521,7 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
614
521
  }
615
522
  let t5;
616
523
  if ($[19] !== items) {
617
- t5 = items.map(_temp4);
524
+ t5 = items.map(_temp6);
618
525
  $[19] = items;
619
526
  $[20] = t5;
620
527
  } else {
@@ -663,68 +570,88 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
663
570
  const VerticalDivider = () => {
664
571
  const $ = c(3);
665
572
  const ref = useRef(null);
666
- const {
667
- isVisibleChild
668
- } = React.useContext(ActionBarContext);
669
- const width = useWidth(ref);
670
573
  let t0;
671
- if ($[0] !== width) {
574
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
672
575
  t0 = {
673
- type: "divider",
674
- width
576
+ type: "divider"
675
577
  };
676
- $[0] = width;
677
- $[1] = t0;
578
+ $[0] = t0;
678
579
  } else {
679
- t0 = $[1];
680
- }
681
- const registryProps = t0;
682
- const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
683
- if (!isVisibleChild(id)) {
684
- return null;
580
+ t0 = $[0];
685
581
  }
582
+ const {
583
+ dataOverflowingAttr
584
+ } = useActionBarItem(ref, t0);
686
585
  let t1;
687
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
586
+ if ($[1] !== dataOverflowingAttr) {
688
587
  t1 = /*#__PURE__*/jsx("div", {
689
588
  ref: ref,
690
589
  "data-component": "ActionBar.VerticalDivider",
691
590
  "aria-hidden": "true",
692
- className: styles.Divider
591
+ className: styles.Divider,
592
+ "data-overflowing": dataOverflowingAttr
693
593
  });
594
+ $[1] = dataOverflowingAttr;
694
595
  $[2] = t1;
695
596
  } else {
696
597
  t1 = $[2];
697
598
  }
698
599
  return t1;
699
600
  };
700
- function _temp() {
701
- return new Set();
601
+ function _temp(entry) {
602
+ return entry[1] !== null;
702
603
  }
703
604
  function _temp2(item, index) {
704
605
  return renderMenuItem(item, index);
705
606
  }
706
607
  function _temp3(t0) {
707
- const [key_0, childProps_0] = t0;
708
- if (childProps_0.type === "action") {
608
+ const [id, menuItem] = t0;
609
+ if (menuItem.type === "divider") {
610
+ return /*#__PURE__*/jsx(ActionList.Divider, {}, id);
611
+ }
612
+ if (menuItem.type === "action") {
709
613
  const {
710
- onClick: onClick_0,
711
- icon: Icon_1,
712
- label: label_1,
713
- disabled: disabled_0
714
- } = childProps_0;
614
+ onClick,
615
+ icon: Icon,
616
+ label,
617
+ disabled
618
+ } = menuItem;
715
619
  return /*#__PURE__*/jsxs(ActionList.Item, {
716
- onSelect: event_0 => {
717
- typeof onClick_0 === "function" && onClick_0(event_0);
620
+ onSelect: event => {
621
+ typeof onClick === "function" && onClick(event);
718
622
  },
719
- disabled: disabled_0,
623
+ disabled: disabled,
720
624
  children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
721
- children: /*#__PURE__*/jsx(Icon_1, {})
722
- }), label_1]
723
- }, key_0);
625
+ children: /*#__PURE__*/jsx(Icon, {})
626
+ }), label]
627
+ }, label);
628
+ }
629
+ if (menuItem.type === "menu") {
630
+ const menuItems = menuItem.items;
631
+ const {
632
+ icon: Icon_0,
633
+ label: label_0,
634
+ returnFocusRef
635
+ } = menuItem;
636
+ return /*#__PURE__*/jsxs(ActionMenu, {
637
+ children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
638
+ children: /*#__PURE__*/jsxs(ActionList.Item, {
639
+ children: [Icon_0 !== "none" ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
640
+ children: /*#__PURE__*/jsx(Icon_0, {})
641
+ }) : null, label_0]
642
+ })
643
+ }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
644
+ ...(returnFocusRef && {
645
+ returnFocusRef
646
+ }),
647
+ children: /*#__PURE__*/jsx(ActionList, {
648
+ children: menuItems.map(_temp2)
649
+ })
650
+ })]
651
+ }, id);
724
652
  }
725
- return null;
726
653
  }
727
- function _temp4(item, index) {
654
+ function _temp6(item, index) {
728
655
  return renderMenuItem(item, index);
729
656
  }
730
657