@primer/react 0.0.0-20260507233415 → 0.0.0-20260508164446

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +5 -13
  2. package/dist/ActionBar/ActionBar-e2c44be2.css +2 -0
  3. package/dist/ActionBar/ActionBar-e2c44be2.css.map +1 -0
  4. package/dist/ActionBar/ActionBar.d.ts +1 -1
  5. package/dist/ActionBar/ActionBar.d.ts.map +1 -1
  6. package/dist/ActionBar/ActionBar.js +293 -381
  7. package/dist/ActionBar/ActionBar.module.css.js +2 -2
  8. package/dist/ActionBar/index.d.ts +1 -1
  9. package/dist/ActionList/Item.js +2 -2
  10. package/dist/ActionList/LinkItem.d.ts +1 -1
  11. package/dist/ActionList/index.d.ts +2 -13
  12. package/dist/ActionList/index.d.ts.map +1 -1
  13. package/dist/ActionList/index.js +0 -3
  14. package/dist/AnchoredOverlay/{AnchoredOverlay-ec9e15fc.css → AnchoredOverlay-0c26c5f8.css} +2 -2
  15. package/dist/AnchoredOverlay/AnchoredOverlay-0c26c5f8.css.map +1 -0
  16. package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
  17. package/dist/AnchoredOverlay/AnchoredOverlay.js +26 -63
  18. package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +1 -1
  19. package/dist/Autocomplete/Autocomplete.d.ts +1 -1
  20. package/dist/DataTable/sorting.d.ts +1 -1
  21. package/dist/FeatureFlags/DefaultFeatureFlags.d.ts.map +1 -1
  22. package/dist/FeatureFlags/DefaultFeatureFlags.js +1 -2
  23. package/dist/TextInput/TextInput.d.ts +1 -1
  24. package/dist/TextInputWithTokens/TextInputWithTokens.d.ts +3 -3
  25. package/dist/TreeView/useRovingTabIndex.d.ts +6 -9
  26. package/dist/TreeView/useRovingTabIndex.d.ts.map +1 -1
  27. package/dist/TreeView/useRovingTabIndex.js +47 -91
  28. package/dist/experimental/SelectPanel2/mock-story-data.d.ts +3 -3
  29. package/dist/hooks/useSyncedState.d.ts +1 -1
  30. package/dist/index.d.ts +0 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +0 -1
  33. package/dist/internal/components/TextInputInnerAction.d.ts +1 -1
  34. package/dist/theme.d.ts +1 -1
  35. package/dist/utils/useIsomorphicLayoutEffect.d.ts +2 -2
  36. package/dist/utils/useIsomorphicLayoutEffect.d.ts.map +1 -1
  37. package/package.json +2 -2
  38. package/dist/ActionBar/ActionBar-a41224b2.css +0 -2
  39. package/dist/ActionBar/ActionBar-a41224b2.css.map +0 -1
  40. package/dist/AnchoredOverlay/AnchoredOverlay-ec9e15fc.css.map +0 -1
@@ -1,5 +1,5 @@
1
- import './ActionBar-a41224b2.css';
1
+ import './ActionBar-e2c44be2.css';
2
2
 
3
- var styles = {"List":"prc-ActionBar-List-9uz46","Divider":"prc-ActionBar-Divider-6V8yH","Nav":"prc-ActionBar-Nav-9spON","Group":"prc-ActionBar-Group-peNCk"};
3
+ var styles = {"List":"prc-ActionBar-List-9uz46","detect-overflow":"prc-ActionBar-detect-overflow-mAuJu","Divider":"prc-ActionBar-Divider-6V8yH","Nav":"prc-ActionBar-Nav-9spON","Group":"prc-ActionBar-Group-peNCk","OverflowContainer":"prc-ActionBar-OverflowContainer-AkYZs","MoreButton":"prc-ActionBar-MoreButton-RHqpx"};
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 | null;
4
+ Divider: () => import("react").JSX.Element;
5
5
  Group: import("react").ForwardRefExoticComponent<{
6
6
  children?: import("react").ReactNode | undefined;
7
7
  } & import("react").RefAttributes<unknown>>;
@@ -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', 'treeitem'];
158
- const listRoleTypes = ['listbox', 'menu', 'list', 'tree'];
157
+ const selectableRoles = ['menuitemradio', 'menuitemcheckbox', 'option'];
158
+ const listRoleTypes = ['listbox', 'menu', 'list'];
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, "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) & {
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
18
  as?: As | undefined;
