import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; type $RestProps = SvelteHTMLElements["li"]; type $Props = { /** * Specify the kind of item. * @default "default" */ kind?: "default" | "danger"; /** * Set to `true` to disable the item * @default false */ disabled?: boolean; /** * Specify the icon to render. * Icon is rendered to the left of the label text. */ icon?: Icon | undefined; /** * Specify the label text. * Required to nest `MenuItem` children and create a submenu: once set, * the default slot holds the nested items instead of the label. * Alternatively, use the "labelChildren" slot for custom label content; * `labelText` is still used as the accessible name and title in that case. */ labelText?: string | undefined; /** * Specify the shortcut text. * Alternatively, use the "shortcutChildren" slot. * Display only; does not register a keybinding. * @example * ```svelte * * Save: S * * ``` * @default "" */ shortcutText?: string; /** * Specify a keyboard shortcut to show, such as `"mod+s"`. `mod` is * Command on Apple platforms and Ctrl elsewhere. The keys show where * `shortcutText` goes, and the item gets `aria-keyshortcuts`. Display only: * bind the command itself with `onShortcut`, since the menu is usually * closed. `shortcutText` and its slot take precedence. A value that isn't * a shortcut, such as `"Ctrl C"`, shows as written. * @default "" */ shortcut?: string; /** * Set to `true` to select the item. * Only applies to a selectable item or one inside * `MenuItemGroup` or `MenuItemRadioGroup`. * @default false */ selected?: boolean; /** * Set to `true` to make the item a standalone checkbox. * Automatically enabled when `selected` is `true` or when the item * is inside `MenuItemGroup`. * @default false */ selectable?: boolean; /** * Specify the id. * It's recommended to provide an id as a value to bind to * within a selectable or radio menu group. * @default uniqueId() */ id?: string; /** * Obtain a reference to the list item HTML element. * @default null */ ref?: null | HTMLLIElement; labelChildren?: (this: void) => void; /** Custom shortcut content. Replaces `shortcutText` and `shortcut`. */ shortcutChildren?: (this: void) => void; children?: (this: void) => void; [key: `data-${string}`]: unknown; }; export type MenuItemProps = Omit<$RestProps, keyof $Props> & $Props; export default class MenuItem extends SvelteComponentTyped< MenuItemProps, { /** * Dispatched on selection. Cancelable: call `preventDefault()` to keep * the menu open. A selectable or radio item's selection still updates. */ click: CustomEvent; keydown: WindowEventMap["keydown"]; }, { default: Record; labelChildren: Record; /** Custom shortcut content. Replaces `shortcutText` and `shortcut`. */ shortcutChildren: Record; /** * @deprecated use the `shortcutChildren` slot */ shortcutText: Record; } > {}