@storybook/addon-a11y 6.5.9 → 7.0.0-alpha.10

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 (100) hide show
  1. package/dist/cjs/a11yRunner.js +68 -193
  2. package/dist/cjs/components/A11YPanel.js +71 -122
  3. package/dist/cjs/components/A11yContext.js +48 -128
  4. package/dist/cjs/components/ColorFilters.js +53 -75
  5. package/dist/cjs/components/Report/Elements.js +35 -75
  6. package/dist/cjs/components/Report/HighlightToggle.js +20 -70
  7. package/dist/cjs/components/Report/Info.js +6 -9
  8. package/dist/cjs/components/Report/Item.js +53 -102
  9. package/dist/cjs/components/Report/Rules.js +30 -37
  10. package/dist/cjs/components/Report/Tags.js +16 -20
  11. package/dist/cjs/components/Report/index.js +15 -42
  12. package/dist/cjs/components/Tabs.js +82 -116
  13. package/dist/cjs/components/VisionSimulator.js +65 -131
  14. package/dist/cjs/constants.js +15 -19
  15. package/dist/cjs/index.js +12 -32
  16. package/dist/cjs/manager.js +19 -25
  17. package/dist/cjs/preview.js +1 -3
  18. package/dist/esm/a11yRunner.js +65 -168
  19. package/dist/esm/components/A11YPanel.js +65 -103
  20. package/dist/esm/components/A11yContext.js +46 -105
  21. package/dist/esm/components/ColorFilters.js +49 -51
  22. package/dist/esm/components/Report/Elements.js +34 -62
  23. package/dist/esm/components/Report/HighlightToggle.js +20 -58
  24. package/dist/esm/components/Report/Info.js +6 -7
  25. package/dist/esm/components/Report/Item.js +49 -81
  26. package/dist/esm/components/Report/Rules.js +30 -34
  27. package/dist/esm/components/Report/Tags.js +15 -18
  28. package/dist/esm/components/Report/index.js +11 -16
  29. package/dist/esm/components/Tabs.js +77 -89
  30. package/dist/esm/components/VisionSimulator.js +62 -108
  31. package/dist/esm/constants.js +14 -17
  32. package/dist/esm/index.js +10 -10
  33. package/dist/esm/manager.js +19 -25
  34. package/dist/esm/preview.js +1 -2
  35. package/dist/{ts3.9 → types}/a11yRunner.d.ts +0 -0
  36. package/dist/{ts3.9 → types}/components/A11YPanel.d.ts +0 -0
  37. package/dist/{ts3.9 → types}/components/A11yContext.d.ts +0 -0
  38. package/dist/{ts3.9 → types}/components/ColorFilters.d.ts +0 -0
  39. package/dist/{ts3.9 → types}/components/Report/Elements.d.ts +0 -0
  40. package/dist/{ts3.9 → types}/components/Report/HighlightToggle.d.ts +0 -0
  41. package/dist/{ts3.9 → types}/components/Report/Info.d.ts +0 -0
  42. package/dist/{ts3.9 → types}/components/Report/Item.d.ts +0 -0
  43. package/dist/{ts3.9 → types}/components/Report/Rules.d.ts +0 -0
  44. package/dist/{ts3.9 → types}/components/Report/Tags.d.ts +0 -0
  45. package/dist/{ts3.9 → types}/components/Report/index.d.ts +0 -0
  46. package/dist/{ts3.9 → types}/components/Tabs.d.ts +0 -0
  47. package/dist/{ts3.9 → types}/components/VisionSimulator.d.ts +0 -0
  48. package/dist/{ts3.9 → types}/constants.d.ts +0 -2
  49. package/dist/{ts3.9 → types}/index.d.ts +0 -1
  50. package/dist/{ts3.9 → types}/manager.d.ts +0 -0
  51. package/dist/{ts3.9 → types}/params.d.ts +0 -0
  52. package/dist/types/preview.d.ts +1 -0
  53. package/package.json +12 -21
  54. package/dist/cjs/a11yHighlight.js +0 -64
  55. package/dist/cjs/highlight.js +0 -22
  56. package/dist/esm/a11yHighlight.js +0 -46
  57. package/dist/esm/highlight.js +0 -10
  58. package/dist/modern/a11yHighlight.js +0 -39
  59. package/dist/modern/a11yRunner.js +0 -91
  60. package/dist/modern/components/A11YPanel.js +0 -155
  61. package/dist/modern/components/A11yContext.js +0 -93
  62. package/dist/modern/components/ColorFilters.js +0 -50
  63. package/dist/modern/components/Report/Elements.js +0 -57
  64. package/dist/modern/components/Report/HighlightToggle.js +0 -57
  65. package/dist/modern/components/Report/Info.js +0 -23
  66. package/dist/modern/components/Report/Item.js +0 -89
  67. package/dist/modern/components/Report/Rules.js +0 -95
  68. package/dist/modern/components/Report/Tags.js +0 -22
  69. package/dist/modern/components/Report/index.js +0 -14
  70. package/dist/modern/components/Tabs.js +0 -117
  71. package/dist/modern/components/VisionSimulator.js +0 -143
  72. package/dist/modern/constants.js +0 -18
  73. package/dist/modern/highlight.js +0 -10
  74. package/dist/modern/index.js +0 -21
  75. package/dist/modern/manager.js +0 -37
  76. package/dist/modern/params.js +0 -1
  77. package/dist/modern/preview.js +0 -2
  78. package/dist/ts3.4/a11yHighlight.d.ts +0 -1
  79. package/dist/ts3.4/a11yRunner.d.ts +0 -1
  80. package/dist/ts3.4/components/A11YPanel.d.ts +0 -7
  81. package/dist/ts3.4/components/A11yContext.d.ts +0 -23
  82. package/dist/ts3.4/components/ColorFilters.d.ts +0 -2
  83. package/dist/ts3.4/components/Report/Elements.d.ts +0 -9
  84. package/dist/ts3.4/components/Report/HighlightToggle.d.ts +0 -8
  85. package/dist/ts3.4/components/Report/Info.d.ts +0 -7
  86. package/dist/ts3.4/components/Report/Item.d.ts +0 -8
  87. package/dist/ts3.4/components/Report/Rules.d.ts +0 -13
  88. package/dist/ts3.4/components/Report/Tags.d.ts +0 -7
  89. package/dist/ts3.4/components/Report/index.d.ts +0 -9
  90. package/dist/ts3.4/components/Tabs.d.ts +0 -13
  91. package/dist/ts3.4/components/VisionSimulator.d.ts +0 -15
  92. package/dist/ts3.4/constants.d.ts +0 -12
  93. package/dist/ts3.4/highlight.d.ts +0 -6
  94. package/dist/ts3.4/index.d.ts +0 -5
  95. package/dist/ts3.4/manager.d.ts +0 -1
  96. package/dist/ts3.4/params.d.ts +0 -12
  97. package/dist/ts3.4/preview.d.ts +0 -2
  98. package/dist/ts3.9/a11yHighlight.d.ts +0 -1
  99. package/dist/ts3.9/highlight.d.ts +0 -6
  100. package/dist/ts3.9/preview.d.ts +0 -2
