@wordpress/components
Version:
UI components for WordPress.
44 lines (36 loc) • 1 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import { createElement } from "@wordpress/element";
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
/**
* Internal dependencies
*/
import { useContextSystem, contextConnect } from '../context'; // eslint-disable-next-line no-duplicate-imports
function Shortcut(props, forwardedRef) {
const {
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("span", _extends({
className: className,
"aria-label": ariaLabel,
ref: forwardedRef
}, otherProps), displayText);
}
const ConnectedShortcut = contextConnect(Shortcut, 'Shortcut');
export default ConnectedShortcut;
//# sourceMappingURL=component.js.map