@astryxdesign/core 0.7.2-canary.fbc03f7 → 0.7.2-canary.fdd384f

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 (58) hide show
  1. package/dist/AppShell/AppShell.d.ts.map +1 -1
  2. package/dist/AppShell/AppShell.js +40 -1
  3. package/dist/CommandPalette/CommandPaletteInput.d.ts +1 -1
  4. package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
  5. package/dist/CommandPalette/CommandPaletteInput.js +37 -5
  6. package/dist/Heading/Heading.d.ts.map +1 -1
  7. package/dist/Heading/Heading.js +4 -2
  8. package/dist/MobileNav/MobileNav.d.ts +9 -0
  9. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  10. package/dist/MobileNav/MobileNav.js +30 -3
  11. package/dist/SideNav/SideNavItem.d.ts +8 -1
  12. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  13. package/dist/SideNav/SideNavItem.js +71 -9
  14. package/dist/Text/Text.d.ts.map +1 -1
  15. package/dist/Text/Text.js +4 -2
  16. package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
  17. package/dist/TopNav/TopNavMegaMenu.js +3 -3
  18. package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
  19. package/dist/TopNav/TopNavMenu.js +3 -3
  20. package/dist/TreeList/TreeList.d.ts.map +1 -1
  21. package/dist/TreeList/TreeList.js +1 -0
  22. package/dist/TreeList/TreeListBranches.d.ts.map +1 -1
  23. package/dist/TreeList/TreeListBranches.js +2 -2
  24. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  25. package/dist/TreeList/TreeListItem.js +57 -9
  26. package/dist/astryx.css +11 -1
  27. package/package.json +3 -3
  28. package/src/AppShell/AppShell.tsx +45 -1
  29. package/src/Breadcrumbs/Breadcrumbs.test.tsx +30 -1
  30. package/src/Card/Card.doc.mjs +1 -1
  31. package/src/CommandPalette/CommandPaletteInput.test.tsx +53 -4
  32. package/src/CommandPalette/CommandPaletteInput.tsx +33 -3
  33. package/src/CommandPalette/__tests__/CommandPaletteInputAudit.a11y.chromium.spec.ts +335 -0
  34. package/src/CommandPalette/__tests__/CommandPaletteItemAudit.a11y.chromium.spec.ts +292 -0
  35. package/src/ContextMenu/ContextMenu.doc.mjs +2 -3
  36. package/src/ContextMenu/__tests__/ContextMenuAudit.a11y.chromium.spec.ts +438 -0
  37. package/src/DropdownMenu/DropdownMenu.test.tsx +41 -1
  38. package/src/DropdownMenu/DropdownMenuDivider.spec.md +192 -0
  39. package/src/DropdownMenu/__tests__/DropdownMenuDividerAudit.a11y.chromium.spec.ts +280 -0
  40. package/src/Heading/Heading.test.tsx +57 -0
  41. package/src/Heading/Heading.tsx +6 -2
  42. package/src/MobileNav/MobileNav.tsx +30 -3
  43. package/src/MobileNav/MobileNavCloseEdgeCases.test.tsx +173 -15
  44. package/src/SideNav/SideNav.test.tsx +179 -0
  45. package/src/SideNav/SideNavItem.doc.mjs +2 -2
  46. package/src/SideNav/SideNavItem.tsx +96 -17
  47. package/src/Text/Text.test.tsx +57 -0
  48. package/src/Text/Text.tsx +6 -2
  49. package/src/TopNav/TopNavMegaMenu.test.tsx +22 -0
  50. package/src/TopNav/TopNavMegaMenu.tsx +7 -3
  51. package/src/TopNav/TopNavMenu.test.tsx +19 -0
  52. package/src/TopNav/TopNavMenu.tsx +11 -3
  53. package/src/TreeList/TreeList.doc.mjs +1 -0
  54. package/src/TreeList/TreeList.test.tsx +327 -6
  55. package/src/TreeList/TreeList.tsx +5 -1
  56. package/src/TreeList/TreeListBranches.tsx +6 -0
  57. package/src/TreeList/TreeListItem.tsx +88 -13
  58. package/src/theme/derivedVarRegistry.test.ts +4 -0
@@ -14,7 +14,7 @@
14
14
  * - /packages/cli/assets/templates/blocks/components/TreeList/ (showcase blocks)
15
15
  */
16
16
 
17
- import {useId, useMemo, type ReactNode} from 'react';
17
+ import {useId, useMemo, useRef, type ReactNode} from 'react';
18
18
  import * as stylex from '@stylexjs/stylex';
