From f851dac2abb999eee9b1d10422ab45b7e5764ea6 Mon Sep 17 00:00:00 2001 From: "VML\\snau" Date: Mon, 18 Dec 2017 14:45:01 -0800 Subject: [PATCH 1/3] **@types/vanilla-modal Creating definitions for "vanilla-modal"** adding all the required files for the new type definition --- types/vanilla-modal/index.d.ts | 50 ++++++++++++++++++++++ types/vanilla-modal/tsconfig.json | 24 +++++++++++ types/vanilla-modal/tslint.json | 1 + types/vanilla-modal/vanilla-modal-tests.ts | 3 ++ 4 files changed, 78 insertions(+) create mode 100644 types/vanilla-modal/index.d.ts create mode 100644 types/vanilla-modal/tsconfig.json create mode 100644 types/vanilla-modal/tslint.json create mode 100644 types/vanilla-modal/vanilla-modal-tests.ts diff --git a/types/vanilla-modal/index.d.ts b/types/vanilla-modal/index.d.ts new file mode 100644 index 0000000000..90775bf7ee --- /dev/null +++ b/types/vanilla-modal/index.d.ts @@ -0,0 +1,50 @@ +// Type definitions for vanilla-modal 1.6 +// Project: https://github.com/benceg/vanilla-modal +// Definitions by: Sam Nau +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface VanillaModalConfig { + modal?: string | HTMLElement; + modalInner?: string; + modalContent?: string; + open?: string; + close?: string; + page?: string; + class?: string; + loadClass?: string; + clickOutside?: boolean; + closeKeys?: [number]; + transitions?: string; + transitionEnd?(): undefined; + onBeforeOpen?(): undefined; + onBeforeClose?(): undefined; + onOpen?(): undefined; + onClose?(): undefined; +} +export interface VanillaModalDomNodes { + modal: HTMLElement; + page: HTMLElement; + modalInner: HTMLElement; + modalContent: HTMLElement; +} + +export default class VanillaModal { + constructor(settings?: VanillaModalConfig); + getDomNodes(): VanillaModalDomNodes; + addLoadedCssClass(): void; + setOpenId(id: string): void; + removeOpenId(): void; + open(allMatches: string, e?: Event): void; + detectTransition(): boolean; + close(e: Event): void; + closeModal(e: Event): void; + closeModalWithTransition(e: Event): void; + captureNode(node: Node): void; + releaseNode(node: Node): void; + closeKeyHandler(e: Event): void; + outsideClickHandler(e: Event): void; + delegateOpen(e: Event): void; + delegateClose(e: Event): void; + listen(): void; + destroy(): void; +} diff --git a/types/vanilla-modal/tsconfig.json b/types/vanilla-modal/tsconfig.json new file mode 100644 index 0000000000..f6d7663c4f --- /dev/null +++ b/types/vanilla-modal/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames" : true + }, + "files": [ + "index.d.ts", + "vanilla-modal-tests.ts" + ] +} diff --git a/types/vanilla-modal/tslint.json b/types/vanilla-modal/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/vanilla-modal/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/vanilla-modal/vanilla-modal-tests.ts b/types/vanilla-modal/vanilla-modal-tests.ts new file mode 100644 index 0000000000..3f75db3cc8 --- /dev/null +++ b/types/vanilla-modal/vanilla-modal-tests.ts @@ -0,0 +1,3 @@ +import VanillaModal from 'vanilla-modal'; + +const modalInstance = new VanillaModal(); From 0c2b75b2cf92e19a18fbeba1984d2c5562ee3f68 Mon Sep 17 00:00:00 2001 From: "VML\\snau" Date: Wed, 20 Dec 2017 12:30:46 -0800 Subject: [PATCH 2/3] updating the test per feedback on the PR --- types/vanilla-modal/vanilla-modal-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/vanilla-modal/vanilla-modal-tests.ts b/types/vanilla-modal/vanilla-modal-tests.ts index 3f75db3cc8..69c98baf3c 100644 --- a/types/vanilla-modal/vanilla-modal-tests.ts +++ b/types/vanilla-modal/vanilla-modal-tests.ts @@ -1,3 +1,4 @@ import VanillaModal from 'vanilla-modal'; const modalInstance = new VanillaModal(); +modalInstance.open('#foo'); From 012e232dea28b23db2c346d252913274c69c6d87 Mon Sep 17 00:00:00 2001 From: "VML\\snau" Date: Thu, 21 Dec 2017 08:56:19 -0800 Subject: [PATCH 3/3] updated the `event` parameter to be optional on the `close` method, just like it is on the `open` method --- types/vanilla-modal/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vanilla-modal/index.d.ts b/types/vanilla-modal/index.d.ts index 90775bf7ee..6c15609ce2 100644 --- a/types/vanilla-modal/index.d.ts +++ b/types/vanilla-modal/index.d.ts @@ -36,7 +36,7 @@ export default class VanillaModal { removeOpenId(): void; open(allMatches: string, e?: Event): void; detectTransition(): boolean; - close(e: Event): void; + close(e?: Event): void; closeModal(e: Event): void; closeModalWithTransition(e: Event): void; captureNode(node: Node): void;