19
19
  } & React.RefAttributes<unknown>) => React.ReactNode;
20
20
  export declare const LinkItem: WithSlotMarker<typeof LinkItemComponent>;
@@ -31,17 +31,6 @@ 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
- }>;
45
34
  /** Collects related `Items` in an `ActionList`. */
46
35
  Group: import("../utils/types").FCWithSlotMarker<import("react").PropsWithChildren<import("./Group").ActionListGroupProps>>;
47
36
  /** An actionable or selectable `Item` */
@@ -95,7 +84,7 @@ export declare const ActionList: (<As extends React.ElementType = "ul">(props: (
95
84
  __SLOT__: symbol;
96
85
  };
97
86
  /** A `Item` that renders a full-size anchor inside ListItem */
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"> & {
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"> & {
99
88
  download?: string;
100
89
  href?: string;
101
90
  hrefLang?: string;
@@ -106,7 +95,7 @@ export declare const ActionList: (<As extends React.ElementType = "ul">(props: (
106
95
  type?: string;
107
96
  referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>["referrerPolicy"];
108
97
  className?: string;
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"> & {
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"> & {
110
99
  download?: string;
111
100
  href?: string;
112
101
  hrefLang?: string;
@@ -1 +1 @@
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"}
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,gGAAgG;;;;IAGhG,qCAAqC;;IAGrC,uBAAuB;;CAEvB,CAAA"}
@@ -7,14 +7,11 @@ 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';
11
10
 
12
11
  /**
13
12
  * Collection of list-related components.
14
13
  */
15
14
  const ActionList = Object.assign(List, {
16
- /** Context for the `ActionList` container. */
17
- ContainerContext: ActionListContainerContext,
18
15
  /** Collects related `Items` in an `ActionList`. */
19
16
  Group,
20
17
  /** 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: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 */
1
+ .prc-AnchoredOverlay-ResponsiveCloseButtonContainer-nuium{position:relative}.prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx{display:none;position:absolute;right:var(--base-size-8,.5rem);top:var(--base-size-8,.5rem)}@media screen and (max-width:calc(48rem - 0.02px)){.prc-AnchoredOverlay-ResponsiveCloseButton-z-2rx{display:inline-grid}}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z{position-try-fallbacks:flip-block,flip-inline,flip-block flip-inline;position-visibility:anchors-visible;position:fixed!important;z-index:100}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[popover]{border:0;inset:auto;margin:0;max-width:none;padding:0}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-bottom]{left:anchor(left);top:calc(anchor(bottom) + var(--base-size-4,.25rem))}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-bottom][data-align=left]{left:auto;right:calc(anchor(right) - var(--anchored-overlay-anchor-offset-left))}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-top]{bottom:anchor(top);left:anchor(left);margin-bottom:var(--base-size-4,.25rem)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-top][data-align=left]{left:auto;right:anchor(right)}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-left]{margin-right:var(--base-size-4,.25rem);right:anchor(left);top:anchor(top);position-try-fallbacks:flip-inline,flip-block,flip-start,--outside-left-to-bottom}.prc-AnchoredOverlay-AnchoredOverlay-fYg9Z[data-side=outside-right]{left:anchor(right);margin-left:var(--base-size-4,.25rem);top:anchor(top);position-try-fallbacks:flip-inline,flip-block,flip-start,--outside-right-to-bottom}@position-try --outside-left-to-bottom{margin:0;right:anchor(right);top:calc(anchor(bottom) + var(--base-size-4,.25rem));width:auto}@position-try --outside-right-to-bottom{left:anchor(left);margin:0;top:calc(anchor(bottom) + var(--base-size-4,.25rem));width:auto}
2
+ /*# sourceMappingURL=AnchoredOverlay-0c26c5f8.css.map */
@@ -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,WA8CF,CA3CE,oDAIE,QAAS,CAHT,UAAW,CACX,QAAS,CAGT,cAAe,CAFf,SAGF,CAEA,qEAGE,iBAAkB,CADlB,oDAOF,CAJE,sFACE,SAAU,CACV,sEACF,CAGF,kEAEE,kBAAmB,CACnB,iBAAkB,CAFlB,uCAQF,CAJE,mFACE,SAAU,CACV,mBACF,CAGF,mEAGE,sCAAgC,CAFhC,kBAAmB,CACnB,eAAgB,CAEhB,iFACF,CAEA,oEACE,kBAAmB,CAEnB,qCAA+B,CAD/B,eAAgB,CAEhB,kFACF,CAGF,uCAGE,QAAS,CAFT,mBAAoB,CACpB,oDAA8C,CAE9C,UACF,CAEA,wCACE,iBAAkB,CAElB,QAAS,CADT,oDAA8C,CAE9C,UACF","file":"AnchoredOverlay-0c26c5f8.css","sourcesContent":[".ResponsiveCloseButtonContainer {\n position: relative;\n}\n\n.ResponsiveCloseButton {\n position: absolute;\n top: var(--base-size-8);\n right: var(--base-size-8);\n display: none;\n\n @media screen and (--viewportRange-narrow) {\n display: inline-grid;\n }\n}\n\n.AnchoredOverlay {\n position-try-fallbacks:\n flip-block,\n flip-inline,\n flip-block flip-inline;\n position-visibility: anchors-visible;\n z-index: 100;\n position: fixed !important;\n\n &[popover] {\n inset: auto;\n margin: 0;\n padding: 0;\n border: 0;\n max-width: none;\n }\n\n &[data-side='outside-bottom'] {\n /* stylelint-disable primer/spacing */\n top: calc(anchor(bottom) + var(--base-size-4));\n left: anchor(left);\n\n &[data-align='left'] {\n left: auto;\n right: calc(anchor(right) - var(--anchored-overlay-anchor-offset-left));\n }\n }\n\n &[data-side='outside-top'] {\n margin-bottom: var(--base-size-4);\n bottom: anchor(top);\n left: anchor(left);\n\n &[data-align='left'] {\n left: auto;\n right: anchor(right);\n }\n }\n\n &[data-side='outside-left'] {\n right: anchor(left);\n top: anchor(top);\n margin-right: var(--base-size-4);\n position-try-fallbacks: flip-inline, flip-block, flip-start, --outside-left-to-bottom;\n }\n\n &[data-side='outside-right'] {\n left: anchor(right);\n top: anchor(top);\n margin-left: var(--base-size-4);\n position-try-fallbacks: flip-inline, flip-block, flip-start, --outside-right-to-bottom;\n }\n}\n\n@position-try --outside-left-to-bottom {\n right: anchor(right);\n top: calc(anchor(bottom) + var(--base-size-4));\n margin: 0;\n width: auto;\n}\n\n@position-try --outside-right-to-bottom {\n left: anchor(left);\n top: calc(anchor(bottom) + var(--base-size-4));\n margin: 0;\n width: auto;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AnchoredOverlay.d.ts","sourceRoot":"","sources":["../../src/AnchoredOverlay/AnchoredOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAmC,KAAK,GAAG,EAAC,MAAM,OAAO,CAAA;AAChE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAA;AAEhE,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAA;AAIhE,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAC,KAAK,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAa,KAAK,eAAe,EAAC,MAAM,WAAW,CAAA;AAO1D,UAAU,8BAA8B;IACtC;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,YAAY,GAAG,iBAAiB,CAAC,EAChG,KAAK,EAAE,CAAC,KACL,GAAG,CAAC,OAAO,CAAA;I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A;IAElD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,YAAY,CAAC,CAAA;IAChE;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,EAAC,QAAQ,EAAC,EAAE;QAAC,QAAQ,EAAE,cAAc,CAAA;KAAC,KAAK,IAAI,CAAA;IACnE;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IAC3C;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAChC;AAED,MAAM,MAAM,oBAAoB,GAAG,wBAAwB,GACzD,CAAC,8BAA8B,GAAG,iCAAiC,CAAC,GACpE,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,MAAM,GAAG,cAAc,GAAG,iBAAiB,GAAG,mBAAmB,CAAC,CAAC,CAAA;AAS9G;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CA2PnF,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 && !(overlayProps !== null && overlayProps !== void 0 && overlayProps.portalContainerName);
57
+ const cssAnchorPositioning = cssAnchorPositioningFlag && supportsNativeCSSAnchorPositioning;
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,51 +133,28 @@ 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}`;
137
136
 
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]);
151
137
  useEffect(() => {
152
138
  if (!cssAnchorPositioning || !anchorElement) return;
153
139
  const currentOverlay = overlayRef.current;
154
- const resolvedAnchorName = anchorElement.style.getPropertyValue('anchor-name') || anchorName;
140
+
141
+ // Link the anchor and the overlay (when present) via CSS anchor positioning.
142
+ anchorElement.style.setProperty('anchor-name', `--anchored-overlay-anchor-${id}`);
155
143
  let pendingPositionFrame = null;
156
144
  if (open && currentOverlay) {
157
- currentOverlay.style.setProperty('position-anchor', resolvedAnchorName);
145
+ currentOverlay.style.setProperty('position-anchor', `--anchored-overlay-anchor-${id}`);
158
146
 
159
147
  // Defer the getBoundingClientRect read into a `requestAnimationFrame` so the style write above
160
148
  // does not force a synchronous layout.
161
149
  pendingPositionFrame = requestAnimationFrame(() => {
162
150
  pendingPositionFrame = null;
163
- const fallbackWidth = width ? parseInt(widthMap[width]) : parseInt(widthMap.small);
164
- const result = getDefaultPosition(anchorElement, currentOverlay, fallbackWidth);
151
+ const overlayWidth = width ? parseInt(widthMap[width]) : null;
152
+ const result = getDefaultPosition(anchorElement, overlayWidth);
165
153
  currentOverlay.setAttribute('data-align', result.horizontal);
166
- if (result.suggestedSide) {
167
- currentOverlay.setAttribute('data-side', result.suggestedSide);
168
- }
154
+
155
+ // Apply offset only when viewport is too narrow
169
156
  const offset = result.horizontal === 'left' ? result.leftOffset : result.rightOffset;
170
157
  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
- }
181
158
  });
182
159
 
183
160
  // Only call showPopover when shouldRenderAsPopover is enabled
@@ -193,6 +170,7 @@ const AnchoredOverlay = ({
193
170
  }
194
171
  return () => {
195
172
  if (pendingPositionFrame !== null) cancelAnimationFrame(pendingPositionFrame);
173
+ anchorElement.style.removeProperty('anchor-name');
196
174
  // 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.
197
175
  if (currentOverlay) {
198
176
  currentOverlay.style.removeProperty('position-anchor');
@@ -279,45 +257,30 @@ const AnchoredOverlay = ({
279
257
  }) : null]
280
258
  });
281
259
  };
282
- function getDefaultPosition(anchorElement, overlayElement, fallbackWidth) {
283
- const anchorRect = anchorElement.getBoundingClientRect();
284
- const overlayRect = overlayElement.getBoundingClientRect();
260
+ function getDefaultPosition(anchorElement, overlayWidth) {
261
+ const rect = anchorElement.getBoundingClientRect();
285
262
  const vw = window.innerWidth;
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;
263
+ const viewportMargin = 8;
264
+ const spaceLeft = rect.left;
265
+ const spaceRight = vw - rect.right;
291
266
  const horizontal = spaceLeft > spaceRight ? 'left' : 'right';
292
267
 
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
- }
268
+ // If there's no explicit overlay width, or either side has enough space
269
+ // to contain the overlay, let CSS position-try-fallbacks handle positioning
270
+ if (!overlayWidth || spaceLeft >= overlayWidth + viewportMargin || spaceRight >= overlayWidth + viewportMargin) {
271
+ return {
272
+ horizontal
273
+ };
307
274
  }
308
275
 
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
- }
276
+ // If the viewport is too narrow to fit the overlay on either side, calculate offsets to prevent overflow
277
+ // leftOffset is how much to shift the overlay to the right, rightOffset is how much to shift the overlay to the left
278
+ const leftOffset = Math.max(0, overlayWidth - rect.right + viewportMargin);
279
+ const rightOffset = Math.max(0, rect.left + overlayWidth - vw + viewportMargin);
316
280
  return {
317
281
  horizontal,
318
282
  leftOffset,
319
- rightOffset,
320
- suggestedSide
283
+ rightOffset
321
284
  };
322
285
  }
323
286
  function assignRef(ref, value) {
@@ -1,4 +1,4 @@
1
- import './AnchoredOverlay-ec9e15fc.css';
1
+ import './AnchoredOverlay-0c26c5f8.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>, "aria-label" | "size" | "tooltipDirection"> & {
31
+ Action: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "size" | "aria-label" | "tooltipDirection"> & {
32
32
  children?: React.ReactNode;
33
33
  "aria-label"?: string;
34
34
  tooltipDirection?: "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
@@ -7,7 +7,7 @@ export declare function transition(direction: Exclude<SortDirection, 'NONE'>): E
7
7
  /**
8
8
  * A sort strategy for comparing any two values
9
9
  */
10
- export declare function basic<T>(a: T, b: T): -1 | 0 | 1;
10
+ export declare function basic<T>(a: T, b: T): 1 | 0 | -1;
11
11
  /**
12
12
  * A sort strategy for comparing two `Date` values. Also includes support for
13
13
  * values from `Date.now()`
@@ -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,kBAK9B,CAAA"}
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,kBAI9B,CAAA"}
@@ -3,8 +3,7 @@ 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,
7
- primer_react_styled_react_use_primer_theme_providers: false
6
+ primer_react_select_panel_order_selected_at_top: false
8
7
  });
9
8
 
10
9
  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>, "aria-label" | "size" | "tooltipDirection"> & {
40
+ Action: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "size" | "aria-label" | "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?: 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;
51
+ ref?: ((instance: HTMLAnchorElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLAnchorElement> | null | undefined;
52
52
  }) | (Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
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;
53
+ ref?: ((instance: HTMLButtonElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLButtonElement> | null | undefined;
54
54
  }) | (Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
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;
55
+ ref?: ((instance: HTMLSpanElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLSpanElement> | null | undefined;
56
56
  }), keyof import("..").TokenProps> & import("..").TokenProps & {
57
57
  as?: "a" | "button" | "span" | undefined;
58
58
  })[];
@@ -1,14 +1,11 @@
1
1
  import type React from 'react';
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;
2
+ export declare function useRovingTabIndex({ containerRef, mouseDownRef, }: {
3
+ containerRef: React.RefObject<HTMLElement>;
4
+ mouseDownRef: React.RefObject<boolean>;
5
+ }): void;
6
+ export declare function getNextFocusableElement(activeElement: HTMLElement, event: KeyboardEvent): HTMLElement | undefined;
10
7
  export declare function getElementState(element: HTMLElement): 'open' | 'closed' | 'end';
11
- export declare function getVisibleElement(element: HTMLElement, direction: 'next' | 'previous', wrapAround?: boolean): HTMLElement | undefined;
8
+ export declare function getVisibleElement(element: HTMLElement, direction: 'next' | 'previous'): HTMLElement | undefined;
12
9
  export declare function getFirstChildElement(element: HTMLElement): HTMLElement | undefined;
13
10
  export declare function getParentElement(element: HTMLElement): HTMLElement | undefined;
14
11
  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,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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AAO,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAa/E;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAwB/G;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,60 +3,17 @@ 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, t1) {
7
- const $ = c(15);
6
+ function useRovingTabIndex(t0) {
7
+ const $ = c(6);
8
8
  const {
9
9
  containerRef,
10
- mouseDownRef,
11
- focusOutBehavior,
12
- preventScroll: t2,
13
- wrapAround: t3
10
+ mouseDownRef
14
11
  } = t0;
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 = () => {
12
+ let t1;
13
+ if ($[0] !== containerRef || $[1] !== mouseDownRef) {
14
+ t1 = () => {
58
15
  var _containerRef$current, _containerRef$current2, _containerRef$current3;
59
- if (mouseDownRef !== null && mouseDownRef !== void 0 && mouseDownRef.current) {
16
+ if (mouseDownRef.current) {
60
17
  return;
61
18
  }
62
19
  const currentItem = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector("[aria-current]");
@@ -69,47 +26,51 @@ function useRovingTabIndex(t0, t1) {
69
26
  }
70
27
  return firstItem instanceof HTMLElement ? firstItem : undefined;
71
28
  };
72
- $[6] = containerRef;
73
- $[7] = mouseDownRef;
74
- $[8] = t7;
29
+ $[0] = containerRef;
30
+ $[1] = mouseDownRef;
31
+ $[2] = t1;
75
32
  } else {
76
- t7 = $[8];
33
+ t1 = $[2];
77
34
  }
78
- let t8;
79
- if ($[9] !== containerRef || $[10] !== preventScroll || $[11] !== t5 || $[12] !== t6 || $[13] !== t7) {
80
- t8 = {
35
+ let t2;
36
+ if ($[3] !== containerRef || $[4] !== t1) {
37
+ t2 = {
81
38
  containerRef,
82
39
  bindKeys: FocusKeys.ArrowVertical | FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd | FocusKeys.Backspace | FocusKeys.PageUpDown,
83
- preventScroll,
84
- getNextFocusable: t5,
85
- ...t6,
86
- focusInStrategy: t7
40
+ preventScroll: true,
41
+ getNextFocusable: _temp,
42
+ focusInStrategy: t1
87
43
  };
88
- $[9] = containerRef;
89
- $[10] = preventScroll;
90
- $[11] = t5;
91
- $[12] = t6;
92
- $[13] = t7;
93
- $[14] = t8;
44
+ $[3] = containerRef;
45
+ $[4] = t1;
46
+ $[5] = t2;
94
47
  } else {
95
- t8 = $[14];
48
+ t2 = $[5];
96
49
  }
97
- useFocusZone(t8, dependencies);
50
+ useFocusZone(t2);
98
51
  }
99
52
 
100
53
  // DOM utilities used for focus management
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);
54
+ function _temp(direction, from, event) {
55
+ var _getNextFocusableElem;
56
+ if (!(from instanceof HTMLElement)) {
57
+ return;
58
+ }
59
+ try {
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);
107
68
 
108
69
  // Reference: https://www.w3.org/WAI/ARIA/apg/patterns/treeview/#keyboard-interaction-24
109
70
  switch (`${elementState} ${event.key}`) {
110
71
  case 'open ArrowRight':
111
72
  // Focus first child node
112
- return getFirstChildElement(treeitem);
73
+ return getFirstChildElement(activeElement);
113
74
  case 'open ArrowLeft':
114
75
  // Close node; don't change focus
115
76
  return;
@@ -118,35 +79,35 @@ function getNextFocusableElement(activeElement, event, wrapAround = false) {
118
79
  return;
119
80
  case 'closed ArrowLeft':
120
81
  // Focus parent element
121
- return getParentElement(treeitem);
82
+ return getParentElement(activeElement);
122
83
  case 'end ArrowRight':
123
84
  // Do nothing
124
85
  return;
125
86
  case 'end ArrowLeft':
126
87
  // Focus parent element
127
- return getParentElement(treeitem);
88
+ return getParentElement(activeElement);
128
89
  }
129
90
 
130
91
  // ArrowUp, ArrowDown, Home, and End behavior are the same regardless of element state
131
92
  switch (event.key) {
132
93
  case 'ArrowUp':
133
94
  // Focus previous visible element
134
- return getVisibleElement(treeitem, 'previous', wrapAround);
95
+ return getVisibleElement(activeElement, 'previous');
135
96
  case 'ArrowDown':
136
97
  // Focus next visible element
137
- return getVisibleElement(treeitem, 'next', wrapAround);
98
+ return getVisibleElement(activeElement, 'next');
138
99
  case 'Backspace':
139
- return getParentElement(treeitem);
100
+ return getParentElement(activeElement);
140
101
  case 'Home':
141
102
  // Focus first visible element
142
- return getFirstElement(treeitem);
103
+ return getFirstElement(activeElement);
143
104
  case 'End':
144
105
  // Focus last visible element
145
- return getLastElement(treeitem);
106
+ return getLastElement(activeElement);
146
107
  case 'PageUp':
147
- return getPreviousPageElement(treeitem);
108
+ return getPreviousPageElement(activeElement);
148
109
  case 'PageDown':
149
- return getNextPageElement(treeitem);
110
+ return getNextPageElement(activeElement);
150
111
  }
151
112
  }
152
113
  function getElementState(element) {
@@ -162,7 +123,7 @@ function getElementState(element) {
162
123
  return 'end';
163
124
  }
164
125
  }
165
- function getVisibleElement(element, direction, wrapAround = false) {
126
+ function getVisibleElement(element, direction) {
166
127
  const root = element.closest('[role=tree]');
167
128
  if (!root) return;
168
129
  const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, node => {
@@ -180,11 +141,6 @@ function getVisibleElement(element, direction, wrapAround = false) {
180
141
  var _next$parentElement;
181
142
  next = direction === 'next' ? walker.nextNode() : walker.previousNode();
182
143
  }
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
- }
188
144
  return next instanceof HTMLElement ? next : undefined;
189
145
  }
190
146
  function getFirstChildElement(element) {
@@ -10,10 +10,10 @@ declare const data: {
10
10
  login: string;
11
11
  recommended: boolean;
12
12
  } | {
13
- recommended?: undefined;
14
13
  id: string;
15
14
  name: string;
16
15
  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;
42
41
  id: string;
43
42
  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;
51
50
  id: string;
52
51
  name: string;
52
+ trailingInfo?: undefined;
53
53
  })[];
54
54
  repos: {
55
55
  org: string;