mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
[a11y-dialog] Create new definitions (#29509)
* Create d.ts file for a11y-dialog. * Finish up implementation for a11y-dialog. * Construct unit tests for a11y-dialog. * added missing create functions. * tslint successfully passes for a11y-dialog * Split out constructor for best practices * none of the duplicates were getters / setters
This commit is contained in:
30
types/a11y-dialog/a11y-dialog-tests.ts
Normal file
30
types/a11y-dialog/a11y-dialog-tests.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import A11yDialog = require('a11y-dialog');
|
||||
|
||||
const dialogEl = new A11yDialog(document.getElementById("test"));
|
||||
const dialogElTwo = new A11yDialog(document.getElementById("test"), document.getElementById("testContainer"));
|
||||
const dialogElThree = new A11yDialog(document.getElementById("test"), "dummy-element");
|
||||
|
||||
dialogEl.show();
|
||||
dialogEl.hide();
|
||||
dialogElTwo.destroy();
|
||||
dialogElThree.create();
|
||||
|
||||
// Test out interfaces that extends Element.
|
||||
dialogEl.on("show", (el: HTMLElement) => {
|
||||
el.textContent;
|
||||
});
|
||||
|
||||
// Test out element and event.
|
||||
dialogEl.on("create", (el: HTMLElement, evt) => {
|
||||
el.textContent;
|
||||
|
||||
evt.target;
|
||||
});
|
||||
|
||||
dialogEl.on('hide', () => {
|
||||
const t = 5;
|
||||
});
|
||||
|
||||
dialogEl.off("show", (el: HTMLElement) => {
|
||||
el.textContent;
|
||||
});
|
||||
31
types/a11y-dialog/index.d.ts
vendored
Normal file
31
types/a11y-dialog/index.d.ts
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Type definitions for a11y-dialog 5.2
|
||||
// Project: https://github.com/edenspiekermann/a11y-dialog
|
||||
// Definitions by: Yuto <https://github.com/Goyatuzo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
type DialogEvents = "show" | "hide" | "destroy" | "create";
|
||||
declare class A11yDialog {
|
||||
constructor(el: Element | null, containers?: NodeList | Element | string | null);
|
||||
/**
|
||||
* Shows the dialog.
|
||||
*/
|
||||
show(): void;
|
||||
/**
|
||||
* Hides the dialog.
|
||||
*/
|
||||
hide(): void;
|
||||
/**
|
||||
* Unbind click listeners from dialog openers and closers and remove all bound custom event listeners registered with `.on()`
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Bind click listeners to dialog openers and closers.
|
||||
*/
|
||||
create(el?: Element | null, containers?: NodeList | Element | string | null): void;
|
||||
|
||||
on(evt: DialogEvents, callback: (dialogElement: any, event: Event) => void): void;
|
||||
off(evt: DialogEvents, callback: (dialogElement: any, event: Event) => void): void;
|
||||
}
|
||||
|
||||
export = A11yDialog;
|
||||
25
types/a11y-dialog/tsconfig.json
Normal file
25
types/a11y-dialog/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"a11y-dialog-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/a11y-dialog/tslint.json
Normal file
3
types/a11y-dialog/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user