@primer/react 0.0.0-20260505150005 → 0.0.0-20260506133933

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,11 +1,9 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260505150005
3
+ ## 0.0.0-20260506133933
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - [#7655](https://github.com/primer/react/pull/7655) [`f59a1b1`](https://github.com/primer/react/commit/f59a1b190027b56f853797c4dc2cf9475cf5e225) Thanks [@iansan5653](https://github.com/iansan5653)! - Replace `ActionBar` overflow calculations with CSS wrapping approach to improve performance and stability
8
-
9
7
  - [#7755](https://github.com/primer/react/pull/7755) [`0e868f9`](https://github.com/primer/react/commit/0e868f9c34ee6d073485e81651a16e92d3ff822c) Thanks [@francinelucca](https://github.com/francinelucca)! - feat: add ActionList, SelectPanel primitives exports and new FilteredActionList.Input components
10
8
 
11
9
  ### Patch Changes
@@ -20,12 +18,10 @@
20
18
 
21
19
  - [#7708](https://github.com/primer/react/pull/7708) [`d0fa0ff`](https://github.com/primer/react/commit/d0fa0ff2301b3db7a4b66e7aabf3ff544ffb4ef2) Thanks [@hectahertz](https://github.com/hectahertz)! - perf(css): audit :has() selectors and add stylelint guard for Safari
22
20
 
23
- - [#7775](https://github.com/primer/react/pull/7775) [`2199b7f`](https://github.com/primer/react/commit/2199b7f18f1a47e79e9b21cf04f1599d5af8836a) Thanks [@TylerJDev](https://github.com/TylerJDev)! - AnchoredOverlay: Ensure styles persist on anchors even when re-mounted (behind feature flag)
21
+ - [#7775](https://github.com/primer/react/pull/7775) [`4b7e4ca`](https://github.com/primer/react/commit/4b7e4ca0fe1dcbb687fff94a9c8cfe6951bb08f7) Thanks [@TylerJDev](https://github.com/TylerJDev)! - AnchoredOverlay: Ensure styles persist on anchors even when re-mounted (behind feature flag)
24
22
 
25
23
  - [#7780](https://github.com/primer/react/pull/7780) [`8330aad`](https://github.com/primer/react/commit/8330aadeba6231bf916a9c93757f89018838ebb4) Thanks [@francinelucca](https://github.com/francinelucca)! - fix: Checkbox indeterminate state now persists on click if the state didn't change
26
24
 
27
- - [#7802](https://github.com/primer/react/pull/7802) [`ef40b1d`](https://github.com/primer/react/commit/ef40b1d7465a8a31cbbdb525dc834f310cdf3040) Thanks [@TylerJDev](https://github.com/TylerJDev)! - AnchoredOverlay: Ensure overlay fits within viewport by calculating viewport height + width (behind `primer_react_css_anchor_positioning` feature flag)
28
-
29
25
  ## 38.21.1
30
26
 
31
27
  ### Patch Changes
@@ -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,#d1d9e0b3);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,6CAAoC,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,OAA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ACH,OAAO,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAA;IACzC;;;OAGG;IACH,KAAK,CAAC,EAAE,sBAAsB,EAAE,CAAA;CACjC,GAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC,GACzC;IACE,IAAI,EAAE,SAAS,CAAA;CAChB,CAAA;AAEL,MAAM,MAAM,kBAAkB,GAAG;IAC/B,2CAA2C;IAC3C,YAAY,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;;;;;;;;;;;wGAgb9C,CAAA;AAED,eAAO,MAAM,eAAe,gCAY3B,CAAA"}
@@ -1,19 +1,29 @@
1
1
  import { c } from 'react-compiler-runtime';
2
- import React, { forwardRef, useRef, useState, useMemo, useCallback, useContext, useSyncExternalStore } from 'react';
2
+ import React, { useRef, useState, forwardRef, useMemo, useCallback } from 'react';
3
3
  import { KebabHorizontalIcon } from '@primer/octicons-react';
4
4
  import { ActionList } from '../ActionList/index.js';
5
+ import useIsomorphicLayoutEffect from '../utils/useIsomorphicLayoutEffect.js';
6
+ import { useResizeObserver } from '../hooks/useResizeObserver.js';
5
7
  import { IconButton } from '../Button/IconButton.js';
6
8
  import { useFocusZone } from '../hooks/useFocusZone.js';
7
9
  import styles from './ActionBar.module.css.js';
8
10
  import { clsx } from 'clsx';
9
11
  import { createDescendantRegistry } from '../utils/descendant-registry.js';
10
- import { jsx, jsxs } from 'react/jsx-runtime';
12
+ import { jsxs, jsx } from 'react/jsx-runtime';
11
13
  import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js';
12
14
  import { FocusKeys } from '@primer/behaviors';
13
15
  import { ActionMenu } from '../ActionMenu/ActionMenu.js';
14
16
 
17
+ const ACTIONBAR_ITEM_GAP = 8;
18
+
19
+ /**
20
+ * Registry of descendants to render in the list or menu. To preserve insertion order across updates, children are
21
+ * set to `null` when unregistered rather than fully dropped from the map.
22
+ */
23
+
15
24
  const ActionBarContext = /*#__PURE__*/React.createContext({
16
25
  size: 'medium',
26
+ isVisibleChild: () => true,
17
27
  groupId: undefined
18
28
  });
19
29
 
@@ -21,8 +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();
25
- const FOCUSABLE_ITEM_SELECTOR = ':is(button, a, input, [tabindex]):not(:disabled):not([data-overflowing]):not([data-more-button-inactive])';
36
+ const calculatePossibleItems = (registryEntries, navWidth, gap, moreMenuWidth = 0) => {
37
+ const widthToFit = navWidth - moreMenuWidth;
38
+ let breakpoint = registryEntries.length; // assume all items will fit
39
+ let sumsOfChildWidth = 0;
40
+ for (const [index, [, child]] of registryEntries.entries()) {
41
+ sumsOfChildWidth += index > 0 ? child.width + gap : child.width;
42
+ if (sumsOfChildWidth > widthToFit) {
43
+ breakpoint = index;
44
+ break;
45
+ } else {
46
+ continue;
47
+ }
48
+ }
49
+ return breakpoint;
50
+ };
26
51
  const renderMenuItem = (item, index) => {
27
52
  if (item.type === 'divider') {
28
53
  return /*#__PURE__*/jsx(ActionList.Divider, {}, index);
@@ -71,256 +96,328 @@ const renderMenuItem = (item, index) => {
71
96
  }, label);
72
97
  };
73
98
  renderMenuItem.displayName = "renderMenuItem";
74
- const ActionBar = t0 => {
75
- const $ = c(40);
99
+ const getMenuItems = (navWidth, moreMenuWidth, childRegistry, hasActiveMenu, gap) => {
100
+ var _childRegistry$entrie;
101
+ const registryEntries = Array.from((_childRegistry$entrie = childRegistry === null || childRegistry === void 0 ? void 0 : childRegistry.entries()) !== null && _childRegistry$entrie !== void 0 ? _childRegistry$entrie : []).filter(entry => entry[1] !== null && (entry[1].type !== 'action' || entry[1].groupId === undefined));
102
+ if (registryEntries.length === 0) return new Set();
103
+ const numberOfItemsPossible = calculatePossibleItems(registryEntries, navWidth, gap);
104
+ const numberOfItemsPossibleWithMoreMenu = calculatePossibleItems(registryEntries, navWidth, gap, moreMenuWidth || MORE_BTN_WIDTH);
105
+ const menuItems = new Set();
106
+
107
+ // First, we check if we can fit all the items with their icons
108
+ if (registryEntries.length >= numberOfItemsPossible) {
109
+ /* Below is an accessibility requirement. Never show only one item in the overflow menu.
110
+ * If there is only one item left to display in the overflow menu according to the calculation,
111
+ * we need to pull another item from the list into the overflow menu.
112
+ */
113
+ const numberOfItemsInMenu = registryEntries.length - numberOfItemsPossibleWithMoreMenu;
114
+ const numberOfListItems = numberOfItemsInMenu === 1 ? numberOfItemsPossibleWithMoreMenu - 1 : numberOfItemsPossibleWithMoreMenu;
115
+ for (const [index, [id, child]] of registryEntries.entries()) {
116
+ if (index < numberOfListItems) {
117
+ continue;
118
+ //if the last item is a divider
119
+ } else if (child.type === 'divider') {
120
+ if (index === numberOfListItems - 1 || index === numberOfListItems) {
121
+ continue;
122
+ } else {
123
+ menuItems.add(id);
124
+ }
125
+ } else {
126
+ menuItems.add(id);
127
+ }
128
+ }
129
+ return menuItems;
130
+ } else if (numberOfItemsPossible > registryEntries.length && hasActiveMenu) {
131
+ /* If the items fit in the list and there are items in the overflow menu, we need to move them back to the list */
132
+ return new Set();
133
+ }
134
+ };
135
+ const ActionBar = props => {
136
+ const $ = c(38);
76
137
  const {
77
- size: t1,
138
+ size: t0,
78
139
  children,
79
140
  "aria-label": ariaLabel,
80
141
  "aria-labelledby": ariaLabelledBy,
81
- flush: t2,
142
+ flush: t1,
82
143
  className,
83
- gap: t3
84
- } = t0;
85
- const size = t1 === undefined ? "medium" : t1;
86
- const flush = t2 === undefined ? false : t2;
87
- const gap = t3 === undefined ? "condensed" : t3;
144
+ gap: t2
145
+ } = props;
146
+ const size = t0 === undefined ? "medium" : t0;
147
+ const flush = t1 === undefined ? false : t1;
148
+ const gap = t2 === undefined ? "condensed" : t2;
149
+ const listRef = useRef(null);
150
+ const [computedGap, setComputedGap] = useState(ACTIONBAR_ITEM_GAP);
88
151
  const [childRegistry, setChildRegistry] = ActionBarItemsRegistry.useRegistryState();
152
+ const [menuItemIds, setMenuItemIds] = useState(_temp);
153
+ const navRef = useRef(null);
154
+ let t3;
155
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
156
+ t3 = () => {
157
+ if (!listRef.current) {
158
+ return;
159
+ }
160
+ const g = window.getComputedStyle(listRef.current).gap;
161
+ const parsed = parseFloat(g);
162
+ if (!Number.isNaN(parsed)) {
163
+ setComputedGap(parsed);
164
+ }
165
+ };
166
+ $[0] = t3;
167
+ } else {
168
+ t3 = $[0];
169
+ }
89
170
  let t4;
90
- if ($[0] !== childRegistry) {
91
- t4 = childRegistry && Array.from(childRegistry.entries()).filter(_temp);
92
- $[0] = childRegistry;
93
- $[1] = t4;
171
+ if ($[1] !== gap) {
172
+ t4 = [gap];
173
+ $[1] = gap;
174
+ $[2] = t4;
94
175
  } else {
95
- t4 = $[1];
176
+ t4 = $[2];
96
177
  }
97
- const overflowItems = t4;
178
+ useIsomorphicLayoutEffect(t3, t4);
179
+ const moreMenuRef = useRef(null);
98
180
  let t5;
99
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
100
- t5 = {
101
- bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
102
- focusOutBehavior: "wrap",
103
- focusableElementFilter: _temp2
181
+ if ($[3] !== childRegistry || $[4] !== computedGap || $[5] !== menuItemIds.size) {
182
+ t5 = resizeObserverEntries => {
183
+ var _moreMenuRef$current$, _moreMenuRef$current;
184
+ const navWidth = resizeObserverEntries[0].contentRect.width;
185
+ const moreMenuWidth = (_moreMenuRef$current$ = (_moreMenuRef$current = moreMenuRef.current) === null || _moreMenuRef$current === void 0 ? void 0 : _moreMenuRef$current.getBoundingClientRect().width) !== null && _moreMenuRef$current$ !== void 0 ? _moreMenuRef$current$ : 0;
186
+ const hasActiveMenu = menuItemIds.size > 0;
187
+ if (navWidth > 0) {
188
+ const newMenuItemIds = getMenuItems(navWidth, moreMenuWidth, childRegistry, hasActiveMenu, computedGap);
189
+ if (newMenuItemIds) {
190
+ setMenuItemIds(newMenuItemIds);
191
+ }
192
+ }
104
193
  };
105
- $[2] = t5;
194
+ $[3] = childRegistry;
195
+ $[4] = computedGap;
196
+ $[5] = menuItemIds.size;
197
+ $[6] = t5;
106
198
  } else {
107
- t5 = $[2];
199
+ t5 = $[6];
108
200
  }
201
+ useResizeObserver(t5, navRef);
109
202
  let t6;
110
- if ($[3] !== overflowItems) {
111
- t6 = [overflowItems];
112
- $[3] = overflowItems;
113
- $[4] = t6;
203
+ if ($[7] !== menuItemIds) {
204
+ t6 = id => !menuItemIds.has(id);
205
+ $[7] = menuItemIds;
206
+ $[8] = t6;
114
207
  } else {
115
- t6 = $[4];
208
+ t6 = $[8];
116
209
  }
117
- const {
118
- containerRef
119
- } = useFocusZone(t5, t6);
210
+ const isVisibleChild = t6;
120
211
  let t7;
121
- if ($[5] !== size) {
212
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
122
213
  t7 = {
123
- size
214
+ containerRef: listRef,
215
+ bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
216
+ focusOutBehavior: "wrap"
124
217
  };
125
- $[5] = size;
126
- $[6] = t7;
218
+ $[9] = t7;
127
219
  } else {
128
- t7 = $[6];
129
- }
130
- let t8;
131
- if ($[7] !== className) {
132
- t8 = clsx(className, styles.Nav);
133
- $[7] = className;
134
- $[8] = t8;
135
- } else {
136
- t8 = $[8];
137
- }
138
- const t9 = containerRef;
139
- const t10 = overflowItems ? overflowItems.length > 0 : undefined;
140
- let t11;
141
- if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
142
- t11 = /*#__PURE__*/jsx("div", {});
143
- $[9] = t11;
144
- } else {
145
- t11 = $[9];
146
- }
147
- let t12;
148
- if ($[10] !== children || $[11] !== setChildRegistry) {
149
- t12 = /*#__PURE__*/jsxs("div", {
150
- className: styles.OverflowContainer,
151
- children: [t11, /*#__PURE__*/jsx(ActionBarItemsRegistry.Provider, {
152
- setRegistry: setChildRegistry,
153
- children: children
154
- })]
155
- });
156
- $[10] = children;
157
- $[11] = setChildRegistry;
158
- $[12] = t12;
220
+ t7 = $[9];
221
+ }
222
+ useFocusZone(t7);
223
+ let groupedItemsMap;
224
+ if ($[10] !== childRegistry) {
225
+ groupedItemsMap = new Map();
226
+ for (const [key, childProps] of childRegistry !== null && childRegistry !== void 0 ? childRegistry : []) {
227
+ if (childProps.type === "action" && childProps.groupId) {
228
+ const existingGroup = groupedItemsMap.get(childProps.groupId) || [];
229
+ existingGroup.push([key, childProps]);
230
+ groupedItemsMap.set(childProps.groupId, existingGroup);
231
+ }
232
+ }
233
+ $[10] = childRegistry;
234
+ $[11] = groupedItemsMap;
159
235
  } else {
160
- t12 = $[12];
236
+ groupedItemsMap = $[11];
161
237
  }
162
- const t13 = `More ${ariaLabel} items ${overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.length}`;
163
- const t14 = overflowItems !== null && overflowItems !== void 0 && overflowItems.length ? undefined : true;
164
- let t15;
165
- if ($[13] !== size || $[14] !== t13 || $[15] !== t14) {
166
- t15 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
167
- children: /*#__PURE__*/jsx(IconButton, {
168
- variant: "invisible",
169
- "aria-label": t13,
170
- icon: KebabHorizontalIcon,
171
- className: styles.MoreButton,
172
- "data-more-button-inactive": t14,
173
- size: size
174
- })
175
- });
238
+ const groupedItems = groupedItemsMap;
239
+ let t8;
240
+ if ($[12] !== isVisibleChild || $[13] !== size) {
241
+ t8 = {
242
+ size,
243
+ isVisibleChild
244
+ };
245
+ $[12] = isVisibleChild;
176
246
  $[13] = size;
177
- $[14] = t13;
178
- $[15] = t14;
179
- $[16] = t15;
247
+ $[14] = t8;
180
248
  } else {
181
- t15 = $[16];
249
+ t8 = $[14];
182
250
  }
183
- let t16;
184
- if ($[17] !== overflowItems) {
185
- t16 = overflowItems === null || overflowItems === void 0 ? void 0 : overflowItems.map(_temp4);
186
- $[17] = overflowItems;
187
- $[18] = t16;
251
+ let t9;
252
+ if ($[15] !== className) {
253
+ t9 = clsx(className, styles.Nav);
254
+ $[15] = className;
255
+ $[16] = t9;
188
256
  } else {
189
- t16 = $[18];
257
+ t9 = $[16];
190
258
  }
191
- let t17;
192
- if ($[19] !== t16) {
193
- t17 = /*#__PURE__*/jsx(ActionMenu.Overlay, {
194
- children: /*#__PURE__*/jsx(ActionList, {
195
- children: t16
196
- })
259
+ let t10;
260
+ if ($[17] !== children || $[18] !== setChildRegistry) {
261
+ t10 = /*#__PURE__*/jsx(ActionBarItemsRegistry.Provider, {
262
+ setRegistry: setChildRegistry,
263
+ children: children
197
264
  });
198
- $[19] = t16;
199
- $[20] = t17;
265
+ $[17] = children;
266
+ $[18] = setChildRegistry;
267
+ $[19] = t10;
200
268
  } else {
201
- t17 = $[20];
269
+ t10 = $[19];
202
270
  }
203
- let t18;
204
- if ($[21] !== t15 || $[22] !== t17) {
205
- t18 = /*#__PURE__*/jsxs(ActionMenu, {
206
- children: [t15, t17]
271
+ let t11;
272
+ if ($[20] !== ariaLabel || $[21] !== childRegistry || $[22] !== groupedItems || $[23] !== menuItemIds) {
273
+ t11 = menuItemIds.size > 0 && /*#__PURE__*/jsxs(ActionMenu, {
274
+ children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
275
+ children: /*#__PURE__*/jsx(IconButton, {
276
+ variant: "invisible",
277
+ "aria-label": `More ${ariaLabel} items`,
278
+ icon: KebabHorizontalIcon
279
+ })
280
+ }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
281
+ children: /*#__PURE__*/jsx(ActionList, {
282
+ children: Array.from(menuItemIds).map(id_0 => {
283
+ const menuItem = childRegistry === null || childRegistry === void 0 ? void 0 : childRegistry.get(id_0);
284
+ if (!menuItem) {
285
+ return null;
286
+ }
287
+ if (menuItem.type === "divider") {
288
+ return /*#__PURE__*/jsx(ActionList.Divider, {}, id_0);
289
+ } else {
290
+ if (menuItem.type === "action") {
291
+ const {
292
+ onClick,
293
+ icon: Icon,
294
+ label,
295
+ disabled
296
+ } = menuItem;
297
+ return /*#__PURE__*/jsxs(ActionList.Item, {
298
+ onSelect: event => {
299
+ typeof onClick === "function" && onClick(event);
300
+ },
301
+ disabled: disabled,
302
+ children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
303
+ children: /*#__PURE__*/jsx(Icon, {})
304
+ }), label]
305
+ }, label);
306
+ }
307
+ }
308
+ if (menuItem.type === "menu") {
309
+ const menuItems = menuItem.items;
310
+ const {
311
+ icon: Icon_0,
312
+ label: label_0,
313
+ returnFocusRef
314
+ } = menuItem;
315
+ return /*#__PURE__*/jsxs(ActionMenu, {
316
+ children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
317
+ children: /*#__PURE__*/jsxs(ActionList.Item, {
318
+ children: [Icon_0 !== "none" ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
319
+ children: /*#__PURE__*/jsx(Icon_0, {})
320
+ }) : null, label_0]
321
+ })
322
+ }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
323
+ ...(returnFocusRef && {
324
+ returnFocusRef
325
+ }),
326
+ children: /*#__PURE__*/jsx(ActionList, {
327
+ children: menuItems.map(_temp2)
328
+ })
329
+ })]
330
+ }, id_0);
331
+ }
332
+ const groupedMenuItems = groupedItems.get(id_0) || [];
333
+ if (menuItem.type === "group") {
334
+ return /*#__PURE__*/jsx(React.Fragment, {
335
+ children: groupedMenuItems.map(_temp3)
336
+ }, id_0);
337
+ }
338
+ })
339
+ })
340
+ })]
207
341
  });
208
- $[21] = t15;
209
- $[22] = t17;
210
- $[23] = t18;
342
+ $[20] = ariaLabel;
343
+ $[21] = childRegistry;
344
+ $[22] = groupedItems;
345
+ $[23] = menuItemIds;
346
+ $[24] = t11;
211
347
  } else {
212
- t18 = $[23];
348
+ t11 = $[24];
213
349
  }
214
- let t19;
215
- if ($[24] !== ariaLabel || $[25] !== ariaLabelledBy || $[26] !== gap || $[27] !== size || $[28] !== t10 || $[29] !== t12 || $[30] !== t18 || $[31] !== t9) {
216
- t19 = /*#__PURE__*/jsxs("div", {
217
- ref: t9,
350
+ let t12;
351
+ if ($[25] !== ariaLabel || $[26] !== ariaLabelledBy || $[27] !== gap || $[28] !== t10 || $[29] !== t11) {
352
+ t12 = /*#__PURE__*/jsxs("div", {
353
+ ref: listRef,
218
354
  role: "toolbar",
219
355
  className: styles.List,
220
356
  "aria-label": ariaLabel,
221
357
  "aria-labelledby": ariaLabelledBy,
222
358
  "data-gap": gap,
223
- "data-size": size,
224
- "data-has-overflow": t10,
225
- children: [t12, t18]
359
+ children: [t10, t11]
226
360
  });
227
- $[24] = ariaLabel;
228
- $[25] = ariaLabelledBy;
229
- $[26] = gap;
230
- $[27] = size;
361
+ $[25] = ariaLabel;
362
+ $[26] = ariaLabelledBy;
363
+ $[27] = gap;
231
364
  $[28] = t10;
232
- $[29] = t12;
233
- $[30] = t18;
234
- $[31] = t9;
235
- $[32] = t19;
365
+ $[29] = t11;
366
+ $[30] = t12;
236
367
  } else {
237
- t19 = $[32];
368
+ t12 = $[30];
238
369
  }
239
- let t20;
240
- if ($[33] !== flush || $[34] !== t19 || $[35] !== t8) {
241
- t20 = /*#__PURE__*/jsx("div", {
242
- className: t8,
370
+ let t13;
371
+ if ($[31] !== flush || $[32] !== t12 || $[33] !== t9) {
372
+ t13 = /*#__PURE__*/jsx("div", {
373
+ ref: navRef,
374
+ className: t9,
243
375
  "data-component": "ActionBar",
244
376
  "data-flush": flush,
245
- children: t19
377
+ children: t12
246
378
  });
247
- $[33] = flush;
248
- $[34] = t19;
249
- $[35] = t8;
250
- $[36] = t20;
379
+ $[31] = flush;
380
+ $[32] = t12;
381
+ $[33] = t9;
382
+ $[34] = t13;
251
383
  } else {
252
- t20 = $[36];
384
+ t13 = $[34];
253
385
  }
254
- let t21;
255
- if ($[37] !== t20 || $[38] !== t7) {
256
- t21 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
257
- value: t7,
258
- children: t20
386
+ let t14;
387
+ if ($[35] !== t13 || $[36] !== t8) {
388
+ t14 = /*#__PURE__*/jsx(ActionBarContext.Provider, {
389
+ value: t8,
390
+ children: t13
259
391
  });
260
- $[37] = t20;
261
- $[38] = t7;
262
- $[39] = t21;
392
+ $[35] = t13;
393
+ $[36] = t8;
394
+ $[37] = t14;
263
395
  } else {
264
- t21 = $[39];
396
+ t14 = $[37];
265
397
  }
266
- return t21;
398
+ return t14;
267
399
  };
268
- function useActionBarItem(ref, registryProps) {
269
- var _useContext;
270
- const $ = c(8);
271
- const isGroupOverflowing = (_useContext = useContext(ActionBarGroupContext)) === null || _useContext === void 0 ? void 0 : _useContext.isOverflowing;
272
- const isInGroup = isGroupOverflowing !== undefined;
400
+ function useWidth(ref) {
401
+ const $ = c(3);
402
+ const [width, setWidth] = useState(-1);
273
403
  let t0;
274
- if ($[0] !== isInGroup || $[1] !== ref) {
275
- t0 = onChange => {
276
- if (isInGroup) {
277
- return _temp5;
278
- }
279
- const observer = new IntersectionObserver(() => onChange(), {
280
- threshold: 1
281
- });
282
- if (ref.current) {
283
- observer.observe(ref.current);
284
- }
285
- return () => observer.disconnect();
286
- };
287
- $[0] = isInGroup;
288
- $[1] = ref;
289
- $[2] = t0;
290
- } else {
291
- t0 = $[2];
292
- }
293
- const subscribeIntersectionObserver = t0;
294
404
  let t1;
295
- if ($[3] !== ref) {
296
- t1 = () => ref.current ? ref.current.offsetTop > 0 : false;
297
- $[3] = ref;
298
- $[4] = t1;
299
- } else {
300
- t1 = $[4];
301
- }
302
- const isItemOverflowing = useSyncExternalStore(subscribeIntersectionObserver, t1, _temp6);
303
- const isOverflowing = isGroupOverflowing || isItemOverflowing;
304
- ActionBarItemsRegistry.useRegisterDescendant(isOverflowing ? registryProps : null);
305
- const t2 = isOverflowing ? "" : undefined;
306
- let t3;
307
- if ($[5] !== isOverflowing || $[6] !== t2) {
308
- t3 = {
309
- isOverflowing,
310
- dataOverflowingAttr: t2
405
+ if ($[0] !== ref) {
406
+ t0 = () => {
407
+ var _ref$current$getBound, _ref$current;
408
+ return setWidth((_ref$current$getBound = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect().width) !== null && _ref$current$getBound !== void 0 ? _ref$current$getBound : -1);
311
409
  };
312
- $[5] = isOverflowing;
313
- $[6] = t2;
314
- $[7] = t3;
410
+ t1 = [ref];
411
+ $[0] = ref;
412
+ $[1] = t0;
413
+ $[2] = t1;
315
414
  } else {
316
- t3 = $[7];
415
+ t0 = $[1];
416
+ t1 = $[2];
317
417
  }
318
- return t3;
319
- }
320
- function _temp6() {
321
- return false;
418
+ useIsomorphicLayoutEffect(t0, t1);
419
+ return width;
322
420
  }
323
- function _temp5() {}
324
421
  const ActionBarIconButton = /*#__PURE__*/forwardRef(({
325
422
  disabled,
326
423
  onClick,
@@ -329,36 +426,44 @@ const ActionBarIconButton = /*#__PURE__*/forwardRef(({
329
426
  const ref = useRef(null);
330
427
  useRefObjectAsForwardedRef(forwardedRef, ref);
331
428
  const {
332
- size
429
+ size,
430
+ isVisibleChild
333
431
  } = React.useContext(ActionBarContext);
432
+ const {
433
+ groupId
434
+ } = React.useContext(ActionBarGroupContext);
435
+ const width = useWidth(ref);
334
436
  const {
335
437
  ['aria-label']: ariaLabel,
336
438
  icon
337
439
  } = props;
338
- const {
339
- dataOverflowingAttr
340
- } = useActionBarItem(ref, useMemo(() => ({
440
+ const registryProps = useMemo(() => ({
341
441
  type: 'action',
342
442
  label: ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : '',
343
443
  icon,
344
444
  disabled: !!disabled,
345
- onClick: onClick
346
- }), [ariaLabel, icon, disabled, onClick]));
445
+ onClick: onClick,
446
+ width,
447
+ groupId: groupId !== null && groupId !== void 0 ? groupId : undefined
448
+ }), [ariaLabel, icon, disabled, onClick, groupId, width]);
449
+ const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
347
450
  const clickHandler = useCallback(event => {
348
451
  if (disabled) return;
349
452
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
350
453
  }, [disabled, onClick]);
454
+ if (!isVisibleChild(id) || groupId && !isVisibleChild(groupId)) return null;
351
455
  return /*#__PURE__*/jsx(IconButton, {
352
456
  "aria-disabled": disabled,
353
457
  ref: ref,
354
458
  size: size,
355
459
  onClick: clickHandler,
356
460
  ...props,
357
- variant: "invisible",
358
- "data-overflowing": dataOverflowingAttr
461
+ variant: "invisible"
359
462
  });
360
463
  });
361
- const ActionBarGroupContext = /*#__PURE__*/React.createContext(null);
464
+ const ActionBarGroupContext = /*#__PURE__*/React.createContext({
465
+ groupId: null
466
+ });
362
467
  const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
363
468
  const $ = c(10);
364
469
  const {
@@ -366,40 +471,39 @@ const ActionBarGroup = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
366
471
  } = t0;
367
472
  const backupRef = useRef(null);
368
473
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
474
+ const width = useWidth(ref);
369
475
  let t1;
370
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
476
+ if ($[0] !== width) {
371
477
  t1 = {
372
- type: "group"
478
+ type: "group",
479
+ width
373
480
  };
374
- $[0] = t1;
481
+ $[0] = width;
482
+ $[1] = t1;
375
483
  } else {
376
- t1 = $[0];
484
+ t1 = $[1];
377
485
  }
378
- const {
379
- dataOverflowingAttr,
380
- isOverflowing
381
- } = useActionBarItem(ref, t1);
486
+ const registryProps = t1;
487
+ const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
382
488
  let t2;
383
- if ($[1] !== isOverflowing) {
489
+ if ($[2] !== id) {
384
490
  t2 = {
385
- isOverflowing
491
+ groupId: id
386
492
  };
387
- $[1] = isOverflowing;
388
- $[2] = t2;
493
+ $[2] = id;
494
+ $[3] = t2;
389
495
  } else {
390
- t2 = $[2];
496
+ t2 = $[3];
391
497
  }
392
498
  let t3;
393
- if ($[3] !== children || $[4] !== dataOverflowingAttr || $[5] !== ref) {
499
+ if ($[4] !== children || $[5] !== ref) {
394
500
  t3 = /*#__PURE__*/jsx("div", {
395
501
  className: styles.Group,
396
502
  "data-component": "ActionBar.Group",
397
503
  ref: ref,
398
- "data-overflowing": dataOverflowingAttr,
399
504
  children: children
400
505
  });
401
- $[3] = children;
402
- $[4] = dataOverflowingAttr;
506
+ $[4] = children;
403
507
  $[5] = ref;
404
508
  $[6] = t3;
405
509
  } else {
@@ -453,12 +557,17 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
453
557
  }
454
558
  const backupRef = useRef(null);
455
559
  const ref = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
560
+ const {
561
+ isVisibleChild
562
+ } = React.useContext(ActionBarContext);
456
563
  const [menuOpen, setMenuOpen] = useState(false);
564
+ const width = useWidth(ref);
457
565
  const t1 = overflowIcon ? overflowIcon : icon;
458
566
  let t2;
459
- if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1) {
567
+ if ($[7] !== ariaLabel || $[8] !== items || $[9] !== returnFocusRef || $[10] !== t1 || $[11] !== width) {
460
568
  t2 = {
461
569
  type: "menu",
570
+ width,
462
571
  label: ariaLabel,
463
572
  icon: t1,
464
573
  returnFocusRef,
@@ -468,27 +577,28 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
468
577
  $[8] = items;
469
578
  $[9] = returnFocusRef;
470
579
  $[10] = t1;
471
- $[11] = t2;
580
+ $[11] = width;
581
+ $[12] = t2;
472
582
  } else {
473
- t2 = $[11];
583
+ t2 = $[12];
584
+ }
585
+ const registryProps = t2;
586
+ const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
587
+ if (!isVisibleChild(id)) {
588
+ return null;
474
589
  }
475
- const {
476
- dataOverflowingAttr
477
- } = useActionBarItem(ref, t2);
478
590
  let t3;
479
- if ($[12] !== ariaLabel || $[13] !== dataOverflowingAttr || $[14] !== icon || $[15] !== props) {
591
+ if ($[13] !== ariaLabel || $[14] !== icon || $[15] !== props) {
480
592
  t3 = /*#__PURE__*/jsx(ActionMenu.Anchor, {
481
593
  children: /*#__PURE__*/jsx(IconButton, {
482
594
  variant: "invisible",
483
595
  "aria-label": ariaLabel,
484
596
  icon: icon,
485
597
  ...props,
486
- "data-overflowing": dataOverflowingAttr,
487
598
  "data-component": "ActionBar.Menu.IconButton"
488
599
  })
489
600
  });
490
- $[12] = ariaLabel;
491
- $[13] = dataOverflowingAttr;
601
+ $[13] = ariaLabel;
492
602
  $[14] = icon;
493
603
  $[15] = props;
494
604
  $[16] = t3;
@@ -507,7 +617,7 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
507
617
  }
508
618
  let t5;
509
619
  if ($[19] !== items) {
510
- t5 = items.map(_temp7);
620
+ t5 = items.map(_temp4);
511
621
  $[19] = items;
512
622
  $[20] = t5;
513
623
  } else {
@@ -556,91 +666,68 @@ const ActionBarMenu = /*#__PURE__*/forwardRef((t0, forwardedRef) => {
556
666
  const VerticalDivider = () => {
557
667
  const $ = c(3);
558
668
  const ref = useRef(null);
669
+ const {
670
+ isVisibleChild
671
+ } = React.useContext(ActionBarContext);
672
+ const width = useWidth(ref);
559
673
  let t0;
560
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
674
+ if ($[0] !== width) {
561
675
  t0 = {
562
- type: "divider"
676
+ type: "divider",
677
+ width
563
678
  };
564
- $[0] = t0;
679
+ $[0] = width;
680
+ $[1] = t0;
565
681
  } else {
566
- t0 = $[0];
682
+ t0 = $[1];
683
+ }
684
+ const registryProps = t0;
685
+ const id = ActionBarItemsRegistry.useRegisterDescendant(registryProps);
686
+ if (!isVisibleChild(id)) {
687
+ return null;
567
688
  }
568
- const {
569
- dataOverflowingAttr
570
- } = useActionBarItem(ref, t0);
571
689
  let t1;
572
- if ($[1] !== dataOverflowingAttr) {
690
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
573
691
  t1 = /*#__PURE__*/jsx("div", {
574
692
  ref: ref,
575
693
  "data-component": "ActionBar.VerticalDivider",
576
694
  "aria-hidden": "true",
577
- className: styles.Divider,
578
- "data-overflowing": dataOverflowingAttr
695
+ className: styles.Divider
579
696
  });
580
- $[1] = dataOverflowingAttr;
581
697
  $[2] = t1;
582
698
  } else {
583
699
  t1 = $[2];
584
700
  }
585
701
  return t1;
586
702
  };
587
- function _temp(entry) {
588
- return entry[1] !== null;
703
+ function _temp() {
704
+ return new Set();
589
705
  }
590
- function _temp2(element) {
591
- return element.matches(FOCUSABLE_ITEM_SELECTOR);
592
- }
593
- function _temp3(item, index) {
706
+ function _temp2(item, index) {
594
707
  return renderMenuItem(item, index);
595
708
  }
596
- function _temp4(t0) {
597
- const [id, menuItem] = t0;
598
- if (menuItem.type === "divider") {
599
- return /*#__PURE__*/jsx(ActionList.Divider, {}, id);
600
- }
601
- if (menuItem.type === "action") {
709
+ function _temp3(t0) {
710
+ const [key_0, childProps_0] = t0;
711
+ if (childProps_0.type === "action") {
602
712
  const {
603
- onClick,
604
- icon: Icon,
605
- label,
606
- disabled
607
- } = menuItem;
713
+ onClick: onClick_0,
714
+ icon: Icon_1,
715
+ label: label_1,
716
+ disabled: disabled_0
717
+ } = childProps_0;
608
718
  return /*#__PURE__*/jsxs(ActionList.Item, {
609
- onSelect: event => {
610
- typeof onClick === "function" && onClick(event);
719
+ onSelect: event_0 => {
720
+ typeof onClick_0 === "function" && onClick_0(event_0);
611
721
  },
612
- disabled: disabled,
722
+ disabled: disabled_0,
613
723
  children: [/*#__PURE__*/jsx(ActionList.LeadingVisual, {
614
- children: /*#__PURE__*/jsx(Icon, {})
615
- }), label]
616
- }, label);
617
- }
618
- if (menuItem.type === "menu") {
619
- const menuItems = menuItem.items;
620
- const {
621
- icon: Icon_0,
622
- label: label_0,
623
- returnFocusRef
624
- } = menuItem;
625
- return /*#__PURE__*/jsxs(ActionMenu, {
626
- children: [/*#__PURE__*/jsx(ActionMenu.Anchor, {
627
- children: /*#__PURE__*/jsxs(ActionList.Item, {
628
- children: [Icon_0 !== "none" ? /*#__PURE__*/jsx(ActionList.LeadingVisual, {
629
- children: /*#__PURE__*/jsx(Icon_0, {})
630
- }) : null, label_0]
631
- })
632
- }), /*#__PURE__*/jsx(ActionMenu.Overlay, {
633
- ...(returnFocusRef && {
634
- returnFocusRef
635
- }),
636
- children: /*#__PURE__*/jsx(ActionList, {
637
- children: menuItems.map(_temp3)
638
- })
639
- })]
640
- }, id);
724
+ children: /*#__PURE__*/jsx(Icon_1, {})
725
+ }), label_1]
726
+ }, key_0);
641
727
  }
728
+ return null;
642
729
  }
643
- function _temp7(item, index) {
730
+ function _temp4(item, index) {
644
731
  return renderMenuItem(item, index);
645
732
  }
646
733
 
@@ -1,5 +1,5 @@
1
- import './ActionBar-3f7b52a3.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>>;
@@ -1,2 +1,2 @@
1
- .prc-AnchoredOverlay-ResponsiveCloseButtonContainer-nuium{position:relative}.prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx{display:none;position:absolute;right:var(--base-size-8,.5rem);top:var(--base-size-8,.5rem)}@media screen and (max-width:calc(48rem - 0.02px)){.prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx{display:inline-grid}}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z{position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline;position-visibility:anchors-visible;position:fixed!important;z-index:100}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[popover]{border:0;inset:auto;margin:0;max-width:none;padding:0}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-bottom]{left:anchor(left);top:calc(anchor(bottom) + var(--base-size-4,.25rem))}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-bottom][data-align=left]{left:auto;right:calc(anchor(right) - var(--anchored-overlay-anchor-offset-left))}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-top]{bottom:anchor(top);left:anchor(left);margin-bottom:var(--base-size-4,.25rem)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-top][data-align=left]{left:auto;right:anchor(right)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-left]{margin-right:var(--base-size-4,.25rem);right:anchor(left);top:var(--anchored-overlay-top-override,anchor(top));position-try-fallbacks:flip-inline,flip-block,flip-start,--outside-left-to-bottom}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-right]{left:anchor(right);margin-left:var(--base-size-4,.25rem);top:var(--anchored-overlay-top-override,anchor(top));position-try-fallbacks:flip-inline,flip-block,flip-start,--outside-right-to-bottom}@position-try --outside-left-to-bottom{margin:0;right:anchor(right);top:calc(anchor(bottom) + var(--base-size-4,.25rem));width:auto}@position-try --outside-right-to-bottom{left:anchor(left);margin:0;top:calc(anchor(bottom) + var(--base-size-4,.25rem));width:auto}
2
- /*# sourceMappingURL=AnchoredOverlay-8dc42f6c.css.map */
1
+ .prc-AnchoredOverlay-ResponsiveCloseButtonContainer-nuium{position:relative}.prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx{display:none;position:absolute;right:var(--base-size-8,.5rem);top:var(--base-size-8,.5rem)}@media screen and (max-width:calc(48rem - 0.02px)){.prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx{display:inline-grid}}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z{position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline;position-visibility:anchors-visible;position:fixed!important;z-index:100}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[popover]{border:0;inset:auto;margin:0;max-width:none;padding:0}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-bottom]{left:anchor(left);top:calc(anchor(bottom) + var(--base-size-4,.25rem))}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-bottom][data-align=left]{left:auto;right:calc(anchor(right) - var(--anchored-overlay-anchor-offset-left))}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-top]{bottom:anchor(top);left:anchor(left);margin-bottom:var(--base-size-4,.25rem)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-top][data-align=left]{left:auto;right:anchor(right)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-left]{margin-right:var(--base-size-4,.25rem);right:anchor(left);top:anchor(top);position-try-fallbacks:flip-inline,flip-block,flip-start,--outside-left-to-bottom}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-right]{left:anchor(right);margin-left:var(--base-size-4,.25rem);top:anchor(top);position-try-fallbacks:flip-inline,flip-block,flip-start,--outside-right-to-bottom}@position-try --outside-left-to-bottom{margin:0;right:anchor(right);top:calc(anchor(bottom) + var(--base-size-4,.25rem));width:auto}@position-try --outside-right-to-bottom{left:anchor(left);margin:0;top:calc(anchor(bottom) + var(--base-size-4,.25rem));width:auto}
2
+ /*# sourceMappingURL=AnchoredOverlay-0c26c5f8.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/AnchoredOverlay/AnchoredOverlay.module.css.js"],"names":[],"mappings":"AAAA,0DACE,iBACF,CAEA,iDAIE,YAAa,CAHb,iBAAkB,CAElB,8BAAyB,CADzB,4BAOF,CAHE,mDANF,iDAOI,mBAEJ,CADE,CAGF,2CACE,oEAGwB,CACxB,mCAAoC,CAEpC,wBAA0B,CAD1B,WA8CF,CA3CE,oDAIE,QAAS,CAHT,UAAW,CACX,QAAS,CAGT,cAAe,CAFf,SAGF,CAEA,qEAGE,iBAAkB,CADlB,oDAOF,CAJE,sFACE,SAAU,CACV,sEACF,CAGF,kEAEE,kBAAmB,CACnB,iBAAkB,CAFlB,uCAQF,CAJE,mFACE,SAAU,CACV,mBACF,CAGF,mEAGE,sCAAgC,CAFhC,kBAAmB,CACnB,eAAgB,CAEhB,iFACF,CAEA,oEACE,kBAAmB,CAEnB,qCAA+B,CAD/B,eAAgB,CAEhB,kFACF,CAGF,uCAGE,QAAS,CAFT,mBAAoB,CACpB,oDAA8C,CAE9C,UACF,CAEA,wCACE,iBAAkB,CAElB,QAAS,CADT,oDAA8C,CAE9C,UACF","file":"AnchoredOverlay-0c26c5f8.css","sourcesContent":[".ResponsiveCloseButtonContainer {\n position: relative;\n}\n\n.ResponsiveCloseButton {\n position: absolute;\n top: var(--base-size-8);\n right: var(--base-size-8);\n display: none;\n\n @media screen and (--viewportRange-narrow) {\n display: inline-grid;\n }\n}\n\n.AnchoredOverlay {\n position-try-fallbacks:\n flip-block,\n flip-inline,\n flip-block flip-inline;\n position-visibility: anchors-visible;\n z-index: 100;\n position: fixed !important;\n\n &[popover] {\n inset: auto;\n margin: 0;\n padding: 0;\n border: 0;\n max-width: none;\n }\n\n &[data-side='outside-bottom'] {\n /* stylelint-disable primer/spacing */\n top: calc(anchor(bottom) + var(--base-size-4));\n left: anchor(left);\n\n &[data-align='left'] {\n left: auto;\n right: calc(anchor(right) - var(--anchored-overlay-anchor-offset-left));\n }\n }\n\n &[data-side='outside-top'] {\n margin-bottom: var(--base-size-4);\n bottom: anchor(top);\n left: anchor(left);\n\n &[data-align='left'] {\n left: auto;\n right: anchor(right);\n }\n }\n\n &[data-side='outside-left'] {\n right: anchor(left);\n top: anchor(top);\n margin-right: var(--base-size-4);\n position-try-fallbacks: flip-inline, flip-block, flip-start, --outside-left-to-bottom;\n }\n\n &[data-side='outside-right'] {\n left: anchor(right);\n top: anchor(top);\n margin-left: var(--base-size-4);\n position-try-fallbacks: flip-inline, flip-block, flip-start, --outside-right-to-bottom;\n }\n}\n\n@position-try --outside-left-to-bottom {\n right: anchor(right);\n top: calc(anchor(bottom) + var(--base-size-4));\n margin: 0;\n width: auto;\n}\n\n@position-try --outside-right-to-bottom {\n left: anchor(left);\n top: calc(anchor(bottom) + var(--base-size-4));\n margin: 0;\n width: auto;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AnchoredOverlay.d.ts","sourceRoot":"","sources":["../../src/AnchoredOverlay/AnchoredOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAmC,KAAK,GAAG,EAAC,MAAM,OAAO,CAAA;AAChE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAA;AAEhE,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAA;AAIhE,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAC,KAAK,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAa,KAAK,eAAe,EAAC,MAAM,WAAW,CAAA;AAO1D,UAAU,8BAA8B;IACtC;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,YAAY,GAAG,iBAAiB,CAAC,EAChG,KAAK,EAAE,CAAC,KACL,GAAG,CAAC,OAAO,CAAA;IAEhB;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAE/C;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,iCAAiC;IACzC;;;OAGG;IACH,YAAY,EAAE,IAAI,CAAA;IAElB;;;OAGG;IACH,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC9C;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,iCAAiC,GACzC,OAAO,CAAC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C,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IAC3C;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAChC;AAED,MAAM,MAAM,oBAAoB,GAAG,wBAAwB,GACzD,CAAC,8BAA8B,GAAG,iCAAiC,CAAC,GACpE,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,MAAM,GAAG,cAAc,GAAG,iBAAiB,GAAG,mBAAmB,CAAC,CAAC,CAAA;AAS9G;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CA2PnF,CAAA"}
@@ -133,51 +133,28 @@ const AnchoredOverlay = ({
133
133
  });
134
134
  const popoverId = useId();
135
135
  const id = popoverId.replaceAll(':', '_'); // popoverId can contain colons which are invalid in CSS custom property names, so we replace them with underscores
136
- const anchorName = `--anchored-overlay-anchor-${id}`;
137
136
 
138
- // Manage `anchor-name` on the anchor independently of `open`/`width` so a
139
- // parent re-render that re-runs the positioning effect below doesn't
140
- // briefly flicker the anchor link off and back on.
141
- useEffect(() => {
142
- if (!cssAnchorPositioning || !anchorElement) return;
143
- if (anchorElement.style.getPropertyValue('anchor-name')) return;
144
- anchorElement.style.setProperty('anchor-name', anchorName);
145
- return () => {
146
- if (anchorElement.style.getPropertyValue('anchor-name') === anchorName) {
147
- anchorElement.style.removeProperty('anchor-name');
148
- }
149
- };
150
- }, [cssAnchorPositioning, anchorElement, anchorName]);
151
137
  useEffect(() => {
152
138
  if (!cssAnchorPositioning || !anchorElement) return;
153
139
  const currentOverlay = overlayRef.current;
154
- const resolvedAnchorName = anchorElement.style.getPropertyValue('anchor-name') || anchorName;
140
+
141
+ // Link the anchor and the overlay (when present) via CSS anchor positioning.
142
+ anchorElement.style.setProperty('anchor-name', `--anchored-overlay-anchor-${id}`);
155
143
  let pendingPositionFrame = null;
156
144
  if (open && currentOverlay) {
157
- currentOverlay.style.setProperty('position-anchor', resolvedAnchorName);
145
+ currentOverlay.style.setProperty('position-anchor', `--anchored-overlay-anchor-${id}`);
158
146
 
159
147
  // Defer the getBoundingClientRect read into a `requestAnimationFrame` so the style write above
160
148
  // does not force a synchronous layout.
161
149
  pendingPositionFrame = requestAnimationFrame(() => {
162
150
  pendingPositionFrame = null;
163
- const fallbackWidth = width ? parseInt(widthMap[width]) : parseInt(widthMap.small);
164
- const result = getDefaultPosition(anchorElement, currentOverlay, fallbackWidth);
151
+ const overlayWidth = width ? parseInt(widthMap[width]) : null;
152
+ const result = getDefaultPosition(anchorElement, overlayWidth);
165
153
  currentOverlay.setAttribute('data-align', result.horizontal);
166
- if (result.suggestedSide) {
167
- currentOverlay.setAttribute('data-side', result.suggestedSide);
168
- }
154
+
155
+ // Apply offset only when viewport is too narrow
169
156
  const offset = result.horizontal === 'left' ? result.leftOffset : result.rightOffset;
170
157
  currentOverlay.style.setProperty(`--anchored-overlay-anchor-offset-${result.horizontal}`, `${offset || 0}px`);
171
-
172
- // Set y-axis offset to prevent overflow if needed.
173
- const settledRect = currentOverlay.getBoundingClientRect();
174
- const overflowBottom = settledRect.bottom - window.innerHeight;
175
- if (overflowBottom > 0) {
176
- const clampedTop = Math.max(0, settledRect.top - overflowBottom - 8);
177
- currentOverlay.style.setProperty('--anchored-overlay-top-override', `${clampedTop}px`);
178
- } else {
179
- currentOverlay.style.removeProperty('--anchored-overlay-top-override');
180
- }
181
158
  });
182
159
 
183
160
  // Only call showPopover when shouldRenderAsPopover is enabled
@@ -193,6 +170,7 @@ const AnchoredOverlay = ({
193
170
  }
194
171
  return () => {
195
172
  if (pendingPositionFrame !== null) cancelAnimationFrame(pendingPositionFrame);
173
+ anchorElement.style.removeProperty('anchor-name');
196
174
  // The overlay may no longer be in the DOM at this point, so we need to check for its presence before trying to update it.
197
175
  if (currentOverlay) {
198
176
  currentOverlay.style.removeProperty('position-anchor');
@@ -279,45 +257,30 @@ const AnchoredOverlay = ({
279
257
  }) : null]
280
258
  });
281
259
  };
282
- function getDefaultPosition(anchorElement, overlayElement, fallbackWidth) {
283
- const anchorRect = anchorElement.getBoundingClientRect();
284
- const overlayRect = overlayElement.getBoundingClientRect();
260
+ function getDefaultPosition(anchorElement, overlayWidth) {
261
+ const rect = anchorElement.getBoundingClientRect();
285
262
  const vw = window.innerWidth;
286
- const vh = window.innerHeight;
287
- const margin = 8;
288
- const overlayWidth = overlayRect.width || fallbackWidth;
289
- const spaceLeft = anchorRect.left;
290
- const spaceRight = vw - anchorRect.right;
263
+ const viewportMargin = 8;
264
+ const spaceLeft = rect.left;
265
+ const spaceRight = vw - rect.right;
291
266
  const horizontal = spaceLeft > spaceRight ? 'left' : 'right';
292
267
 
293
- // Suggest a flip when the overlay is currently overflowing both axes:
294
- // prefer the side of the anchor with enough room, otherwise fall back to
295
- // outside-bottom and let the offsets keep it inside the viewport.
296
- const overflowsX = overlayRect.right > vw || overlayRect.left < 0;
297
- const overflowsY = overlayRect.bottom > vh || overlayRect.top < 0;
298
- let suggestedSide;
299
- if (overflowsX && overflowsY) {
300
- if (spaceLeft >= overlayWidth + margin) {
301
- suggestedSide = 'outside-left';
302
- } else if (spaceRight >= overlayWidth + margin) {
303
- suggestedSide = 'outside-right';
304
- } else {
305
- suggestedSide = 'outside-bottom';
306
- }
268
+ // If there's no explicit overlay width, or either side has enough space
269
+ // to contain the overlay, let CSS position-try-fallbacks handle positioning
270
+ if (!overlayWidth || spaceLeft >= overlayWidth + viewportMargin || spaceRight >= overlayWidth + viewportMargin) {
271
+ return {
272
+ horizontal
273
+ };
307
274
  }
308
275
 
309
- // If the viewport is too narrow to fit the overlay on either side, calculate offsets to prevent overflow.
310
- let leftOffset;
311
- let rightOffset;
312
- if (spaceLeft < overlayWidth + margin && spaceRight < overlayWidth + margin) {
313
- leftOffset = Math.max(0, overlayWidth - anchorRect.right + margin);
314
- rightOffset = Math.max(0, anchorRect.left + overlayWidth - vw + margin);
315
- }
276
+ // If the viewport is too narrow to fit the overlay on either side, calculate offsets to prevent overflow
277
+ // leftOffset is how much to shift the overlay to the right, rightOffset is how much to shift the overlay to the left
278
+ const leftOffset = Math.max(0, overlayWidth - rect.right + viewportMargin);
279
+ const rightOffset = Math.max(0, rect.left + overlayWidth - vw + viewportMargin);
316
280
  return {
317
281
  horizontal,
318
282
  leftOffset,
319
- rightOffset,
320
- suggestedSide
283
+ rightOffset
321
284
  };
322
285
  }
323
286
  function assignRef(ref, value) {
@@ -1,4 +1,4 @@
1
- import './AnchoredOverlay-8dc42f6c.css';
1
+ import './AnchoredOverlay-0c26c5f8.css';
2
2
 
3
3
  var classes = {"ResponsiveCloseButtonContainer":"prc-AnchoredOverlay-ResponsiveCloseButtonContainer-nuium","ResponsiveCloseButton":"prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx","AnchoredOverlay":"prc-AnchoredOverlay-AnchoredOverlay-fYg9Z"};
4
4
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260505150005",
4
+ "version": "0.0.0-20260506133933",
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:flex}.prc-ActionBar-List-9uz46:where([data-size=small]){--actionbar-height:var(--control-small-size,1.75rem)}.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:flex}}.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,#d1d9e0b3);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-3f7b52a3.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,iBA2DF,CA5CE,mDAIE,oDAAiC,CACjC,qCACF,CAGA,kDACE,yBACF,CAEA,mDACE,oDACF,CAEA,oDACE,kDACF,CAEA,mDACE,mDACF,CAGA,iDACE,iBAKF,CAHE,8EACE,kCACF,CAGF,sDACE,iDACF,CAEA,6CAIE,2BACF,CAGF,+CACE,MAEE,yBACF,CACF,CAEA,yBAIE,kBAAmB,CAHnB,YAAa,CAEb,wBAAyB,CADzB,uCAOF,CAHE,kDACE,gBACF,CAIA,oCAME,6CAAoC,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-3f7b52a3.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: flex;\n }\n\n &:where([data-size='small']) {\n --actionbar-height: var(--control-small-size);\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: flex;\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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/AnchoredOverlay/AnchoredOverlay.module.css.js"],"names":[],"mappings":"AAAA,0DACE,iBACF,CAEA,iDAIE,YAAa,CAHb,iBAAkB,CAElB,8BAAyB,CADzB,4BAOF,CAHE,mDANF,iDAOI,mBAEJ,CADE,CAGF,2CACE,oEAGwB,CACxB,mCAAoC,CAEpC,wBAA0B,CAD1B,WAkDF,CA/CE,oDAIE,QAAS,CAHT,UAAW,CACX,QAAS,CAGT,cAAe,CAFf,SAGF,CAEA,qEAGE,iBAAkB,CADlB,oDAOF,CAJE,sFACE,SAAU,CACV,sEACF,CAGF,kEAEE,kBAAmB,CACnB,iBAAkB,CAFlB,uCAQF,CAJE,mFACE,SAAU,CACV,mBACF,CAGF,mEAOE,sCAAgC,CANhC,kBAAmB,CAKnB,oDAAsD,CAEtD,iFACF,CAEA,oEACE,kBAAmB,CAEnB,qCAA+B,CAD/B,oDAAsD,CAEtD,kFACF,CAGF,uCAGE,QAAS,CAFT,mBAAoB,CACpB,oDAA8C,CAE9C,UACF,CAEA,wCACE,iBAAkB,CAElB,QAAS,CADT,oDAA8C,CAE9C,UACF","file":"AnchoredOverlay-8dc42f6c.css","sourcesContent":[".ResponsiveCloseButtonContainer {\n position: relative;\n}\n\n.ResponsiveCloseButton {\n position: absolute;\n top: var(--base-size-8);\n right: var(--base-size-8);\n display: none;\n\n @media screen and (--viewportRange-narrow) {\n display: inline-grid;\n }\n}\n\n.AnchoredOverlay {\n position-try-fallbacks:\n flip-block,\n flip-inline,\n flip-block flip-inline;\n position-visibility: anchors-visible;\n z-index: 100;\n position: fixed !important;\n\n &[popover] {\n inset: auto;\n margin: 0;\n padding: 0;\n border: 0;\n max-width: none;\n }\n\n &[data-side='outside-bottom'] {\n /* stylelint-disable primer/spacing */\n top: calc(anchor(bottom) + var(--base-size-4));\n left: anchor(left);\n\n &[data-align='left'] {\n left: auto;\n right: calc(anchor(right) - var(--anchored-overlay-anchor-offset-left));\n }\n }\n\n &[data-side='outside-top'] {\n margin-bottom: var(--base-size-4);\n bottom: anchor(top);\n left: anchor(left);\n\n &[data-align='left'] {\n left: auto;\n right: anchor(right);\n }\n }\n\n &[data-side='outside-left'] {\n right: anchor(left);\n /* Falls back to `anchor(top)` when JS hasn't overridden it. JS sets the\n override when the overlay's bottom would overflow the viewport so we\n can lift it up to keep the bottom edge on screen, mirroring the JS\n anchored-positioning code path. */\n top: var(--anchored-overlay-top-override, anchor(top));\n margin-right: var(--base-size-4);\n position-try-fallbacks: flip-inline, flip-block, flip-start, --outside-left-to-bottom;\n }\n\n &[data-side='outside-right'] {\n left: anchor(right);\n top: var(--anchored-overlay-top-override, anchor(top));\n margin-left: var(--base-size-4);\n position-try-fallbacks: flip-inline, flip-block, flip-start, --outside-right-to-bottom;\n }\n}\n\n@position-try --outside-left-to-bottom {\n right: anchor(right);\n top: calc(anchor(bottom) + var(--base-size-4));\n margin: 0;\n width: auto;\n}\n\n@position-try --outside-right-to-bottom {\n left: anchor(left);\n top: calc(anchor(bottom) + var(--base-size-4));\n margin: 0;\n width: auto;\n}\n"]}