mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
new definition for "virtual-keyboard" (#18441)
* New definition for 'react-virtual-keyboard' * fixes * cleaning * delete comments and blank line * "noImplicitThis" have to be equal "true" * new definition for 'virtual-keyboard' * change files list in tsconfig.json * Expected file 'virtual-keyboard-test.ts' to be named virtual-keyboard-tests.ts * fix errors * errors * delete header * Expected '// Type definitions for ' * header * Error: At 3:60 : Expected one of * header * header * header * errors * err * err * error * global JQuery * trailing whitespace
This commit is contained in:
93
types/virtual-keyboard/index.d.ts
vendored
Normal file
93
types/virtual-keyboard/index.d.ts
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// Type definitions for virtual-keyboard 1.26
|
||||
// Project: https://www.npmjs.com/package/virtual-keyboard
|
||||
// Definitions by: Bogdan Surai <https://github.com/bsurai>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
export type kbEventHandler = (event?: Event | string, keyboard?: Element, el?: Element) => void;
|
||||
|
||||
export interface NavigateOptions {
|
||||
focusClass?: string;
|
||||
position?: number[];
|
||||
rowLooping?: boolean;
|
||||
toggleMode?: boolean;
|
||||
}
|
||||
|
||||
export interface CustomLayout {
|
||||
[index: string]: string[];
|
||||
}
|
||||
|
||||
export interface KeyboardOptions {
|
||||
type: string;
|
||||
layout?: string;
|
||||
color?: string;
|
||||
class?: string;
|
||||
updateOnChange?: boolean;
|
||||
customLayout?: CustomLayout;
|
||||
position?: boolean | object;
|
||||
reposition?: boolean;
|
||||
css?: object;
|
||||
display?: object;
|
||||
language?: string | string[];
|
||||
wheelMessage?: string;
|
||||
comboRegex?: RegExp;
|
||||
rtl?: boolean;
|
||||
acceptValid?: boolean;
|
||||
alwaysOpen?: boolean;
|
||||
appendLocally?: boolean;
|
||||
appendTo?: string | object;
|
||||
autoAccept?: boolean;
|
||||
autoAcceptOnEsc?: boolean;
|
||||
autoAcceptOnValid?: boolean;
|
||||
cancelClose?: boolean;
|
||||
caretToEnd?: boolean;
|
||||
closeByClickEvent?: boolean;
|
||||
combos?: object;
|
||||
enterMod?: string;
|
||||
enterNavigation?: boolean;
|
||||
ignoreEsc?: boolean;
|
||||
initialFocus?: boolean;
|
||||
keyBinding?: string;
|
||||
lockInput?: boolean;
|
||||
maxInsert?: boolean;
|
||||
maxLength?: boolean | number;
|
||||
noFocus?: boolean;
|
||||
openOn?: string;
|
||||
preventPaste?: string;
|
||||
repeatDelay?: number;
|
||||
repeatRate?: number;
|
||||
resetDefault?: boolean;
|
||||
restrictInclude?: string;
|
||||
restrictInput?: boolean;
|
||||
scrollAdjustment?: number | string;
|
||||
stayOpen?: boolean;
|
||||
stickyShift?: boolean;
|
||||
stopAtEnd?: boolean;
|
||||
tabNavigation?: boolean;
|
||||
useCombos?: boolean;
|
||||
usePreview?: boolean;
|
||||
useWheel?: boolean;
|
||||
userClosed?: boolean;
|
||||
accepted?: kbEventHandler;
|
||||
beforeClose?: kbEventHandler;
|
||||
beforeInsert?: kbEventHandler;
|
||||
beforeVisible?: kbEventHandler;
|
||||
buildKey?: kbEventHandler;
|
||||
canceled?: kbEventHandler;
|
||||
change?: kbEventHandler;
|
||||
hidden?: kbEventHandler;
|
||||
initialized?: kbEventHandler;
|
||||
restricted?: kbEventHandler;
|
||||
switchInput?: kbEventHandler;
|
||||
validate?: kbEventHandler;
|
||||
visible?: kbEventHandler;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface JQuery {
|
||||
keyboard(options: KeyboardOptions): this;
|
||||
addNavigation(options: NavigateOptions): this;
|
||||
}
|
||||
}
|
||||
23
types/virtual-keyboard/tsconfig.json
Normal file
23
types/virtual-keyboard/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"virtual-keyboard-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
1
types/virtual-keyboard/tslint.json
Normal file
1
types/virtual-keyboard/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
73
types/virtual-keyboard/virtual-keyboard-tests.ts
Normal file
73
types/virtual-keyboard/virtual-keyboard-tests.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import * as jQuery from "jquery";
|
||||
import { KeyboardOptions, NavigateOptions } from "virtual-keyboard";
|
||||
|
||||
const kbOptions: KeyboardOptions = {
|
||||
display: {
|
||||
bksp : "\u2190",
|
||||
accept: `Next` ,
|
||||
cancel: `Back`,
|
||||
normal: "ABC",
|
||||
meta1 : "#+-",
|
||||
space : "Space",
|
||||
alt : `Alt`,
|
||||
s : `ABC`,
|
||||
},
|
||||
acceptValid: true,
|
||||
type: "input",
|
||||
layout: "custom",
|
||||
customLayout: {
|
||||
normal: [
|
||||
`a b c d e f g h i j k l m`,
|
||||
`n o p q r s t u v x y z w`,
|
||||
`1 2 3 4 5 6 7 8 9 0 . _ @`,
|
||||
`{alt} {s} {space} {meta1} {s} {bksp} `,
|
||||
`{cancel} {accept}`
|
||||
],
|
||||
shift: [
|
||||
`A B C D E F G H I J K L M`,
|
||||
`N O P Q R S T U V X Y Z W`,
|
||||
`1 2 3 4 5 6 7 8 9 0 . _ @`,
|
||||
`{alt} {s} {space} {meta1} {s} {bksp} `,
|
||||
`{cancel} {accept}`
|
||||
],
|
||||
meta1: [
|
||||
`- / : ; ( ) \u20ac & \" ! ? ' \``,
|
||||
`[ ] { } # % ^ * + = ° ´ §`,
|
||||
` \\ | ~ < > $ \u00a3 \u00a5 , ' ² ³`,
|
||||
`{space} {meta1} {bksp}`,
|
||||
`{cancel} {accept}`
|
||||
],
|
||||
"alt-shift": [
|
||||
`A B C D E F G H I J K L M N O`,
|
||||
`P Q R S T U V X Y Z W \u00df \u00dc \u00d6 \u00c4`,
|
||||
`1 2 3 4 5 6 7 8 9 0 . _ @ \u0301`,
|
||||
`{alt} {s} {space} {meta1} {s} {bksp} `,
|
||||
`{cancel} {accept}`
|
||||
],
|
||||
alt: [
|
||||
`a b c d e f g h i j k l m n o`,
|
||||
`p q r s t u v x y z w \u00df \u00fc \u00f6 \u00e4`,
|
||||
`1 2 3 4 5 6 7 8 9 0 . _ @ \u0301`,
|
||||
`{alt} {s} {space} {meta1} {s} {bksp} `,
|
||||
`{cancel} {accept}`
|
||||
],
|
||||
},
|
||||
lockInput: true,
|
||||
alwaysOpen: true,
|
||||
appendLocally: true,
|
||||
color: "light",
|
||||
class: "sxcycx",
|
||||
updateOnChange: true,
|
||||
usePreview: false,
|
||||
tabNavigation: false,
|
||||
canceled: () => { console.log("cancelled"); }
|
||||
};
|
||||
|
||||
const navOptions: NavigateOptions = {
|
||||
position : [0, 0],
|
||||
toggleMode : true,
|
||||
focusClass : "hasFocus",
|
||||
rowLooping : true,
|
||||
};
|
||||
|
||||
jQuery("#keyboard").keyboard(kbOptions).addNavigation(navOptions);
|
||||
Reference in New Issue
Block a user