ariaPropsMap.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _iterationDecorator = _interopRequireDefault(require("./util/iterationDecorator"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  9. 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."); }
  10. 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; }
  11. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  12. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  13. 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); }
  14. 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; }
  15. var properties = [['aria-activedescendant', {
  16. 'type': 'id'
  17. }], ['aria-atomic', {
  18. 'type': 'boolean'
  19. }], ['aria-autocomplete', {
  20. 'type': 'token',
  21. 'values': ['inline', 'list', 'both', 'none']
  22. }], ['aria-braillelabel', {
  23. 'type': 'string'
  24. }], ['aria-brailleroledescription', {
  25. 'type': 'string'
  26. }], ['aria-busy', {
  27. 'type': 'boolean'
  28. }], ['aria-checked', {
  29. 'type': 'tristate'
  30. }], ['aria-colcount', {
  31. type: 'integer'
  32. }], ['aria-colindex', {
  33. type: 'integer'
  34. }], ['aria-colspan', {
  35. type: 'integer'
  36. }], ['aria-controls', {
  37. 'type': 'idlist'
  38. }], ['aria-current', {
  39. type: 'token',
  40. values: ['page', 'step', 'location', 'date', 'time', true, false]
  41. }], ['aria-describedby', {
  42. 'type': 'idlist'
  43. }], ['aria-description', {
  44. 'type': 'string'
  45. }], ['aria-details', {
  46. 'type': 'id'
  47. }], ['aria-disabled', {
  48. 'type': 'boolean'
  49. }], ['aria-dropeffect', {
  50. 'type': 'tokenlist',
  51. 'values': ['copy', 'execute', 'link', 'move', 'none', 'popup']
  52. }], ['aria-errormessage', {
  53. 'type': 'id'
  54. }], ['aria-expanded', {
  55. 'type': 'boolean',
  56. 'allowundefined': true
  57. }], ['aria-flowto', {
  58. 'type': 'idlist'
  59. }], ['aria-grabbed', {
  60. 'type': 'boolean',
  61. 'allowundefined': true
  62. }], ['aria-haspopup', {
  63. 'type': 'token',
  64. 'values': [false, true, 'menu', 'listbox', 'tree', 'grid', 'dialog']
  65. }], ['aria-hidden', {
  66. 'type': 'boolean',
  67. 'allowundefined': true
  68. }], ['aria-invalid', {
  69. 'type': 'token',
  70. 'values': ['grammar', false, 'spelling', true]
  71. }], ['aria-keyshortcuts', {
  72. type: 'string'
  73. }], ['aria-label', {
  74. 'type': 'string'
  75. }], ['aria-labelledby', {
  76. 'type': 'idlist'
  77. }], ['aria-level', {
  78. 'type': 'integer'
  79. }], ['aria-live', {
  80. 'type': 'token',
  81. 'values': ['assertive', 'off', 'polite']
  82. }], ['aria-modal', {
  83. type: 'boolean'
  84. }], ['aria-multiline', {
  85. 'type': 'boolean'
  86. }], ['aria-multiselectable', {
  87. 'type': 'boolean'
  88. }], ['aria-orientation', {
  89. 'type': 'token',
  90. 'values': ['vertical', 'undefined', 'horizontal']
  91. }], ['aria-owns', {
  92. 'type': 'idlist'
  93. }], ['aria-placeholder', {
  94. type: 'string'
  95. }], ['aria-posinset', {
  96. 'type': 'integer'
  97. }], ['aria-pressed', {
  98. 'type': 'tristate'
  99. }], ['aria-readonly', {
  100. 'type': 'boolean'
  101. }], ['aria-relevant', {
  102. 'type': 'tokenlist',
  103. 'values': ['additions', 'all', 'removals', 'text']
  104. }], ['aria-required', {
  105. 'type': 'boolean'
  106. }], ['aria-roledescription', {
  107. type: 'string'
  108. }], ['aria-rowcount', {
  109. type: 'integer'
  110. }], ['aria-rowindex', {
  111. type: 'integer'
  112. }], ['aria-rowspan', {
  113. type: 'integer'
  114. }], ['aria-selected', {
  115. 'type': 'boolean',
  116. 'allowundefined': true
  117. }], ['aria-setsize', {
  118. 'type': 'integer'
  119. }], ['aria-sort', {
  120. 'type': 'token',
  121. 'values': ['ascending', 'descending', 'none', 'other']
  122. }], ['aria-valuemax', {
  123. 'type': 'number'
  124. }], ['aria-valuemin', {
  125. 'type': 'number'
  126. }], ['aria-valuenow', {
  127. 'type': 'number'
  128. }], ['aria-valuetext', {
  129. 'type': 'string'
  130. }]];
  131. var ariaPropsMap = {
  132. entries: function entries() {
  133. return properties;
  134. },
  135. forEach: function forEach(fn) {
  136. var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  137. var _iterator = _createForOfIteratorHelper(properties),
  138. _step;
  139. try {
  140. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  141. var _step$value = _slicedToArray(_step.value, 2),
  142. key = _step$value[0],
  143. values = _step$value[1];
  144. fn.call(thisArg, values, key, properties);
  145. }
  146. } catch (err) {
  147. _iterator.e(err);
  148. } finally {
  149. _iterator.f();
  150. }
  151. },
  152. get: function get(key) {
  153. var item = properties.find(function (tuple) {
  154. return tuple[0] === key ? true : false;
  155. });
  156. return item && item[1];
  157. },
  158. has: function has(key) {
  159. return !!ariaPropsMap.get(key);
  160. },
  161. keys: function keys() {
  162. return properties.map(function (_ref) {
  163. var _ref2 = _slicedToArray(_ref, 1),
  164. key = _ref2[0];
  165. return key;
  166. });
  167. },
  168. values: function values() {
  169. return properties.map(function (_ref3) {
  170. var _ref4 = _slicedToArray(_ref3, 2),
  171. values = _ref4[1];
  172. return values;
  173. });
  174. }
  175. };
  176. var _default = (0, _iterationDecorator.default)(ariaPropsMap, ariaPropsMap.entries());
  177. exports.default = _default;