123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- "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 interactiveRoles = 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');
- });
- });
- interactiveRoles.push('toolbar');
- var isInteractiveRole = function isInteractiveRole(tagName, attributes) {
- var value = (0, _jsxAstUtils.getLiteralPropValue)((0, _jsxAstUtils.getProp)(attributes, 'role'));
-
-
- if (value === undefined || value === null) {
- return false;
- }
- var isInteractive = false;
- var normalizedValues = String(value).toLowerCase().split(' ');
- var validRoles = normalizedValues.reduce(function (accumulator, name) {
- if ((0, _arrayIncludes["default"])(roles, name)) {
- accumulator.push(name);
- }
- return accumulator;
- }, []);
- if (validRoles.length > 0) {
-
- isInteractive = (0, _arrayIncludes["default"])(interactiveRoles, validRoles[0]);
- }
- return isInteractive;
- };
- var _default = isInteractiveRole;
- exports["default"] = _default;
|