@ngbracket/a11y-devtools 0.17.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 CHANGED
@@ -3,6 +3,34 @@
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.0
7
+
8
+ ### Added
9
+
10
+ - Report mode can list each route's tab order (`--walkthrough`, or
11
+ `walkthrough: true` in `scanPages`). Every tab stop gets a line with its
12
+ computed role, accessible name, states and owning component, for example
13
+ `button "Save" (disabled) — SaveBarComponent`. A stop with no name reads
14
+ `(no accessible name)`, and a positive `tabindex` is flagged. The list is in
15
+ the JSON, Markdown and HTML reports, under a note that it is a computed
16
+ approximation and not the output of any one screen reader. With
17
+ `--color-scheme both` it runs on the light pass only. It stops at 300 stops
18
+ per page; the report gives the real total when it is cut short.
19
+ - The pill shows a count badge: the issues on the page that pass the menu's
20
+ filters, coloured by the most severe of them (green at 0). The switch gets the
21
+ count in words as its description, for example "5 issues of 14 on this page
22
+ match the filters".
23
+ - The pill menu has a **Show component** filter that lists the components with
24
+ issues on the current page, each with its count at the chosen severity.
25
+ Choosing one draws only that component's highlights and updates the badge.
26
+ The choice isn't saved, and it goes back to all components when the path
27
+ changes. A query-string change (`?page=2`) keeps it.
28
+
29
+ ### Changed
30
+
31
+ - The keyboard-layer screenshot in the README is new: the demo's Keyboard
32
+ section with the severity filter at "Serious and above".
33
+
6
34
  ## 0.17.0
7
35
 
8
36
  ### Added
package/README.md CHANGED
@@ -60,11 +60,11 @@ export const appConfig: ApplicationConfig = {
60
60
  };
61
61
  ```
62
62
 
63
- ![Keyboard & Focus Mode over the demo page: numbered tab-order badges (badge 1 in
64
- orange flags a positive tabindex) joined by a connector path, severity-coloured
65
- finding highlights labelled with their owning component (including the ngbr/*
66
- keyboard findings), and the Focus preview card showing the focused button's
67
- computed role, name and states.](./demo/keyboard-layer-2026-09.png)
63
+ ![Keyboard & Focus Mode over the demo page's Keyboard section: numbered tab-order
64
+ badges joined by a dashed path (badge 1 in orange flags a positive tabindex), two
65
+ serious keyboard findings labelled with their owning component, the Focus preview
66
+ card showing the focused Menu button's computed role, name and states, and the a11y
67
+ pill in the corner with a red 5, the count of issues that pass the severity filter.](./demo/keyboard-layer-2026-10.png)
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`).
@@ -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,
@@ -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), headingLevel = _ref119[1];
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 (headingLevel && !ariaHeadingLevel) {
25526
- return parseInt(headingLevel, 10);
25525
+ if (headingLevel2 && !ariaHeadingLevel) {
25526
+ return parseInt(headingLevel2, 10);
25527
25527
  }
25528
25528
  if (isNaN(ariaLevel) || ariaLevel < 1) {
25529
- if (headingLevel) {
25530
- return parseInt(headingLevel, 10);
25529
+ if (headingLevel2) {
25530
+ return parseInt(headingLevel2, 10);
25531
25531
  }
25532
25532
  return 2;
25533
25533
  }
@@ -35453,6 +35453,135 @@
35453
35453
  };
35454
35454
  }
35455
35455
 
35456
+ // dist/keyboard/accname.js
35457
+ var axePromise;
35458
+ function loadAxe() {
35459
+ return axePromise ??= Promise.resolve().then(() => __toESM(require_axe(), 1)).then((m) => m.default ?? m);
35460
+ }
35461
+ async function describeElement(element) {
35462
+ return (await describeElements([element]))[0];
35463
+ }
35464
+ async function describeElements(elements) {
35465
+ if (elements.length === 0)
35466
+ return [];
35467
+ const axe = await loadAxe();
35468
+ const doc = elements[0].ownerDocument ?? document;
35469
+ const computed = elements.map(() => ({ role: null, name: "" }));
35470
+ let didSetup = false;
35471
+ try {
35472
+ axe.setup(doc);
35473
+ didSetup = true;
35474
+ elements.forEach((element, i) => {
35475
+ try {
35476
+ const vnode = axe.utils.getNodeFromTree(element);
35477
+ computed[i] = {
35478
+ role: axe.commons.aria.getRole(element) ?? null,
35479
+ name: vnode ? axe.commons.text.accessibleTextVirtual(vnode) ?? "" : ""
35480
+ };
35481
+ } catch {
35482
+ }
35483
+ });
35484
+ } catch {
35485
+ } finally {
35486
+ if (didSetup) {
35487
+ try {
35488
+ axe.teardown();
35489
+ } catch {
35490
+ }
35491
+ }
35492
+ }
35493
+ return elements.map((element, i) => ({
35494
+ ...computed[i],
35495
+ description: accessibleDescription(element),
35496
+ states: ariaStates(element)
35497
+ }));
35498
+ }
35499
+ function accessibleDescription(element) {
35500
+ const ids = element.getAttribute("aria-describedby");
35501
+ if (ids) {
35502
+ const doc = element.ownerDocument ?? document;
35503
+ const text = ids.split(/\s+/).filter(Boolean).map((id) => doc.getElementById(id)?.textContent?.trim() ?? "").filter(Boolean).join(" ");
35504
+ if (text)
35505
+ return text;
35506
+ }
35507
+ return element.getAttribute("title")?.trim() ?? "";
35508
+ }
35509
+ function isOn(value) {
35510
+ return value !== null && value !== "false" && value !== "undefined";
35511
+ }
35512
+ function ariaStates(element) {
35513
+ const states = [];
35514
+ const attr = (name) => element.getAttribute(name);
35515
+ const expanded = attr("aria-expanded");
35516
+ if (expanded === "true")
35517
+ states.push("expanded");
35518
+ else if (expanded === "false")
35519
+ states.push("collapsed");
35520
+ const checked = attr("aria-checked");
35521
+ if (checked === "true")
35522
+ states.push("checked");
35523
+ else if (checked === "false")
35524
+ states.push("not checked");
35525
+ else if (checked === "mixed")
35526
+ states.push("mixed");
35527
+ else if ("checked" in element && element.checked)
35528
+ states.push("checked");
35529
+ const pressed = attr("aria-pressed");
35530
+ if (pressed === "true")
35531
+ states.push("pressed");
35532
+ else if (pressed === "false")
35533
+ states.push("not pressed");
35534
+ if (attr("aria-selected") === "true")
35535
+ states.push("selected");
35536
+ if (isOn(attr("aria-disabled")) || "disabled" in element && element.disabled) {
35537
+ states.push("disabled");
35538
+ }
35539
+ if (isOn(attr("aria-required")) || "required" in element && element.required) {
35540
+ states.push("required");
35541
+ }
35542
+ if (attr("aria-invalid") === "true")
35543
+ states.push("invalid");
35544
+ if (attr("aria-readonly") === "true")
35545
+ states.push("read only");
35546
+ const current = attr("aria-current");
35547
+ if (isOn(current))
35548
+ states.push(current === "true" ? "current" : `current ${current}`);
35549
+ const haspopup = attr("aria-haspopup");
35550
+ if (isOn(haspopup))
35551
+ states.push(haspopup === "true" ? "has popup" : `has ${haspopup} popup`);
35552
+ const level = attr("aria-level") ?? headingLevel(element);
35553
+ if (level)
35554
+ states.push(`level ${level}`);
35555
+ const posinset = attr("aria-posinset");
35556
+ const setsize = attr("aria-setsize");
35557
+ if (posinset && setsize)
35558
+ states.push(`${posinset} of ${setsize}`);
35559
+ return states;
35560
+ }
35561
+ function headingLevel(element) {
35562
+ const match = /^h([1-6])$/.exec(element.tagName.toLowerCase());
35563
+ return match ? match[1] : null;
35564
+ }
35565
+
35566
+ // dist/keyboard/walkthrough.js
35567
+ var WALKTHROUGH_MAX_STEPS = 300;
35568
+ async function linearWalkthrough(root = document, options = {}) {
35569
+ const stops = tabSequence(root, options);
35570
+ const kept = stops.slice(0, WALKTHROUGH_MAX_STEPS);
35571
+ const described = await describeElements(kept.map((s) => s.element));
35572
+ const steps = kept.map((stop, i) => ({
35573
+ order: stop.order,
35574
+ role: described[i].role,
35575
+ name: described[i].name.replace(/\s+/g, " ").trim(),
35576
+ description: described[i].description,
35577
+ states: described[i].states,
35578
+ tag: stop.element.tagName.toLowerCase(),
35579
+ positive: stop.positive,
35580
+ component: stop.component
35581
+ }));
35582
+ return { steps, total: stops.length };
35583
+ }
35584
+
35456
35585
  // dist/scan.js
35457
35586
  var runChain = Promise.resolve();
35458
35587
  function scan(root = document, options, scanOptions) {
@@ -35500,6 +35629,7 @@
35500
35629
  var run = (options, scanOptions) => scan(document, options, scanOptions);
35501
35630
  globalThis.__ngbA11yScan = run;
35502
35631
  globalThis.__ngbA11yCreateFocusProbe = (prefixes) => createFocusWalkProbe(document, prefixes);
35632
+ globalThis.__ngbA11yWalkthrough = (prefixes) => linearWalkthrough(document, { frameworkPrefixes: prefixes });
35503
35633
  })();
35504
35634
  /*! Bundled license information:
35505
35635
 
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
  /**
@@ -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 = element.ownerDocument ?? document;
31
- let role = null;
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
- const vnode = axe.utils.getNodeFromTree(element);
38
- role = axe.commons.aria.getRole(element) ?? null;
39
- name = vnode ? (axe.commons.text.accessibleTextVirtual(vnode) ?? '') : '';
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 { role, name, description: accessibleDescription(element), states: ariaStates(element) };
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) {
@@ -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',
@@ -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
- Object.assign(select.style, {
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
- panel.append(status, fieldset, severityLabel, select, download, pagesNote);
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 shown = settings.highlights ? visibleFindings(lastFindings, settings.minImpact) : [];
63
- pillView?.setStatus({ found: lastFindings.length, shown: shown.length, pages: visited.size });
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 ? { settings, onChange: setSettings, onDownload: downloadReport } : undefined,
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();
@@ -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 {
@@ -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
@@ -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
- // A keyboard trap doesn't depend on the theme; walking it twice only costs time.
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
  }
@@ -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;
@@ -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
+ }
@@ -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';
@@ -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';
@@ -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
- /** The findings to draw, given the severity filter. */
26
- export declare function visibleFindings(findings: A11yFinding[], min: MinImpact): A11yFinding[];
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
- /** The findings to draw, given the severity filter. */
16
- export function visibleFindings(findings, min) {
17
- return min === 'minor' ? findings : findings.filter((f) => meetsMinImpact(f.impact, min));
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 (no-op without a menu). */
56
- setStatus(status: PillMenuStatus): void;
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
- button.append(dot, name, state);
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: (status) => menu?.setStatus(status),
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.17.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",