UNPKG

@wordpress/components

Version:
40 lines (39 loc) • 1.09 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); let react_jsx_runtime = require("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__ */ (0, react_jsx_runtime.jsx)("span", { className, "aria-label": ariaLabel, dir: "ltr", children: displayText }); } exports.default = Shortcut; //# sourceMappingURL=index.cjs.map