@primer/react 0.0.0-20260508193930 → 0.0.0-20260508213558
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 +18 -4
- package/dist/ActionBar/ActionBar-a41224b2.css +2 -0
- package/dist/ActionBar/ActionBar-a41224b2.css.map +1 -0
- package/dist/ActionBar/ActionBar.d.ts +1 -1
- package/dist/ActionBar/ActionBar.d.ts.map +1 -1
- package/dist/ActionBar/ActionBar.js +381 -293
- package/dist/ActionBar/ActionBar.module.css.js +2 -2
- package/dist/ActionBar/index.d.ts +1 -1
- package/dist/ActionList/Item.js +2 -2
- package/dist/ActionList/LinkItem.d.ts +1 -1
- package/dist/ActionList/index.d.ts +13 -2
- package/dist/ActionList/index.d.ts.map +1 -1
- package/dist/ActionList/index.js +3 -0
- package/dist/AnchoredOverlay/{AnchoredOverlay-0c26c5f8.css → AnchoredOverlay-ec9e15fc.css} +2 -2
- package/dist/AnchoredOverlay/AnchoredOverlay-ec9e15fc.css.map +1 -0
- package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
- package/dist/AnchoredOverlay/AnchoredOverlay.js +63 -26
- package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +1 -1
- package/dist/Autocomplete/Autocomplete.d.ts +1 -1
- package/dist/DataTable/sorting.d.ts +1 -1
- package/dist/FeatureFlags/DefaultFeatureFlags.d.ts.map +1 -1
- package/dist/FeatureFlags/DefaultFeatureFlags.js +2 -1
- package/dist/TextInput/TextInput.d.ts +1 -1
- package/dist/TextInputWithTokens/TextInputWithTokens.d.ts +3 -3
- package/dist/TreeView/useRovingTabIndex.d.ts +9 -6
- package/dist/TreeView/useRovingTabIndex.d.ts.map +1 -1
- package/dist/TreeView/useRovingTabIndex.js +91 -47
- package/dist/experimental/SelectPanel2/mock-story-data.d.ts +3 -3
- package/dist/hooks/useSyncedState.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/components/TextInputInnerAction.d.ts +1 -1
- package/dist/theme.d.ts +1 -1
- package/dist/utils/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/utils/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/ActionBar/ActionBar-e2c44be2.css +0 -2
- package/dist/ActionBar/ActionBar-e2c44be2.css.map +0 -1
- package/dist/AnchoredOverlay/AnchoredOverlay-0c26c5f8.css.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import './ActionBar-
|
|
1
|
+
import './ActionBar-a41224b2.css';
|
|
2
2
|
|
|
3
|
-
var styles = {"List":"prc-ActionBar-List-9uz46","
|
|
3
|
+
var styles = {"List":"prc-ActionBar-List-9uz46","Divider":"prc-ActionBar-Divider-6V8yH","Nav":"prc-ActionBar-Nav-9spON","Group":"prc-ActionBar-Group-peNCk"};
|
|
4
4
|
|
|
5
5
|
export { styles as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { ActionBarProps, ActionBarMenuProps, ActionBarMenuItemProps } from './ActionBar';
|
|
2
2
|
declare const ActionBar: import("react").FC<import("react").PropsWithChildren<import("./ActionBar").ActionBarProps>> & {
|
|
3
3
|
IconButton: import("react").ForwardRefExoticComponent<import("./ActionBar").ActionBarIconButtonProps & import("react").RefAttributes<unknown>>;
|
|
4
|
-
Divider: () => import("react").JSX.Element;
|
|
4
|
+
Divider: () => import("react").JSX.Element | null;
|
|
5
5
|
Group: import("react").ForwardRefExoticComponent<{
|
|
6
6
|
children?: import("react").ReactNode | undefined;
|
|
7
7
|
} & import("react").RefAttributes<unknown>>;
|
package/dist/ActionList/Item.js
CHANGED
|
@@ -154,8 +154,8 @@ const slotsConfig = {
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
// Pre-allocated array for selectableRoles check, avoids per-render allocation
|
|
157
|
-
const selectableRoles = ['menuitemradio', 'menuitemcheckbox', 'option'];
|
|
158
|
-
const listRoleTypes = ['listbox', 'menu', 'list'];
|
|
157
|
+
const selectableRoles = ['menuitemradio', 'menuitemcheckbox', 'option', 'treeitem'];
|
|
158
|
+
const listRoleTypes = ['listbox', 'menu', 'list', 'tree'];
|
|
159
159
|
const UnwrappedItem = (t0, forwardedRef) => {
|
|
160
160
|
var _slots$trailingVisual, _slots$description$pr, _slots$description;
|
|
161
161
|
const $ = c(159);
|
|
@@ -14,7 +14,7 @@ type LinkProps = {
|
|
|
14
14
|
className?: string;
|
|
15
15
|
};
|
|
16
16
|
export type ActionListLinkItemProps = Pick<ActionListItemProps, 'active' | 'children' | 'inactiveText' | 'variant' | 'size'> & LinkProps;
|
|
17
|
-
declare const LinkItemComponent: <As extends React.ElementType = "a">(props: (React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & Pick<ActionListItemProps, "
|
|
17
|
+
declare const LinkItemComponent: <As extends React.ElementType = "a">(props: (React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & Pick<ActionListItemProps, "active" | "children" | "inactiveText" | "size" | "variant"> & LinkProps extends infer T ? T extends React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & Pick<ActionListItemProps, "active" | "children" | "inactiveText" | "size" | "variant"> & LinkProps ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
|
|
18
18
|
as?: As | undefined;
|
|
19
19
|
} & React.RefAttributes<unknown>) => React.ReactNode;
|
|
20
20
|
export declare const LinkItem: WithSlotMarker<typeof LinkItemComponent>;
|
|
@@ -31,6 +31,17 @@ export declare const ActionList: (<As extends React.ElementType = "ul">(props: (
|
|
|
31
31
|
} ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
|
|
32
32
|
as?: As | undefined;
|
|
33
33
|
} & import("react").RefAttributes<unknown>) => React.ReactNode) & {
|
|
34
|
+
/** Context for the `ActionList` container. */
|
|
35
|
+
ContainerContext: import("react").Context<{
|
|
36
|
+
container?: string;
|
|
37
|
+
listRole?: import("../utils/types").AriaRole;
|
|
38
|
+
selectionVariant?: "single" | "multiple" | "radio";
|
|
39
|
+
selectionAttribute?: "aria-selected" | "aria-checked";
|
|
40
|
+
listLabelledBy?: string;
|
|
41
|
+
afterSelect?: Function;
|
|
42
|
+
enableFocusZone?: boolean;
|
|
43
|
+
defaultTrailingVisual?: React.ReactElement<any>;
|
|
44
|
+
}>;
|
|
34
45
|
/** Collects related `Items` in an `ActionList`. */
|
|
35
46
|
Group: import("../utils/types").FCWithSlotMarker<import("react").PropsWithChildren<import("./Group").ActionListGroupProps>>;
|
|
36
47
|
/** An actionable or selectable `Item` */
|
|
@@ -84,7 +95,7 @@ export declare const ActionList: (<As extends React.ElementType = "ul">(props: (
|
|
|
84
95
|
__SLOT__: symbol;
|
|
85
96
|
};
|
|
86
97
|
/** A `Item` that renders a full-size anchor inside ListItem */
|
|
87
|
-
LinkItem: import("../utils/types").WithSlotMarker<(<As extends React.ElementType = "a">(props: (import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<import("./shared").ActionListItemProps, "
|
|
98
|
+
LinkItem: import("../utils/types").WithSlotMarker<(<As extends React.ElementType = "a">(props: (import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<import("./shared").ActionListItemProps, "active" | "children" | "inactiveText" | "size" | "variant"> & {
|
|
88
99
|
download?: string;
|
|
89
100
|
href?: string;
|
|
90
101
|
hrefLang?: string;
|
|
@@ -95,7 +106,7 @@ export declare const ActionList: (<As extends React.ElementType = "ul">(props: (
|
|
|
95
106
|
type?: string;
|
|
96
107
|
referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>["referrerPolicy"];
|
|
97
108
|
className?: string;
|
|
98
|
-
} extends infer T ? T extends import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<import("./shared").ActionListItemProps, "
|
|
109
|
+
} extends infer T ? T extends import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<import("./shared").ActionListItemProps, "active" | "children" | "inactiveText" | "size" | "variant"> & {
|
|
99
110
|
download?: string;
|
|
100
111
|
href?: string;
|
|
101
112
|
hrefLang?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ActionList/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ActionList/index.ts"],"names":[],"mappings":"AAWA,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,8CAA8C;;;;;;;;;;;IAE9C,mDAAmD;;IAGnD,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGzC,+DAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;IAG/D,iEAAiE;;IAGjE,4EAA4E;;IAG5E,uDAAuD;;IAGvD,sDAAsD;;IAGtD,mCAAmC;;IAGnC,gGAAgG;;;;IAGhG,qCAAqC;;IAGrC,uBAAuB;;CAEvB,CAAA"}
|
package/dist/ActionList/index.js
CHANGED
|
@@ -7,11 +7,14 @@ import { Description } from './Description.js';
|
|
|
7
7
|
import { TrailingAction } from './TrailingAction.js';
|
|
8
8
|
import { TrailingVisual, LeadingVisual } from './Visuals.js';
|
|
9
9
|
import { Heading } from './Heading.js';
|
|
10
|
+
import { ActionListContainerContext } from './ActionListContainerContext.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Collection of list-related components.
|
|
13
14
|
*/
|
|
14
15
|
const ActionList = Object.assign(List, {
|
|
16
|
+
/** Context for the `ActionList` container. */
|
|
17
|
+
ContainerContext: ActionListContainerContext,
|
|
15
18
|
/** Collects related `Items` in an `ActionList`. */
|
|
16
19
|
Group,
|
|
17
20
|
/** An actionable or selectable `Item` */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.prc-AnchoredOverlay-ResponsiveCloseButtonContainer-nuium{position:relative}.prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx{display:none;position:absolute;right:var(--base-size-8,.5rem);top:var(--base-size-8,.5rem)}@media screen and (max-width:calc(48rem - 0.02px)){.prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx{display:inline-grid}}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z{position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline;position-visibility:anchors-visible;position:fixed!important;z-index:100}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[popover]{border:0;inset:auto;margin:0;max-width:none;padding:0}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-bottom]{left:anchor(left);top:calc(anchor(bottom) + var(--base-size-4,.25rem))}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-bottom][data-align=left]{left:auto;right:calc(anchor(right) - var(--anchored-overlay-anchor-offset-left))}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-top]{bottom:anchor(top);left:anchor(left);margin-bottom:var(--base-size-4,.25rem)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-top][data-align=left]{left:auto;right:anchor(right)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-left]{margin-right:var(--base-size-4,.25rem);right:anchor(left);top:anchor(top);position-try-fallbacks:flip-inline,flip-block,flip-start,--outside-left-to-bottom}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-right]{left:anchor(right);margin-left:var(--base-size-4,.25rem);top:anchor(top);position-try-fallbacks:flip-inline,flip-block,flip-start,--outside-right-to-bottom}@position-try --outside-left-to-bottom{margin:0;right:anchor(right);top:calc(anchor(bottom) + var(--base-size-4,.25rem));width:auto}@position-try --outside-right-to-bottom{left:anchor(left);margin:0;top:calc(anchor(bottom) + var(--base-size-4,.25rem));width:auto}
|
|
2
|
-
/*# sourceMappingURL=AnchoredOverlay-
|
|
1
|
+
.prc-AnchoredOverlay-ResponsiveCloseButtonContainer-nuium{position:relative}.prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx{display:none;position:absolute;right:var(--base-size-8,.5rem);top:var(--base-size-8,.5rem)}@media screen and (max-width:calc(48rem - 0.02px)){.prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx{display:inline-grid}}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z{position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline;position-visibility:anchors-visible;position:fixed!important;z-index:100}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[popover]{border:0;inset:auto;margin:0;max-width:none;padding:0}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-bottom]{left:anchor(left);top:calc(anchor(bottom) + var(--base-size-4,.25rem))}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-bottom][data-align=left]{left:auto;right:calc(anchor(right) - var(--anchored-overlay-anchor-offset-left))}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-top]{bottom:anchor(top);left:anchor(left);margin-bottom:var(--base-size-4,.25rem)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-top][data-align=left]{left:auto;right:anchor(right)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-left]{margin-right:var(--base-size-4,.25rem);right:anchor(left);top:var(--anchored-overlay-top-override,anchor(top));position-try-fallbacks:flip-inline,flip-block,flip-start,--outside-left-to-bottom}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-right]{left:anchor(right);margin-left:var(--base-size-4,.25rem);top:var(--anchored-overlay-top-override,anchor(top));position-try-fallbacks:flip-inline,flip-block,flip-start,--outside-right-to-bottom}@position-try --outside-left-to-bottom{margin:0;right:anchor(right);top:calc(anchor(bottom) + var(--base-size-4,.25rem));width:auto}@position-try --outside-right-to-bottom{left:anchor(left);margin:0;top:calc(anchor(bottom) + var(--base-size-4,.25rem));width:auto}
|
|
2
|
+
/*# sourceMappingURL=AnchoredOverlay-ec9e15fc.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/AnchoredOverlay/AnchoredOverlay.module.css.js"],"names":[],"mappings":"AAAA,0DACE,iBACF,CAEA,iDAIE,YAAa,CAHb,iBAAkB,CAElB,8BAAyB,CADzB,4BAOF,CAHE,mDANF,iDAOI,mBAEJ,CADE,CAGF,2CACE,oEAGwB,CACxB,mCAAoC,CAEpC,wBAA0B,CAD1B,WAsDF,CAnDE,oDAIE,QAAS,CAHT,UAAW,CACX,QAAS,CAGT,cAAe,CAFf,SAGF,CAEA,qEAGE,iBAAkB,CADlB,oDAOF,CAJE,sFACE,SAAU,CACV,sEACF,CAGF,kEAEE,kBAAmB,CACnB,iBAAkB,CAFlB,uCAQF,CAJE,mFACE,SAAU,CACV,mBACF,CAGF,mEAWE,sCAAgC,CAVhC,kBAAmB,CASnB,oDAAsD,CAEtD,iFACF,CAEA,oEACE,kBAAmB,CAEnB,qCAA+B,CAD/B,oDAAsD,CAEtD,kFACF,CAGF,uCAGE,QAAS,CAFT,mBAAoB,CACpB,oDAA8C,CAE9C,UACF,CAEA,wCACE,iBAAkB,CAElB,QAAS,CADT,oDAA8C,CAE9C,UACF","file":"AnchoredOverlay-ec9e15fc.css","sourcesContent":[".ResponsiveCloseButtonContainer {\n position: relative;\n}\n\n.ResponsiveCloseButton {\n position: absolute;\n top: var(--base-size-8);\n right: var(--base-size-8);\n display: none;\n\n @media screen and (--viewportRange-narrow) {\n display: inline-grid;\n }\n}\n\n.AnchoredOverlay {\n position-try-fallbacks:\n flip-block,\n flip-inline,\n flip-block flip-inline;\n position-visibility: anchors-visible;\n z-index: 100;\n position: fixed !important;\n\n &[popover] {\n inset: auto;\n margin: 0;\n padding: 0;\n border: 0;\n max-width: none;\n }\n\n &[data-side='outside-bottom'] {\n /* stylelint-disable primer/spacing */\n top: calc(anchor(bottom) + var(--base-size-4));\n left: anchor(left);\n\n &[data-align='left'] {\n left: auto;\n right: calc(anchor(right) - var(--anchored-overlay-anchor-offset-left));\n }\n }\n\n &[data-side='outside-top'] {\n margin-bottom: var(--base-size-4);\n bottom: anchor(top);\n left: anchor(left);\n\n &[data-align='left'] {\n left: auto;\n right: anchor(right);\n }\n }\n\n &[data-side='outside-left'] {\n right: anchor(left);\n /* Falls back to `anchor(top)` when JS hasn't overridden it. JS sets the\n override when the overlay's bottom would overflow the viewport so we\n can lift it up to keep the bottom edge on screen, mirroring the JS\n anchored-positioning code path.\n\n This override only applies when CSS cannot find space using the default position -\n or any of its defined fallbacks.\n */\n top: var(--anchored-overlay-top-override, anchor(top));\n margin-right: var(--base-size-4);\n position-try-fallbacks: flip-inline, flip-block, flip-start, --outside-left-to-bottom;\n }\n\n &[data-side='outside-right'] {\n left: anchor(right);\n top: var(--anchored-overlay-top-override, anchor(top));\n margin-left: var(--base-size-4);\n position-try-fallbacks: flip-inline, flip-block, flip-start, --outside-right-to-bottom;\n }\n}\n\n@position-try --outside-left-to-bottom {\n right: anchor(right);\n top: calc(anchor(bottom) + var(--base-size-4));\n margin: 0;\n width: auto;\n}\n\n@position-try --outside-right-to-bottom {\n left: anchor(left);\n top: calc(anchor(bottom) + var(--base-size-4));\n margin: 0;\n width: auto;\n}\n"]}
|
|
@@ -1 +1 @@
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,CAAC,CAAA;IAC3C;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAChC;AAED,MAAM,MAAM,oBAAoB,GAAG,wBAAwB,GACzD,CAAC,8BAA8B,GAAG,iCAAiC,CAAC,GACpE,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,MAAM,GAAG,cAAc,GAAG,iBAAiB,GAAG,mBAAmB,CAAC,CAAC,CAAA;AAS9G;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAoRnF,CAAA"}
|
|
@@ -54,7 +54,7 @@ const AnchoredOverlay = ({
|
|
|
54
54
|
// Lazy initial state so feature detection runs once per mount on the client.
|
|
55
55
|
// Guarded for SSR where `document` is undefined.
|
|
56
56
|
const [supportsNativeCSSAnchorPositioning] = useState(() => typeof document !== 'undefined' && 'anchorName' in document.documentElement.style);
|
|
57
|
-
const cssAnchorPositioning = cssAnchorPositioningFlag && supportsNativeCSSAnchorPositioning;
|
|
57
|
+
const cssAnchorPositioning = cssAnchorPositioningFlag && supportsNativeCSSAnchorPositioning && !(overlayProps !== null && overlayProps !== void 0 && overlayProps.portalContainerName);
|
|
58
58
|
// Only use Popover API when both CSS anchor positioning is enabled AND renderAs is true
|
|
59
59
|
const shouldRenderAsPopover = cssAnchorPositioning && renderAs === 'popover';
|
|
60
60
|
const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
|
|
@@ -133,28 +133,51 @@ const AnchoredOverlay = ({
|
|
|
133
133
|
});
|
|
134
134
|
const popoverId = useId();
|
|
135
135
|
const id = popoverId.replaceAll(':', '_'); // popoverId can contain colons which are invalid in CSS custom property names, so we replace them with underscores
|
|
136
|
+
const anchorName = `--anchored-overlay-anchor-${id}`;
|
|
136
137
|
|
|
138
|
+
// Manage `anchor-name` on the anchor independently of `open`/`width` so a
|
|
139
|
+
// parent re-render that re-runs the positioning effect below doesn't
|
|
140
|
+
// briefly flicker the anchor link off and back on.
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (!cssAnchorPositioning || !anchorElement) return;
|
|
143
|
+
if (anchorElement.style.getPropertyValue('anchor-name')) return;
|
|
144
|
+
anchorElement.style.setProperty('anchor-name', anchorName);
|
|
145
|
+
return () => {
|
|
146
|
+
if (anchorElement.style.getPropertyValue('anchor-name') === anchorName) {
|
|
147
|
+
anchorElement.style.removeProperty('anchor-name');
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}, [cssAnchorPositioning, anchorElement, anchorName]);
|
|
137
151
|
useEffect(() => {
|
|
138
152
|
if (!cssAnchorPositioning || !anchorElement) return;
|
|
139
153
|
const currentOverlay = overlayRef.current;
|
|
140
|
-
|
|
141
|
-
// Link the anchor and the overlay (when present) via CSS anchor positioning.
|
|
142
|
-
anchorElement.style.setProperty('anchor-name', `--anchored-overlay-anchor-${id}`);
|
|
154
|
+
const resolvedAnchorName = anchorElement.style.getPropertyValue('anchor-name') || anchorName;
|
|
143
155
|
let pendingPositionFrame = null;
|
|
144
156
|
if (open && currentOverlay) {
|
|
145
|
-
currentOverlay.style.setProperty('position-anchor',
|
|
157
|
+
currentOverlay.style.setProperty('position-anchor', resolvedAnchorName);
|
|
146
158
|
|
|
147
159
|
// Defer the getBoundingClientRect read into a `requestAnimationFrame` so the style write above
|
|
148
160
|
// does not force a synchronous layout.
|
|
149
161
|
pendingPositionFrame = requestAnimationFrame(() => {
|
|
150
162
|
pendingPositionFrame = null;
|
|
151
|
-
const
|
|
152
|
-
const result = getDefaultPosition(anchorElement,
|
|
163
|
+
const fallbackWidth = width ? parseInt(widthMap[width]) : parseInt(widthMap.small);
|
|
164
|
+
const result = getDefaultPosition(anchorElement, currentOverlay, fallbackWidth);
|
|
153
165
|
currentOverlay.setAttribute('data-align', result.horizontal);
|
|
154
|
-
|
|
155
|
-
|
|
166
|
+
if (result.suggestedSide) {
|
|
167
|
+
currentOverlay.setAttribute('data-side', result.suggestedSide);
|
|
168
|
+
}
|
|
156
169
|
const offset = result.horizontal === 'left' ? result.leftOffset : result.rightOffset;
|
|
157
170
|
currentOverlay.style.setProperty(`--anchored-overlay-anchor-offset-${result.horizontal}`, `${offset || 0}px`);
|
|
171
|
+
|
|
172
|
+
// Set y-axis offset to prevent overflow if needed.
|
|
173
|
+
const settledRect = currentOverlay.getBoundingClientRect();
|
|
174
|
+
const overflowBottom = settledRect.bottom - window.innerHeight;
|
|
175
|
+
if (overflowBottom > 0) {
|
|
176
|
+
const clampedTop = Math.max(0, settledRect.top - overflowBottom - 8);
|
|
177
|
+
currentOverlay.style.setProperty('--anchored-overlay-top-override', `${clampedTop}px`);
|
|
178
|
+
} else {
|
|
179
|
+
currentOverlay.style.removeProperty('--anchored-overlay-top-override');
|
|
180
|
+
}
|
|
158
181
|
});
|
|
159
182
|
|
|
160
183
|
// Only call showPopover when shouldRenderAsPopover is enabled
|
|
@@ -170,7 +193,6 @@ const AnchoredOverlay = ({
|
|
|
170
193
|
}
|
|
171
194
|
return () => {
|
|
172
195
|
if (pendingPositionFrame !== null) cancelAnimationFrame(pendingPositionFrame);
|
|
173
|
-
anchorElement.style.removeProperty('anchor-name');
|
|
174
196
|
// The overlay may no longer be in the DOM at this point, so we need to check for its presence before trying to update it.
|
|
175
197
|
if (currentOverlay) {
|
|
176
198
|
currentOverlay.style.removeProperty('position-anchor');
|
|
@@ -257,30 +279,45 @@ const AnchoredOverlay = ({
|
|
|
257
279
|
}) : null]
|
|
258
280
|
});
|
|
259
281
|
};
|
|
260
|
-
function getDefaultPosition(anchorElement,
|
|
261
|
-
const
|
|
282
|
+
function getDefaultPosition(anchorElement, overlayElement, fallbackWidth) {
|
|
283
|
+
const anchorRect = anchorElement.getBoundingClientRect();
|
|
284
|
+
const overlayRect = overlayElement.getBoundingClientRect();
|
|
262
285
|
const vw = window.innerWidth;
|
|
263
|
-
const
|
|
264
|
-
const
|
|
265
|
-
const
|
|
286
|
+
const vh = window.innerHeight;
|
|
287
|
+
const margin = 8;
|
|
288
|
+
const overlayWidth = overlayRect.width || fallbackWidth;
|
|
289
|
+
const spaceLeft = anchorRect.left;
|
|
290
|
+
const spaceRight = vw - anchorRect.right;
|
|
266
291
|
const horizontal = spaceLeft > spaceRight ? 'left' : 'right';
|
|
267
292
|
|
|
268
|
-
//
|
|
269
|
-
//
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
293
|
+
// Suggest a flip when the overlay is currently overflowing both axes:
|
|
294
|
+
// prefer the side of the anchor with enough room, otherwise fall back to
|
|
295
|
+
// outside-bottom and let the offsets keep it inside the viewport.
|
|
296
|
+
const overflowsX = overlayRect.right > vw || overlayRect.left < 0;
|
|
297
|
+
const overflowsY = overlayRect.bottom > vh || overlayRect.top < 0;
|
|
298
|
+
let suggestedSide;
|
|
299
|
+
if (overflowsX && overflowsY) {
|
|
300
|
+
if (spaceLeft >= overlayWidth + margin) {
|
|
301
|
+
suggestedSide = 'outside-left';
|
|
302
|
+
} else if (spaceRight >= overlayWidth + margin) {
|
|
303
|
+
suggestedSide = 'outside-right';
|
|
304
|
+
} else {
|
|
305
|
+
suggestedSide = 'outside-bottom';
|
|
306
|
+
}
|
|
274
307
|
}
|
|
275
308
|
|
|
276
|
-
// If the viewport is too narrow to fit the overlay on either side, calculate offsets to prevent overflow
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
309
|
+
// If the viewport is too narrow to fit the overlay on either side, calculate offsets to prevent overflow.
|
|
310
|
+
let leftOffset;
|
|
311
|
+
let rightOffset;
|
|
312
|
+
if (spaceLeft < overlayWidth + margin && spaceRight < overlayWidth + margin) {
|
|
313
|
+
leftOffset = Math.max(0, overlayWidth - anchorRect.right + margin);
|
|
314
|
+
rightOffset = Math.max(0, anchorRect.left + overlayWidth - vw + margin);
|
|
315
|
+
}
|
|
280
316
|
return {
|
|
281
317
|
horizontal,
|
|
282
318
|
leftOffset,
|
|
283
|
-
rightOffset
|
|
319
|
+
rightOffset,
|
|
320
|
+
suggestedSide
|
|
284
321
|
};
|
|
285
322
|
}
|
|
286
323
|
function assignRef(ref, value) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './AnchoredOverlay-
|
|
1
|
+
import './AnchoredOverlay-ec9e15fc.css';
|
|
2
2
|
|
|
3
3
|
var classes = {"ResponsiveCloseButtonContainer":"prc-AnchoredOverlay-ResponsiveCloseButtonContainer-nuium","ResponsiveCloseButton":"prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx","AnchoredOverlay":"prc-AnchoredOverlay-AnchoredOverlay-fYg9Z"};
|
|
4
4
|
|
|
@@ -28,7 +28,7 @@ declare const _default: React.FC<React.PropsWithChildren<{
|
|
|
28
28
|
} | null>;
|
|
29
29
|
Input: import("../utils/polymorphic").ForwardRefComponent<import("../utils/polymorphic").ForwardRefComponent<"input", import("..").TextInputProps> & {
|
|
30
30
|
__SLOT__: symbol;
|
|
31
|
-
Action: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "
|
|
31
|
+
Action: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "aria-label" | "size" | "tooltipDirection"> & {
|
|
32
32
|
children?: React.ReactNode;
|
|
33
33
|
"aria-label"?: string;
|
|
34
34
|
tooltipDirection?: "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
|
|
@@ -7,7 +7,7 @@ export declare function transition(direction: Exclude<SortDirection, 'NONE'>): E
|
|
|
7
7
|
/**
|
|
8
8
|
* A sort strategy for comparing any two values
|
|
9
9
|
*/
|
|
10
|
-
export declare function basic<T>(a: T, b: T): 1 | 0 |
|
|
10
|
+
export declare function basic<T>(a: T, b: T): -1 | 0 | 1;
|
|
11
11
|
/**
|
|
12
12
|
* A sort strategy for comparing two `Date` values. Also includes support for
|
|
13
13
|
* values from `Date.now()`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultFeatureFlags.d.ts","sourceRoot":"","sources":["../../src/FeatureFlags/DefaultFeatureFlags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAEnD,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"DefaultFeatureFlags.d.ts","sourceRoot":"","sources":["../../src/FeatureFlags/DefaultFeatureFlags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAEnD,eAAO,MAAM,mBAAmB,kBAK9B,CAAA"}
|
|
@@ -3,7 +3,8 @@ import { FeatureFlagScope } from './FeatureFlagScope.js';
|
|
|
3
3
|
const DefaultFeatureFlags = FeatureFlagScope.create({
|
|
4
4
|
primer_react_css_anchor_positioning: false,
|
|
5
5
|
primer_react_select_panel_fullscreen_on_narrow: false,
|
|
6
|
-
primer_react_select_panel_order_selected_at_top: false
|
|
6
|
+
primer_react_select_panel_order_selected_at_top: false,
|
|
7
|
+
primer_react_styled_react_use_primer_theme_providers: false
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
export { DefaultFeatureFlags };
|
|
@@ -37,7 +37,7 @@ export type TextInputNonPassthroughProps = {
|
|
|
37
37
|
export type TextInputProps = Merge<React.ComponentPropsWithoutRef<'input'>, TextInputNonPassthroughProps>;
|
|
38
38
|
declare const _default: PolymorphicForwardRefComponent<"input", TextInputProps> & {
|
|
39
39
|
__SLOT__: symbol;
|
|
40
|
-
Action: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "
|
|
40
|
+
Action: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "aria-label" | "size" | "tooltipDirection"> & {
|
|
41
41
|
children?: React.ReactNode;
|
|
42
42
|
"aria-label"?: string;
|
|
43
43
|
tooltipDirection?: "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
|
|
@@ -48,11 +48,11 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<{
|
|
|
48
48
|
* The array of tokens to render
|
|
49
49
|
*/
|
|
50
50
|
tokens: any[] | (Omit<(Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> & {
|
|
51
|
-
ref?: ((instance: HTMLAnchorElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) |
|
|
51
|
+
ref?: RefObject<HTMLAnchorElement> | ((instance: HTMLAnchorElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
|
|
52
52
|
}) | (Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
53
|
-
ref?: ((instance: HTMLButtonElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) |
|
|
53
|
+
ref?: RefObject<HTMLButtonElement> | ((instance: HTMLButtonElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
|
|
54
54
|
}) | (Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
55
|
-
ref?: ((instance: HTMLSpanElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) |
|
|
55
|
+
ref?: RefObject<HTMLSpanElement> | ((instance: HTMLSpanElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
|
|
56
56
|
}), keyof import("..").TokenProps> & import("..").TokenProps & {
|
|
57
57
|
as?: "a" | "button" | "span" | undefined;
|
|
58
58
|
})[];
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
export declare function useRovingTabIndex({ containerRef, mouseDownRef, }: {
|
|
3
|
-
containerRef: React.RefObject<HTMLElement>;
|
|
4
|
-
mouseDownRef
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
export declare function useRovingTabIndex({ containerRef, mouseDownRef, focusOutBehavior, preventScroll, wrapAround, }: {
|
|
3
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
4
|
+
mouseDownRef?: React.RefObject<boolean>;
|
|
5
|
+
preventScroll?: boolean;
|
|
6
|
+
focusOutBehavior?: 'stop' | 'wrap';
|
|
7
|
+
wrapAround?: boolean;
|
|
8
|
+
}, dependencies?: React.DependencyList): void;
|
|
9
|
+
export declare function getNextFocusableElement(activeElement: HTMLElement, event: KeyboardEvent, wrapAround?: boolean): HTMLElement | undefined;
|
|
7
10
|
export declare function getElementState(element: HTMLElement): 'open' | 'closed' | 'end';
|
|
8
|
-
export declare function getVisibleElement(element: HTMLElement, direction: 'next' | 'previous'): HTMLElement | undefined;
|
|
11
|
+
export declare function getVisibleElement(element: HTMLElement, direction: 'next' | 'previous', wrapAround?: boolean): HTMLElement | undefined;
|
|
9
12
|
export declare function getFirstChildElement(element: HTMLElement): HTMLElement | undefined;
|
|
10
13
|
export declare function getParentElement(element: HTMLElement): HTMLElement | undefined;
|
|
11
14
|
export declare function getFirstElement(element: HTMLElement): HTMLElement | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRovingTabIndex.d.ts","sourceRoot":"","sources":["../../src/TreeView/useRovingTabIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,wBAAgB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"useRovingTabIndex.d.ts","sourceRoot":"","sources":["../../src/TreeView/useRovingTabIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,wBAAgB,iBAAiB,CAC/B,EACE,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,aAAoB,EACpB,UAAkB,GACnB,EAAE;IACD,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACjD,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IACvC,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAClC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,EACD,YAAY,GAAE,KAAK,CAAC,cAAmB,QA6DxC;AAID,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,WAAW,EAC1B,KAAK,EAAE,aAAa,EACpB,UAAU,GAAE,OAAe,GAC1B,WAAW,GAAG,SAAS,CAgEzB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAa/E;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,MAAM,GAAG,UAAU,EAC9B,UAAU,UAAQ,GACjB,WAAW,GAAG,SAAS,CA6BzB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAGlF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAI9E;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAI7E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAuB5E"}
|
|
@@ -3,17 +3,60 @@ import { useFocusZone } from '../hooks/useFocusZone.js';
|
|
|
3
3
|
import { getScrollContainer } from '../utils/scroll.js';
|
|
4
4
|
import { FocusKeys } from '@primer/behaviors';
|
|
5
5
|
|
|
6
|
-
function useRovingTabIndex(t0) {
|
|
7
|
-
const $ = c(
|
|
6
|
+
function useRovingTabIndex(t0, t1) {
|
|
7
|
+
const $ = c(15);
|
|
8
8
|
const {
|
|
9
9
|
containerRef,
|
|
10
|
-
mouseDownRef
|
|
10
|
+
mouseDownRef,
|
|
11
|
+
focusOutBehavior,
|
|
12
|
+
preventScroll: t2,
|
|
13
|
+
wrapAround: t3
|
|
11
14
|
} = t0;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const preventScroll = t2 === undefined ? true : t2;
|
|
16
|
+
const wrapAround = t3 === undefined ? false : t3;
|
|
17
|
+
let t4;
|
|
18
|
+
if ($[0] !== t1) {
|
|
19
|
+
t4 = t1 === undefined ? [] : t1;
|
|
20
|
+
$[0] = t1;
|
|
21
|
+
$[1] = t4;
|
|
22
|
+
} else {
|
|
23
|
+
t4 = $[1];
|
|
24
|
+
}
|
|
25
|
+
const dependencies = t4;
|
|
26
|
+
let t5;
|
|
27
|
+
if ($[2] !== wrapAround) {
|
|
28
|
+
t5 = (direction, from, event) => {
|
|
29
|
+
var _getNextFocusableElem;
|
|
30
|
+
if (!(from instanceof HTMLElement)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
if (from.closest("dialog:modal")) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
} catch {}
|
|
38
|
+
return (_getNextFocusableElem = getNextFocusableElement(from, event, wrapAround)) !== null && _getNextFocusableElem !== void 0 ? _getNextFocusableElem : from;
|
|
39
|
+
};
|
|
40
|
+
$[2] = wrapAround;
|
|
41
|
+
$[3] = t5;
|
|
42
|
+
} else {
|
|
43
|
+
t5 = $[3];
|
|
44
|
+
}
|
|
45
|
+
let t6;
|
|
46
|
+
if ($[4] !== focusOutBehavior) {
|
|
47
|
+
t6 = focusOutBehavior ? {
|
|
48
|
+
focusOutBehavior
|
|
49
|
+
} : {};
|
|
50
|
+
$[4] = focusOutBehavior;
|
|
51
|
+
$[5] = t6;
|
|
52
|
+
} else {
|
|
53
|
+
t6 = $[5];
|
|
54
|
+
}
|
|
55
|
+
let t7;
|
|
56
|
+
if ($[6] !== containerRef || $[7] !== mouseDownRef) {
|
|
57
|
+
t7 = () => {
|
|
15
58
|
var _containerRef$current, _containerRef$current2, _containerRef$current3;
|
|
16
|
-
if (mouseDownRef.current) {
|
|
59
|
+
if (mouseDownRef !== null && mouseDownRef !== void 0 && mouseDownRef.current) {
|
|
17
60
|
return;
|
|
18
61
|
}
|
|
19
62
|
const currentItem = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector("[aria-current]");
|
|
@@ -26,51 +69,47 @@ function useRovingTabIndex(t0) {
|
|
|
26
69
|
}
|
|
27
70
|
return firstItem instanceof HTMLElement ? firstItem : undefined;
|
|
28
71
|
};
|
|
29
|
-
$[
|
|
30
|
-
$[
|
|
31
|
-
$[
|
|
72
|
+
$[6] = containerRef;
|
|
73
|
+
$[7] = mouseDownRef;
|
|
74
|
+
$[8] = t7;
|
|
32
75
|
} else {
|
|
33
|
-
|
|
76
|
+
t7 = $[8];
|
|
34
77
|
}
|
|
35
|
-
let
|
|
36
|
-
if ($[
|
|
37
|
-
|
|
78
|
+
let t8;
|
|
79
|
+
if ($[9] !== containerRef || $[10] !== preventScroll || $[11] !== t5 || $[12] !== t6 || $[13] !== t7) {
|
|
80
|
+
t8 = {
|
|
38
81
|
containerRef,
|
|
39
82
|
bindKeys: FocusKeys.ArrowVertical | FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd | FocusKeys.Backspace | FocusKeys.PageUpDown,
|
|
40
|
-
preventScroll
|
|
41
|
-
getNextFocusable:
|
|
42
|
-
|
|
83
|
+
preventScroll,
|
|
84
|
+
getNextFocusable: t5,
|
|
85
|
+
...t6,
|
|
86
|
+
focusInStrategy: t7
|
|
43
87
|
};
|
|
44
|
-
$[
|
|
45
|
-
$[
|
|
46
|
-
$[
|
|
88
|
+
$[9] = containerRef;
|
|
89
|
+
$[10] = preventScroll;
|
|
90
|
+
$[11] = t5;
|
|
91
|
+
$[12] = t6;
|
|
92
|
+
$[13] = t7;
|
|
93
|
+
$[14] = t8;
|
|
47
94
|
} else {
|
|
48
|
-
|
|
95
|
+
t8 = $[14];
|
|
49
96
|
}
|
|
50
|
-
useFocusZone(
|
|
97
|
+
useFocusZone(t8, dependencies);
|
|
51
98
|
}
|
|
52
99
|
|
|
53
100
|
// DOM utilities used for focus management
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (from.closest("dialog:modal")) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
} catch {}
|
|
64
|
-
return (_getNextFocusableElem = getNextFocusableElement(from, event)) !== null && _getNextFocusableElem !== void 0 ? _getNextFocusableElem : from;
|
|
65
|
-
}
|
|
66
|
-
function getNextFocusableElement(activeElement, event) {
|
|
67
|
-
const elementState = getElementState(activeElement);
|
|
101
|
+
|
|
102
|
+
function getNextFocusableElement(activeElement, event, wrapAround = false) {
|
|
103
|
+
// If focus is on a non-treeitem child (e.g. GroupHeadingWrap), resolve to the closest treeitem ancestor.
|
|
104
|
+
const treeitem = activeElement.getAttribute('role') === 'treeitem' ? activeElement : activeElement.closest('[role="treeitem"]');
|
|
105
|
+
if (!treeitem) return;
|
|
106
|
+
const elementState = getElementState(treeitem);
|
|
68
107
|
|
|
69
108
|
// Reference: https://www.w3.org/WAI/ARIA/apg/patterns/treeview/#keyboard-interaction-24
|
|
70
109
|
switch (`${elementState} ${event.key}`) {
|
|
71
110
|
case 'open ArrowRight':
|
|
72
111
|
// Focus first child node
|
|
73
|
-
return getFirstChildElement(
|
|
112
|
+
return getFirstChildElement(treeitem);
|
|
74
113
|
case 'open ArrowLeft':
|
|
75
114
|
// Close node; don't change focus
|
|
76
115
|
return;
|
|
@@ -79,35 +118,35 @@ function getNextFocusableElement(activeElement, event) {
|
|
|
79
118
|
return;
|
|
80
119
|
case 'closed ArrowLeft':
|
|
81
120
|
// Focus parent element
|
|
82
|
-
return getParentElement(
|
|
121
|
+
return getParentElement(treeitem);
|
|
83
122
|
case 'end ArrowRight':
|
|
84
123
|
// Do nothing
|
|
85
124
|
return;
|
|
86
125
|
case 'end ArrowLeft':
|
|
87
126
|
// Focus parent element
|
|
88
|
-
return getParentElement(
|
|
127
|
+
return getParentElement(treeitem);
|
|
89
128
|
}
|
|
90
129
|
|
|
91
130
|
// ArrowUp, ArrowDown, Home, and End behavior are the same regardless of element state
|
|
92
131
|
switch (event.key) {
|
|
93
132
|
case 'ArrowUp':
|
|
94
133
|
// Focus previous visible element
|
|
95
|
-
return getVisibleElement(
|
|
134
|
+
return getVisibleElement(treeitem, 'previous', wrapAround);
|
|
96
135
|
case 'ArrowDown':
|
|
97
136
|
// Focus next visible element
|
|
98
|
-
return getVisibleElement(
|
|
137
|
+
return getVisibleElement(treeitem, 'next', wrapAround);
|
|
99
138
|
case 'Backspace':
|
|
100
|
-
return getParentElement(
|
|
139
|
+
return getParentElement(treeitem);
|
|
101
140
|
case 'Home':
|
|
102
141
|
// Focus first visible element
|
|
103
|
-
return getFirstElement(
|
|
142
|
+
return getFirstElement(treeitem);
|
|
104
143
|
case 'End':
|
|
105
144
|
// Focus last visible element
|
|
106
|
-
return getLastElement(
|
|
145
|
+
return getLastElement(treeitem);
|
|
107
146
|
case 'PageUp':
|
|
108
|
-
return getPreviousPageElement(
|
|
147
|
+
return getPreviousPageElement(treeitem);
|
|
109
148
|
case 'PageDown':
|
|
110
|
-
return getNextPageElement(
|
|
149
|
+
return getNextPageElement(treeitem);
|
|
111
150
|
}
|
|
112
151
|
}
|
|
113
152
|
function getElementState(element) {
|
|
@@ -123,7 +162,7 @@ function getElementState(element) {
|
|
|
123
162
|
return 'end';
|
|
124
163
|
}
|
|
125
164
|
}
|
|
126
|
-
function getVisibleElement(element, direction) {
|
|
165
|
+
function getVisibleElement(element, direction, wrapAround = false) {
|
|
127
166
|
const root = element.closest('[role=tree]');
|
|
128
167
|
if (!root) return;
|
|
129
168
|
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, node => {
|
|
@@ -141,6 +180,11 @@ function getVisibleElement(element, direction) {
|
|
|
141
180
|
var _next$parentElement;
|
|
142
181
|
next = direction === 'next' ? walker.nextNode() : walker.previousNode();
|
|
143
182
|
}
|
|
183
|
+
|
|
184
|
+
// Wrap around if we reached the end/beginning of the tree
|
|
185
|
+
if (!next && wrapAround) {
|
|
186
|
+
return direction === 'next' ? getFirstElement(element) : getLastElement(element);
|
|
187
|
+
}
|
|
144
188
|
return next instanceof HTMLElement ? next : undefined;
|
|
145
189
|
}
|
|
146
190
|
function getFirstChildElement(element) {
|
|
@@ -10,10 +10,10 @@ declare const data: {
|
|
|
10
10
|
login: string;
|
|
11
11
|
recommended: boolean;
|
|
12
12
|
} | {
|
|
13
|
+
recommended?: undefined;
|
|
13
14
|
id: string;
|
|
14
15
|
name: string;
|
|
15
16
|
login: string;
|
|
16
|
-
recommended?: undefined;
|
|
17
17
|
})[];
|
|
18
18
|
labels: ({
|
|
19
19
|
color: string;
|
|
@@ -38,18 +38,18 @@ declare const data: {
|
|
|
38
38
|
name: string;
|
|
39
39
|
trailingInfo: string;
|
|
40
40
|
} | {
|
|
41
|
+
trailingInfo?: undefined;
|
|
41
42
|
id: string;
|
|
42
43
|
name: string;
|
|
43
|
-
trailingInfo?: undefined;
|
|
44
44
|
})[];
|
|
45
45
|
tags: ({
|
|
46
46
|
id: string;
|
|
47
47
|
name: string;
|
|
48
48
|
trailingInfo: string;
|
|
49
49
|
} | {
|
|
50
|
+
trailingInfo?: undefined;
|
|
50
51
|
id: string;
|
|
51
52
|
name: string;
|
|
52
|
-
trailingInfo?: undefined;
|
|
53
53
|
})[];
|
|
54
54
|
repos: {
|
|
55
55
|
org: string;
|