@storybook/addon-a11y 7.0.0-alpha.3 → 7.0.0-alpha.6
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.
|
@@ -58,9 +58,8 @@ const A11yContextProvider = _ref => {
|
|
|
58
58
|
const [results, setResults] = (0, _api.useAddonState)(_constants.ADDON_ID, defaultResult);
|
|
59
59
|
const [tab, setTab] = React.useState(0);
|
|
60
60
|
const [highlighted, setHighlighted] = React.useState([]);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
} = (0, _api.useStorybookState)();
|
|
61
|
+
const api = (0, _api.useStorybookApi)();
|
|
62
|
+
const storyEntry = api.getCurrentStoryData();
|
|
64
63
|
const handleToggleHighlight = React.useCallback((target, highlight) => {
|
|
65
64
|
setHighlighted(prevHighlighted => highlight ? [...prevHighlighted, ...target] : prevHighlighted.filter(t => !target.includes(t)));
|
|
66
65
|
}, []);
|
|
@@ -89,12 +88,12 @@ const A11yContextProvider = _ref => {
|
|
|
89
88
|
});
|
|
90
89
|
}, [highlighted, tab]);
|
|
91
90
|
React.useEffect(() => {
|
|
92
|
-
if (active) {
|
|
93
|
-
handleRun(
|
|
91
|
+
if (active && (storyEntry === null || storyEntry === void 0 ? void 0 : storyEntry.type) === 'story') {
|
|
92
|
+
handleRun(storyEntry.id);
|
|
94
93
|
} else {
|
|
95
94
|
handleClearHighlights();
|
|
96
95
|
}
|
|
97
|
-
}, [active, handleClearHighlights, emit,
|
|
96
|
+
}, [active, handleClearHighlights, emit, storyEntry]);
|
|
98
97
|
if (!active) return null;
|
|
99
98
|
return /*#__PURE__*/React.createElement(A11yContext.Provider, _extends({
|
|
100
99
|
value: {
|
|
@@ -6,7 +6,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
6
6
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import { themes, convert } from '@storybook/theming';
|
|
9
|
-
import { useChannel,
|
|
9
|
+
import { useChannel, useAddonState, useStorybookApi } from '@storybook/api';
|
|
10
10
|
import { STORY_CHANGED, STORY_RENDERED } from '@storybook/core-events';
|
|
11
11
|
import { ADDON_ID, EVENTS } from '../constants';
|
|
12
12
|
const colorsByType = [convert(themes.normal).color.negative, // VIOLATION,
|
|
@@ -40,9 +40,8 @@ export const A11yContextProvider = _ref => {
|
|
|
40
40
|
const [results, setResults] = useAddonState(ADDON_ID, defaultResult);
|
|
41
41
|
const [tab, setTab] = React.useState(0);
|
|
42
42
|
const [highlighted, setHighlighted] = React.useState([]);
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
} = useStorybookState();
|
|
43
|
+
const api = useStorybookApi();
|
|
44
|
+
const storyEntry = api.getCurrentStoryData();
|
|
46
45
|
const handleToggleHighlight = React.useCallback((target, highlight) => {
|
|
47
46
|
setHighlighted(prevHighlighted => highlight ? [...prevHighlighted, ...target] : prevHighlighted.filter(t => !target.includes(t)));
|
|
48
47
|
}, []);
|
|
@@ -71,12 +70,12 @@ export const A11yContextProvider = _ref => {
|
|
|
71
70
|
});
|
|
72
71
|
}, [highlighted, tab]);
|
|
73
72
|
React.useEffect(() => {
|
|
74
|
-
if (active) {
|
|
75
|
-
handleRun(
|
|
73
|
+
if (active && storyEntry?.type === 'story') {
|
|
74
|
+
handleRun(storyEntry.id);
|
|
76
75
|
} else {
|
|
77
76
|
handleClearHighlights();
|
|
78
77
|
}
|
|
79
|
-
}, [active, handleClearHighlights, emit,
|
|
78
|
+
}, [active, handleClearHighlights, emit, storyEntry]);
|
|
80
79
|
if (!active) return null;
|
|
81
80
|
return /*#__PURE__*/React.createElement(A11yContext.Provider, _extends({
|
|
82
81
|
value: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-a11y",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.6",
|
|
4
4
|
"description": "Test component compliance with web accessibility standards",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"a11y",
|
|
@@ -38,20 +38,19 @@
|
|
|
38
38
|
"prepare": "node ../../scripts/prepare.js"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
42
|
-
"@storybook/api": "7.0.0-alpha.
|
|
43
|
-
"@storybook/channels": "7.0.0-alpha.
|
|
44
|
-
"@storybook/client-logger": "7.0.0-alpha.
|
|
45
|
-
"@storybook/components": "7.0.0-alpha.
|
|
46
|
-
"@storybook/core-events": "7.0.0-alpha.
|
|
41
|
+
"@storybook/addons": "7.0.0-alpha.6",
|
|
42
|
+
"@storybook/api": "7.0.0-alpha.6",
|
|
43
|
+
"@storybook/channels": "7.0.0-alpha.6",
|
|
44
|
+
"@storybook/client-logger": "7.0.0-alpha.6",
|
|
45
|
+
"@storybook/components": "7.0.0-alpha.6",
|
|
46
|
+
"@storybook/core-events": "7.0.0-alpha.6",
|
|
47
47
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
48
|
-
"@storybook/theming": "7.0.0-alpha.
|
|
48
|
+
"@storybook/theming": "7.0.0-alpha.6",
|
|
49
49
|
"axe-core": "^4.2.0",
|
|
50
50
|
"core-js": "^3.8.2",
|
|
51
51
|
"global": "^4.4.0",
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
53
|
"react-sizeme": "^3.0.1",
|
|
54
|
-
"regenerator-runtime": "^0.13.7",
|
|
55
54
|
"ts-dedent": "^2.0.0",
|
|
56
55
|
"util-deprecate": "^1.0.2"
|
|
57
56
|
},
|
|
@@ -73,7 +72,7 @@
|
|
|
73
72
|
"publishConfig": {
|
|
74
73
|
"access": "public"
|
|
75
74
|
},
|
|
76
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "a88dcca40ba169a373bad33dd76e9a4bd4f1f5ec",
|
|
77
76
|
"storybook": {
|
|
78
77
|
"displayName": "Accessibility",
|
|
79
78
|
"icon": "https://user-images.githubusercontent.com/263385/101991665-47042f80-3c7c-11eb-8f00-64b5a18f498a.png",
|