@techsio/storybook-better-a11y 0.0.1

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.
Files changed (58) hide show
  1. package/AGENTS.MD +12 -0
  2. package/README.md +40 -0
  3. package/dist/100.js +122 -0
  4. package/dist/212.js +1965 -0
  5. package/dist/212.js.LICENSE.txt +19 -0
  6. package/dist/699.js +529 -0
  7. package/dist/AccessibilityRuleMaps.d.ts +9 -0
  8. package/dist/AccessibilityRuleMaps.d.ts.map +1 -0
  9. package/dist/a11yRunner.d.ts +4 -0
  10. package/dist/a11yRunner.d.ts.map +1 -0
  11. package/dist/a11yRunnerUtils.d.ts +4 -0
  12. package/dist/a11yRunnerUtils.d.ts.map +1 -0
  13. package/dist/apcaChecker.d.ts +13 -0
  14. package/dist/apcaChecker.d.ts.map +1 -0
  15. package/dist/axeRuleMappingHelper.d.ts +4 -0
  16. package/dist/axeRuleMappingHelper.d.ts.map +1 -0
  17. package/dist/components/A11YPanel.d.ts +3 -0
  18. package/dist/components/A11YPanel.d.ts.map +1 -0
  19. package/dist/components/A11yContext.d.ts +31 -0
  20. package/dist/components/A11yContext.d.ts.map +1 -0
  21. package/dist/components/Report/Details.d.ts +11 -0
  22. package/dist/components/Report/Details.d.ts.map +1 -0
  23. package/dist/components/Report/Report.d.ts +13 -0
  24. package/dist/components/Report/Report.d.ts.map +1 -0
  25. package/dist/components/Tabs.d.ts +14 -0
  26. package/dist/components/Tabs.d.ts.map +1 -0
  27. package/dist/components/TestDiscrepancyMessage.d.ts +7 -0
  28. package/dist/components/TestDiscrepancyMessage.d.ts.map +1 -0
  29. package/dist/components/VisionSimulator.d.ts +2 -0
  30. package/dist/components/VisionSimulator.d.ts.map +1 -0
  31. package/dist/constants.d.ts +19 -0
  32. package/dist/constants.d.ts.map +1 -0
  33. package/dist/index.d.ts +7 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +7 -0
  36. package/dist/manager.d.ts +2 -0
  37. package/dist/manager.d.ts.map +1 -0
  38. package/dist/manager.js +1550 -0
  39. package/dist/params.d.ts +48 -0
  40. package/dist/params.d.ts.map +1 -0
  41. package/dist/postinstall.d.ts +9 -0
  42. package/dist/postinstall.d.ts.map +1 -0
  43. package/dist/postinstall.js +21 -0
  44. package/dist/preview.d.ts +14 -0
  45. package/dist/preview.d.ts.map +1 -0
  46. package/dist/preview.js +1 -0
  47. package/dist/results.mock.d.ts +2 -0
  48. package/dist/results.mock.d.ts.map +1 -0
  49. package/dist/rslib-runtime.js +37 -0
  50. package/dist/types.d.ts +52 -0
  51. package/dist/types.d.ts.map +1 -0
  52. package/dist/utils.d.ts +3 -0
  53. package/dist/utils.d.ts.map +1 -0
  54. package/dist/visionSimulatorFilters.d.ts +7 -0
  55. package/dist/visionSimulatorFilters.d.ts.map +1 -0
  56. package/dist/withVisionSimulator.d.ts +3 -0
  57. package/dist/withVisionSimulator.d.ts.map +1 -0
  58. package/package.json +70 -0
