@primer/react 0.0.0-20260402135204 → 0.0.0-20260402145624

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 (164) hide show
  1. package/CHANGELOG.md +2 -88
  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 +2 -2
  5. package/dist/ActionBar/ActionBar.d.ts.map +1 -1
  6. package/dist/ActionBar/ActionBar.js +290 -367
  7. package/dist/ActionBar/ActionBar.module.css.js +2 -2
  8. package/dist/ActionBar/index.d.ts +2 -2
  9. package/dist/ActionList/Heading.js +16 -17
  10. package/dist/ActionList/Item.d.ts.map +1 -1
  11. package/dist/ActionList/Item.js +192 -626
  12. package/dist/ActionList/LinkItem.d.ts +3 -6
  13. package/dist/ActionList/LinkItem.d.ts.map +1 -1
  14. package/dist/ActionList/LinkItem.js +87 -42
  15. package/dist/ActionList/List.d.ts.map +1 -1
  16. package/dist/ActionList/List.js +40 -41
  17. package/dist/ActionList/index.d.ts +1 -25
  18. package/dist/ActionList/index.d.ts.map +1 -1
  19. package/dist/ActionMenu/{ActionMenu-58362ca7.css → ActionMenu-53493541.css} +2 -2
  20. package/dist/ActionMenu/ActionMenu-53493541.css.map +1 -0
  21. package/dist/ActionMenu/ActionMenu.d.ts.map +1 -1
  22. package/dist/ActionMenu/ActionMenu.js +3 -14
  23. package/dist/ActionMenu/ActionMenu.module.css.js +1 -1
  24. package/dist/AnchoredOverlay/AnchoredOverlay-73c1b2d1.css +2 -0
  25. package/dist/AnchoredOverlay/AnchoredOverlay-73c1b2d1.css.map +1 -0
  26. package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
  27. package/dist/AnchoredOverlay/AnchoredOverlay.js +23 -86
  28. package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +2 -2
  29. package/dist/Autocomplete/AutocompleteInput.js +3 -3
  30. package/dist/Autocomplete/AutocompleteOverlay.js +3 -3
  31. package/dist/Banner/{Banner-41040ab7.css → Banner-b3871000.css} +2 -2
  32. package/dist/Banner/{Banner-41040ab7.css.map → Banner-b3871000.css.map} +1 -1
  33. package/dist/Banner/Banner.d.ts.map +1 -1
  34. package/dist/Banner/Banner.js +1 -2
  35. package/dist/Banner/Banner.module.css.js +1 -1
  36. package/dist/Breadcrumbs/Breadcrumbs.d.ts +8 -23
  37. package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  38. package/dist/Breadcrumbs/Breadcrumbs.js +66 -27
  39. package/dist/Button/{ButtonBase-4da3fa22.css → ButtonBase-781fba8b.css} +2 -2
  40. package/dist/Button/ButtonBase-781fba8b.css.map +1 -0
  41. package/dist/Button/ButtonBase.d.ts.map +1 -1
  42. package/dist/Button/ButtonBase.js +5 -4
  43. package/dist/Button/ButtonBase.module.css.js +2 -2
  44. package/dist/Button/types.d.ts +1 -1
  45. package/dist/Button/types.d.ts.map +1 -1
  46. package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
  47. package/dist/ButtonGroup/ButtonGroup.js +23 -23
  48. package/dist/Checkbox/Checkbox.d.ts.map +1 -1
  49. package/dist/Checkbox/Checkbox.js +5 -5
  50. package/dist/Details/Details.js +1 -1
  51. package/dist/Dialog/{Dialog-b577691f.css → Dialog-2d417a89.css} +2 -2
  52. package/dist/Dialog/Dialog-2d417a89.css.map +1 -0
  53. package/dist/Dialog/Dialog.d.ts.map +1 -1
  54. package/dist/Dialog/Dialog.js +10 -38
  55. package/dist/Dialog/Dialog.module.css.js +2 -2
  56. package/dist/FeatureFlags/DefaultFeatureFlags.d.ts.map +1 -1
  57. package/dist/FeatureFlags/DefaultFeatureFlags.js +1 -2
  58. package/dist/FilteredActionList/FilteredActionList-02db90c6.css +2 -0
  59. package/dist/FilteredActionList/FilteredActionList-02db90c6.css.map +1 -0
  60. package/dist/FilteredActionList/FilteredActionList.d.ts.map +1 -1
  61. package/dist/FilteredActionList/FilteredActionList.js +8 -8
  62. package/dist/FilteredActionList/FilteredActionList.module.css.js +1 -1
  63. package/dist/Heading/Heading.js +3 -3
  64. package/dist/Link/{Link-ba423096.css → Link-968346ff.css} +2 -2
  65. package/dist/Link/Link-968346ff.css.map +1 -0
  66. package/dist/Link/Link.d.ts.map +1 -1
  67. package/dist/Link/Link.js +5 -5
  68. package/dist/Link/Link.module.css.js +1 -1
  69. package/dist/NavList/NavList.d.ts +3 -20
  70. package/dist/NavList/NavList.d.ts.map +1 -1
  71. package/dist/NavList/NavList.js +124 -50
  72. package/dist/Overlay/Overlay-15519c09.css +2 -0
  73. package/dist/Overlay/Overlay-15519c09.css.map +1 -0
  74. package/dist/Overlay/Overlay.d.ts +0 -1
  75. package/dist/Overlay/Overlay.d.ts.map +1 -1
  76. package/dist/Overlay/Overlay.js +82 -106
  77. package/dist/Overlay/Overlay.module.css.js +1 -1
  78. package/dist/PageHeader/PageHeader.d.ts.map +1 -1
  79. package/dist/PageHeader/PageHeader.js +31 -30
  80. package/dist/PageLayout/PageLayout.d.ts +20 -4
  81. package/dist/PageLayout/PageLayout.d.ts.map +1 -1
  82. package/dist/PageLayout/PageLayout.js +5 -17
  83. package/dist/SelectPanel/SelectPanel.d.ts +2 -2
  84. package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
  85. package/dist/SelectPanel/SelectPanel.js +29 -32
  86. package/dist/Stack/Stack-9e7b935d.css +2 -0
  87. package/dist/Stack/Stack-9e7b935d.css.map +1 -0
  88. package/dist/Stack/Stack.d.ts +2 -12
  89. package/dist/Stack/Stack.d.ts.map +1 -1
  90. package/dist/Stack/Stack.js +61 -89
  91. package/dist/Stack/Stack.module.css.js +1 -1
  92. package/dist/StateLabel/{StateLabel-cd51ae39.css → StateLabel-056eec66.css} +2 -2
  93. package/dist/StateLabel/StateLabel-056eec66.css.map +1 -0
  94. package/dist/StateLabel/StateLabel.d.ts +0 -1
  95. package/dist/StateLabel/StateLabel.d.ts.map +1 -1
  96. package/dist/StateLabel/StateLabel.js +2 -4
  97. package/dist/StateLabel/StateLabel.module.css.js +1 -1
  98. package/dist/TextInput/TextInput.d.ts.map +1 -1
  99. package/dist/TextInput/TextInput.js +11 -36
  100. package/dist/TextInputWithTokens/TextInputWithTokens.js +90 -91
  101. package/dist/ThemeProvider.d.ts.map +1 -1
  102. package/dist/ThemeProvider.js +104 -163
  103. package/dist/Timeline/Timeline-19bef8c5.css +2 -0
  104. package/dist/Timeline/Timeline-19bef8c5.css.map +1 -0
  105. package/dist/Timeline/Timeline.d.ts +1 -1
  106. package/dist/Timeline/Timeline.d.ts.map +1 -1
  107. package/dist/Timeline/Timeline.js +14 -27
  108. package/dist/Timeline/Timeline.module.css.js +1 -1
  109. package/dist/TooltipV2/{Tooltip-dd983e5b.css → Tooltip-fcb90d9c.css} +2 -2
  110. package/dist/TooltipV2/Tooltip-fcb90d9c.css.map +1 -0
  111. package/dist/TooltipV2/Tooltip.d.ts +1 -1
  112. package/dist/TooltipV2/Tooltip.d.ts.map +1 -1
  113. package/dist/TooltipV2/Tooltip.js +15 -21
  114. package/dist/TooltipV2/Tooltip.module.css.js +2 -2
  115. package/dist/TreeView/TreeView.d.ts.map +1 -1
  116. package/dist/TreeView/TreeView.js +59 -101
  117. package/dist/deprecated/DialogV1/Dialog.js +9 -10
  118. package/dist/experimental/Tabs/Tabs.d.ts +1 -1
  119. package/dist/experimental/Tabs/Tabs.d.ts.map +1 -1
  120. package/dist/experimental/Tabs/Tabs.js +16 -16
  121. package/dist/hooks/index.d.ts +0 -1
  122. package/dist/hooks/index.d.ts.map +1 -1
  123. package/dist/hooks/useAnchoredPosition.d.ts.map +1 -1
  124. package/dist/hooks/useAnchoredPosition.js +0 -47
  125. package/dist/hooks/useProvidedRefOrCreate.d.ts +0 -9
  126. package/dist/hooks/useProvidedRefOrCreate.d.ts.map +1 -1
  127. package/dist/hooks/useProvidedRefOrCreate.js +0 -12
  128. package/dist/hooks/useRefObjectAsForwardedRef.d.ts +0 -12
  129. package/dist/hooks/useRefObjectAsForwardedRef.d.ts.map +1 -1
  130. package/dist/hooks/useRefObjectAsForwardedRef.js +0 -12
  131. package/dist/index.d.ts +0 -1
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.js +0 -1
  134. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.d.ts.map +1 -1
  135. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.js +8 -17
  136. package/dist/internal/hooks/useMergedRefs.d.ts +2 -0
  137. package/dist/internal/hooks/useMergedRefs.d.ts.map +1 -0
  138. package/dist/internal/hooks/useMergedRefs.js +16 -0
  139. package/dist/utils/character-counter.d.ts.map +1 -1
  140. package/dist/utils/character-counter.js +0 -1
  141. package/generated/components.json +9 -49
  142. package/generated/hooks.json +0 -22
  143. package/package.json +7 -9
  144. package/dist/ActionBar/ActionBar-a41224b2.css +0 -2
  145. package/dist/ActionBar/ActionBar-a41224b2.css.map +0 -1
  146. package/dist/ActionMenu/ActionMenu-58362ca7.css.map +0 -1
  147. package/dist/AnchoredOverlay/AnchoredOverlay-647c7065.css +0 -2
  148. package/dist/AnchoredOverlay/AnchoredOverlay-647c7065.css.map +0 -1
  149. package/dist/Button/ButtonBase-4da3fa22.css.map +0 -1
  150. package/dist/Dialog/Dialog-b577691f.css.map +0 -1
  151. package/dist/FilteredActionList/FilteredActionList-6808e67a.css +0 -2
  152. package/dist/FilteredActionList/FilteredActionList-6808e67a.css.map +0 -1
  153. package/dist/Link/Link-ba423096.css.map +0 -1
  154. package/dist/Overlay/Overlay-f81a131d.css +0 -2
  155. package/dist/Overlay/Overlay-f81a131d.css.map +0 -1
  156. package/dist/Stack/Stack-58c33984.css +0 -2
  157. package/dist/Stack/Stack-58c33984.css.map +0 -1
  158. package/dist/StateLabel/StateLabel-cd51ae39.css.map +0 -1
  159. package/dist/Timeline/Timeline-4d67684a.css +0 -2
  160. package/dist/Timeline/Timeline-4d67684a.css.map +0 -1
  161. package/dist/TooltipV2/Tooltip-dd983e5b.css.map +0 -1
  162. package/dist/hooks/useMergedRefs.d.ts +0 -51
  163. package/dist/hooks/useMergedRefs.d.ts.map +0 -1
  164. package/dist/hooks/useMergedRefs.js +0 -92
