1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- "use strict";
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
- var _ariaQuery = require("aria-query");
- var _jsxAstUtils = require("jsx-ast-utils");
- var _arrayIncludes = _interopRequireDefault(require("array-includes"));
- var roles = (0, _toConsumableArray2["default"])(_ariaQuery.roles.keys());
- var nonInteractiveRoles = roles.filter(function (name) {
- return !_ariaQuery.roles.get(name)["abstract"];
- }).filter(function (name) {
- return !_ariaQuery.roles.get(name).superClass.some(function (klasses) {
- return (0, _arrayIncludes["default"])(klasses, 'widget');
- });
- });
- var isNonInteractiveRole = function isNonInteractiveRole(tagName, attributes) {
-
-
- if (!_ariaQuery.dom.has(tagName)) {
- return false;
- }
- var role = (0, _jsxAstUtils.getLiteralPropValue)((0, _jsxAstUtils.getProp)(attributes, 'role'));
- var isNonInteractive = false;
- var normalizedValues = String(role).toLowerCase().split(' ');
- var validRoles = normalizedValues.reduce(function (accumulator, name) {
- if ((0, _arrayIncludes["default"])(roles, name)) {
- accumulator.push(name);
- }
- return accumulator;
- }, []);
- if (validRoles.length > 0) {
-
- isNonInteractive = (0, _arrayIncludes["default"])(nonInteractiveRoles, validRoles[0]);
- }
- return isNonInteractive;
- };
- var _default = isNonInteractiveRole;
- exports["default"] = _default;
|