diff --git a/types/tingle.js/index.d.ts b/types/tingle.js/index.d.ts new file mode 100644 index 0000000000..30c04b9342 --- /dev/null +++ b/types/tingle.js/index.d.ts @@ -0,0 +1,36 @@ +// Type definitions for tingle.js 0.13 +// Project: https://github.com/robinparisi/tingle#readme +// Definitions by: Klaus Meinhardt +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export interface Options { + onOpen?: (this: modal) => void; + onClose?: (this: modal) => void; + beforeOpen?: () => void; + beforeClose?: (this: modal) => boolean | undefined; + stickyFooter?: boolean; + footer?: boolean; + cssClass?: string[]; + closeLabel?: string; + closeMethods?: string[]; +} +export class modal { + constructor(options?: Options); + setContent(content: string | Element): void; + getContent(): HTMLDivElement; + destroy(): void; + open(): void; + isOpen(): boolean; + close(): void; + setFooterContent(content: string): void; + getFooterContent(): HTMLDivElement | undefined; + setStickyFooter(sticky: boolean): void; + addFooterBtn( + label: string, + cssClass: string | undefined, + listener: HTMLElement['onclick'], + ): HTMLButtonElement; + isOverflow(): boolean; + checkOverflow(): void; +} diff --git a/types/tingle.js/tingle.js-tests.ts b/types/tingle.js/tingle.js-tests.ts new file mode 100644 index 0000000000..28c7a08c7e --- /dev/null +++ b/types/tingle.js/tingle.js-tests.ts @@ -0,0 +1,23 @@ +import { modal } from 'tingle.js'; + +let instance = new modal(); +instance.open(); +instance.checkOverflow(); +instance.close(); +instance.close(); + +instance = new modal({ + onOpen() { + this.checkOverflow(); + }, + beforeClose() { + return this.isOverflow(); + }, +}); + +instance.addFooterBtn('text', undefined, function(e) { + e.x; + this.innerText; +}); + +instance.setStickyFooter(false); diff --git a/types/tingle.js/tsconfig.json b/types/tingle.js/tsconfig.json new file mode 100644 index 0000000000..8bca97462f --- /dev/null +++ b/types/tingle.js/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "tingle.js-tests.ts" + ] +} diff --git a/types/tingle.js/tslint.json b/types/tingle.js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/tingle.js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }