@selenite/commons
Version:
This typescript package provides a set of frequently used utilities, types and svelte actions for building projects with Typescript and Svelte.
14 lines (13 loc) • 546 B
TypeScript
import type { Action, ActionReturn } from 'svelte/action';
export {};
export declare const keyboardNavigation: Action<HTMLElement>;
type KeysHandler<E extends Element> = (e: KeyboardEvent & {
target: E;
}) => void;
type SupportedKeys = 'escape' | 'enter' | 'up' | 'left' | 'down' | 'right' | 'backspace';
type KeysParams<E extends Element> = {
[key in SupportedKeys]?: KeysHandler<E>;
} & {
preventDefault?: boolean;
};
export declare function keys<E extends HTMLElement>(node: E, params: KeysParams<E>): ActionReturn<KeysParams<E>>;