@primer/react 38.22.0 → 38.22.1-rc.6d999c4d8

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,5 +1,11 @@
1
1
  # @primer/react
2
2
 
3
+ ## 38.22.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#7802](https://github.com/primer/react/pull/7802) [`872bf46`](https://github.com/primer/react/commit/872bf464c0cdf2144b680ffe309ef4ad2ac1b5ac) 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)
8
+
3
9
  ## 38.22.0
4
10
 
5
11
  ### Minor Changes
@@ -14,7 +14,7 @@ type LinkProps = {
14
14
  className?: string;
15
15
  };
16
16
  export type ActionListLinkItemProps = Pick<ActionListItemProps, 'active' | 'children' | 'inactiveText' | 'variant' | 'size'> & LinkProps;
17
- declare const LinkItemComponent: <As extends React.ElementType = "a">(props: (React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & Pick<ActionListItemProps, "children" | "size" | "active" | "variant" | "inactiveText"> & LinkProps extends infer T ? T extends React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & Pick<ActionListItemProps, "children" | "size" | "active" | "variant" | "inactiveText"> & LinkProps ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
17
+ declare const LinkItemComponent: <As extends React.ElementType = "a">(props: (React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & Pick<ActionListItemProps, "active" | "children" | "inactiveText" | "size" | "variant"> & LinkProps extends infer T ? T extends React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & Pick<ActionListItemProps, "active" | "children" | "inactiveText" | "size" | "variant"> & LinkProps ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
18
18
  as?: As | undefined;
19
19
  } & React.RefAttributes<unknown>) => React.ReactNode;
20
20
  export declare const LinkItem: WithSlotMarker<typeof LinkItemComponent>;
@@ -84,7 +84,7 @@ export declare const ActionList: (<As extends React.ElementType = "ul">(props: (
84
84
  __SLOT__: symbol;
85
85
  };
86
86
  /** A `Item` that renders a full-size anchor inside ListItem */
87
- LinkItem: import("../utils/types").WithSlotMarker<(<As extends React.ElementType = "a">(props: (import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<import("./shared").ActionListItemProps, "children" | "size" | "active" | "variant" | "inactiveText"> & {
87
+ LinkItem: import("../utils/types").WithSlotMarker<(<As extends React.ElementType = "a">(props: (import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<import("./shared").ActionListItemProps, "active" | "children" | "inactiveText" | "size" | "variant"> & {
88
88
  download?: string;
89
89
  href?: string;
90
90
  hrefLang?: string;
@@ -95,7 +95,7 @@ export declare const ActionList: (<As extends React.ElementType = "ul">(props: (
95
95
  type?: string;
96
96
  referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>["referrerPolicy"];
97
97
  className?: string;
98
- } extends infer T ? T extends import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<import("./shared").ActionListItemProps, "children" | "size" | "active" | "variant" | "inactiveText"> & {
98
+ } extends infer T ? T extends import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<import("./shared").ActionListItemProps, "active" | "children" | "inactiveText" | "size" | "variant"> & {
99
99
  download?: string;
100
100
  href?: string;
101
101
  hrefLang?: string;
@@ -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: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 */
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-ec9e15fc.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,WAsDF,CAnDE,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,mEAWE,sCAAgC,CAVhC,kBAAmB,CASnB,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-ec9e15fc.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\n This override only applies when CSS cannot find space using the default position -\n or any of its defined fallbacks.\n */\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"]}
@@ -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,KAC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AO,CAAC,qBAAqB,CAAC,CAAA;IAElD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,YAAY,CAAC,CAAA;IAChE;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,EAAC,QAAQ,EAAC,EAAE;QAAC,QAAQ,EAAE,cAAc,CAAA;KAAC,KAAK,IAAI,CAAA;IACnE;;OAEG;IACH,kBAAkB,CAAC,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,CAmRnF,CAAA"}
@@ -133,28 +133,51 @@ 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}`;
136
137
 
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]);
137
151
  useEffect(() => {
138
152
  if (!cssAnchorPositioning || !anchorElement) return;
139
153
  const currentOverlay = overlayRef.current;
140
-
141
- // Link the anchor and the overlay (when present) via CSS anchor positioning.
142
- anchorElement.style.setProperty('anchor-name', `--anchored-overlay-anchor-${id}`);
154
+ const resolvedAnchorName = anchorElement.style.getPropertyValue('anchor-name') || anchorName;
143
155
  let pendingPositionFrame = null;
144
156
  if (open && currentOverlay) {
145
- currentOverlay.style.setProperty('position-anchor', `--anchored-overlay-anchor-${id}`);
157
+ currentOverlay.style.setProperty('position-anchor', resolvedAnchorName);
146
158
 
147
159
  // Defer the getBoundingClientRect read into a `requestAnimationFrame` so the style write above
148
160
  // does not force a synchronous layout.
149
161
  pendingPositionFrame = requestAnimationFrame(() => {
150
162
  pendingPositionFrame = null;
151
- const overlayWidth = width ? parseInt(widthMap[width]) : null;
152
- const result = getDefaultPosition(anchorElement, overlayWidth);
163
+ const fallbackWidth = width ? parseInt(widthMap[width]) : parseInt(widthMap.small);
164
+ const result = getDefaultPosition(anchorElement, currentOverlay, fallbackWidth);
153
165
  currentOverlay.setAttribute('data-align', result.horizontal);
154
-
155
- // Apply offset only when viewport is too narrow
166
+ if (result.suggestedSide) {
167
+ currentOverlay.setAttribute('data-side', result.suggestedSide);
168
+ }
156
169
  const offset = result.horizontal === 'left' ? result.leftOffset : result.rightOffset;
157
170
  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
+ }
158
181
  });
159
182
 
160
183
  // Only call showPopover when shouldRenderAsPopover is enabled
@@ -170,7 +193,6 @@ const AnchoredOverlay = ({
170
193
  }
171
194
  return () => {
172
195
  if (pendingPositionFrame !== null) cancelAnimationFrame(pendingPositionFrame);
173
- anchorElement.style.removeProperty('anchor-name');
174
196
  // 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.
175
197
  if (currentOverlay) {
176
198
  currentOverlay.style.removeProperty('position-anchor');
@@ -257,30 +279,45 @@ const AnchoredOverlay = ({
257
279
  }) : null]
258
280
  });
259
281
  };
260
- function getDefaultPosition(anchorElement, overlayWidth) {
261
- const rect = anchorElement.getBoundingClientRect();
282
+ function getDefaultPosition(anchorElement, overlayElement, fallbackWidth) {
283
+ const anchorRect = anchorElement.getBoundingClientRect();
284
+ const overlayRect = overlayElement.getBoundingClientRect();
262
285
  const vw = window.innerWidth;
263
- const viewportMargin = 8;
264
- const spaceLeft = rect.left;
265
- const spaceRight = vw - rect.right;
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;
266
291
  const horizontal = spaceLeft > spaceRight ? 'left' : 'right';
267
292
 
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
- };
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
+ }
274
307
  }
275
308
 
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);
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
+ }
280
316
  return {
281
317
  horizontal,
282
318
  leftOffset,
283
- rightOffset
319
+ rightOffset,
320
+ suggestedSide
284
321
  };
285
322
  }
286
323
  function assignRef(ref, value) {
@@ -1,4 +1,4 @@
1
- import './AnchoredOverlay-0c26c5f8.css';
1
+ import './AnchoredOverlay-ec9e15fc.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
 
@@ -28,7 +28,7 @@ declare const _default: React.FC<React.PropsWithChildren<{
28
28
  } | null>;
29
29
  Input: import("../utils/polymorphic").ForwardRefComponent<import("../utils/polymorphic").ForwardRefComponent<"input", import("..").TextInputProps> & {
30
30
  __SLOT__: symbol;
31
- Action: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "size" | "aria-label" | "tooltipDirection"> & {
31
+ Action: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "aria-label" | "size" | "tooltipDirection"> & {
32
32
  children?: React.ReactNode;
33
33
  "aria-label"?: string;
34
34
  tooltipDirection?: "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
@@ -7,7 +7,7 @@ export declare function transition(direction: Exclude<SortDirection, 'NONE'>): E
7
7
  /**
8
8
  * A sort strategy for comparing any two values
9
9
  */
10
- export declare function basic<T>(a: T, b: T): 1 | 0 | -1;
10
+ export declare function basic<T>(a: T, b: T): -1 | 0 | 1;
11
11
  /**
12
12
  * A sort strategy for comparing two `Date` values. Also includes support for
13
13
  * values from `Date.now()`
@@ -37,7 +37,7 @@ export type TextInputNonPassthroughProps = {
37
37
  export type TextInputProps = Merge<React.ComponentPropsWithoutRef<'input'>, TextInputNonPassthroughProps>;
38
38
  declare const _default: PolymorphicForwardRefComponent<"input", TextInputProps> & {
39
39
  __SLOT__: symbol;
40
- Action: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "size" | "aria-label" | "tooltipDirection"> & {
40
+ Action: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "aria-label" | "size" | "tooltipDirection"> & {
41
41
  children?: React.ReactNode;
42
42
  "aria-label"?: string;
43
43
  tooltipDirection?: "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
@@ -48,11 +48,11 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<{
48
48
  * The array of tokens to render
49
49
  */
50
50
  tokens: any[] | (Omit<(Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> & {
51
- ref?: ((instance: HTMLAnchorElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLAnchorElement> | null | undefined;
51
+ ref?: RefObject<HTMLAnchorElement> | ((instance: HTMLAnchorElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
52
52
  }) | (Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
53
- ref?: ((instance: HTMLButtonElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLButtonElement> | null | undefined;
53
+ ref?: RefObject<HTMLButtonElement> | ((instance: HTMLButtonElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
54
54
  }) | (Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
55
- ref?: ((instance: HTMLSpanElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLSpanElement> | null | undefined;
55
+ ref?: RefObject<HTMLSpanElement> | ((instance: HTMLSpanElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
56
56
  }), keyof import("..").TokenProps> & import("..").TokenProps & {
57
57
  as?: "a" | "button" | "span" | undefined;
58
58
  })[];
@@ -10,10 +10,10 @@ declare const data: {
10
10
  login: string;
11
11
  recommended: boolean;
12
12
  } | {
13
+ recommended?: undefined;
13
14
  id: string;
14
15
  name: string;
15
16
  login: string;
16
- recommended?: undefined;
17
17
  })[];
18
18
  labels: ({
19
19
  color: string;
@@ -38,18 +38,18 @@ declare const data: {
38
38
  name: string;
39
39
  trailingInfo: string;
40
40
  } | {
41
+ trailingInfo?: undefined;
41
42
  id: string;
42
43
  name: string;
43
- trailingInfo?: undefined;
44
44
  })[];
45
45
  tags: ({
46
46
  id: string;
47
47
  name: string;
48
48
  trailingInfo: string;
49
49
  } | {
50
+ trailingInfo?: undefined;
50
51
  id: string;
51
52
  name: string;
52
- trailingInfo?: undefined;
53
53
  })[];
54
54
  repos: {
55
55
  org: string;
@@ -9,7 +9,7 @@
9
9
  * This is adapted almost directly from https://beta.reactjs.org/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
10
10
  */
11
11
  export declare const useSyncedState: <T>(initialValue: T | (() => T), { isPropUpdateDisabled, isEqual }?: {
12
- isPropUpdateDisabled?: boolean | undefined;
13
12
  isEqual?: ((value1: any, value2: any) => boolean) | undefined;
13
+ isPropUpdateDisabled?: boolean | undefined;
14
14
  }) => readonly [T, import("react").Dispatch<import("react").SetStateAction<T>>];
15
15
  //# sourceMappingURL=useSyncedState.d.ts.map
@@ -16,7 +16,7 @@ export type TextInputActionProps = Omit<React.ButtonHTMLAttributes<HTMLButtonEle
16
16
  */
17
17
  variant?: ButtonProps['variant'];
18
18
  };
19
- declare const TextInputAction: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "size" | "aria-label" | "tooltipDirection"> & {
19
+ declare const TextInputAction: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "aria-label" | "size" | "tooltipDirection"> & {
20
20
  /** @deprecated Text input action buttons should only use icon buttons */
21
21
  children?: React.ReactNode;
22
22
  /** Text that appears in a tooltip. If an icon is passed, this is also used as the label used by assistive technologies. */
package/dist/theme.d.ts CHANGED
@@ -29,7 +29,7 @@ declare const theme: {
29
29
  xlarge: string;
30
30
  };
31
31
  space: string[];
32
- colorSchemes: Record<"light" | "light_high_contrast" | "light_colorblind" | "light_tritanopia" | "dark" | "dark_dimmed" | "dark_high_contrast" | "dark_colorblind" | "dark_tritanopia", {
32
+ colorSchemes: Record<"dark" | "dark_colorblind" | "dark_dimmed" | "dark_high_contrast" | "dark_tritanopia" | "light" | "light_colorblind" | "light_high_contrast" | "light_tritanopia", {
33
33
  colors: Partial<{
34
34
  colors: {
35
35
  canvasDefaultTransparent: string;
@@ -1,4 +1,4 @@
1
- import { useEffect } from 'react';
2
- declare const useIsomorphicLayoutEffect: typeof useEffect;
1
+ import { useLayoutEffect } from 'react';
2
+ declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
3
3
  export default useIsomorphicLayoutEffect;
4
4
  //# sourceMappingURL=useIsomorphicLayoutEffect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../src/utils/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAkB,MAAM,OAAO,CAAA;AAEhD,QAAA,MAAM,yBAAyB,kBAOhB,CAAA;AAEf,eAAe,yBAAyB,CAAA"}
1
+ {"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../src/utils/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,eAAe,EAAC,MAAM,OAAO,CAAA;AAEhD,QAAA,MAAM,yBAAyB,wBAOhB,CAAA;AAEf,eAAe,yBAAyB,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "38.22.0",
4
+ "version": "38.22.1-rc.6d999c4d8",
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",
@@ -178,7 +178,7 @@
178
178
  "ts-toolbelt": "9.6.0",
179
179
  "tsx": "4.20.3",
180
180
  "typed-css-modules": "^0.9.1",
181
- "typescript": "^5.9.2",
181
+ "typescript": "^6.0.3",
182
182
  "typescript-plugin-css-modules": "^5.2.0",
183
183
  "unist-util-find": "3.0.0",
184
184
  "unist-util-find-before": "4.0.0",
@@ -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,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"]}