@@ -1,29 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- require("core-js/modules/es.array.iterator.js");
6
-
7
- require("core-js/modules/es.string.iterator.js");
8
-
9
- require("core-js/modules/es.weak-map.js");
10
-
11
- require("core-js/modules/web.dom-collections.iterator.js");
12
-
13
- require("core-js/modules/es.object.get-own-property-descriptor.js");
14
-
15
- require("core-js/modules/es.symbol.js");
16
-
17
- require("core-js/modules/es.symbol.description.js");
18
-
19
- require("core-js/modules/es.symbol.iterator.js");
20
-
21
- require("core-js/modules/es.object.to-string.js");
22
-
23
- require("core-js/modules/es.promise.js");
24
-
25
- require("regenerator-runtime/runtime.js");
26
-
27
3
  var _global = _interopRequireDefault(require("global"));
28
4
 
29
5
  var _addons = require("@storybook/addons");
@@ -32,197 +8,96 @@ var _constants = require("./constants");
32
8
 
33
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
10
 
35
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
36
-
37
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
38
12
 
39
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
40
14
 
41
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
42
-
43
- var document = _global.default.document,
44
- globalWindow = _global.default.window;
15
+ const {
16
+ document,
17
+ window: globalWindow
18
+ } = _global.default;
45
19
 
