@primer/react 0.0.0-20260312205709 → 0.0.0-20260313015748

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,6 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260312205709
4
-
5
- ### Minor Changes
6
-
7
- - [#7658](https://github.com/primer/react/pull/7658) [`2da6602`](https://github.com/primer/react/commit/2da66024e332ac0510815aa304ecc13b6d07ea75) Thanks [@hussam-i-am](https://github.com/hussam-i-am)! - fix(polymorphic): Improve prop passthrough for ActionList.LinkItem and Breadcrumbs.Item
3
+ ## 0.0.0-20260313015748
8
4
 
9
5
  ### Patch Changes
10
6
 
@@ -30,8 +26,6 @@
30
26
 
31
27
  - [#7545](https://github.com/primer/react/pull/7545) [`17ec46f`](https://github.com/primer/react/commit/17ec46f77524f3ad5e1789102bdf2dbaf47eab49) Thanks [@hectahertz](https://github.com/hectahertz)! - perf(TreeView): defer scrollIntoView to coalesce reflows during rapid navigation
32
28
 
33
- - [#7544](https://github.com/primer/react/pull/7544) [`63bfd67`](https://github.com/primer/react/commit/63bfd67b6d3ee4c9d5c6a0c11bfeae7f0159ef5d) Thanks [@hectahertz](https://github.com/hectahertz)! - perf(TreeView): replace O(n) TreeWalker with O(depth) sibling traversal
34
-
35
29
  ## 38.15.0
36
30
 
37
31
  ### Minor Changes
@@ -1,5 +1,5 @@
1
- import type React from 'react';
2
- import type { WithSlotMarker } from '../utils/types/Slots';
1
+ import React from 'react';
2
+ import type { ForwardRefComponent as PolymorphicForwardRefComponent } from '../utils/polymorphic';
3
3
  import type { ActionListItemProps } from './shared';
4
4
  type LinkProps = {
5
5
  download?: string;
@@ -14,9 +14,6 @@ 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, "children" | "size" | "active" | "variant" | "inactiveText"> & LinkProps extends infer T ? T extends React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & Pick<ActionListItemProps, "children" | "size" | "active" | "variant" | "inactiveText"> & LinkProps ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
18
- as?: As | undefined;
19
- } & React.RefAttributes<unknown>) => React.ReactNode;
20
- export declare const LinkItem: WithSlotMarker<typeof LinkItemComponent>;
17
+ export declare const LinkItem: PolymorphicForwardRefComponent<"a", ActionListLinkItemProps>;
21
18
  export {};
22
19
  //# sourceMappingURL=LinkItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LinkItem.d.ts","sourceRoot":"","sources":["../../src/ActionList/LinkItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAA;AAGxD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AAIjD,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAChF,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAGD,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,mBAAmB,EACnB,QAAQ,GAAG,UAAU,GAAG,cAAc,GAAG,SAAS,GAAG,MAAM,CAC5D,GACC,SAAS,CAAA;AAIX,QAAA,MAAM,iBAAiB,GACpB,EAAE,SAAS,KAAK,CAAC,WAAW;;oDAqC9B,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,cAAc,CAAC,OAAO,iBAAiB,CAG5D,CAAA"}
1
+ {"version":3,"file":"LinkItem.d.ts","sourceRoot":"","sources":["../../src/ActionList/LinkItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAG/F,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AAGjD,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAChF,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAGD,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,mBAAmB,EACnB,QAAQ,GAAG,UAAU,GAAG,cAAc,GAAG,SAAS,GAAG,MAAM,CAC5D,GACC,SAAS,CAAA;AAEX,eAAO,MAAM,QAAQ,EA4BhB,8BAA8B,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAA"}
@@ -1,46 +1,62 @@
1
+ import { c } from 'react-compiler-runtime';
2
+ import React from 'react';
1
3
  import { Item } from './Item.js';
2
- import { fixedForwardRef } from '../utils/modern-polymorphic.js';
3
4
  import { jsx } from 'react/jsx-runtime';
4
5
  import Link from '../Link/Link.js';
5
6
 
6
- const LinkItemComponent = fixedForwardRef(({
7
- active,
8
- inactiveText,
9
- variant,
10
- size,
11
- as: Component,
12
- className,
13
- ...props
14
- }, forwardedRef) => {
15
- return /*#__PURE__*/jsx(Item, {
16
- className: className,
17
- active: active,
18
- inactiveText: inactiveText,
19
- "data-inactive": inactiveText ? true : undefined,
20
- variant: variant,
21
- size: size,
22
- _PrivateItemWrapper: ({
23
- children,
24
- onClick,
25
- ...rest
26
- }) => {
7
+ const LinkItem = /*#__PURE__*/React.forwardRef((t0, forwardedRef) => {
8
+ const $ = c(22);
9
+ let Component;
10
+ let active;
11
+ let className;
12
+ let inactiveText;
13
+ let props;
14
+ let size;
15
+ let variant;
16
+ if ($[0] !== t0) {
17
+ ({
18
+ active,
19
+ inactiveText,
20
+ variant,
21
+ size,
22
+ as: Component,
23
+ className,
24
+ ...props
25
+ } = t0);
26
+ $[0] = t0;
27
+ $[1] = Component;
28
+ $[2] = active;
29
+ $[3] = className;
30
+ $[4] = inactiveText;
31
+ $[5] = props;
32
+ $[6] = size;
33
+ $[7] = variant;
34
+ } else {
35
+ Component = $[1];
36
+ active = $[2];
37
+ className = $[3];
38
+ inactiveText = $[4];
39
+ props = $[5];
40
+ size = $[6];
41
+ variant = $[7];
42
+ }
43
+ const t1 = inactiveText ? true : undefined;
44
+ let t2;
45
+ if ($[8] !== Component || $[9] !== forwardedRef || $[10] !== inactiveText || $[11] !== props) {
46
+ t2 = t3 => {
47
+ const {
48
+ children,
49
+ onClick,
50
+ ...rest
51
+ } = t3;
27
52
  const clickHandler = event => {
28
53
  onClick && onClick(event);
29
54
  props.onClick && props.onClick(event);
30
55
  };
31
- if (inactiveText) {
32
- return /*#__PURE__*/jsx("span", {
33
- ...rest,
34
- children: children
35
- });
36
- }
37
-
38
- // Type safety for the polymorphic `as` prop is enforced at the
39
- // LinkItem boundary via fixedForwardRef. Internally we widen
40
- // Link's type so TypeScript doesn't re-check the generic
41
- // constraint across two polymorphic layers.
42
- const InternalLink = Link;
43
- return /*#__PURE__*/jsx(InternalLink, {
56
+ return inactiveText ? /*#__PURE__*/jsx("span", {
57
+ ...rest,
58
+ children: children
59
+ }) : /*#__PURE__*/jsx(Link, {
44
60
  as: Component,
45
61
  ...rest,
46
62
  ...props,
@@ -48,13 +64,42 @@ const LinkItemComponent = fixedForwardRef(({
48
64
  ref: forwardedRef,
49
65
  children: children
50
66
  });
51
- },
52
- children: props.children
53
- });
54
- });
55
- const LinkItem = Object.assign(LinkItemComponent, {
56
- displayName: 'ActionList.LinkItem',
57
- __SLOT__: Symbol('ActionList.LinkItem')
67
+ };
68
+ $[8] = Component;
69
+ $[9] = forwardedRef;
70
+ $[10] = inactiveText;
71
+ $[11] = props;
72
+ $[12] = t2;
73
+ } else {
74
+ t2 = $[12];
75
+ }
76
+ let t3;
77
+ if ($[13] !== active || $[14] !== className || $[15] !== inactiveText || $[16] !== props.children || $[17] !== size || $[18] !== t1 || $[19] !== t2 || $[20] !== variant) {
78
+ t3 = /*#__PURE__*/jsx(Item, {
79
+ className: className,
80
+ active: active,
81
+ inactiveText: inactiveText,
82
+ "data-inactive": t1,
83
+ variant: variant,
84
+ size: size,
85
+ _PrivateItemWrapper: t2,
86
+ children: props.children
87
+ });
88
+ $[13] = active;
89
+ $[14] = className;
90
+ $[15] = inactiveText;
91
+ $[16] = props.children;
92
+ $[17] = size;
93
+ $[18] = t1;
94
+ $[19] = t2;
95
+ $[20] = variant;
96
+ $[21] = t3;
97
+ } else {
98
+ t3 = $[21];
99
+ }
100
+ return t3;
58
101
  });
102
+ LinkItem.displayName = 'ActionList.LinkItem';
103
+ LinkItem.__SLOT__ = Symbol('ActionList.LinkItem');
59
104
 
60
105
  export { LinkItem };
@@ -84,31 +84,7 @@ export declare const ActionList: (<As extends React.ElementType = "ul">(props: (
84
84
  __SLOT__: symbol;
85
85
  };
86
86
  /** A `Item` that renders a full-size anchor inside ListItem */
87
- LinkItem: import("../utils/types").WithSlotMarker<(<As extends React.ElementType = "a">(props: (import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<import("./shared").ActionListItemProps, "children" | "size" | "active" | "variant" | "inactiveText"> & {
88
- download?: string;
89
- href?: string;
90
- hrefLang?: string;
91
- media?: string;
92
- ping?: string;
93
- rel?: string;
94
- target?: string;
95
- type?: string;
96
- referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>["referrerPolicy"];
97
- className?: string;
98
- } extends infer T ? T extends import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<import("./shared").ActionListItemProps, "children" | "size" | "active" | "variant" | "inactiveText"> & {
99
- download?: string;
100
- href?: string;
101
- hrefLang?: string;
102
- media?: string;
103
- ping?: string;
104
- rel?: string;
105
- target?: string;
106
- type?: string;
107
- referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>["referrerPolicy"];
108
- className?: string;
109
- } ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
110
- as?: As | undefined;
111
- } & import("react").RefAttributes<unknown>) => React.ReactNode)>;
87
+ LinkItem: import("../utils/polymorphic").ForwardRefComponent<"a", import("./LinkItem").ActionListLinkItemProps>;
112
88
  /** Visually separates `Item`s or `Group`s in an `ActionList`. */
113
89
  Divider: import("../utils/types").FCWithSlotMarker<import("react").PropsWithChildren<import("./Divider").ActionListDividerProps>>;
114
90
  /** Secondary text which provides additional information about an `Item`. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ActionList/index.ts"],"names":[],"mappings":"AAUA,YAAY,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AAC7C,YAAY,EAAC,oBAAoB,EAAE,2BAA2B,EAAC,MAAM,SAAS,CAAA;AAC9E,YAAY,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AACjD,YAAY,EAAC,uBAAuB,EAAC,MAAM,YAAY,CAAA;AACvD,YAAY,EAA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yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGzC,+DAA+D;;IAG/D,iEAAiE;;IAGjE,4EAA4E;;IAG5E,uDAAuD;;IAGvD,sDAAsD;;IAGtD,mCAAmC;;IAGnC,qCAAqC;;IAGrC,uBAAuB;;CAEvB,CAAA"}
@@ -1,6 +1,5 @@
1
1
  import type { To } from 'history';
2
2
  import React from 'react';
3
- import { type PolymorphicProps } from '../utils/modern-polymorphic';
4
3
  export type BreadcrumbsProps = React.PropsWithChildren<{
5
4
  /**
6
5
  * Optional class name for the breadcrumbs container.
@@ -28,38 +27,24 @@ declare function Breadcrumbs({ className, children, style, overflow, variant }:
28
27
  declare namespace Breadcrumbs {
29
28
  var displayName: string;
30
29
  }
31
- type StyledBreadcrumbsItemProps<As extends React.ElementType = 'a'> = PolymorphicProps<As, 'a', {
30
+ type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends any ? Omit<T, TOmitted> : never;
31
+ type StyledBreadcrumbsItemProps<As extends React.ElementType> = {
32
+ as?: As;
32
33
  to?: To;
33
34
  selected?: boolean;
34
- }>;
35
+ className?: string;
36
+ style?: React.CSSProperties;
37
+ } & DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? 'a' : As>, 'as'>;
35
38
  export type BreadcrumbsItemProps<As extends React.ElementType = 'a'> = StyledBreadcrumbsItemProps<As>;
36
39
  declare const _default: typeof Breadcrumbs & {
37
- Item: (<As extends React.ElementType = "a">(props: (React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & {
38
- to?: To;
39
- selected?: boolean;
40
- } extends infer T ? T extends React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & {
41
- to?: To;
42
- selected?: boolean;
43
- } ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
44
- as?: As | undefined;
45
- } & React.RefAttributes<any>) => React.ReactNode) & {
46
- displayName: string;
47
- };
40
+ Item: React.ForwardRefExoticComponent<Omit<StyledBreadcrumbsItemProps<React.ElementType<any, keyof React.JSX.IntrinsicElements>>, "ref"> & React.RefAttributes<any>>;
48
41
  };
49
42
  export default _default;
50
43
  /**
51
44
  * @deprecated Use the `Breadcrumbs` component instead (i.e. `<Breadcrumb>` → `<Breadcrumbs>`)
52
45
  */
53
46
  export declare const Breadcrumb: typeof Breadcrumbs & {
54
- Item: <As extends React.ElementType = "a">(props: (React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & {
55
- to?: To;
56
- selected?: boolean;
57
- } extends infer T ? T extends React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & {
58
- to?: To;
59
- selected?: boolean;
60
- } ? T extends unknown ? Omit<T, "as"> : never : never : never) & {
61
- as?: As | undefined;
62
- } & React.RefAttributes<any>) => React.ReactNode;
47
+ Item: React.ForwardRefExoticComponent<Omit<StyledBreadcrumbsItemProps<React.ElementType<any, keyof React.JSX.IntrinsicElements>>, "ref"> & React.RefAttributes<any>>;
63
48
  };
64
49
  /**
65
50
  * @deprecated Use the `BreadcrumbsProps` type instead
@@ -1 +1 @@
1
- {"version":3,"file":"Breadcrumbs.d.ts","sourceRoot":"","sources":["../../src/Breadcrumbs/Breadcrumbs.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,SAAS,CAAA;AAC/B,OAAO,KAA6E,MAAM,OAAO,CAAA;AAWjG,OAAO,EAAC,KAAK,gBAAgB,EAAkB,MAAM,6BAA6B,CAAA;AAElF,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACrD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAA;IAC7C;;;;OAIG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,CAAC,C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}
@@ -8,7 +8,6 @@ import { KebabHorizontalIcon } from '@primer/octicons-react';
8
8
  import { useResizeObserver } from '../hooks/useResizeObserver.js';
9
9
  import { useOnEscapePress } from '../hooks/useOnEscapePress.js';
10
10
  import { useOnOutsideClick } from '../hooks/useOnOutsideClick.js';
11
- import { fixedForwardRef } from '../utils/modern-polymorphic.js';
12
11
  import { jsx, jsxs } from 'react/jsx-runtime';
13
12
  import { useFeatureFlag } from '../FeatureFlags/useFeatureFlag.js';
14
13
  import Details from '../Details/Details.js';
@@ -400,26 +399,69 @@ const ItemSeparator = () => {
400
399
  }
401
400
  return t0;
402
401
  };
403
- const BreadcrumbsItem = fixedForwardRef((props, ref) => {
404
- const {
405
- as: Component = 'a',
406
- selected,
407
- className,
408
- ...rest
409
- } = props;
410
- return /*#__PURE__*/jsx(Component, {
411
- className: clsx(className, classes.Item, selected && 'selected'),
412
- "aria-current": selected ? 'page' : undefined,
413
- ref: ref,
414
- ...rest
415
- });
416
- });
402
+
403
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
404
+
405
+ function BreadcrumbsItemComponent(props, ref) {
406
+ const $ = c(14);
407
+ let className;
408
+ let rest;
409
+ let selected;
410
+ let t0;
411
+ if ($[0] !== props) {
412
+ ({
413
+ as: t0,
414
+ selected,
415
+ className,
416
+ ...rest
417
+ } = props);
418
+ $[0] = props;
419
+ $[1] = className;
420
+ $[2] = rest;
421
+ $[3] = selected;
422
+ $[4] = t0;
423
+ } else {
424
+ className = $[1];
425
+ rest = $[2];
426
+ selected = $[3];
427
+ t0 = $[4];
428
+ }
429
+ const Component = t0 === undefined ? "a" : t0;
430
+ const t1 = selected && "selected";
431
+ let t2;
432
+ if ($[5] !== className || $[6] !== t1) {
433
+ t2 = clsx(className, classes.Item, t1);
434
+ $[5] = className;
435
+ $[6] = t1;
436
+ $[7] = t2;
437
+ } else {
438
+ t2 = $[7];
439
+ }
440
+ const t3 = selected ? "page" : undefined;
441
+ let t4;
442
+ if ($[8] !== Component || $[9] !== ref || $[10] !== rest || $[11] !== t2 || $[12] !== t3) {
443
+ t4 = /*#__PURE__*/jsx(Component, {
444
+ className: t2,
445
+ "aria-current": t3,
446
+ ref: ref,
447
+ ...rest
448
+ });
449
+ $[8] = Component;
450
+ $[9] = ref;
451
+ $[10] = rest;
452
+ $[11] = t2;
453
+ $[12] = t3;
454
+ $[13] = t4;
455
+ } else {
456
+ t4 = $[13];
457
+ }
458
+ return t4;
459
+ }
460
+ BreadcrumbsItemComponent.displayName = 'Breadcrumbs.Item';
461
+ const BreadcrumbsItem = /*#__PURE__*/React.forwardRef(BreadcrumbsItemComponent);
417
462
  Breadcrumbs.displayName = 'Breadcrumbs';
418
- const BreadcrumbsItemWithDisplayName = Object.assign(BreadcrumbsItem, {
419
- displayName: 'Breadcrumbs.Item'
420
- });
421
463
  var Breadcrumbs_default = Object.assign(Breadcrumbs, {
422
- Item: BreadcrumbsItemWithDisplayName
464
+ Item: BreadcrumbsItem
423
465
  });
424
466
 
425
467
  /**
@@ -5,20 +5,6 @@ export declare function useRovingTabIndex({ containerRef, mouseDownRef, }: {
5
5
  }): void;
6
6
  export declare function getNextFocusableElement(activeElement: HTMLElement, event: KeyboardEvent): HTMLElement | undefined;
7
7
  export declare function getElementState(element: HTMLElement): 'open' | 'closed' | 'end';
8
- /**
9
- * Find the next or previous visible treeitem using direct DOM traversal.
10
- *
11
- * PERFORMANCE: This is O(tree depth) instead of O(n) because it walks
12
- * siblings and parent/child edges directly, rather than creating a TreeWalker
13
- * that scans from the root to find the current element on every keystroke.
14
- *
15
- * NOTE: This relies on TreeView.SubTree unmounting its children when collapsed
16
- * (returning null when !isExpanded). Because collapsed subtree children are
17
- * never in the DOM, we can safely skip them by only entering children of nodes
18
- * with aria-expanded="true". If SubTree ever changes to keep collapsed children
19
- * mounted (e.g. via CSS display:none), this logic would need to add filtering
20
- * for items inside collapsed parents.
21
- */
22
8
  export declare function getVisibleElement(element: HTMLElement, direction: 'next' | 'previous'): HTMLElement | undefined;
23
9
  export declare function getFirstChildElement(element: HTMLElement): HTMLElement | undefined;
24
10
  export declare function getParentElement(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,CAAC,EAChC,YAAY,EACZ,YAAY,GACb,EAAE;IACD,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IAC1C,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;CACvC,QAwDA;AAID,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,GAAG,WAAW,GAAG,SAAS,CAyDjH;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAa/E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAK/G;AAsFD,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"}
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,CAAC,EAChC,YAAY,EACZ,YAAY,GACb,EAAE;IACD,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IAC1C,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;CACvC,QAwDA;AAID,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,GAAG,WAAW,GAAG,SAAS,CAyDjH;AAED,wBAAgB,eAAe,CAAC,OAAO,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"}
@@ -123,103 +123,25 @@ function getElementState(element) {
123
123
  return 'end';
124
124
  }
125
125
  }
126
-
127
- /**
128
- * Find the next or previous visible treeitem using direct DOM traversal.
129
- *
130
- * PERFORMANCE: This is O(tree depth) instead of O(n) because it walks
131
- * siblings and parent/child edges directly, rather than creating a TreeWalker
132
- * that scans from the root to find the current element on every keystroke.
133
- *
134
- * NOTE: This relies on TreeView.SubTree unmounting its children when collapsed
135
- * (returning null when !isExpanded). Because collapsed subtree children are
136
- * never in the DOM, we can safely skip them by only entering children of nodes
137
- * with aria-expanded="true". If SubTree ever changes to keep collapsed children
138
- * mounted (e.g. via CSS display:none), this logic would need to add filtering
139
- * for items inside collapsed parents.
140
- */
141
126
  function getVisibleElement(element, direction) {
142
- if (direction === 'next') {
143
- return getNextVisibleElement(element);
144
- }
145
- return getPreviousVisibleElement(element);
146
- }
147
- function getNextVisibleElement(element) {
148
- // If the current item is expanded, the next visible item is its first child
149
- if (element.getAttribute('aria-expanded') === 'true') {
150
- const firstChild = getFirstChildElement(element);
151
- if (firstChild) return firstChild;
152
- }
153
-
154
- // Otherwise, walk up the tree looking for a next sibling
155
- let current = element;
156
- while (current) {
157
- const next = getNextSiblingTreeItem(current);
158
- if (next) return next;
159
-
160
- // No next sibling at this level, try the parent's next sibling
161
- current = getParentElement(current);
162
- }
163
- return undefined;
164
- }
165
- function getPreviousVisibleElement(element) {
166
- const prev = getPreviousSiblingTreeItem(element);
167
- if (prev) {
168
- // Navigate to the deepest last visible descendant of the previous sibling
169
- return getDeepestLastDescendant(prev);
170
- }
171
-
172
- // No previous sibling, the parent is the previous visible element
173
- return getParentElement(element);
174
- }
127
+ const root = element.closest('[role=tree]');
128
+ if (!root) return;
129
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, node => {
130
+ if (!(node instanceof HTMLElement)) return NodeFilter.FILTER_SKIP;
131
+ return node.getAttribute('role') === 'treeitem' ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
132
+ });
133
+ let current = walker.firstChild();
134
+ while (current !== element) {
135
+ current = walker.nextNode();
136
+ }
137
+ let next = direction === 'next' ? walker.nextNode() : walker.previousNode();
175
138
 
176
- /**
177
- * Walk into expanded subtrees to find the deepest last visible descendant.
178
- * For example, if the last sibling is an expanded directory whose last child
179
- * is also an expanded directory, we drill all the way down.
180
- */
181
- function getDeepestLastDescendant(element) {
182
- let current = element;
183
- while (current.getAttribute('aria-expanded') === 'true') {
184
- const lastChild = getLastChildTreeItem(current);
185
- if (!lastChild) break;
186
- current = lastChild;
187
- }
188
- return current;
189
- }
190
- function getNextSiblingTreeItem(element) {
191
- let sibling = element.nextElementSibling;
192
- while (sibling) {
193
- if (sibling instanceof HTMLElement && sibling.getAttribute('role') === 'treeitem') {
194
- return sibling;
195
- }
196
- sibling = sibling.nextElementSibling;
197
- }
198
- return undefined;
199
- }
200
- function getPreviousSiblingTreeItem(element) {
201
- let sibling = element.previousElementSibling;
202
- while (sibling) {
203
- if (sibling instanceof HTMLElement && sibling.getAttribute('role') === 'treeitem') {
204
- return sibling;
205
- }
206
- sibling = sibling.previousElementSibling;
207
- }
208
- return undefined;
209
- }
210
- function getLastChildTreeItem(element) {
211
- // Find the [role=group] child (the subtree container), then get its last treeitem
212
- for (let i = element.children.length - 1; i >= 0; i--) {
213
- const child = element.children[i];
214
- if (child instanceof HTMLElement && child.getAttribute('role') === 'group') {
215
- let lastChild = child.lastElementChild;
216
- while (lastChild && !(lastChild instanceof HTMLElement && lastChild.getAttribute('role') === 'treeitem')) {
217
- lastChild = lastChild.previousElementSibling;
218
- }
219
- return lastChild instanceof HTMLElement ? lastChild : undefined;
220
- }
139
+ // If next element is nested inside a collapsed subtree, continue iterating
140
+ while (next instanceof HTMLElement && (_next$parentElement = next.parentElement) !== null && _next$parentElement !== void 0 && _next$parentElement.closest('[role=treeitem][aria-expanded=false]')) {
141
+ var _next$parentElement;
142
+ next = direction === 'next' ? walker.nextNode() : walker.previousNode();
221
143
  }
222
- return undefined;
144
+ return next instanceof HTMLElement ? next : undefined;
223
145
  }
224
146
  function getFirstChildElement(element) {
225
147
  const firstChild = element.querySelector('[role=treeitem]');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260312205709",
4
+ "version": "0.0.0-20260313015748",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",