@a11y-hud/vue 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 +26 -0
- package/dist/index.cjs +102 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +60 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +99 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
This software includes icons from Lucide (https://lucide.dev/).
|
|
26
|
+
See LICENSE-ICONS.md for details.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
var a11yHud = require('a11y-hud');
|
|
5
|
+
|
|
6
|
+
// src/component.ts
|
|
7
|
+
function useA11yHud(options = {}) {
|
|
8
|
+
const instanceRef = vue.shallowRef(null);
|
|
9
|
+
const elementRef = vue.shallowRef(null);
|
|
10
|
+
vue.onMounted(() => {
|
|
11
|
+
const { theme, autoScan, debounce } = options;
|
|
12
|
+
const instance = a11yHud.mount({
|
|
13
|
+
...theme !== void 0 && { theme },
|
|
14
|
+
...autoScan !== void 0 && { autoScan },
|
|
15
|
+
...debounce !== void 0 && { debounce }
|
|
16
|
+
});
|
|
17
|
+
instanceRef.value = instance;
|
|
18
|
+
elementRef.value = document.querySelector("a11y-hud");
|
|
19
|
+
});
|
|
20
|
+
vue.onUnmounted(() => {
|
|
21
|
+
instanceRef.value?.unmount();
|
|
22
|
+
instanceRef.value = null;
|
|
23
|
+
elementRef.value = null;
|
|
24
|
+
});
|
|
25
|
+
vue.watch(
|
|
26
|
+
() => options.theme,
|
|
27
|
+
(newTheme) => {
|
|
28
|
+
if (newTheme !== void 0) instanceRef.value?.setTheme(newTheme);
|
|
29
|
+
},
|
|
30
|
+
{ flush: "post" }
|
|
31
|
+
);
|
|
32
|
+
vue.watch(
|
|
33
|
+
() => options.autoScan,
|
|
34
|
+
(newAutoScan) => {
|
|
35
|
+
const el = elementRef.value;
|
|
36
|
+
if (!el) return;
|
|
37
|
+
if (newAutoScan === false) {
|
|
38
|
+
el.removeAttribute("auto-scan");
|
|
39
|
+
} else {
|
|
40
|
+
el.setAttribute("auto-scan", "");
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{ flush: "post" }
|
|
44
|
+
);
|
|
45
|
+
vue.watch(
|
|
46
|
+
() => options.debounce,
|
|
47
|
+
(newDebounce) => {
|
|
48
|
+
const el = elementRef.value;
|
|
49
|
+
if (!el || newDebounce === void 0) return;
|
|
50
|
+
el.setAttribute("debounce", String(newDebounce));
|
|
51
|
+
},
|
|
52
|
+
{ flush: "post" }
|
|
53
|
+
);
|
|
54
|
+
vue.watchPostEffect(() => {
|
|
55
|
+
const instance = instanceRef.value;
|
|
56
|
+
if (!instance) return;
|
|
57
|
+
const el = elementRef.value;
|
|
58
|
+
if (el) {
|
|
59
|
+
el.scopeElement = options.scope?.value ?? void 0;
|
|
60
|
+
}
|
|
61
|
+
void instance.runScan();
|
|
62
|
+
});
|
|
63
|
+
function runScan() {
|
|
64
|
+
return instanceRef.value?.runScan() ?? Promise.resolve(null);
|
|
65
|
+
}
|
|
66
|
+
function setTheme(theme) {
|
|
67
|
+
instanceRef.value?.setTheme(theme);
|
|
68
|
+
}
|
|
69
|
+
return { runScan, setTheme };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/component.ts
|
|
73
|
+
var A11yHud = vue.defineComponent({
|
|
74
|
+
name: "A11yHud",
|
|
75
|
+
props: {
|
|
76
|
+
theme: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: void 0
|
|
79
|
+
},
|
|
80
|
+
scope: {
|
|
81
|
+
type: Object,
|
|
82
|
+
default: void 0
|
|
83
|
+
},
|
|
84
|
+
autoScan: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: void 0
|
|
87
|
+
},
|
|
88
|
+
debounce: {
|
|
89
|
+
type: Number,
|
|
90
|
+
default: void 0
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
setup(props) {
|
|
94
|
+
useA11yHud(props);
|
|
95
|
+
return () => null;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
exports.A11yHud = A11yHud;
|
|
100
|
+
exports.useA11yHud = useA11yHud;
|
|
101
|
+
//# sourceMappingURL=index.cjs.map
|
|
102
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/composable.ts","../src/component.ts"],"names":["shallowRef","onMounted","mount","onUnmounted","watch","watchPostEffect","defineComponent"],"mappings":";;;;;;AAKO,SAAS,UAAA,CAAW,OAAA,GAA6B,EAAC,EAAqB;AAC5E,EAAA,MAAM,WAAA,GAAcA,eAAmC,IAAI,CAAA;AAC3D,EAAA,MAAM,UAAA,GAAaA,eAAkC,IAAI,CAAA;AAEzD,EAAAC,aAAA,CAAU,MAAM;AACd,IAAA,MAAM,EAAE,KAAA,EAAO,QAAA,EAAU,QAAA,EAAS,GAAI,OAAA;AACtC,IAAA,MAAM,WAAWC,aAAA,CAAM;AAAA,MACrB,GAAI,KAAA,KAAU,MAAA,IAAa,EAAE,KAAA,EAAM;AAAA,MACnC,GAAI,QAAA,KAAa,MAAA,IAAa,EAAE,QAAA,EAAS;AAAA,MACzC,GAAI,QAAA,KAAa,MAAA,IAAa,EAAE,QAAA;AAAS,KAC1C,CAAA;AACD,IAAA,WAAA,CAAY,KAAA,GAAQ,QAAA;AACpB,IAAA,UAAA,CAAW,KAAA,GAAQ,QAAA,CAAS,aAAA,CAA8B,UAAU,CAAA;AAAA,EACtE,CAAC,CAAA;AAED,EAAAC,eAAA,CAAY,MAAM;AAChB,IAAA,WAAA,CAAY,OAAO,OAAA,EAAQ;AAC3B,IAAA,WAAA,CAAY,KAAA,GAAQ,IAAA;AACpB,IAAA,UAAA,CAAW,KAAA,GAAQ,IAAA;AAAA,EACrB,CAAC,CAAA;AAED,EAAAC,SAAA;AAAA,IACE,MAAM,OAAA,CAAQ,KAAA;AAAA,IACd,CAAC,QAAA,KAAa;AACZ,MAAA,IAAI,QAAA,KAAa,MAAA,EAAW,WAAA,CAAY,KAAA,EAAO,SAAS,QAAQ,CAAA;AAAA,IAClE,CAAA;AAAA,IACA,EAAE,OAAO,MAAA;AAAO,GAClB;AAEA,EAAAA,SAAA;AAAA,IACE,MAAM,OAAA,CAAQ,QAAA;AAAA,IACd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,OAAO,EAAE,SAAS,QAAA,EAAS;AAC7B;;;ACvEO,IAAM,UAAUC,mBAAA,CAAgB;AAAA,EACrC,IAAA,EAAM,SAAA;AAAA,EACN,KAAA,EAAO;AAAA,IACL,KAAA,EAAO;AAAA,MACL,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA,IACA,KAAA,EAAO;AAAA,MACL,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA,IACA,QAAA,EAAU;AAAA,MACR,IAAA,EAAM,OAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA,IACA,QAAA,EAAU;AAAA,MACR,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA;AACX,GACF;AAAA,EACA,MAAM,KAAA,EAAO;AACX,IAAA,UAAA,CAAW,KAAqB,CAAA;AAChC,IAAA,OAAO,MAAM,IAAA;AAAA,EACf;AACF,CAAC","file":"index.cjs","sourcesContent":["import type { A11yHudElement, A11yHudInstance, AxeResults, Theme } from \"a11y-hud\";\nimport { mount } from \"a11y-hud\";\nimport { onMounted, onUnmounted, shallowRef, watch, watchPostEffect } from \"vue\";\nimport type { UseA11yHudOptions, UseA11yHudReturn } from \"./types.js\";\n\nexport function useA11yHud(options: UseA11yHudOptions = {}): UseA11yHudReturn {\n const instanceRef = shallowRef<A11yHudInstance | null>(null);\n const elementRef = shallowRef<A11yHudElement | null>(null);\n\n onMounted(() => {\n const { theme, autoScan, debounce } = options;\n const instance = mount({\n ...(theme !== undefined && { theme }),\n ...(autoScan !== undefined && { autoScan }),\n ...(debounce !== undefined && { debounce }),\n });\n instanceRef.value = instance;\n elementRef.value = document.querySelector<A11yHudElement>(\"a11y-hud\");\n });\n\n onUnmounted(() => {\n instanceRef.value?.unmount();\n instanceRef.value = null;\n elementRef.value = null;\n });\n\n watch(\n () => options.theme,\n (newTheme) => {\n if (newTheme !== undefined) instanceRef.value?.setTheme(newTheme);\n },\n { flush: \"post\" }\n );\n\n watch(\n () => options.autoScan,\n (newAutoScan) => {\n const el = elementRef.value;\n if (!el) return;\n if (newAutoScan === false) {\n el.removeAttribute(\"auto-scan\");\n } else {\n el.setAttribute(\"auto-scan\", \"\");\n }\n },\n { flush: \"post\" }\n );\n\n watch(\n () => options.debounce,\n (newDebounce) => {\n const el = elementRef.value;\n if (!el || newDebounce === undefined) return;\n el.setAttribute(\"debounce\", String(newDebounce));\n },\n { flush: \"post\" }\n );\n\n watchPostEffect(() => {\n const instance = instanceRef.value;\n if (!instance) return;\n const el = elementRef.value;\n if (el) {\n el.scopeElement = options.scope?.value ?? undefined;\n }\n void instance.runScan();\n });\n\n function runScan(): Promise<AxeResults> {\n return instanceRef.value?.runScan() ?? Promise.resolve(null as unknown as AxeResults);\n }\n\n function setTheme(theme: Theme): void {\n instanceRef.value?.setTheme(theme);\n }\n\n return { runScan, setTheme };\n}\n","import type { Theme } from \"a11y-hud\";\nimport type { PropType, Ref } from \"vue\";\nimport { defineComponent } from \"vue\";\nimport { useA11yHud } from \"./composable.js\";\nimport type { A11yHudProps } from \"./types.js\";\n\nexport const A11yHud = defineComponent({\n name: \"A11yHud\",\n props: {\n theme: {\n type: String as PropType<Theme>,\n default: undefined,\n },\n scope: {\n type: Object as PropType<Ref<Element | null>>,\n default: undefined,\n },\n autoScan: {\n type: Boolean as PropType<boolean>,\n default: undefined,\n },\n debounce: {\n type: Number as PropType<number>,\n default: undefined,\n },\n },\n setup(props) {\n useA11yHud(props as A11yHudProps);\n return () => null;\n },\n});\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { PropType, Ref } from 'vue';
|
|
3
|
+
import { Theme, AxeResults } from 'a11y-hud';
|
|
4
|
+
|
|
5
|
+
declare const A11yHud: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
6
|
+
theme: {
|
|
7
|
+
type: PropType<Theme>;
|
|
8
|
+
default: undefined;
|
|
9
|
+
};
|
|
10
|
+
scope: {
|
|
11
|
+
type: PropType<Ref<Element | null>>;
|
|
12
|
+
default: undefined;
|
|
13
|
+
};
|
|
14
|
+
autoScan: {
|
|
15
|
+
type: PropType<boolean>;
|
|
16
|
+
default: undefined;
|
|
17
|
+
};
|
|
18
|
+
debounce: {
|
|
19
|
+
type: PropType<number>;
|
|
20
|
+
default: undefined;
|
|
21
|
+
};
|
|
22
|
+
}>, () => null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
23
|
+
theme: {
|
|
24
|
+
type: PropType<Theme>;
|
|
25
|
+
default: undefined;
|
|
26
|
+
};
|
|
27
|
+
scope: {
|
|
28
|
+
type: PropType<Ref<Element | null>>;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
autoScan: {
|
|
32
|
+
type: PropType<boolean>;
|
|
33
|
+
default: undefined;
|
|
34
|
+
};
|
|
35
|
+
debounce: {
|
|
36
|
+
type: PropType<number>;
|
|
37
|
+
default: undefined;
|
|
38
|
+
};
|
|
39
|
+
}>> & Readonly<{}>, {
|
|
40
|
+
theme: Theme;
|
|
41
|
+
autoScan: boolean;
|
|
42
|
+
debounce: number;
|
|
43
|
+
scope: Ref<Element | null, Element | null>;
|
|
44
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
45
|
+
|
|
46
|
+
interface UseA11yHudOptions {
|
|
47
|
+
theme?: Theme;
|
|
48
|
+
scope?: Ref<Element | null>;
|
|
49
|
+
autoScan?: boolean;
|
|
50
|
+
debounce?: number;
|
|
51
|
+
}
|
|
52
|
+
type A11yHudProps = UseA11yHudOptions;
|
|
53
|
+
interface UseA11yHudReturn {
|
|
54
|
+
runScan(): Promise<AxeResults>;
|
|
55
|
+
setTheme(theme: Theme): void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare function useA11yHud(options?: UseA11yHudOptions): UseA11yHudReturn;
|
|
59
|
+
|
|
60
|
+
export { A11yHud, type A11yHudProps, type UseA11yHudOptions, type UseA11yHudReturn, useA11yHud };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { PropType, Ref } from 'vue';
|
|
3
|
+
import { Theme, AxeResults } from 'a11y-hud';
|
|
4
|
+
|
|
5
|
+
declare const A11yHud: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
6
|
+
theme: {
|
|
7
|
+
type: PropType<Theme>;
|
|
8
|
+
default: undefined;
|
|
9
|
+
};
|
|
10
|
+
scope: {
|
|
11
|
+
type: PropType<Ref<Element | null>>;
|
|
12
|
+
default: undefined;
|
|
13
|
+
};
|
|
14
|
+
autoScan: {
|
|
15
|
+
type: PropType<boolean>;
|
|
16
|
+
default: undefined;
|
|
17
|
+
};
|
|
18
|
+
debounce: {
|
|
19
|
+
type: PropType<number>;
|
|
20
|
+
default: undefined;
|
|
21
|
+
};
|
|
22
|
+
}>, () => null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
23
|
+
theme: {
|
|
24
|
+
type: PropType<Theme>;
|
|
25
|
+
default: undefined;
|
|
26
|
+
};
|
|
27
|
+
scope: {
|
|
28
|
+
type: PropType<Ref<Element | null>>;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
autoScan: {
|
|
32
|
+
type: PropType<boolean>;
|
|
33
|
+
default: undefined;
|
|
34
|
+
};
|
|
35
|
+
debounce: {
|
|
36
|
+
type: PropType<number>;
|
|
37
|
+
default: undefined;
|
|
38
|
+
};
|
|
39
|
+
}>> & Readonly<{}>, {
|
|
40
|
+
theme: Theme;
|
|
41
|
+
autoScan: boolean;
|
|
42
|
+
debounce: number;
|
|
43
|
+
scope: Ref<Element | null, Element | null>;
|
|
44
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
45
|
+
|
|
46
|
+
interface UseA11yHudOptions {
|
|
47
|
+
theme?: Theme;
|
|
48
|
+
scope?: Ref<Element | null>;
|
|
49
|
+
autoScan?: boolean;
|
|
50
|
+
debounce?: number;
|
|
51
|
+
}
|
|
52
|
+
type A11yHudProps = UseA11yHudOptions;
|
|
53
|
+
interface UseA11yHudReturn {
|
|
54
|
+
runScan(): Promise<AxeResults>;
|
|
55
|
+
setTheme(theme: Theme): void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare function useA11yHud(options?: UseA11yHudOptions): UseA11yHudReturn;
|
|
59
|
+
|
|
60
|
+
export { A11yHud, type A11yHudProps, type UseA11yHudOptions, type UseA11yHudReturn, useA11yHud };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { defineComponent, shallowRef, onMounted, onUnmounted, watch, watchPostEffect } from 'vue';
|
|
2
|
+
import { mount } from 'a11y-hud';
|
|
3
|
+
|
|
4
|
+
// src/component.ts
|
|
5
|
+
function useA11yHud(options = {}) {
|
|
6
|
+
const instanceRef = shallowRef(null);
|
|
7
|
+
const elementRef = shallowRef(null);
|
|
8
|
+
onMounted(() => {
|
|
9
|
+
const { theme, autoScan, debounce } = options;
|
|
10
|
+
const instance = mount({
|
|
11
|
+
...theme !== void 0 && { theme },
|
|
12
|
+
...autoScan !== void 0 && { autoScan },
|
|
13
|
+
...debounce !== void 0 && { debounce }
|
|
14
|
+
});
|
|
15
|
+
instanceRef.value = instance;
|
|
16
|
+
elementRef.value = document.querySelector("a11y-hud");
|
|
17
|
+
});
|
|
18
|
+
onUnmounted(() => {
|
|
19
|
+
instanceRef.value?.unmount();
|
|
20
|
+
instanceRef.value = null;
|
|
21
|
+
elementRef.value = null;
|
|
22
|
+
});
|
|
23
|
+
watch(
|
|
24
|
+
() => options.theme,
|
|
25
|
+
(newTheme) => {
|
|
26
|
+
if (newTheme !== void 0) instanceRef.value?.setTheme(newTheme);
|
|
27
|
+
},
|
|
28
|
+
{ flush: "post" }
|
|
29
|
+
);
|
|
30
|
+
watch(
|
|
31
|
+
() => options.autoScan,
|
|
32
|
+
(newAutoScan) => {
|
|
33
|
+
const el = elementRef.value;
|
|
34
|
+
if (!el) return;
|
|
35
|
+
if (newAutoScan === false) {
|
|
36
|
+
el.removeAttribute("auto-scan");
|
|
37
|
+
} else {
|
|
38
|
+
el.setAttribute("auto-scan", "");
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{ flush: "post" }
|
|
42
|
+
);
|
|
43
|
+
watch(
|
|
44
|
+
() => options.debounce,
|
|
45
|
+
(newDebounce) => {
|
|
46
|
+
const el = elementRef.value;
|
|
47
|
+
if (!el || newDebounce === void 0) return;
|
|
48
|
+
el.setAttribute("debounce", String(newDebounce));
|
|
49
|
+
},
|
|
50
|
+
{ flush: "post" }
|
|
51
|
+
);
|
|
52
|
+
watchPostEffect(() => {
|
|
53
|
+
const instance = instanceRef.value;
|
|
54
|
+
if (!instance) return;
|
|
55
|
+
const el = elementRef.value;
|
|
56
|
+
if (el) {
|
|
57
|
+
el.scopeElement = options.scope?.value ?? void 0;
|
|
58
|
+
}
|
|
59
|
+
void instance.runScan();
|
|
60
|
+
});
|
|
61
|
+
function runScan() {
|
|
62
|
+
return instanceRef.value?.runScan() ?? Promise.resolve(null);
|
|
63
|
+
}
|
|
64
|
+
function setTheme(theme) {
|
|
65
|
+
instanceRef.value?.setTheme(theme);
|
|
66
|
+
}
|
|
67
|
+
return { runScan, setTheme };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/component.ts
|
|
71
|
+
var A11yHud = defineComponent({
|
|
72
|
+
name: "A11yHud",
|
|
73
|
+
props: {
|
|
74
|
+
theme: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: void 0
|
|
77
|
+
},
|
|
78
|
+
scope: {
|
|
79
|
+
type: Object,
|
|
80
|
+
default: void 0
|
|
81
|
+
},
|
|
82
|
+
autoScan: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: void 0
|
|
85
|
+
},
|
|
86
|
+
debounce: {
|
|
87
|
+
type: Number,
|
|
88
|
+
default: void 0
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
setup(props) {
|
|
92
|
+
useA11yHud(props);
|
|
93
|
+
return () => null;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export { A11yHud, useA11yHud };
|
|
98
|
+
//# sourceMappingURL=index.js.map
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/composable.ts","../src/component.ts"],"names":[],"mappings":";;;;AAKO,SAAS,UAAA,CAAW,OAAA,GAA6B,EAAC,EAAqB;AAC5E,EAAA,MAAM,WAAA,GAAc,WAAmC,IAAI,CAAA;AAC3D,EAAA,MAAM,UAAA,GAAa,WAAkC,IAAI,CAAA;AAEzD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,EAAE,KAAA,EAAO,QAAA,EAAU,QAAA,EAAS,GAAI,OAAA;AACtC,IAAA,MAAM,WAAW,KAAA,CAAM;AAAA,MACrB,GAAI,KAAA,KAAU,MAAA,IAAa,EAAE,KAAA,EAAM;AAAA,MACnC,GAAI,QAAA,KAAa,MAAA,IAAa,EAAE,QAAA,EAAS;AAAA,MACzC,GAAI,QAAA,KAAa,MAAA,IAAa,EAAE,QAAA;AAAS,KAC1C,CAAA;AACD,IAAA,WAAA,CAAY,KAAA,GAAQ,QAAA;AACpB,IAAA,UAAA,CAAW,KAAA,GAAQ,QAAA,CAAS,aAAA,CAA8B,UAAU,CAAA;AAAA,EACtE,CAAC,CAAA;AAED,EAAA,WAAA,CAAY,MAAM;AAChB,IAAA,WAAA,CAAY,OAAO,OAAA,EAAQ;AAC3B,IAAA,WAAA,CAAY,KAAA,GAAQ,IAAA;AACpB,IAAA,UAAA,CAAW,KAAA,GAAQ,IAAA;AAAA,EACrB,CAAC,C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K,SAAS,OAAA,EAAQ;AAAA,EACxB,CAAC,CAAA;AAED,EAAA,SAAS,OAAA,GAA+B;AACtC,IAAA,OAAO,YAAY,KAAA,EAAO,OAAA,EAAQ,IAAK,OAAA,CAAQ,QAAQ,IAA6B,CAAA;AAAA,EACtF;AAEA,EAAA,SAAS,SAAS,KAAA,EAAoB;AACpC,IAAA,WAAA,CAAY,KAAA,EAAO,SAAS,KAAK,CAAA;AAAA,EACnC;AAEA,EAAA,OAAO,EAAE,SAAS,QAAA,EAAS;AAC7B;;;ACvEO,IAAM,UAAU,eAAA,CAAgB;AAAA,EACrC,IAAA,EAAM,SAAA;AAAA,EACN,KAAA,EAAO;AAAA,IACL,KAAA,EAAO;AAAA,MACL,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA,IACA,KAAA,EAAO;AAAA,MACL,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA,IACA,QAAA,EAAU;AAAA,MACR,IAAA,EAAM,OAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA,IACA,QAAA,EAAU;AAAA,MACR,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA;AACX,GACF;AAAA,EACA,MAAM,KAAA,EAAO;AACX,IAAA,UAAA,CAAW,KAAqB,CAAA;AAChC,IAAA,OAAO,MAAM,IAAA;AAAA,EACf;AACF,CAAC","file":"index.js","sourcesContent":["import type { A11yHudElement, A11yHudInstance, AxeResults, Theme } from \"a11y-hud\";\nimport { mount } from \"a11y-hud\";\nimport { onMounted, onUnmounted, shallowRef, watch, watchPostEffect } from \"vue\";\nimport type { UseA11yHudOptions, UseA11yHudReturn } from \"./types.js\";\n\nexport function useA11yHud(options: UseA11yHudOptions = {}): UseA11yHudReturn {\n const instanceRef = shallowRef<A11yHudInstance | null>(null);\n const elementRef = shallowRef<A11yHudElement | null>(null);\n\n onMounted(() => {\n const { theme, autoScan, debounce } = options;\n const instance = mount({\n ...(theme !== undefined && { theme }),\n ...(autoScan !== undefined && { autoScan }),\n ...(debounce !== undefined && { debounce }),\n });\n instanceRef.value = instance;\n elementRef.value = document.querySelector<A11yHudElement>(\"a11y-hud\");\n });\n\n onUnmounted(() => {\n instanceRef.value?.unmount();\n instanceRef.value = null;\n elementRef.value = null;\n });\n\n watch(\n () => options.theme,\n (newTheme) => {\n if (newTheme !== undefined) instanceRef.value?.setTheme(newTheme);\n },\n { flush: \"post\" }\n );\n\n watch(\n () => options.autoScan,\n (newAutoScan) => {\n const el = elementRef.value;\n if (!el) return;\n if (newAutoScan === false) {\n el.removeAttribute(\"auto-scan\");\n } else {\n el.setAttribute(\"auto-scan\", \"\");\n }\n },\n { flush: \"post\" }\n );\n\n watch(\n () => options.debounce,\n (newDebounce) => {\n const el = elementRef.value;\n if (!el || newDebounce === undefined) return;\n el.setAttribute(\"debounce\", String(newDebounce));\n },\n { flush: \"post\" }\n );\n\n watchPostEffect(() => {\n const instance = instanceRef.value;\n if (!instance) return;\n const el = elementRef.value;\n if (el) {\n el.scopeElement = options.scope?.value ?? undefined;\n }\n void instance.runScan();\n });\n\n function runScan(): Promise<AxeResults> {\n return instanceRef.value?.runScan() ?? Promise.resolve(null as unknown as AxeResults);\n }\n\n function setTheme(theme: Theme): void {\n instanceRef.value?.setTheme(theme);\n }\n\n return { runScan, setTheme };\n}\n","import type { Theme } from \"a11y-hud\";\nimport type { PropType, Ref } from \"vue\";\nimport { defineComponent } from \"vue\";\nimport { useA11yHud } from \"./composable.js\";\nimport type { A11yHudProps } from \"./types.js\";\n\nexport const A11yHud = defineComponent({\n name: \"A11yHud\",\n props: {\n theme: {\n type: String as PropType<Theme>,\n default: undefined,\n },\n scope: {\n type: Object as PropType<Ref<Element | null>>,\n default: undefined,\n },\n autoScan: {\n type: Boolean as PropType<boolean>,\n default: undefined,\n },\n debounce: {\n type: Number as PropType<number>,\n default: undefined,\n },\n },\n setup(props) {\n useA11yHud(props as A11yHudProps);\n return () => null;\n },\n});\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@a11y-hud/vue",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vue adapter for a11y-hud — run axe-core accessibility audits in your Vue app with no DevTools required.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"a11y-hud": "0.1.1"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"vue": ">=3.4"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@playwright/test": "^1.49.1",
|
|
29
|
+
"@vue/test-utils": "^2.4.6",
|
|
30
|
+
"@vitejs/plugin-vue": "^6.0.5",
|
|
31
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
32
|
+
"jsdom": "^29.1.1",
|
|
33
|
+
"tsup": "^8.3.5",
|
|
34
|
+
"vue": "^3.5.0",
|
|
35
|
+
"vitest": "^4.1.5"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=22"
|
|
39
|
+
},
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"homepage": "https://github.com/arthurvasconcelos/a11y-hud#readme",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/arthurvasconcelos/a11y-hud.git",
|
|
45
|
+
"directory": "packages/vue"
|
|
46
|
+
},
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/arthurvasconcelos/a11y-hud/issues"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"accessibility",
|
|
52
|
+
"a11y",
|
|
53
|
+
"axe",
|
|
54
|
+
"axe-core",
|
|
55
|
+
"wcag",
|
|
56
|
+
"vue",
|
|
57
|
+
"vue3",
|
|
58
|
+
"dev-tools",
|
|
59
|
+
"overlay",
|
|
60
|
+
"hud"
|
|
61
|
+
],
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsup",
|
|
64
|
+
"dev": "tsup --watch",
|
|
65
|
+
"test": "vitest run",
|
|
66
|
+
"test:watch": "vitest",
|
|
67
|
+
"test:coverage": "vitest run --coverage",
|
|
68
|
+
"test:e2e": "playwright test",
|
|
69
|
+
"typecheck": "tsc --noEmit"
|
|
70
|
+
}
|
|
71
|
+
}
|