@primer/react 0.0.0-20260313173502 → 0.0.0-20260313175735

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 (54) hide show
  1. package/CHANGELOG.md +2 -20
  2. package/dist/ActionBar/ActionBar-94abaa40.css +2 -0
  3. package/dist/ActionBar/ActionBar-94abaa40.css.map +1 -0
  4. package/dist/ActionBar/ActionBar.d.ts +1 -1
  5. package/dist/ActionBar/ActionBar.d.ts.map +1 -1
  6. package/dist/ActionBar/ActionBar.js +257 -362
  7. package/dist/ActionBar/ActionBar.module.css.js +2 -2
  8. package/dist/ActionBar/index.d.ts +1 -1
  9. package/dist/ActionList/Item.d.ts.map +1 -1
  10. package/dist/ActionList/Item.js +192 -628
  11. package/dist/ActionList/LinkItem.d.ts +3 -6
  12. package/dist/ActionList/LinkItem.d.ts.map +1 -1
  13. package/dist/ActionList/LinkItem.js +87 -42
  14. package/dist/ActionList/List.d.ts.map +1 -1
  15. package/dist/ActionList/List.js +5 -6
  16. package/dist/ActionList/index.d.ts +1 -25
  17. package/dist/ActionList/index.d.ts.map +1 -1
  18. package/dist/Banner/{Banner-41040ab7.css → Banner-b3871000.css} +2 -2
  19. package/dist/Banner/{Banner-41040ab7.css.map → Banner-b3871000.css.map} +1 -1
  20. package/dist/Banner/Banner.d.ts.map +1 -1
  21. package/dist/Banner/Banner.js +0 -1
  22. package/dist/Banner/Banner.module.css.js +1 -1
  23. package/dist/Breadcrumbs/Breadcrumbs.d.ts +8 -23
  24. package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  25. package/dist/Breadcrumbs/Breadcrumbs.js +66 -27
  26. package/dist/Button/{ButtonBase-6659abcf.css → ButtonBase-781fba8b.css} +2 -2
  27. package/dist/Button/{ButtonBase-6659abcf.css.map → ButtonBase-781fba8b.css.map} +1 -1
  28. package/dist/Button/ButtonBase.module.css.js +1 -1
  29. package/dist/Dialog/{Dialog-2de477b3.css → Dialog-2d417a89.css} +2 -2
  30. package/dist/Dialog/{Dialog-2de477b3.css.map → Dialog-2d417a89.css.map} +1 -1
  31. package/dist/Dialog/Dialog.d.ts.map +1 -1
  32. package/dist/Dialog/Dialog.js +1 -3
  33. package/dist/Dialog/Dialog.module.css.js +2 -2
  34. package/dist/NavList/NavList.d.ts +3 -20
  35. package/dist/NavList/NavList.d.ts.map +1 -1
  36. package/dist/NavList/NavList.js +124 -50
  37. package/dist/Overlay/{Overlay-dbaa6b8c.css → Overlay-15519c09.css} +2 -2
  38. package/dist/Overlay/Overlay-15519c09.css.map +1 -0
  39. package/dist/Overlay/Overlay.module.css.js +1 -1
  40. package/dist/PageLayout/PageLayout.d.ts +20 -4
  41. package/dist/PageLayout/PageLayout.d.ts.map +1 -1
  42. package/dist/PageLayout/PageLayout.js +0 -12
  43. package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
  44. package/dist/SelectPanel/SelectPanel.js +29 -30
  45. package/dist/TextInput/TextInput.d.ts.map +1 -1
  46. package/dist/TextInput/TextInput.js +5 -31
  47. package/dist/TreeView/TreeView.d.ts.map +1 -1
  48. package/dist/TreeView/TreeView.js +59 -101
  49. package/dist/utils/character-counter.d.ts.map +1 -1
  50. package/dist/utils/character-counter.js +0 -1
  51. package/package.json +1 -1
  52. package/dist/ActionBar/ActionBar-a41224b2.css +0 -2
  53. package/dist/ActionBar/ActionBar-a41224b2.css.map +0 -1
  54. package/dist/Overlay/Overlay-dbaa6b8c.css.map +0 -1
@@ -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';
10
+ import { jsx, jsxs } from 'react/jsx-runtime';
13
11
  import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.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,7 @@ 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
- };
51
25
  const renderMenuItem = (item, index) => {
52
26
  if (item.type === 'divider') {
53
27
  return /*#__PURE__*/jsx(ActionList.Divider, {}, index);
@@ -96,44 +70,8 @@ const renderMenuItem = (item, index) => {
96
70
  }, label);
97
71
  };
