@primer/react 0.0.0-20260317171210 → 0.0.0-20260317172615
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 +8 -4
- package/dist/ActionList/LinkItem.d.ts +6 -3
- package/dist/ActionList/LinkItem.d.ts.map +1 -1
- package/dist/ActionList/LinkItem.js +42 -87
- package/dist/ActionList/index.d.ts +25 -1
- package/dist/ActionList/index.d.ts.map +1 -1
- package/dist/ActionMenu/ActionMenu.d.ts.map +1 -1
- package/dist/ActionMenu/ActionMenu.js +9 -1
- package/dist/AnchoredOverlay/AnchoredOverlay-0f6f45b5.css +2 -0
- package/dist/AnchoredOverlay/AnchoredOverlay-0f6f45b5.css.map +1 -0
- package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
- package/dist/AnchoredOverlay/AnchoredOverlay.js +43 -10
- package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +2 -2
- package/dist/Banner/Banner.js +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +23 -8
- package/dist/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.js +27 -65
- package/dist/Details/Details.js +1 -1
- package/dist/FeatureFlags/DefaultFeatureFlags.d.ts.map +1 -1
- package/dist/FeatureFlags/DefaultFeatureFlags.js +1 -0
- package/dist/NavList/NavList.d.ts +20 -3
- package/dist/NavList/NavList.d.ts.map +1 -1
- package/dist/NavList/NavList.js +50 -124
- package/dist/Overlay/Overlay-2e0ce8db.css +2 -0
- package/dist/Overlay/Overlay-2e0ce8db.css.map +1 -0
- package/dist/Overlay/Overlay.d.ts.map +1 -1
- package/dist/Overlay/Overlay.js +10 -4
- package/dist/Overlay/Overlay.module.css.js +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useProvidedRefOrCreate.d.ts +0 -12
- package/dist/hooks/useProvidedRefOrCreate.d.ts.map +1 -1
- package/dist/hooks/useProvidedRefOrCreate.js +0 -12
- package/dist/hooks/useRefObjectAsForwardedRef.d.ts +0 -12
- package/dist/hooks/useRefObjectAsForwardedRef.d.ts.map +1 -1
- package/dist/hooks/useRefObjectAsForwardedRef.js +0 -12
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/internal/hooks/useMergedRefs.d.ts +2 -0
- package/dist/internal/hooks/useMergedRefs.d.ts.map +1 -0
- package/dist/internal/hooks/useMergedRefs.js +16 -0
- package/generated/hooks.json +0 -22
- package/package.json +2 -1
- package/dist/AnchoredOverlay/AnchoredOverlay-73c1b2d1.css +0 -2
- package/dist/AnchoredOverlay/AnchoredOverlay-73c1b2d1.css.map +0 -1
- package/dist/Overlay/Overlay-dbaa6b8c.css +0 -2
- package/dist/Overlay/Overlay-dbaa6b8c.css.map +0 -1
- package/dist/hooks/useMergedRefs.d.ts +0 -51
- package/dist/hooks/useMergedRefs.d.ts.map +0 -1
- package/dist/hooks/useMergedRefs.js +0 -86
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260317172615
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
-
- [#
|
|
8
|
-
- Deprecates `useRefObjectAsForwardedRef`; see doc comment for migration instructions
|
|
9
|
-
- Deprecates `useProvidedRefOrCreate`; see doc comment for migration instructions
|
|
7
|
+
- [#7658](https://github.com/primer/react/pull/7658) [`259fdff`](https://github.com/primer/react/commit/259fdff67550e328b851129a78e87413ddb07229) Thanks [@hussam-i-am](https://github.com/hussam-i-am)! - fix(polymorphic): Improve prop passthrough for ActionList.LinkItem and Breadcrumbs.Item
|
|
10
8
|
|
|
11
9
|
### Patch Changes
|
|
12
10
|
|
|
13
11
|
- Fake entry to force publishing
|
|
14
12
|
|
|
13
|
+
## 38.16.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [#7661](https://github.com/primer/react/pull/7661) [`dceb79c`](https://github.com/primer/react/commit/dceb79c5e0f8ab5c25bbc9727bc3207fb77d520e) Thanks [@TylerJDev](https://github.com/TylerJDev)! - AnchoredOverlay: Add CSS Anchor Positioning to `AnchoredOverlay` (under a feature flag)
|
|
18
|
+
|
|
15
19
|
## 38.15.1
|
|
16
20
|
|
|
17
21
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type {
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { WithSlotMarker } from '../utils/types/Slots';
|
|
3
3
|
import type { ActionListItemProps } from './shared';
|
|
4
4
|
type LinkProps = {
|
|
5
5
|
download?: string;
|
|
@@ -14,6 +14,9 @@ type LinkProps = {
|
|
|
14
14
|
className?: string;
|
|
15
15
|
};
|
|
16
16
|
export type ActionListLinkItemProps = Pick<ActionListItemProps, 'active' | 'children' | 'inactiveText' | 'variant' | 'size'> & LinkProps;
|
|
17
|
-
|
|
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) & {
|
|
18
|
+
as?: As | undefined;
|
|
19
|
+
} & React.RefAttributes<unknown>) => React.ReactNode;
|
|
20
|
+
export declare const LinkItem: WithSlotMarker<typeof LinkItemComponent>;
|
|
18
21
|
export {};
|
|
19
22
|
//# sourceMappingURL=LinkItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkItem.d.ts","sourceRoot":"","sources":["../../src/ActionList/LinkItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"LinkItem.d.ts","sourceRoot":"","sources":["../../src/ActionList/LinkItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAA;AAGxD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AAIjD,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAChF,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAGD,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,mBAAmB,EACnB,QAAQ,GAAG,UAAU,GAAG,cAAc,GAAG,SAAS,GAAG,MAAM,CAC5D,GACC,SAAS,CAAA;AAIX,QAAA,MAAM,iBAAiB,GACpB,EAAE,SAAS,KAAK,CAAC,WAAW;;oDAqC9B,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,cAAc,CAAC,OAAO,iBAAiB,CAG5D,CAAA"}
|
|
@@ -1,62 +1,46 @@
|
|
|
1
|
-
import { c } from 'react-compiler-runtime';
|
|
2
|
-
import React from 'react';
|
|
3
1
|
import { Item } from './Item.js';
|
|
2
|
+
import { fixedForwardRef } from '../utils/modern-polymorphic.js';
|
|
4
3
|
import { jsx } from 'react/jsx-runtime';
|
|
5
4
|
import Link from '../Link/Link.js';
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
$[2] = active;
|
|
29
|
-
$[3] = className;
|
|
30
|
-
$[4] = inactiveText;
|
|
31
|
-
$[5] = props;
|
|
32
|
-
$[6] = size;
|
|
33
|
-
$[7] = variant;
|
|
34
|
-
} else {
|
|
35
|
-
Component = $[1];
|
|
36
|
-
active = $[2];
|
|
37
|
-
className = $[3];
|
|
38
|
-
inactiveText = $[4];
|
|
39
|
-
props = $[5];
|
|
40
|
-
size = $[6];
|
|
41
|
-
variant = $[7];
|
|
42
|
-
}
|
|
43
|
-
const t1 = inactiveText ? true : undefined;
|
|
44
|
-
let t2;
|
|
45
|
-
if ($[8] !== Component || $[9] !== forwardedRef || $[10] !== inactiveText || $[11] !== props) {
|
|
46
|
-
t2 = t3 => {
|
|
47
|
-
const {
|
|
48
|
-
children,
|
|
49
|
-
onClick,
|
|
50
|
-
...rest
|
|
51
|
-
} = t3;
|
|
6
|
+
const LinkItemComponent = fixedForwardRef(({
|
|
7
|
+
active,
|
|
8
|
+
inactiveText,
|
|
9
|
+
variant,
|
|
10
|
+
size,
|
|
11
|
+
as: Component,
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}, forwardedRef) => {
|
|
15
|
+
return /*#__PURE__*/jsx(Item, {
|
|
16
|
+
className: className,
|
|
17
|
+
active: active,
|
|
18
|
+
inactiveText: inactiveText,
|
|
19
|
+
"data-inactive": inactiveText ? true : undefined,
|
|
20
|
+
variant: variant,
|
|
21
|
+
size: size,
|
|
22
|
+
_PrivateItemWrapper: ({
|
|
23
|
+
children,
|
|
24
|
+
onClick,
|
|
25
|
+
...rest
|
|
26
|
+
}) => {
|
|
52
27
|
const clickHandler = event => {
|
|
53
28
|
onClick && onClick(event);
|
|
54
29
|
props.onClick && props.onClick(event);
|
|
55
30
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
31
|
+
if (inactiveText) {
|
|
32
|
+
return /*#__PURE__*/jsx("span", {
|
|
33
|
+
...rest,
|
|
34
|
+
children: children
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Type safety for the polymorphic `as` prop is enforced at the
|
|
39
|
+
// LinkItem boundary via fixedForwardRef. Internally we widen
|
|
40
|
+
// Link's type so TypeScript doesn't re-check the generic
|
|
41
|
+
// constraint across two polymorphic layers.
|
|
42
|
+
const InternalLink = Link;
|
|
43
|
+
return /*#__PURE__*/jsx(InternalLink, {
|
|
60
44
|
as: Component,
|
|
61
45
|
...rest,
|
|
62
46
|
...props,
|
|
@@ -64,42 +48,13 @@ const LinkItem = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
|
|
|
64
48
|
ref: forwardedRef,
|
|
65
49
|
children: children
|
|
66
50
|
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
t2 = $[12];
|
|
75
|
-
}
|
|
76
|
-
let t3;
|
|
77
|
-
if ($[13] !== active || $[14] !== className || $[15] !== inactiveText || $[16] !== props.children || $[17] !== size || $[18] !== t1 || $[19] !== t2 || $[20] !== variant) {
|
|
78
|
-
t3 = /*#__PURE__*/jsx(Item, {
|
|
79
|
-
className: className,
|
|
80
|
-
active: active,
|
|
81
|
-
inactiveText: inactiveText,
|
|
82
|
-
"data-inactive": t1,
|
|
83
|
-
variant: variant,
|
|
84
|
-
size: size,
|
|
85
|
-
_PrivateItemWrapper: t2,
|
|
86
|
-
children: props.children
|
|
87
|
-
});
|
|
88
|
-
$[13] = active;
|
|
89
|
-
$[14] = className;
|
|
90
|
-
$[15] = inactiveText;
|
|
91
|
-
$[16] = props.children;
|
|
92
|
-
$[17] = size;
|
|
93
|
-
$[18] = t1;
|
|
94
|
-
$[19] = t2;
|
|
95
|
-
$[20] = variant;
|
|
96
|
-
$[21] = t3;
|
|
97
|
-
} else {
|
|
98
|
-
t3 = $[21];
|
|
99
|
-
}
|
|
100
|
-
return t3;
|
|
51
|
+
},
|
|
52
|
+
children: props.children
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
const LinkItem = Object.assign(LinkItemComponent, {
|
|
56
|
+
displayName: 'ActionList.LinkItem',
|
|
57
|
+
__SLOT__: Symbol('ActionList.LinkItem')
|
|
101
58
|
});
|
|
102
|
-
LinkItem.displayName = 'ActionList.LinkItem';
|
|
103
|
-
LinkItem.__SLOT__ = Symbol('ActionList.LinkItem');
|
|
104
59
|
|
|
105
60
|
export { LinkItem };
|
|
@@ -84,7 +84,31 @@ 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/
|
|
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"> & {
|
|
88
|
+
download?: string;
|
|
89
|
+
href?: string;
|
|
90
|
+
hrefLang?: string;
|
|
91
|
+
media?: string;
|
|
92
|
+
ping?: string;
|
|
93
|
+
rel?: string;
|
|
94
|
+
target?: string;
|
|
95
|
+
type?: string;
|
|
96
|
+
referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>["referrerPolicy"];
|
|
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"> & {
|
|
99
|
+
download?: string;
|
|
100
|
+
href?: string;
|
|
101
|
+
hrefLang?: string;
|
|
102
|
+
media?: string;
|
|
103
|
+
ping?: string;
|
|
104
|
+
rel?: string;
|
|
105
|
+
target?: string;
|
|
106
|
+
type?: string;
|
|
107
|
+
referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>["referrerPolicy"];
|
|
108
|
+
className?: string;
|
|
109
|
+
} ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
|
|
110
|
+
as?: As | undefined;
|
|
111
|
+
} & import("react").RefAttributes<unknown>) => React.ReactNode)>;
|
|
88
112
|
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
|
89
113
|
Divider: import("../utils/types").FCWithSlotMarker<import("react").PropsWithChildren<import("./Divider").ActionListDividerProps>>;
|
|
90
114
|
/** Secondary text which provides additional information about an `Item`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ActionList/index.ts"],"names":[],"mappings":"AAUA,YAAY,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AAC7C,YAAY,EAAC,oBAAoB,EAAE,2BAA2B,EAAC,MAAM,SAAS,CAAA;AAC9E,YAAY,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AACjD,YAAY,EAAC,uBAAuB,EAAC,MAAM,YAAY,CAAA;AACvD,YAAY,EAAC,sBAAsB,EAAC,MAAM,WAAW,CAAA;AACrD,YAAY,EAAC,0BAA0B,EAAC,MAAM,eAAe,CAAA;AAC7D,YAAY,EAAC,4BAA4B,EAAE,6BAA6B,EAAC,MAAM,WAAW,CAAA;AAC1F,YAAY,EAAC,sBAAsB,EAAC,MAAM,WAAW,CAAA;AACrD,YAAY,EAAC,6BAA6B,EAAC,MAAM,kBAAkB,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;IACrB,mDAAmD;;IAGnD,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGzC,+DAA+D
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ActionList/index.ts"],"names":[],"mappings":"AAUA,YAAY,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AAC7C,YAAY,EAAC,oBAAoB,EAAE,2BAA2B,EAAC,MAAM,SAAS,CAAA;AAC9E,YAAY,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AACjD,YAAY,EAAC,uBAAuB,EAAC,MAAM,YAAY,CAAA;AACvD,YAAY,EAAC,sBAAsB,EAAC,MAAM,WAAW,CAAA;AACrD,YAAY,EAAC,0BAA0B,EAAC,MAAM,eAAe,CAAA;AAC7D,YAAY,EAAC,4BAA4B,EAAE,6BAA6B,EAAC,MAAM,WAAW,CAAA;AAC1F,YAAY,EAAC,sBAAsB,EAAC,MAAM,WAAW,CAAA;AACrD,YAAY,EAAC,6BAA6B,EAAC,MAAM,kBAAkB,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;IACrB,mDAAmD;;IAGnD,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGzC,+DAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;IAG/D,iEAAiE;;IAGjE,4EAA4E;;IAG5E,uDAAuD;;IAGvD,sDAAsD;;IAGtD,mCAAmC;;IAGnC,qCAAqC;;IAGrC,uBAAuB;;CAEvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionMenu.d.ts","sourceRoot":"","sources":["../../src/ActionMenu/ActionMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8D,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ActionMenu.d.ts","sourceRoot":"","sources":["../../src/ActionMenu/ActionMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8D,MAAM,OAAO,CAAA;AAGlF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAI5C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAA;AAIrD,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAK/F,OAAO,KAAK,EAAC,gBAAgB,EAAE,cAAc,EAAC,MAAM,sBAAsB,CAAA;AAI1E,MAAM,MAAM,gBAAgB,GAAG,CAC7B,OAAO,EAAE,cAAc,GAAG,eAAe,GAAG,QAAQ,GAAG,KAAK,GAAG,aAAa,GAAG,YAAY,GAAG,OAAO,KAClG,IAAI,CAAA;AAET,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,oBAAoB,EACpB,WAAW,GAAG,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAC9D,GAAG;IACF,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAGD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IAEH,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;IAE7D;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACpC,GAAG,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAA;AA8I3C,MAAM,MAAM,qBAAqB,GAAG;IAAC,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;AA2DxH,6CAA6C;AAC7C,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAA;AAe/C,KAAK,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,GAC3C,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,mBAAmB,CAAC,GAAG;IAC/E;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,gBAAgB,CAAC,EAAE,CAAC,EAAC,QAAQ,EAAC,EAAE;QAAC,QAAQ,EAAE,cAAc,CAAA;KAAC,KAAK,IAAI,CAAA;CACpE,CAAA;AAgHH,eAAO,MAAM,UAAU;;;kBA7LP,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC;aAC5B,MAAM;;;;CA4L4E,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
2
3
|
import { ChevronRightIcon, TriangleDownIcon } from '@primer/octicons-react';
|
|
3
4
|
import { Divider } from '../ActionList/Divider.js';
|
|
4
5
|
import { ActionListContainerContext } from '../ActionList/ActionListContainerContext.js';
|
|
@@ -43,6 +44,9 @@ const mergeAnchorHandlers = (anchorProps, buttonProps) => {
|
|
|
43
44
|
};
|
|
44
45
|
mergedAnchorProps.onKeyDown = mergedOnAnchorKeyDown;
|
|
45
46
|
}
|
|
47
|
+
if (buttonProps.className) {
|
|
48
|
+
mergedAnchorProps.className = clsx(anchorProps.className, buttonProps.className);
|
|
49
|
+
}
|
|
46
50
|
return mergedAnchorProps;
|
|
47
51
|
};
|
|
48
52
|
const Menu = ({
|
|
@@ -120,7 +124,10 @@ const Menu = ({
|
|
|
120
124
|
};
|
|
121
125
|
}
|
|
122
126
|
} else {
|
|
123
|
-
renderAnchor = anchorProps => /*#__PURE__*/React.cloneElement(child,
|
|
127
|
+
renderAnchor = anchorProps => /*#__PURE__*/React.cloneElement(child, {
|
|
128
|
+
...anchorProps,
|
|
129
|
+
className: clsx(anchorProps.className, child.props.className)
|
|
130
|
+
});
|
|
124
131
|
}
|
|
125
132
|
return null;
|
|
126
133
|
} else if (child.type === MenuButton || isSlot(child, MenuButton)) {
|
|
@@ -181,6 +188,7 @@ const Anchor = /*#__PURE__*/React.forwardRef(({
|
|
|
181
188
|
children: /*#__PURE__*/React.cloneElement(child, {
|
|
182
189
|
...anchorProps,
|
|
183
190
|
ref: anchorRef,
|
|
191
|
+
className: clsx(anchorProps.className, child.props.className),
|
|
184
192
|
onClick: onButtonClick,
|
|
185
193
|
onKeyDown: onButtonKeyDown
|
|
186
194
|
})
|
|
@@ -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-Wrapper-w6jU3{anchor-scope:--anchored-overlay-anchor}.prc-AnchoredOverlay-Anchor-DWRfK{anchor-name:--anchored-overlay-anchor}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z{position-anchor:--anchored-overlay-anchor;position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline;position-visibility:anchors-visible;position:fixed;z-index:100}.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-top]{bottom:anchor(top);left:anchor(left);margin-bottom:var(--base-size-4,.25rem)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-left]{margin-right:var(--base-size-4,.25rem);right:anchor(left);top:anchor(top)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-right]{left:anchor(right);margin-left:var(--base-size-4,.25rem);top:anchor(top)}
|
|
2
|
+
/*# sourceMappingURL=AnchoredOverlay-0f6f45b5.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,mCACE,sCACF,CAEA,kCAEE,qCACF,CAEA,2CAEE,yCAA0C,CAC1C,oEAGwB,CACxB,mCAAoC,CAEpC,cAAe,CADf,WA0BF,CAvBE,qEAGE,iBAAkB,CADlB,oDAEF,CAEA,kEAEE,kBAAmB,CACnB,iBAAkB,CAFlB,uCAGF,CAEA,mEAGE,sCAAgC,CAFhC,kBAAmB,CACnB,eAEF,CAEA,oEACE,kBAAmB,CAEnB,qCAA+B,CAD/B,eAEF","file":"AnchoredOverlay-0f6f45b5.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.Wrapper {\n anchor-scope: --anchored-overlay-anchor;\n}\n\n.Anchor {\n /* Anchor name, this is currently tied to `renderAnchor` */\n anchor-name: --anchored-overlay-anchor;\n}\n\n.AnchoredOverlay {\n /* Anchor position, this is currently tied to `<Overlay>` */\n position-anchor: --anchored-overlay-anchor;\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;\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\n &[data-side='outside-top'] {\n margin-bottom: var(--base-size-4);\n bottom: anchor(top);\n left: anchor(left);\n }\n\n &[data-side='outside-left'] {\n right: anchor(left);\n top: anchor(top);\n margin-right: var(--base-size-4);\n }\n\n &[data-side='outside-right'] {\n left: anchor(right);\n top: anchor(top);\n margin-left: var(--base-size-4);\n }\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,
|
|
1
|
+
{"version":3,"file":"AnchoredOverlay.d.ts","sourceRoot":"","sources":["../../src/AnchoredOverlay/AnchoredOverlay.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect } from 'react';
|
|
1
|
+
import { useCallback, useRef, useEffect } from 'react';
|
|
2
2
|
import { useFocusTrap } from '../hooks/useFocusTrap.js';
|
|
3
3
|
import { useFocusZone } from '../hooks/useFocusZone.js';
|
|
4
4
|
import { useId } from '../hooks/useId.js';
|
|
@@ -7,11 +7,22 @@ import { XIcon } from '@primer/octicons-react';
|
|
|
7
7
|
import classes from './AnchoredOverlay.module.css.js';
|
|
8
8
|
import { clsx } from 'clsx';
|
|
9
9
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
10
|
+
import { useFeatureFlag } from '../FeatureFlags/useFeatureFlag.js';
|
|
10
11
|
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
|
|
11
12
|
import { useRenderForcingRef } from '../hooks/useRenderForcingRef.js';
|
|
12
13
|
import { useAnchoredPosition } from '../hooks/useAnchoredPosition.js';
|
|
13
14
|
import Overlay from '../Overlay/Overlay.js';
|
|
14
15
|
|
|
16
|
+
const applyAnchorPositioningPolyfill = async () => {
|
|
17
|
+
if (typeof window !== 'undefined' && !('anchorName' in document.documentElement.style)) {
|
|
18
|
+
try {
|
|
19
|
+
await import('@oddbird/css-anchor-positioning');
|
|
20
|
+
} catch (e) {
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
console.warn('Failed to load CSS anchor positioning polyfill:', e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
15
26
|
const defaultVariant = {
|
|
16
27
|
regular: 'anchored',
|
|
17
28
|
narrow: 'anchored'
|
|
@@ -48,6 +59,7 @@ const AnchoredOverlay = ({
|
|
|
48
59
|
displayCloseButton = true,
|
|
49
60
|
closeButtonProps = defaultCloseButtonProps
|
|
50
61
|
}) => {
|
|
62
|
+
const cssAnchorPositioning = useFeatureFlag('primer_react_css_anchor_positioning');
|
|
51
63
|
const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
|
|
52
64
|
const [overlayRef, updateOverlayRef] = useRenderForcingRef();
|
|
53
65
|
const anchorId = useId(externalAnchorId);
|
|
@@ -91,12 +103,17 @@ const AnchoredOverlay = ({
|
|
|
91
103
|
displayInViewport,
|
|
92
104
|
onPositionChange: positionChange
|
|
93
105
|
}, [overlayRef.current]);
|
|
106
|
+
const hasLoadedAnchorPositioningPolyfill = useRef(false);
|
|
94
107
|
useEffect(() => {
|
|
95
108
|
// ensure overlay ref gets cleared when closed, so position can reset between closing/re-opening
|
|
96
109
|
if (!open && overlayRef.current) {
|
|
97
110
|
updateOverlayRef(null);
|
|
98
111
|
}
|
|
99
|
-
|
|
112
|
+
if (cssAnchorPositioning && !hasLoadedAnchorPositioningPolyfill.current) {
|
|
113
|
+
applyAnchorPositioningPolyfill();
|
|
114
|
+
hasLoadedAnchorPositioningPolyfill.current = true;
|
|
115
|
+
}
|
|
116
|
+
}, [open, overlayRef, updateOverlayRef, cssAnchorPositioning]);
|
|
100
117
|
useFocusZone({
|
|
101
118
|
containerRef: overlayRef,
|
|
102
119
|
disabled: !open || !position_0,
|
|
@@ -110,7 +127,11 @@ const AnchoredOverlay = ({
|
|
|
110
127
|
const showXIcon = onClose && variant.narrow === 'fullscreen' && displayCloseButton;
|
|
111
128
|
const XButtonAriaLabelledBy = closeButtonProps['aria-labelledby'];
|
|
112
129
|
const XButtonAriaLabel = closeButtonProps['aria-label'];
|
|
113
|
-
|
|
130
|
+
const {
|
|
131
|
+
className: overlayClassName,
|
|
132
|
+
...restOverlayProps
|
|
133
|
+
} = overlayProps || {};
|
|
134
|
+
const innerContent = /*#__PURE__*/jsxs(Fragment, {
|
|
114
135
|
children: [renderAnchor && renderAnchor({
|
|
115
136
|
ref: anchorRef,
|
|
116
137
|
id: anchorId,
|
|
@@ -118,30 +139,35 @@ const AnchoredOverlay = ({
|
|
|
118
139
|
'aria-expanded': open,
|
|
119
140
|
tabIndex: 0,
|
|
120
141
|
onClick: onAnchorClick,
|
|
121
|
-
onKeyDown: onAnchorKeyDown
|
|
142
|
+
onKeyDown: onAnchorKeyDown,
|
|
143
|
+
...(cssAnchorPositioning ? {
|
|
144
|
+
className: classes.Anchor
|
|
145
|
+
} : {})
|
|
122
146
|
}), open ? /*#__PURE__*/jsxs(Overlay, {
|
|
123
147
|
returnFocusRef: anchorRef,
|
|
124
148
|
onClickOutside: onClickOutside,
|
|
125
149
|
ignoreClickRefs: [anchorRef],
|
|
126
150
|
onEscape: onEscape,
|
|
127
151
|
role: "none",
|
|
128
|
-
visibility: position_0 ? 'visible' : 'hidden',
|
|
152
|
+
visibility: cssAnchorPositioning || position_0 ? 'visible' : 'hidden',
|
|
129
153
|
height: height,
|
|
130
154
|
width: width,
|
|
131
|
-
top: (position_0 === null || position_0 === void 0 ? void 0 : position_0.top) || 0,
|
|
132
|
-
left: (position_0 === null || position_0 === void 0 ? void 0 : position_0.left) || 0,
|
|
155
|
+
top: cssAnchorPositioning ? undefined : (position_0 === null || position_0 === void 0 ? void 0 : position_0.top) || 0,
|
|
156
|
+
left: cssAnchorPositioning ? undefined : (position_0 === null || position_0 === void 0 ? void 0 : position_0.left) || 0,
|
|
133
157
|
responsiveVariant: variant.narrow === 'fullscreen' ? 'fullscreen' : undefined,
|
|
134
|
-
anchorSide: position_0 === null || position_0 === void 0 ? void 0 : position_0.anchorSide,
|
|
135
|
-
className: className,
|
|
158
|
+
anchorSide: cssAnchorPositioning ? undefined : position_0 === null || position_0 === void 0 ? void 0 : position_0.anchorSide,
|
|
159
|
+
className: clsx(className, overlayClassName, cssAnchorPositioning ? classes.AnchoredOverlay : undefined),
|
|
136
160
|
preventOverflow: preventOverflow,
|
|
137
161
|
"data-component": "AnchoredOverlay",
|
|
138
|
-
...
|
|
162
|
+
...restOverlayProps,
|
|
139
163
|
ref: node => {
|
|
140
164
|
if (overlayProps !== null && overlayProps !== void 0 && overlayProps.ref) {
|
|
141
165
|
assignRef(overlayProps.ref, node);
|
|
142
166
|
}
|
|
143
167
|
updateOverlayRef(node);
|
|
144
168
|
},
|
|
169
|
+
"data-anchor-position": cssAnchorPositioning,
|
|
170
|
+
"data-side": cssAnchorPositioning ? side : position_0 === null || position_0 === void 0 ? void 0 : position_0.anchorSide,
|
|
145
171
|
children: [showXIcon ? /*#__PURE__*/jsx("div", {
|
|
146
172
|
className: classes.ResponsiveCloseButtonContainer,
|
|
147
173
|
children: /*#__PURE__*/jsx(IconButton, {
|
|
@@ -164,6 +190,13 @@ const AnchoredOverlay = ({
|
|
|
164
190
|
}) : null, children]
|
|
165
191
|
}) : null]
|
|
166
192
|
});
|
|
193
|
+
if (cssAnchorPositioning) {
|
|
194
|
+
return /*#__PURE__*/jsx("div", {
|
|
195
|
+
className: classes.Wrapper,
|
|
196
|
+
children: innerContent
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return innerContent;
|
|
167
200
|
};
|
|
168
201
|
function assignRef(ref, value) {
|
|
169
202
|
if (typeof ref === 'function') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import './AnchoredOverlay-
|
|
1
|
+
import './AnchoredOverlay-0f6f45b5.css';
|
|
2
2
|
|
|
3
|
-
var classes = {"ResponsiveCloseButtonContainer":"prc-AnchoredOverlay-ResponsiveCloseButtonContainer-nuium","ResponsiveCloseButton":"prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx"};
|
|
3
|
+
var classes = {"ResponsiveCloseButtonContainer":"prc-AnchoredOverlay-ResponsiveCloseButtonContainer-nuium","ResponsiveCloseButton":"prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx","Wrapper":"prc-AnchoredOverlay-Wrapper-w6jU3","Anchor":"prc-AnchoredOverlay-Anchor-DWRfK","AnchoredOverlay":"prc-AnchoredOverlay-AnchoredOverlay-fYg9Z"};
|
|
4
4
|
|
|
5
5
|
export { classes as default };
|
package/dist/Banner/Banner.js
CHANGED
|
@@ -3,7 +3,7 @@ import React, { useEffect, forwardRef } from 'react';
|
|
|
3
3
|
import { XIcon, AlertIcon, InfoIcon, CheckCircleIcon, StopIcon } from '@primer/octicons-react';
|
|
4
4
|
import { IconButton } from '../Button/IconButton.js';
|
|
5
5
|
import { ButtonComponent } from '../Button/Button.js';
|
|
6
|
-
import { useMergedRefs } from '../hooks/useMergedRefs.js';
|
|
6
|
+
import { useMergedRefs } from '../internal/hooks/useMergedRefs.js';
|
|
7
7
|
import { useId } from '../hooks/useId.js';
|
|
8
8
|
import classes from './Banner.module.css.js';
|
|
9
9
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { To } from 'history';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { type PolymorphicProps } from '../utils/modern-polymorphic';
|
|
3
4
|
export type BreadcrumbsProps = React.PropsWithChildren<{
|
|
4
5
|
/**
|
|
5
6
|
* Optional class name for the breadcrumbs container.
|
|
@@ -27,24 +28,38 @@ declare function Breadcrumbs({ className, children, style, overflow, variant }:
|
|
|
27
28
|
declare namespace Breadcrumbs {
|
|
28
29
|
var displayName: string;
|
|
29
30
|
}
|
|
30
|
-
type
|
|
31
|
-
type StyledBreadcrumbsItemProps<As extends React.ElementType> = {
|
|
32
|
-
as?: As;
|
|
31
|
+
type StyledBreadcrumbsItemProps<As extends React.ElementType = 'a'> = PolymorphicProps<As, 'a', {
|
|
33
32
|
to?: To;
|
|
34
33
|
selected?: boolean;
|
|
35
|
-
|
|
36
|
-
style?: React.CSSProperties;
|
|
37
|
-
} & DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? 'a' : As>, 'as'>;
|
|
34
|
+
}>;
|
|
38
35
|
export type BreadcrumbsItemProps<As extends React.ElementType = 'a'> = StyledBreadcrumbsItemProps<As>;
|
|
39
36
|
declare const _default: typeof Breadcrumbs & {
|
|
40
|
-
Item:
|
|
37
|
+
Item: (<As extends React.ElementType = "a">(props: (React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & {
|
|
38
|
+
to?: To;
|
|
39
|
+
selected?: boolean;
|
|
40
|
+
} extends infer T ? T extends React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & {
|
|
41
|
+
to?: To;
|
|
42
|
+
selected?: boolean;
|
|
43
|
+
} ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
|
|
44
|
+
as?: As | undefined;
|
|
45
|
+
} & React.RefAttributes<any>) => React.ReactNode) & {
|
|
46
|
+
displayName: string;
|
|
47
|
+
};
|
|
41
48
|
};
|
|
42
49
|
export default _default;
|
|
43
50
|
/**
|
|
44
51
|
* @deprecated Use the `Breadcrumbs` component instead (i.e. `<Breadcrumb>` → `<Breadcrumbs>`)
|
|
45
52
|
*/
|
|
46
53
|
export declare const Breadcrumb: typeof Breadcrumbs & {
|
|
47
|
-
Item:
|
|
54
|
+
Item: <As extends React.ElementType = "a">(props: (React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & {
|
|
55
|
+
to?: To;
|
|
56
|
+
selected?: boolean;
|
|
57
|
+
} extends infer T ? T extends React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & {
|
|
58
|
+
to?: To;
|
|
59
|
+
selected?: boolean;
|
|
60
|
+
} ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
|
|
61
|
+
as?: As | undefined;
|
|
62
|
+
} & React.RefAttributes<any>) => React.ReactNode;
|
|
48
63
|
};
|
|
49
64
|
/**
|
|
50
65
|
* @deprecated Use the `BreadcrumbsProps` type instead
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../src/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,SAAS,CAAA;AAC/B,OAAO,KAA6E,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../src/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,SAAS,CAAA;AAC/B,OAAO,KAA6E,MAAM,OAAO,CAAA;AAWjG,OAAO,EAAC,KAAK,gBAAgB,EAAkB,MAAM,6BAA6B,CAAA;AAElF,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACrD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAA;IAC7C;;;;OAIG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,CAAC,CAAA;AA8GF,iBAAS,WAAW,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAiB,EAAE,OAAkB,EAAC,EAAE,gBAAgB,qBA+MzG;kBA/MQ,WAAW;;;AA2NpB,KAAK,0BAA0B,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,GAAG,IAAI,gBAAgB,CACpF,EAAE,EACF,GAAG,EACH;IACE,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CACF,CAAA;AAsBD,MAAM,MAAM,oBAAoB,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,GAAG,IAAI,0BAA0B,CAAC,EAAE,CAAC,CAAA;;YAnBlG,EAAE,SAAS,KAAK,CAAC,WAAW;aANtB,EAAE;mBACI,OAAO;;aADb,EAAE;mBACI,OAAO;;;;;;;AA2BtB,wBAAiF;AAEjF;;GAEG;AACH,eAAO,MAAM,UAAU;WA3BpB,EAAE,SAAS,KAAK,CAAC,WAAW;aANtB,EAAE;mBACI,OAAO;;aADb,EAAE;mBACI,OAAO;;;;CAgCuD,CAAA;AAE7E;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,EAAE,SAAS,KAAK,CAAC,WAAW,GAAG,GAAG,IAAI,oBAAoB,CAAC,EAAE,CAAC,CAAA"}
|
|
@@ -8,6 +8,7 @@ import { KebabHorizontalIcon } from '@primer/octicons-react';
|
|
|
8
8
|
import { useResizeObserver } from '../hooks/useResizeObserver.js';
|
|
9
9
|
import { useOnEscapePress } from '../hooks/useOnEscapePress.js';
|
|
10
10
|
import { useOnOutsideClick } from '../hooks/useOnOutsideClick.js';
|
|
11
|
+
import { fixedForwardRef } from '../utils/modern-polymorphic.js';
|
|
11
12
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
12
13
|
import { useFeatureFlag } from '../FeatureFlags/useFeatureFlag.js';
|
|
13
14
|
import Details from '../Details/Details.js';
|
|
@@ -399,69 +400,26 @@ const ItemSeparator = () => {
|
|
|
399
400
|
}
|
|
400
401
|
return t0;
|
|
401
402
|
};
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
...rest
|
|
417
|
-
} = props);
|
|
418
|
-
$[0] = props;
|
|
419
|
-
$[1] = className;
|
|
420
|
-
$[2] = rest;
|
|
421
|
-
$[3] = selected;
|
|
422
|
-
$[4] = t0;
|
|
423
|
-
} else {
|
|
424
|
-
className = $[1];
|
|
425
|
-
rest = $[2];
|
|
426
|
-
selected = $[3];
|
|
427
|
-
t0 = $[4];
|
|
428
|
-
}
|
|
429
|
-
const Component = t0 === undefined ? "a" : t0;
|
|
430
|
-
const t1 = selected && "selected";
|
|
431
|
-
let t2;
|
|
432
|
-
if ($[5] !== className || $[6] !== t1) {
|
|
433
|
-
t2 = clsx(className, classes.Item, t1);
|
|
434
|
-
$[5] = className;
|
|
435
|
-
$[6] = t1;
|
|
436
|
-
$[7] = t2;
|
|
437
|
-
} else {
|
|
438
|
-
t2 = $[7];
|
|
439
|
-
}
|
|
440
|
-
const t3 = selected ? "page" : undefined;
|
|
441
|
-
let t4;
|
|
442
|
-
if ($[8] !== Component || $[9] !== ref || $[10] !== rest || $[11] !== t2 || $[12] !== t3) {
|
|
443
|
-
t4 = /*#__PURE__*/jsx(Component, {
|
|
444
|
-
className: t2,
|
|
445
|
-
"aria-current": t3,
|
|
446
|
-
ref: ref,
|
|
447
|
-
...rest
|
|
448
|
-
});
|
|
449
|
-
$[8] = Component;
|
|
450
|
-
$[9] = ref;
|
|
451
|
-
$[10] = rest;
|
|
452
|
-
$[11] = t2;
|
|
453
|
-
$[12] = t3;
|
|
454
|
-
$[13] = t4;
|
|
455
|
-
} else {
|
|
456
|
-
t4 = $[13];
|
|
457
|
-
}
|
|
458
|
-
return t4;
|
|
459
|
-
}
|
|
460
|
-
BreadcrumbsItemComponent.displayName = 'Breadcrumbs.Item';
|
|
461
|
-
const BreadcrumbsItem = /*#__PURE__*/React.forwardRef(BreadcrumbsItemComponent);
|
|
403
|
+
const BreadcrumbsItem = fixedForwardRef((props, ref) => {
|
|
404
|
+
const {
|
|
405
|
+
as: Component = 'a',
|
|
406
|
+
selected,
|
|
407
|
+
className,
|
|
408
|
+
...rest
|
|
409
|
+
} = props;
|
|
410
|
+
return /*#__PURE__*/jsx(Component, {
|
|
411
|
+
className: clsx(className, classes.Item, selected && 'selected'),
|
|
412
|
+
"aria-current": selected ? 'page' : undefined,
|
|
413
|
+
ref: ref,
|
|
414
|
+
...rest
|
|
415
|
+
});
|
|
416
|
+
});
|
|
462
417
|
Breadcrumbs.displayName = 'Breadcrumbs';
|
|
418
|
+
const BreadcrumbsItemWithDisplayName = Object.assign(BreadcrumbsItem, {
|
|
419
|
+
displayName: 'Breadcrumbs.Item'
|
|
420
|
+
});
|
|
463
421
|
var Breadcrumbs_default = Object.assign(Breadcrumbs, {
|
|
464
|
-
Item:
|
|
422
|
+
Item: BreadcrumbsItemWithDisplayName
|
|
465
423
|
});
|
|
466
424
|
|
|
467
425
|
/**
|
|
@@ -479,11 +437,15 @@ const Breadcrumb = Object.assign(Breadcrumbs, {
|
|
|
479
437
|
* @deprecated Use the `BreadcrumbsItemProps` type instead
|
|
480
438
|
*/
|
|
481
439
|
function _temp(item, index) {
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
440
|
+
const {
|
|
441
|
+
children,
|
|
442
|
+
selected,
|
|
443
|
+
as: Component,
|
|
444
|
+
...itemProps
|
|
445
|
+
} = item.props;
|
|
485
446
|
return /*#__PURE__*/jsx(ActionList.LinkItem, {
|
|
486
|
-
|
|
447
|
+
as: Component,
|
|
448
|
+
...itemProps,
|
|
487
449
|
"aria-current": selected ? "page" : undefined,
|
|
488
450
|
children: children
|
|
489
451
|
}, index);
|