UNPKG

@wordpress/components

Version:
35 lines (34 loc) • 929 B
import { jsx } from "react/jsx-runtime"; // packages/components/src/shortcut/index.tsx /** * Shortcut component is used to display keyboard shortcuts, and it can be customized with a custom display and aria label if needed. * * ```jsx * import { Shortcut } from '@wordpress/components'; * * const MyShortcut = () => { * return ( * <Shortcut shortcut={{ display: 'Ctrl + S', ariaLabel: 'Save' }} /> * ); * }; * ``` */ function Shortcut(props) { const { shortcut, className } = props; if (!shortcut) return null; let displayText; let ariaLabel; if (typeof shortcut === "string") displayText = shortcut; if (shortcut !== null && typeof shortcut === "object") { displayText = shortcut.display; ariaLabel = shortcut.ariaLabel; } return /* @__PURE__ */ jsx("span", { className, "aria-label": ariaLabel, dir: "ltr", children: displayText }); } export { Shortcut as default }; //# sourceMappingURL=index.mjs.map