@ngbracket/a11y-devtools 0.16.0 → 0.18.0
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 +68 -0
- package/README.md +7 -11
- package/bin/ngbr-a11y-report.mjs +6 -1
- package/dist/inpage.global.js +244 -7
- package/dist/inpage.js +3 -0
- package/dist/keyboard/accname.d.ts +5 -0
- package/dist/keyboard/accname.js +28 -7
- package/dist/keyboard/drag-drop.d.ts +45 -0
- package/dist/keyboard/drag-drop.js +95 -0
- package/dist/keyboard/focus-walk.js +4 -1
- package/dist/keyboard/keyboard-scan.js +69 -2
- package/dist/keyboard/tab-sequence.d.ts +2 -2
- package/dist/keyboard/tab-sequence.js +38 -7
- package/dist/keyboard/walkthrough.d.ts +29 -0
- package/dist/keyboard/walkthrough.js +29 -0
- package/dist/overlay.d.ts +6 -1
- package/dist/overlay.js +1 -1
- package/dist/pill-menu.d.ts +9 -0
- package/dist/pill-menu.js +42 -5
- package/dist/provider.d.ts +2 -1
- package/dist/provider.js +32 -4
- package/dist/report/acr.js +1 -0
- package/dist/report/format.d.ts +14 -0
- package/dist/report/format.js +48 -0
- package/dist/report/headless.d.ts +10 -1
- package/dist/report/headless.js +17 -4
- package/dist/report/html.d.ts +1 -1
- package/dist/report/html.js +26 -1
- package/dist/report/index.d.ts +2 -1
- package/dist/report/index.js +1 -1
- package/dist/runner.d.ts +2 -1
- package/dist/settings.d.ts +14 -2
- package/dist/settings.js +29 -3
- package/dist/toggle.d.ts +10 -2
- package/dist/toggle.js +48 -3
- package/package.json +5 -1
package/dist/report/format.js
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
/** One-line explanation for a dark-only page, shared by the Markdown and HTML reports. */
|
|
2
2
|
export const DARK_ONLY_NOTE = 'Dark mode: lists only issues that don’t also appear in light mode on this route.';
|
|
3
|
+
/**
|
|
4
|
+
* Heading note for the walkthrough, shared by the Markdown and HTML reports. Same
|
|
5
|
+
* honesty rule as the overlay's Focus preview: computed, not a screen reader.
|
|
6
|
+
*/
|
|
7
|
+
export const WALKTHROUGH_NOTE = 'Each tab stop in order, with its computed role, name and states. A computed approximation, ' +
|
|
8
|
+
'not what any one screen reader announces.';
|
|
9
|
+
/** One walkthrough step as a single line, e.g. `button "Save" (disabled) — SaveBarComponent`. */
|
|
10
|
+
export function formatStep(step) {
|
|
11
|
+
const role = step.role ?? `<${step.tag}>`;
|
|
12
|
+
const name = step.name ? `"${step.name}"` : '(no accessible name)';
|
|
13
|
+
const states = step.states.length ? ` (${step.states.join(', ')})` : '';
|
|
14
|
+
const tabindex = step.positive ? ' [positive tabindex]' : '';
|
|
15
|
+
const component = step.component ? ` — ${step.component}` : '';
|
|
16
|
+
return `${role} ${name}${states}${tabindex}${component}`;
|
|
17
|
+
}
|
|
18
|
+
/** "Showing the first 300 of 412 tab stops." when the list was capped, else ''. */
|
|
19
|
+
export function walkthroughCapNote(walkthrough) {
|
|
20
|
+
return walkthrough.total > walkthrough.steps.length
|
|
21
|
+
? `Showing the first ${walkthrough.steps.length} of ${walkthrough.total} tab stops.`
|
|
22
|
+
: '';
|
|
23
|
+
}
|
|
3
24
|
/**
|
|
4
25
|
* Report title, shared by every format. Says "automated scan" on purpose: a file
|
|
5
26
|
* titled "Accessibility report" is easy to hand to procurement as if it were a
|
|
@@ -83,6 +104,7 @@ export function toJson(report, diff) {
|
|
|
83
104
|
distinctRules: distinctRuleCount(p.findings),
|
|
84
105
|
nodeInstances: p.findings.length,
|
|
85
106
|
findings: p.findings,
|
|
107
|
+
...(p.walkthrough && { walkthrough: p.walkthrough }),
|
|
86
108
|
})),
|
|
87
109
|
}, null, 2);
|
|
88
110
|
}
|
|
@@ -117,9 +139,13 @@ export function parseReport(json) {
|
|
|
117
139
|
...(p.error !== undefined && { error: p.error }),
|
|
118
140
|
...(p.colorScheme && { colorScheme: p.colorScheme }),
|
|
119
141
|
...(p.darkOnly && { darkOnly: true }),
|
|
142
|
+
...(isWalkthrough(p.walkthrough) && { walkthrough: p.walkthrough }),
|
|
120
143
|
})),
|
|
121
144
|
};
|
|
122
145
|
}
|
|
146
|
+
function isWalkthrough(w) {
|
|
147
|
+
return Array.isArray(w?.steps) && typeof w.total === 'number';
|
|
148
|
+
}
|
|
123
149
|
/** UI primitives and directives a finding came through, for a "via …" note. */
|
|
124
150
|
export function viaNames(finding) {
|
|
125
151
|
// e.g. an `<button nbButton>` shows as "via NbButtonComponent" under its app owner.
|
|
@@ -186,6 +212,7 @@ export function toMarkdown(report, diff) {
|
|
|
186
212
|
if (page.findings.length === 0) {
|
|
187
213
|
lines.push('No automated violations found. ✅');
|
|
188
214
|
lines.push('');
|
|
215
|
+
lines.push(...markdownWalkthrough(page));
|
|
189
216
|
continue;
|
|
190
217
|
}
|
|
191
218
|
lines.push(`${page.findings.length} node-instance(s) across ${distinctRuleCount(page.findings)} distinct rule(s).`);
|
|
@@ -204,6 +231,27 @@ export function toMarkdown(report, diff) {
|
|
|
204
231
|
}
|
|
205
232
|
lines.push('');
|
|
206
233
|
}
|
|
234
|
+
lines.push(...markdownWalkthrough(page));
|
|
207
235
|
}
|
|
208
236
|
return lines.join('\n');
|
|
209
237
|
}
|
|
238
|
+
/** A page's walkthrough as a numbered Markdown list under its own heading, or nothing. */
|
|
239
|
+
function markdownWalkthrough(page) {
|
|
240
|
+
const walkthrough = page.walkthrough;
|
|
241
|
+
if (!walkthrough)
|
|
242
|
+
return [];
|
|
243
|
+
const lines = ['### Tab order walkthrough', '', `_${WALKTHROUGH_NOTE}_`, ''];
|
|
244
|
+
if (walkthrough.steps.length === 0) {
|
|
245
|
+
lines.push('No tab stops on this page.', '');
|
|
246
|
+
return lines;
|
|
247
|
+
}
|
|
248
|
+
const cap = walkthroughCapNote(walkthrough);
|
|
249
|
+
if (cap)
|
|
250
|
+
lines.push(cap, '');
|
|
251
|
+
// Names are page text: escape anything Markdown would read as markup.
|
|
252
|
+
for (const step of walkthrough.steps) {
|
|
253
|
+
lines.push(`${step.order}. ${formatStep(step).replace(/([<>*_`[\]\\|&])/g, '\\$1')}`);
|
|
254
|
+
}
|
|
255
|
+
lines.push('');
|
|
256
|
+
return lines;
|
|
257
|
+
}
|
|
@@ -68,7 +68,8 @@ export interface ScanPagesOptions {
|
|
|
68
68
|
/**
|
|
69
69
|
* Also run the keyboard layer in-page — heuristic `ngbr/*` findings for
|
|
70
70
|
* keyboard-unreachable controls, click-without-keyboard handlers, hover-only
|
|
71
|
-
* content, and tab-order mismatches (the
|
|
71
|
+
* content, drag and drop with no keyboard way, and tab-order mismatches (the
|
|
72
|
+
* last needs real layout, which headless has).
|
|
72
73
|
* Default false.
|
|
73
74
|
*/
|
|
74
75
|
keyboard?: boolean;
|
|
@@ -80,6 +81,14 @@ export interface ScanPagesOptions {
|
|
|
80
81
|
* modal is containment, not a trap, and isn't reported. Default false.
|
|
81
82
|
*/
|
|
82
83
|
focusTraps?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Also list each route's tab order with every stop's computed role, name,
|
|
86
|
+
* states and owning component: a reading list for checking the keyboard and
|
|
87
|
+
* screen-reader path without opening the app. A computed approximation, not
|
|
88
|
+
* what any one screen reader says. With `colorScheme: 'both'` it runs on the
|
|
89
|
+
* light pass only. Default false.
|
|
90
|
+
*/
|
|
91
|
+
walkthrough?: boolean;
|
|
83
92
|
}
|
|
84
93
|
/**
|
|
85
94
|
* Drive a real headless browser over a running Angular **dev** build and return
|
package/dist/report/headless.js
CHANGED
|
@@ -108,6 +108,17 @@ async function scanPass(browser, colorScheme, config) {
|
|
|
108
108
|
const w = window;
|
|
109
109
|
return w.__ngbA11yScan(args.axe, args.scan);
|
|
110
110
|
}, { axe: axeOptions, scan: { frameworkPrefixes, keyboard: config.keyboard } }));
|
|
111
|
+
// Before the trap walk: pressing Tab can change the page.
|
|
112
|
+
let walkthrough;
|
|
113
|
+
if (config.walkthrough) {
|
|
114
|
+
try {
|
|
115
|
+
walkthrough = await page.evaluate((prefixes) => window.__ngbA11yWalkthrough(prefixes), frameworkPrefixes);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
119
|
+
console.warn(`ngbr-a11y-report: walkthrough failed on ${label}: ${message}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
111
122
|
if (config.focusTraps) {
|
|
112
123
|
// A failed walk shouldn't throw away the scan's findings — warn and move on.
|
|
113
124
|
try {
|
|
@@ -120,7 +131,7 @@ async function scanPass(browser, colorScheme, config) {
|
|
|
120
131
|
console.warn(`ngbr-a11y-report: focus-trap walk failed on ${label}: ${message}`);
|
|
121
132
|
}
|
|
122
133
|
}
|
|
123
|
-
pages.push({ label, url: page.url(), findings, colorScheme });
|
|
134
|
+
pages.push({ label, url: page.url(), findings, colorScheme, ...(walkthrough && { walkthrough }) });
|
|
124
135
|
}
|
|
125
136
|
catch (err) {
|
|
126
137
|
// One bad route shouldn't sink the whole run — record it and continue.
|
|
@@ -141,7 +152,7 @@ async function scanPass(browser, colorScheme, config) {
|
|
|
141
152
|
* to the component that rendered it — with no change to the target app.
|
|
142
153
|
*/
|
|
143
154
|
export async function scanPages(options) {
|
|
144
|
-
const { baseUrl, routes, tags, waitMs = 1500, labels = {}, setup, beforeScan, headed = false, frameworkPrefixes, keyboard, focusTraps = false, darkClass, darkAttribute, } = options;
|
|
155
|
+
const { baseUrl, routes, tags, waitMs = 1500, labels = {}, setup, beforeScan, headed = false, frameworkPrefixes, keyboard, focusTraps = false, walkthrough = false, darkClass, darkAttribute, } = options;
|
|
145
156
|
const colorScheme = options.colorScheme ?? (darkClass || darkAttribute ? 'both' : 'light');
|
|
146
157
|
const config = {
|
|
147
158
|
baseUrl,
|
|
@@ -153,6 +164,7 @@ export async function scanPages(options) {
|
|
|
153
164
|
frameworkPrefixes,
|
|
154
165
|
keyboard,
|
|
155
166
|
focusTraps,
|
|
167
|
+
walkthrough,
|
|
156
168
|
setup,
|
|
157
169
|
beforeScan,
|
|
158
170
|
darkClass,
|
|
@@ -167,8 +179,8 @@ export async function scanPages(options) {
|
|
|
167
179
|
}
|
|
168
180
|
else {
|
|
169
181
|
const light = await scanPass(browser, 'light', config);
|
|
170
|
-
//
|
|
171
|
-
const dark = await scanPass(browser, 'dark', { ...config, focusTraps: false });
|
|
182
|
+
// Keyboard traps and the tab order don't depend on the theme; doing them twice only costs time.
|
|
183
|
+
const dark = await scanPass(browser, 'dark', { ...config, focusTraps: false, walkthrough: false });
|
|
172
184
|
// Interleave per route (light, then its dark) and keep only what dark adds.
|
|
173
185
|
pages = light.flatMap((lightPage, i) => {
|
|
174
186
|
const darkPage = dark[i];
|
|
@@ -187,6 +199,7 @@ export async function scanPages(options) {
|
|
|
187
199
|
...(tags && { tags }),
|
|
188
200
|
keyboard: keyboard ?? false,
|
|
189
201
|
focusTraps,
|
|
202
|
+
...(walkthrough && { walkthrough }),
|
|
190
203
|
};
|
|
191
204
|
return { generatedAt: new Date().toISOString(), checks, pages };
|
|
192
205
|
}
|
package/dist/report/html.d.ts
CHANGED
|
@@ -17,6 +17,6 @@ import { type ScanReport } from './format.js';
|
|
|
17
17
|
export declare function escapeHtml(text: string): string;
|
|
18
18
|
/** Only http(s) links are rendered as links; anything else stays plain text. */
|
|
19
19
|
export declare function safeHref(url: string): string | null;
|
|
20
|
-
export declare const STYLES = "\n:root {\n color-scheme: light dark;\n --bg: #ffffff; --fg: #1a1a1a; --muted: #555555; --line: #d9d9d9; --panel: #f6f6f6;\n --critical: #a4001d; --serious: #9a4400; --moderate: #6b5300; --minor: #1f4e9c;\n --new: #0b6b3a; --link: #0b57d0;\n}\n@media (prefers-color-scheme: dark) {\n :root {\n --bg: #161616; --fg: #ececec; --muted: #b5b5b5; --line: #3a3a3a; --panel: #222222;\n --critical: #ff8a9a; --serious: #ffb77a; --moderate: #f0d060; --minor: #9cc3ff;\n --new: #7ee0a8; --link: #9cc3ff;\n }\n}\n* { box-sizing: border-box; }\nbody { margin: 0; background: var(--bg); color: var(--fg);\n font: 15px/1.55 system-ui, -apple-system, \"Segoe UI\", sans-serif; }\nmain { max-width: 960px; margin: 0 auto; padding: 32px 16px 64px; }\nh1 { font-size: 1.6rem; margin: 0 0 4px; }\nh2 { font-size: 1.25rem; margin: 40px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); }\nh3 { font-size: 1.05rem; margin: 0 0 4px; }\n.meta { color: var(--muted); margin: 0 0 12px; }\n.scope { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;\n margin: 0 0 24px; padding: 10px 14px; }\na { color: var(--link); }\ncode { font: 0.9em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }\ntable { border-collapse: collapse; width: 100%; margin: 8px 0 16px; }\nth, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }\nth[scope=\"col\"]:not(:first-child), td:not(:first-child) { text-align: right; }\ntfoot th, tfoot td { font-weight: 700; }\n.table-wrap { overflow-x: auto; }\n.component { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;\n margin: 12px 0; padding: 12px 14px 0; }\n.count { color: var(--muted); font-weight: 400; }\na:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }\n.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;\n overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }\nul.findings { list-style: none; margin: 0 0 12px; padding: 0; }\nul.findings > li { padding: 10px 0; border-top: 1px solid var(--line); }\n.impact { font-weight: 700; text-transform: uppercase; font-size: 0.8em; letter-spacing: 0.04em; }\n.impact-critical { color: var(--critical); } .impact-serious { color: var(--serious); }\n.impact-moderate { color: var(--moderate); } .impact-minor { color: var(--minor); }\n.new { font-weight: 700; color: var(--new); }\n.rule { font-weight: 600; }\n.via, .detail { color: var(--muted); font-size: 0.92em; }\n.detail { margin: 4px 0 0; }\n.ok { color: var(--new); font-weight: 600; }\n.error { color: var(--critical); font-weight: 600; }\n.diff { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;\n margin-top: 32px; padding: 4px 16px; }\n.diff h2 { border-top: 0; margin-top: 12px; padding-top: 0; }\n";
|
|
20
|
+
export declare const STYLES = "\n:root {\n color-scheme: light dark;\n --bg: #ffffff; --fg: #1a1a1a; --muted: #555555; --line: #d9d9d9; --panel: #f6f6f6;\n --critical: #a4001d; --serious: #9a4400; --moderate: #6b5300; --minor: #1f4e9c;\n --new: #0b6b3a; --link: #0b57d0;\n}\n@media (prefers-color-scheme: dark) {\n :root {\n --bg: #161616; --fg: #ececec; --muted: #b5b5b5; --line: #3a3a3a; --panel: #222222;\n --critical: #ff8a9a; --serious: #ffb77a; --moderate: #f0d060; --minor: #9cc3ff;\n --new: #7ee0a8; --link: #9cc3ff;\n }\n}\n* { box-sizing: border-box; }\nbody { margin: 0; background: var(--bg); color: var(--fg);\n font: 15px/1.55 system-ui, -apple-system, \"Segoe UI\", sans-serif; }\nmain { max-width: 960px; margin: 0 auto; padding: 32px 16px 64px; }\nh1 { font-size: 1.6rem; margin: 0 0 4px; }\nh2 { font-size: 1.25rem; margin: 40px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); }\nh3 { font-size: 1.05rem; margin: 0 0 4px; }\n.meta { color: var(--muted); margin: 0 0 12px; }\n.scope { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;\n margin: 0 0 24px; padding: 10px 14px; }\na { color: var(--link); }\ncode { font: 0.9em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }\ntable { border-collapse: collapse; width: 100%; margin: 8px 0 16px; }\nth, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }\nth[scope=\"col\"]:not(:first-child), td:not(:first-child) { text-align: right; }\ntfoot th, tfoot td { font-weight: 700; }\n.table-wrap { overflow-x: auto; }\n.component { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;\n margin: 12px 0; padding: 12px 14px 0; }\n.count { color: var(--muted); font-weight: 400; }\na:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }\n.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;\n overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }\nul.findings { list-style: none; margin: 0 0 12px; padding: 0; }\nul.findings > li { padding: 10px 0; border-top: 1px solid var(--line); }\n.impact { font-weight: 700; text-transform: uppercase; font-size: 0.8em; letter-spacing: 0.04em; }\n.impact-critical { color: var(--critical); } .impact-serious { color: var(--serious); }\n.impact-moderate { color: var(--moderate); } .impact-minor { color: var(--minor); }\n.new { font-weight: 700; color: var(--new); }\n.rule { font-weight: 600; }\n.via, .detail { color: var(--muted); font-size: 0.92em; }\n.detail { margin: 4px 0 0; }\n.ok { color: var(--new); font-weight: 600; }\n.error { color: var(--critical); font-weight: 600; }\n.diff { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;\n margin-top: 32px; padding: 4px 16px; }\n.diff h2 { border-top: 0; margin-top: 12px; padding-top: 0; }\n.walkthrough { margin: 20px 0 0; }\n.walkthrough ol { margin: 8px 0 0; padding-left: 2.5em; }\n.walkthrough li { padding: 2px 0; overflow-wrap: anywhere; }\n";
|
|
21
21
|
/** Render the report as one self-contained, accessible HTML document. */
|
|
22
22
|
export declare function toHtml(report: ScanReport, diff?: BaselineDiff): string;
|
package/dist/report/html.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addedBySeverity, COVERAGE_URL, DARK_ONLY_NOTE, REPORT_SCOPE_NOTE, REPORT_TITLE, bySeverity, distinctRuleCount, groupByComponent, viaNames, } from './format.js';
|
|
1
|
+
import { addedBySeverity, COVERAGE_URL, DARK_ONLY_NOTE, formatStep, REPORT_SCOPE_NOTE, REPORT_TITLE, bySeverity, distinctRuleCount, groupByComponent, viaNames, walkthroughCapNote, WALKTHROUGH_NOTE, } from './format.js';
|
|
2
2
|
/**
|
|
3
3
|
* A single self-contained HTML report: inline CSS, no scripts, no external
|
|
4
4
|
* requests — so it can be attached to a CI run, emailed, or opened offline.
|
|
@@ -76,6 +76,9 @@ ul.findings > li { padding: 10px 0; border-top: 1px solid var(--line); }
|
|
|
76
76
|
.diff { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
|
|
77
77
|
margin-top: 32px; padding: 4px 16px; }
|
|
78
78
|
.diff h2 { border-top: 0; margin-top: 12px; padding-top: 0; }
|
|
79
|
+
.walkthrough { margin: 20px 0 0; }
|
|
80
|
+
.walkthrough ol { margin: 8px 0 0; padding-left: 2.5em; }
|
|
81
|
+
.walkthrough li { padding: 2px 0; overflow-wrap: anywhere; }
|
|
79
82
|
`;
|
|
80
83
|
/** Render the report as one self-contained, accessible HTML document. */
|
|
81
84
|
export function toHtml(report, diff) {
|
|
@@ -135,6 +138,7 @@ export function toHtml(report, diff) {
|
|
|
135
138
|
}
|
|
136
139
|
if (page.findings.length === 0) {
|
|
137
140
|
out.push('<p class="ok">No automated violations found.</p>');
|
|
141
|
+
out.push(...htmlWalkthrough(page));
|
|
138
142
|
out.push('</section>');
|
|
139
143
|
return;
|
|
140
144
|
}
|
|
@@ -162,6 +166,7 @@ export function toHtml(report, diff) {
|
|
|
162
166
|
out.push('</ul>');
|
|
163
167
|
out.push('</div>');
|
|
164
168
|
}
|
|
169
|
+
out.push(...htmlWalkthrough(page));
|
|
165
170
|
out.push('</section>');
|
|
166
171
|
});
|
|
167
172
|
out.push('</main>');
|
|
@@ -169,3 +174,23 @@ export function toHtml(report, diff) {
|
|
|
169
174
|
out.push('</html>');
|
|
170
175
|
return out.join('\n');
|
|
171
176
|
}
|
|
177
|
+
/** A page's walkthrough as an ordered list under its own heading, or nothing. */
|
|
178
|
+
function htmlWalkthrough(page) {
|
|
179
|
+
const walkthrough = page.walkthrough;
|
|
180
|
+
if (!walkthrough)
|
|
181
|
+
return [];
|
|
182
|
+
const out = ['<div class="walkthrough">', '<h3>Tab order walkthrough</h3>'];
|
|
183
|
+
out.push(`<p class="meta">${escapeHtml(WALKTHROUGH_NOTE)}</p>`);
|
|
184
|
+
if (walkthrough.steps.length === 0) {
|
|
185
|
+
out.push('<p>No tab stops on this page.</p>', '</div>');
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
188
|
+
const cap = walkthroughCapNote(walkthrough);
|
|
189
|
+
if (cap)
|
|
190
|
+
out.push(`<p>${escapeHtml(cap)}</p>`);
|
|
191
|
+
out.push('<ol>');
|
|
192
|
+
for (const step of walkthrough.steps)
|
|
193
|
+
out.push(`<li>${escapeHtml(formatStep(step))}</li>`);
|
|
194
|
+
out.push('</ol>', '</div>');
|
|
195
|
+
return out;
|
|
196
|
+
}
|
package/dist/report/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { axeVersion, scanPages, type ColorScheme, type ScanPagesOptions, type ThemeContext, } from './headless.js';
|
|
2
|
-
export { groupByComponent, distinctRuleCount, parseReport, toJson, toMarkdown, DARK_ONLY_NOTE, type PageReport, type ScanChecks, type ScanReport, } from './format.js';
|
|
2
|
+
export { groupByComponent, distinctRuleCount, parseReport, toJson, toMarkdown, DARK_ONLY_NOTE, formatStep, WALKTHROUGH_NOTE, type PageReport, type ScanChecks, type ScanReport, } from './format.js';
|
|
3
3
|
export { toHtml } from './html.js';
|
|
4
|
+
export type { Walkthrough, WalkthroughStep } from '../keyboard/walkthrough.js';
|
|
4
5
|
export { diffAgainstBaseline, findingKey, findingsNotIn, parseBaseline, type BaselineDiff, type BaselineReport, type NewFinding, } from './baseline.js';
|
|
5
6
|
export { isServing, startDevServer, type DevServer, type DevServerOptions } from './serve.js';
|
|
6
7
|
export { ACR_RESULT_LABELS, ACR_TITLE, buildAcrWorksheet, toAcrHtml, toAcrMarkdown, type AcrResult, type AcrRow, type AcrRuleEvidence, type AcrWorksheet, type AxeRuleMeta, } from './acr.js';
|
package/dist/report/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { axeVersion, scanPages, } from './headless.js';
|
|
2
|
-
export { groupByComponent, distinctRuleCount, parseReport, toJson, toMarkdown, DARK_ONLY_NOTE, } from './format.js';
|
|
2
|
+
export { groupByComponent, distinctRuleCount, parseReport, toJson, toMarkdown, DARK_ONLY_NOTE, formatStep, WALKTHROUGH_NOTE, } from './format.js';
|
|
3
3
|
export { toHtml } from './html.js';
|
|
4
4
|
export { diffAgainstBaseline, findingKey, findingsNotIn, parseBaseline, } from './baseline.js';
|
|
5
5
|
export { isServing, startDevServer } from './serve.js';
|
package/dist/runner.d.ts
CHANGED
|
@@ -23,7 +23,8 @@ export interface RunOptions {
|
|
|
23
23
|
/**
|
|
24
24
|
* Also run the keyboard layer — heuristic `ngbr/*` findings for
|
|
25
25
|
* keyboard-unreachable controls, click-without-keyboard handlers, hover-only
|
|
26
|
-
* content, and tab-order mismatches.
|
|
26
|
+
* content, drag and drop with no keyboard way, and tab-order mismatches.
|
|
27
|
+
* Default false.
|
|
27
28
|
*/
|
|
28
29
|
keyboard?: boolean;
|
|
29
30
|
}
|
package/dist/settings.d.ts
CHANGED
|
@@ -22,8 +22,20 @@ export declare const IMPACTS: readonly MinImpact[];
|
|
|
22
22
|
* everything is shown (`minor`).
|
|
23
23
|
*/
|
|
24
24
|
export declare function meetsMinImpact(impact: Impact, min: MinImpact): boolean;
|
|
25
|
-
/**
|
|
26
|
-
export declare
|
|
25
|
+
/** Component filter value for findings with no owning component. */
|
|
26
|
+
export declare const UNKNOWN_COMPONENT = "(unknown component)";
|
|
27
|
+
/**
|
|
28
|
+
* The findings to draw, given the severity filter and, optionally, one owning
|
|
29
|
+
* component (`UNKNOWN_COMPONENT` for unattributed findings).
|
|
30
|
+
*/
|
|
31
|
+
export declare function visibleFindings(findings: A11yFinding[], min: MinImpact, component?: string | null): A11yFinding[];
|
|
32
|
+
/** The most severe impact among `findings`, or null when there are none (or none has an impact). */
|
|
33
|
+
export declare function worstImpact(findings: A11yFinding[]): Impact;
|
|
34
|
+
/** Each owning component on the page with its issue count, most issues first. */
|
|
35
|
+
export declare function componentCounts(findings: A11yFinding[]): {
|
|
36
|
+
name: string;
|
|
37
|
+
count: number;
|
|
38
|
+
}[];
|
|
27
39
|
/**
|
|
28
40
|
* The effective settings: the app's defaults with the developer's remembered
|
|
29
41
|
* changes on top. Unknown or malformed stored values are ignored.
|
package/dist/settings.js
CHANGED
|
@@ -12,9 +12,35 @@ export function meetsMinImpact(impact, min) {
|
|
|
12
12
|
return min === 'minor';
|
|
13
13
|
return IMPACT_RANK[impact] >= IMPACT_RANK[min];
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
export
|
|
17
|
-
|
|
15
|
+
/** Component filter value for findings with no owning component. */
|
|
16
|
+
export const UNKNOWN_COMPONENT = '(unknown component)';
|
|
17
|
+
/**
|
|
18
|
+
* The findings to draw, given the severity filter and, optionally, one owning
|
|
19
|
+
* component (`UNKNOWN_COMPONENT` for unattributed findings).
|
|
20
|
+
*/
|
|
21
|
+
export function visibleFindings(findings, min, component) {
|
|
22
|
+
const bySeverity = min === 'minor' ? findings : findings.filter((f) => meetsMinImpact(f.impact, min));
|
|
23
|
+
return component ? bySeverity.filter((f) => (f.component ?? UNKNOWN_COMPONENT) === component) : bySeverity;
|
|
24
|
+
}
|
|
25
|
+
/** The most severe impact among `findings`, or null when there are none (or none has an impact). */
|
|
26
|
+
export function worstImpact(findings) {
|
|
27
|
+
let worst = null;
|
|
28
|
+
for (const f of findings) {
|
|
29
|
+
if (f.impact && (!worst || IMPACT_RANK[f.impact] > IMPACT_RANK[worst]))
|
|
30
|
+
worst = f.impact;
|
|
31
|
+
}
|
|
32
|
+
return worst;
|
|
33
|
+
}
|
|
34
|
+
/** Each owning component on the page with its issue count, most issues first. */
|
|
35
|
+
export function componentCounts(findings) {
|
|
36
|
+
const counts = new Map();
|
|
37
|
+
for (const f of findings) {
|
|
38
|
+
const name = f.component ?? UNKNOWN_COMPONENT;
|
|
39
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
40
|
+
}
|
|
41
|
+
return [...counts]
|
|
42
|
+
.map(([name, count]) => ({ name, count }))
|
|
43
|
+
.sort((a, b) => b.count - a.count || a.name.localeCompare(b.name));
|
|
18
44
|
}
|
|
19
45
|
/**
|
|
20
46
|
* The effective settings: the app's defaults with the developer's remembered
|
package/dist/toggle.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Impact } from './scan.js';
|
|
1
2
|
import { type PillMenuOptions, type PillMenuStatus } from './pill-menu.js';
|
|
2
3
|
/** Default keyboard shortcut that turns the devtools on/off. */
|
|
3
4
|
export declare const DEFAULT_TOGGLE_SHORTCUT = "Alt+Shift+A";
|
|
@@ -49,11 +50,18 @@ export interface TogglePillOptions {
|
|
|
49
50
|
/** Add the `⋯` settings menu next to the switch. */
|
|
50
51
|
menu?: Omit<PillMenuOptions, 'opensUp' | 'alignLeft'>;
|
|
51
52
|
}
|
|
53
|
+
/** What the pill and its menu show about the current page. */
|
|
54
|
+
export interface PillStatus extends PillMenuStatus {
|
|
55
|
+
/** Issues that pass the severity and component filters: the pill's count badge. */
|
|
56
|
+
matching?: number;
|
|
57
|
+
/** Most severe impact among those, which colours the badge. */
|
|
58
|
+
worst?: Impact;
|
|
59
|
+
}
|
|
52
60
|
export interface TogglePill {
|
|
53
61
|
/** Reflect a state change made elsewhere (e.g. the keyboard shortcut). */
|
|
54
62
|
setEnabled(enabled: boolean): void;
|
|
55
|
-
/** Update the menu's issue and page counts
|
|
56
|
-
setStatus(status:
|
|
63
|
+
/** Update the count badge and the menu's issue and page counts. */
|
|
64
|
+
setStatus(status: PillStatus): void;
|
|
57
65
|
destroy(): void;
|
|
58
66
|
}
|
|
59
67
|
/**
|
package/dist/toggle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OVERLAY_ATTR } from './overlay.js';
|
|
1
|
+
import { IMPACT_LABEL_FILL, OVERLAY_ATTR } from './overlay.js';
|
|
2
2
|
import { keepInTopLayer } from './top-layer.js';
|
|
3
3
|
import { createPillMenu } from './pill-menu.js';
|
|
4
4
|
/** Default keyboard shortcut that turns the devtools on/off. */
|
|
@@ -93,6 +93,9 @@ export function writeStoredEnabled(storage, enabled) {
|
|
|
93
93
|
}
|
|
94
94
|
const PILL_ON = '#3ecf8e';
|
|
95
95
|
const PILL_OFF = '#8a8f98';
|
|
96
|
+
/** Count badge fill when nothing matches: 5.3:1 with its white text. */
|
|
97
|
+
const BADGE_CLEAR_FILL = '#1f7a4d';
|
|
98
|
+
let nextBadgeId = 0;
|
|
96
99
|
/**
|
|
97
100
|
* A small on/off switch for the devtools, fixed to a corner of the page. A real
|
|
98
101
|
* `<button role="switch">` so it works by keyboard and screen reader: the
|
|
@@ -137,7 +140,44 @@ export function createTogglePill(options) {
|
|
|
137
140
|
const state = doc.createElement('span');
|
|
138
141
|
state.setAttribute('aria-hidden', 'true');
|
|
139
142
|
state.style.fontWeight = '400';
|
|
140
|
-
|
|
143
|
+
// Issue-count badge. Visible digits only; assistive tech gets the count in
|
|
144
|
+
// words as the switch's description.
|
|
145
|
+
const badge = doc.createElement('span');
|
|
146
|
+
badge.setAttribute('aria-hidden', 'true');
|
|
147
|
+
badge.hidden = true;
|
|
148
|
+
Object.assign(badge.style, {
|
|
149
|
+
minWidth: '18px',
|
|
150
|
+
padding: '2px 5px',
|
|
151
|
+
borderRadius: '999px',
|
|
152
|
+
color: '#ffffff',
|
|
153
|
+
font: '700 11px/1 ui-sans-serif, system-ui, sans-serif',
|
|
154
|
+
textAlign: 'center',
|
|
155
|
+
});
|
|
156
|
+
const badgeWords = doc.createElement('span');
|
|
157
|
+
badgeWords.id = `ngbr-a11y-count-${nextBadgeId++}`;
|
|
158
|
+
badgeWords.hidden = true; // still read as a description via aria-describedby
|
|
159
|
+
button.append(dot, name, state, badge, badgeWords);
|
|
160
|
+
let status;
|
|
161
|
+
function renderBadge() {
|
|
162
|
+
const matching = status?.matching;
|
|
163
|
+
if (!enabled || matching === undefined || !status) {
|
|
164
|
+
badge.hidden = true;
|
|
165
|
+
button.removeAttribute('aria-describedby');
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const { found } = status;
|
|
169
|
+
badge.hidden = false;
|
|
170
|
+
badge.textContent = String(matching);
|
|
171
|
+
badge.style.background = matching === 0 ? BADGE_CLEAR_FILL : IMPACT_LABEL_FILL[status.worst ?? 'none'];
|
|
172
|
+
const issues = (n) => `${n} ${n === 1 ? 'issue' : 'issues'}`;
|
|
173
|
+
badgeWords.textContent =
|
|
174
|
+
matching === found
|
|
175
|
+
? found === 0
|
|
176
|
+
? 'No issues on this page'
|
|
177
|
+
: `${issues(found)} on this page`
|
|
178
|
+
: `${issues(matching)} of ${found} on this page match the filters`;
|
|
179
|
+
button.setAttribute('aria-describedby', badgeWords.id);
|
|
180
|
+
}
|
|
141
181
|
// Inline styles can't do :focus-visible, so draw the ring from focus events,
|
|
142
182
|
// only when the browser would show one.
|
|
143
183
|
button.addEventListener('focus', () => {
|
|
@@ -157,6 +197,7 @@ export function createTogglePill(options) {
|
|
|
157
197
|
state.textContent = enabled ? 'on' : 'off';
|
|
158
198
|
button.style.opacity = enabled ? '1' : '0.75';
|
|
159
199
|
button.title = `a11y devtools ${enabled ? 'on' : 'off'}${keys ? ` (${keys})` : ''}`;
|
|
200
|
+
renderBadge();
|
|
160
201
|
}
|
|
161
202
|
setEnabled(enabled);
|
|
162
203
|
button.addEventListener('click', () => {
|
|
@@ -194,7 +235,11 @@ export function createTogglePill(options) {
|
|
|
194
235
|
const releaseTopLayer = keepInTopLayer(layer, { document: doc });
|
|
195
236
|
return {
|
|
196
237
|
setEnabled,
|
|
197
|
-
setStatus: (
|
|
238
|
+
setStatus: (next) => {
|
|
239
|
+
status = next;
|
|
240
|
+
renderBadge();
|
|
241
|
+
menu?.setStatus(next);
|
|
242
|
+
},
|
|
198
243
|
destroy: () => {
|
|
199
244
|
menu?.destroy();
|
|
200
245
|
releaseTopLayer();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngbracket/a11y-devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Finds accessibility problems in Angular apps and names the component behind each one. A dev overlay, or headless reports for CI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Duncan Faulkner",
|
|
@@ -74,12 +74,16 @@
|
|
|
74
74
|
"@analogjs/vite-plugin-angular": "^2.8.0",
|
|
75
75
|
"@analogjs/vitest-angular": "^2.8.0",
|
|
76
76
|
"@angular/build": "^22.2.1",
|
|
77
|
+
"@angular/cdk": "^22.2.1",
|
|
77
78
|
"@angular/common": "^22.2.1",
|
|
78
79
|
"@angular/compiler": "^22.2.1",
|
|
79
80
|
"@angular/compiler-cli": "^22.2.1",
|
|
80
81
|
"@angular/core": "^22.2.1",
|
|
82
|
+
"@angular/forms": "^22.2.1",
|
|
81
83
|
"@angular/platform-browser": "^22.2.1",
|
|
82
84
|
"@angular/platform-browser-dynamic": "^22.2.1",
|
|
85
|
+
"@emnapi/core": "^1.11.3",
|
|
86
|
+
"@emnapi/runtime": "^1.11.3",
|
|
83
87
|
"@oxc-project/runtime": "^0.149.0",
|
|
84
88
|
"@types/node": "^26.5.0",
|
|
85
89
|
"jsdom": "^30.0.1",
|