@ngbracket/a11y-devtools 0.17.0 → 0.18.1
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 +41 -0
- package/README.md +7 -11
- package/bin/ngbr-a11y-report.mjs +6 -1
- package/dist/inpage.global.js +149 -6
- package/dist/inpage.js +3 -0
- package/dist/keyboard/accname.d.ts +5 -0
- package/dist/keyboard/accname.js +28 -7
- package/dist/keyboard/keyboard-scan.js +30 -2
- 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.js +32 -4
- package/dist/report/format.d.ts +14 -0
- package/dist/report/format.js +48 -0
- package/dist/report/headless.d.ts +8 -0
- 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/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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
3
3
|
All notable changes to `@ngbracket/a11y-devtools` are documented here.
|
|
4
4
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## 0.18.1
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- `ngbr/unreachable-control` no longer reports the touch target in Angular
|
|
11
|
+
Material 15 to 21 checkboxes and radio buttons
|
|
12
|
+
(`.mat-mdc-checkbox-touch-target`, `.mat-mdc-radio-touch-target`). The
|
|
13
|
+
target is an empty element with a click handler that toggles the native
|
|
14
|
+
input beside it, and Tab reaches that input. The rule now skips an empty
|
|
15
|
+
element with a click listener and no role when its parent holds a checkbox
|
|
16
|
+
or radio input. The same element beside a text field or a button is still
|
|
17
|
+
reported. Material 22 removed the handler, so apps on 22 were not affected.
|
|
18
|
+
|
|
19
|
+
## 0.18.0
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- Report mode can list each route's tab order (`--walkthrough`, or
|
|
24
|
+
`walkthrough: true` in `scanPages`). Every tab stop gets a line with its
|
|
25
|
+
computed role, accessible name, states and owning component, for example
|
|
26
|
+
`button "Save" (disabled) — SaveBarComponent`. A stop with no name reads
|
|
27
|
+
`(no accessible name)`, and a positive `tabindex` is flagged. The list is in
|
|
28
|
+
the JSON, Markdown and HTML reports, under a note that it is a computed
|
|
29
|
+
approximation and not the output of any one screen reader. With
|
|
30
|
+
`--color-scheme both` it runs on the light pass only. It stops at 300 stops
|
|
31
|
+
per page; the report gives the real total when it is cut short.
|
|
32
|
+
- The pill shows a count badge: the issues on the page that pass the menu's
|
|
33
|
+
filters, coloured by the most severe of them (green at 0). The switch gets the
|
|
34
|
+
count in words as its description, for example "5 issues of 14 on this page
|
|
35
|
+
match the filters".
|
|
36
|
+
- The pill menu has a **Show component** filter that lists the components with
|
|
37
|
+
issues on the current page, each with its count at the chosen severity.
|
|
38
|
+
Choosing one draws only that component's highlights and updates the badge.
|
|
39
|
+
The choice isn't saved, and it goes back to all components when the path
|
|
40
|
+
changes. A query-string change (`?page=2`) keeps it.
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
|
|
44
|
+
- The keyboard-layer screenshot in the README is new: the demo's Keyboard
|
|
45
|
+
section with the severity filter at "Serious and above".
|
|
46
|
+
|
|
6
47
|
## 0.17.0
|
|
7
48
|
|
|
8
49
|
### Added
|
package/README.md
CHANGED
|
@@ -60,11 +60,11 @@ export const appConfig: ApplicationConfig = {
|
|
|
60
60
|
};
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-

