@primer/react 0.0.0-20260508164446 → 0.0.0-20260508174823

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