@primer/react 0.0.0-20260518154353 → 0.0.0-20260519124320

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,6 +1,6 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260518154353
3
+ ## 0.0.0-20260519124320
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -24,6 +24,8 @@
24
24
 
25
25
  - [#7776](https://github.com/primer/react/pull/7776) [`d6f61c1`](https://github.com/primer/react/commit/d6f61c1e197b52eb75cff97299bfac4caedcc1ac) Thanks [@llastflowers](https://github.com/llastflowers)! - Add `data-component` attributes for Blankslate, BranchName, Breadcrumbs, ButtonGroup, Checkbox, CheckboxGroup, CircleBadge, ConfirmationDialog, CounterLabel, and Dialog to provide stable selectors.
26
26
 
27
+ - [#7852](https://github.com/primer/react/pull/7852) [`8966e0d`](https://github.com/primer/react/commit/8966e0dddd591fa83cc89b962ec1a6d8c0faa875) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Card: Add `data-component` attributes to `Card` and its subcomponents (`Icon`, `Image`, `Heading`, `Description`, `Metadata`, `Menu`). `Card` now requires `children`. Also improves docs and stories.
28
+
27
29
  - [#7816](https://github.com/primer/react/pull/7816) [`aef8548`](https://github.com/primer/react/commit/aef85486a77a544ab36fcc18470dc06bf2502b09) Thanks [@iansan5653](https://github.com/iansan5653)! - Replace `ActionBar` overflow calculations with CSS wrapping approach to improve performance and stability
28
30
 
29
31
  - [#7831](https://github.com/primer/react/pull/7831) [`0de97c2`](https://github.com/primer/react/commit/0de97c25ae2adb026b04f7cac46463779ff023a1) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Dialog: Support custom width values.
@@ -0,0 +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-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,4 +1,4 @@
1
- import './AnchoredOverlay-efecedd0.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
 
@@ -1 +1 @@
1
- {"version":3,"file":"AutocompleteOverlay.d.ts","sourceRoot":"","sources":["../../src/Autocomplete/AutocompleteOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAQlD,KAAK,gCAAgC,GAAG;IACtC;;OAEG;IAC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,gCAAgC,4BAwDlC;kBA9DQ,mBAAmB;;;;AAkE5B,MAAM,MAAM,wBAAwB,GAAG,cAAc,CAAC,OAAO,mBAAmB,CAAC,CAAA;AACjF,eAAe,mBAAmB,CAAA"}
@@ -1,5 +1,4 @@
1
1
  import { useContext, useRef, useEffect, useCallback } from 'react';
2
- import { useCSSAnchorPositioning } from '../hooks/useCSSAnchorPositioning.js';
3
2
  import { AutocompleteContext } from './AutocompleteContext.js';
4
3
  import { useMergedRefs } from '../hooks/useMergedRefs.js';
5
4
  import VisuallyHidden from '../_VisuallyHidden.js';
@@ -41,22 +40,13 @@ function AutocompleteOverlay({
41
40
  const tokensRoot = (_tokensContainer$pare = tokensContainer === null || tokensContainer === void 0 ? void 0 : tokensContainer.parentElement) !== null && _tokensContainer$pare !== void 0 ? _tokensContainer$pare : null;
42
41
  computedAnchorRef.current = (_ref = explicit !== null && explicit !== void 0 ? explicit : tokensRoot) !== null && _ref !== void 0 ? _ref : inputRef.current;
43
42
  }, [menuAnchorRef, inputRef]);
44
- const {
45
- enabled: cssAnchorPositioning
46
- } = useCSSAnchorPositioning({
47
- anchorElementRef: computedAnchorRef,
48
- floatingElementRef: scrollContainerRef,
49
- open: showMenu
50
- });
51
43
  const {
52
44
  floatingElementRef,
53
45
  position
54
46
  } = useAnchoredPosition({
55
47
  side: 'outside-bottom',
56
48
  align: 'start',
57
- anchorElementRef: computedAnchorRef,
58
- floatingElementRef: scrollContainerRef,
59
- enabled: !cssAnchorPositioning
49
+ anchorElementRef: computedAnchorRef
60
50
  }, [showMenu, selectedItemLength]);
61
51
  const mergedScrollContainerRef = useMergedRefs(scrollContainerRef, floatingElementRef);
62
52
  const closeOptionList = useCallback(() => {
@@ -71,12 +61,9 @@ function AutocompleteOverlay({
71
61
  onClickOutside: closeOptionList,
72
62
  onEscape: closeOptionList,
73
63
  ref: mergedScrollContainerRef,
74
- top: cssAnchorPositioning ? undefined : position === null || position === void 0 ? void 0 : position.top,
75
- left: cssAnchorPositioning ? undefined : position === null || position === void 0 ? void 0 : position.left,
76
- visibility: cssAnchorPositioning || position ? 'visible' : 'hidden',
64
+ top: position === null || position === void 0 ? void 0 : position.top,
65
+ left: position === null || position === void 0 ? void 0 : position.left,
77
66
  className: clsx(classes.Overlay, className),
78
- "data-side": cssAnchorPositioning ? 'outside-bottom' : undefined,
79
- "data-anchor-position": cssAnchorPositioning ? true : undefined,
80
67
  ...overlayProps,
81
68
  children: children
82
69
  }) :
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export type CardProps = React.ComponentPropsWithoutRef<'div'> & {
2
+ export type CardProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> & {
3
3
  /**
4
4
  * Provide an optional className to add to the outermost element rendered by
5
5
  * the Card
@@ -15,6 +15,15 @@ export type CardProps = React.ComponentPropsWithoutRef<'div'> & {
15
15
  * @default 'large'
16
16
  */
17
17
  borderRadius?: 'medium' | 'large';
18
+ /**
19
+ * The contents of the card. Provide either `Card.*` subcomponents (for
20
+ * example `Card.Heading`, `Card.Description`, `Card.Metadata`) or any
21
+ * custom content.
22
+ *
23
+ * A card with no children will not render — at least one meaningful
24
+ * child is required.
25
+ */
26
+ children: React.ReactNode;
18
27
  };
19
28
  type HeadingLevel = 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
20
29
  type HeadingProps = React.ComponentPropsWithoutRef<'h3'> & {
@@ -25,6 +34,10 @@ type HeadingProps = React.ComponentPropsWithoutRef<'h3'> & {
25
34
  children: React.ReactNode;
26
35
  };
27
36
  type DescriptionProps = React.ComponentPropsWithoutRef<'p'> & {
37
+ /**
38
+ * The descriptive text for the card. Rendered inside a `<p>` element so
39
+ * should be flowing text content.
40
+ */
28
41
  children: React.ReactNode;
29
42
  };
30
43
  type IconProps = {
@@ -49,12 +62,25 @@ type ImageProps = React.ComponentPropsWithoutRef<'img'> & {
49
62
  alt?: string;
50
63
  };
51
64
  type MenuProps = {
65
+ /**
66
+ * The interactive control(s) to render in the top-right corner of the card,
67
+ * typically a single `IconButton` or `ActionMenu` trigger. When a card
68
+ * contains a menu, make sure the control's accessible name includes enough
69
+ * context to distinguish it from other cards (for example,
70
+ * `Options for Project Alpha` rather than just `Options`).
71
+ */
52
72
  children: React.ReactNode;
53
73
  };
54
74
  type MetadataProps = React.ComponentPropsWithoutRef<'div'> & {
75
+ /**
76
+ * The metadata content to render at the bottom of the card. Accepts any
77
+ * content, including plain text, icons, and other Primer components (for
78
+ * example a `Label`, `Octicon`, or any combination). Avoid using
79
+ * `RelativeTime` until its outstanding accessibility issues are resolved.
80
+ */
55
81
  children: React.ReactNode;
56
82
  };
57
- declare const CardImpl: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
83
+ declare const CardImpl: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children"> & {
58
84
  /**
59
85
  * Provide an optional className to add to the outermost element rendered by
60
86
  * the Card
@@ -70,6 +96,15 @@ declare const CardImpl: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLP
70
96
  * @default 'large'
71
97
  */
72
98
  borderRadius?: "medium" | "large";
99
+ /**
100
+ * The contents of the card. Provide either `Card.*` subcomponents (for
101
+ * example `Card.Heading`, `Card.Description`, `Card.Metadata`) or any
102
+ * custom content.
103
+ *
104
+ * A card with no children will not render — at least one meaningful
105
+ * child is required.
106
+ */
107
+ children: React.ReactNode;
73
108
  } & React.RefAttributes<HTMLDivElement>>;
74
109
  declare const CardIcon: {
75
110
  ({ icon: IconComponent, "aria-label": ariaLabel, className }: IconProps): React.JSX.Element;
@@ -87,13 +122,37 @@ declare const CardHeading: React.ForwardRefExoticComponent<Omit<React.DetailedHT
87
122
  children: React.ReactNode;
88
123
  } & React.RefAttributes<HTMLHeadingElement>>;
89
124
  declare const CardDescription: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & {
125
+ /**
126
+ * The descriptive text for the card. Rendered inside a `<p>` element so
127
+ * should be flowing text content.
128
+ */
90
129
  children: React.ReactNode;
91
130
  } & React.RefAttributes<HTMLParagraphElement>>;
131
+ /**
132
+ * Renders an interactive control (or controls) positioned at the top-right
133
+ * corner of the card. `Card.Menu` is intended for a single action trigger
134
+ * such as an `IconButton` or `ActionMenu` anchor.
135
+ *
136
+ * Accessibility:
137
+ * - The trigger's accessible name should include enough context to
138
+ * distinguish it from triggers in other cards (for example,
139
+ * `"More options for Project Alpha"` rather than just `"More options"`),
140
+ * because lists of cards often share identical control labels.
141
+ * - Avoid placing multiple interactive controls inside `Card.Menu`.
142
+ * If a card needs multiple actions, expose them inside an `ActionMenu`
143
+ * overlay so they remain reachable in a predictable focus order.
144
+ */
92
145
  declare const CardMenu: {
93
146
  ({ children }: MenuProps): React.JSX.Element;
94
147
  displayName: string;
95
148
  };
96
149
  declare const CardMetadata: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
150
+ /**
151
+ * The metadata content to render at the bottom of the card. Accepts any
152
+ * content, including plain text, icons, and other Primer components (for
153
+ * example a `Label`, `Octicon`, or any combination). Avoid using
154
+ * `RelativeTime` until its outstanding accessibility issues are resolved.
155
+ */
97
156
  children: React.ReactNode;
98
157
  } & React.RefAttributes<HTMLDivElement>>;
99
158
  export { CardImpl, CardIcon, CardImage, CardHeading, CardDescription, CardMenu, CardMetadata };
@@ -1 +1 @@
1
- {"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/Card/Card.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAGvC,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,GAAG;IAC9D;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,OAAO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AS;;CAYrF,CAAA;AAID,QAAA,MAAM,SAAS;uCAAyC,UAAU;;CAIjE,CAAA;AAID,QAAA,MAAM,WAAW;IAzKf;;OAEG;SACE,YAAY;cACP,KAAK,CAAC,SAAS;4CA8KzB,CAAA;AAEF,QAAA,MAAM,eAAe;IA5KnB;;;OAGG;cACO,KAAK,CAAC,SAAS;8CAiLzB,CAAA;AAEF;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,QAAQ;mBAAgB,SAAS;;CAEtC,CAAA;AAID,QAAA,MAAM,YAAY;IAjKhB;;;;;OAKG;cACO,KAAK,CAAC,SAAS;wCAoKzB,CAAA;AAEF,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAC,CAAA;AAC5F,YAAY,EAAC,YAAY,IAAI,gBAAgB,EAAC,CAAA;AAC9C,YAAY,EAAC,gBAAgB,IAAI,oBAAoB,EAAC,CAAA;AACtD,YAAY,EAAC,SAAS,IAAI,aAAa,EAAC,CAAA;AACxC,YAAY,EAAC,UAAU,IAAI,cAAc,EAAC,CAAA;AAC1C,YAAY,EAAC,SAAS,IAAI,aAAa,EAAC,CAAA;AACxC,YAAY,EAAC,aAAa,IAAI,iBAAiB,EAAC,CAAA"}
package/dist/Card/Card.js CHANGED
@@ -2,10 +2,11 @@ import { c } from 'react-compiler-runtime';
2
2
  import { clsx } from 'clsx';
3
3
  import React, { forwardRef } from 'react';
4
4
  import classes from './Card.module.css.js';
5
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+ import { warning } from '../utils/warning.js';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
7
 
7
8
  const CardImpl = /*#__PURE__*/forwardRef(function Card(t0, ref) {
8
- const $ = c(53);
9
+ const $ = c(55);
9
10
  let children;
10
11
  let className;
11
12
  let rest;
@@ -38,6 +39,7 @@ const CardImpl = /*#__PURE__*/forwardRef(function Card(t0, ref) {
38
39
  let heading;
39
40
  let menu;
40
41
  let metadata;
42
+ let t10;
41
43
  let t3;
42
44
  let t4;
43
45
  let t5;
@@ -46,7 +48,7 @@ const CardImpl = /*#__PURE__*/forwardRef(function Card(t0, ref) {
46
48
  let t8;
47
49
  let t9;
48
50
  if ($[6] !== borderRadius || $[7] !== children || $[8] !== className || $[9] !== padding || $[10] !== ref || $[11] !== rest) {
49
- t9 = Symbol.for("react.early_return_sentinel");
51
+ t10 = Symbol.for("react.early_return_sentinel");
50
52
  bb0: {
51
53
  let icon = null;
52
54
  let image = null;
@@ -84,50 +86,58 @@ const CardImpl = /*#__PURE__*/forwardRef(function Card(t0, ref) {
84
86
  }
85
87
  }
86
88
  const hasSlotChildren = icon || image || heading || description || metadata || menu;
89
+ const isEmpty = !hasSlotChildren && childArray.length === 0;
90
+ process.env.NODE_ENV !== "production" ? warning(isEmpty, "The <Card> component was rendered with no children and will not render. Provide either Card subcomponents (Card.Heading, Card.Description, etc.) or custom content.") : void 0;
91
+ if (isEmpty) {
92
+ t10 = null;
93
+ break bb0;
94
+ }
87
95
  if (!hasSlotChildren) {
88
- let t10;
89
- if ($[23] !== className) {
90
- t10 = clsx(classes.Card, className);
91
- $[23] = className;
92
- $[24] = t10;
96
+ let t11;
97
+ if ($[24] !== className) {
98
+ t11 = clsx(classes.Card, className);
99
+ $[24] = className;
100
+ $[25] = t11;
93
101
  } else {
94
- t10 = $[24];
102
+ t11 = $[25];
95
103
  }
96
- let t11;
97
- if ($[25] !== borderRadius || $[26] !== children || $[27] !== padding || $[28] !== ref || $[29] !== rest || $[30] !== t10) {
98
- t11 = /*#__PURE__*/jsx("div", {
104
+ let t12;
105
+ if ($[26] !== borderRadius || $[27] !== children || $[28] !== padding || $[29] !== ref || $[30] !== rest || $[31] !== t11) {
106
+ t12 = /*#__PURE__*/jsx("div", {
99
107
  ref: ref,
100
- className: t10,
108
+ className: t11,
109
+ "data-component": "Card",
101
110
  "data-padding": padding,
102
111
  "data-border-radius": borderRadius,
103
112
  ...rest,
104
113
  children: children
105
114
  });
106
- $[25] = borderRadius;
107
- $[26] = children;
108
- $[27] = padding;
109
- $[28] = ref;
110
- $[29] = rest;
111
- $[30] = t10;
115
+ $[26] = borderRadius;
116
+ $[27] = children;
117
+ $[28] = padding;
118
+ $[29] = ref;
119
+ $[30] = rest;
112
120
  $[31] = t11;
121
+ $[32] = t12;
113
122
  } else {
114
- t11 = $[31];
123
+ t12 = $[32];
115
124
  }
116
- t9 = t11;
125
+ t10 = t12;
117
126
  break bb0;
118
127
  }
119
128
  t3 = ref;
120
- if ($[32] !== className) {
129
+ if ($[33] !== className) {
121
130
  t4 = clsx(classes.Card, className);
122
- $[32] = className;
123
- $[33] = t4;
131
+ $[33] = className;
132
+ $[34] = t4;
124
133
  } else {
125
- t4 = $[33];
134
+ t4 = $[34];
126
135
  }
127
- t5 = padding;
128
- t6 = borderRadius;
129
- t7 = rest;
130
- t8 = (image || icon) && /*#__PURE__*/jsx("div", {
136
+ t5 = "Card";
137
+ t6 = padding;
138
+ t7 = borderRadius;
139
+ t8 = rest;
140
+ t9 = (image || icon) && /*#__PURE__*/jsx("div", {
131
141
  className: clsx(classes.CardHeader, image && classes.CardHeaderEdgeToEdge),
132
142
  children: image || icon
133
143
  });
@@ -142,98 +152,102 @@ const CardImpl = /*#__PURE__*/forwardRef(function Card(t0, ref) {
142
152
  $[13] = heading;
143
153
  $[14] = menu;
144
154
  $[15] = metadata;
145
- $[16] = t3;
146
- $[17] = t4;
147
- $[18] = t5;
148
- $[19] = t6;
149
- $[20] = t7;
150
- $[21] = t8;
151
- $[22] = t9;
155
+ $[16] = t10;
156
+ $[17] = t3;
157
+ $[18] = t4;
158
+ $[19] = t5;
159
+ $[20] = t6;
160
+ $[21] = t7;
161
+ $[22] = t8;
162
+ $[23] = t9;
152
163
  } else {
153
164
  description = $[12];
154
165
  heading = $[13];
155
166
  menu = $[14];
156
167
  metadata = $[15];
157
- t3 = $[16];
158
- t4 = $[17];
159
- t5 = $[18];
160
- t6 = $[19];
161
- t7 = $[20];
162
- t8 = $[21];
163
- t9 = $[22];
168
+ t10 = $[16];
169
+ t3 = $[17];
170
+ t4 = $[18];
171
+ t5 = $[19];
172
+ t6 = $[20];
173
+ t7 = $[21];
174
+ t8 = $[22];
175
+ t9 = $[23];
164
176
  }
165
- if (t9 !== Symbol.for("react.early_return_sentinel")) {
166
- return t9;
177
+ if (t10 !== Symbol.for("react.early_return_sentinel")) {
178
+ return t10;
167
179
  }
168
- let t10;
169
- if ($[34] !== description || $[35] !== heading) {
170
- t10 = /*#__PURE__*/jsxs("div", {
180
+ let t11;
181
+ if ($[35] !== description || $[36] !== heading) {
182
+ t11 = /*#__PURE__*/jsxs("div", {
171
183
  className: classes.CardContent,
172
184
  children: [heading, description]
173
185
  });
174
- $[34] = description;
175
- $[35] = heading;
176
- $[36] = t10;
186
+ $[35] = description;
187
+ $[36] = heading;
188
+ $[37] = t11;
177
189
  } else {
178
- t10 = $[36];
190
+ t11 = $[37];
179
191
  }
180
- let t11;
181
- if ($[37] !== metadata) {
182
- t11 = metadata ? /*#__PURE__*/jsx("div", {
192
+ let t12;
193
+ if ($[38] !== metadata) {
194
+ t12 = metadata ? /*#__PURE__*/jsx("div", {
183
195
  className: classes.CardMetadataContainer,
184
196
  children: metadata
185
197
  }) : null;
186
- $[37] = metadata;
187
- $[38] = t11;
198
+ $[38] = metadata;
199
+ $[39] = t12;
188
200
  } else {
189
- t11 = $[38];
201
+ t12 = $[39];
190
202
  }
191
- let t12;
192
- if ($[39] !== t10 || $[40] !== t11) {
193
- t12 = /*#__PURE__*/jsxs("div", {
203
+ let t13;
204
+ if ($[40] !== t11 || $[41] !== t12) {
205
+ t13 = /*#__PURE__*/jsxs("div", {
194
206
  className: classes.CardBody,
195
- children: [t10, t11]
207
+ children: [t11, t12]
196
208
  });
197
- $[39] = t10;
198
209
  $[40] = t11;
199
210
  $[41] = t12;
211
+ $[42] = t13;
200
212
  } else {
201
- t12 = $[41];
213
+ t13 = $[42];
202
214
  }
203
- let t13;
204
- if ($[42] !== menu) {
205
- t13 = menu ? /*#__PURE__*/jsx("div", {
215
+ let t14;
216
+ if ($[43] !== menu) {
217
+ t14 = menu ? /*#__PURE__*/jsx("div", {
206
218
  className: classes.CardMenu,
207
219
  children: menu
208
220
  }) : null;
209
- $[42] = menu;
210
- $[43] = t13;
221
+ $[43] = menu;
222
+ $[44] = t14;
211
223
  } else {
212
- t13 = $[43];
224
+ t14 = $[44];
213
225
  }
214
- let t14;
215
- if ($[44] !== t12 || $[45] !== t13 || $[46] !== t3 || $[47] !== t4 || $[48] !== t5 || $[49] !== t6 || $[50] !== t7 || $[51] !== t8) {
216
- t14 = /*#__PURE__*/jsxs("div", {
226
+ let t15;
227
+ if ($[45] !== t13 || $[46] !== t14 || $[47] !== t3 || $[48] !== t4 || $[49] !== t5 || $[50] !== t6 || $[51] !== t7 || $[52] !== t8 || $[53] !== t9) {
228
+ t15 = /*#__PURE__*/jsxs("div", {
217
229
  ref: t3,
218
230
  className: t4,
219
- "data-padding": t5,
220
- "data-border-radius": t6,
221
- ...t7,
222
- children: [t8, t12, t13]
231
+ "data-component": t5,
232
+ "data-padding": t6,
233
+ "data-border-radius": t7,
234
+ ...t8,
235
+ children: [t9, t13, t14]
223
236
  });
224
- $[44] = t12;
225
237
  $[45] = t13;
226
- $[46] = t3;
227
- $[47] = t4;
228
- $[48] = t5;
229
- $[49] = t6;
230
- $[50] = t7;
231
- $[51] = t8;
232
- $[52] = t14;
238
+ $[46] = t14;
239
+ $[47] = t3;
240
+ $[48] = t4;
241
+ $[49] = t5;
242
+ $[50] = t6;
243
+ $[51] = t7;
244
+ $[52] = t8;
245
+ $[53] = t9;
246
+ $[54] = t15;
233
247
  } else {
234
- t14 = $[52];
248
+ t15 = $[54];
235
249
  }
236
- return t14;
250
+ return t15;
237
251
  });
238
252
  const CardIcon = t0 => {
239
253
  const $ = c(10);
@@ -264,6 +278,7 @@ const CardIcon = t0 => {
264
278
  if ($[4] !== ariaLabel || $[5] !== t1 || $[6] !== t2 || $[7] !== t3 || $[8] !== t4) {
265
279
  t5 = /*#__PURE__*/jsx("span", {
266
280
  className: t1,
281
+ "data-component": "Card.Icon",
267
282
  role: t2,
268
283
  "aria-label": ariaLabel,
269
284
  "aria-hidden": t3,
@@ -320,6 +335,7 @@ const CardImage = t0 => {
320
335
  src: src,
321
336
  alt: alt,
322
337
  className: t2,
338
+ "data-component": "Card.Image",
323
339
  ...rest
324
340
  });
325
341
  $[7] = alt;
@@ -371,6 +387,7 @@ const CardHeading = /*#__PURE__*/forwardRef(function CardHeading(t0, ref) {
371
387
  t3 = /*#__PURE__*/jsx(Component, {
372
388
  ref: ref,
373
389
  className: t2,
390
+ "data-component": "Card.Heading",
374
391
  ...rest,
375
392
  children: children
376
393
  });
@@ -418,6 +435,7 @@ const CardDescription = /*#__PURE__*/forwardRef(function CardDescription(t0, ref
418
435
  t2 = /*#__PURE__*/jsx("p", {
419
436
  ref: ref,
420
437
  className: t1,
438
+ "data-component": "Card.Description",
421
439
  ...rest,
422
440
  children: children
423
441
  });
@@ -431,6 +449,21 @@ const CardDescription = /*#__PURE__*/forwardRef(function CardDescription(t0, ref
431
449
  }
432
450
  return t2;
433
451
  });
452
+
453
+ /**
454
+ * Renders an interactive control (or controls) positioned at the top-right
455
+ * corner of the card. `Card.Menu` is intended for a single action trigger
456
+ * such as an `IconButton` or `ActionMenu` anchor.
457
+ *
458
+ * Accessibility:
459
+ * - The trigger's accessible name should include enough context to
460
+ * distinguish it from triggers in other cards (for example,
461
+ * `"More options for Project Alpha"` rather than just `"More options"`),
462
+ * because lists of cards often share identical control labels.
463
+ * - Avoid placing multiple interactive controls inside `Card.Menu`.
464
+ * If a card needs multiple actions, expose them inside an `ActionMenu`
465
+ * overlay so they remain reachable in a predictable focus order.
466
+ */
434
467
  const CardMenu = t0 => {
435
468
  const $ = c(2);
436
469
  const {
@@ -438,7 +471,8 @@ const CardMenu = t0 => {
438
471
  } = t0;
439
472
  let t1;
440
473
  if ($[0] !== children) {
441
- t1 = /*#__PURE__*/jsx(Fragment, {
474
+ t1 = /*#__PURE__*/jsx("div", {
475
+ "data-component": "Card.Menu",
442
476
  children: children
443
477
  });
444
478
  $[0] = children;
@@ -482,6 +516,7 @@ const CardMetadata = /*#__PURE__*/forwardRef(function CardMetadata(t0, ref) {
482
516
  t2 = /*#__PURE__*/jsx("div", {
483
517
  ref: ref,
484
518
  className: t1,
519
+ "data-component": "Card.Metadata",
485
520
  ...rest,
486
521
  children: children
487
522
  });
@@ -1,8 +1,9 @@
1
1
  import type { CardProps, CardIconProps, CardImageProps, CardHeadingProps, CardDescriptionProps, CardMenuProps, CardMetadataProps } from './Card';
2
- declare const Card: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
2
+ declare const Card: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children"> & {
3
3
  className?: string;
4
4
  padding?: "none" | "condensed" | "normal";
5
5
  borderRadius?: "medium" | "large";
6
+ children: React.ReactNode;
6
7
  } & import("react").RefAttributes<HTMLDivElement>> & {
7
8
  Icon: {
8
9
  ({ icon: IconComponent, "aria-label": ariaLabel, className }: CardIconProps): import("react").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Card/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EAClB,MAAM,QAAQ,CAAA;AAEf,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOR,CAAA;AAEF,OAAO,EAAC,IAAI,EAAC,CAAA;AACb,YAAY,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,GAClB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Card/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EAClB,MAAM,QAAQ,CAAA;AAEf,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOR,CAAA;AAEF,OAAO,EAAC,IAAI,EAAC,CAAA;AACb,YAAY,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,GAClB,CAAA"}
@@ -1,2 +1,2 @@
1
- @keyframes prc-Overlay-overlay-appear-JpFey{0%{opacity:0}to{opacity:1}}.prc-Overlay-Overlay-jfs-T{background-color:var(--overlay-bgColor,#fff);border-radius:var(--borderRadius-large,.75rem);box-shadow:var(--shadow-floating-small,0 0 0 1px #d1d9e080,0 6px 12px -3px #25292e0a,0 6px 18px 0 #25292e1f);height:auto;max-height:100vh;max-width:calc(100vw - 2rem);min-width:192px;overflow:auto;position:absolute;width:auto}.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal]),.prc-Overlay-Overlay-jfs-T[data-anchor-position=false]{bottom:var(--bottom,auto);right:var(--right,auto)}@media screen and (max-width:calc(48rem - 0.02px)){[data-responsive=fullscreen]:is(.prc-Overlay-Overlay-jfs-T[data-anchor-position=false],.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal])):not([data-variant]){left:0;top:0}}:is(.prc-Overlay-Overlay-jfs-T[data-anchor-position=false],.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal])):not([data-variant]){left:var(--left,auto);top:var(--top,auto)}.prc-Overlay-Overlay-jfs-T:focus{outline:none}@media (forced-colors:active){.prc-Overlay-Overlay-jfs-T{outline:1px solid transparent}}.prc-Overlay-Overlay-jfs-T:where([data-reflow-container=true]){max-width:calc(100vw - 2rem)}.prc-Overlay-Overlay-jfs-T:where([data-overflow-auto]){overflow:auto}.prc-Overlay-Overlay-jfs-T:where([data-overflow-hidden]){overflow:hidden}.prc-Overlay-Overlay-jfs-T:where([data-overflow-scroll]){overflow:scroll}.prc-Overlay-Overlay-jfs-T:where([data-overflow-visible]){overflow:visible}.prc-Overlay-Overlay-jfs-T:where([data-height-xsmall]){height:192px}.prc-Overlay-Overlay-jfs-T:where([data-height-small]){height:256px}.prc-Overlay-Overlay-jfs-T:where([data-height-medium]){height:320px}.prc-Overlay-Overlay-jfs-T:where([data-height-large]){height:432px}.prc-Overlay-Overlay-jfs-T:where([data-height-xlarge]){height:600px}.prc-Overlay-Overlay-jfs-T:where([data-height-auto]),.prc-Overlay-Overlay-jfs-T:where([data-height-initial]){height:auto}.prc-Overlay-Overlay-jfs-T:where([data-height-fit-content]){height:-moz-fit-content;height:fit-content}.prc-Overlay-Overlay-jfs-T:where([data-max-height-xsmall]){max-height:min(192px,100vh)}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-max-height-xsmall]){max-height:min(192px,100dvh)}}.prc-Overlay-Overlay-jfs-T:where([data-max-height-small]){max-height:min(256px,100vh)}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-max-height-small]){max-height:min(256px,100dvh)}}.prc-Overlay-Overlay-jfs-T:where([data-max-height-medium]){max-height:min(320px,100vh)}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-max-height-medium]){max-height:min(320px,100dvh)}}.prc-Overlay-Overlay-jfs-T:where([data-max-height-large]){max-height:min(432px,100vh)}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-max-height-large]){max-height:min(432px,100dvh)}}.prc-Overlay-Overlay-jfs-T:where([data-max-height-xlarge]){max-height:min(600px,100vh)}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-max-height-xlarge]){max-height:min(600px,100dvh)}}.prc-Overlay-Overlay-jfs-T:where([data-max-height-fit-content]){max-height:-moz-fit-content;max-height:fit-content}.prc-Overlay-Overlay-jfs-T:where([data-width-small]){width:256px}.prc-Overlay-Overlay-jfs-T:where([data-width-medium]){width:320px}.prc-Overlay-Overlay-jfs-T:where([data-width-large]){width:480px}.prc-Overlay-Overlay-jfs-T:where([data-width-xlarge]){width:640px}.prc-Overlay-Overlay-jfs-T:where([data-width-xxlarge]){width:960px}.prc-Overlay-Overlay-jfs-T:where([data-width-auto]){width:auto}.prc-Overlay-Overlay-jfs-T:where([data-max-width-small]){max-width:256px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-medium]){max-width:320px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-large]){max-width:480px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-xlarge]){max-width:640px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-xxlarge]){max-width:960px}.prc-Overlay-Overlay-jfs-T:where([data-visibility-visible]){visibility:visible}.prc-Overlay-Overlay-jfs-T:where([data-visibility-hidden]){visibility:hidden}.prc-Overlay-Overlay-jfs-T[data-anchor-position=true]{position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline;position-visibility:anchors-visible;position:fixed!important}.prc-Overlay-Overlay-jfs-T[data-anchor-position=true][popover]{border:0;inset:auto;margin:0;max-width:none;padding:0}.prc-Overlay-Overlay-jfs-T[data-anchor-position=true][data-side=outside-bottom]{left:anchor(left);top:calc(anchor(bottom) + var(--base-size-4,.25rem))}.prc-Overlay-Overlay-jfs-T[data-anchor-position=true][data-side=outside-top]{bottom:anchor(top);left:anchor(left);margin-bottom:var(--base-size-4,.25rem)}@media screen and (max-width:calc(48rem - 0.02px)){.prc-Overlay-Overlay-jfs-T:where([data-responsive=fullscreen]),.prc-Overlay-Overlay-jfs-T[data-responsive=fullscreen][data-anchor-position=true]{border-radius:unset;height:100vh;left:0;margin:0;max-height:none;max-width:none;padding-bottom:env(safe-area-inset-bottom);position:fixed;top:0;width:100vw}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-responsive=fullscreen]),.prc-Overlay-Overlay-jfs-T[data-responsive=fullscreen][data-anchor-position=true]{height:100dvh}}}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-variant=fullscreen]){height:100dvh}}@media (prefers-reduced-motion:no-preference){.prc-Overlay-Overlay-jfs-T{animation:prc-Overlay-overlay-appear-JpFey .2s cubic-bezier(.33,1,.68,1)}}
2
- /*# sourceMappingURL=Overlay-4e689024.css.map */
1
+ @keyframes prc-Overlay-overlay-appear-JpFey{0%{opacity:0}to{opacity:1}}.prc-Overlay-Overlay-jfs-T{background-color:var(--overlay-bgColor,#fff);border-radius:var(--borderRadius-large,.75rem);box-shadow:var(--shadow-floating-small,0 0 0 1px #d1d9e080,0 6px 12px -3px #25292e0a,0 6px 18px 0 #25292e1f);height:auto;max-height:100vh;max-width:calc(100vw - 2rem);min-width:192px;overflow:auto;position:absolute;width:auto}.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal]),.prc-Overlay-Overlay-jfs-T[data-anchor-position=false]{bottom:var(--bottom,auto);right:var(--right,auto)}@media screen and (max-width:calc(48rem - 0.02px)){[data-responsive=fullscreen]:is(.prc-Overlay-Overlay-jfs-T[data-anchor-position=false],.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal])):not([data-variant]){left:0;top:0}}:is(.prc-Overlay-Overlay-jfs-T[data-anchor-position=false],.prc-Overlay-Overlay-jfs-T:not([data-anchor-position]):not([data-variant=modal])):not([data-variant]){left:var(--left,auto);top:var(--top,auto)}.prc-Overlay-Overlay-jfs-T:focus{outline:none}@media (forced-colors:active){.prc-Overlay-Overlay-jfs-T{outline:1px solid transparent}}.prc-Overlay-Overlay-jfs-T:where([data-reflow-container=true]){max-width:calc(100vw - 2rem)}.prc-Overlay-Overlay-jfs-T:where([data-overflow-auto]){overflow:auto}.prc-Overlay-Overlay-jfs-T:where([data-overflow-hidden]){overflow:hidden}.prc-Overlay-Overlay-jfs-T:where([data-overflow-scroll]){overflow:scroll}.prc-Overlay-Overlay-jfs-T:where([data-overflow-visible]){overflow:visible}.prc-Overlay-Overlay-jfs-T:where([data-height-xsmall]){height:192px}.prc-Overlay-Overlay-jfs-T:where([data-height-small]){height:256px}.prc-Overlay-Overlay-jfs-T:where([data-height-medium]){height:320px}.prc-Overlay-Overlay-jfs-T:where([data-height-large]){height:432px}.prc-Overlay-Overlay-jfs-T:where([data-height-xlarge]){height:600px}.prc-Overlay-Overlay-jfs-T:where([data-height-auto]),.prc-Overlay-Overlay-jfs-T:where([data-height-initial]){height:auto}.prc-Overlay-Overlay-jfs-T:where([data-height-fit-content]){height:-moz-fit-content;height:fit-content}.prc-Overlay-Overlay-jfs-T:where([data-max-height-xsmall]){max-height:min(192px,100vh)}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-max-height-xsmall]){max-height:min(192px,100dvh)}}.prc-Overlay-Overlay-jfs-T:where([data-max-height-small]){max-height:min(256px,100vh)}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-max-height-small]){max-height:min(256px,100dvh)}}.prc-Overlay-Overlay-jfs-T:where([data-max-height-medium]){max-height:min(320px,100vh)}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-max-height-medium]){max-height:min(320px,100dvh)}}.prc-Overlay-Overlay-jfs-T:where([data-max-height-large]){max-height:min(432px,100vh)}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-max-height-large]){max-height:min(432px,100dvh)}}.prc-Overlay-Overlay-jfs-T:where([data-max-height-xlarge]){max-height:min(600px,100vh)}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-max-height-xlarge]){max-height:min(600px,100dvh)}}.prc-Overlay-Overlay-jfs-T:where([data-max-height-fit-content]){max-height:-moz-fit-content;max-height:fit-content}.prc-Overlay-Overlay-jfs-T:where([data-width-small]){width:256px}.prc-Overlay-Overlay-jfs-T:where([data-width-medium]){width:320px}.prc-Overlay-Overlay-jfs-T:where([data-width-large]){width:480px}.prc-Overlay-Overlay-jfs-T:where([data-width-xlarge]){width:640px}.prc-Overlay-Overlay-jfs-T:where([data-width-xxlarge]){width:960px}.prc-Overlay-Overlay-jfs-T:where([data-width-auto]){width:auto}.prc-Overlay-Overlay-jfs-T:where([data-max-width-small]){max-width:256px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-medium]){max-width:320px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-large]){max-width:480px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-xlarge]){max-width:640px}.prc-Overlay-Overlay-jfs-T:where([data-max-width-xxlarge]){max-width:960px}.prc-Overlay-Overlay-jfs-T:where([data-visibility-visible]){visibility:visible}.prc-Overlay-Overlay-jfs-T:where([data-visibility-hidden]){visibility:hidden}@media screen and (max-width:calc(48rem - 0.02px)){.prc-Overlay-Overlay-jfs-T:where([data-responsive=fullscreen]),.prc-Overlay-Overlay-jfs-T[data-responsive=fullscreen][data-anchor-position=true]{border-radius:unset;height:100vh;left:0;margin:0;max-height:none;max-width:none;padding-bottom:env(safe-area-inset-bottom);position:fixed;top:0;width:100vw}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-responsive=fullscreen]),.prc-Overlay-Overlay-jfs-T[data-responsive=fullscreen][data-anchor-position=true]{height:100dvh}}}@supports (height:100dvh){.prc-Overlay-Overlay-jfs-T:where([data-variant=fullscreen]){height:100dvh}}@media (prefers-reduced-motion:no-preference){.prc-Overlay-Overlay-jfs-T{animation:prc-Overlay-overlay-appear-JpFey .2s cubic-bezier(.33,1,.68,1)}}
2
+ /*# sourceMappingURL=Overlay-95cfd3c7.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Overlay/Overlay.module.css.js"],"names":[],"mappings":"AAAA,4CACE,GACE,SACF,CAEA,GACE,SACF,CACF,CAEA,2BAQE,4CAAwC,CACxC,8CAAwC,CACxC,4GAAwC,CALxC,WAAY,CACZ,gBAAiB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-95cfd3c7.css","sourcesContent":["@keyframes overlay-appear {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n.Overlay {\n position: absolute;\n max-width: calc(100vw - 2rem);\n width: auto;\n min-width: 192px;\n height: auto;\n max-height: 100vh;\n overflow: auto;\n background-color: var(--overlay-bgColor);\n border-radius: var(--borderRadius-large);\n box-shadow: var(--shadow-floating-small);\n\n &[data-anchor-position='false'],\n &:not([data-anchor-position]):not([data-variant='modal']) {\n /* stylelint-disable-next-line primer/spacing */\n right: var(--right, auto);\n /* stylelint-disable-next-line primer/spacing */\n bottom: var(--bottom, auto);\n\n /* stylelint-disable-next-line selector-max-specificity */\n &[data-responsive='fullscreen']:not([data-variant]) {\n @media screen and (--viewportRange-narrow) {\n top: 0;\n left: 0;\n }\n }\n\n &:not([data-variant]) {\n /* stylelint-disable-next-line primer/spacing */\n top: var(--top, auto);\n /* stylelint-disable-next-line primer/spacing */\n left: var(--left, auto);\n }\n }\n\n &:focus {\n outline: none;\n }\n\n @media (forced-colors: active) {\n /* Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips */\n outline: solid 1px transparent;\n }\n\n &:where([data-reflow-container='true']) {\n max-width: calc(100vw - 2rem);\n }\n\n &:where([data-overflow-auto]) {\n overflow: auto;\n }\n\n &:where([data-overflow-hidden]) {\n overflow: hidden;\n }\n\n &:where([data-overflow-scroll]) {\n overflow: scroll;\n }\n\n &:where([data-overflow-visible]) {\n overflow: visible;\n }\n\n &:where([data-height-xsmall]) {\n height: 192px;\n }\n\n &:where([data-height-small]) {\n height: 256px;\n }\n\n &:where([data-height-medium]) {\n height: 320px;\n }\n\n &:where([data-height-large]) {\n height: 432px;\n }\n\n &:where([data-height-xlarge]) {\n height: 600px;\n }\n\n &:where([data-height-auto]),\n &:where([data-height-initial]) {\n height: auto;\n }\n\n &:where([data-height-fit-content]) {\n height: fit-content;\n }\n\n &:where([data-max-height-xsmall]) {\n max-height: min(192px, 100vh);\n\n @supports (height: 100dvh) {\n max-height: min(192px, 100dvh);\n }\n }\n\n &:where([data-max-height-small]) {\n max-height: min(256px, 100vh);\n\n @supports (height: 100dvh) {\n max-height: min(256px, 100dvh);\n }\n }\n\n &:where([data-max-height-medium]) {\n max-height: min(320px, 100vh);\n\n @supports (height: 100dvh) {\n max-height: min(320px, 100dvh);\n }\n }\n\n &:where([data-max-height-large]) {\n max-height: min(432px, 100vh);\n\n @supports (height: 100dvh) {\n max-height: min(432px, 100dvh);\n }\n }\n\n &:where([data-max-height-xlarge]) {\n max-height: min(600px, 100vh);\n\n @supports (height: 100dvh) {\n max-height: min(600px, 100dvh);\n }\n }\n\n &:where([data-max-height-fit-content]) {\n max-height: fit-content;\n }\n\n &:where([data-width-small]) {\n width: 256px;\n }\n\n &:where([data-width-medium]) {\n width: 320px;\n }\n\n &:where([data-width-large]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 480px;\n }\n\n &:where([data-width-xlarge]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 640px;\n }\n\n &:where([data-width-xxlarge]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 960px;\n }\n\n &:where([data-width-auto]) {\n width: auto;\n }\n\n &:where([data-max-width-small]) {\n max-width: 256px;\n }\n\n &:where([data-max-width-medium]) {\n max-width: 320px;\n }\n\n &:where([data-max-width-large]) {\n max-width: 480px;\n }\n\n &:where([data-max-width-xlarge]) {\n max-width: 640px;\n }\n\n &:where([data-max-width-xxlarge]) {\n max-width: 960px;\n }\n\n &:where([data-visibility-visible]) {\n visibility: visible;\n }\n\n &:where([data-visibility-hidden]) {\n visibility: hidden;\n }\n\n &:where([data-responsive='fullscreen']),\n &[data-responsive='fullscreen'][data-anchor-position='true'] {\n @media screen and (--viewportRange-narrow) {\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n max-width: none;\n height: 100vh;\n max-height: none;\n margin: 0;\n border-radius: unset;\n /* stylelint-disable-next-line primer/spacing */\n padding-bottom: env(safe-area-inset-bottom);\n\n @supports (height: 100dvh) {\n /* fix for mobile safari (100vh clips the screen with the toolbar) */\n height: 100dvh;\n }\n }\n }\n\n @supports (height: 100dvh) {\n /* fix for mobile safari (100vh clips the screen with the toolbar) */\n &:where([data-variant='fullscreen']) {\n height: 100dvh;\n }\n }\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .Overlay {\n animation: overlay-appear 200ms cubic-bezier(0.33, 1, 0.68, 1);\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import './Overlay-4e689024.css';
1
+ import './Overlay-95cfd3c7.css';
2
2
 
3
3
  var classes = {"Overlay":"prc-Overlay-Overlay-jfs-T","overlay-appear":"prc-Overlay-overlay-appear-JpFey"};
4
4
 
@@ -6,8 +6,6 @@ export { useOpenAndCloseFocus } from './useOpenAndCloseFocus';
6
6
  export type { UseOpenAndCloseFocusSettings } from './useOpenAndCloseFocus';
7
7
  export type { AnchoredPositionHookSettings } from './useAnchoredPosition';
8
8
  export { useAnchoredPosition } from './useAnchoredPosition';
9
- export type { CSSAnchorPositioningSettings, CSSAnchorPositioningResult } from './useCSSAnchorPositioning';
10
- export { useCSSAnchorPositioning } from './useCSSAnchorPositioning';
11
9
  export { useOverlay } from './useOverlay';
12
10
  export type { UseOverlaySettings } from './useOverlay';
13
11
  export { useRenderForcingRef } from './useRenderForcingRef';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrD,YAAY,EAAC,yBAAyB,EAAE,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrF,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAA;AAC3D,YAAY,EAAC,4BAA4B,EAAC,MAAM,wB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4B,EAAC,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,YAAY,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAA;AACpD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,0BAA0B,EAAC,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA"}
@@ -2126,18 +2126,28 @@
2126
2126
  "stories": [
2127
2127
  {
2128
2128
  "id": "experimental-components-card--default",
2129
- "code": "() => {\n return (\n <div\n style={{\n maxWidth: '400px',\n }}\n >\n <Card>\n <Card.Icon icon={RocketIcon} />\n <Card.Heading>Card Heading</Card.Heading>\n <Card.Description>\n This is a description of the card providing supplemental information.\n </Card.Description>\n <Card.Metadata>Updated 2 hours ago</Card.Metadata>\n </Card>\n </div>\n )\n}"
2129
+ "code": "() => {\n return (\n <Card>\n <Card.Icon icon={RocketIcon} />\n <Card.Heading>Card Heading</Card.Heading>\n <Card.Description>\n This is a description of the card providing supplemental information.\n </Card.Description>\n <Card.Metadata>\n <PeopleIcon size={16} />3 contributors\n </Card.Metadata>\n </Card>\n )\n}"
2130
2130
  },
2131
2131
  {
2132
2132
  "id": "experimental-components-card-features--with-image",
2133
- "code": "() => {\n return (\n <div\n style={{\n maxWidth: '400px',\n }}\n >\n <Card>\n <Card.Image src=\"https://github.com/octocat.png\" alt=\"Octocat\" />\n <Card.Heading>Card with Image</Card.Heading>\n <Card.Description>\n This card uses an edge-to-edge image instead of an icon.\n </Card.Description>\n </Card>\n </div>\n )\n}"
2133
+ "code": "() => {\n return (\n <Card>\n <Card.Image src=\"https://github.com/octocat.png\" alt=\"Octocat\" />\n <Card.Heading>Card with Image</Card.Heading>\n <Card.Description>\n This card uses an edge-to-edge image instead of an icon.\n </Card.Description>\n </Card>\n )\n}"
2134
2134
  },
2135
2135
  {
2136
2136
  "id": "experimental-components-card-features--with-metadata",
2137
- "code": "() => {\n return (\n <div\n style={{\n maxWidth: '400px',\n }}\n >\n <Card>\n <Card.Icon icon={RepoIcon} />\n <Card.Heading>primer/react</Card.Heading>\n <Card.Description>\n {\n \"GitHub's design system implemented as React components for building consistent user interfaces.\"\n }\n </Card.Description>\n <Card.Metadata>\n <StarIcon size={16} />\n 1.2k stars\n </Card.Metadata>\n </Card>\n </div>\n )\n}"
2137
+ "code": "() => {\n return (\n <Card>\n <Card.Icon icon={RepoIcon} />\n <Card.Heading>primer/react</Card.Heading>\n <Card.Description>\n {\n \"GitHub's design system implemented as React components for building consistent user interfaces.\"\n }\n </Card.Description>\n <Card.Metadata>\n <StarIcon size={16} />\n 1.2k stars\n </Card.Metadata>\n </Card>\n )\n}"
2138
+ },
2139
+ {
2140
+ "id": "experimental-components-card-features--with-menu",
2141
+ "code": "() => {\n return (\n <Card>\n <Card.Icon icon={RepoIcon} />\n <Card.Heading>primer/react</Card.Heading>\n <Card.Description>\n {\n \"GitHub's design system implemented as React components for building consistent user interfaces.\"\n }\n </Card.Description>\n <Card.Menu>\n <ActionMenu>\n <ActionMenu.Anchor>\n <IconButton\n icon={KebabHorizontalIcon}\n aria-label=\"More options for primer/react\"\n variant=\"invisible\"\n />\n </ActionMenu.Anchor>\n <ActionMenu.Overlay>\n <ActionList>\n <ActionList.Item>Star</ActionList.Item>\n <ActionList.Item>Watch</ActionList.Item>\n <ActionList.Item>Fork</ActionList.Item>\n </ActionList>\n </ActionMenu.Overlay>\n </ActionMenu>\n </Card.Menu>\n </Card>\n )\n}"
2138
2142
  }
2139
2143
  ],
2140
2144
  "props": [
2145
+ {
2146
+ "name": "children",
2147
+ "type": "React.ReactNode",
2148
+ "required": true,
2149
+ "description": "The contents of the card. Provide either `Card.*` subcomponents (for example `Card.Heading`, `Card.Description`, `Card.Metadata`) or any custom content. A card with no children will not render."
2150
+ },
2141
2151
  {
2142
2152
  "name": "className",
2143
2153
  "type": "string",
@@ -2201,15 +2211,36 @@
2201
2211
  },
2202
2212
  {
2203
2213
  "name": "Card.Description",
2204
- "props": []
2214
+ "props": [
2215
+ {
2216
+ "name": "children",
2217
+ "type": "React.ReactNode",
2218
+ "required": true,
2219
+ "description": "The descriptive text for the card. Rendered inside a `<p>` element so should be flowing text content."
2220
+ }
2221
+ ]
2205
2222
  },
2206
2223
  {
2207
2224
  "name": "Card.Menu",
2208
- "props": []
2225
+ "props": [
2226
+ {
2227
+ "name": "children",
2228
+ "type": "React.ReactNode",
2229
+ "required": true,
2230
+ "description": "The interactive control(s) to render in the top-right corner of the card, typically a single `IconButton` or `ActionMenu` trigger. When a card contains a menu, make sure the control's accessible name includes enough context to distinguish it from other cards (for example, 'Options for Project Alpha' rather than just 'Options')."
2231
+ }
2232
+ ]
2209
2233
  },
2210
2234
  {
2211
2235
  "name": "Card.Metadata",
2212
- "props": []
2236
+ "props": [
2237
+ {
2238
+ "name": "children",
2239
+ "type": "React.ReactNode",
2240
+ "required": true,
2241
+ "description": "The metadata content to render at the bottom of the card. Accepts any content, including plain text, icons, and other Primer components (for example a `Label`, `Octicon`, or any combination). Avoid using `RelativeTime` until its outstanding accessibility issues are resolved."
2242
+ }
2243
+ ]
2213
2244
  }
2214
2245
  ]
2215
2246
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260518154353",
4
+ "version": "0.0.0-20260519124320",
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-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{z-index:100}.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][data-align=left]{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-efecedd0.css.map */
@@ -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,WAoCF,CAjCI,sFACE,SAAU,CACV,sEACF,CAIA,mFACE,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-efecedd0.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 z-index: 100;\n\n &[data-side='outside-bottom'] {\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 &[data-align='left'] {\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 +0,0 @@
1
- {"version":3,"sources":["../src/Overlay/Overlay.module.css.js"],"names":[],"mappings":"AAAA,4CACE,GACE,SACF,CAEA,GACE,SACF,CACF,CAEA,2BAQE,4CAAwC,CACxC,8CAAwC,CACxC,4GAAwC,CALxC,WAAY,CACZ,gBAAiB,CAJjB,4BAA6B,CAE7B,eAAgB,CAGhB,aAAc,CANd,iBAAkB,CAElB,UAsPF,CA7OE,wIAKE,yBAA2B,CAF3B,uBAkBF,CAZI,mDADF,6LAGI,MAAO,CADP,KAGJ,CADE,CAGF,iKAIE,qBAAuB,CAFvB,mBAGF,CAGF,iCACE,YACF,CAEA,8BAvCF,2BAyCI,6BAgNJ,CA/ME,CAEA,+DACE,4BACF,CAEA,uDACE,aACF,CAEA,yDACE,eACF,CAEA,yDACE,eACF,CAEA,0DACE,gBACF,CAEA,uDACE,YACF,CAEA,sDACE,YACF,CAEA,uDACE,YACF,CAEA,sDACE,YACF,CAEA,uDACE,YACF,CAEA,6GAEE,WACF,CAEA,4DACE,uBAAmB,CAAnB,kBACF,CAEA,2DACE,2BAKF,CAHE,0BAHF,2DAII,4BAEJ,CADE,CAGF,0DACE,2BAKF,CAHE,0BAHF,0DAII,4BAEJ,CADE,CAGF,2DACE,2BAKF,CAHE,0BAHF,2DAII,4BAEJ,CADE,CAGF,0DACE,2BAKF,CAHE,0BAHF,0DAII,4BAEJ,CADE,CAGF,2DACE,2BAKF,CAHE,0BAHF,2DAII,4BAEJ,CADE,CAGF,gEACE,2BAAuB,CAAvB,sBACF,CAEA,qDACE,WACF,CAEA,sDACE,WACF,CAEA,qDAEE,WACF,CAEA,sDAEE,WACF,CAEA,uDAEE,WACF,CAEA,oDACE,UACF,CAEA,yDACE,eACF,CAEA,0DACE,eACF,CAEA,yDACE,eACF,CAEA,0DACE,eACF,CAEA,2DACE,eACF,CAEA,4DACE,kBACF,CAEA,2DACE,iBACF,CAEA,sDACE,oEAGwB,CACxB,mCAAoC,CACpC,wBAqBF,CAnBE,+DAIE,QAAS,CAHT,UAAW,CACX,QAAS,CAGT,cAAe,CAFf,SAGF,CAEA,gFAEE,iBAAkB,CADlB,oDAEF,CAEA,6EAEE,kBAAmB,CACnB,iBAAkB,CAFlB,uCAGF,CAMA,mDAFF,iJAWI,mBAAoB,CAHpB,YAAa,CAHb,MAAO,CAKP,QAAS,CADT,eAAgB,CAFhB,cAAe,CAMf,0CAA2C,CAV3C,cAAe,CACf,KAAM,CAEN,WAcJ,CALI,0BAfJ,iJAiBM,aAGN,CAFI,CACF,CAGF,0BAEE,4DACE,aACF,CACF,CAGF,8CACE,2BACE,wEACF,CACF","file":"Overlay-4e689024.css","sourcesContent":["@keyframes overlay-appear {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n.Overlay {\n position: absolute;\n max-width: calc(100vw - 2rem);\n width: auto;\n min-width: 192px;\n height: auto;\n max-height: 100vh;\n overflow: auto;\n background-color: var(--overlay-bgColor);\n border-radius: var(--borderRadius-large);\n box-shadow: var(--shadow-floating-small);\n\n &[data-anchor-position='false'],\n &:not([data-anchor-position]):not([data-variant='modal']) {\n /* stylelint-disable-next-line primer/spacing */\n right: var(--right, auto);\n /* stylelint-disable-next-line primer/spacing */\n bottom: var(--bottom, auto);\n\n /* stylelint-disable-next-line selector-max-specificity */\n &[data-responsive='fullscreen']:not([data-variant]) {\n @media screen and (--viewportRange-narrow) {\n top: 0;\n left: 0;\n }\n }\n\n &:not([data-variant]) {\n /* stylelint-disable-next-line primer/spacing */\n top: var(--top, auto);\n /* stylelint-disable-next-line primer/spacing */\n left: var(--left, auto);\n }\n }\n\n &:focus {\n outline: none;\n }\n\n @media (forced-colors: active) {\n /* Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips */\n outline: solid 1px transparent;\n }\n\n &:where([data-reflow-container='true']) {\n max-width: calc(100vw - 2rem);\n }\n\n &:where([data-overflow-auto]) {\n overflow: auto;\n }\n\n &:where([data-overflow-hidden]) {\n overflow: hidden;\n }\n\n &:where([data-overflow-scroll]) {\n overflow: scroll;\n }\n\n &:where([data-overflow-visible]) {\n overflow: visible;\n }\n\n &:where([data-height-xsmall]) {\n height: 192px;\n }\n\n &:where([data-height-small]) {\n height: 256px;\n }\n\n &:where([data-height-medium]) {\n height: 320px;\n }\n\n &:where([data-height-large]) {\n height: 432px;\n }\n\n &:where([data-height-xlarge]) {\n height: 600px;\n }\n\n &:where([data-height-auto]),\n &:where([data-height-initial]) {\n height: auto;\n }\n\n &:where([data-height-fit-content]) {\n height: fit-content;\n }\n\n &:where([data-max-height-xsmall]) {\n max-height: min(192px, 100vh);\n\n @supports (height: 100dvh) {\n max-height: min(192px, 100dvh);\n }\n }\n\n &:where([data-max-height-small]) {\n max-height: min(256px, 100vh);\n\n @supports (height: 100dvh) {\n max-height: min(256px, 100dvh);\n }\n }\n\n &:where([data-max-height-medium]) {\n max-height: min(320px, 100vh);\n\n @supports (height: 100dvh) {\n max-height: min(320px, 100dvh);\n }\n }\n\n &:where([data-max-height-large]) {\n max-height: min(432px, 100vh);\n\n @supports (height: 100dvh) {\n max-height: min(432px, 100dvh);\n }\n }\n\n &:where([data-max-height-xlarge]) {\n max-height: min(600px, 100vh);\n\n @supports (height: 100dvh) {\n max-height: min(600px, 100dvh);\n }\n }\n\n &:where([data-max-height-fit-content]) {\n max-height: fit-content;\n }\n\n &:where([data-width-small]) {\n width: 256px;\n }\n\n &:where([data-width-medium]) {\n width: 320px;\n }\n\n &:where([data-width-large]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 480px;\n }\n\n &:where([data-width-xlarge]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 640px;\n }\n\n &:where([data-width-xxlarge]) {\n /* stylelint-disable-next-line primer/responsive-widths */\n width: 960px;\n }\n\n &:where([data-width-auto]) {\n width: auto;\n }\n\n &:where([data-max-width-small]) {\n max-width: 256px;\n }\n\n &:where([data-max-width-medium]) {\n max-width: 320px;\n }\n\n &:where([data-max-width-large]) {\n max-width: 480px;\n }\n\n &:where([data-max-width-xlarge]) {\n max-width: 640px;\n }\n\n &:where([data-max-width-xxlarge]) {\n max-width: 960px;\n }\n\n &:where([data-visibility-visible]) {\n visibility: visible;\n }\n\n &:where([data-visibility-hidden]) {\n visibility: hidden;\n }\n\n &[data-anchor-position='true'] {\n position-try-fallbacks:\n flip-block,\n flip-inline,\n flip-block flip-inline;\n position-visibility: anchors-visible;\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 top: calc(anchor(bottom) + var(--base-size-4));\n left: anchor(left);\n }\n\n &[data-side='outside-top'] {\n margin-bottom: var(--base-size-4);\n bottom: anchor(top);\n left: anchor(left);\n }\n /* stylelint-enable primer/spacing */\n }\n\n &:where([data-responsive='fullscreen']),\n &[data-responsive='fullscreen'][data-anchor-position='true'] {\n @media screen and (--viewportRange-narrow) {\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n max-width: none;\n height: 100vh;\n max-height: none;\n margin: 0;\n border-radius: unset;\n /* stylelint-disable-next-line primer/spacing */\n padding-bottom: env(safe-area-inset-bottom);\n\n @supports (height: 100dvh) {\n /* fix for mobile safari (100vh clips the screen with the toolbar) */\n height: 100dvh;\n }\n }\n }\n\n @supports (height: 100dvh) {\n /* fix for mobile safari (100vh clips the screen with the toolbar) */\n &:where([data-variant='fullscreen']) {\n height: 100dvh;\n }\n }\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .Overlay {\n animation: overlay-appear 200ms cubic-bezier(0.33, 1, 0.68, 1);\n }\n}\n"]}
@@ -1,35 +0,0 @@
1
- import type React from 'react';
2
- export interface CSSAnchorPositioningSettings {
3
- /**
4
- * Ref to the anchor element that the overlay is positioned relative to.
5
- */
6
- anchorElementRef: React.RefObject<HTMLElement | null>;
7
- /**
8
- * Ref to the floating/overlay element that will be positioned.
9
- */
10
- floatingElementRef: React.RefObject<Element | null>;
11
- /**
12
- * Whether the overlay is currently open/visible. When false, only the
13
- * anchor-name is applied (without position-anchor on the overlay).
14
- */
15
- open?: boolean;
16
- }
17
- export interface CSSAnchorPositioningResult {
18
- /**
19
- * Whether CSS anchor positioning is active (feature flag enabled (temporary) + browser support).
20
- * Use this to conditionally skip JS-based positioning and apply CSS classes.
21
- */
22
- enabled: boolean;
23
- }
24
- /**
25
- * Manages CSS anchor positioning by linking an anchor element and a floating
26
- * element via `anchor-name` and `position-anchor` CSS properties.
27
- *
28
- * 1. Checks the `primer_react_css_anchor_positioning` feature flag
29
- * 2. Detects native browser support for CSS anchor positioning
30
- * 3. Sets `anchor-name` on the anchor element
31
- * 4. Sets `position-anchor` on the floating element when open
32
- * 5. Cleans up styles on unmount or when closed
33
- */
34
- export declare function useCSSAnchorPositioning(settings: CSSAnchorPositioningSettings): CSSAnchorPositioningResult;
35
- //# sourceMappingURL=useCSSAnchorPositioning.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCSSAnchorPositioning.d.ts","sourceRoot":"","sources":["../../src/hooks/useCSSAnchorPositioning.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACrD;;OAEG;IACH,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACnD;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,4BAA4B,GAAG,0BAA0B,CAsC1G"}
@@ -1,90 +0,0 @@
1
- import { c } from 'react-compiler-runtime';
2
- import { useState, useEffect } from 'react';
3
- import { useId } from './useId.js';
4
- import { useFeatureFlag } from '../FeatureFlags/useFeatureFlag.js';
5
-
6
- /**
7
- * Manages CSS anchor positioning by linking an anchor element and a floating
8
- * element via `anchor-name` and `position-anchor` CSS properties.
9
- *
10
- * 1. Checks the `primer_react_css_anchor_positioning` feature flag
11
- * 2. Detects native browser support for CSS anchor positioning
12
- * 3. Sets `anchor-name` on the anchor element
13
- * 4. Sets `position-anchor` on the floating element when open
14
- * 5. Cleans up styles on unmount or when closed
15
- */
16
- function useCSSAnchorPositioning(settings) {
17
- const $ = c(11);
18
- const {
19
- anchorElementRef,
20
- floatingElementRef,
21
- open: t0
22
- } = settings;
23
- const open = t0 === undefined ? true : t0;
24
- const cssAnchorPositioningFlag = useFeatureFlag("primer_react_css_anchor_positioning");
25
- const [supportsNativeCSSAnchorPositioning] = useState(_temp);
26
- const enabled = cssAnchorPositioningFlag && supportsNativeCSSAnchorPositioning;
27
- const rawId = useId();
28
- let t1;
29
- if ($[0] !== rawId) {
30
- t1 = rawId.replaceAll(":", "_");
31
- $[0] = rawId;
32
- $[1] = t1;
33
- } else {
34
- t1 = $[1];
35
- }
36
- const id = t1;
37
- const anchorName = `--css-anchor-${id}`;
38
- let t2;
39
- let t3;
40
- if ($[2] !== anchorElementRef || $[3] !== anchorName || $[4] !== enabled || $[5] !== floatingElementRef || $[6] !== open) {
41
- t2 = () => {
42
- if (!enabled) {
43
- return;
44
- }
45
- const anchorElement = anchorElementRef.current;
46
- const floatingElement = floatingElementRef.current;
47
- if (!anchorElement) {
48
- return;
49
- }
50
- anchorElement.style.setProperty("anchor-name", anchorName);
51
- if (open && floatingElement) {
52
- floatingElement.style.setProperty("position-anchor", anchorName);
53
- }
54
- return () => {
55
- anchorElement.style.removeProperty("anchor-name");
56
- if (floatingElement) {
57
- floatingElement.style.removeProperty("position-anchor");
58
- }
59
- };
60
- };
61
- t3 = [enabled, open, anchorName, anchorElementRef, floatingElementRef];
62
- $[2] = anchorElementRef;
63
- $[3] = anchorName;
64
- $[4] = enabled;
65
- $[5] = floatingElementRef;
66
- $[6] = open;
67
- $[7] = t2;
68
- $[8] = t3;
69
- } else {
70
- t2 = $[7];
71
- t3 = $[8];
72
- }
73
- useEffect(t2, t3);
74
- let t4;
75
- if ($[9] !== enabled) {
76
- t4 = {
77
- enabled
78
- };
79
- $[9] = enabled;
80
- $[10] = t4;
81
- } else {
82
- t4 = $[10];
83
- }
84
- return t4;
85
- }
86
- function _temp() {
87
- return typeof document !== "undefined" && "anchorName" in document.documentElement.style;
88
- }
89
-
90
- export { useCSSAnchorPositioning };