|
|
68
68
|
|
|
69
69
|
In CI (`--serve` starts `ng serve`, waits for it, and stops it after the scan):
|
|
70
70
|
|
|
@@ -116,12 +116,6 @@ ever becomes reachable through a static import.
|
|
|
116
116
|
|
|
117
117
|
## Roadmap
|
|
118
118
|
|
|
119
|
-
### Planned
|
|
120
|
-
|
|
121
|
-
- A headless "linear walkthrough": the tab sequence as a reading list per route in
|
|
122
|
-
report mode. The Focus preview is overlay-only for now.
|
|
123
|
-
- Per-component filtering and a violation-count badge.
|
|
124
|
-
|
|
125
119
|
### Done
|
|
126
120
|
|
|
127
121
|
- Component attribution: the nearest app-owned component, skipping UI primitives.
|
|
@@ -144,3 +138,5 @@ ever becomes reachable through a static import.
|
|
|
144
138
|
- Report mode can start the dev server (`--serve`).
|
|
145
139
|
- ACR evaluation worksheet by WCAG 2.2 A/AA criterion (`--format acr`).
|
|
146
140
|
- Re-render a saved JSON report in any format without scanning (`--from`).
|
|
141
|
+
- Issue-count badge on the pill and a per-component filter in its menu.
|
|
142
|
+
- Tab order walkthrough in report mode (`--walkthrough`).
|
package/bin/ngbr-a11y-report.mjs
CHANGED
|
@@ -61,6 +61,9 @@ Options:
|
|
|
61
61
|
--focus-traps Also walk each route with real Tab presses to find keyboard
|
|
62
62
|
traps — focus that cycles inside part of the page and
|
|
63
63
|
never moves on (ngbr/focus-trap). Runs after the scan
|
|
64
|
+
--walkthrough Also list each route's tab order with every stop's computed
|
|
65
|
+
role, name, states and component (an approximation, not
|
|
66
|
+
any one screen reader's output)
|
|
64
67
|
--color-scheme <s> light | dark | both — scan with the browser emulating that
|
|
65
68
|
prefers-color-scheme (default light). "both" scans each
|
|
66
69
|
route twice; dark pages list only issues light doesn't have
|
|
@@ -99,6 +102,7 @@ function parseArgs(argv) {
|
|
|
99
102
|
case '--no-skip-primitives': opts.frameworkPrefixes = []; break;
|
|
100
103
|
case '--keyboard': opts.keyboard = true; break;
|
|
101
104
|
case '--focus-traps': opts.focusTraps = true; break;
|
|
105
|
+
case '--walkthrough': opts.walkthrough = true; break;
|
|
102
106
|
case '--color-scheme': opts.colorScheme = next(); break;
|
|
103
107
|
case '--dark-class': opts.darkClass = next(); break;
|
|
104
108
|
case '--dark-attribute': opts.darkAttribute = next(); break;
|
|
@@ -117,7 +121,7 @@ const opts = parseArgs(process.argv.slice(2));
|
|
|
117
121
|
const SCAN_ONLY = {
|
|
118
122
|
base: '--base', serve: '--serve', serveTimeout: '--serve-timeout', routes: '--route', tags: '--tags',
|
|
119
123
|
wait: '--wait', frameworkPrefixes: '--framework-prefixes / --no-skip-primitives', keyboard: '--keyboard',
|
|
120
|
-
focusTraps: '--focus-traps', colorScheme: '--color-scheme', darkClass: '--dark-class',
|
|
124
|
+
focusTraps: '--focus-traps', walkthrough: '--walkthrough', colorScheme: '--color-scheme', darkClass: '--dark-class',
|
|
121
125
|
darkAttribute: '--dark-attribute', headed: '--headed',
|
|
122
126
|
};
|
|
123
127
|
if (opts.from && !opts.help) {
|
|
@@ -245,6 +249,7 @@ if (!report) {
|
|
|
245
249
|
frameworkPrefixes: opts.frameworkPrefixes,
|
|
246
250
|
keyboard: opts.keyboard,
|
|
247
251
|
focusTraps: opts.focusTraps,
|
|
252
|
+
walkthrough: opts.walkthrough,
|
|
248
253
|
colorScheme: opts.colorScheme,
|
|
249
254
|
darkClass: opts.darkClass,
|
|
250
255
|
darkAttribute,
|
package/dist/inpage.global.js
CHANGED
|
@@ -25518,16 +25518,16 @@
|
|
|
25518
25518
|
var headingRole = role && role.includes("heading");
|
|
25519
25519
|
var ariaHeadingLevel = _getAriaValue(vNode, "aria-level").value;
|
|
25520
25520
|
var ariaLevel = parseInt(ariaHeadingLevel, 10);
|
|
25521
|
-
var _ref118 = vNode.props.nodeName.match(/h(\d)/) || [], _ref119 = _slicedToArray(_ref118, 2),
|
|
25521
|
+
var _ref118 = vNode.props.nodeName.match(/h(\d)/) || [], _ref119 = _slicedToArray(_ref118, 2), headingLevel2 = _ref119[1];
|
|
25522
25522
|
if (!headingRole) {
|
|
25523
25523
|
return -1;
|
|
25524
25524
|
}
|
|
25525
|
-
if (
|
|
25526
|
-
return parseInt(
|
|
25525
|
+
if (headingLevel2 && !ariaHeadingLevel) {
|
|
25526
|
+
return parseInt(headingLevel2, 10);
|
|
25527
25527
|
}
|
|
25528
25528
|
if (isNaN(ariaLevel) || ariaLevel < 1) {
|
|
25529
|
-
if (
|
|
25530
|
-
return parseInt(
|
|
25529
|
+
if (headingLevel2) {
|
|
25530
|
+
return parseInt(headingLevel2, 10);
|
|
25531
25531
|
}
|
|
25532
25532
|
return 2;
|
|
25533
25533
|
}
|
|
@@ -35151,6 +35151,14 @@
|
|
|
35151
35151
|
}
|
|
35152
35152
|
return false;
|
|
35153
35153
|
}
|
|
35154
|
+
function hitAreaForToggleInput(element) {
|
|
35155
|
+
if (element.children.length || element.textContent?.trim())
|
|
35156
|
+
return false;
|
|
35157
|
+
const parent = element.parentElement;
|
|
35158
|
+
if (!parent)
|
|
35159
|
+
return false;
|
|
35160
|
+
return [...parent.children].some((sibling) => sibling.matches('input[type="checkbox" i], input[type="radio" i]'));
|
|
35161
|
+
}
|
|
35154
35162
|
var RULE_DOCS = "https://ngbracket.com/tools/a11y-devtools/docs";
|
|
35155
35163
|
function shortSelector(element) {
|
|
35156
35164
|
const tag = element.tagName.toLowerCase();
|
|
@@ -35202,6 +35210,7 @@
|
|
|
35202
35210
|
const keyCache = /* @__PURE__ */ new Map();
|
|
35203
35211
|
const sharedCache = /* @__PURE__ */ new Map();
|
|
35204
35212
|
const unreachable = /* @__PURE__ */ new Set();
|
|
35213
|
+
const hitAreas = /* @__PURE__ */ new Set();
|
|
35205
35214
|
const listenerEvents = /* @__PURE__ */ new Map();
|
|
35206
35215
|
const eventsOf = (el) => {
|
|
35207
35216
|
let events = listenerEvents.get(el);
|
|
@@ -35260,6 +35269,10 @@
|
|
|
35260
35269
|
if (!focusable) {
|
|
35261
35270
|
if (!interactiveByRole && partOfKeyboardOperatedWidget(element, isVisible, keyCache, sharedCache))
|
|
35262
35271
|
continue;
|
|
35272
|
+
if (!interactiveByRole && hitAreaForToggleInput(element)) {
|
|
35273
|
+
hitAreas.add(element);
|
|
35274
|
+
continue;
|
|
35275
|
+
}
|
|
35263
35276
|
const within = interactiveByRole ? reachedWithinWidget(element, isVisible, keyCache, sharedCache) : false;
|
|
35264
35277
|
if (within === "reached")
|
|
35265
35278
|
continue;
|
|
@@ -35278,7 +35291,7 @@
|
|
|
35278
35291
|
findings.push(make(element, "ngbr/click-without-key", "moderate", `Keyboard users may not be able to activate this: Tab reaches it, but it only listens for click, and Enter and Space don't fire click on a non-native element. Use a <button>, or handle Enter and Space too. Heuristic \u2014 verify manually.`, `${RULE_DOCS}/click-without-key`));
|
|
35279
35292
|
}
|
|
35280
35293
|
}
|
|
35281
|
-
const hoverFlagged = new Set(unreachable);
|
|
35294
|
+
const hoverFlagged = /* @__PURE__ */ new Set([...unreachable, ...hitAreas]);
|
|
35282
35295
|
for (const element of root.querySelectorAll("*")) {
|
|
35283
35296
|
if (modal && !modal.contains(element))
|
|
35284
35297
|
continue;
|
|
@@ -35453,6 +35466,135 @@
|
|
|
35453
35466
|
};
|
|
35454
35467
|
}
|
|
35455
35468
|
|
|
35469
|
+
// dist/keyboard/accname.js
|
|
35470
|
+
var axePromise;
|
|
35471
|
+
function loadAxe() {
|
|
35472
|
+
return axePromise ??= Promise.resolve().then(() => __toESM(require_axe(), 1)).then((m) => m.default ?? m);
|
|
35473
|
+
}
|
|
35474
|
+
async function describeElement(element) {
|
|
35475
|
+
return (await describeElements([element]))[0];
|
|
35476
|
+
}
|
|
35477
|
+
async function describeElements(elements) {
|
|
35478
|
+
if (elements.length === 0)
|
|
35479
|
+
return [];
|
|
35480
|
+
const axe = await loadAxe();
|
|
35481
|
+
const doc = elements[0].ownerDocument ?? document;
|
|
35482
|
+
const computed = elements.map(() => ({ role: null, name: "" }));
|
|
35483
|
+
let didSetup = false;
|
|
35484
|
+
try {
|
|
35485
|
+
axe.setup(doc);
|
|
35486
|
+
didSetup = true;
|
|
35487
|
+
elements.forEach((element, i) => {
|
|
35488
|
+
try {
|
|
35489
|
+
const vnode = axe.utils.getNodeFromTree(element);
|
|
35490
|
+
computed[i] = {
|
|
35491
|
+
role: axe.commons.aria.getRole(element) ?? null,
|
|
35492
|
+
name: vnode ? axe.commons.text.accessibleTextVirtual(vnode) ?? "" : ""
|
|
35493
|
+
};
|
|
35494
|
+
} catch {
|
|
35495
|
+
}
|
|
35496
|
+
});
|
|
35497
|
+
} catch {
|
|
35498
|
+
} finally {
|
|
35499
|
+
if (didSetup) {
|
|
35500
|
+
try {
|
|
35501
|
+
axe.teardown();
|
|
35502
|
+
} catch {
|
|
35503
|
+
}
|
|
35504
|
+
}
|
|
35505
|
+
}
|
|
35506
|
+
return elements.map((element, i) => ({
|
|
35507
|
+
...computed[i],
|
|
35508
|
+
description: accessibleDescription(element),
|
|
35509
|
+
states: ariaStates(element)
|
|
35510
|
+
}));
|
|
35511
|
+
}
|
|
35512
|
+
function accessibleDescription(element) {
|
|
35513
|
+
const ids = element.getAttribute("aria-describedby");
|
|
35514
|
+
if (ids) {
|
|
35515
|
+
const doc = element.ownerDocument ?? document;
|
|
35516
|
+
const text = ids.split(/\s+/).filter(Boolean).map((id) => doc.getElementById(id)?.textContent?.trim() ?? "").filter(Boolean).join(" ");
|
|
35517
|
+
if (text)
|
|
35518
|
+
return text;
|
|
35519
|
+
}
|
|
35520
|
+
return element.getAttribute("title")?.trim() ?? "";
|
|
35521
|
+
}
|
|
35522
|
+
function isOn(value) {
|
|
35523
|
+
return value !== null && value !== "false" && value !== "undefined";
|
|
35524
|
+
}
|
|
35525
|
+
function ariaStates(element) {
|
|
35526
|
+
const states = [];
|
|
35527
|
+
const attr = (name) => element.getAttribute(name);
|
|
35528
|
+
const expanded = attr("aria-expanded");
|
|
35529
|
+
if (expanded === "true")
|
|
35530
|
+
states.push("expanded");
|
|
35531
|
+
else if (expanded === "false")
|
|
35532
|
+
states.push("collapsed");
|
|
35533
|
+
const checked = attr("aria-checked");
|
|
35534
|
+
if (checked === "true")
|
|
35535
|
+
states.push("checked");
|
|
35536
|
+
else if (checked === "false")
|
|
35537
|
+
states.push("not checked");
|
|
35538
|
+
else if (checked === "mixed")
|
|
35539
|
+
states.push("mixed");
|
|
35540
|
+
else if ("checked" in element && element.checked)
|
|
35541
|
+
states.push("checked");
|
|
35542
|
+
const pressed = attr("aria-pressed");
|
|
35543
|
+
if (pressed === "true")
|
|
35544
|
+
states.push("pressed");
|
|
35545
|
+
else if (pressed === "false")
|
|
35546
|
+
states.push("not pressed");
|
|
35547
|
+
if (attr("aria-selected") === "true")
|
|
35548
|
+
states.push("selected");
|
|
35549
|
+
if (isOn(attr("aria-disabled")) || "disabled" in element && element.disabled) {
|
|
35550
|
+
states.push("disabled");
|
|
35551
|
+
}
|
|
35552
|
+
if (isOn(attr("aria-required")) || "required" in element && element.required) {
|
|
35553
|
+
states.push("required");
|
|
35554
|
+
}
|
|
35555
|
+
if (attr("aria-invalid") === "true")
|
|
35556
|
+
states.push("invalid");
|
|
35557
|
+
if (attr("aria-readonly") === "true")
|
|
35558
|
+
states.push("read only");
|
|
35559
|
+
const current = attr("aria-current");
|
|
35560
|
+
if (isOn(current))
|
|
35561
|
+
states.push(current === "true" ? "current" : `current ${current}`);
|
|
35562
|
+
const haspopup = attr("aria-haspopup");
|
|
35563
|
+
if (isOn(haspopup))
|
|
35564
|
+
states.push(haspopup === "true" ? "has popup" : `has ${haspopup} popup`);
|
|
35565
|
+
const level = attr("aria-level") ?? headingLevel(element);
|
|
35566
|
+
if (level)
|
|
35567
|
+
states.push(`level ${level}`);
|
|
35568
|
+
const posinset = attr("aria-posinset");
|
|
35569
|
+
const setsize = attr("aria-setsize");
|
|
35570
|
+
if (posinset && setsize)
|
|
35571
|
+
states.push(`${posinset} of ${setsize}`);
|
|
35572
|
+
return states;
|
|
35573
|
+
}
|
|
35574
|
+
function headingLevel(element) {
|
|
35575
|
+
const match = /^h([1-6])$/.exec(element.tagName.toLowerCase());
|
|
35576
|
+
return match ? match[1] : null;
|
|
35577
|
+
}
|
|
35578
|
+
|
|
35579
|
+
// dist/keyboard/walkthrough.js
|
|
35580
|
+
var WALKTHROUGH_MAX_STEPS = 300;
|
|
35581
|
+
async function linearWalkthrough(root = document, options = {}) {
|
|
35582
|
+
const stops = tabSequence(root, options);
|
|
35583
|
+
const kept = stops.slice(0, WALKTHROUGH_MAX_STEPS);
|
|
35584
|
+
const described = await describeElements(kept.map((s) => s.element));
|
|
35585
|
+
const steps = kept.map((stop, i) => ({
|
|
35586
|
+
order: stop.order,
|
|
35587
|
+
role: described[i].role,
|
|
35588
|
+
name: described[i].name.replace(/\s+/g, " ").trim(),
|
|
35589
|
+
description: described[i].description,
|
|
35590
|
+
states: described[i].states,
|
|
35591
|
+
tag: stop.element.tagName.toLowerCase(),
|
|
35592
|
+
positive: stop.positive,
|
|
35593
|
+
component: stop.component
|
|
35594
|
+
}));
|
|
35595
|
+
return { steps, total: stops.length };
|
|
35596
|
+
}
|
|
35597
|
+
|
|
35456
35598
|
// dist/scan.js
|
|
35457
35599
|
var runChain = Promise.resolve();
|
|
35458
35600
|
function scan(root = document, options, scanOptions) {
|
|
@@ -35500,6 +35642,7 @@
|
|
|
35500
35642
|
var run = (options, scanOptions) => scan(document, options, scanOptions);
|
|
35501
35643
|
globalThis.__ngbA11yScan = run;
|
|
35502
35644
|
globalThis.__ngbA11yCreateFocusProbe = (prefixes) => createFocusWalkProbe(document, prefixes);
|
|
35645
|
+
globalThis.__ngbA11yWalkthrough = (prefixes) => linearWalkthrough(document, { frameworkPrefixes: prefixes });
|
|
35503
35646
|
})();
|
|
35504
35647
|
/*! Bundled license information:
|
|
35505
35648
|
|
package/dist/inpage.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createFocusWalkProbe } from './keyboard/focus-walk.js';
|
|
2
|
+
import { linearWalkthrough } from './keyboard/walkthrough.js';
|
|
2
3
|
import { scan } from './scan.js';
|
|
3
4
|
const run = (options, scanOptions) => scan(document, options, scanOptions);
|
|
4
5
|
globalThis.__ngbA11yScan = run;
|
|
5
6
|
// The in-page half of the focus-trap walk: the driver creates a probe, presses
|
|
6
7
|
// real Tab keys, and asks the probe what has focus after each one.
|
|
7
8
|
globalThis.__ngbA11yCreateFocusProbe = (prefixes) => createFocusWalkProbe(document, prefixes);
|
|
9
|
+
// The linear walkthrough: the tab order with each stop's computed role and name.
|
|
10
|
+
globalThis.__ngbA11yWalkthrough = (prefixes) => linearWalkthrough(document, { frameworkPrefixes: prefixes });
|
|
@@ -31,6 +31,11 @@ export interface AxDescription {
|
|
|
31
31
|
* built — e.g. a scan is mid-flight — so a focus-follow caller degrades quietly.
|
|
32
32
|
*/
|
|
33
33
|
export declare function describeElement(element: Element): Promise<AxDescription>;
|
|
34
|
+
/**
|
|
35
|
+
* {@link describeElement} for many elements of one document, building axe's
|
|
36
|
+
* tree once instead of once per element (a page's whole tab order, say).
|
|
37
|
+
*/
|
|
38
|
+
export declare function describeElements(elements: readonly Element[]): Promise<AxDescription[]>;
|
|
34
39
|
/** The accessible description: `aria-describedby` targets' text, else the `title`. */
|
|
35
40
|
export declare function accessibleDescription(element: Element): string;
|
|
36
41
|
/**
|
package/dist/keyboard/accname.js
CHANGED
|
@@ -26,17 +26,34 @@ function loadAxe() {
|
|
|
26
26
|
* built — e.g. a scan is mid-flight — so a focus-follow caller degrades quietly.
|
|
27
27
|
*/
|
|
28
28
|
export async function describeElement(element) {
|
|
29
|
+
return (await describeElements([element]))[0];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* {@link describeElement} for many elements of one document, building axe's
|
|
33
|
+
* tree once instead of once per element (a page's whole tab order, say).
|
|
34
|
+
*/
|
|
35
|
+
export async function describeElements(elements) {
|
|
36
|
+
if (elements.length === 0)
|
|
37
|
+
return [];
|
|
29
38
|
const axe = await loadAxe();
|
|
30
|
-
const doc =
|
|
31
|
-
|
|
32
|
-
let name = '';
|
|
39
|
+
const doc = elements[0].ownerDocument ?? document;
|
|
40
|
+
const computed = elements.map(() => ({ role: null, name: '' }));
|
|
33
41
|
let didSetup = false;
|
|
34
42
|
try {
|
|
35
43
|
axe.setup(doc);
|
|
36
44
|
didSetup = true;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
elements.forEach((element, i) => {
|
|
46
|
+
try {
|
|
47
|
+
const vnode = axe.utils.getNodeFromTree(element);
|
|
48
|
+
computed[i] = {
|
|
49
|
+
role: axe.commons.aria.getRole(element) ?? null,
|
|
50
|
+
name: vnode ? (axe.commons.text.accessibleTextVirtual(vnode) ?? '') : '',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Leave this one at role=null / name=''.
|
|
55
|
+
}
|
|
56
|
+
});
|
|
40
57
|
}
|
|
41
58
|
catch {
|
|
42
59
|
// Leave role=null / name='' — axe couldn't build a tree (e.g. run in flight).
|
|
@@ -53,7 +70,11 @@ export async function describeElement(element) {
|
|
|
53
70
|
}
|
|
54
71
|
}
|
|
55
72
|
}
|
|
56
|
-
return
|
|
73
|
+
return elements.map((element, i) => ({
|
|
74
|
+
...computed[i],
|
|
75
|
+
description: accessibleDescription(element),
|
|
76
|
+
states: ariaStates(element),
|
|
77
|
+
}));
|
|
57
78
|
}
|
|
58
79
|
/** The accessible description: `aria-describedby` targets' text, else the `title`. */
|
|
59
80
|
export function accessibleDescription(element) {
|
|
@@ -252,6 +252,26 @@ function partOfKeyboardOperatedWidget(element, isVisible, keyCache, sharedCache)
|
|
|
252
252
|
}
|
|
253
253
|
return false;
|
|
254
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* True when `element` is an empty hit area beside a checkbox or radio input: a
|
|
257
|
+
* larger click or touch target that toggles the input, which the keyboard
|
|
258
|
+
* reaches and operates on its own. Angular Material 15 to 21 draws one in every
|
|
259
|
+
* checkbox and radio button (`.mat-mdc-checkbox-touch-target`,
|
|
260
|
+
* `.mat-mdc-radio-touch-target`, each with a click handler; only 21 also marks
|
|
261
|
+
* it `aria-hidden`). Disabled inputs count too: their hit area does nothing either.
|
|
262
|
+
*
|
|
263
|
+
* Only checkbox and radio inputs: an empty clickable beside a text field or a
|
|
264
|
+
* button (a clear "×" drawn in CSS) is a separate action Tab can't reach, and
|
|
265
|
+
* is still reported.
|
|
266
|
+
*/
|
|
267
|
+
function hitAreaForToggleInput(element) {
|
|
268
|
+
if (element.children.length || element.textContent?.trim())
|
|
269
|
+
return false;
|
|
270
|
+
const parent = element.parentElement;
|
|
271
|
+
if (!parent)
|
|
272
|
+
return false;
|
|
273
|
+
return [...parent.children].some((sibling) => sibling.matches('input[type="checkbox" i], input[type="radio" i]'));
|
|
274
|
+
}
|
|
255
275
|
/**
|
|
256
276
|
* Each rule's page: what the message means, who it affects, exactly what
|
|
257
277
|
* triggers it, how to fix and check it, and the WCAG/APG reference.
|
|
@@ -329,6 +349,8 @@ export function scanKeyboard(root = document, options = {}) {
|
|
|
329
349
|
const sharedCache = new Map();
|
|
330
350
|
/** Elements reported as unreachable controls, so the hover check doesn't repeat them. */
|
|
331
351
|
const unreachable = new Set();
|
|
352
|
+
/** Checkbox and radio hit areas, skipped by the hover check too. */
|
|
353
|
+
const hitAreas = new Set();
|
|
332
354
|
/** Angular listener names per element, read once and shared by both passes. */
|
|
333
355
|
const listenerEvents = new Map();
|
|
334
356
|
const eventsOf = (el) => {
|
|
@@ -417,6 +439,11 @@ export function scanKeyboard(root = document, options = {}) {
|
|
|
417
439
|
// Only for unreachable elements: one Tab reaches is still checked below.
|
|
418
440
|
if (!interactiveByRole && partOfKeyboardOperatedWidget(element, isVisible, keyCache, sharedCache))
|
|
419
441
|
continue;
|
|
442
|
+
// A mouse/touch hit area for the checkbox or radio next to it (Material's touch targets).
|
|
443
|
+
if (!interactiveByRole && hitAreaForToggleInput(element)) {
|
|
444
|
+
hitAreas.add(element);
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
420
447
|
const within = interactiveByRole ? reachedWithinWidget(element, isVisible, keyCache, sharedCache) : false;
|
|
421
448
|
if (within === 'reached')
|
|
422
449
|
continue;
|
|
@@ -446,8 +473,9 @@ export function scanKeyboard(root = document, options = {}) {
|
|
|
446
473
|
}
|
|
447
474
|
// Hover-only content: a tooltip, hover listener or icon `title` on something
|
|
448
475
|
// Tab can't reach, so keyboard users may never see what it shows.
|
|
449
|
-
// Seeded with the unreachable controls, so an icon inside one isn't reported
|
|
450
|
-
|
|
476
|
+
// Seeded with the unreachable controls, so an icon inside one isn't reported
|
|
477
|
+
// again, and with the skipped checkbox/radio hit areas.
|
|
478
|
+
const hoverFlagged = new Set([...unreachable, ...hitAreas]);
|
|
451
479
|
for (const element of root.querySelectorAll('*')) {
|
|
452
480
|
if (modal && !modal.contains(element))
|
|
453
481
|
continue;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type TabSequenceOptions } from './tab-sequence.js';
|
|
2
|
+
/** One tab stop in the walkthrough. Plain data, so it survives JSON. */
|
|
3
|
+
export interface WalkthroughStep {
|
|
4
|
+
/** 1-based position in the tab order. */
|
|
5
|
+
order: number;
|
|
6
|
+
/** Computed ARIA role, or null when none resolves. */
|
|
7
|
+
role: string | null;
|
|
8
|
+
/** Computed accessible name; '' when it has none. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Computed accessible description, or ''. */
|
|
11
|
+
description: string;
|
|
12
|
+
/** State labels, e.g. `['expanded', 'required']`. */
|
|
13
|
+
states: string[];
|
|
14
|
+
/** Tag name of the element, e.g. `button`. */
|
|
15
|
+
tag: string;
|
|
16
|
+
/** True when a positive `tabindex` puts this stop out of DOM order. */
|
|
17
|
+
positive: boolean;
|
|
18
|
+
/** Owning app component, or null. */
|
|
19
|
+
component: string | null;
|
|
20
|
+
}
|
|
21
|
+
/** Steps past this many are dropped; the report says how many there were. */
|
|
22
|
+
export declare const WALKTHROUGH_MAX_STEPS = 300;
|
|
23
|
+
export interface Walkthrough {
|
|
24
|
+
steps: WalkthroughStep[];
|
|
25
|
+
/** Tab stops on the page. More than `steps.length` when the list was capped. */
|
|
26
|
+
total: number;
|
|
27
|
+
}
|
|
28
|
+
/** Walk the tab order of `root` and describe each stop. */
|
|
29
|
+
export declare function linearWalkthrough(root?: ParentNode, options?: Pick<TabSequenceOptions, 'frameworkPrefixes'>): Promise<Walkthrough>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The linear walkthrough: the page's tab order as a reading list, each stop with
|
|
3
|
+
* its computed role, name and states and the component that rendered it. It's
|
|
4
|
+
* the report-mode form of the overlay's tab-order path and Focus preview.
|
|
5
|
+
*
|
|
6
|
+
* Like the Focus preview, this is a *computed approximation* (see `accname.ts`),
|
|
7
|
+
* never what any one screen reader says.
|
|
8
|
+
*/
|
|
9
|
+
import { describeElements } from './accname.js';
|
|
10
|
+
import { tabSequence } from './tab-sequence.js';
|
|
11
|
+
/** Steps past this many are dropped; the report says how many there were. */
|
|
12
|
+
export const WALKTHROUGH_MAX_STEPS = 300;
|
|
13
|
+
/** Walk the tab order of `root` and describe each stop. */
|
|
14
|
+
export async function linearWalkthrough(root = document, options = {}) {
|
|
15
|
+
const stops = tabSequence(root, options);
|
|
16
|
+
const kept = stops.slice(0, WALKTHROUGH_MAX_STEPS);
|
|
17
|
+
const described = await describeElements(kept.map((s) => s.element));
|
|
18
|
+
const steps = kept.map((stop, i) => ({
|
|
19
|
+
order: stop.order,
|
|
20
|
+
role: described[i].role,
|
|
21
|
+
name: described[i].name.replace(/\s+/g, ' ').trim(),
|
|
22
|
+
description: described[i].description,
|
|
23
|
+
states: described[i].states,
|
|
24
|
+
tag: stop.element.tagName.toLowerCase(),
|
|
25
|
+
positive: stop.positive,
|
|
26
|
+
component: stop.component,
|
|
27
|
+
}));
|
|
28
|
+
return { steps, total: stops.length };
|
|
29
|
+
}
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { A11yFinding } from './scan.js';
|
|
1
|
+
import type { A11yFinding, Impact } from './scan.js';
|
|
2
2
|
import type { TabStop } from './keyboard/tab-sequence.js';
|
|
3
3
|
import type { AxDescription } from './keyboard/accname.js';
|
|
4
4
|
/**
|
|
@@ -8,6 +8,11 @@ import type { AxDescription } from './keyboard/accname.js';
|
|
|
8
8
|
export declare const OVERLAY_ATTR = "data-ngb-a11y-overlay";
|
|
9
9
|
/** Selector form of {@link OVERLAY_ATTR}, passed to axe as an exclude. */
|
|
10
10
|
export declare const OVERLAY_EXCLUDE_SELECTOR = "[data-ngb-a11y-overlay]";
|
|
11
|
+
/**
|
|
12
|
+
* Label fill per impact, behind white 11px text: at least 4.5:1 with white, in
|
|
13
|
+
* the same hue as the border, so the labels pass a contrast check themselves.
|
|
14
|
+
*/
|
|
15
|
+
export declare const IMPACT_LABEL_FILL: Record<NonNullable<Impact> | 'none', string>;
|
|
11
16
|
/** The computed accessibility-tree info shown in the focus-follow panel. */
|
|
12
17
|
export interface AxPanelData extends AxDescription {
|
|
13
18
|
/** Owning component of the focused element, or null. */
|
package/dist/overlay.js
CHANGED
|
@@ -32,7 +32,7 @@ const IMPACT_COLOR = {
|
|
|
32
32
|
* Label fill per impact, behind white 11px text: at least 4.5:1 with white, in
|
|
33
33
|
* the same hue as the border, so the labels pass a contrast check themselves.
|
|
34
34
|
*/
|
|
35
|
-
const IMPACT_LABEL_FILL = {
|
|
35
|
+
export const IMPACT_LABEL_FILL = {
|
|
36
36
|
critical: '#d32029',
|
|
37
37
|
serious: '#b45309',
|
|
38
38
|
moderate: '#8a6d00',
|
package/dist/pill-menu.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export interface PillMenuOptions {
|
|
|
5
5
|
onChange: (settings: DevtoolsSettings) => void;
|
|
6
6
|
/** Download the report for the pages visited so far. */
|
|
7
7
|
onDownload: () => void;
|
|
8
|
+
/** Show only one component's issues (`null`: every component). */
|
|
9
|
+
onComponentChange?: (component: string | null) => void;
|
|
8
10
|
/** Open the panel above the button (pill at the bottom) or below it. */
|
|
9
11
|
opensUp: boolean;
|
|
10
12
|
/** Align the panel's left edge (pill on the left) or right edge. */
|
|
@@ -17,6 +19,13 @@ export interface PillMenuStatus {
|
|
|
17
19
|
shown: number;
|
|
18
20
|
/** Pages recorded for the report. */
|
|
19
21
|
pages: number;
|
|
22
|
+
/** Components with issues on this page, most issues first. */
|
|
23
|
+
components?: {
|
|
24
|
+
name: string;
|
|
25
|
+
count: number;
|
|
26
|
+
}[];
|
|
27
|
+
/** The component filter in force, or null for every component. */
|
|
28
|
+
component?: string | null;
|
|
20
29
|
}
|
|
21
30
|
export interface PillMenu {
|
|
22
31
|
/** The `⋯` button that opens the panel. */
|
package/dist/pill-menu.js
CHANGED
|
@@ -102,7 +102,7 @@ export function createPillMenu(doc, options) {
|
|
|
102
102
|
select.append(opt);
|
|
103
103
|
}
|
|
104
104
|
select.value = settings.minImpact;
|
|
105
|
-
|
|
105
|
+
const selectStyle = {
|
|
106
106
|
width: '100%',
|
|
107
107
|
minHeight: '28px',
|
|
108
108
|
marginBottom: '10px',
|
|
@@ -111,8 +111,42 @@ export function createPillMenu(doc, options) {
|
|
|
111
111
|
background: '#2a2e37',
|
|
112
112
|
border: '1px solid rgba(255,255,255,0.3)',
|
|
113
113
|
borderRadius: '4px',
|
|
114
|
-
}
|
|
114
|
+
};
|
|
115
|
+
Object.assign(select.style, selectStyle);
|
|
115
116
|
select.addEventListener('change', () => update({ minImpact: select.value }));
|
|
117
|
+
// Per-component filter. Its options follow the components on the current page.
|
|
118
|
+
const componentLabel = doc.createElement('label');
|
|
119
|
+
componentLabel.textContent = 'Show component';
|
|
120
|
+
Object.assign(componentLabel.style, { display: 'block', fontWeight: '700', marginBottom: '4px' });
|
|
121
|
+
const componentSelect = doc.createElement('select');
|
|
122
|
+
componentSelect.id = `${id}-component`;
|
|
123
|
+
componentLabel.htmlFor = componentSelect.id;
|
|
124
|
+
Object.assign(componentSelect.style, selectStyle);
|
|
125
|
+
componentSelect.addEventListener('change', () => options.onComponentChange?.(componentSelect.value || null));
|
|
126
|
+
let componentOptionsKey = '';
|
|
127
|
+
/** Rebuild the options only when they change, so an open select isn't reset under the user. */
|
|
128
|
+
function setComponentOptions(components, selected) {
|
|
129
|
+
const list = [...components];
|
|
130
|
+
// Keep a chosen component listed after its issues are fixed, so the filter stays visible.
|
|
131
|
+
if (selected && !list.some((c) => c.name === selected))
|
|
132
|
+
list.push({ name: selected, count: 0 });
|
|
133
|
+
const key = JSON.stringify([list, selected]);
|
|
134
|
+
if (key === componentOptionsKey)
|
|
135
|
+
return;
|
|
136
|
+
componentOptionsKey = key;
|
|
137
|
+
const all = doc.createElement('option');
|
|
138
|
+
all.value = '';
|
|
139
|
+
all.textContent = 'All components';
|
|
140
|
+
const opts = list.map(({ name, count }) => {
|
|
141
|
+
const opt = doc.createElement('option');
|
|
142
|
+
opt.value = name;
|
|
143
|
+
opt.textContent = `${name} (${count})`;
|
|
144
|
+
return opt;
|
|
145
|
+
});
|
|
146
|
+
componentSelect.replaceChildren(all, ...opts);
|
|
147
|
+
componentSelect.value = selected ?? '';
|
|
148
|
+
}
|
|
149
|
+
setComponentOptions([], null);
|
|
116
150
|
const download = doc.createElement('button');
|
|
117
151
|
download.type = 'button';
|
|
118
152
|
download.textContent = 'Download report';
|
|
@@ -129,7 +163,8 @@ export function createPillMenu(doc, options) {
|
|
|
129
163
|
download.addEventListener('click', () => options.onDownload());
|
|
130
164
|
const pagesNote = doc.createElement('p');
|
|
131
165
|
Object.assign(pagesNote.style, { margin: '4px 0 0', fontSize: '12px', color: muted });
|
|
132
|
-
|
|
166
|
+
const componentControls = options.onComponentChange ? [componentLabel, componentSelect] : [];
|
|
167
|
+
panel.append(status, fieldset, severityLabel, select, ...componentControls, download, pagesNote);
|
|
133
168
|
function update(patch) {
|
|
134
169
|
settings = { ...settings, ...patch };
|
|
135
170
|
options.onChange(settings);
|
|
@@ -157,7 +192,7 @@ export function createPillMenu(doc, options) {
|
|
|
157
192
|
};
|
|
158
193
|
doc.addEventListener('pointerdown', onPointerDown, true);
|
|
159
194
|
// Inline styles can't do :focus-visible; draw the rings from focus events.
|
|
160
|
-
for (const el of [button, download, select]) {
|
|
195
|
+
for (const el of [button, download, select, componentSelect]) {
|
|
161
196
|
el.addEventListener('focus', () => {
|
|
162
197
|
if (el.matches(':focus-visible')) {
|
|
163
198
|
el.style.outline = '2px solid #7ab8ff';
|
|
@@ -171,7 +206,9 @@ export function createPillMenu(doc, options) {
|
|
|
171
206
|
return {
|
|
172
207
|
button,
|
|
173
208
|
panel,
|
|
174
|
-
setStatus({ found, shown, pages }) {
|
|
209
|
+
setStatus({ found, shown, pages, components, component }) {
|
|
210
|
+
if (components)
|
|
211
|
+
setComponentOptions(components, component ?? null);
|
|
175
212
|
const issues = `${found} ${found === 1 ? 'issue' : 'issues'} on this page`;
|
|
176
213
|
status.textContent = shown === found ? issues : `${issues}, ${shown} shown`;
|
|
177
214
|
pagesNote.textContent = `Covers ${pages} ${pages === 1 ? 'page' : 'pages'} visited since the app loaded.`;
|
package/dist/provider.js
CHANGED
|
@@ -6,7 +6,7 @@ import { tabSequence } from './keyboard/tab-sequence.js';
|
|
|
6
6
|
import { describeElement } from './keyboard/accname.js';
|
|
7
7
|
import { resolveOwningComponentName } from './attribution.js';
|
|
8
8
|
import { createTogglePill, DEFAULT_TOGGLE_SHORTCUT, matchesShortcut, parseShortcut, readStoredEnabled, writeStoredEnabled, } from './toggle.js';
|
|
9
|
-
import { readStoredSettings, resolveSettings, visibleFindings, writeStoredSettings, } from './settings.js';
|
|
9
|
+
import { componentCounts, readStoredSettings, resolveSettings, visibleFindings, worstImpact, writeStoredSettings, } from './settings.js';
|
|
10
10
|
/**
|
|
11
11
|
* Dev-only in-app accessibility auditing. Rescans whenever the application
|
|
12
12
|
* settles (zoneless-aware, via `ApplicationRef.isStable`) and reports each
|
|
@@ -57,10 +57,24 @@ function devtoolsProviders(options) {
|
|
|
57
57
|
// and the latest findings per route visited, for the downloadable report.
|
|
58
58
|
let lastFindings = [];
|
|
59
59
|
const visited = new Map();
|
|
60
|
+
// Show one component's issues only (null: all). Not remembered, and reset
|
|
61
|
+
// on a route change: the components change from page to page.
|
|
62
|
+
let componentFilter = null;
|
|
63
|
+
let lastPath;
|
|
60
64
|
/** Draw (or clear) each overlay layer from the last scan and the settings. */
|
|
61
65
|
function draw() {
|
|
62
|
-
const
|
|
63
|
-
|
|
66
|
+
const matching = visibleFindings(lastFindings, settings.minImpact, componentFilter);
|
|
67
|
+
const shown = settings.highlights ? matching : [];
|
|
68
|
+
pillView?.setStatus({
|
|
69
|
+
found: lastFindings.length,
|
|
70
|
+
shown: shown.length,
|
|
71
|
+
pages: visited.size,
|
|
72
|
+
matching: matching.length,
|
|
73
|
+
worst: worstImpact(matching),
|
|
74
|
+
// Counted at the chosen severity, so an option's count matches the badge.
|
|
75
|
+
components: componentCounts(visibleFindings(lastFindings, settings.minImpact)),
|
|
76
|
+
component: componentFilter,
|
|
77
|
+
});
|
|
64
78
|
if (!overlayView)
|
|
65
79
|
return;
|
|
66
80
|
if (!enabled) {
|
|
@@ -137,7 +151,17 @@ function devtoolsProviders(options) {
|
|
|
137
151
|
onToggle: setEnabled,
|
|
138
152
|
shortcut,
|
|
139
153
|
position: pill,
|
|
140
|
-
menu: overlayView
|
|
154
|
+
menu: overlayView
|
|
155
|
+
? {
|
|
156
|
+
settings,
|
|
157
|
+
onChange: setSettings,
|
|
158
|
+
onDownload: downloadReport,
|
|
159
|
+
onComponentChange: (component) => {
|
|
160
|
+
componentFilter = component;
|
|
161
|
+
draw();
|
|
162
|
+
},
|
|
163
|
+
}
|
|
164
|
+
: undefined,
|
|
141
165
|
})
|
|
142
166
|
: undefined;
|
|
143
167
|
let onKeyDown;
|
|
@@ -217,6 +241,10 @@ function devtoolsProviders(options) {
|
|
|
217
241
|
return; // switched off mid-scan: draw nothing
|
|
218
242
|
lastFindings = findings;
|
|
219
243
|
const route = location.pathname + location.search;
|
|
244
|
+
// A new path is a new page; a query-string change (?page=2) keeps the filter.
|
|
245
|
+
if (lastPath !== undefined && location.pathname !== lastPath)
|
|
246
|
+
componentFilter = null;
|
|
247
|
+
lastPath = location.pathname;
|
|
220
248
|
// Label by route: a single-page app usually keeps one title on every route.
|
|
221
249
|
visited.set(route, { label: route, url: location.href, findings });
|
|
222
250
|
draw();
|
package/dist/report/format.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { A11yFinding, Impact } from '../scan.js';
|
|
2
2
|
import type { BaselineDiff } from './baseline.js';
|
|
3
|
+
import type { Walkthrough, WalkthroughStep } from '../keyboard/walkthrough.js';
|
|
3
4
|
/**
|
|
4
5
|
* Pure formatting for report-mode: grouping + Markdown/JSON serialization. Kept
|
|
5
6
|
* free of any Node or Playwright imports so the browser side (`report.ts`) can
|
|
@@ -21,9 +22,20 @@ export interface PageReport {
|
|
|
21
22
|
* ones that don't also appear in the light pass of the same route.
|
|
22
23
|
*/
|
|
23
24
|
darkOnly?: boolean;
|
|
25
|
+
/** The tab order with each stop's computed role and name, when the run asked for it. */
|
|
26
|
+
walkthrough?: Walkthrough;
|
|
24
27
|
}
|
|
25
28
|
/** One-line explanation for a dark-only page, shared by the Markdown and HTML reports. */
|
|
26
29
|
export declare const DARK_ONLY_NOTE = "Dark mode: lists only issues that don\u2019t also appear in light mode on this route.";
|
|
30
|
+
/**
|
|
31
|
+
* Heading note for the walkthrough, shared by the Markdown and HTML reports. Same
|
|
32
|
+
* honesty rule as the overlay's Focus preview: computed, not a screen reader.
|
|
33
|
+
*/
|
|
34
|
+
export declare const WALKTHROUGH_NOTE: string;
|
|
35
|
+
/** One walkthrough step as a single line, e.g. `button "Save" (disabled) — SaveBarComponent`. */
|
|
36
|
+
export declare function formatStep(step: WalkthroughStep): string;
|
|
37
|
+
/** "Showing the first 300 of 412 tab stops." when the list was capped, else ''. */
|
|
38
|
+
export declare function walkthroughCapNote(walkthrough: Walkthrough): string;
|
|
27
39
|
/**
|
|
28
40
|
* Report title, shared by every format. Says "automated scan" on purpose: a file
|
|
29
41
|
* titled "Accessibility report" is easy to hand to procurement as if it were a
|
|
@@ -48,6 +60,8 @@ export interface ScanChecks {
|
|
|
48
60
|
keyboard: boolean;
|
|
49
61
|
/** The real-Tab keyboard-trap walk (`ngbr/focus-trap`) ran. */
|
|
50
62
|
focusTraps: boolean;
|
|
63
|
+
/** Each page lists its tab order with computed roles and names. */
|
|
64
|
+
walkthrough?: boolean;
|
|
51
65
|
}
|
|
52
66
|
/** A whole report-mode run across one or more pages. */
|
|
53
67
|
export interface ScanReport {
|
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
|
+
}
|
|
@@ -81,6 +81,14 @@ export interface ScanPagesOptions {
|
|
|
81
81
|
* modal is containment, not a trap, and isn't reported. Default false.
|
|
82
82
|
*/
|
|
83
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;
|
|
84
92
|
}
|
|
85
93
|
/**
|
|
86
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/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.1",
|
|
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",
|