46
20
  if (module && module.hot && module.hot.decline) {
47
21
  module.hot.decline();
48
22
  }
49
23
 
50
- var channel = _addons.addons.getChannel(); // Holds axe core running state
24
+ const channel = _addons.addons.getChannel(); // Holds axe core running state
51
25
 
52
26
 
53
- var active = false; // Holds latest story we requested a run
27
+ let active = false; // Holds latest story we requested a run
54
28
 
55
- var activeStoryId;
29
+ let activeStoryId;
56
30
  /**
57
31
  * Handle A11yContext events.
58
32
  * Because the event are sent without manual check, we split calls
59
33
  */
60
34
 
61
- var handleRequest = /*#__PURE__*/function () {
62
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(storyId) {
63
- var _yield$getParams, manual;
64
-
65
- return regeneratorRuntime.wrap(function _callee$(_context) {
66
- while (1) {
67
- switch (_context.prev = _context.next) {
68
- case 0:
69
- _context.next = 2;
70
- return getParams(storyId);
71
-
72
- case 2:
73
- _yield$getParams = _context.sent;
74
- manual = _yield$getParams.manual;
75
-
76
- if (manual) {
77
- _context.next = 7;
78
- break;
79
- }
80
-
81
- _context.next = 7;
82
- return run(storyId);
83
-
84
- case 7:
85
- case "end":
86
- return _context.stop();
87
- }
35
+ const handleRequest = async storyId => {
36
+ const {
37
+ manual
38
+ } = await getParams(storyId);
39
+
40
+ if (!manual) {
41
+ await run(storyId);
42
+ }
43
+ };
44
+
45
+ const run = async storyId => {
46
+ activeStoryId = storyId;
47
+
48
+ try {
49
+ const input = await getParams(storyId);
50
+
51
+ if (!active) {
52
+ active = true;
53
+ channel.emit(_constants.EVENTS.RUNNING);
54
+ const axe = (await Promise.resolve().then(() => _interopRequireWildcard(require('axe-core')))).default;
55
+ const {
56
+ element = '#root',
57
+ config,
58
+ options = {}
59
+ } = input;
60
+ const htmlElement = document.querySelector(element);
61
+ axe.reset();
62
+
63
+ if (config) {
64
+ axe.configure(config);
88
65
  }
89
- }, _callee);
90
- }));
91
66
 
92
- return function handleRequest(_x) {
93
- return _ref.apply(this, arguments);
94
- };
95
- }();
96
-
97
- var run = /*#__PURE__*/function () {
98
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(storyId) {
99
- var input, axe, _input$element, element, config, _input$options, options, htmlElement, result;
100
-
101
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
102
- while (1) {
103
- switch (_context2.prev = _context2.next) {
104
- case 0:
105
- activeStoryId = storyId;
106
- _context2.prev = 1;
107
- _context2.next = 4;
108
- return getParams(storyId);
109
-
110
- case 4:
111
- input = _context2.sent;
112
-
113
- if (active) {
114
- _context2.next = 19;
115
- break;
116
- }
117
-
118
- active = true;
119
- channel.emit(_constants.EVENTS.RUNNING);
120
- _context2.next = 10;
121
- return Promise.resolve().then(function () {
122
- return _interopRequireWildcard(require('axe-core'));
123
- });
124
-
125
- case 10:
126
- axe = _context2.sent.default;
127
- _input$element = input.element, element = _input$element === void 0 ? '#root' : _input$element, config = input.config, _input$options = input.options, options = _input$options === void 0 ? {} : _input$options;
128
- htmlElement = document.querySelector(element);
129
- axe.reset();
130
-
131
- if (config) {
132
- axe.configure(config);
133
- }
134
-
135
- _context2.next = 17;
136
- return axe.run(htmlElement, options);
137
-
138
- case 17:
139
- result = _context2.sent;
140
-
141
- // It's possible that we requested a new run on a different story.
142
- // Unfortunately, axe doesn't support a cancel method to abort current run.
143
- // We check if the story we run against is still the current one,
144
- // if not, trigger a new run using the current story
145
- if (activeStoryId === storyId) {
146
- channel.emit(_constants.EVENTS.RESULT, result);
147
- } else {
148
- active = false;
149
- run(activeStoryId);
150
- }
151
-
152
- case 19:
153
- _context2.next = 24;
154
- break;
155
-
156
- case 21:
157
- _context2.prev = 21;
158
- _context2.t0 = _context2["catch"](1);
159
- channel.emit(_constants.EVENTS.ERROR, _context2.t0);
160
-
161
- case 24:
162
- _context2.prev = 24;
163
- active = false;
164
- return _context2.finish(24);
165
-
166
- case 27:
167
- case "end":
168
- return _context2.stop();
169
- }
170
- }
171
- }, _callee2, null, [[1, 21, 24, 27]]);
172
- }));
67
+ const result = await axe.run(htmlElement, options); // It's possible that we requested a new run on a different story.
68
+ // Unfortunately, axe doesn't support a cancel method to abort current run.
69
+ // We check if the story we run against is still the current one,
70
+ // if not, trigger a new run using the current story
173
71
 