98
72
  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
73
  const ActionBar = props => {
136
- const $ = c(38);
74
+ const $ = c(35);
137
75
  const {
138
76
  size: t0,
139
77
  children,
@@ -147,276 +85,226 @@ const ActionBar = props => {
147
85
  const flush = t1 === undefined ? false : t1;
148
86
  const gap = t2 === undefined ? "condensed" : t2;
149
87
  const listRef = useRef(null);
150
- const [computedGap, setComputedGap] = useState(ACTIONBAR_ITEM_GAP);
151
88
  const [childRegistry, setChildRegistry] = ActionBarItemsRegistry.useRegistryState();
152
- const [menuItemIds, setMenuItemIds] = useState(_temp);
153
89
  const navRef = useRef(null);
154
90
  let t3;
155
91
  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);
164
- }
92
+ t3 = {
93
+ containerRef: listRef,
94
+ bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
95
+ focusOutBehavior: "wrap"
165
96
  };
166
97
  $[0] = t3;
167
98
  } else {
168
99
  t3 = $[0];
169
100
  }
101
+ useFocusZone(t3);
170
102
  let t4;
171
- if ($[1] !== gap) {
172
- t4 = [gap];
173
- $[1] = gap;
103
+ if ($[1] !== childRegistry) {
104
+ t4 = childRegistry && Array.from(childRegistry.entries()).filter(_temp);
105
+ $[1] = childRegistry;
174
106
  $[2] = t4;
175
107
  } else {
176
108
  t4 = $[2];
177
109
  }
178
- useIsomorphicLayoutEffect(t3, t4);
179
- const moreMenuRef = useRef(null);
110
+ const overflowItems = t4;
180
111
  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
- }
112
+ if ($[3] !== size) {
113
+ t5 = {
114
+ size
193
115
  };
194
- $[3] = childRegistry;
195
- $[4] = computedGap;
196
- $[5] = menuItemIds.size;
197
- $[6] = t5;
116
+ $[3] = size;
117
+ $[4] = t5;
198
118
  } else {
199
- t5 = $[6];
119
+ t5 = $[4];
200
120
  }
201
- useResizeObserver(t5, navRef);
202
121
  let t6;
203
- if ($[7] !== menuItemIds) {
204
- t6 = id => !menuItemIds.has(id);
205
- $[7] = menuItemIds;
206
- $[8] = t6;
122
+ if ($[5] !== className) {
123
+ t6 = clsx(className, styles.Nav);
124
+ $[5] = className;
125
+ $[6] = t6;
207
126
  } else {
208
- t6 = $[8];
127
+ t6 = $[6];
209
128
  }
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;
129
+ const t7 = overflowItems ? overflowItems.length > 0 : undefined;
130
+ let t8;
131
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
132
+ t8 = /*#__PURE__*/jsx("div", {});
133
+ $[7] = t8;
219
134
  } 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;
135
+ t8 = $[7];
136
+ }
137
+ let t9;
138
+ if ($[8] !== children || $[9] !== setChildRegistry) {
139
+ t9 = /*#__PURE__*/jsxs("div", {
140
+ className: styles.OverflowContainer,
141
+ children: [t8, /*#__PURE__*/jsx(ActionBarItemsRegistry.Provider, {
142
+ setRegistry: setChildRegistry,
143
+ children: children
144
+ })]
145
+ });
146
+ $[8] = children;
147
+ $[9] = setChildRegistry;
148
+ $[10] = t9;
235
149
  } else {
236
- groupedItemsMap = $[11];
150
+ t9 = $[10];
237
151
  }
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;
152
+ const t10 = `More ${ariaLabel} items`;
153
+ let t11;
154
+ if ($[11] !== t10) {
155
+ t11 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
156
+ children: /*#__PURE__*/jsx(IconButton, {
157
+ variant: "invisible",
158
+ "aria-label": t10,
159
+ icon: KebabHorizontalIcon,
160
+ className: styles.MoreButton
161
+ })
162
+ });
163
+ $[11] = t10;
164
+ $[12] = t11;
248
165
  } else {
249
- t8 = $[14];
166
+ t11 = $[12];
250
167
  }
