russellsamora / svelte-keyboard

Virtual keyboard component for Svelte
https://russellsamora.github.io/svelte-keyboard
MIT License
56 stars 9 forks source link

Typescript types #10

Open hmnd opened 2 years ago

hmnd commented 2 years ago

Would be awesome if this package could include proper Typescript types. Might tackle this in a PR myself if I have some time.

spectacularGavin commented 4 months ago

Here are the types that I use. You can include this in you own types declaration file

declare module 'svelte-keyboard' {
  import { SvelteComponent } from "svelte";

  export type KeyboardProps = {
    custom?: Array<{ row: number, value: string }> | null;
    localizationLayout?: 'qwerty' | 'azerty';
    layout?: 'standard' | 'crossword' | 'wordle';
    keyClass?: {
      [k: string]: string
    };
    noSwap?: string[]
  };

  export type KeyboardEvents = {
    keydown: CustomEvent<string>;
    [evt: string]: CustomEvent<any>;
  };

  export type KeyboardSlots = {};

  export default class Keyboard extends SvelteComponent<
    KeyboardProps,
    KeyboardEvents,
    KeyboardSlots
  > {
  }
}