@@ -1,29 +1,19 @@
1
1
  import { c } from 'react-compiler-runtime';
2
- import React, { useRef, useState, forwardRef, useMemo, useCallback } from 'react';
2
+ import React, { useRef, forwardRef, useState, useMemo, useCallback, useContext, useSyncExternalStore } from 'react';
3
3
  import { KebabHorizontalIcon } from '@primer/octicons-react';
4
4
  import { ActionList } from '../ActionList/index.js';
5
- import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
6
- import { useResizeObserver } from '../hooks/useResizeObserver.js';
7
5
  import { IconButton } from '../Button/IconButton.js';
8
6
  import { useFocusZone } from '../hooks/useFocusZone.js';
9
7
  import styles from './ActionBar.module.css.js';
10
8
  import { clsx } from 'clsx';
11
9
  import { createDescendantRegistry } from '../utils/descendant-registry.js';
12
- import { jsxs, jsx } from 'react/jsx-runtime';
13
- import { useMergedRefs } from '../hooks/useMergedRefs.js';
10
+ import { jsx, jsxs } from 'react/jsx-runtime';
11
+ import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js';
14
12
  import { FocusKeys } from '@primer/behaviors';
15
13
  import { ActionMenu } from '../ActionMenu/ActionMenu.js';
16
14
 