251
- let t9;
252
- if ($[15] !== className) {
253
- t9 = clsx(className, styles.Nav);
254
- $[15] = className;
255
- $[16] = t9;
168
+ let t12;
169
+ if ($[13] !== overflowItems) {
170
+ t12 = overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.map(_temp3);
171
+ $[13] = overflowItems;
172
+ $[14] = t12;
256
173
  } else {
257
- t9 = $[16];
174
+ t12 = $[14];
258
175
  }
259
- let t10;
260
- if ($[17] !== children || $[18] !== setChildRegistry) {
261
- t10 = /*#__PURE__*/jsx(ActionBarItemsRegistry.Provider, {
262
- setRegistry: setChildRegistry,
263
- children: children
176
+ let t13;
177
+ if ($[15] !== t12) {
178
+ t13 = /*#__PURE__*/jsx(ActionMenu.Overlay, {
179
+ children: /*#__PURE__*/jsx(ActionList, {
180
+ children: t12
181
+ })
264
182
  });
265
- $[17] = children;
266
- $[18] = setChildRegistry;
267
- $[19] = t10;
183
+ $[15] = t12;
184
+ $[16] = t13;
268
185
  } else {
269
- t10 = $[19];
186
+ t13 = $[16];
270
187
  }
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
- })]
188
+ let t14;
189
+ if ($[17] !== t11 || $[18] !== t13) {
190
+ t14 = /*#__PURE__*/jsxs(ActionMenu, {
191
+ children: [t11, t13]
341
192
  });
342
- $[20] = ariaLabel;
343
- $[21] = childRegistry;
344
- $[22] = groupedItems;
345
- $[23] = menuItemIds;
346
- $[24] = t11;
193
+ $[17] = t11;
194
+ $[18] = t13;
195
+ $[19] = t14;
347
196
  } else {
348
- t11 = $[24];
197
+ t14 = $[19];
349
198
  }
350
- let t12;
351
- if ($[25] !== ariaLabel || $[26] !== ariaLabelledBy || $[27] !== gap || $[28] !== t10 || $[29] !== t11) {
352
- t12 = /*#__PURE__*/jsxs("div", {
199
+ let t15;
200
+ if ($[20] !== ariaLabel || $[21] !== ariaLabelledBy || $[22] !== gap || $[23] !== size || $[24] !== t14 || $[25] !== t7 || $[26] !== t9) {
201
+ t15 = /*#__PURE__*/jsxs("div", {
353
202
  ref: listRef,
354
203
  role: "toolbar",
355
204
  className: styles.List,
356
205
  "aria-label": ariaLabel,
357
206
  "aria-labelledby": ariaLabelledBy,
358
207
  "data-gap": gap,
359
- children: [t10, t11]
208
+ "data-size": size,
209
+ "data-has-overflow": t7,
210
+ children: [t9, t14]
360
211
  });
361
- $[25] = ariaLabel;
362
- $[26] = ariaLabelledBy;
363
- $[27] = gap;
364
- $[28] = t10;
365
- $[29] = t11;
366
- $[30] = t12;
212
+ $[20] = ariaLabel;
213
+ $[21] = ariaLabelledBy;
214
+ $[22] = gap;
215
+ $[23] = size;
216
+ $[24] = t14;
217
+ $[25] = t7;
218
+ $[26] = t9;
219
+ $[27] = t15;
367
220
  } else {
368
- t12 = $[30];
221
+ t15 = $[27];
369
222
  }
370
- let t13;
371
- if ($[31] !== flush || $[32] !== t12 || $[33] !== t9) {
372
- t13 = /*#__PURE__*/jsx("div", {
223
+ let t16;
224
+ if ($[28] !== flush || $[29] !== t15 || $[30] !== t6) {
225
+ t16 = /*#__PURE__*/jsx("div", {
373
226
  ref: navRef,
374
- className: t9,
227
+ className: t6,
375
228
  "data-flush": flush,
376
- children: t12
229
+ children: t15
377
230
  });
378
- $[31] = flush;
379
- $[32] = t12;
380
- $[33] = t9;
381
- $[34] = t13;
231
+ $[28] = flush;
232
+ $[29] = t15;
233
+ $[30] = t6;
234
+ $[31] = t16;
382
235
  } else {
383
- t13 = $[34];
236
+ t16 = $[31];
384
237
  }
385
- let t14;
386
- if ($[35] !== t13 || $[36] !== t8) {
387
- t14 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
388
- value: t8,
389
- children: t13
238
+ let t17;
239
+ if ($[32] !== t16 || $[33] !== t5) {
240
+ t17 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
241
+ value: t5,
242
+ children: t16
390
243
  });
391
- $[35] = t13;
392
- $[36] = t8;
393
- $[37] = t14;
244
+ $[32] = t16;
245
+ $[33] = t5;
246
+ $[34] = t17;
394
247
  } else {
395
- t14 = $[37];
248
+ t17 = $[34];
396
249
  }
397
- return t14;
250
+ return t17;
398
251
  };
399
- function useWidth(ref) {
400
- const $ = c(3);
401
- const [width, setWidth] = useState(-1);
252
+ function useActionBarItem(ref, registryProps) {
253
+ var _useContext;
254
+ const $ = c(8);
255
+ const isGroupOverflowing = (_useContext = useContext(ActionBarGroupContext)) === null || _useContext === void 0 ? void 0 : _useContext.isOverflowing;
256
+ const isInGroup = isGroupOverflowing !== undefined;
402
257
  let t0;
258
+ if ($[0] !== isInGroup || $[1] !== ref) {
259
+ t0 = onChange => {
260
+ if (isInGroup) {
261
+ return _temp4;
262
+ }
263
+ const observer = new IntersectionObserver(() => onChange(), {
264
+ threshold: 1
265
+ });
266
+ if (ref.current) {
267
+ observer.observe(ref.current);
268
+ }
269
+ return () => observer.disconnect();
270
+ };
271
+ $[0] = isInGroup;
272
+ $[1] = ref;
273
+ $[2] = t0;
274
+ } else {
275
+ t0 = $[2];
276
+ }
277
+ const subscribeIntersectionObserver = t0;
403
278
  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);
279
+ if ($[3] !== ref) {
280
+ t1 = () => ref.current ? ref.current.offsetTop > 0 : false;
281
+ $[3] = ref;
282
+ $[4] = t1;
283
+ } else {
284
+ t1 = $[4];
285
+ }
286
+ const isItemOverflowing = useSyncExternalStore(subscribeIntersectionObserver, t1, _temp5);
287
+ const isOverflowing = isGroupOverflowing || isItemOverflowing;
288
+ ActionBarItemsRegistry.useRegisterDescendant(isOverflowing ? registryProps : null);
289
+ const t2 = isOverflowing ? "" : undefined;
290
+ let t3;
291
+ if ($[5] !== isOverflowing || $[6] !== t2) {
292
+ t3 = {
293
+ isOverflowing,
294
+ dataOverflowingAttr: t2
408
295
  };
409
- t1 = [ref];
410
- $[0] = ref;
411
- $[1] = t0;
412
- $[2] = t1;
296
+ $[5] = isOverflowing;
297
+ $[6] = t2;
298
+ $[7] = t3;
413
299
  } else {
414
- t0 = $[1];
415
- t1 = $[2];
300
+ t3 = $[7];
416
301
  }
417
- useIsomorphicLayoutEffect(t0, t1);
418
- return width;
302
+ return t3;
303
+ }
304
+ function _temp5() {
305
+ return false;
419
306
  }
307
+ function _temp4() {}
420
308
  const ActionBarIconButton = /*#__PURE__*/forwardRef(({
421
309
  disabled,
422
310
  onClick,
@@ -425,44 +313,36 @@ const ActionBarIconButton = /*#__PURE__*/forwardRef(({
425
313
  const ref = useRef(null);
426
314
  useRefObjectAsForwardedRef(forwardedRef, ref);
427
315
  const {
428
- size,
429
- isVisibleChild
316
+ size
430
317
  } = React.useContext(ActionBarContext);
431
- const {
432
- groupId
433
- } = React.useContext(ActionBarGroupContext);
434
- const width = useWidth(ref);
435
318
  const {
436
319
  ['aria-label']: ariaLabel,
437
320
  icon
438
321
  } = props;
439
- const registryProps = useMemo(() => ({
322
+ const {
323
+ dataOverflowingAttr
324
+ } = useActionBarItem(ref, useMemo(() => ({
440
325
  type: 'action',
441
326
  label: ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : '',
442
327
  icon,
443
328
  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);
329
+ onClick: onClick
330
+ }), [ariaLabel, icon, disabled, onClick]));
449
331
  const clickHandler = useCallback(event => {
450
332
  if (disabled) return;
451
333
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
452
334
  }, [disabled, onClick]);
453
- if (!isVisibleChild(id) || groupId && !isVisibleChild(groupId)) return null;
454
335
  return /*#__PURE__*/jsx(IconButton, {
455
336
  "aria-disabled": disabled,
456
337
  ref: ref,
457
338
  size: size,
458
339
  onClick: clickHandler,
459
340
  ...props,
460
- variant: "invisible"
341
+ variant: "invisible",
342
+ "data-overflowing": dataOverflowingAttr
461
343
  });
462
344
  });
463
- const ActionBarGroupContext = /*#__PURE__*/React.createContext({
464
- groupId: null
465
- });
345
+ const ActionBarGroupContext = /*#__PURE__*/React.createContext(null);
466
346
  const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
467
347
  const $ = c(10);
468
348
  const {
@@ -470,38 +350,39 @@ const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
470
350
  } = t0;
471
351
  const backupRef = useRef(null);
472
352
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
473
- const width = useWidth(ref);
474
353
  let t1;
475
- if ($[0] !== width) {
354
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
476
355
  t1 = {
477
- type: "group",
478
- width
356
+ type: "group"
479
357
  };
480
- $[0] = width;
481
- $[1] = t1;
358
+ $[0] = t1;
482
359
  } else {
483
- t1 = $[1];
360
+ t1 = $[0];
484
361
  }
485
- const registryProps = t1;
486
- const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
362
+ const {
363
+ dataOverflowingAttr,
364
+ isOverflowing
365
+ } = useActionBarItem(ref, t1);
487
366
  let t2;
488
- if ($[2] !== id) {
367
+ if ($[1] !== isOverflowing) {
489
368
  t2 = {
490
- groupId: id
369
+ isOverflowing
491
370
  };
492
- $[2] = id;
493
- $[3] = t2;
371
+ $[1] = isOverflowing;
372
+ $[2] = t2;
494
373
  } else {
495
- t2 = $[3];
374
+ t2 = $[2];
496
375
  }
497
376
  let t3;
498
- if ($[4] !== children || $[5] !== ref) {
377
+ if ($[3] !== children || $[4] !== dataOverflowingAttr || $[5] !== ref) {
499
378
  t3 = /*#__PURE__*/jsx("div", {
500
379
  className: styles.Group,
501
380
  ref: ref,
381
+ "data-overflowing": dataOverflowingAttr,
502
382
  children: children
503
383
  });
504
- $[4] = children;
384
+ $[3] = children;
385
+ $[4] = dataOverflowingAttr;
505
386
  $[5] = ref;
506
387
  $[6] = t3;
507
388
  } else {
@@ -555,17 +436,12 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
555
436
  }
556
437
  const backupRef = useRef(null);
557
438
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
558
- const {
559
- isVisibleChild
560
- } = React.useContext(ActionBarContext);
561
439
  const [menuOpen, setMenuOpen] = useState(false);
562
- const width = useWidth(ref);
563
440
  const t1 = overflowIcon ? overflowIcon : icon;
564
441
  let t2;
565
- if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1 || $[11] !== width) {
442
+ if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1) {
566
443
  t2 = {
567
444
  type: "menu",
568
- width,
569
445
  label: ariaLabel,
570
446
  icon: t1,
571
447
  returnFocusRef,
@@ -575,27 +451,26 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
575
451
  $[8] = items;
576
452
  $[9] = returnFocusRef;
577
453
  $[10] = t1;
578
- $[11] = width;
579
- $[12] = t2;
454
+ $[11] = t2;
580
455
  } else {
581
- t2 = $[12];
582
- }
583
- const registryProps = t2;
584
- const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
585
- if (!isVisibleChild(id)) {
586
- return null;
456
+ t2 = $[11];
587
457
  }
458
+ const {
459
+ dataOverflowingAttr
460
+ } = useActionBarItem(ref, t2);
588
461
  let t3;
589
- if ($[13] !== ariaLabel || $[14] !== icon || $[15] !== props) {
462
+ if ($[12] !== ariaLabel || $[13] !== dataOverflowingAttr || $[14] !== icon || $[15] !== props) {
590
463
  t3 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
591
464
  children: /*#__PURE__*/jsx(IconButton, {
592
465
  variant: "invisible",
593
466
  "aria-label": ariaLabel,
594
467
  icon: icon,
595
- ...props
468
+ ...props,
469
+ "data-overflowing": dataOverflowingAttr
596
470
  })
597
471
  });
598
- $[13] = ariaLabel;
472
+ $[12] = ariaLabel;
473
+ $[13] = dataOverflowingAttr;
599
474
  $[14] = icon;
600
475
  $[15] = props;
601
476
  $[16] = t3;
@@ -614,7 +489,7 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
614
489
  }
615
490
  let t5;
616
491
  if ($[19] !== items) {
617
- t5 = items.map(_temp4);
492
+ t5 = items.map(_temp6);
618
493
  $[19] = items;
619
494
  $[20] = t5;
620
495
  } else {
@@ -663,68 +538,88 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
663
538
  const VerticalDivider = () => {
664
539
  const $ = c(3);
665
540
  const ref = useRef(null);
666
- const {
667
- isVisibleChild
668
- } = React.useContext(ActionBarContext);
669
- const width = useWidth(ref);
670
541
  let t0;
671
- if ($[0] !== width) {
542
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
672
543
  t0 = {
673
- type: "divider",
674
- width
544
+ type: "divider"
675
545
  };
676
- $[0] = width;
677
- $[1] = t0;
546
+ $[0] = t0;
678
547
  } else {
679
- t0 = $[1];
680
- }
681
- const registryProps = t0;
682
- const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
683
- if (!isVisibleChild(id)) {
684
- return null;
548
+ t0 = $[0];
685
549
  }
550
+ const {
551
+ dataOverflowingAttr
552
+ } = useActionBarItem(ref, t0);
686
553
  let t1;
687
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
554
+ if ($[1] !== dataOverflowingAttr) {
688
555
  t1 = /*#__PURE__*/jsx("div", {
689
556
  ref: ref,
690
557
  "data-component": "ActionBar.VerticalDivider",
691
558
  "aria-hidden": "true",
692
- className: styles.Divider
559
+ className: styles.Divider,
560
+ "data-overflowing": dataOverflowingAttr
693
561
  });
562
+ $[1] = dataOverflowingAttr;
694
563
  $[2] = t1;
695
564
  } else {
696
565
  t1 = $[2];
697
566
  }
698
567
  return t1;
699
568
  };
700
- function _temp() {
701
- return new Set();
569
+ function _temp(entry) {
570
+ return entry[1] !== null;
702
571
  }
703
572
  function _temp2(item, index) {
704
573
  return renderMenuItem(item, index);
705
574
  }
706
575
  function _temp3(t0) {
707
- const [key_0, childProps_0] = t0;
708
- if (childProps_0.type === "action") {
576
+ const [id, menuItem] = t0;
577
+ if (menuItem.type === "divider") {
578
+ return /*#__PURE__*/jsx(ActionList.Divider, {}, id);
579
+ }
580
+ if (menuItem.type === "action") {
709
581
  const {
710
- onClick: onClick_0,
711
- icon: Icon_1,
712
- label: label_1,
713
- disabled: disabled_0
714
- } = childProps_0;
582
+ onClick,
583
+ icon: Icon,
584
+ label,
585
+ disabled
586
+ } = menuItem;
715
587
  return /*#__PURE__*/jsxs(ActionList.Item, {
716
- onSelect: event_0 => {
717
- typeof onClick_0 === "function" && onClick_0(event_0);
588
+ onSelect: event => {
589
+ typeof onClick === "function" && onClick(event);
718
590
  },
719
- disabled: disabled_0,
591
+ disabled: disabled,
720
592
  children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
721
- children: /*#__PURE__*/jsx(Icon_1, {})
722
- }), label_1]
723
- }, key_0);
593
+ children: /*#__PURE__*/jsx(Icon, {})
594
+ }), label]
595
+ }, label);
596
+ }
597
+ if (menuItem.type === "menu") {
598
+ const menuItems = menuItem.items;
599
+ const {
600
+ icon: Icon_0,
601
+ label: label_0,
602
+ returnFocusRef
603
+ } = menuItem;
604
+ return /*#__PURE__*/jsxs(ActionMenu, {
605
+ children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
606
+ children: /*#__PURE__*/jsxs(ActionList.Item, {
607
+ children: [Icon_0 !== "none" ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
608
+ children: /*#__PURE__*/jsx(Icon_0, {})
609
+ }) : null, label_0]
610
+ })
611
+ }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
612
+ ...(returnFocusRef && {
613
+ returnFocusRef
614
+ }),
615
+ children: /*#__PURE__*/jsx(ActionList, {
616
+ children: menuItems.map(_temp2)
617
+ })
618
+ })]
619
+ }, id);
724
620
  }
725
- return null;
726
621
  }
727
- function _temp4(item, index) {
622
+ function _temp6(item, index) {
728
623
  return renderMenuItem(item, index);
729
624
  }
730
625