@primer/react 0.0.0-20260403172558 → 0.0.0-20260403174426

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.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260403172558
3
+ ## 0.0.0-20260403174426
4
4
 
5
- ### Minor Changes
5
+ ### Patch Changes
6
+
7
+ - Fake entry to force publishing
6
8
 
7
- - [#7655](https://github.com/primer/react/pull/7655) [`8f1f205`](https://github.com/primer/react/commit/8f1f205a637939eb167095b4ac766cf6524ac558) Thanks [@iansan5653](https://github.com/iansan5653)! - Replace `ActionBar` overflow calculations with CSS wrapping approach to improve performance and stability
9
+ ## 38.19.0
10
+
11
+ ### Minor Changes
8
12
 
9
13
  - [#7677](https://github.com/primer/react/pull/7677) [`c1a81b1`](https://github.com/primer/react/commit/c1a81b178742ba547b85a3df3ed3c27bcff6b7c5) Thanks [@TylerJDev](https://github.com/TylerJDev)! - AnchoredOverlay: Add Popover API to AnchoredOverlay (behind `primer_react_css_anchor_positioning` feature flag)
10
14
 
@@ -18,8 +22,6 @@
18
22
 
19
23
  - [#7638](https://github.com/primer/react/pull/7638) [`f04e85d`](https://github.com/primer/react/commit/f04e85df536cd6e8047f70b070bd3cf7c0961f92) Thanks [@iansan5653](https://github.com/iansan5653)! - Update internal implementations of combined refs to improve performance and add support for React 19 callback refs
20
24
 
21
- - Fake entry to force publishing
22
-
23
25
  - [#7633](https://github.com/primer/react/pull/7633) [`a107d39`](https://github.com/primer/react/commit/a107d398e0574b5f8085485c96b27a168061eb50) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Graduate `primer_react_css_has_selector_perf` feature flag: the CSS `:has()` performance optimization (`body[data-dialog-scroll-disabled]`) is now the default behavior for Dialog scroll disabling
24
26
 
25
27
  - [#7695](https://github.com/primer/react/pull/7695) [`780fc3d`](https://github.com/primer/react/commit/780fc3d7b52fd0f9b63f313af6355398180a0118) Thanks [@mattcosta7](https://github.com/mattcosta7)! - perf(ThemeProvider): Reduce unnecessary renders and effect cascades
@@ -0,0 +1,2 @@
1
+ .prc-ActionBar-List-9uz46{align-items:center;display:flex;gap:var(--actionbar-gap,var(--stack-gap-condensed,.5rem));list-style:none;margin-bottom:-1px;min-width:0;position:relative;white-space:nowrap}.prc-ActionBar-List-9uz46:where([data-gap=none]){--actionbar-gap:0}.prc-ActionBar-List-9uz46:where([data-gap=none]) .prc-ActionBar-Divider-6V8yH{padding:0 var(--base-size-8,.5rem)}.prc-ActionBar-List-9uz46:where([data-gap=condensed]){--actionbar-gap:var(--stack-gap-condensed,0.5rem)}.prc-ActionBar-Nav-9spON{align-items:center;display:flex;justify-content:flex-end;padding-inline:var(--base-size-16,1rem)}.prc-ActionBar-Nav-9spON:where([data-flush=true]){padding-inline:0}.prc-ActionBar-Divider-6V8yH:before{background:var(--borderColor-muted,var(--color-border-muted));content:"";display:block;height:var(--base-size-20,1.25rem);width:var(--borderWidth-thin,.0625rem)}.prc-ActionBar-Group-peNCk{display:flex;gap:inherit}
2
+ /*# sourceMappingURL=ActionBar-a41224b2.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ActionBar/ActionBar.module.css.js"],"names":[],"mappings":"AAAA,0BAUE,kBAAmB,CARnB,YAAa,CASb,yDAAqD,CAFrD,eAAgB,CAFhB,kBAAmB,CAJnB,WAAY,CAFZ,iBAAkB,CAOlB,kBAiBF,CAXE,iDACE,iBAKF,CAHE,8EACE,kCACF,CAGF,sDACE,iDACF,CAGF,yBAIE,kBAAmB,CAHnB,YAAa,CAEb,wBAAyB,CADzB,uCAOF,CAHE,kDACE,gBACF,CAIA,oCAME,6DAAoC,CAFpC,UAAW,CAHX,aAAc,CAEd,kCAA2B,CAD3B,sCAKF,CAGF,2BACE,YAAa,CACb,WACF","file":"ActionBar-a41224b2.css","sourcesContent":[".List {\n position: relative;\n display: flex;\n min-width: 0;\n\n /* wonder why this is here */\n /* stylelint-disable-next-line primer/spacing */\n margin-bottom: -1px;\n white-space: nowrap;\n list-style: none;\n align-items: center;\n gap: var(--actionbar-gap, var(--stack-gap-condensed));\n\n /* Gap scale (mirrors Stack) */\n &:where([data-gap='none']) {\n --actionbar-gap: 0;\n\n .Divider {\n padding: 0 var(--base-size-8);\n }\n }\n\n &:where([data-gap='condensed']) {\n --actionbar-gap: var(--stack-gap-condensed);\n }\n}\n\n.Nav {\n display: flex;\n padding-inline: var(--base-size-16);\n justify-content: flex-end;\n align-items: center;\n\n &:where([data-flush='true']) {\n padding-inline: 0;\n }\n}\n\n.Divider {\n &::before {\n display: block;\n width: var(--borderWidth-thin);\n height: var(--base-size-20);\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background: var(--borderColor-muted);\n }\n}\n\n.Group {\n display: flex;\n gap: inherit;\n}\n"]}
@@ -120,6 +120,6 @@ export declare const ActionBarMenu: React.ForwardRefExoticComponent<{
120
120
  keyshortcuts?: string;
121
121
  keybindingHint?: string | string[];
122
122
  } & Omit<import("..").ButtonBaseProps, "aria-label" | "aria-labelledby"> & React.RefAttributes<unknown>>;
123
- export declare const VerticalDivider: () => React.JSX.Element;
123
+ export declare const VerticalDivider: () => React.JSX.Element | null;
124
124
  export {};
125
125
  //# sourceMappingURL=ActionBar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionBar.d.ts","sourceRoot":"","sources":["../../src/ActionBar/ActionBar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiF,MAAM,OAAO,CAAA;AAErG,OAAO,EAAa,KAAK,mBAAmB,EAAC,MAAM,eAAe,CAAA;AAElE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,WAAW,CAAA;AAqC9C,KAAK,IAAI,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAExC,KAAK,SAAS,GACV;IACE,wDAAwD;IACxD,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IAChD,iBAA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AAY,EAAE,MAAM,CAAA;IACpB,+BAA+B;IAC/B,IAAI,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAA;IACtC,KAAK,EAAE,sBAAsB,EAAE,CAAA;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,wBAAwB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;IACxD;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;CAC9C,GAAG,eAAe,CAAA;AAkInB,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,cAAc,CAAC,CA4KvE,CAAA;AAUD,eAAO,MAAM,mBAAmB,0FAgD/B,CAAA;AAMD,eAAO,MAAM,cAAc;;iCAgBzB,CAAA;AAEF,eAAO,MAAM,aAAa;IA9YxB,2CAA2C;kBAC7B,MAAM;IACpB,+BAA+B;UACzB,wBAAwB,CAAC,MAAM,CAAC;WAC/B,sBAAsB,EAAE;IAC/B;;;OAGG;mBACY,wBAAwB,CAAC,MAAM,CAAC,GAAG,MAAM;IACxD;;OAEG;qBACc,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;;;;;;;;;;;wGAya9C,CAAA;AAED,eAAO,MAAM,eAAe,gCAY3B,CAAA"}
@@ -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 { useMergedRefs } from '../hooks/useMergedRefs.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(41);
136
+ const $ = c(38);
75
137
  const {
76
138
  size: t0,
77
139
  children,
@@ -85,273 +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
- if ($[0] !== childRegistry) {
92
- t3 = childRegistry === null || childRegistry === void 0 ? void 0 : childRegistry.values().every(_temp);
93
- $[0] = childRegistry;
94
- $[1] = 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;
95
167
  } else {
96
- t3 = $[1];
168
+ t3 = $[0];
97
169
  }
98
170
  let t4;
99
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
100
- t4 = (direction, from) => {
101
- var _listRef$current$quer, _listRef$current;
102
- const items = Array.from((_listRef$current$quer = (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.querySelectorAll(":is(button, a, input, [tabindex]):not(:disabled):not([data-overflowing]):not([data-more-button-inactive])")) !== null && _listRef$current$quer !== void 0 ? _listRef$current$quer : []);
103
- const fromIndex = from ? items.indexOf(from) : -1;
104
- switch (direction) {
105
- case "start":
106
- {
107
- return items[0];
108
- }
109
- case "end":
110
- {
111
- return items.at(-1);
112
- }
113
- case "next":
114
- {
115
- var _items;
116
- return (_items = items[fromIndex + 1]) !== null && _items !== void 0 ? _items : items[0];
117
- }
118
- case "previous":
119
- {
120
- var _items2;
121
- return (_items2 = items[fromIndex - 1]) !== null && _items2 !== void 0 ? _items2 : items.at(-1);
122
- }
123
- }
124
- };
171
+ if ($[1] !== gap) {
172
+ t4 = [gap];
173
+ $[1] = gap;
125
174
  $[2] = t4;
126
175
  } else {
127
176
  t4 = $[2];
128
177
  }
178
+ useIsomorphicLayoutEffect(t3, t4);
179
+ const moreMenuRef = useRef(null);
129
180
  let t5;
130
- if ($[3] !== t3) {
131
- t5 = {
132
- containerRef: listRef,
133
- bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
134
- focusOutBehavior: "wrap",
135
- disabled: t3,
136
- getNextFocusable: t4
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
193
  };
138
- $[3] = t3;
139
- $[4] = t5;
194
+ $[3] = childRegistry;
195
+ $[4] = computedGap;
196
+ $[5] = menuItemIds.size;
197
+ $[6] = t5;
140
198
  } else {
141
- t5 = $[4];
199
+ t5 = $[6];
142
200
  }
143
- useFocusZone(t5);
201
+ useResizeObserver(t5, navRef);
144
202
  let t6;
145
- if ($[5] !== childRegistry) {
146
- t6 = childRegistry && Array.from(childRegistry.entries()).filter(_temp2);
147
- $[5] = childRegistry;
148
- $[6] = t6;
203
+ if ($[7] !== menuItemIds) {
204
+ t6 = id => !menuItemIds.has(id);
205
+ $[7] = menuItemIds;
206
+ $[8] = t6;
149
207
  } else {
150
- t6 = $[6];
208
+ t6 = $[8];
151
209
  }
152
- const overflowItems = t6;
210
+ const isVisibleChild = t6;
153
211
  let t7;
154
- if ($[7] !== size) {
212
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
155
213
  t7 = {
156
- size
214
+ containerRef: listRef,
215
+ bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
216
+ focusOutBehavior: "wrap"
157
217
  };
158
- $[7] = size;
159
- $[8] = t7;
218
+ $[9] = t7;
219
+ } 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
235
  } else {
161
- t7 = $[8];
236
+ groupedItemsMap = $[11];
162
237
  }
238
+ const groupedItems = groupedItemsMap;
163
239
  let t8;
164
- if ($[9] !== className) {
165
- t8 = clsx(className, styles.Nav);
166
- $[9] = className;
167
- $[10] = t8;
168
- } else {
169
- t8 = $[10];
170
- }
171
- const t9 = overflowItems ? overflowItems.length > 0 : undefined;
172
- let t10;
173
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
174
- t10 = /*#__PURE__*/jsx("div", {});
175
- $[11] = t10;
176
- } else {
177
- t10 = $[11];
178
- }
179
- let t11;
180
- if ($[12] !== children || $[13] !== setChildRegistry) {
181
- t11 = /*#__PURE__*/jsxs("div", {
182
- className: styles.OverflowContainer,
183
- children: [t10, /*#__PURE__*/jsx(ActionBarItemsRegistry.Provider, {
184
- setRegistry: setChildRegistry,
185
- children: children
186
- })]
187
- });
188
- $[12] = children;
189
- $[13] = setChildRegistry;
190
- $[14] = t11;
191
- } else {
192
- t11 = $[14];
193
- }
194
- const t12 = `More ${ariaLabel} items ${overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.length}`;
195
- const t13 = overflowItems !== null && overflowItems !== void 0 && overflowItems.length ? undefined : true;
196
- let t14;
197
- if ($[15] !== size || $[16] !== t12 || $[17] !== t13) {
198
- t14 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
199
- children: /*#__PURE__*/jsx(IconButton, {
200
- variant: "invisible",
201
- "aria-label": t12,
202
- icon: KebabHorizontalIcon,
203
- className: styles.MoreButton,
204
- "data-more-button-inactive": t13,
205
- size: size
206
- })
207
- });
208
- $[15] = size;
209
- $[16] = t12;
210
- $[17] = t13;
211
- $[18] = t14;
240
+ if ($[12] !== isVisibleChild || $[13] !== size) {
241
+ t8 = {
242
+ size,
243
+ isVisibleChild
244
+ };
245
+ $[12] = isVisibleChild;
246
+ $[13] = size;
247
+ $[14] = t8;
212
248
  } else {
213
- t14 = $[18];
249
+ t8 = $[14];
214
250
  }
215
- let t15;
216
- if ($[19] !== overflowItems) {
217
- t15 = overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.map(_temp4);
218
- $[19] = overflowItems;
219
- $[20] = t15;
251
+ let t9;
252
+ if ($[15] !== className) {
253
+ t9 = clsx(className, styles.Nav);
254
+ $[15] = className;
255
+ $[16] = t9;
220
256
  } else {
221
- t15 = $[20];
257
+ t9 = $[16];
222
258
  }
223
- let t16;
224
- if ($[21] !== t15) {
225
- t16 = /*#__PURE__*/jsx(ActionMenu.Overlay, {
226
- children: /*#__PURE__*/jsx(ActionList, {
227
- children: t15
228
- })
259
+ let t10;
260
+ if ($[17] !== children || $[18] !== setChildRegistry) {
261
+ t10 = /*#__PURE__*/jsx(ActionBarItemsRegistry.Provider, {
262
+ setRegistry: setChildRegistry,
263
+ children: children
229
264
  });
230
- $[21] = t15;
231
- $[22] = t16;
265
+ $[17] = children;
266
+ $[18] = setChildRegistry;
267
+ $[19] = t10;
232
268
  } else {
233
- t16 = $[22];
269
+ t10 = $[19];
234
270
  }
235
- let t17;
236
- if ($[23] !== t14 || $[24] !== t16) {
237
- t17 = /*#__PURE__*/jsxs(ActionMenu, {
238
- children: [t14, t16]
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
+ })]
239
341
  });
240
- $[23] = t14;
241
- $[24] = t16;
242
- $[25] = t17;
342
+ $[20] = ariaLabel;
343
+ $[21] = childRegistry;
344
+ $[22] = groupedItems;
345
+ $[23] = menuItemIds;
346
+ $[24] = t11;
243
347
  } else {
244
- t17 = $[25];
348
+ t11 = $[24];
245
349
  }
246
- let t18;
247
- if ($[26] !== ariaLabel || $[27] !== ariaLabelledBy || $[28] !== gap || $[29] !== size || $[30] !== t11 || $[31] !== t17 || $[32] !== t9) {
248
- t18 = /*#__PURE__*/jsxs("div", {
350
+ let t12;
351
+ if ($[25] !== ariaLabel || $[26] !== ariaLabelledBy || $[27] !== gap || $[28] !== t10 || $[29] !== t11) {
352
+ t12 = /*#__PURE__*/jsxs("div", {
249
353
  ref: listRef,
250
354
  role: "toolbar",
251
355
  className: styles.List,
252
356
  "aria-label": ariaLabel,
253
357
  "aria-labelledby": ariaLabelledBy,
254
358
  "data-gap": gap,
255
- "data-size": size,
256
- "data-has-overflow": t9,
257
- children: [t11, t17]
359
+ children: [t10, t11]
258
360
  });
259
- $[26] = ariaLabel;
260
- $[27] = ariaLabelledBy;
261
- $[28] = gap;
262
- $[29] = size;
263
- $[30] = t11;
264
- $[31] = t17;
265
- $[32] = t9;
266
- $[33] = t18;
267
- } else {
268
- t18 = $[33];
269
- }
270
- let t19;
271
- if ($[34] !== flush || $[35] !== t18 || $[36] !== t8) {
272
- t19 = /*#__PURE__*/jsx("div", {
361
+ $[25] = ariaLabel;
362
+ $[26] = ariaLabelledBy;
363
+ $[27] = gap;
364
+ $[28] = t10;
365
+ $[29] = t11;
366
+ $[30] = t12;
367
+ } else {
368
+ t12 = $[30];
369
+ }
370
+ let t13;
371
+ if ($[31] !== flush || $[32] !== t12 || $[33] !== t9) {
372
+ t13 = /*#__PURE__*/jsx("div", {
273
373
  ref: navRef,
274
- className: t8,
374
+ className: t9,
275
375
  "data-flush": flush,
276
- children: t18
376
+ children: t12
277
377
  });
278
- $[34] = flush;
279
- $[35] = t18;
280
- $[36] = t8;
281
- $[37] = t19;
378
+ $[31] = flush;
379
+ $[32] = t12;
380
+ $[33] = t9;
381
+ $[34] = t13;
282
382
  } else {
283
- t19 = $[37];
383
+ t13 = $[34];
284
384
  }
285
- let t20;
286
- if ($[38] !== t19 || $[39] !== t7) {
287
- t20 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
288
- value: t7,
289
- children: t19
385
+ let t14;
386
+ if ($[35] !== t13 || $[36] !== t8) {
387
+ t14 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
388
+ value: t8,
389
+ children: t13
290
390
  });
291
- $[38] = t19;
292
- $[39] = t7;
293
- $[40] = t20;
391
+ $[35] = t13;
392
+ $[36] = t8;
393
+ $[37] = t14;
294
394
  } else {
295
- t20 = $[40];
395
+ t14 = $[37];
296
396
  }
297
- return t20;
397
+ return t14;
298
398
  };
299
- function useActionBarItem(ref, registryProps) {
300
- var _useContext;
301
- const $ = c(8);
302
- const isGroupOverflowing = (_useContext = useContext(ActionBarGroupContext)) === null || _useContext === void 0 ? void 0 : _useContext.isOverflowing;
303
- const isInGroup = isGroupOverflowing !== undefined;
399
+ function useWidth(ref) {
400
+ const $ = c(3);
401
+ const [width, setWidth] = useState(-1);
304
402
  let t0;
305
- if ($[0] !== isInGroup || $[1] !== ref) {
306
- t0 = onChange => {
307
- if (isInGroup) {
308
- return _temp5;
309
- }
310
- const observer = new IntersectionObserver(() => onChange(), {
311
- threshold: 1
312
- });
313
- if (ref.current) {
314
- observer.observe(ref.current);
315
- }
316
- return () => observer.disconnect();
317
- };
318
- $[0] = isInGroup;
319
- $[1] = ref;
320
- $[2] = t0;
321
- } else {
322
- t0 = $[2];
323
- }
324
- const subscribeIntersectionObserver = t0;
325
403
  let t1;
326
- if ($[3] !== ref) {
327
- t1 = () => ref.current ? ref.current.offsetTop > 0 : false;
328
- $[3] = ref;
329
- $[4] = t1;
330
- } else {
331
- t1 = $[4];
332
- }
333
- const isItemOverflowing = useSyncExternalStore(subscribeIntersectionObserver, t1, _temp6);
334
- const isOverflowing = isGroupOverflowing || isItemOverflowing;
335
- ActionBarItemsRegistry.useRegisterDescendant(isOverflowing ? registryProps : null);
336
- const t2 = isOverflowing ? "" : undefined;
337
- let t3;
338
- if ($[5] !== isOverflowing || $[6] !== t2) {
339
- t3 = {
340
- isOverflowing,
341
- 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);
342
408
  };
343
- $[5] = isOverflowing;
344
- $[6] = t2;
345
- $[7] = t3;
409
+ t1 = [ref];
410
+ $[0] = ref;
411
+ $[1] = t0;
412
+ $[2] = t1;
346
413
  } else {
347
- t3 = $[7];
414
+ t0 = $[1];
415
+ t1 = $[2];
348
416
  }
349
- return t3;
417
+ useIsomorphicLayoutEffect(t0, t1);
418
+ return width;
350
419
  }
351
- function _temp6() {
352
- return false;
353
- }
354
- function _temp5() {}
355
420
  const ActionBarIconButton = /*#__PURE__*/forwardRef(({
356
421
  disabled,
357
422
  onClick,
@@ -360,36 +425,44 @@ const ActionBarIconButton = /*#__PURE__*/forwardRef(({
360
425
  const ref = useRef(null);
361
426
  const mergedRef = useMergedRefs(ref, forwardedRef);
362
427
  const {
363
- size
428
+ size,
429
+ isVisibleChild
364
430
  } = React.useContext(ActionBarContext);
431
+ const {
432
+ groupId
433
+ } = React.useContext(ActionBarGroupContext);
434
+ const width = useWidth(ref);
365
435
  const {
366
436
  ['aria-label']: ariaLabel,
367
437
  icon
368
438
  } = props;
369
- const {
370
- dataOverflowingAttr
371
- } = useActionBarItem(ref, useMemo(() => ({
439
+ const registryProps = useMemo(() => ({
372
440
  type: 'action',
373
441
  label: ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : '',
374
442
  icon,
375
443
  disabled: !!disabled,
376
- onClick: onClick
377
- }), [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);
378
449
  const clickHandler = useCallback(event => {
379
450
  if (disabled) return;
380
451
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
381
452
  }, [disabled, onClick]);
453
+ if (!isVisibleChild(id) || groupId && !isVisibleChild(groupId)) return null;
382
454
  return /*#__PURE__*/jsx(IconButton, {
383
455
  "aria-disabled": disabled,
384
456
  ref: mergedRef,
385
457
  size: size,
386
458
  onClick: clickHandler,
387
459
  ...props,
388
- variant: "invisible",
389
- "data-overflowing": dataOverflowingAttr
460
+ variant: "invisible"
390
461
  });
391
462
  });
392
- const ActionBarGroupContext = /*#__PURE__*/React.createContext(null);
463
+ const ActionBarGroupContext = /*#__PURE__*/React.createContext({
464
+ groupId: null
465
+ });
393
466
  const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
394
467
  const $ = c(10);
395
468
  const {
@@ -397,39 +470,38 @@ const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
397
470
  } = t0;
398
471
  const backupRef = useRef(null);
399
472
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
473
+ const width = useWidth(ref);
400
474
  let t1;
401
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
475
+ if ($[0] !== width) {
402
476
  t1 = {
403
- type: "group"
477
+ type: "group",
478
+ width
404
479
  };
405
- $[0] = t1;
480
+ $[0] = width;
481
+ $[1] = t1;
406
482
  } else {
407
- t1 = $[0];
483
+ t1 = $[1];
408
484
  }
409
- const {
410
- dataOverflowingAttr,
411
- isOverflowing
412
- } = useActionBarItem(ref, t1);
485
+ const registryProps = t1;
486
+ const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
413
487
  let t2;
414
- if ($[1] !== isOverflowing) {
488
+ if ($[2] !== id) {
415
489
  t2 = {
416
- isOverflowing
490
+ groupId: id
417
491
  };
418
- $[1] = isOverflowing;
419
- $[2] = t2;
492
+ $[2] = id;
493
+ $[3] = t2;
420
494
  } else {
421
- t2 = $[2];
495
+ t2 = $[3];
422
496
  }
423
497
  let t3;
424
- if ($[3] !== children || $[4] !== dataOverflowingAttr || $[5] !== ref) {
498
+ if ($[4] !== children || $[5] !== ref) {
425
499
  t3 = /*#__PURE__*/jsx("div", {
426
500
  className: styles.Group,
427
501
  ref: ref,
428
- "data-overflowing": dataOverflowingAttr,
429
502
  children: children
430
503
  });
431
- $[3] = children;
432
- $[4] = dataOverflowingAttr;
504
+ $[4] = children;
433
505
  $[5] = ref;
434
506
  $[6] = t3;
435
507
  } else {
@@ -483,12 +555,17 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
483
555
  }
484
556
  const backupRef = useRef(null);
485
557
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
558
+ const {
559
+ isVisibleChild
560
+ } = React.useContext(ActionBarContext);
486
561
  const [menuOpen, setMenuOpen] = useState(false);
562
+ const width = useWidth(ref);
487
563
  const t1 = overflowIcon ? overflowIcon : icon;
488
564
  let t2;
489
- if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1) {
565
+ if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1 || $[11] !== width) {
490
566
  t2 = {
491
567
  type: "menu",
568
+ width,
492
569
  label: ariaLabel,
493
570
  icon: t1,
494
571
  returnFocusRef,
@@ -498,26 +575,27 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
498
575
  $[8] = items;
499
576
  $[9] = returnFocusRef;
500
577
  $[10] = t1;
501
- $[11] = t2;
578
+ $[11] = width;
579
+ $[12] = t2;
502
580
  } else {
503
- t2 = $[11];
581
+ t2 = $[12];
582
+ }
583
+ const registryProps = t2;
584
+ const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
585
+ if (!isVisibleChild(id)) {
586
+ return null;
504
587
  }
505
- const {
506
- dataOverflowingAttr
507
- } = useActionBarItem(ref, t2);
508
588
  let t3;
509
- if ($[12] !== ariaLabel || $[13] !== dataOverflowingAttr || $[14] !== icon || $[15] !== props) {
589
+ if ($[13] !== ariaLabel || $[14] !== icon || $[15] !== props) {
510
590
  t3 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
511
591
  children: /*#__PURE__*/jsx(IconButton, {
512
592
  variant: "invisible",
513
593
  "aria-label": ariaLabel,
514
594
  icon: icon,
515
- ...props,
516
- "data-overflowing": dataOverflowingAttr
595
+ ...props
517
596
  })
518
597
  });
519
- $[12] = ariaLabel;
520
- $[13] = dataOverflowingAttr;
598
+ $[13] = ariaLabel;
521
599
  $[14] = icon;
522
600
  $[15] = props;
523
601
  $[16] = t3;
@@ -536,7 +614,7 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
536
614
  }
537
615
  let t5;
538
616
  if ($[19] !== items) {
539
- t5 = items.map(_temp7);
617
+ t5 = items.map(_temp4);
540
618
  $[19] = items;
541
619
  $[20] = t5;
542
620
  } else {
@@ -585,91 +663,68 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
585
663
  const VerticalDivider = () => {
586
664
  const $ = c(3);
587
665
  const ref = useRef(null);
666
+ const {
667
+ isVisibleChild
668
+ } = React.useContext(ActionBarContext);
669
+ const width = useWidth(ref);
588
670
  let t0;
589
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
671
+ if ($[0] !== width) {
590
672
  t0 = {
591
- type: "divider"
673
+ type: "divider",
674
+ width
592
675
  };
593
- $[0] = t0;
676
+ $[0] = width;
677
+ $[1] = t0;
594
678
  } else {
595
- t0 = $[0];
679
+ t0 = $[1];
680
+ }
681
+ const registryProps = t0;
682
+ const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
683
+ if (!isVisibleChild(id)) {
684
+ return null;
596
685
  }
597
- const {
598
- dataOverflowingAttr
599
- } = useActionBarItem(ref, t0);
600
686
  let t1;
601
- if ($[1] !== dataOverflowingAttr) {
687
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
602
688
  t1 = /*#__PURE__*/jsx("div", {
603
689
  ref: ref,
604
690
  "data-component": "ActionBar.VerticalDivider",
605
691
  "aria-hidden": "true",
606
- className: styles.Divider,
607
- "data-overflowing": dataOverflowingAttr
692
+ className: styles.Divider
608
693
  });
609
- $[1] = dataOverflowingAttr;
610
694
  $[2] = t1;
611
695
  } else {
612
696
  t1 = $[2];
613
697
  }
614
698
  return t1;
615
699
  };
616
- function _temp(v) {
617
- return v !== null;
700
+ function _temp() {
701
+ return new Set();
618
702
  }
619
- function _temp2(entry) {
620
- return entry[1] !== null;
621
- }
622
- function _temp3(item, index) {
703
+ function _temp2(item, index) {
623
704
  return renderMenuItem(item, index);
624
705
  }
625
- function _temp4(t0) {
626
- const [id, menuItem] = t0;
627
- if (menuItem.type === "divider") {
628
- return /*#__PURE__*/jsx(ActionList.Divider, {}, id);
629
- }
630
- if (menuItem.type === "action") {
706
+ function _temp3(t0) {
707
+ const [key_0, childProps_0] = t0;
708
+ if (childProps_0.type === "action") {
631
709
  const {
632
- onClick,
633
- icon: Icon,
634
- label,
635
- disabled
636
- } = menuItem;
710
+ onClick: onClick_0,
711
+ icon: Icon_1,
712
+ label: label_1,
713
+ disabled: disabled_0
714
+ } = childProps_0;
637
715
  return /*#__PURE__*/jsxs(ActionList.Item, {
638
- onSelect: event => {
639
- typeof onClick === "function" && onClick(event);
716
+ onSelect: event_0 => {
717
+ typeof onClick_0 === "function" && onClick_0(event_0);
640
718
  },
641
- disabled: disabled,
719
+ disabled: disabled_0,
642
720
  children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
643
- children: /*#__PURE__*/jsx(Icon, {})
644
- }), label]
645
- }, label);
646
- }
647
- if (menuItem.type === "menu") {
648
- const menuItems = menuItem.items;
649
- const {
650
- icon: Icon_0,
651
- label: label_0,
652
- returnFocusRef
653
- } = menuItem;
654
- return /*#__PURE__*/jsxs(ActionMenu, {
655
- children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
656
- children: /*#__PURE__*/jsxs(ActionList.Item, {
657
- children: [Icon_0 !== "none" ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
658
- children: /*#__PURE__*/jsx(Icon_0, {})
659
- }) : null, label_0]
660
- })
661
- }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
662
- ...(returnFocusRef && {
663
- returnFocusRef
664
- }),
665
- children: /*#__PURE__*/jsx(ActionList, {
666
- children: menuItems.map(_temp3)
667
- })
668
- })]
669
- }, id);
721
+ children: /*#__PURE__*/jsx(Icon_1, {})
722
+ }), label_1]
723
+ }, key_0);
670
724
  }
725
+ return null;
671
726
  }
672
- function _temp7(item, index) {
727
+ function _temp4(item, index) {
673
728
  return renderMenuItem(item, index);
674
729
  }
675
730
 
@@ -1,5 +1,5 @@
1
- import './ActionBar-94abaa40.css';
1
+ import './ActionBar-a41224b2.css';
2
2
 
3
- var styles = {"List":"prc-ActionBar-List-9uz46","detect-overflow":"prc-ActionBar-detect-overflow-mAuJu","Divider":"prc-ActionBar-Divider-6V8yH","Nav":"prc-ActionBar-Nav-9spON","Group":"prc-ActionBar-Group-peNCk","OverflowContainer":"prc-ActionBar-OverflowContainer-AkYZs","MoreButton":"prc-ActionBar-MoreButton-RHqpx"};
3
+ var styles = {"List":"prc-ActionBar-List-9uz46","Divider":"prc-ActionBar-Divider-6V8yH","Nav":"prc-ActionBar-Nav-9spON","Group":"prc-ActionBar-Group-peNCk"};
4
4
 
5
5
  export { styles as default };
@@ -1,7 +1,7 @@
1
1
  export type { ActionBarProps, ActionBarMenuProps, ActionBarMenuItemProps } from './ActionBar';
2
2
  declare const ActionBar: import("react").FC<import("react").PropsWithChildren<import("./ActionBar").ActionBarProps>> & {
3
3
  IconButton: import("react").ForwardRefExoticComponent<import("./ActionBar").ActionBarIconButtonProps & import("react").RefAttributes<unknown>>;
4
- Divider: () => import("react").JSX.Element;
4
+ Divider: () => import("react").JSX.Element | null;
5
5
  Group: import("react").ForwardRefExoticComponent<{
6
6
  children?: import("react").ReactNode | undefined;
7
7
  } & import("react").RefAttributes<unknown>>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260403172558",
4
+ "version": "0.0.0-20260403174426",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -1,2 +0,0 @@
1
- .prc-ActionBar-List-9uz46{align-items:flex-start;display:flex;gap:var(--actionbar-gap,var(--stack-gap-condensed,.5rem));height:var(--actionbar-height,var(--control-small-size,1.75rem));list-style:none;margin-bottom:-1px;min-width:0;overflow:hidden;position:relative}.prc-ActionBar-List-9uz46:not([data-has-overflow]){animation:prc-ActionBar-detect-overflow-mAuJu linear;animation-timeline:scroll(self block)}.prc-ActionBar-List-9uz46[data-has-overflow=true]{--morebutton-display:block}.prc-ActionBar-List-9uz46:where([data-size=medium]){--actionbar-height:var(--control-medium-size,2rem)}.prc-ActionBar-List-9uz46:where([data-size=large]){--actionbar-height:var(--control-large-size,2.5rem)}.prc-ActionBar-List-9uz46:where([data-gap=none]){--actionbar-gap:0}.prc-ActionBar-List-9uz46:where([data-gap=none]) .prc-ActionBar-Divider-6V8yH{padding:0 var(--base-size-8,.5rem)}.prc-ActionBar-List-9uz46:where([data-gap=condensed]){--actionbar-gap:var(--stack-gap-condensed,0.5rem)}.prc-ActionBar-List-9uz46 [data-overflowing]{visibility:hidden!important}@keyframes prc-ActionBar-detect-overflow-mAuJu{0%,to{--morebutton-display:block}}.prc-ActionBar-Nav-9spON{align-items:center;display:flex;justify-content:flex-end;padding-inline:var(--base-size-16,1rem)}.prc-ActionBar-Nav-9spON:where([data-flush=true]){padding-inline:0}.prc-ActionBar-Divider-6V8yH:before{background:var(--borderColor-muted,var(--color-border-muted));content:"";display:block;height:var(--base-size-20,1.25rem);margin-top:calc((var(--actionbar-height) - var(--base-size-20,1.25rem))/2);width:var(--borderWidth-thin,.0625rem)}.prc-ActionBar-Group-peNCk,.prc-ActionBar-OverflowContainer-AkYZs{display:flex;gap:inherit}.prc-ActionBar-OverflowContainer-AkYZs{flex-wrap:wrap;justify-content:flex-end;overflow:hidden}.prc-ActionBar-MoreButton-RHqpx{display:var(--morebutton-display,none)}
2
- /*# sourceMappingURL=ActionBar-94abaa40.css.map */
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ActionBar/ActionBar.module.css.js"],"names":[],"mappings":"AAAA,0BASE,sBAAuB,CAPvB,YAAa,CAQb,yDAAqD,CAGrD,gEAA0D,CAL1D,eAAgB,CADhB,kBAAmB,CAJnB,WAAY,CAQZ,eAAgB,CAVhB,iBAuDF,CAxCE,mDAIE,oDAAiC,CACjC,qCACF,CAGA,kDACE,0BACF,CAEA,oDACE,kDACF,CAEA,mDACE,mDACF,CAGA,iDACE,iBAKF,CAHE,8EACE,kCACF,CAGF,sDACE,iDACF,CAEA,6CAIE,2BACF,CAGF,+CACE,MAEE,0BACF,CACF,CAEA,yBAIE,kBAAmB,CAHnB,YAAa,CAEb,wBAAyB,CADzB,uCAOF,CAHE,kDACE,gBACF,CAIA,oCAME,6DAAoC,CAFpC,UAAW,CAHX,aAAc,CAEd,kCAA2B,CAK3B,0EAAqE,CANrE,sCAOF,CAQF,kEAJE,YAAa,CACb,WASF,CANA,uCAEE,cAAe,CAEf,wBAAyB,CACzB,eACF,CAEA,gCACE,sCACF","file":"ActionBar-94abaa40.css","sourcesContent":[".List {\n position: relative;\n display: flex;\n min-width: 0;\n\n /* wonder why this is here */\n /* stylelint-disable-next-line primer/spacing */\n margin-bottom: -1px;\n list-style: none;\n align-items: flex-start;\n gap: var(--actionbar-gap, var(--stack-gap-condensed));\n overflow: hidden;\n /* Explicit height is required to clip wrapped items */\n height: var(--actionbar-height, var(--control-small-size));\n\n /* Only apply scroll animation before overflow is calculated (for SSR/initial render) */\n &:not([data-has-overflow]) {\n /* Scroll-based animations have no effect unless the container is scrollable (has overflow, even with overflow:hidden)\n so we can use them to detect overflow. It would be cleaner to use scroll-state container queries for this, but\n browser support for scroll-driven animations is slightly better. */\n animation: detect-overflow linear;\n animation-timeline: scroll(self block);\n }\n\n /* After initial render, JS is used to control visibility which provides progressive enhancement for unsupported browsers */\n &[data-has-overflow='true'] {\n --morebutton-display: block;\n }\n\n &:where([data-size='medium']) {\n --actionbar-height: var(--control-medium-size);\n }\n\n &:where([data-size='large']) {\n --actionbar-height: var(--control-large-size);\n }\n\n /* Gap scale (mirrors Stack) */\n &:where([data-gap='none']) {\n --actionbar-gap: 0;\n\n .Divider {\n padding: 0 var(--base-size-8);\n }\n }\n\n &:where([data-gap='condensed']) {\n --actionbar-gap: var(--stack-gap-condensed);\n }\n\n & [data-overflowing] {\n /* Hide overflowing items. Even though they are clipped by `overflow: hidden`, setting `visibility: hidden` ensures\n they can't accidentally be shown and also hides them from screen readers / keyboard nav. `!important` prevents\n consumers from unintentionally overriding this and breaking accessibility. */\n visibility: hidden !important;\n }\n}\n\n@keyframes detect-overflow {\n 0%,\n 100% {\n --morebutton-display: block;\n }\n}\n\n.Nav {\n display: flex;\n padding-inline: var(--base-size-16);\n justify-content: flex-end;\n align-items: center;\n\n &:where([data-flush='true']) {\n padding-inline: 0;\n }\n}\n\n.Divider {\n &::before {\n display: block;\n width: var(--borderWidth-thin);\n height: var(--base-size-20);\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background: var(--borderColor-muted);\n /* stylelint-disable-next-line primer/spacing */\n margin-top: calc((var(--actionbar-height) - var(--base-size-20)) / 2);\n }\n}\n\n.Group {\n display: flex;\n gap: inherit;\n}\n\n.OverflowContainer {\n display: flex;\n flex-wrap: wrap;\n gap: inherit;\n justify-content: flex-end;\n overflow: hidden;\n}\n\n.MoreButton {\n display: var(--morebutton-display, none);\n}\n"]}