mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2026-04-30 00:00:04 +08:00
Update types, tests
This commit is contained in:
+58
-2
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user