@primer/react 38.36.0-rc.bd3520b7c → 38.36.0-rc.e29d259bd
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 -0
- package/dist/ActionBar/ActionBar.js +10 -8
- package/dist/ActionList/Heading.js +2 -1
- package/dist/ActionList/Item.js +282 -277
- package/dist/ActionList/LinkItem.js +11 -3
- package/dist/ActionList/index.d.ts +3 -0
- package/dist/ActionList/shared.d.ts +4 -0
- package/dist/CounterLabel/CounterLabel.js +5 -2
- package/dist/Details/Details.js +2 -1
- package/dist/Dialog/Dialog.js +3 -2
- package/dist/NavList/NavList.d.ts +2 -0
- package/dist/NavList/NavList.js +15 -11
- package/dist/PageHeader/PageHeader.js +2 -1
- package/dist/Portal/Portal.js +91 -29
- package/dist/SelectPanel/SelectPanel.js +26 -25
- package/dist/TooltipV2/Tooltip.js +3 -2
- package/dist/TreeView/TreeView.js +0 -1
- package/dist/UnderlineNav/UnderlineNav.d.ts +3 -2
- package/dist/UnderlineNav/UnderlineNav.js +1 -1
- package/dist/deprecated/ActionList/List.js +2 -1
- package/dist/experimental/SelectPanel2/SelectPanel.js +7 -4
- package/dist/hooks/useFocusZone.js +2 -1
- package/dist/hooks/useMenuInitialFocus.js +72 -57
- package/generated/components.json +7 -1
- package/package.json +2 -2
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { fixedForwardRef } from "../utils/modern-polymorphic.js";
|
|
2
|
+
import { Tooltip } from "../TooltipV2/Tooltip.js";
|
|
2
3
|
import { Item } from "./Item.js";
|
|
3
4
|
import Link from "../Link/Link.js";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
//#region src/ActionList/LinkItem.tsx
|
|
6
|
-
const LinkItemComponent = fixedForwardRef(({ active, inactiveText, variant, size, as: Component, className, ...props }, forwardedRef) => {
|
|
7
|
+
const LinkItemComponent = fixedForwardRef(({ active, inactiveText, variant, size, as: Component, className, _PrivateTooltipText, ...props }, forwardedRef) => {
|
|
7
8
|
return /*#__PURE__*/ jsx(Item, {
|
|
8
9
|
className,
|
|
9
10
|
active,
|
|
@@ -20,14 +21,21 @@ const LinkItemComponent = fixedForwardRef(({ active, inactiveText, variant, size
|
|
|
20
21
|
...rest,
|
|
21
22
|
children
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
+
const link = /*#__PURE__*/ jsx(Link, {
|
|
24
25
|
as: Component,
|
|
25
26
|
...rest,
|
|
26
27
|
...props,
|
|
27
28
|
onClick: clickHandler,
|
|
28
|
-
ref: forwardedRef,
|
|
29
|
+
ref: _PrivateTooltipText ? void 0 : forwardedRef,
|
|
29
30
|
children
|
|
30
31
|
});
|
|
32
|
+
return _PrivateTooltipText ? /*#__PURE__*/ jsx(Tooltip, {
|
|
33
|
+
ref: forwardedRef,
|
|
34
|
+
text: _PrivateTooltipText,
|
|
35
|
+
direction: "e",
|
|
36
|
+
delay: "medium",
|
|
37
|
+
children: link
|
|
38
|
+
}) : link;
|
|
31
39
|
},
|
|
32
40
|
children: props.children
|
|
33
41
|
});
|
|
@@ -60,6 +60,7 @@ declare const ActionList: (<As extends React.ElementType = "ul">(props: Distribu
|
|
|
60
60
|
role?: string;
|
|
61
61
|
className?: string;
|
|
62
62
|
}>>;
|
|
63
|
+
_PrivateTooltipText?: string;
|
|
63
64
|
className?: string;
|
|
64
65
|
groupId?: string;
|
|
65
66
|
renderItem?: (item: React.FC<React.PropsWithChildren<{
|
|
@@ -100,6 +101,8 @@ declare const ActionList: (<As extends React.ElementType = "ul">(props: Distribu
|
|
|
100
101
|
className?: string;
|
|
101
102
|
}, "as"> & {
|
|
102
103
|
as?: As | undefined;
|
|
104
|
+
} & {
|
|
105
|
+
_PrivateTooltipText?: string;
|
|
103
106
|
} & import("react").RefAttributes<unknown>) => React.ReactNode)>; /** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
|
104
107
|
Divider: FCWithSlotMarker<import("react").PropsWithChildren<ActionListDividerProps>>; /** Secondary text which provides additional information about an `Item`. */
|
|
105
108
|
Description: FCWithSlotMarker<import("react").PropsWithChildren<ActionListDescriptionProps>>; /** Icon (or similar) positioned before `Item` text. */
|
|
@@ -55,6 +55,10 @@ type ActionListItemProps<As extends React.ElementType = 'li'> = ExcludeSelectEve
|
|
|
55
55
|
* Private API for use internally only. Used by LinkItem to wrap contents in an anchor
|
|
56
56
|
*/
|
|
57
57
|
_PrivateItemWrapper?: React.FC<React.PropsWithChildren<MenuItemProps>>;
|
|
58
|
+
/**
|
|
59
|
+
* Private API for use internally only. Adds a tooltip to the interactive item.
|
|
60
|
+
*/
|
|
61
|
+
_PrivateTooltipText?: string;
|
|
58
62
|
className?: string;
|
|
59
63
|
groupId?: string;
|
|
60
64
|
renderItem?: (item: React.FC<React.PropsWithChildren<MenuItemProps>>) => React.ReactNode;
|
|
@@ -11,11 +11,14 @@ const CounterLabel = /*#__PURE__*/ forwardRef(({ variant, scheme, className, chi
|
|
|
11
11
|
")"
|
|
12
12
|
] });
|
|
13
13
|
const inferredVariant = variant || scheme || "secondary";
|
|
14
|
-
|
|
14
|
+
const counterProps = {
|
|
15
15
|
ref: forwardedRef,
|
|
16
16
|
["aria-hidden"]: "true",
|
|
17
17
|
["data-variant"]: inferredVariant,
|
|
18
|
-
...rest
|
|
18
|
+
...rest
|
|
19
|
+
};
|
|
20
|
+
return /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsx("span", {
|
|
21
|
+
...counterProps,
|
|
19
22
|
"data-component": dataComponent !== null && dataComponent !== void 0 ? dataComponent : "CounterLabel",
|
|
20
23
|
className: clsx(className, CounterLabel_module_css_default.CounterLabel),
|
|
21
24
|
children
|
package/dist/Details/Details.js
CHANGED
|
@@ -34,7 +34,8 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardRef) => {
|
|
|
34
34
|
t1 = () => {
|
|
35
35
|
const { current: details } = detailsRef;
|
|
36
36
|
if (!details) return;
|
|
37
|
-
|
|
37
|
+
const summary = details.querySelector("summary:not([data-default-summary])");
|
|
38
|
+
warning(summary === null, "The <Details> component must have a <summary> child component. You can either use <Details.Summary> or a native <summary> element.");
|
|
38
39
|
};
|
|
39
40
|
t2 = [];
|
|
40
41
|
$[5] = t1;
|
package/dist/Dialog/Dialog.js
CHANGED
|
@@ -140,7 +140,7 @@ const _Dialog = /*#__PURE__*/ React.forwardRef((props, forwardedRef) => {
|
|
|
140
140
|
});
|
|
141
141
|
const footer = (_slots$footer = slots.footer) !== null && _slots$footer !== void 0 ? _slots$footer : (renderFooter !== null && renderFooter !== void 0 ? renderFooter : DefaultFooter)(defaultedProps);
|
|
142
142
|
const hasFooter = footer != null;
|
|
143
|
-
|
|
143
|
+
const updateFooterButtonLayout = useCallback(() => {
|
|
144
144
|
if (!hasFooter) return;
|
|
145
145
|
const dialogElement = dialogRef.current;
|
|
146
146
|
if (!(dialogElement instanceof HTMLElement)) return;
|
|
@@ -150,7 +150,8 @@ const _Dialog = /*#__PURE__*/ React.forwardRef((props, forwardedRef) => {
|
|
|
150
150
|
const newLayout = bodyWrapper.clientHeight >= MIN_BODY_HEIGHT ? "wrap" : "scroll";
|
|
151
151
|
dialogElement.setAttribute("data-footer-button-layout", newLayout);
|
|
152
152
|
setFooterButtonLayout(newLayout);
|
|
153
|
-
}, [hasFooter])
|
|
153
|
+
}, [hasFooter]);
|
|
154
|
+
useResizeObserver(updateFooterButtonLayout, backdropRef);
|
|
154
155
|
const positionDataAttributes = typeof position === "string" ? { "data-position-regular": position } : Object.fromEntries(Object.entries(position).map(([key, value]) => {
|
|
155
156
|
return [`data-position-${key}`, value];
|
|
156
157
|
}));
|
|
@@ -24,6 +24,7 @@ type NavListItemProps<As extends React.ElementType = React.ElementType> = Polymo
|
|
|
24
24
|
href?: string;
|
|
25
25
|
'aria-current'?: 'page' | 'step' | 'location' | 'date' | 'time' | 'true' | 'false' | boolean;
|
|
26
26
|
inactiveText?: string;
|
|
27
|
+
tooltipText?: string;
|
|
27
28
|
}>;
|
|
28
29
|
type NavListSubNavProps = {
|
|
29
30
|
children: React.ReactNode;
|
|
@@ -59,6 +60,7 @@ declare const NavList: React.ForwardRefExoticComponent<Omit<NavListProps, "ref">
|
|
|
59
60
|
href?: string;
|
|
60
61
|
'aria-current'?: "page" | "step" | "location" | "date" | "time" | "true" | "false" | boolean;
|
|
61
62
|
inactiveText?: string;
|
|
63
|
+
tooltipText?: string;
|
|
62
64
|
}, "as"> & {
|
|
63
65
|
as?: As | undefined;
|
|
64
66
|
} & React.RefAttributes<unknown>) => React.ReactNode) & {
|
package/dist/NavList/NavList.js
CHANGED
|
@@ -165,7 +165,7 @@ const Heading = (t0) => {
|
|
|
165
165
|
};
|
|
166
166
|
Heading.displayName = "NavList.Heading";
|
|
167
167
|
Heading.__SLOT__ = Symbol("NavList.Heading");
|
|
168
|
-
const ItemComponent = fixedForwardRef(({ "aria-current": ariaCurrent, children, defaultOpen, as: Component, ...props }, ref) => {
|
|
168
|
+
const ItemComponent = fixedForwardRef(({ "aria-current": ariaCurrent, children, defaultOpen, tooltipText, as: Component, ...props }, ref) => {
|
|
169
169
|
const { depth } = React.useContext(SubNavContext);
|
|
170
170
|
const [slots, childrenWithoutSubNavOrTrailingAction] = useSlots(children, {
|
|
171
171
|
subNav: SubNav,
|
|
@@ -177,6 +177,7 @@ const ItemComponent = fixedForwardRef(({ "aria-current": ariaCurrent, children,
|
|
|
177
177
|
subNav,
|
|
178
178
|
depth,
|
|
179
179
|
defaultOpen,
|
|
180
|
+
tooltipText,
|
|
180
181
|
style: { "--subitem-depth": depth },
|
|
181
182
|
children: childrenWithoutSubNavOrTrailingAction
|
|
182
183
|
});
|
|
@@ -188,6 +189,7 @@ const ItemComponent = fixedForwardRef(({ "aria-current": ariaCurrent, children,
|
|
|
188
189
|
active: Boolean(ariaCurrent) && ariaCurrent !== "false",
|
|
189
190
|
style: { "--subitem-depth": depth },
|
|
190
191
|
"data-component": "NavList.Item",
|
|
192
|
+
_PrivateTooltipText: tooltipText,
|
|
191
193
|
...props,
|
|
192
194
|
children
|
|
193
195
|
});
|
|
@@ -207,8 +209,8 @@ function hasCurrentNavItem(node) {
|
|
|
207
209
|
}
|
|
208
210
|
function ItemWithSubNav(t0) {
|
|
209
211
|
var _ref;
|
|
210
|
-
const $ = c(
|
|
211
|
-
const { children, subNav, defaultOpen, style } = t0;
|
|
212
|
+
const $ = c(30);
|
|
213
|
+
const { children, subNav, defaultOpen, tooltipText, style } = t0;
|
|
212
214
|
const buttonId = useId$1();
|
|
213
215
|
const subNavId = useId$1();
|
|
214
216
|
let t1;
|
|
@@ -281,7 +283,7 @@ function ItemWithSubNav(t0) {
|
|
|
281
283
|
$[17] = t9;
|
|
282
284
|
} else t9 = $[17];
|
|
283
285
|
let t10;
|
|
284
|
-
if ($[18] !== buttonId || $[19] !== children || $[20] !== isOpen || $[21] !== style || $[22] !== subNavId || $[23] !== t5 || $[24] !== t9) {
|
|
286
|
+
if ($[18] !== buttonId || $[19] !== children || $[20] !== isOpen || $[21] !== style || $[22] !== subNavId || $[23] !== t5 || $[24] !== t9 || $[25] !== tooltipText) {
|
|
285
287
|
t10 = /*#__PURE__*/ jsxs(ActionList.Item, {
|
|
286
288
|
id: buttonId,
|
|
287
289
|
"aria-expanded": isOpen,
|
|
@@ -290,6 +292,7 @@ function ItemWithSubNav(t0) {
|
|
|
290
292
|
onSelect: t6,
|
|
291
293
|
style,
|
|
292
294
|
"data-component": "NavList.Item",
|
|
295
|
+
_PrivateTooltipText: tooltipText,
|
|
293
296
|
children: [
|
|
294
297
|
children,
|
|
295
298
|
t7,
|
|
@@ -303,18 +306,19 @@ function ItemWithSubNav(t0) {
|
|
|
303
306
|
$[22] = subNavId;
|
|
304
307
|
$[23] = t5;
|
|
305
308
|
$[24] = t9;
|
|
306
|
-
$[25] =
|
|
307
|
-
|
|
309
|
+
$[25] = tooltipText;
|
|
310
|
+
$[26] = t10;
|
|
311
|
+
} else t10 = $[26];
|
|
308
312
|
let t11;
|
|
309
|
-
if ($[
|
|
313
|
+
if ($[27] !== t10 || $[28] !== t4) {
|
|
310
314
|
t11 = /*#__PURE__*/ jsx(ItemWithSubNavContext.Provider, {
|
|
311
315
|
value: t4,
|
|
312
316
|
children: t10
|
|
313
317
|
});
|
|
314
|
-
$[
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
} else t11 = $[
|
|
318
|
+
$[27] = t10;
|
|
319
|
+
$[28] = t4;
|
|
320
|
+
$[29] = t11;
|
|
321
|
+
} else t11 = $[29];
|
|
318
322
|
return t11;
|
|
319
323
|
}
|
|
320
324
|
function _temp(open) {
|
|
@@ -72,7 +72,8 @@ const Root = /*#__PURE__*/ React.forwardRef((t0, forwardedRef) => {
|
|
|
72
72
|
if (/*#__PURE__*/ React.isValidElement(child_1) && (child_1.type === ContextArea || isSlot(child_1, ContextArea))) hasContextArea = true;
|
|
73
73
|
if (/*#__PURE__*/ React.isValidElement(child_1) && (child_1.type === LeadingAction || isSlot(child_1, LeadingAction))) hasLeadingAction = true;
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
const hasInteractiveContent = Array.from(titleArea.childNodes).some((child_2) => child_2 instanceof HTMLElement && isInteractive(child_2) || Array.from(child_2.childNodes).some((child_3) => child_3 instanceof HTMLElement && isInteractive(child_3)));
|
|
76
|
+
warning(hasInteractiveContent && (hasContextArea || hasLeadingAction), "When PageHeader.ContextArea or PageHeader.LeadingAction is present, we recommended not to include any interactive items in the PageHeader.TitleArea to make sure the focus order is logical.");
|
|
76
77
|
};
|
|
77
78
|
t3 = [children, readRef];
|
|
78
79
|
$[0] = children;
|
package/dist/Portal/Portal.js
CHANGED
|
@@ -1,43 +1,105 @@
|
|
|
1
1
|
import useIsomorphicLayoutEffect from "../utils/useIsomorphicLayoutEffect.js";
|
|
2
2
|
import { PortalContext } from "./PortalContext.js";
|
|
3
3
|
import { DEFAULT_PORTAL_CONTAINER_NAME, ensureDefaultPortal, getPortalRoot } from "./portalRoot.js";
|
|
4
|
-
import
|
|
4
|
+
import { c } from "react-compiler-runtime";
|
|
5
|
+
import React, { useContext, useSyncExternalStore } from "react";
|
|
5
6
|
import { createPortal } from "react-dom";
|
|
6
7
|
//#region src/Portal/Portal.tsx
|
|
8
|
+
const subscribe = () => () => {};
|
|
9
|
+
const getSnapshot = () => true;
|
|
10
|
+
const getServerSnapshot = () => false;
|
|
11
|
+
/**
|
|
12
|
+
* Returns `true` only when React is rendering on the client, and not as part of
|
|
13
|
+
* hydrating server-rendered markup.
|
|
14
|
+
*
|
|
15
|
+
* `Portal` needs this because React's server renderer throws when it encounters a
|
|
16
|
+
* portal, and portaled content is never part of the server-rendered markup.
|
|
17
|
+
*
|
|
18
|
+
* `useSyncExternalStore` is used rather than a `useEffect`/`useState` "is mounted"
|
|
19
|
+
* flag because it only defers the portal for the renders that need it: it returns
|
|
20
|
+
* `false` while server rendering and for the hydration pass (keeping hydration
|
|
21
|
+
* consistent with the server markup), but `true` from the very first render of a
|
|
22
|
+
* client-only render. That way client-rendered portals — the overwhelmingly common
|
|
23
|
+
* case for overlays, dialogs and menus — still mount their children in the same
|
|
24
|
+
* commit as the `Portal` itself, so refs into portaled content are populated by the
|
|
25
|
+
* time the parent's layout effects run.
|
|
26
|
+
*/
|
|
27
|
+
function useIsClientRender() {
|
|
28
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
29
|
+
}
|
|
7
30
|
/**
|
|
8
31
|
* Creates a React Portal, placing all children in a separate physical DOM root node.
|
|
9
32
|
* @see https://reactjs.org/docs/portals.html
|
|
10
33
|
*/
|
|
11
|
-
const Portal = (
|
|
34
|
+
const Portal = (t0) => {
|
|
35
|
+
const $ = c(12);
|
|
36
|
+
const { children, onMount, containerName: _containerName } = t0;
|
|
12
37
|
const { portalContainerName } = useContext(PortalContext);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
elementRef.current = div;
|
|
20
|
-
}
|
|
21
|
-
const element = elementRef.current;
|
|
22
|
-
useIsomorphicLayoutEffect(() => {
|
|
23
|
-
let containerName = _containerName !== null && _containerName !== void 0 ? _containerName : portalContainerName;
|
|
24
|
-
if (containerName === void 0) {
|
|
25
|
-
containerName = DEFAULT_PORTAL_CONTAINER_NAME;
|
|
26
|
-
ensureDefaultPortal();
|
|
27
|
-
}
|
|
28
|
-
const parentElement = getPortalRoot(containerName);
|
|
29
|
-
if (!parentElement) throw new Error(`Portal container '${containerName}' is not yet registered. Container must be registered with registerPortalRoot before use.`);
|
|
30
|
-
parentElement.appendChild(element);
|
|
31
|
-
onMount === null || onMount === void 0 || onMount();
|
|
32
|
-
return () => {
|
|
33
|
-
parentElement.removeChild(element);
|
|
38
|
+
const isClientRender = useIsClientRender();
|
|
39
|
+
const onMountRef = React.useRef(onMount);
|
|
40
|
+
let t1;
|
|
41
|
+
if ($[0] !== onMount) {
|
|
42
|
+
t1 = () => {
|
|
43
|
+
onMountRef.current = onMount;
|
|
34
44
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
]);
|
|
40
|
-
|
|
45
|
+
$[0] = onMount;
|
|
46
|
+
$[1] = t1;
|
|
47
|
+
} else t1 = $[1];
|
|
48
|
+
useIsomorphicLayoutEffect(t1);
|
|
49
|
+
const [element] = React.useState(_temp);
|
|
50
|
+
let t2;
|
|
51
|
+
let t3;
|
|
52
|
+
if ($[2] !== _containerName || $[3] !== element || $[4] !== isClientRender || $[5] !== portalContainerName) {
|
|
53
|
+
t2 = () => {
|
|
54
|
+
var _onMountRef$current;
|
|
55
|
+
if (!element || !isClientRender) return;
|
|
56
|
+
let containerName = _containerName !== null && _containerName !== void 0 ? _containerName : portalContainerName;
|
|
57
|
+
if (containerName === void 0) {
|
|
58
|
+
containerName = DEFAULT_PORTAL_CONTAINER_NAME;
|
|
59
|
+
ensureDefaultPortal();
|
|
60
|
+
}
|
|
61
|
+
const parentElement = getPortalRoot(containerName);
|
|
62
|
+
if (!parentElement) throw new Error(`Portal container '${containerName}' is not yet registered. Container must be registered with registerPortalRoot before use.`);
|
|
63
|
+
parentElement.appendChild(element);
|
|
64
|
+
(_onMountRef$current = onMountRef.current) === null || _onMountRef$current === void 0 || _onMountRef$current.call(onMountRef);
|
|
65
|
+
return () => {
|
|
66
|
+
parentElement.removeChild(element);
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
t3 = [
|
|
70
|
+
element,
|
|
71
|
+
isClientRender,
|
|
72
|
+
_containerName,
|
|
73
|
+
portalContainerName
|
|
74
|
+
];
|
|
75
|
+
$[2] = _containerName;
|
|
76
|
+
$[3] = element;
|
|
77
|
+
$[4] = isClientRender;
|
|
78
|
+
$[5] = portalContainerName;
|
|
79
|
+
$[6] = t2;
|
|
80
|
+
$[7] = t3;
|
|
81
|
+
} else {
|
|
82
|
+
t2 = $[6];
|
|
83
|
+
t3 = $[7];
|
|
84
|
+
}
|
|
85
|
+
useIsomorphicLayoutEffect(t2, t3);
|
|
86
|
+
let t4;
|
|
87
|
+
if ($[8] !== children || $[9] !== element || $[10] !== isClientRender) {
|
|
88
|
+
t4 = element && isClientRender ? /*#__PURE__*/ createPortal(children, element) : null;
|
|
89
|
+
$[8] = children;
|
|
90
|
+
$[9] = element;
|
|
91
|
+
$[10] = isClientRender;
|
|
92
|
+
$[11] = t4;
|
|
93
|
+
} else t4 = $[11];
|
|
94
|
+
return t4;
|
|
41
95
|
};
|
|
96
|
+
function _temp() {
|
|
97
|
+
if (typeof document === "undefined") return null;
|
|
98
|
+
const div = document.createElement("div");
|
|
99
|
+
div.setAttribute("data-component", "Portal");
|
|
100
|
+
div.style.position = "relative";
|
|
101
|
+
div.style.zIndex = "1";
|
|
102
|
+
return div;
|
|
103
|
+
}
|
|
42
104
|
//#endregion
|
|
43
105
|
export { Portal };
|
|
@@ -435,6 +435,31 @@ function Panel({ open, onOpenChange, renderAnchor = defaultRenderAnchor, anchorR
|
|
|
435
435
|
if (event.key !== "/" && !isAlphabetKey(event.nativeEvent)) return;
|
|
436
436
|
event.stopPropagation();
|
|
437
437
|
}, [overlayProps]);
|
|
438
|
+
const mergedOverlayProps = useMemo(() => ({
|
|
439
|
+
role: "dialog",
|
|
440
|
+
"aria-labelledby": titleId,
|
|
441
|
+
"aria-describedby": subtitle ? subtitleId : void 0,
|
|
442
|
+
...overlayProps,
|
|
443
|
+
...variant === "modal" ? {
|
|
444
|
+
top: "50vh",
|
|
445
|
+
left: "50vw",
|
|
446
|
+
anchorSide: void 0
|
|
447
|
+
} : {},
|
|
448
|
+
style: {
|
|
449
|
+
transform: variant === "modal" ? "translate(-50%, -50%)" : void 0,
|
|
450
|
+
...isKeyboardVisible ? { maxHeight: availablePanelHeight !== void 0 ? `${availablePanelHeight}px` : "auto" } : {}
|
|
451
|
+
},
|
|
452
|
+
onKeyDown: preventBubbling
|
|
453
|
+
}), [
|
|
454
|
+
titleId,
|
|
455
|
+
subtitle,
|
|
456
|
+
subtitleId,
|
|
457
|
+
overlayProps,
|
|
458
|
+
variant,
|
|
459
|
+
isKeyboardVisible,
|
|
460
|
+
availablePanelHeight,
|
|
461
|
+
preventBubbling
|
|
462
|
+
]);
|
|
438
463
|
return /*#__PURE__*/ jsxs(Fragment, { children: [/*#__PURE__*/ jsx(AnchoredOverlay, {
|
|
439
464
|
renderAnchor: renderMenuAnchor,
|
|
440
465
|
anchorRef,
|
|
@@ -442,31 +467,7 @@ function Panel({ open, onOpenChange, renderAnchor = defaultRenderAnchor, anchorR
|
|
|
442
467
|
open,
|
|
443
468
|
onOpen,
|
|
444
469
|
onClose,
|
|
445
|
-
overlayProps:
|
|
446
|
-
role: "dialog",
|
|
447
|
-
"aria-labelledby": titleId,
|
|
448
|
-
"aria-describedby": subtitle ? subtitleId : void 0,
|
|
449
|
-
...overlayProps,
|
|
450
|
-
...variant === "modal" ? {
|
|
451
|
-
top: "50vh",
|
|
452
|
-
left: "50vw",
|
|
453
|
-
anchorSide: void 0
|
|
454
|
-
} : {},
|
|
455
|
-
style: {
|
|
456
|
-
transform: variant === "modal" ? "translate(-50%, -50%)" : void 0,
|
|
457
|
-
...isKeyboardVisible ? { maxHeight: availablePanelHeight !== void 0 ? `${availablePanelHeight}px` : "auto" } : {}
|
|
458
|
-
},
|
|
459
|
-
onKeyDown: preventBubbling
|
|
460
|
-
}), [
|
|
461
|
-
titleId,
|
|
462
|
-
subtitle,
|
|
463
|
-
subtitleId,
|
|
464
|
-
overlayProps,
|
|
465
|
-
variant,
|
|
466
|
-
isKeyboardVisible,
|
|
467
|
-
availablePanelHeight,
|
|
468
|
-
preventBubbling
|
|
469
|
-
]),
|
|
470
|
+
overlayProps: mergedOverlayProps,
|
|
470
471
|
focusTrapSettings,
|
|
471
472
|
focusZoneSettings,
|
|
472
473
|
height,
|
|
@@ -100,10 +100,11 @@ const Tooltip = /*#__PURE__*/ React.forwardRef(({ direction = "s", text, type =
|
|
|
100
100
|
const trigger = readTriggerRef.current;
|
|
101
101
|
tooltip.showPopover();
|
|
102
102
|
setIsPopoverOpen(true);
|
|
103
|
-
const
|
|
103
|
+
const settings = {
|
|
104
104
|
side: directionToPosition[direction].side,
|
|
105
105
|
align: directionToPosition[direction].align
|
|
106
|
-
}
|
|
106
|
+
};
|
|
107
|
+
const { top, left, anchorAlign, anchorSide } = getAnchoredPosition(tooltip, trigger, settings);
|
|
107
108
|
const calculatedDirection = positionToDirection[`${anchorSide}-${anchorAlign}`];
|
|
108
109
|
setCalculatedDirection(calculatedDirection);
|
|
109
110
|
tooltip.style.top = `${top}px`;
|
|
@@ -17,8 +17,9 @@ type UnderlineNavProps = {
|
|
|
17
17
|
*/
|
|
18
18
|
variant?: 'inset' | 'flush';
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* Controls the container width below which icons are hidden to save space. Defaults to `medium`.
|
|
21
|
+
* To keep icons visible in a narrow container, use a smaller breakpoint such as `xsmall`, or set to `null` to
|
|
22
|
+
* always show icons.
|
|
22
23
|
*/
|
|
23
24
|
hideIconsBreakpoint?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | null;
|
|
24
25
|
};
|
|
@@ -22,7 +22,7 @@ const UnderlineNav = /*#__PURE__*/ forwardRef((t0, forwardedRef) => {
|
|
|
22
22
|
const as = t1 === void 0 ? "nav" : t1;
|
|
23
23
|
const loadingCounters = t2 === void 0 ? false : t2;
|
|
24
24
|
const variant = t3 === void 0 ? "inset" : t3;
|
|
25
|
-
const hideIconsBreakpoint = t4 === void 0 ? "
|
|
25
|
+
const hideIconsBreakpoint = t4 === void 0 ? "medium" : t4;
|
|
26
26
|
const backupRef = useRef(null);
|
|
27
27
|
const navRef = forwardedRef !== null && forwardedRef !== void 0 ? forwardedRef : backupRef;
|
|
28
28
|
const listRef = useRef(null);
|
|
@@ -59,7 +59,8 @@ const List = /*#__PURE__*/ React.forwardRef((props, forwardedRef) => {
|
|
|
59
59
|
const { firstGroupStyle, lastGroupStyle, headerStyle, itemStyle } = useListVariant(restProps.variant);
|
|
60
60
|
const renderGroup = (groupProps) => {
|
|
61
61
|
var _ref;
|
|
62
|
-
|
|
62
|
+
const GroupComponent = ((_ref = "renderGroup" in groupProps && groupProps.renderGroup) !== null && _ref !== void 0 ? _ref : restProps.renderGroup) || Group;
|
|
63
|
+
return /*#__PURE__*/ createElement(GroupComponent, {
|
|
63
64
|
...groupProps,
|
|
64
65
|
key: groupProps.groupId
|
|
65
66
|
});
|
|
@@ -43,10 +43,11 @@ const responsiveButtonSizes = {
|
|
|
43
43
|
const Panel = ({ title, description, variant: propsVariant, selectionVariant = "multiple", id, defaultOpen = false, open: propsOpen, anchorRef: providedAnchorRef, anchoredPositionSettings, onCancel: propsOnCancel, onClearSelection: propsOnClearSelection, onSubmit: propsOnSubmit, width = "medium", maxHeight = "large", className, ...props }) => {
|
|
44
44
|
var _position$top, _position$left, _slots$header;
|
|
45
45
|
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
46
|
-
const
|
|
46
|
+
const responsiveVariants = Object.assign({
|
|
47
47
|
regular: "anchored",
|
|
48
48
|
narrow: "full-screen"
|
|
49
|
-
}, typeof propsVariant === "string" ? { regular: propsVariant } : propsVariant)
|
|
49
|
+
}, typeof propsVariant === "string" ? { regular: propsVariant } : propsVariant);
|
|
50
|
+
const currentVariant = useResponsiveValue(responsiveVariants, "anchored");
|
|
50
51
|
if (propsOpen !== void 0 && internalOpen !== propsOpen) setInternalOpen(propsOpen);
|
|
51
52
|
let Anchor;
|
|
52
53
|
const anchorRef = useProvidedRefOrCreate(providedAnchorRef);
|
|
@@ -348,18 +349,20 @@ const SelectPanelFooter = ({ ...props }) => {
|
|
|
348
349
|
SelectPanelFooter.displayName = "SelectPanelFooter";
|
|
349
350
|
SelectPanelFooter.__SLOT__ = Symbol("SelectPanel.Footer");
|
|
350
351
|
const SecondaryButton = (props) => {
|
|
352
|
+
const size = useResponsiveValue(responsiveButtonSizes, "small");
|
|
351
353
|
return /*#__PURE__*/ jsx(ButtonComponent, {
|
|
352
354
|
type: "button",
|
|
353
|
-
size
|
|
355
|
+
size,
|
|
354
356
|
block: true,
|
|
355
357
|
...props
|
|
356
358
|
});
|
|
357
359
|
};
|
|
358
360
|
SecondaryButton.displayName = "SecondaryButton";
|
|
359
361
|
const SecondaryLink = ({ className, ...props }) => {
|
|
362
|
+
const size = useResponsiveValue(responsiveButtonSizes, "small");
|
|
360
363
|
return /*#__PURE__*/ jsx(ButtonComponent, {
|
|
361
364
|
as: Link,
|
|
362
|
-
size
|
|
365
|
+
size,
|
|
363
366
|
variant: "invisible",
|
|
364
367
|
block: true,
|
|
365
368
|
...props,
|
|
@@ -5,7 +5,8 @@ import { FocusKeys as FocusKeys$1, focusZone } from "@primer/behaviors";
|
|
|
5
5
|
function useFocusZone(settings = {}, dependencies = []) {
|
|
6
6
|
const containerRef = useProvidedRefOrCreate(settings.containerRef);
|
|
7
7
|
const useActiveDescendant = !!settings.activeDescendantFocus;
|
|
8
|
-
const
|
|
8
|
+
const passedActiveDescendantRef = typeof settings.activeDescendantFocus === "boolean" || !settings.activeDescendantFocus ? void 0 : settings.activeDescendantFocus;
|
|
9
|
+
const activeDescendantControlRef = useProvidedRefOrCreate(passedActiveDescendantRef);
|
|
9
10
|
const disabled = settings.disabled;
|
|
10
11
|
const abortController = React.useRef();
|
|
11
12
|
useEffect(() => {
|