@primer/react 0.0.0-20260313155735 → 0.0.0-20260313165442

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