Update types, tests

This commit is contained in:
Francisco Hodge
2021-03-16 00:40:23 -04:00
parent 8ba81892fe
commit cae07749f4
33 changed files with 1392 additions and 957 deletions
+58 -2
View File
@@ -1,3 +1,7 @@
/* eslint-disable no-unused-vars */
import SimpleKeyboard from "./components/Keyboard";
import Utilities from "./services/Utilities";
export interface KeyboardLayoutObject {
[key: string]: string[];
}
@@ -17,11 +21,33 @@ export interface KeyboardInput {
[key: string]: string
}
export type KeyboardButton = HTMLDivElement | HTMLButtonElement;
export type KeyboardParams = [KeyboardOptions] | [string | HTMLDivElement, KeyboardOptions];
export type CandidateBoxParams = {
utilities: Utilities
}
export type CandidateBoxShowParams = {
candidateValue: string,
targetElement: KeyboardElement,
// eslint-disable-next-line no-unused-vars
onSelect: (selectedCandidate: string) => void
}
export type CandidateBoxRenderParams = {
candidateListPages: string[][],
targetElement: KeyboardElement,
pageIndex: number;
nbPages: number;
// eslint-disable-next-line no-unused-vars
onItemSelected: (selectedCandidate: string) => void
}
export type KeyboardElement = HTMLDivElement | HTMLButtonElement;
export type KeyboardHandlerEvent = PointerEvent & TouchEvent & KeyboardEvent & { target: HTMLDivElement | HTMLInputElement };
export interface KeyboardButtonElements {
[key: string]: KeyboardButton[]
[key: string]: KeyboardElement[]
}
export interface UtilitiesParams {
@@ -179,6 +205,36 @@ export interface KeyboardOptions {
*/
rtl?: boolean;
/**
* Enable input method editor candidate list support.
*/
enableLayoutCandidates?: boolean;
/**
* Character suggestions to be shown on certain key presses
*/
layoutCandidates?: { [key: string]: string };
/**
* Exclude buttons from layout
*/
excludeFromLayout?: { [key: string]: string[] };
/**
* Determine size of layout candidate list
*/
layoutCandidatesPageSize?: number;
/**
* Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
*/
onRender?: (instance?: SimpleKeyboard) => void;
/**
* Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
*/
onInit?: (instance?: SimpleKeyboard) => void;
/**
* Module options can have any format
*/