GT2/Ejectable/node_modules/react-native-web/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityCompone...

62 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-08-16 00:14:59 +00:00
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _propsToAriaRole = _interopRequireDefault(require("./propsToAriaRole"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) Nicolas Gallagher.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
var roleComponents = {
article: 'article',
banner: 'header',
complementary: 'aside',
contentinfo: 'footer',
form: 'form',
link: 'a',
list: 'ul',
listitem: 'li',
main: 'main',
navigation: 'nav',
region: 'section'
};
var emptyObject = {};
var propsToAccessibilityComponent = function propsToAccessibilityComponent(props) {
if (props === void 0) {
props = emptyObject;
}
// special-case for "label" role which doesn't map to an ARIA role
if (props.accessibilityRole === 'label') {
return 'label';
}
var role = (0, _propsToAriaRole.default)(props);
if (role) {
if (role === 'heading') {
var level = props['aria-level'];
if (level != null) {
return "h" + level;
}
return 'h1';
}
return roleComponents[role];
}
};
var _default = propsToAccessibilityComponent;
exports.default = _default;
module.exports = exports.default;