mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 07:40:10 +00:00
begin work at v1.0.0-alpha.1
add Sidenav
This commit is contained in:
112
types/materialize-css/index.d.ts
vendored
Normal file
112
types/materialize-css/index.d.ts
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
// Type definitions for materialize-css 1.0
|
||||
// Project: http://materializecss.com/
|
||||
// Definitions by: 胡玮文 <https://github.com/huww98>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
export = M;
|
||||
|
||||
declare global {
|
||||
namespace M {
|
||||
class Sidenav {
|
||||
/**
|
||||
* Construct Sidenav instance and set up overlay
|
||||
*/
|
||||
constructor(elem: Element, options?: Partial<SidenavOptions>);
|
||||
|
||||
/**
|
||||
* Get Instance
|
||||
*/
|
||||
static getInstance(elem: Element): Sidenav;
|
||||
|
||||
/**
|
||||
* Opens Sidenav
|
||||
*/
|
||||
open(): void;
|
||||
|
||||
/**
|
||||
* Closes Sidenav
|
||||
*/
|
||||
close(): void;
|
||||
|
||||
/**
|
||||
* Destroy plugin instance and teardown
|
||||
*/
|
||||
destroy(): void;
|
||||
|
||||
/**
|
||||
* The DOM element the plugin was initialized with
|
||||
*/
|
||||
el: Element;
|
||||
|
||||
/**
|
||||
* The options the instance was initialized with
|
||||
*/
|
||||
options: SidenavOptions;
|
||||
|
||||
/**
|
||||
* Describes open/close state of Sidenav
|
||||
*/
|
||||
isOpen: boolean;
|
||||
|
||||
/**
|
||||
* Describes if sidenav is fixed
|
||||
*/
|
||||
isFixed: boolean;
|
||||
|
||||
/**
|
||||
* Describes if Sidenav is being dragged
|
||||
*/
|
||||
isDragged: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for the Sidenav
|
||||
*/
|
||||
interface SidenavOptions {
|
||||
/**
|
||||
* Side of screen on which Sidenav appears
|
||||
* @default 'left'
|
||||
*/
|
||||
edge: 'left' | 'right';
|
||||
|
||||
/**
|
||||
* Allow swipe gestures to open/close Sidenav
|
||||
* @default true
|
||||
*/
|
||||
draggable: boolean;
|
||||
|
||||
/**
|
||||
* Length in ms of enter transition
|
||||
* @default 250
|
||||
*/
|
||||
inDuration: number;
|
||||
|
||||
/**
|
||||
* Length in ms of exit transition
|
||||
* @default 200
|
||||
*/
|
||||
outDuration: number;
|
||||
|
||||
/**
|
||||
* Function called when sidenav starts entering
|
||||
*/
|
||||
onOpenStart: (instance: Sidenav, elem: Element) => void;
|
||||
|
||||
/**
|
||||
* Function called when sidenav finishes entering
|
||||
*/
|
||||
onOpenEnd: (instance: Sidenav, elem: Element) => void;
|
||||
|
||||
/**
|
||||
* Function called when sidenav starts exiting
|
||||
*/
|
||||
onCloseStart: (instance: Sidenav, elem: Element) => void;
|
||||
|
||||
/**
|
||||
* Function called when sidenav finishes exiting
|
||||
*/
|
||||
onCloseEnd: (instance: Sidenav, elem: Element) => void;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
const elem = document.querySelector('.sidenav')!;
|
||||
// $ExpectType Sidenav
|
||||
const sidenav = new M.Sidenav(elem);
|
||||
21
types/materialize-css/test/materialize-css-module.test.ts
Normal file
21
types/materialize-css/test/materialize-css-module.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as materialize from "materialize-css";
|
||||
|
||||
// Sidenav
|
||||
const elem = document.querySelector('.sidenav')!;
|
||||
// $ExpectType Sidenav
|
||||
const sidenav = new materialize.Sidenav(elem, {
|
||||
edge: "left",
|
||||
inDuration: 300,
|
||||
onCloseStart: () => console.log("closing")
|
||||
});
|
||||
// $ExpectType void
|
||||
sidenav.open();
|
||||
// $ExpectType void
|
||||
sidenav.destroy();
|
||||
|
||||
// $ExpectType SidenavOptions
|
||||
sidenav.options;
|
||||
// $ExpectType Element
|
||||
sidenav.el;
|
||||
// $ExpectType boolean
|
||||
sidenav.isOpen;
|
||||
25
types/materialize-css/tsconfig.json
Normal file
25
types/materialize-css/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
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/materialize-css-global.test.ts",
|
||||
"test/materialize-css-module.test.ts"
|
||||
]
|
||||
}
|
||||
6
types/materialize-css/tslint.json
Normal file
6
types/materialize-css/tslint.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user