@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.
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +12 -2
- package/dist/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.js +6 -1
- package/dist/Kbd/Kbd.d.ts +5 -3
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +36 -42
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +6 -2
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +63 -59
- package/dist/Markdown/ast.d.ts +124 -0
- package/dist/Markdown/ast.d.ts.map +1 -0
- package/dist/Markdown/ast.js +38 -0
- package/dist/Markdown/parser.d.ts +14 -8
- package/dist/Markdown/parser.d.ts.map +1 -1
- package/dist/Markdown/parser.js +352 -97
- package/dist/Outline/parseOutlineFromMarkdown.d.ts.map +1 -1
- package/dist/Outline/parseOutlineFromMarkdown.js +7 -7
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +46 -30
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +13 -1
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +5 -5
- package/dist/SideNav/SideNav.d.ts +2 -1
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +9 -3
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +14 -8
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +11 -0
- package/dist/TabList/Tab.d.ts +1 -1
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +20 -7
- package/dist/ToggleButton/ToggleButton.d.ts +2 -1
- package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton/ToggleButton.js +7 -1
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +15 -6
- package/dist/astryx.css +8 -0
- package/dist/utils/interactionOverlay.stylex.d.ts +8 -0
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +9 -0
- package/package.json +3 -3
- package/src/Button/__tests__/Button.a11y.chromium.spec.ts +17 -1
- package/src/Button/__tests__/Button.a11y.known-failures.ts +0 -29
- package/src/Button/__tests__/Button.a11y.renders.tsx +9 -2
- package/src/Button/__tests__/Button.a11y.states.ts +9 -0
- package/src/CheckboxInput/CheckboxInput.doc.mjs +11 -0
- package/src/CheckboxInput/CheckboxInput.test.tsx +34 -0
- package/src/CheckboxInput/CheckboxInput.tsx +21 -1
- package/src/ClickableCard/ClickableCard.test.tsx +102 -5
- package/src/Collapsible/Collapsible.doc.mjs +11 -0
- package/src/Collapsible/Collapsible.test.tsx +21 -0
- package/src/Collapsible/Collapsible.tsx +5 -0
- package/src/Kbd/Kbd.doc.mjs +3 -3
- package/src/Kbd/Kbd.test.tsx +57 -1
- package/src/Kbd/Kbd.tsx +57 -37
- package/src/Link/Link.doc.mjs +11 -0
- package/src/Link/Link.test.tsx +24 -0
- package/src/Link/Link.tsx +5 -0
- package/src/Markdown/Markdown.spec.md +159 -43
- package/src/Markdown/Markdown.test.tsx +11 -0
- package/src/Markdown/Markdown.tsx +106 -96
- package/src/Markdown/ast.test.ts +169 -0
- package/src/Markdown/ast.ts +231 -0
- package/src/Markdown/incremental.test.ts +12 -0
- package/src/Markdown/parser.ts +427 -118
- package/src/Outline/Outline.spec.md +1 -1
- package/src/Outline/modules/parseOutlineFromMarkdown.spec.md +142 -0
- package/src/Outline/parseOutlineFromMarkdown.ts +8 -13
- package/src/PowerSearch/PowerSearchEditPopover.test.tsx +150 -1
- package/src/PowerSearch/PowerSearchEditPopover.tsx +51 -28
- package/src/RadioList/RadioList.doc.mjs +11 -0
- package/src/RadioList/RadioList.test.tsx +32 -0
- package/src/RadioList/RadioListItem.tsx +25 -1
- package/src/SegmentedControl/SegmentedControl.doc.mjs +2 -2
- package/src/SegmentedControl/SegmentedControl.test.tsx +31 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +6 -9
- package/src/SideNav/SideNav.doc.mjs +1 -1
- package/src/SideNav/SideNav.test.tsx +10 -0
- package/src/SideNav/SideNav.tsx +14 -2
- package/src/Slider/Slider.doc.mjs +11 -0
- package/src/Slider/Slider.test.tsx +128 -0
- package/src/Slider/Slider.tsx +25 -7
- package/src/Switch/Switch.doc.mjs +11 -0
- package/src/Switch/Switch.test.tsx +16 -0
- package/src/Switch/Switch.tsx +28 -0
- package/src/TabList/Tab.tsx +35 -7
- package/src/TabList/TabList.doc.mjs +11 -0
- package/src/TabList/TabList.test.tsx +66 -0
- package/src/TabList/__tests__/Tabs.a11y.known-failures.ts +1 -34
- package/src/ToggleButton/ToggleButton.test.tsx +133 -0
- package/src/ToggleButton/ToggleButton.tsx +9 -2
- package/src/ToggleButton/__tests__/ToggleButton.a11y.chromium.spec.ts +209 -0
- package/src/Tokenizer/Tokenizer.spec.md +142 -75
- package/src/Typeahead/BaseTypeahead.spec.md +4 -3
- package/src/Typeahead/BaseTypeahead.tsx +15 -6
- package/src/Typeahead/Typeahead.test.tsx +53 -0
- package/src/__tests__/PressedState.a11y.chromium.spec.ts +813 -0
- package/src/__tests__/pressState.ts +93 -0
- 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
|
});
|