19
19
  import {
20
20
  colorVars,
@@ -27,6 +27,10 @@ import {
27
27
  import {focusOutlineProps} from '../utils/focusOutline.stylex';
28
28
  import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
29
29
  import {usePressFeedback} from '../hooks/usePressFeedback';
30
+ import {
31
+ hasInteractiveAncestor,
32
+ useClickableContainer,
33
+ } from '../hooks/useClickableContainer';
30
34
  import {Icon} from '../Icon';
31
35
  import {mergeProps} from '../utils';
32
36
  import {useLinkComponent} from '../Link/useLinkComponent';
@@ -46,6 +50,13 @@ const styles = stylex.create({
46
50
  padding: 0,
47
51
  position: 'relative',
48
52
  width: '100%',
53
+ // Publish whether THIS treeitem has keyboard focus, for its row's
54
+ // `zIndex` (see `contentWrapper`). Every nested <li> redeclares the
55
+ // default, so a focused ancestor never lifts its descendants' rows.
56
+ '--_tree-focus-z': {
57
+ default: 'auto',
58
+ ':focus-visible': '2',
59
+ },
49
60
  // The treeitem row is the roving-tabindex focus owner; suppress the
50
61
  // native focus ring in favor of the row's :focus-visible outline below.
51
62
  outline: 'none',
@@ -82,6 +93,9 @@ const styles = stylex.create({
82
93
  display: 'flex',
83
94
  alignItems: 'center',
84
95
  gap: spacingVars['--spacing-2'],
96
+ // The row's own inline padding only. The per-level indent lives on
97
+ // `indentedContent` inside it, so a theme or caller padding here composes
98
+ // with the indent instead of replacing it.
85
99
  paddingInline: spacingVars['--spacing-2'],
86
100
  // No `outline: 'none'` here: this element receives the shared focus ring,
87
101
  // which already defaults to none, and the shorthand would erase it.
@@ -89,12 +103,38 @@ const styles = stylex.create({
89
103
  position: 'relative',
90
104
  boxSizing: 'border-box',
91
105
  textAlign: 'start',
92
- // Per-level indent. Declared here (not inline) so it lives in
93
- // `@layer astryx-base` and the theme layer can override it in normal
94
- // cascade order — an inline longhand would outrank every layer. The row
95
- // publishes only the computed distance as `--_tree-indent`; the per-level
96
- // step is the public `--tree-list-indent` lever (see TreeList `root`).
97
- marginInlineStart: 'var(--_tree-indent, 0px)',
106
+ },
107
+ // Guide lines draw above the rows (TreeListBranches) so a row's fill does
108
+ // not break them. Lift the row whose focus ring is showing above the guides
109
+ // too, so no guide cuts through the ring: when focus is inside the row, or
110
+ // when its own treeitem publishes focus (`--_tree-focus-z` on `wrapper`).
111
+ // The ring is the row's outline, so it cannot be lifted on its own: a
112
+ // focused row that is also filled (selected or hovered) covers the guides at
113
+ // that row. That is the accepted trade-off (DD3). Applied only with
114
+ // `focusWithinOrPublished`, the rows that draw the ring: a plain row shows
115
+ // no ring, so its fill stays under the guides.
116
+ focusLift: {
117
+ zIndex: {
118
+ default: 'var(--_tree-focus-z, auto)',
119
+ ':has(:focus-visible)': 2,
120
+ },
121
+ },
122
+ // Per-level indent, drawn INSIDE the row box: the row (`contentWrapper`)
123
+ // stays full width, so a nested row's hover and selected fill spans the
124
+ // list like a root row's, while its content sits exactly where a margin
125
+ // indent would put it. A child of the row rather than the row's own padding,
126
+ // so a theme or caller that sets the row's padding keeps the indent. It
127
+ // inherits the row's flex alignment and gap, so a theme that retunes those
128
+ // on `tree-list-item` still lays the content out. The row publishes only the
129
+ // computed distance as `--_tree-indent`; the per-level step is the public,
130
+ // themeable `--tree-list-indent` lever (see TreeList `root`).
131
+ indentedContent: {
132
+ display: 'flex',
133
+ flex: 1,
134
+ minWidth: 0,
135
+ alignItems: 'inherit',
136
+ gap: 'inherit',
137
+ paddingInlineStart: 'var(--_tree-indent, 0px)',
98
138
  },
99
139
  interactive: {
100
140
  cursor: {
@@ -369,6 +409,7 @@ export function TreeListItem({
369
409
  const labelId = useId();
370
410
  const descriptionId = useId();
371
411
  const LinkComponent = useLinkComponent();
412
+ const linkRef = useRef<HTMLAnchorElement>(null);
372
413
  const isInteractive = onClick != null || href != null;
373
414
 
374
415
  const handleToggle = useMemo(
@@ -388,8 +429,10 @@ export function TreeListItem({
388
429
  if (isDisabled) {
389
430
  return;
390
431
  }
391
- const el = e.target as HTMLElement;
392
- if (el.closest('button, a, input, select, textarea')) {
432
+ // Controls inside the row, native or role-based, keep their own
433
+ // activation (FR7): the same rule link rows get from the shared
434
+ // enlarged-surface hook below.
435
+ if (hasInteractiveAncestor(e.target as Element, e.currentTarget)) {
393
436
  return;
394
437
  }
395
438
  if (onClick != null) {
@@ -402,6 +445,34 @@ export function TreeListItem({
402
445
  return undefined;
403
446
  }, [onClick, hasChildren, onToggle, id, isDisabled]);
404
447
 
448
+ // A link row (an `href` and no other row action) is an enlarged surface for
449
+ // its link: the indent is part of the row, so a click anywhere in it must
450
+ // follow the link, as Enter already does. Built on the shared
451
+ // enlarged-surface hook (family:navigation-destinations), which skips
452
+ // clicks on nested controls, native or role-based, and text selections.
453
+ // - Clicks are delegated: the hook re-dispatches the click on the anchor
454
+ // with its modifier keys, so the link component and the browser handle
455
+ // same-tab, new-tab and new-window activation, and stops the original, so
456
+ // ancestors see one click per press.
457
+ // - Middle-click has no synthetic equivalent, so it takes the hook's href
458
+ // path, which opens the destination in a new tab after the shared
459
+ // navigation rule.
460
+ // The container ref is attached to link rows only, so every other row stays
461
+ // a plain element and both hook instances stay inert on it.
462
+ const forwardsToLink = href != null && handleClick == null;
463
+ const linkRowRef = useRef<HTMLDivElement>(null);
464
+ const {onClick: delegateToLink} = useClickableContainer({
465
+ containerRef: linkRowRef,
466
+ interactiveRef: linkRef,
467
+ disabled: isDisabled || !forwardsToLink,
468
+ });
469
+ const {onMouseUp: openLinkOnMiddleClick} = useClickableContainer({
470
+ containerRef: linkRowRef,
471
+ href,
472
+ target,
473
+ disabled: isDisabled || !forwardsToLink,
474
+ });
475
+
405
476
  // Per-level indent distance. The per-level step is the public, themeable
406
477
  // `--tree-list-indent` lever (default `--spacing-4`, set on the tree-list
407
478
  // root). A leaf adds a fixed chevron-column offset (chevron width + gap) so
@@ -411,8 +482,8 @@ export function TreeListItem({
411
482
  // every row sits flush, like a parent at that level. That offset is tied to
412
483
  // the chevron's own dimensions, not the indent step, so it does not scale
413
484
  // with the lever. Published as the private `--_tree-indent` and consumed by
414
- // `contentWrapper`'s stylesheet `margin-inline-start` (kept out of the inline
415
- // style so the theme layer can override it — see #4308).
485
+ // `indentedContent`'s stylesheet `padding-inline-start`; the step stays
486
+ // themeable through `--tree-list-indent` (see #4308).
416
487
  const reservesChevronColumn = !hasChildren && hasExpandableItems;
417
488
  const indentDistance = reservesChevronColumn
418
489
  ? `calc(${nestedLevel} * var(--tree-list-indent) + ${spacingVars['--spacing-4']} + ${spacingVars['--spacing-2']})`
@@ -521,6 +592,7 @@ export function TreeListItem({
521
592
  )}
522
593
  {href != null ? (
523
594
  <LinkComponent
595
+ ref={linkRef}
524
596
  href={href}
525
597
  target={target}
526
598
  aria-disabled={isDisabled || undefined}
@@ -599,6 +671,7 @@ export function TreeListItem({
599
671
  isInteractive || (hasChildren && onClick == null)
600
672
  ? focusOutlineProps.focusWithinOrPublished(
601
673
  styles.contentWrapper,
674
+ styles.focusLift,
602
675
  densityStyles[density],
603
676
  styles.interactive,
604
677
  interactionOverlayStyles.backgroundImage,
@@ -620,8 +693,10 @@ export function TreeListItem({
620
693
  className,
621
694
  {...indentStyle, ...style},
622
695
  )}
623
- onClick={handleClick}>
624
- {innerContent}
696
+ ref={forwardsToLink ? linkRowRef : undefined}
697
+ onClick={forwardsToLink ? delegateToLink : handleClick}
698
+ onMouseUp={forwardsToLink ? openLinkOnMiddleClick : undefined}>
699
+ <div {...stylex.props(styles.indentedContent)}>{innerContent}</div>
625
700
  </div>
626
701
  </div>
627
702
  {isExpanded && renderedChildren != null && (
@@ -319,6 +319,10 @@ const VARS_WITHOUT_DERIVED_MAPPING = new Set([
319
319
  '--tree-list-indent',
320
320
  '--_tree-indent',
321
321
  '--tree-list-row-gap',
322
+ // Published by each treeitem while it has keyboard focus and read as its
323
+ // row's z-index, so the focused row paints above the guide lines. Focus
324
+ // state, not a value a theme author sets.
325
+ '--_tree-focus-z',
322
326
  // Clipped on the ONE side each on-track connector segment faces the
323
327
  // indicator from — trailing above the node, leading below it, mirrored
324
328
  // again per axis. No standard property maps onto this purpose-based seam: