@a11y-hud/angular 0.1.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/LICENSE +21 -0
- package/README.md +132 -0
- package/dist/LICENSE +21 -0
- package/dist/README.md +132 -0
- package/dist/fesm2022/a11y-hud-angular.mjs +138 -0
- package/dist/fesm2022/a11y-hud-angular.mjs.map +1 -0
- package/dist/types/a11y-hud-angular.d.ts +50 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arthur Vasconcelos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# @a11y-hud/angular
|
|
2
|
+
|
|
3
|
+
Angular adapter for [a11y-hud](https://www.npmjs.com/package/a11y-hud) — run axe-core accessibility audits inside your Angular app with no browser extension required.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install a11y-hud @a11y-hud/angular
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `@angular/core >= 20.0.0 < 23.0.0` (Angular 20 and 21).
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Component
|
|
16
|
+
|
|
17
|
+
Drop `<a11y-hud-angular>` into your root component's template. It renders nothing into the Angular tree — the HUD panel is appended to `document.body` as a Custom Element.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { Component } from '@angular/core';
|
|
21
|
+
import { A11yHudComponent } from '@a11y-hud/angular';
|
|
22
|
+
|
|
23
|
+
@Component({
|
|
24
|
+
standalone: true,
|
|
25
|
+
imports: [A11yHudComponent],
|
|
26
|
+
template: `
|
|
27
|
+
<a11y-hud-angular [theme]="'auto'" />
|
|
28
|
+
<router-outlet />
|
|
29
|
+
`,
|
|
30
|
+
})
|
|
31
|
+
export class AppComponent {}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Service
|
|
35
|
+
|
|
36
|
+
Use `A11yHudService` when you need programmatic access to `runScan` or `setTheme`.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { Component, OnInit } from '@angular/core';
|
|
40
|
+
import { A11yHudService } from '@a11y-hud/angular';
|
|
41
|
+
|
|
42
|
+
@Component({
|
|
43
|
+
standalone: true,
|
|
44
|
+
providers: [A11yHudService],
|
|
45
|
+
template: `<button (click)="scan()">Scan now</button>`,
|
|
46
|
+
})
|
|
47
|
+
export class DevToolsComponent implements OnInit {
|
|
48
|
+
constructor(private readonly hud: A11yHudService) {}
|
|
49
|
+
|
|
50
|
+
ngOnInit() {
|
|
51
|
+
this.hud.init({ theme: 'auto' });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
scan() {
|
|
55
|
+
void this.hud.runScan();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Subtree scoping
|
|
61
|
+
|
|
62
|
+
Restrict the scan to a specific subtree by passing a template reference variable or an `ElementRef`.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { Component } from '@angular/core';
|
|
66
|
+
import { A11yHudComponent } from '@a11y-hud/angular';
|
|
67
|
+
import { RouterOutlet } from '@angular/router';
|
|
68
|
+
|
|
69
|
+
@Component({
|
|
70
|
+
standalone: true,
|
|
71
|
+
imports: [A11yHudComponent, RouterOutlet],
|
|
72
|
+
template: `
|
|
73
|
+
<a11y-hud-angular [scope]="mainRef" />
|
|
74
|
+
<main #mainRef>
|
|
75
|
+
<router-outlet />
|
|
76
|
+
</main>
|
|
77
|
+
`,
|
|
78
|
+
})
|
|
79
|
+
export class AppComponent {}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The `scope` input accepts a template reference variable (typed as `Element` by Angular's template checker), an `ElementRef<Element>` from `@ViewChild`, or `null` to restore full-page scanning.
|
|
83
|
+
|
|
84
|
+
### Route change rescans
|
|
85
|
+
|
|
86
|
+
Angular Router navigation mutates the DOM — the core's built-in `MutationObserver` picks up these changes and rescans automatically. No extra wiring needed.
|
|
87
|
+
|
|
88
|
+
If you need a manual rescan on a specific navigation event (for example, inside a `CanActivate` guard or a resolver), call `runScan()` on the component or through `A11yHudService`:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { Component, ViewChild } from '@angular/core';
|
|
92
|
+
import { Router, NavigationEnd } from '@angular/router';
|
|
93
|
+
import { A11yHudComponent } from '@a11y-hud/angular';
|
|
94
|
+
import { filter } from 'rxjs/operators';
|
|
95
|
+
|
|
96
|
+
@Component({
|
|
97
|
+
standalone: true,
|
|
98
|
+
imports: [A11yHudComponent],
|
|
99
|
+
template: `<a11y-hud-angular #hud />`,
|
|
100
|
+
})
|
|
101
|
+
export class AppComponent {
|
|
102
|
+
@ViewChild('hud') hud!: A11yHudComponent;
|
|
103
|
+
|
|
104
|
+
constructor(router: Router) {
|
|
105
|
+
router.events
|
|
106
|
+
.pipe(filter(e => e instanceof NavigationEnd))
|
|
107
|
+
.subscribe(() => this.hud.runScan());
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Inputs
|
|
113
|
+
|
|
114
|
+
| Input | Type | Default | Description |
|
|
115
|
+
|---|---|---|---|
|
|
116
|
+
| `theme` | `'auto' \| 'default' \| 'light' \| 'high-contrast'` | `'auto'` | Panel color theme |
|
|
117
|
+
| `scope` | `ElementRef<Element> \| Element \| null` | `null` | Restrict scan to this element |
|
|
118
|
+
| `autoScan` | `boolean` | `true` | Rescan on DOM mutations |
|
|
119
|
+
| `debounce` | `number` | `500` | MutationObserver debounce in ms |
|
|
120
|
+
|
|
121
|
+
## `A11yHudService` methods
|
|
122
|
+
|
|
123
|
+
| Method | Description |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `init(options?)` | Mount the HUD; call once in `ngOnInit` or `ngAfterViewInit` |
|
|
126
|
+
| `runScan()` | Trigger a manual scan, returns `Promise<AxeResults>` |
|
|
127
|
+
| `setTheme(theme)` | Switch the theme at runtime |
|
|
128
|
+
| `syncScope(scope)` | Update the scan scope |
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT © Arthur Vasconcelos
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arthur Vasconcelos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# @a11y-hud/angular
|
|
2
|
+
|
|
3
|
+
Angular adapter for [a11y-hud](https://www.npmjs.com/package/a11y-hud) — run axe-core accessibility audits inside your Angular app with no browser extension required.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install a11y-hud @a11y-hud/angular
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `@angular/core >= 20.0.0 < 23.0.0` (Angular 20 and 21).
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Component
|
|
16
|
+
|
|
17
|
+
Drop `<a11y-hud-angular>` into your root component's template. It renders nothing into the Angular tree — the HUD panel is appended to `document.body` as a Custom Element.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { Component } from '@angular/core';
|
|
21
|
+
import { A11yHudComponent } from '@a11y-hud/angular';
|
|
22
|
+
|
|
23
|
+
@Component({
|
|
24
|
+
standalone: true,
|
|
25
|
+
imports: [A11yHudComponent],
|
|
26
|
+
template: `
|
|
27
|
+
<a11y-hud-angular [theme]="'auto'" />
|
|
28
|
+
<router-outlet />
|
|
29
|
+
`,
|
|
30
|
+
})
|
|
31
|
+
export class AppComponent {}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Service
|
|
35
|
+
|
|
36
|
+
Use `A11yHudService` when you need programmatic access to `runScan` or `setTheme`.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { Component, OnInit } from '@angular/core';
|
|
40
|
+
import { A11yHudService } from '@a11y-hud/angular';
|
|
41
|
+
|
|
42
|
+
@Component({
|
|
43
|
+
standalone: true,
|
|
44
|
+
providers: [A11yHudService],
|
|
45
|
+
template: `<button (click)="scan()">Scan now</button>`,
|
|
46
|
+
})
|
|
47
|
+
export class DevToolsComponent implements OnInit {
|
|
48
|
+
constructor(private readonly hud: A11yHudService) {}
|
|
49
|
+
|
|
50
|
+
ngOnInit() {
|
|
51
|
+
this.hud.init({ theme: 'auto' });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
scan() {
|
|
55
|
+
void this.hud.runScan();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Subtree scoping
|
|
61
|
+
|
|
62
|
+
Restrict the scan to a specific subtree by passing a template reference variable or an `ElementRef`.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { Component } from '@angular/core';
|
|
66
|
+
import { A11yHudComponent } from '@a11y-hud/angular';
|
|
67
|
+
import { RouterOutlet } from '@angular/router';
|
|
68
|
+
|
|
69
|
+
@Component({
|
|
70
|
+
standalone: true,
|
|
71
|
+
imports: [A11yHudComponent, RouterOutlet],
|
|
72
|
+
template: `
|
|
73
|
+
<a11y-hud-angular [scope]="mainRef" />
|
|
74
|
+
<main #mainRef>
|
|
75
|
+
<router-outlet />
|
|
76
|
+
</main>
|
|
77
|
+
`,
|
|
78
|
+
})
|
|
79
|
+
export class AppComponent {}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The `scope` input accepts a template reference variable (typed as `Element` by Angular's template checker), an `ElementRef<Element>` from `@ViewChild`, or `null` to restore full-page scanning.
|
|
83
|
+
|
|
84
|
+
### Route change rescans
|
|
85
|
+
|
|
86
|
+
Angular Router navigation mutates the DOM — the core's built-in `MutationObserver` picks up these changes and rescans automatically. No extra wiring needed.
|
|
87
|
+
|
|
88
|
+
If you need a manual rescan on a specific navigation event (for example, inside a `CanActivate` guard or a resolver), call `runScan()` on the component or through `A11yHudService`:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { Component, ViewChild } from '@angular/core';
|
|
92
|
+
import { Router, NavigationEnd } from '@angular/router';
|
|
93
|
+
import { A11yHudComponent } from '@a11y-hud/angular';
|
|
94
|
+
import { filter } from 'rxjs/operators';
|
|
95
|
+
|
|
96
|
+
@Component({
|
|
97
|
+
standalone: true,
|
|
98
|
+
imports: [A11yHudComponent],
|
|
99
|
+
template: `<a11y-hud-angular #hud />`,
|
|
100
|
+
})
|
|
101
|
+
export class AppComponent {
|
|
102
|
+
@ViewChild('hud') hud!: A11yHudComponent;
|
|
103
|
+
|
|
104
|
+
constructor(router: Router) {
|
|
105
|
+
router.events
|
|
106
|
+
.pipe(filter(e => e instanceof NavigationEnd))
|
|
107
|
+
.subscribe(() => this.hud.runScan());
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Inputs
|
|
113
|
+
|
|
114
|
+
| Input | Type | Default | Description |
|
|
115
|
+
|---|---|---|---|
|
|
116
|
+
| `theme` | `'auto' \| 'default' \| 'light' \| 'high-contrast'` | `'auto'` | Panel color theme |
|
|
117
|
+
| `scope` | `ElementRef<Element> \| Element \| null` | `null` | Restrict scan to this element |
|
|
118
|
+
| `autoScan` | `boolean` | `true` | Rescan on DOM mutations |
|
|
119
|
+
| `debounce` | `number` | `500` | MutationObserver debounce in ms |
|
|
120
|
+
|
|
121
|
+
## `A11yHudService` methods
|
|
122
|
+
|
|
123
|
+
| Method | Description |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `init(options?)` | Mount the HUD; call once in `ngOnInit` or `ngAfterViewInit` |
|
|
126
|
+
| `runScan()` | Trigger a manual scan, returns `Promise<AxeResults>` |
|
|
127
|
+
| `setTheme(theme)` | Switch the theme at runtime |
|
|
128
|
+
| `syncScope(scope)` | Update the scan scope |
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT © Arthur Vasconcelos
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, NgZone, Injectable, Input, Component } from '@angular/core';
|
|
3
|
+
import { mount } from 'a11y-hud';
|
|
4
|
+
|
|
5
|
+
function resolveScope(scope) {
|
|
6
|
+
if (scope == null)
|
|
7
|
+
return undefined;
|
|
8
|
+
return scope instanceof Element ? scope : scope.nativeElement;
|
|
9
|
+
}
|
|
10
|
+
class A11yHudService {
|
|
11
|
+
ngZone = inject(NgZone);
|
|
12
|
+
instance = null;
|
|
13
|
+
el = null;
|
|
14
|
+
init(options = {}) {
|
|
15
|
+
const { theme, autoScan, debounce } = options;
|
|
16
|
+
this.instance = mount({
|
|
17
|
+
...(theme !== undefined && { theme }),
|
|
18
|
+
...(autoScan !== undefined && { autoScan }),
|
|
19
|
+
...(debounce !== undefined && { debounce }),
|
|
20
|
+
});
|
|
21
|
+
this.el = document.querySelector("a11y-hud");
|
|
22
|
+
if (this.el) {
|
|
23
|
+
this.el.scopeElement = resolveScope(options.scope);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
syncScope(scope) {
|
|
27
|
+
const el = this.el;
|
|
28
|
+
if (!el)
|
|
29
|
+
return;
|
|
30
|
+
el.scopeElement = resolveScope(scope);
|
|
31
|
+
}
|
|
32
|
+
syncTheme(theme) {
|
|
33
|
+
if (theme !== undefined)
|
|
34
|
+
this.instance?.setTheme(theme);
|
|
35
|
+
}
|
|
36
|
+
syncAutoScan(autoScan) {
|
|
37
|
+
const el = this.el;
|
|
38
|
+
if (!el || autoScan === undefined)
|
|
39
|
+
return;
|
|
40
|
+
if (autoScan === false) {
|
|
41
|
+
el.removeAttribute("auto-scan");
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
el.setAttribute("auto-scan", "");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
syncDebounce(debounce) {
|
|
48
|
+
const el = this.el;
|
|
49
|
+
if (!el || debounce === undefined)
|
|
50
|
+
return;
|
|
51
|
+
el.setAttribute("debounce", String(debounce));
|
|
52
|
+
}
|
|
53
|
+
runScan() {
|
|
54
|
+
return this.ngZone.runOutsideAngular(() => this.instance?.runScan() ?? Promise.resolve(null));
|
|
55
|
+
}
|
|
56
|
+
setTheme(theme) {
|
|
57
|
+
this.instance?.setTheme(theme);
|
|
58
|
+
}
|
|
59
|
+
get initialized() {
|
|
60
|
+
return this.instance !== null;
|
|
61
|
+
}
|
|
62
|
+
ngOnDestroy() {
|
|
63
|
+
this.instance?.unmount();
|
|
64
|
+
this.instance = null;
|
|
65
|
+
this.el = null;
|
|
66
|
+
}
|
|
67
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: A11yHudService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
68
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: A11yHudService });
|
|
69
|
+
}
|
|
70
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: A11yHudService, decorators: [{
|
|
71
|
+
type: Injectable
|
|
72
|
+
}] });
|
|
73
|
+
|
|
74
|
+
class A11yHudComponent {
|
|
75
|
+
theme;
|
|
76
|
+
scope = null;
|
|
77
|
+
autoScan;
|
|
78
|
+
debounce;
|
|
79
|
+
service = inject(A11yHudService);
|
|
80
|
+
ngAfterViewInit() {
|
|
81
|
+
this.service.init({
|
|
82
|
+
...(this.theme !== undefined && { theme: this.theme }),
|
|
83
|
+
scope: this.scope,
|
|
84
|
+
...(this.autoScan !== undefined && { autoScan: this.autoScan }),
|
|
85
|
+
...(this.debounce !== undefined && { debounce: this.debounce }),
|
|
86
|
+
});
|
|
87
|
+
void this.service.runScan();
|
|
88
|
+
}
|
|
89
|
+
ngOnChanges(changes) {
|
|
90
|
+
if (!this.service.initialized)
|
|
91
|
+
return;
|
|
92
|
+
if ("scope" in changes) {
|
|
93
|
+
this.service.syncScope(this.scope);
|
|
94
|
+
void this.service.runScan();
|
|
95
|
+
}
|
|
96
|
+
if ("theme" in changes) {
|
|
97
|
+
this.service.syncTheme(this.theme);
|
|
98
|
+
}
|
|
99
|
+
if ("autoScan" in changes) {
|
|
100
|
+
this.service.syncAutoScan(this.autoScan);
|
|
101
|
+
}
|
|
102
|
+
if ("debounce" in changes) {
|
|
103
|
+
this.service.syncDebounce(this.debounce);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
runScan() {
|
|
107
|
+
return this.service.runScan();
|
|
108
|
+
}
|
|
109
|
+
setTheme(theme) {
|
|
110
|
+
this.service.setTheme(theme);
|
|
111
|
+
}
|
|
112
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: A11yHudComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
113
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.11", type: A11yHudComponent, isStandalone: true, selector: "a11y-hud-angular", inputs: { theme: "theme", scope: "scope", autoScan: "autoScan", debounce: "debounce" }, providers: [A11yHudService], usesOnChanges: true, ngImport: i0, template: "", isInline: true });
|
|
114
|
+
}
|
|
115
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: A11yHudComponent, decorators: [{
|
|
116
|
+
type: Component,
|
|
117
|
+
args: [{
|
|
118
|
+
standalone: true,
|
|
119
|
+
selector: "a11y-hud-angular",
|
|
120
|
+
template: "",
|
|
121
|
+
providers: [A11yHudService],
|
|
122
|
+
}]
|
|
123
|
+
}], propDecorators: { theme: [{
|
|
124
|
+
type: Input
|
|
125
|
+
}], scope: [{
|
|
126
|
+
type: Input
|
|
127
|
+
}], autoScan: [{
|
|
128
|
+
type: Input
|
|
129
|
+
}], debounce: [{
|
|
130
|
+
type: Input
|
|
131
|
+
}] } });
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Generated bundle index. Do not edit.
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
export { A11yHudComponent, A11yHudService };
|
|
138
|
+
//# sourceMappingURL=a11y-hud-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y-hud-angular.mjs","sources":["../../src/service.ts","../../src/component.ts","../../src/a11y-hud-angular.ts"],"sourcesContent":["import { type ElementRef, Injectable, inject, NgZone, type OnDestroy } from \"@angular/core\";\nimport type { A11yHudElement, A11yHudInstance, AxeResults, Theme } from \"a11y-hud\";\nimport { mount } from \"a11y-hud\";\nimport type { ScopeInput, UseA11yHudOptions } from \"./types.js\";\n\nfunction resolveScope(scope: ScopeInput): Element | undefined {\n if (scope == null) return undefined;\n return scope instanceof Element ? scope : (scope as ElementRef<Element>).nativeElement;\n}\n\n@Injectable()\nexport class A11yHudService implements OnDestroy {\n private readonly ngZone = inject(NgZone);\n private instance: A11yHudInstance | null = null;\n private el: A11yHudElement | null = null;\n\n init(options: UseA11yHudOptions = {}): void {\n const { theme, autoScan, debounce } = options;\n this.instance = mount({\n ...(theme !== undefined && { theme }),\n ...(autoScan !== undefined && { autoScan }),\n ...(debounce !== undefined && { debounce }),\n });\n this.el = document.querySelector<A11yHudElement>(\"a11y-hud\");\n if (this.el) {\n this.el.scopeElement = resolveScope(options.scope);\n }\n }\n\n syncScope(scope: ScopeInput): void {\n const el = this.el;\n if (!el) return;\n el.scopeElement = resolveScope(scope);\n }\n\n syncTheme(theme: Theme | undefined): void {\n if (theme !== undefined) this.instance?.setTheme(theme);\n }\n\n syncAutoScan(autoScan: boolean | undefined): void {\n const el = this.el;\n if (!el || autoScan === undefined) return;\n if (autoScan === false) {\n el.removeAttribute(\"auto-scan\");\n } else {\n el.setAttribute(\"auto-scan\", \"\");\n }\n }\n\n syncDebounce(debounce: number | undefined): void {\n const el = this.el;\n if (!el || debounce === undefined) return;\n el.setAttribute(\"debounce\", String(debounce));\n }\n\n runScan(): Promise<AxeResults> {\n return this.ngZone.runOutsideAngular(\n () => this.instance?.runScan() ?? Promise.resolve(null as unknown as AxeResults)\n );\n }\n\n setTheme(theme: Theme): void {\n this.instance?.setTheme(theme);\n }\n\n get initialized(): boolean {\n return this.instance !== null;\n }\n\n ngOnDestroy(): void {\n this.instance?.unmount();\n this.instance = null;\n this.el = null;\n }\n}\n","import {\n type AfterViewInit,\n Component,\n Input,\n inject,\n type OnChanges,\n type SimpleChanges,\n} from \"@angular/core\";\nimport type { AxeResults, Theme } from \"a11y-hud\";\nimport { A11yHudService } from \"./service.js\";\nimport type { ScopeInput } from \"./types.js\";\n\n@Component({\n standalone: true,\n selector: \"a11y-hud-angular\",\n template: \"\",\n providers: [A11yHudService],\n})\nexport class A11yHudComponent implements AfterViewInit, OnChanges {\n @Input() theme?: Theme;\n @Input() scope: ScopeInput = null;\n @Input() autoScan?: boolean;\n @Input() debounce?: number;\n\n private readonly service = inject(A11yHudService);\n\n ngAfterViewInit(): void {\n this.service.init({\n ...(this.theme !== undefined && { theme: this.theme }),\n scope: this.scope,\n ...(this.autoScan !== undefined && { autoScan: this.autoScan }),\n ...(this.debounce !== undefined && { debounce: this.debounce }),\n });\n void this.service.runScan();\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (!this.service.initialized) return;\n\n if (\"scope\" in changes) {\n this.service.syncScope(this.scope);\n void this.service.runScan();\n }\n if (\"theme\" in changes) {\n this.service.syncTheme(this.theme);\n }\n if (\"autoScan\" in changes) {\n this.service.syncAutoScan(this.autoScan);\n }\n if (\"debounce\" in changes) {\n this.service.syncDebounce(this.debounce);\n }\n }\n\n runScan(): Promise<AxeResults> {\n return this.service.runScan();\n }\n\n setTheme(theme: Theme): void {\n this.service.setTheme(theme);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAKA,SAAS,YAAY,CAAC,KAAiB,EAAA;IACrC,IAAI,KAAK,IAAI,IAAI;AAAE,QAAA,OAAO,SAAS;AACnC,IAAA,OAAO,KAAK,YAAY,OAAO,GAAG,KAAK,GAAI,KAA6B,CAAC,aAAa;AACxF;MAGa,cAAc,CAAA;AACR,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAChC,QAAQ,GAA2B,IAAI;IACvC,EAAE,GAA0B,IAAI;IAExC,IAAI,CAAC,UAA6B,EAAE,EAAA;QAClC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO;AAC7C,QAAA,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACpB,IAAI,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC;YACrC,IAAI,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC3C,IAAI,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5C,SAAA,CAAC;QACF,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAiB,UAAU,CAAC;AAC5D,QAAA,IAAI,IAAI,CAAC,EAAE,EAAE;YACX,IAAI,CAAC,EAAE,CAAC,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC;QACpD;IACF;AA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cAAc,CAAC;AAC5B,iBAAA;;sBAEE;;sBACA;;sBACA;;sBACA;;;ACtBH;;AAEG;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { ElementRef, AfterViewInit, OnChanges, SimpleChanges, OnDestroy } from '@angular/core';
|
|
3
|
+
import { Theme, AxeResults } from 'a11y-hud';
|
|
4
|
+
|
|
5
|
+
type ScopeInput = ElementRef<Element> | Element | null | undefined;
|
|
6
|
+
interface UseA11yHudOptions {
|
|
7
|
+
theme?: Theme;
|
|
8
|
+
scope?: ScopeInput;
|
|
9
|
+
autoScan?: boolean;
|
|
10
|
+
debounce?: number;
|
|
11
|
+
}
|
|
12
|
+
type A11yHudProps = UseA11yHudOptions;
|
|
13
|
+
interface UseA11yHudReturn {
|
|
14
|
+
runScan(): Promise<AxeResults>;
|
|
15
|
+
setTheme(theme: Theme): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare class A11yHudComponent implements AfterViewInit, OnChanges {
|
|
19
|
+
theme?: Theme;
|
|
20
|
+
scope: ScopeInput;
|
|
21
|
+
autoScan?: boolean;
|
|
22
|
+
debounce?: number;
|
|
23
|
+
private readonly service;
|
|
24
|
+
ngAfterViewInit(): void;
|
|
25
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
26
|
+
runScan(): Promise<AxeResults>;
|
|
27
|
+
setTheme(theme: Theme): void;
|
|
28
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<A11yHudComponent, never>;
|
|
29
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<A11yHudComponent, "a11y-hud-angular", never, { "theme": { "alias": "theme"; "required": false; }; "scope": { "alias": "scope"; "required": false; }; "autoScan": { "alias": "autoScan"; "required": false; }; "debounce": { "alias": "debounce"; "required": false; }; }, {}, never, never, true, never>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare class A11yHudService implements OnDestroy {
|
|
33
|
+
private readonly ngZone;
|
|
34
|
+
private instance;
|
|
35
|
+
private el;
|
|
36
|
+
init(options?: UseA11yHudOptions): void;
|
|
37
|
+
syncScope(scope: ScopeInput): void;
|
|
38
|
+
syncTheme(theme: Theme | undefined): void;
|
|
39
|
+
syncAutoScan(autoScan: boolean | undefined): void;
|
|
40
|
+
syncDebounce(debounce: number | undefined): void;
|
|
41
|
+
runScan(): Promise<AxeResults>;
|
|
42
|
+
setTheme(theme: Theme): void;
|
|
43
|
+
get initialized(): boolean;
|
|
44
|
+
ngOnDestroy(): void;
|
|
45
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<A11yHudService, never>;
|
|
46
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<A11yHudService>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { A11yHudComponent, A11yHudService };
|
|
50
|
+
export type { A11yHudProps, ScopeInput, UseA11yHudOptions, UseA11yHudReturn };
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@a11y-hud/angular",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Angular adapter for a11y-hud — run axe-core accessibility audits in your Angular app with no DevTools required.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/types/a11y-hud-angular.d.ts",
|
|
9
|
+
"default": "./dist/fesm2022/a11y-hud-angular.mjs"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"module": "./dist/fesm2022/a11y-hud-angular.mjs",
|
|
13
|
+
"types": "./dist/types/a11y-hud-angular.d.ts",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"tslib": "^2.3.0",
|
|
22
|
+
"a11y-hud": "0.1.3"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@angular/core": ">=20.0.0 <23.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@angular/compiler": "^21.0.0",
|
|
29
|
+
"@angular/compiler-cli": "^21.0.0",
|
|
30
|
+
"@angular/core": "^21.0.0",
|
|
31
|
+
"@angular/platform-browser": "^21.0.0",
|
|
32
|
+
"@angular/platform-browser-dynamic": "^21.0.0",
|
|
33
|
+
"@playwright/test": "^1.49.1",
|
|
34
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
35
|
+
"jsdom": "^29.1.1",
|
|
36
|
+
"ng-packagr": "^21.0.0",
|
|
37
|
+
"typescript": "~5.9.0",
|
|
38
|
+
"vitest": "^4.1.5",
|
|
39
|
+
"zone.js": "^0.15.0"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=22"
|
|
43
|
+
},
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"homepage": "https://github.com/arthurvasconcelos/a11y-hud#readme",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/arthurvasconcelos/a11y-hud.git",
|
|
49
|
+
"directory": "packages/angular"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/arthurvasconcelos/a11y-hud/issues"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"accessibility",
|
|
56
|
+
"a11y",
|
|
57
|
+
"axe",
|
|
58
|
+
"axe-core",
|
|
59
|
+
"wcag",
|
|
60
|
+
"angular",
|
|
61
|
+
"dev-tools",
|
|
62
|
+
"overlay",
|
|
63
|
+
"hud"
|
|
64
|
+
],
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "ng-packagr -p ng-package.json",
|
|
67
|
+
"dev": "ng-packagr -p ng-package.json --watch",
|
|
68
|
+
"test": "vitest run",
|
|
69
|
+
"test:watch": "vitest",
|
|
70
|
+
"test:coverage": "vitest run --coverage",
|
|
71
|
+
"test:e2e": "playwright test",
|
|
72
|
+
"typecheck": "tsc --noEmit"
|
|
73
|
+
}
|
|
74
|
+
}
|