You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2 KiB

/**
* 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.
*
*
*/
import propsToAriaRole from './propsToAriaRole';
var roleComponents = {
article: 'article',
banner: 'header',
blockquote: 'blockquote',
code: 'code',
complementary: 'aside',
contentinfo: 'footer',
deletion: 'del',
emphasis: 'em',
figure: 'figure',
insertion: 'ins',
form: 'form',
list: 'ul',
listitem: 'li',
main: 'main',
navigation: 'nav',
region: 'section',
strong: 'strong'
};
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 = propsToAriaRole(props);
if (role) {
if (role === 'heading') {
var level = props.accessibilityLevel || props['aria-level'];
if (level != null) {
return "h" + level;
}
return 'h1';
}
return roleComponents[role];
}
};
export default propsToAccessibilityComponent;