@storybook/addon-a11y 10.0.0-beta.5 → 10.0.0-beta.7
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/dist/manager.js +74 -69
- package/dist/postinstall.js +6 -6
- package/dist/preview.d.ts +50 -3
- package/package.json +3 -3
- package/dist/preview.d.tsx +0 -50
package/dist/manager.js
CHANGED
|
@@ -791,10 +791,11 @@ var A11yContextProvider = /* @__PURE__ */ __name((props) => {
|
|
|
791
791
|
useEffect(() => {
|
|
792
792
|
setStatus(getInitialStatus(manual));
|
|
793
793
|
}, [getInitialStatus, manual]);
|
|
794
|
+
const isInitial = status === "initial";
|
|
794
795
|
useEffect(() => {
|
|
795
796
|
emit(REMOVE_HIGHLIGHT, `${ADDON_ID}/selected`);
|
|
796
797
|
emit(REMOVE_HIGHLIGHT, `${ADDON_ID}/others`);
|
|
797
|
-
if (!highlighted) {
|
|
798
|
+
if (!highlighted || isInitial) {
|
|
798
799
|
return;
|
|
799
800
|
}
|
|
800
801
|
const selected = Array.from(selectedItems.values()).flatMap((key) => {
|
|
@@ -806,75 +807,79 @@ var A11yContextProvider = /* @__PURE__ */ __name((props) => {
|
|
|
806
807
|
const target = result?.nodes[Number(number) - 1]?.target;
|
|
807
808
|
return target ? [String(target)] : [];
|
|
808
809
|
});
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
810
|
+
if (selected.length) {
|
|
811
|
+
emit(HIGHLIGHT, {
|
|
812
|
+
id: `${ADDON_ID}/selected`,
|
|
813
|
+
priority: 1,
|
|
814
|
+
selectors: selected,
|
|
815
|
+
styles: {
|
|
816
|
+
outline: `1px solid color-mix(in srgb, ${colorsByType[tab]}, transparent 30%)`,
|
|
817
|
+
backgroundColor: "transparent"
|
|
818
|
+
},
|
|
819
|
+
hoverStyles: {
|
|
820
|
+
outlineWidth: "2px"
|
|
821
|
+
},
|
|
822
|
+
focusStyles: {
|
|
823
|
+
backgroundColor: "transparent"
|
|
824
|
+
},
|
|
825
|
+
menu: results?.[tab].map((result) => {
|
|
826
|
+
const selectors = result.nodes.flatMap((n) => n.target).map(String).filter((e) => selected.includes(e));
|
|
827
|
+
return [
|
|
828
|
+
{
|
|
829
|
+
id: `${tab}.${result.id}:info`,
|
|
830
|
+
title: getTitleForAxeResult(result),
|
|
831
|
+
description: getFriendlySummaryForAxeResult(result),
|
|
832
|
+
selectors
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
id: `${tab}.${result.id}`,
|
|
836
|
+
iconLeft: "info",
|
|
837
|
+
iconRight: "shareAlt",
|
|
838
|
+
title: "Learn how to resolve this violation",
|
|
839
|
+
clickEvent: EVENTS.SELECT,
|
|
840
|
+
selectors
|
|
841
|
+
}
|
|
842
|
+
];
|
|
843
|
+
})
|
|
844
|
+
});
|
|
845
|
+
}
|
|
843
846
|
const others = results?.[tab].flatMap((r) => r.nodes.flatMap((n) => n.target).map(String)).filter((e) => ![...unhighlightedSelectors, ...selected].includes(e));
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
847
|
+
if (others?.length) {
|
|
848
|
+
emit(HIGHLIGHT, {
|
|
849
|
+
id: `${ADDON_ID}/others`,
|
|
850
|
+
selectors: others,
|
|
851
|
+
styles: {
|
|
852
|
+
outline: `1px solid color-mix(in srgb, ${colorsByType[tab]}, transparent 30%)`,
|
|
853
|
+
backgroundColor: `color-mix(in srgb, ${colorsByType[tab]}, transparent 60%)`
|
|
854
|
+
},
|
|
855
|
+
hoverStyles: {
|
|
856
|
+
outlineWidth: "2px"
|
|
857
|
+
},
|
|
858
|
+
focusStyles: {
|
|
859
|
+
backgroundColor: "transparent"
|
|
860
|
+
},
|
|
861
|
+
menu: results?.[tab].map((result) => {
|
|
862
|
+
const selectors = result.nodes.flatMap((n) => n.target).map(String).filter((e) => !selected.includes(e));
|
|
863
|
+
return [
|
|
864
|
+
{
|
|
865
|
+
id: `${tab}.${result.id}:info`,
|
|
866
|
+
title: getTitleForAxeResult(result),
|
|
867
|
+
description: getFriendlySummaryForAxeResult(result),
|
|
868
|
+
selectors
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
id: `${tab}.${result.id}`,
|
|
872
|
+
iconLeft: "info",
|
|
873
|
+
iconRight: "shareAlt",
|
|
874
|
+
title: "Learn how to resolve this violation",
|
|
875
|
+
clickEvent: EVENTS.SELECT,
|
|
876
|
+
selectors
|
|
877
|
+
}
|
|
878
|
+
];
|
|
879
|
+
})
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
}, [isInitial, emit, highlighted, results, tab, selectedItems]);
|
|
878
883
|
const discrepancy = useMemo(() => {
|
|
879
884
|
if (!currentStoryA11yStatusValue) {
|
|
880
885
|
return null;
|
package/dist/postinstall.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_3o5932roygk from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_3o5932roygk from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_3o5932roygk from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_3o5932roygk.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_3o5932roygk.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_3o5932roygk.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { AfterEach } from 'storybook/internal/types';
|
|
2
|
+
import { Selector, SelectorList, RunOptions, Spec } from 'axe-core';
|
|
3
|
+
|
|
4
|
+
type SelectorWithoutNode = Omit<Selector, 'Node'> | Omit<SelectorList, 'NodeList'>;
|
|
5
|
+
type ContextObjectWithoutNode = {
|
|
6
|
+
include: SelectorWithoutNode;
|
|
7
|
+
exclude?: SelectorWithoutNode;
|
|
8
|
+
} | {
|
|
9
|
+
exclude: SelectorWithoutNode;
|
|
10
|
+
include?: SelectorWithoutNode;
|
|
11
|
+
};
|
|
12
|
+
type ContextSpecWithoutNode = SelectorWithoutNode | ContextObjectWithoutNode;
|
|
13
|
+
type A11yTest = 'off' | 'todo' | 'error';
|
|
14
|
+
interface A11yParameters {
|
|
15
|
+
/**
|
|
16
|
+
* Context parameter for axe-core's run function, except without support for passing Nodes and
|
|
17
|
+
* NodeLists directly.
|
|
18
|
+
*
|
|
19
|
+
* @see https://github.com/dequelabs/axe-core/blob/develop/doc/context.md
|
|
20
|
+
*/
|
|
21
|
+
context?: ContextSpecWithoutNode;
|
|
22
|
+
/**
|
|
23
|
+
* Options for running axe-core.
|
|
24
|
+
*
|
|
25
|
+
* @see https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#options-parameter
|
|
26
|
+
*/
|
|
27
|
+
options?: RunOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Configuration object for axe-core.
|
|
30
|
+
*
|
|
31
|
+
* @see https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axeconfigure
|
|
32
|
+
*/
|
|
33
|
+
config?: Spec;
|
|
34
|
+
/** Whether to disable accessibility tests. */
|
|
35
|
+
disable?: boolean;
|
|
36
|
+
/** Defines how accessibility violations should be handled: 'off', 'todo', or 'error'. */
|
|
37
|
+
test?: A11yTest;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare const afterEach: AfterEach<any>;
|
|
41
|
+
declare const initialGlobals: {
|
|
42
|
+
a11y: {
|
|
43
|
+
manual: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
declare const parameters: {
|
|
47
|
+
a11y: A11yParameters;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { afterEach, initialGlobals, parameters };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-a11y",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.7",
|
|
4
4
|
"description": "Storybook Addon A11y: Test UI component compliance with WCAG web accessibility standards",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"a11y",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@radix-ui/react-tabs": "1.0.4",
|
|
67
|
-
"@storybook/icons": "^1.
|
|
67
|
+
"@storybook/icons": "^1.6.0",
|
|
68
68
|
"@testing-library/react": "^14.0.0",
|
|
69
69
|
"execa": "^9.5.2",
|
|
70
70
|
"react": "^18.2.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"vitest-axe": "^0.1.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"storybook": "^10.0.0-beta.
|
|
77
|
+
"storybook": "^10.0.0-beta.7"
|
|
78
78
|
},
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
package/dist/preview.d.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { AfterEach } from 'storybook/internal/types';
|
|
2
|
-
import { Selector, SelectorList, RunOptions, Spec } from 'axe-core';
|
|
3
|
-
|
|
4
|
-
type SelectorWithoutNode = Omit<Selector, 'Node'> | Omit<SelectorList, 'NodeList'>;
|
|
5
|
-
type ContextObjectWithoutNode = {
|
|
6
|
-
include: SelectorWithoutNode;
|
|
7
|
-
exclude?: SelectorWithoutNode;
|
|
8
|
-
} | {
|
|
9
|
-
exclude: SelectorWithoutNode;
|
|
10
|
-
include?: SelectorWithoutNode;
|
|
11
|
-
};
|
|
12
|
-
type ContextSpecWithoutNode = SelectorWithoutNode | ContextObjectWithoutNode;
|
|
13
|
-
type A11yTest = 'off' | 'todo' | 'error';
|
|
14
|
-
interface A11yParameters {
|
|
15
|
-
/**
|
|
16
|
-
* Context parameter for axe-core's run function, except without support for passing Nodes and
|
|
17
|
-
* NodeLists directly.
|
|
18
|
-
*
|
|
19
|
-
* @see https://github.com/dequelabs/axe-core/blob/develop/doc/context.md
|
|
20
|
-
*/
|
|
21
|
-
context?: ContextSpecWithoutNode;
|
|
22
|
-
/**
|
|
23
|
-
* Options for running axe-core.
|
|
24
|
-
*
|
|
25
|
-
* @see https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#options-parameter
|
|
26
|
-
*/
|
|
27
|
-
options?: RunOptions;
|
|
28
|
-
/**
|
|
29
|
-
* Configuration object for axe-core.
|
|
30
|
-
*
|
|
31
|
-
* @see https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axeconfigure
|
|
32
|
-
*/
|
|
33
|
-
config?: Spec;
|
|
34
|
-
/** Whether to disable accessibility tests. */
|
|
35
|
-
disable?: boolean;
|
|
36
|
-
/** Defines how accessibility violations should be handled: 'off', 'todo', or 'error'. */
|
|
37
|
-
test?: A11yTest;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
declare const afterEach: AfterEach<any>;
|
|
41
|
-
declare const initialGlobals: {
|
|
42
|
-
a11y: {
|
|
43
|
-
manual: boolean;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
declare const parameters: {
|
|
47
|
-
a11y: A11yParameters;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { afterEach, initialGlobals, parameters };
|