@primer/react 0.0.0-20260402152027 → 0.0.0-20260402165401

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