import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; export type KbdTranslationId = "ctrl" | "control" | "alt" | "option" | "shift" | "meta" | "command" | "enter" | "return" | "escape" | "escapeName" | "tab" | "backspace" | "delete" | "forwardDelete" | "del" | "forwardDel" | "space" | "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "pageUp" | "pageDown" | "home" | "end"; type $RestProps = SvelteHTMLElements["kbd"]; type $Props = { /** * Specify the shortcut to show, such as `"mod+k"` or `"shift+?"`. `mod` * shows Command on Apple platforms and Ctrl elsewhere. Leave it empty * to show the default slot as one key. * @default "" */ shortcut?: string; /** * Specify the size of the keys. * @default "default" */ size?: "sm" | "default"; /** * Specify how the keys look: `"keycap"` boxes each key; `"muted"` runs * them together as secondary text, as menus show shortcuts: icons run * together on Apple platforms, Ctrl+Shift+P elsewhere. * @default "keycap" */ variant?: "keycap" | "muted"; /** * Set to `true` to show the keys as on an Apple platform, or `false` as * elsewhere. Unset, it follows the browser once mounted; the server renders * the keys for other platforms. */ apple?: boolean | undefined; /** * Override the default translations of the key names. Words such as * "Ctrl" are shown on the keys; names such as "Command" are read by * screen readers for the icons shown on Apple platforms. A key it * returns `undefined` for uses the nearest `setKbdTranslations`, then * English. * @default (id) => shared?.(id) ?? KBD_TRANSLATIONS[id] */ translateWithId?: (id: KbdTranslationId) => string | undefined; /** * Obtain a reference to the outer `kbd` element. * @default null */ ref?: null | HTMLElement; children?: (this: void) => void; [key: `data-${string}`]: unknown; }; export type KbdProps = Omit<$RestProps, keyof $Props> & $Props; export default class Kbd extends SvelteComponentTyped< KbdProps, Record, { default: Record } > { /** * Default translation ids */ translationIds: { ctrl: "ctrl"; control: "control"; alt: "alt"; option: "option"; shift: "shift"; meta: "meta"; command: "command"; enter: "enter"; return: "return"; escape: "escape"; escapeName: "escapeName"; tab: "tab"; backspace: "backspace"; delete: "delete"; forwardDelete: "forwardDelete"; del: "del"; forwardDel: "forwardDel"; space: "space"; arrowUp: "arrowUp"; arrowDown: "arrowDown"; arrowLeft: "arrowLeft"; arrowRight: "arrowRight"; pageUp: "pageUp"; pageDown: "pageDown"; home: "home"; end: "end" }; }