UNPKG

@wordpress/components

Version:
56 lines (44 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _element = require("@wordpress/element"); var _lodash = require("lodash"); /** * External dependencies */ /** @typedef {string | { display: string, ariaLabel: string }} Shortcut */ /** * @typedef Props * @property {Shortcut} shortcut Shortcut configuration * @property {string} [className] Classname */ /** * @param {Props} props Props * @return {JSX.Element | null} Element */ function Shortcut({ shortcut, className }) { if (!shortcut) { return null; } let displayText; let ariaLabel; if ((0, _lodash.isString)(shortcut)) { displayText = shortcut; } if ((0, _lodash.isObject)(shortcut)) { displayText = shortcut.display; ariaLabel = shortcut.ariaLabel; } return (0, _element.createElement)("span", { className: className, "aria-label": ariaLabel }, displayText); } var _default = Shortcut; exports.default = _default; //# sourceMappingURL=index.js.map