@astryxdesign/core 0.6.2-canary.bfee8a4 → 0.6.2-canary.d4cc232

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 (103) hide show
  1. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  2. package/dist/CheckboxInput/CheckboxInput.js +12 -2
  3. package/dist/Collapsible/Collapsible.d.ts.map +1 -1
  4. package/dist/Collapsible/Collapsible.js +6 -1
  5. package/dist/Kbd/Kbd.d.ts +5 -3
  6. package/dist/Kbd/Kbd.d.ts.map +1 -1
  7. package/dist/Kbd/Kbd.js +36 -42
  8. package/dist/Link/Link.d.ts.map +1 -1
  9. package/dist/Link/Link.js +6 -2
  10. package/dist/Markdown/Markdown.d.ts.map +1 -1
  11. package/dist/Markdown/Markdown.js +63 -59
  12. package/dist/Markdown/ast.d.ts +124 -0
  13. package/dist/Markdown/ast.d.ts.map +1 -0
  14. package/dist/Markdown/ast.js +38 -0
  15. package/dist/Markdown/parser.d.ts +14 -8
  16. package/dist/Markdown/parser.d.ts.map +1 -1
  17. package/dist/Markdown/parser.js +352 -97
  18. package/dist/Outline/parseOutlineFromMarkdown.d.ts.map +1 -1
  19. package/dist/Outline/parseOutlineFromMarkdown.js +7 -7
  20. package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
  21. package/dist/PowerSearch/PowerSearchEditPopover.js +46 -30
  22. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  23. package/dist/RadioList/RadioListItem.js +13 -1
  24. package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
  25. package/dist/SegmentedControl/SegmentedControlItem.js +5 -5
  26. package/dist/SideNav/SideNav.d.ts +2 -1
  27. package/dist/SideNav/SideNav.d.ts.map +1 -1
  28. package/dist/SideNav/SideNav.js +9 -3
  29. package/dist/Slider/Slider.d.ts.map +1 -1
  30. package/dist/Slider/Slider.js +14 -8
  31. package/dist/Switch/Switch.d.ts.map +1 -1
  32. package/dist/Switch/Switch.js +11 -0
  33. package/dist/TabList/Tab.d.ts +1 -1
  34. package/dist/TabList/Tab.d.ts.map +1 -1
  35. package/dist/TabList/Tab.js +20 -7
  36. package/dist/ToggleButton/ToggleButton.d.ts +2 -1
  37. package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
  38. package/dist/ToggleButton/ToggleButton.js +7 -1
  39. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  40. package/dist/Typeahead/BaseTypeahead.js +15 -6
  41. package/dist/astryx.css +8 -0
  42. package/dist/utils/interactionOverlay.stylex.d.ts +8 -0
  43. package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
  44. package/dist/utils/interactionOverlay.stylex.js +9 -0
  45. package/package.json +3 -3
  46. package/src/Button/__tests__/Button.a11y.chromium.spec.ts +17 -1
  47. package/src/Button/__tests__/Button.a11y.known-failures.ts +0 -29
  48. package/src/Button/__tests__/Button.a11y.renders.tsx +9 -2
  49. package/src/Button/__tests__/Button.a11y.states.ts +9 -0
  50. package/src/CheckboxInput/CheckboxInput.doc.mjs +11 -0
  51. package/src/CheckboxInput/CheckboxInput.test.tsx +34 -0
  52. package/src/CheckboxInput/CheckboxInput.tsx +21 -1
  53. package/src/ClickableCard/ClickableCard.test.tsx +102 -5
  54. package/src/Collapsible/Collapsible.doc.mjs +11 -0
  55. package/src/Collapsible/Collapsible.test.tsx +21 -0
  56. package/src/Collapsible/Collapsible.tsx +5 -0
  57. package/src/Kbd/Kbd.doc.mjs +3 -3
  58. package/src/Kbd/Kbd.test.tsx +57 -1
  59. package/src/Kbd/Kbd.tsx +57 -37
  60. package/src/Link/Link.doc.mjs +11 -0
  61. package/src/Link/Link.test.tsx +24 -0
  62. package/src/Link/Link.tsx +5 -0
  63. package/src/Markdown/Markdown.spec.md +159 -43
  64. package/src/Markdown/Markdown.test.tsx +11 -0
  65. package/src/Markdown/Markdown.tsx +106 -96
  66. package/src/Markdown/ast.test.ts +169 -0
  67. package/src/Markdown/ast.ts +231 -0
  68. package/src/Markdown/incremental.test.ts +12 -0
  69. package/src/Markdown/parser.ts +427 -118
  70. package/src/Outline/Outline.spec.md +1 -1
  71. package/src/Outline/modules/parseOutlineFromMarkdown.spec.md +142 -0
  72. package/src/Outline/parseOutlineFromMarkdown.ts +8 -13
  73. package/src/PowerSearch/PowerSearchEditPopover.test.tsx +150 -1
  74. package/src/PowerSearch/PowerSearchEditPopover.tsx +51 -28
  75. package/src/RadioList/RadioList.doc.mjs +11 -0
  76. package/src/RadioList/RadioList.test.tsx +32 -0
  77. package/src/RadioList/RadioListItem.tsx +25 -1
  78. package/src/SegmentedControl/SegmentedControl.doc.mjs +2 -2
  79. package/src/SegmentedControl/SegmentedControl.test.tsx +31 -0
  80. package/src/SegmentedControl/SegmentedControlItem.tsx +6 -9
  81. package/src/SideNav/SideNav.doc.mjs +1 -1
  82. package/src/SideNav/SideNav.test.tsx +10 -0
  83. package/src/SideNav/SideNav.tsx +14 -2
  84. package/src/Slider/Slider.doc.mjs +11 -0
  85. package/src/Slider/Slider.test.tsx +128 -0
  86. package/src/Slider/Slider.tsx +25 -7
  87. package/src/Switch/Switch.doc.mjs +11 -0
  88. package/src/Switch/Switch.test.tsx +16 -0
  89. package/src/Switch/Switch.tsx +28 -0
  90. package/src/TabList/Tab.tsx +35 -7
  91. package/src/TabList/TabList.doc.mjs +11 -0
  92. package/src/TabList/TabList.test.tsx +66 -0
  93. package/src/TabList/__tests__/Tabs.a11y.known-failures.ts +1 -34
  94. package/src/ToggleButton/ToggleButton.test.tsx +133 -0
  95. package/src/ToggleButton/ToggleButton.tsx +9 -2
  96. package/src/ToggleButton/__tests__/ToggleButton.a11y.chromium.spec.ts +209 -0
  97. package/src/Tokenizer/Tokenizer.spec.md +142 -75
  98. package/src/Typeahead/BaseTypeahead.spec.md +4 -3
  99. package/src/Typeahead/BaseTypeahead.tsx +15 -6
  100. package/src/Typeahead/Typeahead.test.tsx +53 -0
  101. package/src/__tests__/PressedState.a11y.chromium.spec.ts +813 -0
  102. package/src/__tests__/pressState.ts +93 -0
  103. package/src/utils/interactionOverlay.stylex.ts +20 -0