174
- return function run(_x2) {
175
- return _ref2.apply(this, arguments);
176
- };
177
- }();
72
+ if (activeStoryId === storyId) {
73
+ channel.emit(_constants.EVENTS.RESULT, result);
74
+ } else {
75
+ active = false;
76
+ run(activeStoryId);
77
+ }
78
+ }
79
+ } catch (error) {
80
+ channel.emit(_constants.EVENTS.ERROR, error);
81
+ } finally {
82
+ active = false;
83
+ }
84
+ };
178
85
  /** Returns story parameters or default ones. */
179
86
 
180
87
 
181
- var getParams = /*#__PURE__*/function () {
182
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(storyId) {
183
- var _ref4, parameters;
184
-
185
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
186
- while (1) {
187
- switch (_context3.prev = _context3.next) {
188
- case 0:
189
- _context3.next = 2;
190
- return globalWindow.__STORYBOOK_STORY_STORE__.loadStory({
191
- storyId: storyId
192
- });
193
-
194
- case 2:
195
- _context3.t0 = _context3.sent;
196
-
197
- if (_context3.t0) {
198
- _context3.next = 5;
199
- break;
200
- }
201
-
202
- _context3.t0 = {};
203
-
204
- case 5:
205
- _ref4 = _context3.t0;
206
- parameters = _ref4.parameters;
207
- return _context3.abrupt("return", parameters.a11y || {
208
- config: {},
209
- options: {
210
- restoreScroll: true
211
- }
212
- });
213
-
214
- case 8:
215
- case "end":
216
- return _context3.stop();
217
- }
218
- }
219
- }, _callee3);
220
- }));
221
-
222
- return function getParams(_x3) {
223
- return _ref3.apply(this, arguments);
88
+ const getParams = async storyId => {
89
+ const {
90
+ parameters
91
+ } = (await globalWindow.__STORYBOOK_STORY_STORE__.loadStory({
92
+ storyId
93
+ })) || {};
94
+ return parameters.a11y || {
95
+ config: {},
96
+ options: {
97
+ restoreScroll: true
98
+ }
224
99
  };
225
- }();
100
+ };
226
101
 
227
102
  channel.on(_constants.EVENTS.REQUEST, handleRequest);
228
103
  channel.on(_constants.EVENTS.MANUAL, run);
@@ -1,33 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- require("core-js/modules/es.symbol.js");
6
-
7
- require("core-js/modules/es.symbol.description.js");
8
-
9
- require("core-js/modules/es.object.to-string.js");
10
-
11
- require("core-js/modules/es.symbol.iterator.js");
12
-
13
- require("core-js/modules/es.array.iterator.js");
14
-
15
- require("core-js/modules/es.string.iterator.js");
16
-
17
- require("core-js/modules/web.dom-collections.iterator.js");
18
-
19
- require("core-js/modules/es.array.slice.js");
20
-
21
- require("core-js/modules/es.function.name.js");
22
-
23
- require("core-js/modules/es.array.from.js");
24
-
25
- require("core-js/modules/es.regexp.exec.js");
26
-
27
- require("core-js/modules/es.weak-map.js");
28
-
29
- require("core-js/modules/es.object.get-own-property-descriptor.js");
30
-
31
3
  Object.defineProperty(exports, "__esModule", {
32
4
  value: true
33
5
  });