package/AGENTS.MD ADDED
@@ -0,0 +1,12 @@
1
+ # AGENTS
2
+
3
+ ## Upstream sync policy
4
+ This addon is derived from Storybook's official `@storybook/addon-a11y`.
5
+
6
+ When Storybook releases updates to the upstream addon, we must merge or rebase:
7
+ 1. Pull upstream changes from `storybookjs/storybook` (or the tracked fork).
8
+ 2. Re-apply APCA-specific patches on top of upstream changes.
9
+ 3. Re-run unit tests and update proof screenshots.
10
+ 4. Document the upstream version in the release notes.
11
+
12
+ Keep the diff with upstream minimal to make future merges straightforward.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @techsio/storybook-better-a11y
2
+
3
+ Storybook Accessibility addon with APCA (WCAG 3) contrast checks, tuned for RsBuild/RsLib.
4
+
5
+ ## Install
6
+ ```bash
7
+ pnpm add -D @techsio/storybook-better-a11y
8
+ ```
9
+
10
+ ## Usage
11
+ ```ts
12
+ // .storybook/main.ts
13
+ export default {
14
+ addons: ['@techsio/storybook-better-a11y'],
15
+ };
16
+ ```
17
+
18
+ ```ts
19
+ // .storybook/preview.ts
20
+ export default {
21
+ parameters: {
22
+ a11y: {
23
+ options: {
24
+ runOnly: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'best-practice', 'wcag2aaa'],
25
+ },
26
+ apca: {
27
+ level: 'silver',
28
+ useCase: 'body',
29
+ },
30
+ test: 'error',
31
+ },
32
+ },
33
+ };
34
+ ```
35
+
36
+ ## APCA parameters
37
+ - `level`: `bronze | silver | gold`
38
+ - `useCase`: `body | fluent | sub-fluent | non-fluent`
39
+
40
+ You can override the use case per element using `data-apca-usecase`.
package/dist/100.js ADDED
@@ -0,0 +1,122 @@
1
+ const ADDON_ID = 'storybook/a11y';
2
+ const PANEL_ID = `${ADDON_ID}/panel`;
3
+ "a11y";
4
+ "vision";
5
+ const RESULT = `${ADDON_ID}/result`;
6
+ const REQUEST = `${ADDON_ID}/request`;
7
+ const RUNNING = `${ADDON_ID}/running`;
8
+ const ERROR = `${ADDON_ID}/error`;
9
+ const MANUAL = `${ADDON_ID}/manual`;
10
+ const SELECT = `${ADDON_ID}/select`;
11
+ const DOCUMENTATION_LINK = 'writing-tests/accessibility-testing';
12
+ const DOCUMENTATION_DISCREPANCY_LINK = `${DOCUMENTATION_LINK}#why-are-my-tests-failing-in-different-environments`;
13
+ const EVENTS = {
14
+ RESULT: RESULT,
15
+ REQUEST: REQUEST,
16
+ RUNNING: RUNNING,
17
+ ERROR: ERROR,
18
+ MANUAL: MANUAL,
19
+ SELECT: SELECT
20
+ };
21
+ const STATUS_TYPE_ID_COMPONENT_TEST = 'storybook/component-test';
22
+ const STATUS_TYPE_ID_A11Y = 'storybook/a11y';
23
+ const filters = {
24
+ blurred: {
25
+ label: 'Blurred vision',
26
+ filter: 'blur(2px)',
27
+ percentage: 22.9
28
+ },
29
+ deuteranomaly: {
30
+ label: 'Deuteranomaly',
31
+ filter: 'url("#storybook-a11y-vision-deuteranomaly")',
32
+ percentage: 2.7
33
+ },
34
+ deuteranopia: {
35
+ label: 'Deuteranopia',
36
+ filter: 'url("#storybook-a11y-vision-deuteranopia")',
37
+ percentage: 0.56
38
+ },
39
+ protanomaly: {
40
+ label: 'Protanomaly',
41
+ filter: 'url("#storybook-a11y-vision-protanomaly")',
42
+ percentage: 0.66
43
+ },
44
+ protanopia: {
45
+ label: 'Protanopia',
46
+ filter: 'url("#storybook-a11y-vision-protanopia")',
47
+ percentage: 0.59
48
+ },
49
+ tritanomaly: {
50
+ label: 'Tritanomaly',
51
+ filter: 'url("#storybook-a11y-vision-tritanomaly")',
52
+ percentage: 0.01
53
+ },
54
+ tritanopia: {
55
+ label: 'Tritanopia',
56
+ filter: 'url("#storybook-a11y-vision-tritanopia")',
57
+ percentage: 0.016
58
+ },
59
+ achromatopsia: {
60
+ label: 'Achromatopsia',
61
+ filter: 'url("#storybook-a11y-vision-achromatopsia")',
62
+ percentage: 0.0001
63
+ },
64
+ grayscale: {
65
+ label: 'Grayscale',
66
+ filter: 'grayscale(100%)'
67
+ }
68
+ };
69
+ const filterDefs = `<svg id="storybook-a11y-vision-filters" style="display: none !important;">
70
+ <defs>
71
+ <filter id="storybook-a11y-vision-protanopia">
72
+ <feColorMatrix
73
+ in="SourceGraphic"
74
+ type="matrix"
75
+ values="0.567, 0.433, 0, 0, 0 0.558, 0.442, 0, 0, 0 0, 0.242, 0.758, 0, 0 0, 0, 0, 1, 0"
76
+ />
77
+ </filter>
78
+ <filter id="storybook-a11y-vision-protanomaly">
79
+ <feColorMatrix
80
+ in="SourceGraphic"
81
+ type="matrix"
82
+ values="0.817, 0.183, 0, 0, 0 0.333, 0.667, 0, 0, 0 0, 0.125, 0.875, 0, 0 0, 0, 0, 1, 0"
83
+ />
84
+ </filter>
85
+ <filter id="storybook-a11y-vision-deuteranopia">
86
+ <feColorMatrix
87
+ in="SourceGraphic"
88
+ type="matrix"
89
+ values="0.625, 0.375, 0, 0, 0 0.7, 0.3, 0, 0, 0 0, 0.3, 0.7, 0, 0 0, 0, 0, 1, 0"
90
+ />
91
+ </filter>
92
+ <filter id="storybook-a11y-vision-deuteranomaly">
93
+ <feColorMatrix
94
+ in="SourceGraphic"
95
+ type="matrix"
96
+ values="0.8, 0.2, 0, 0, 0 0.258, 0.742, 0, 0, 0 0, 0.142, 0.858, 0, 0 0, 0, 0, 1, 0"
97
+ />
98
+ </filter>
99
+ <filter id="storybook-a11y-vision-tritanopia">
100
+ <feColorMatrix
101
+ in="SourceGraphic"
102
+ type="matrix"
103
+ values="0.95, 0.05, 0, 0, 0 0, 0.433, 0.567, 0, 0 0, 0.475, 0.525, 0, 0 0, 0, 0, 1, 0"
104
+ />
105
+ </filter>
106
+ <filter id="storybook-a11y-vision-tritanomaly">
107
+ <feColorMatrix
108
+ in="SourceGraphic"
109
+ type="matrix"
110
+ values="0.967, 0.033, 0, 0, 0 0, 0.733, 0.267, 0, 0 0, 0.183, 0.817, 0, 0 0, 0, 0, 1, 0"
111
+ />
112
+ </filter>
113
+ <filter id="storybook-a11y-vision-achromatopsia">
114
+ <feColorMatrix
115
+ in="SourceGraphic"
116
+ type="matrix"
117
+ values="0.299, 0.587, 0.114, 0, 0 0.299, 0.587, 0.114, 0, 0 0.299, 0.587, 0.114, 0, 0 0, 0, 0, 1, 0"
118
+ />
119
+ </filter>
120
+ </defs>
121
+ </svg>`;
122
+ export { ADDON_ID, DOCUMENTATION_DISCREPANCY_LINK, EVENTS, PANEL_ID, STATUS_TYPE_ID_A11Y, STATUS_TYPE_ID_COMPONENT_TEST, filterDefs, filters };