@storybook/addon-a11y 7.0.0-alpha.1 → 7.0.0-alpha.2
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/cjs/a11yHighlight.js +14 -30
- package/dist/cjs/a11yRunner.js +68 -209
- package/dist/cjs/components/A11YPanel.js +71 -122
- package/dist/cjs/components/A11yContext.js +39 -120
- package/dist/cjs/components/ColorFilters.js +53 -75
- package/dist/cjs/components/Report/Elements.js +35 -75
- package/dist/cjs/components/Report/HighlightToggle.js +20 -70
- package/dist/cjs/components/Report/Info.js +6 -9
- package/dist/cjs/components/Report/Item.js +53 -102
- package/dist/cjs/components/Report/Rules.js +30 -37
- package/dist/cjs/components/Report/Tags.js +16 -20
- package/dist/cjs/components/Report/index.js +15 -42
- package/dist/cjs/components/Tabs.js +82 -116
- package/dist/cjs/components/VisionSimulator.js +65 -131
- package/dist/cjs/constants.js +17 -17
- package/dist/cjs/highlight.js +10 -10
- package/dist/cjs/index.js +13 -19
- package/dist/cjs/manager.js +19 -23
- package/package.json +9 -9
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.array.from.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.string.iterator.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.array.iterator.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.object.to-string.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.set.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.array.join.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.array.map.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.array.concat.js");
|
|
20
|
-
|
|
21
3
|
var _global = _interopRequireDefault(require("global"));
|
|
22
4
|
|
|
23
5
|
var _addons = require("@storybook/addons");
|
|
@@ -30,30 +12,32 @@ var _highlight = require("./highlight");
|
|
|
30
12
|
|
|
31
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
14
|
|
|
33
|
-
|
|
15
|
+
const {
|
|
16
|
+
document
|
|
17
|
+
} = _global.default;
|
|
34
18
|
|
|
35
19
|
if (module && module.hot && module.hot.decline) {
|
|
36
20
|
module.hot.decline();
|
|
37
21
|
}
|
|
38
22
|
|
|
39
|
-
|
|
23
|
+
const channel = _addons.addons.getChannel();
|
|
40
24
|
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
const highlight = infos => {
|
|
26
|
+
const id = _constants.HIGHLIGHT_STYLE_ID;
|
|
43
27
|
resetHighlight(); // Make sure there are no duplicated selectors
|
|
44
28
|
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
const elements = Array.from(new Set(infos.elements));
|
|
30
|
+
const sheet = document.createElement('style');
|
|
47
31
|
sheet.setAttribute('id', id);
|
|
48
|
-
sheet.innerHTML = elements.map(
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
sheet.innerHTML = elements.map(target => `${target}{
|
|
33
|
+
${(0, _highlight.highlightStyle)(infos.color)}
|
|
34
|
+
}`).join(' ');
|
|
51
35
|
document.head.appendChild(sheet);
|
|
52
36
|
};
|
|
53
37
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
const resetHighlight = () => {
|
|
39
|
+
const id = _constants.HIGHLIGHT_STYLE_ID;
|
|
40
|
+
const sheetToBeRemoved = document.getElementById(id);
|
|
57
41
|
|
|
58
42
|
if (sheetToBeRemoved) {
|
|
59
43
|
sheetToBeRemoved.parentNode.removeChild(sheetToBeRemoved);
|
package/dist/cjs/a11yRunner.js
CHANGED
|
@@ -1,43 +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.symbol.iterator.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.array.iterator.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.string.iterator.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.symbol.async-iterator.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.symbol.to-string-tag.js");
|
|
20
|
-
|
|
21
|
-
require("core-js/modules/es.json.to-string-tag.js");
|
|
22
|
-
|
|
23
|
-
require("core-js/modules/es.math.to-string-tag.js");
|
|
24
|
-
|
|
25
|
-
require("core-js/modules/es.object.get-prototype-of.js");
|
|
26
|
-
|
|
27
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
28
|
-
|
|
29
|
-
require("core-js/modules/es.function.name.js");
|
|
30
|
-
|
|
31
|
-
require("core-js/modules/es.array.slice.js");
|
|
32
|
-
|
|
33
|
-
require("core-js/modules/es.weak-map.js");
|
|
34
|
-
|
|
35
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
36
|
-
|
|
37
|
-
require("core-js/modules/es.object.to-string.js");
|
|
38
|
-
|
|
39
|
-
require("core-js/modules/es.promise.js");
|
|
40
|
-
|
|
41
3
|
var _global = _interopRequireDefault(require("global"));
|
|
42
4
|
|
|
43
5
|
var _addons = require("@storybook/addons");
|
|
@@ -46,199 +8,96 @@ var _constants = require("./constants");
|
|
|
46
8
|
|
|
47
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
48
10
|
|
|
49
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
|
50
|
-
|
|
51
|
-
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; }
|
|
52
|
-
|
|
53
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
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); }
|
|
54
12
|
|
|
55
|
-
function
|
|
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; }
|
|
56
14
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
15
|
+
const {
|
|
16
|
+
document,
|
|
17
|
+
window: globalWindow
|
|
18
|
+
} = _global.default;
|
|
61
19
|
|
|
62
20
|
if (module && module.hot && module.hot.decline) {
|
|
63
21
|
module.hot.decline();
|
|
64
22
|
}
|
|
65
23
|
|
|
66
|
-
|
|
24
|
+
const channel = _addons.addons.getChannel(); // Holds axe core running state
|
|
67
25
|
|
|
68
26
|
|
|
69
|
-
|
|
27
|
+
let active = false; // Holds latest story we requested a run
|
|
70
28
|
|
|
71
|
-
|
|
29
|
+
let activeStoryId;
|
|
72
30
|
/**
|
|
73
31
|
* Handle A11yContext events.
|
|
74
32
|
* Because the event are sent without manual check, we split calls
|
|
75
33
|
*/
|
|
76
34
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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);
|
|
104
65
|
}
|
|
105
|
-
}, _callee);
|
|
106
|
-
}));
|
|
107
66
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var run = /*#__PURE__*/function () {
|
|
114
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(storyId) {
|
|
115
|
-
var input, axe, _input$element, element, config, _input$options, options, htmlElement, result;
|
|
116
|
-
|
|
117
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
118
|
-
while (1) {
|
|
119
|
-
switch (_context2.prev = _context2.next) {
|
|
120
|
-
case 0:
|
|
121
|
-
activeStoryId = storyId;
|
|
122
|
-
_context2.prev = 1;
|
|
123
|
-
_context2.next = 4;
|
|
124
|
-
return getParams(storyId);
|
|
125
|
-
|
|
126
|
-
case 4:
|
|
127
|
-
input = _context2.sent;
|
|
128
|
-
|
|
129
|
-
if (active) {
|
|
130
|
-
_context2.next = 19;
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
active = true;
|
|
135
|
-
channel.emit(_constants.EVENTS.RUNNING);
|
|
136
|
-
_context2.next = 10;
|
|
137
|
-
return Promise.resolve().then(function () {
|
|
138
|
-
return _interopRequireWildcard(require('axe-core'));
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
case 10:
|
|
142
|
-
axe = _context2.sent.default;
|
|
143
|
-
_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;
|
|
144
|
-
htmlElement = document.querySelector(element);
|
|
145
|
-
axe.reset();
|
|
146
|
-
|
|
147
|
-
if (config) {
|
|
148
|
-
axe.configure(config);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
_context2.next = 17;
|
|
152
|
-
return axe.run(htmlElement, options);
|
|
153
|
-
|
|
154
|
-
case 17:
|
|
155
|
-
result = _context2.sent;
|
|
156
|
-
|
|
157
|
-
// It's possible that we requested a new run on a different story.
|
|
158
|
-
// Unfortunately, axe doesn't support a cancel method to abort current run.
|
|
159
|
-
// We check if the story we run against is still the current one,
|
|
160
|
-
// if not, trigger a new run using the current story
|
|
161
|
-
if (activeStoryId === storyId) {
|
|
162
|
-
channel.emit(_constants.EVENTS.RESULT, result);
|
|
163
|
-
} else {
|
|
164
|
-
active = false;
|
|
165
|
-
run(activeStoryId);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
case 19:
|
|
169
|
-
_context2.next = 24;
|
|
170
|
-
break;
|
|
171
|
-
|
|
172
|
-
case 21:
|
|
173
|
-
_context2.prev = 21;
|
|
174
|
-
_context2.t0 = _context2["catch"](1);
|
|
175
|
-
channel.emit(_constants.EVENTS.ERROR, _context2.t0);
|
|
176
|
-
|
|
177
|
-
case 24:
|
|
178
|
-
_context2.prev = 24;
|
|
179
|
-
active = false;
|
|
180
|
-
return _context2.finish(24);
|
|
181
|
-
|
|
182
|
-
case 27:
|
|
183
|
-
case "end":
|
|
184
|
-
return _context2.stop();
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}, _callee2, null, [[1, 21, 24, 27]]);
|
|
188
|
-
}));
|
|
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
|
|
189
71
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
+
};
|
|
194
85
|
/** Returns story parameters or default ones. */
|
|
195
86
|
|
|
196
87
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
case 2:
|
|
211
|
-
_context3.t0 = _context3.sent;
|
|
212
|
-
|
|
213
|
-
if (_context3.t0) {
|
|
214
|
-
_context3.next = 5;
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
_context3.t0 = {};
|
|
219
|
-
|
|
220
|
-
case 5:
|
|
221
|
-
_ref4 = _context3.t0;
|
|
222
|
-
parameters = _ref4.parameters;
|
|
223
|
-
return _context3.abrupt("return", parameters.a11y || {
|
|
224
|
-
config: {},
|
|
225
|
-
options: {
|
|
226
|
-
restoreScroll: true
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
case 8:
|
|
231
|
-
case "end":
|
|
232
|
-
return _context3.stop();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}, _callee3);
|
|
236
|
-
}));
|
|
237
|
-
|
|
238
|
-
return function getParams(_x3) {
|
|
239
|
-
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
|
+
}
|
|
240
99
|
};
|
|
241
|
-
}
|
|
100
|
+
};
|
|
242
101
|
|
|
243
102
|
channel.on(_constants.EVENTS.REQUEST, handleRequest);
|
|
244
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
37
|
+
const Icon = (0, _theming.styled)(_components.Icons)({
|
|
80
38
|
height: 12,
|
|
81
39
|
width: 12,
|
|
82
40
|
marginRight: 4
|
|
83
41
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
73
|
+
const A11YPanel = () => {
|
|
74
|
+
const {
|
|
75
|
+
manual
|
|
76
|
+
} = (0, _api.useParameter)('a11y', {
|
|
123
77
|
manual: false
|
|
124
|
-
})
|
|
125
|
-
|
|
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
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
83
|
+
const {
|
|
84
|
+
setResults,
|
|
85
|
+
results
|
|
86
|
+
} = (0, _A11yContext.useA11yContext)();
|
|
87
|
+
const {
|
|
88
|
+
storyId
|
|
89
|
+
} = (0, _api.useStorybookState)();
|
|
140
90
|
|
|
141
|
-
|
|
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
|
-
|
|
95
|
+
const handleResult = axeResults => {
|
|
149
96
|
setStatus('ran');
|
|
150
97
|
setResults(axeResults);
|
|
151
|
-
setTimeout(
|
|
98
|
+
setTimeout(() => {
|
|
152
99
|
if (status === 'ran') {
|
|
153
100
|
setStatus('ready');
|
|
154
101
|
}
|
|
155
102
|
}, 900);
|
|
156
103
|
};
|
|
157
104
|
|
|
158
|
-
|
|
105
|
+
const handleRun = (0, _react.useCallback)(() => {
|
|
159
106
|
setStatus('running');
|
|
160
107
|
}, []);
|
|
161
|
-
|
|
108
|
+
const handleError = (0, _react.useCallback)(err => {
|
|
162
109
|
setStatus('error');
|
|
163
110
|
setError(err);
|
|
164
111
|
}, []);
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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, {
|