@gechiui/components
Version:
UI components for GeChiUI.
47 lines (39 loc) • 1.03 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import { createElement } from "@gechiui/element";
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
/**
* Internal dependencies
*/
import { useContextSystem, contextConnect } from '../context';
import { View } from '../../view';
function Shortcut(props, forwardedRef) {
const {
as: asProp = 'span',
shortcut,
className,
...otherProps
} = useContextSystem(props, 'Shortcut');
if (!shortcut) {
return null;
}
let displayText;
let ariaLabel;
if (typeof shortcut === 'string') {
displayText = shortcut;
} else {
displayText = shortcut.display;
ariaLabel = shortcut.ariaLabel;
}
return createElement(View, _extends({
as: asProp,
className: className,
"aria-label": ariaLabel,
ref: forwardedRef
}, otherProps), displayText);
}
const ConnectedShortcut = contextConnect(Shortcut, 'Shortcut');
export default ConnectedShortcut;
//# sourceMappingURL=component.js.map