input.js 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports["default"] = getImplicitRoleForInput;
  6. var _jsxAstUtils = require("jsx-ast-utils");
  7. /**
  8. * Returns the implicit role for an input tag.
  9. */
  10. function getImplicitRoleForInput(attributes) {
  11. var type = (0, _jsxAstUtils.getProp)(attributes, 'type');
  12. if (type) {
  13. var value = (0, _jsxAstUtils.getLiteralPropValue)(type) || '';
  14. switch (typeof value === 'string' && value.toUpperCase()) {
  15. case 'BUTTON':
  16. case 'IMAGE':
  17. case 'RESET':
  18. case 'SUBMIT':
  19. return 'button';
  20. case 'CHECKBOX':
  21. return 'checkbox';
  22. case 'RADIO':
  23. return 'radio';
  24. case 'RANGE':
  25. return 'slider';
  26. case 'EMAIL':
  27. case 'PASSWORD':
  28. case 'SEARCH': // with [list] selector it's combobox
  29. case 'TEL': // with [list] selector it's combobox
  30. case 'URL': // with [list] selector it's combobox
  31. default:
  32. return 'textbox';
  33. }
  34. }
  35. return 'textbox';
  36. }