@@ -49,25 +21,11 @@ var _A11yContext = require("./A11yContext");
49
21
 
50
22
  var _constants = require("../constants");
51
23
 
52
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
53
-
54
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
55
-
56
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
57
-
58
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
59
-
60
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
61
-
62
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
63
-
64
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
24
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
65
25
 
66
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
26
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
67
27
 
68
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
69
-
70
- var RuleType;
28
+ let RuleType;
71
29
  exports.RuleType = RuleType;
72
30
 
73
31
  (function (RuleType) {
@@ -76,116 +34,107 @@ exports.RuleType = RuleType;
76
34
  RuleType[RuleType["INCOMPLETION"] = 2] = "INCOMPLETION";
77
35
  })(RuleType || (exports.RuleType = RuleType = {}));
78
36
 
79
- var Icon = (0, _theming.styled)(_components.Icons)({
37
+ const Icon = (0, _theming.styled)(_components.Icons)({
80
38
  height: 12,
81
39
  width: 12,
82
40
  marginRight: 4
83
41
  });
84
- var RotatingIcon = (0, _theming.styled)(Icon)(function (_ref) {
85
- var theme = _ref.theme;
86
- return {
87
- animation: "".concat(theme.animation.rotate360, " 1s linear infinite;")
88
- };
89
- });
90
-
91
- var Passes = _theming.styled.span(function (_ref2) {
92
- var theme = _ref2.theme;
93
- return {
94
- color: theme.color.positive
95
- };
96
- });
97
-
98
- var Violations = _theming.styled.span(function (_ref3) {
99
- var theme = _ref3.theme;
100
- return {
101
- color: theme.color.negative
102
- };
103
- });
104
-
105
- var Incomplete = _theming.styled.span(function (_ref4) {
106
- var theme = _ref4.theme;
107
- return {
108
- color: theme.color.warning
109
- };
110
- });
111
-
112
- var Centered = _theming.styled.span({
42
+ const RotatingIcon = (0, _theming.styled)(Icon)(({
43
+ theme
44
+ }) => ({
45
+ animation: `${theme.animation.rotate360} 1s linear infinite;`
46
+ }));
47
+
48
+ const Passes = _theming.styled.span(({
49
+ theme
50
+ }) => ({
51
+ color: theme.color.positive
52
+ }));
53
+
54
+ const Violations = _theming.styled.span(({
55
+ theme
56
+ }) => ({
57
+ color: theme.color.negative
58
+ }));
59
+
60
+ const Incomplete = _theming.styled.span(({
61
+ theme
62
+ }) => ({
63
+ color: theme.color.warning
64
+ }));
65
+
66
+ const Centered = _theming.styled.span({
113
67
  display: 'flex',
114
68
  alignItems: 'center',
115
69
  justifyContent: 'center',
116
70
  height: '100%'
117
71
  });
118
72
 
119
- var A11YPanel = function A11YPanel() {
120
- var _useChannel;
121
-
122
- var _useParameter = (0, _api.useParameter)('a11y', {
73
+ const A11YPanel = () => {
74
+ const {
75
+ manual
76
+ } = (0, _api.useParameter)('a11y', {
123
77
  manual: false
124
- }),
125
- manual = _useParameter.manual;
126
-
127
- var _useState = (0, _react.useState)(manual ? 'manual' : 'initial'),
128
- _useState2 = _slicedToArray(_useState, 2),
129
- status = _useState2[0],
130
- setStatus = _useState2[1];
78
+ });
79
+ const [status, setStatus] = (0, _react.useState)(manual ? 'manual' : 'initial');
131
80
 
132
- var _React$useState = _react.default.useState(undefined),
133
- _React$useState2 = _slicedToArray(_React$useState, 2),
134
- error = _React$useState2[0],
135
- setError = _React$useState2[1];
81
+ const [error, setError] = _react.default.useState(undefined);
136
82
 
137
- var _useA11yContext = (0, _A11yContext.useA11yContext)(),
138
- setResults = _useA11yContext.setResults,
139
- results = _useA11yContext.results;
83
+ const {
84
+ setResults,
85
+ results
86
+ } = (0, _A11yContext.useA11yContext)();
87
+ const {
88
+ storyId
89
+ } = (0, _api.useStorybookState)();
140
90
 
141
- var _useStorybookState = (0, _api.useStorybookState)(),
142
- storyId = _useStorybookState.storyId;
143
-
144
- _react.default.useEffect(function () {
91
+ _react.default.useEffect(() => {
145
92
  setStatus(manual ? 'manual' : 'initial');
146
93
  }, [manual]);
147
94
 
148
- var handleResult = function handleResult(axeResults) {
95
+ const handleResult = axeResults => {
149
96
  setStatus('ran');
150
97
  setResults(axeResults);
151
- setTimeout(function () {
98
+ setTimeout(() => {
152
99
  if (status === 'ran') {
153
100
  setStatus('ready');
154
101
  }
155
102
  }, 900);
156
103
  };
157
104
 
158
- var handleRun = (0, _react.useCallback)(function () {
105
+ const handleRun = (0, _react.useCallback)(() => {
159
106
  setStatus('running');
160
107
  }, []);
161
- var handleError = (0, _react.useCallback)(function (err) {
108
+ const handleError = (0, _react.useCallback)(err => {
162
109
  setStatus('error');
163
110
  setError(err);
164
111
  }, []);
165
- var emit = (0, _api.useChannel)((_useChannel = {}, _defineProperty(_useChannel, _constants.EVENTS.RUNNING, handleRun), _defineProperty(_useChannel, _constants.EVENTS.RESULT, handleResult), _defineProperty(_useChannel, _constants.EVENTS.ERROR, handleError), _useChannel));
166
- var handleManual = (0, _react.useCallback)(function () {
112
+ const emit = (0, _api.useChannel)({
113
+ [_constants.EVENTS.RUNNING]: handleRun,
114
+ [_constants.EVENTS.RESULT]: handleResult,
115
+ [_constants.EVENTS.ERROR]: handleError
116
+ });
117
+ const handleManual = (0, _react.useCallback)(() => {
167
118
  setStatus('running');
168
119
  emit(_constants.EVENTS.MANUAL, storyId);
169
120
  }, [storyId]);
170
- var manualActionItems = (0, _react.useMemo)(function () {
171
- return [{
172
- title: 'Run test',
173
- onClick: handleManual
174
- }];
175
- }, [handleManual]);
176
- var readyActionItems = (0, _react.useMemo)(function () {
177
- return [{
178
- title: status === 'ready' ? 'Rerun tests' : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Icon, {
179
- inline: true,
180
- icon: "check"
181
- }), " Tests completed"),
182
- onClick: handleManual
183
- }];
184
- }, [status, handleManual]);
185
- var tabs = (0, _react.useMemo)(function () {
186
- var passes = results.passes,
187
- incomplete = results.incomplete,
188
- violations = results.violations;
121
+ const manualActionItems = (0, _react.useMemo)(() => [{
122
+ title: 'Run test',
123
+ onClick: handleManual
124
+ }], [handleManual]);
125
+ const readyActionItems = (0, _react.useMemo)(() => [{
126
+ title: status === 'ready' ? 'Rerun tests' : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Icon, {
127
+ inline: true,
128
+ icon: "check"
129
+ }), " Tests completed"),
130
+ onClick: handleManual
131
+ }], [status, handleManual]);
132
+ const tabs = (0, _react.useMemo)(() => {
133
+ const {
134
+ passes,
135
+ incomplete,
136
+ violations
137
+ } = results;
189
138
  return [{
190
139
  label: /*#__PURE__*/_react.default.createElement(Violations, null, violations.length, " Violations"),
191
140
  panel: /*#__PURE__*/_react.default.createElement(_Report.Report, {