@@ -0,0 +1,93 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file pressState.ts
5
+ * @input Uses document.styleSheets (populated by StyleX runtime injection)
6
+ * @output Exports rulesDeclaredFor and expectPressedArm test helpers
7
+ * @position Shared test helper for asserting a control paints a pressed state
8
+ *
9
+ * jsdom does not compute `:active` (there is no real pointer), so a component
10
+ * test asserts the next-best thing: that the StyleX dev runtime injected a
11
+ * rule, keyed to the element's own classes, that paints the design system's
12
+ * pressed overlay token while the control is pressed. The selector shape is
13
+ * deliberately not pinned — a press may be read off the element itself
14
+ * (`.x:active`) or off an ancestor scope marker (`.x:where(.marker:active *)`).
15
+ *
16
+ * SYNC: When modified, update this header.
17
+ */
18
+
19
+ const PRESSED_TOKEN = '--color-overlay-pressed';
20
+
21
+ function walk(list: CSSRuleList, visit: (rule: CSSRule) => void): void {
22
+ for (const rule of Array.from(list)) {
23
+ visit(rule);
24
+ const nested = (rule as CSSGroupingRule).cssRules;
25
+ if (nested != null) {
26
+ walk(nested, visit);
27
+ }
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Every injected style rule (rules nested in `@media` included) whose selector
33
+ * names one of the element's classes, as `selector {declarations}` text.
34
+ */
35
+ export function rulesDeclaredFor(el: Element): string[] {
36
+ const classes = el.className
37
+ .split(/\s+/)
38
+ .filter(Boolean)
39
+ .map(name => `.${name}`);
40
+ const out: string[] = [];
41
+ for (const sheet of Array.from(document.styleSheets)) {
42
+ let rules: CSSRuleList;
43
+ try {
44
+ rules = sheet.cssRules;
45
+ } catch {
46
+ continue;
47
+ }
48
+ walk(rules, rule => {
49
+ if (!(rule instanceof CSSStyleRule)) {
50
+ return;
51
+ }
52
+ const selector = rule.selectorText;
53
+ if (classes.some(cls => selector.startsWith(cls))) {
54
+ out.push(`${selector} {${rule.style.cssText}}`);
55
+ }
56
+ });
57
+ }
58
+ return out;
59
+ }
60
+
61
+ /** The rules on `el` whose selector matches `pseudo` (e.g. `:active`). */
62
+ export function rulesWithSelector(el: Element, pseudo: string): string[] {
63
+ return rulesDeclaredFor(el).filter(rule => {
64
+ const selector = rule.slice(0, rule.indexOf('{'));
65
+ return selector.includes(pseudo);
66
+ });
67
+ }
68
+
69
+ /**
70
+ * Does one of the element's own rules paint the pressed overlay token while
71
+ * `pseudo` matches? `pseudo` defaults to `:active`, the arm a mouse press
72
+ * takes.
73
+ */
74
+ export function hasPressedArm(el: Element, pseudo = ':active'): boolean {
75
+ return rulesWithSelector(el, pseudo).some(rule =>
76
+ rule.includes(PRESSED_TOKEN),
77
+ );
78
+ }
79
+
80
+ /**
81
+ * Does one of the element's own classes paint the pressed overlay token
82
+ * unconditionally — no pseudo-class, no ancestor scope — because the component
83
+ * applies the class while it holds the press itself (a dragged slider thumb)?
84
+ * StyleX's specificity padding (`:not(#\#)`) is not a condition.
85
+ */
86
+ export function declaresPressedOverlay(el: Element): boolean {
87
+ return rulesDeclaredFor(el).some(rule => {
88
+ const selector = rule
89
+ .slice(0, rule.indexOf('{'))
90
+ .replaceAll(':not(#\\#)', '');
91
+ return !selector.includes(':') && rule.includes(PRESSED_TOKEN);
92
+ });
93
+ }
@@ -10,6 +10,11 @@
10
10
  * @output Exports reusable background-color and background-image state styles
11
11
  * @position Internal styling utility for interactive core surfaces
12
12
  *
13
+ * Every surface that paints a press composes one of these (or carries its own
14
+ * `:active` rule), so a change to how the system answers a press is made here
15
+ * once. `pressedBackgroundColor` is the press without the hover, for controls
16
+ * whose hover is a colour or nothing.
17
+ *
13
18
  * Keep the enabled guard outside the individual states. StyleX assigns an
14
19
  * extra priority bucket (and generated selector specificity) to media-nested
15
20
  * rules. Repeating `:active` inside the hover-capable branch gives hover and
@@ -71,4 +76,19 @@ export const interactionOverlayStyles = stylex.create({
71
76
  },
72
77
  },
73
78
  },
79
+ /**
80
+ * The pressed arm alone, for a control whose hover answer is its own — a
81
+ * text link changes colour, a disclosure row has none — so a press paints
82
+ * the system's pressed overlay without adding a hover surface the control
83
+ * never had. Same enabled guard as the paired states above.
84
+ */
85
+ pressedBackgroundColor: {
86
+ backgroundColor: {
87
+ default: null,
88
+ [ENABLED]: {
89
+ default: null,
90
+ ':active': colorVars['--color-overlay-pressed'],
91
+ },
92
+ },
93
+ },
74
94
  });