17
- const ACTIONBAR_ITEM_GAP = 8;
18
-
19
- /**
20
- * Registry of descendants to render in the list or menu. To preserve insertion order across updates, children are
21
- * set to `null` when unregistered rather than fully dropped from the map.
22
- */
23
-
24
15
  const ActionBarContext = /*#__PURE__*/React.createContext({
25
16
  size: 'medium',
26
- isVisibleChild: () => true,
27
17
  groupId: undefined
28
18
  });
29
19
 
@@ -31,23 +21,7 @@ const ActionBarContext = /*#__PURE__*/React.createContext({
31
21
  small (28px), medium (32px), large (40px)
32
22
  */
33
23
 
34
- const MORE_BTN_WIDTH = 32;
35
24
  const ActionBarItemsRegistry = createDescendantRegistry();
36
- const calculatePossibleItems = (registryEntries, navWidth, gap, moreMenuWidth = 0) => {
37
- const widthToFit = navWidth - moreMenuWidth;
38
- let breakpoint = registryEntries.length; // assume all items will fit
39
- let sumsOfChildWidth = 0;
40
- for (const [index, [, child]] of registryEntries.entries()) {
41
- sumsOfChildWidth += index > 0 ? child.width + gap : child.width;
42
- if (sumsOfChildWidth > widthToFit) {
43
- breakpoint = index;
44
- break;
45
- } else {
46
- continue;
47
- }
48
- }
49
- return breakpoint;
50
- };
51
25
  const renderMenuItem = (item, index) => {
52
26
  if (item.type === 'divider') {
53
27
  return /*#__PURE__*/jsx(ActionList.Divider, {}, index);
@@ -96,44 +70,8 @@ const renderMenuItem = (item, index) => {
96
70
  }, label);
97
71
  };
98
72
  renderMenuItem.displayName = "renderMenuItem";
99
- const getMenuItems = (navWidth, moreMenuWidth, childRegistry, hasActiveMenu, gap) => {
100
- var _childRegistry$entrie;
101
- const registryEntries = Array.from((_childRegistry$entrie = childRegistry === null || childRegistry === void 0 ? void 0 : childRegistry.entries()) !== null && _childRegistry$entrie !== void 0 ? _childRegistry$entrie : []).filter(entry => entry[1] !== null && (entry[1].type !== 'action' || entry[1].groupId === undefined));
102
- if (registryEntries.length === 0) return new Set();
103
- const numberOfItemsPossible = calculatePossibleItems(registryEntries, navWidth, gap);
104
- const numberOfItemsPossibleWithMoreMenu = calculatePossibleItems(registryEntries, navWidth, gap, moreMenuWidth || MORE_BTN_WIDTH);
105
- const menuItems = new Set();
106
-
107
- // First, we check if we can fit all the items with their icons
108
- if (registryEntries.length >= numberOfItemsPossible) {
109
- /* Below is an accessibility requirement. Never show only one item in the overflow menu.
110
- * If there is only one item left to display in the overflow menu according to the calculation,
111
- * we need to pull another item from the list into the overflow menu.
112
- */
113
- const numberOfItemsInMenu = registryEntries.length - numberOfItemsPossibleWithMoreMenu;
114
- const numberOfListItems = numberOfItemsInMenu === 1 ? numberOfItemsPossibleWithMoreMenu - 1 : numberOfItemsPossibleWithMoreMenu;
115
- for (const [index, [id, child]] of registryEntries.entries()) {
116
- if (index < numberOfListItems) {
117
- continue;
118
- //if the last item is a divider
119
- } else if (child.type === 'divider') {
120
- if (index === numberOfListItems - 1 || index === numberOfListItems) {
121
- continue;
122
- } else {
123
- menuItems.add(id);
124
- }
125
- } else {
126
- menuItems.add(id);
127
- }
128
- }
129
- return menuItems;
130
- } else if (numberOfItemsPossible > registryEntries.length && hasActiveMenu) {
131
- /* If the items fit in the list and there are items in the overflow menu, we need to move them back to the list */
132
- return new Set();
133
- }
134
- };
135
73
  const ActionBar = props => {
136
- const $ = c(38);
74
+ const $ = c(35);
137
75
  const {
138
76
  size: t0,
139
77
  children,
@@ -147,322 +85,289 @@ 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("button, a, input, [tabindex]")) !== null && _listRef$current$quer !== void 0 ? _listRef$current$quer : []).filter(_temp);
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(_temp2);
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`;
178
+ let t11;
179
+ if ($[11] !== t10) {
180
+ t11 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
181
+ children: /*#__PURE__*/jsx(IconButton, {
182
+ variant: "invisible",
183
+ "aria-label": t10,
184
+ icon: KebabHorizontalIcon,
185
+ className: styles.MoreButton
186
+ })
187
+ });
188
+ $[11] = t10;
189
+ $[12] = t11;
248
190
  } else {
249
- t8 = $[14];
191
+ t11 = $[12];
250
192
  }
251
- let t9;
252
- if ($[15] !== className) {
253
- t9 = clsx(className, styles.Nav);
254
- $[15] = className;
255
- $[16] = t9;
193
+ let t12;
194
+ if ($[13] !== overflowItems) {
195
+ t12 = overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.map(_temp4);
196
+ $[13] = overflowItems;
197
+ $[14] = t12;
256
198
  } else {
257
- t9 = $[16];
199
+ t12 = $[14];
258
200
  }
259
- let t10;
260
- if ($[17] !== children || $[18] !== setChildRegistry) {
261
- t10 = /*#__PURE__*/jsx(ActionBarItemsRegistry.Provider, {
262
- setRegistry: setChildRegistry,
263
- children: children
201
+ let t13;
202
+ if ($[15] !== t12) {
203
+ t13 = /*#__PURE__*/jsx(ActionMenu.Overlay, {
204
+ children: /*#__PURE__*/jsx(ActionList, {
205
+ children: t12
206
+ })
264
207
  });
265
- $[17] = children;
266
- $[18] = setChildRegistry;
267
- $[19] = t10;
208
+ $[15] = t12;
209
+ $[16] = t13;
268
210
  } else {
269
- t10 = $[19];
211
+ t13 = $[16];
270
212
  }
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
- })]
213
+ let t14;
214
+ if ($[17] !== t11 || $[18] !== t13) {
215
+ t14 = /*#__PURE__*/jsxs(ActionMenu, {
216
+ children: [t11, t13]
341
217
  });
342
- $[20] = ariaLabel;
343
- $[21] = childRegistry;
344
- $[22] = groupedItems;
345
- $[23] = menuItemIds;
346
- $[24] = t11;
218
+ $[17] = t11;
219
+ $[18] = t13;
220
+ $[19] = t14;
347
221
  } else {
348
- t11 = $[24];
222
+ t14 = $[19];
349
223
  }
350
- let t12;
351
- if ($[25] !== ariaLabel || $[26] !== ariaLabelledBy || $[27] !== gap || $[28] !== t10 || $[29] !== t11) {
352
- t12 = /*#__PURE__*/jsxs("div", {
224
+ let t15;
225
+ if ($[20] !== ariaLabel || $[21] !== ariaLabelledBy || $[22] !== gap || $[23] !== size || $[24] !== t14 || $[25] !== t7 || $[26] !== t9) {
226
+ t15 = /*#__PURE__*/jsxs("div", {
353
227
  ref: listRef,
354
228
  role: "toolbar",
355
229
  className: styles.List,
356
230
  "aria-label": ariaLabel,
357
231
  "aria-labelledby": ariaLabelledBy,
358
232
  "data-gap": gap,
359
- children: [t10, t11]
233
+ "data-size": size,
234
+ "data-has-overflow": t7,
235
+ children: [t9, t14]
360
236
  });
361
- $[25] = ariaLabel;
362
- $[26] = ariaLabelledBy;
363
- $[27] = gap;
364
- $[28] = t10;
365
- $[29] = t11;
366
- $[30] = t12;
237
+ $[20] = ariaLabel;
238
+ $[21] = ariaLabelledBy;
239
+ $[22] = gap;
240
+ $[23] = size;
241
+ $[24] = t14;
242
+ $[25] = t7;
243
+ $[26] = t9;
244
+ $[27] = t15;
367
245
  } else {
368
- t12 = $[30];
246
+ t15 = $[27];
369
247
  }
370
- let t13;
371
- if ($[31] !== flush || $[32] !== t12 || $[33] !== t9) {
372
- t13 = /*#__PURE__*/jsx("div", {
248
+ let t16;
249
+ if ($[28] !== flush || $[29] !== t15 || $[30] !== t6) {
250
+ t16 = /*#__PURE__*/jsx("div", {
373
251
  ref: navRef,
374
- className: t9,
252
+ className: t6,
375
253
  "data-flush": flush,
376
- children: t12
254
+ children: t15
377
255
  });
378
- $[31] = flush;
379
- $[32] = t12;
380
- $[33] = t9;
381
- $[34] = t13;
256
+ $[28] = flush;
257
+ $[29] = t15;
258
+ $[30] = t6;
259
+ $[31] = t16;
382
260
  } else {
383
- t13 = $[34];
261
+ t16 = $[31];
384
262
  }
385
- let t14;
386
- if ($[35] !== t13 || $[36] !== t8) {
387
- t14 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
388
- value: t8,
389
- children: t13
263
+ let t17;
264
+ if ($[32] !== t16 || $[33] !== t5) {
265
+ t17 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
266
+ value: t5,
267
+ children: t16
390
268
  });
391
- $[35] = t13;
392
- $[36] = t8;
393
- $[37] = t14;
269
+ $[32] = t16;
270
+ $[33] = t5;
271
+ $[34] = t17;
394
272
  } else {
395
- t14 = $[37];
273
+ t17 = $[34];
396
274
  }
397
- return t14;
275
+ return t17;
398
276
  };
399
- function useWidth(ref) {
400
- const $ = c(3);
401
- const [width, setWidth] = useState(-1);
277
+ function useActionBarItem(ref, registryProps) {
278
+ var _useContext;
279
+ const $ = c(8);
280
+ const isGroupOverflowing = (_useContext = useContext(ActionBarGroupContext)) === null || _useContext === void 0 ? void 0 : _useContext.isOverflowing;
281
+ const isInGroup = isGroupOverflowing !== undefined;
402
282
  let t0;
283
+ if ($[0] !== isInGroup || $[1] !== ref) {
284
+ t0 = onChange => {
285
+ if (isInGroup) {
286
+ return _temp5;
287
+ }
288
+ const observer = new IntersectionObserver(() => onChange(), {
289
+ threshold: 1
290
+ });
291
+ if (ref.current) {
292
+ observer.observe(ref.current);
293
+ }
294
+ return () => observer.disconnect();
295
+ };
296
+ $[0] = isInGroup;
297
+ $[1] = ref;
298
+ $[2] = t0;
299
+ } else {
300
+ t0 = $[2];
301
+ }
302
+ const subscribeIntersectionObserver = t0;
403
303
  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);
304
+ if ($[3] !== ref) {
305
+ t1 = () => ref.current ? ref.current.offsetTop > 0 : false;
306
+ $[3] = ref;
307
+ $[4] = t1;
308
+ } else {
309
+ t1 = $[4];
310
+ }
311
+ const isItemOverflowing = useSyncExternalStore(subscribeIntersectionObserver, t1, _temp6);
312
+ const isOverflowing = isGroupOverflowing || isItemOverflowing;
313
+ ActionBarItemsRegistry.useRegisterDescendant(isOverflowing ? registryProps : null);
314
+ const t2 = isOverflowing ? "" : undefined;
315
+ let t3;
316
+ if ($[5] !== isOverflowing || $[6] !== t2) {
317
+ t3 = {
318
+ isOverflowing,
319
+ dataOverflowingAttr: t2
408
320
  };
409
- t1 = [ref];
410
- $[0] = ref;
411
- $[1] = t0;
412
- $[2] = t1;
321
+ $[5] = isOverflowing;
322
+ $[6] = t2;
323
+ $[7] = t3;
413
324
  } else {
414
- t0 = $[1];
415
- t1 = $[2];
325
+ t3 = $[7];
416
326
  }
417
- useIsomorphicLayoutEffect(t0, t1);
418
- return width;
327
+ return t3;
419
328
  }
329
+ function _temp6() {
330
+ return false;
331
+ }
332
+ function _temp5() {}
420
333
  const ActionBarIconButton = /*#__PURE__*/forwardRef(({
421
334
  disabled,
422
335
  onClick,
423
336
  ...props
424
337
  }, forwardedRef) => {
425
338
  const ref = useRef(null);
426
- const mergedRef = useMergedRefs(ref, forwardedRef);
339
+ useRefObjectAsForwardedRef(forwardedRef, ref);
427
340
  const {
428
- size,
429
- isVisibleChild
341
+ size
430
342
  } = React.useContext(ActionBarContext);
431
- const {
432
- groupId
433
- } = React.useContext(ActionBarGroupContext);
434
- const width = useWidth(ref);
435
343
  const {
436
344
  ['aria-label']: ariaLabel,
437
345
  icon
438
346
  } = props;
439
- const registryProps = useMemo(() => ({
347
+ const {
348
+ dataOverflowingAttr
349
+ } = useActionBarItem(ref, useMemo(() => ({
440
350
  type: 'action',
441
351
  label: ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : '',
442
352
  icon,
443
353
  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);
354
+ onClick: onClick
355
+ }), [ariaLabel, icon, disabled, onClick]));
449
356
  const clickHandler = useCallback(event => {
450
357
  if (disabled) return;
451
358
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
452
359
  }, [disabled, onClick]);
453
- if (!isVisibleChild(id) || groupId && !isVisibleChild(groupId)) return null;
454
360
  return /*#__PURE__*/jsx(IconButton, {
455
361
  "aria-disabled": disabled,
456
- ref: mergedRef,
362
+ ref: ref,
457
363
  size: size,
458
364
  onClick: clickHandler,
459
365
  ...props,
460
- variant: "invisible"
366
+ variant: "invisible",
367
+ "data-overflowing": dataOverflowingAttr
461
368
  });
462
369
  });
463
- const ActionBarGroupContext = /*#__PURE__*/React.createContext({
464
- groupId: null
465
- });
370
+ const ActionBarGroupContext = /*#__PURE__*/React.createContext(null);
466
371
  const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
467
372
  const $ = c(10);
468
373
  const {
@@ -470,38 +375,39 @@ const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
470
375
  } = t0;
471
376
  const backupRef = useRef(null);
472
377
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
473
- const width = useWidth(ref);
474
378
  let t1;
475
- if ($[0] !== width) {
379
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
476
380
  t1 = {
477
- type: "group",
478
- width
381
+ type: "group"
479
382
  };
480
- $[0] = width;
481
- $[1] = t1;
383
+ $[0] = t1;
482
384
  } else {
483
- t1 = $[1];
385
+ t1 = $[0];
484
386
  }
485
- const registryProps = t1;
486
- const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
387
+ const {
388
+ dataOverflowingAttr,
389
+ isOverflowing
390
+ } = useActionBarItem(ref, t1);
487
391
  let t2;
488
- if ($[2] !== id) {
392
+ if ($[1] !== isOverflowing) {
489
393
  t2 = {
490
- groupId: id
394
+ isOverflowing
491
395
  };
492
- $[2] = id;
493
- $[3] = t2;
396
+ $[1] = isOverflowing;
397
+ $[2] = t2;
494
398
  } else {
495
- t2 = $[3];
399
+ t2 = $[2];
496
400
  }
497
401
  let t3;
498
- if ($[4] !== children || $[5] !== ref) {
402
+ if ($[3] !== children || $[4] !== dataOverflowingAttr || $[5] !== ref) {
499
403
  t3 = /*#__PURE__*/jsx("div", {
500
404
  className: styles.Group,
501
405
  ref: ref,
406
+ "data-overflowing": dataOverflowingAttr,
502
407
  children: children
503
408
  });
504
- $[4] = children;
409
+ $[3] = children;
410
+ $[4] = dataOverflowingAttr;
505
411
  $[5] = ref;
506
412
  $[6] = t3;
507
413
  } else {
@@ -555,17 +461,12 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
555
461
  }
556
462
  const backupRef = useRef(null);
557
463
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
558
- const {
559
- isVisibleChild
560
- } = React.useContext(ActionBarContext);
561
464
  const [menuOpen, setMenuOpen] = useState(false);
562
- const width = useWidth(ref);
563
465
  const t1 = overflowIcon ? overflowIcon : icon;
564
466
  let t2;
565
- if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1 || $[11] !== width) {
467
+ if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1) {
566
468
  t2 = {
567
469
  type: "menu",
568
- width,
569
470
  label: ariaLabel,
570
471
  icon: t1,
571
472
  returnFocusRef,
@@ -575,27 +476,26 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
575
476
  $[8] = items;
576
477
  $[9] = returnFocusRef;
577
478
  $[10] = t1;
578
- $[11] = width;
579
- $[12] = t2;
479
+ $[11] = t2;
580
480
  } else {
581
- t2 = $[12];
582
- }
583
- const registryProps = t2;
584
- const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
585
- if (!isVisibleChild(id)) {
586
- return null;
481
+ t2 = $[11];
587
482
  }
483
+ const {
484
+ dataOverflowingAttr
485
+ } = useActionBarItem(ref, t2);
588
486
  let t3;
589
- if ($[13] !== ariaLabel || $[14] !== icon || $[15] !== props) {
487
+ if ($[12] !== ariaLabel || $[13] !== dataOverflowingAttr || $[14] !== icon || $[15] !== props) {
590
488
  t3 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
591
489
  children: /*#__PURE__*/jsx(IconButton, {
592
490
  variant: "invisible",
593
491
  "aria-label": ariaLabel,
594
492
  icon: icon,
595
- ...props
493
+ ...props,
494
+ "data-overflowing": dataOverflowingAttr
596
495
  })
597
496
  });
598
- $[13] = ariaLabel;
497
+ $[12] = ariaLabel;
498
+ $[13] = dataOverflowingAttr;
599
499
  $[14] = icon;
600
500
  $[15] = props;
601
501
  $[16] = t3;
@@ -614,7 +514,7 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
614
514
  }
615
515
  let t5;
616
516
  if ($[19] !== items) {
617
- t5 = items.map(_temp4);
517
+ t5 = items.map(_temp7);
618
518
  $[19] = items;
619
519
  $[20] = t5;
620
520
  } else {
@@ -663,68 +563,91 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
663
563
  const VerticalDivider = () => {
664
564
  const $ = c(3);
665
565
  const ref = useRef(null);
666
- const {
667
- isVisibleChild
668
- } = React.useContext(ActionBarContext);
669
- const width = useWidth(ref);
670
566
  let t0;
671
- if ($[0] !== width) {
567
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
672
568
  t0 = {
673
- type: "divider",
674
- width
569
+ type: "divider"
675
570
  };
676
- $[0] = width;
677
- $[1] = t0;
571
+ $[0] = t0;
678
572
  } else {
679
- t0 = $[1];
680
- }
681
- const registryProps = t0;
682
- const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
683
- if (!isVisibleChild(id)) {
684
- return null;
573
+ t0 = $[0];
685
574
  }
575
+ const {
576
+ dataOverflowingAttr
577
+ } = useActionBarItem(ref, t0);
686
578
  let t1;
687
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
579
+ if ($[1] !== dataOverflowingAttr) {
688
580
  t1 = /*#__PURE__*/jsx("div", {
689
581
  ref: ref,
690
582
  "data-component": "ActionBar.VerticalDivider",
691
583
  "aria-hidden": "true",
692
- className: styles.Divider
584
+ className: styles.Divider,
585
+ "data-overflowing": dataOverflowingAttr
693
586
  });
587
+ $[1] = dataOverflowingAttr;
694
588
  $[2] = t1;
695
589
  } else {
696
590
  t1 = $[2];
697
591
  }
698
592
  return t1;
699
593
  };
700
- function _temp() {
701
- return new Set();
594
+ function _temp(item) {
595
+ return !item.hasAttribute("data-overflowing") && !item.hasAttribute("disabled");
702
596
  }
703
- function _temp2(item, index) {
704
- return renderMenuItem(item, index);
597
+ function _temp2(entry) {
598
+ return entry[1] !== null;
599
+ }
600
+ function _temp3(item_0, index) {
601
+ return renderMenuItem(item_0, index);
705
602
  }
706
- function _temp3(t0) {
707
- const [key_0, childProps_0] = t0;
708
- if (childProps_0.type === "action") {
603
+ function _temp4(t0) {
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(_temp3)
645
+ })
646
+ })]
647
+ }, id);
724
648
  }
725
- return null;
726
649
  }
727
- function _temp4(item, index) {
650
+ function _temp7(item, index) {
728
651
  return renderMenuItem(item, index);
729
652
  }
730
653