mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
[Simplebar] Add typing for v5 (#42654)
* move old typings in v2 * add new typings * fix linter errors * move tests under v2 * add more classes * revert original comments in v2
This commit is contained in:
committed by
GitHub
parent
9d29adedf6
commit
9af68d8d95
31
types/simplebar/index.d.ts
vendored
31
types/simplebar/index.d.ts
vendored
@@ -1,14 +1,15 @@
|
||||
// Type definitions for simplebar.js 2.4
|
||||
// Type definitions for simplebar.js 5.1
|
||||
// Project: https://github.com/Grsmto/simplebar, https://grsmto.github.io/simplebar
|
||||
// Definitions by: Gregor Woiwode <https://github.com/gregonnet>, Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Definitions by: Valikhan Akhmedov <https://github.com/val-o>, Gregor Woiwode <https://github.com/gregonnet>, Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export as namespace SimpleBar;
|
||||
export = SimpleBar;
|
||||
|
||||
declare class SimpleBar {
|
||||
static removeObserver(): void;
|
||||
static instances: Pick<WeakMap<HTMLElement, SimpleBar>, 'get' | 'has'>;
|
||||
|
||||
constructor(element: HTMLElement, options?: SimpleBar.Options);
|
||||
|
||||
@@ -19,16 +20,32 @@ declare class SimpleBar {
|
||||
|
||||
declare namespace SimpleBar {
|
||||
interface Options {
|
||||
wrapContent?: boolean;
|
||||
autoHide?: boolean;
|
||||
scrollbarMinSize?: number;
|
||||
classNames?: ClassNamesOptions;
|
||||
forceVisible?: boolean | 'x' | 'y';
|
||||
direction?: 'rtl' | 'ltr';
|
||||
timeout?: number;
|
||||
clickOnTrack?: boolean;
|
||||
scrollbarMinSize?: number;
|
||||
scrollbarMaxSize?: number;
|
||||
}
|
||||
|
||||
interface ClassNamesOptions {
|
||||
content?: string;
|
||||
scrollContent?: string;
|
||||
contentEl?: string;
|
||||
contentWrapper?: string;
|
||||
offset?: string;
|
||||
mask?: string;
|
||||
wrapper?: string;
|
||||
placeholder?: string;
|
||||
scrollbar?: string;
|
||||
track?: string;
|
||||
heightAutoObserverWrapperEl?: string;
|
||||
heightAutoObserverEl?: string;
|
||||
visible?: string;
|
||||
horizontal?: string;
|
||||
vertical?: string;
|
||||
hover?: string;
|
||||
dragging?: string;
|
||||
[className: string]: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
function test_start() {
|
||||
function test_constructorWithoutOpts() {
|
||||
new SimpleBar(document.getElementById('myElement'));
|
||||
}
|
||||
|
||||
function test_options_wrapContent() {
|
||||
new SimpleBar(document.getElementById('myElement'), { wrapContent: false });
|
||||
}
|
||||
|
||||
function test_options_autoHide() {
|
||||
new SimpleBar(document.getElementById('myElement'), { autoHide: false });
|
||||
}
|
||||
|
||||
function test_options_scrollbarMinSize() {
|
||||
new SimpleBar(document.getElementById('myElement'), { scrollbarMinSize: 10 });
|
||||
function test_constructor() {
|
||||
new SimpleBar(document.getElementById('myElement'), {
|
||||
autoHide: true,
|
||||
clickOnTrack: true,
|
||||
direction: 'ltr',
|
||||
forceVisible: 'x',
|
||||
scrollbarMaxSize: 20,
|
||||
scrollbarMinSize: 10,
|
||||
timeout: 300,
|
||||
});
|
||||
}
|
||||
|
||||
function test_options_classNames() {
|
||||
@@ -21,31 +21,19 @@ function test_options_classNames() {
|
||||
content: 'simplebar-content',
|
||||
scrollContent: 'simplebar-scroll-content',
|
||||
scrollbar: 'simplebar-scrollbar',
|
||||
track: 'simplebar-track'
|
||||
}
|
||||
track: 'simplebar-track',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function test_recalculate() {
|
||||
function test_instanceFunctions() {
|
||||
const el = new SimpleBar(document.getElementById('myElement'));
|
||||
el.recalculate();
|
||||
const contentEl: Element = el.getContentElement();
|
||||
const scrollEl: Element = el.getScrollElement();
|
||||
}
|
||||
|
||||
function test_getScrollElement() {
|
||||
const el = new SimpleBar(document.getElementById('myElement'));
|
||||
el.getScrollElement();
|
||||
}
|
||||
|
||||
function test_scrollEvent() {
|
||||
const el = new SimpleBar(document.getElementById('myElement'));
|
||||
el.getScrollElement().addEventListener('scroll', () => { });
|
||||
}
|
||||
|
||||
function test_getContentElement() {
|
||||
const el = new SimpleBar(document.getElementById('myElement'));
|
||||
el.getContentElement();
|
||||
}
|
||||
|
||||
function test_removeObserver() {
|
||||
function test_staticFunctions() {
|
||||
SimpleBar.removeObserver();
|
||||
SimpleBar.instances.get(new HTMLDivElement());
|
||||
}
|
||||
|
||||
34
types/simplebar/v2/index.d.ts
vendored
Normal file
34
types/simplebar/v2/index.d.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Type definitions for simplebar.js 2.4
|
||||
// Project: https://github.com/Grsmto/simplebar, https://grsmto.github.io/simplebar
|
||||
// Definitions by: Gregor Woiwode <https://github.com/gregonnet>, Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export as namespace SimpleBar;
|
||||
export = SimpleBar;
|
||||
|
||||
declare class SimpleBar {
|
||||
static removeObserver(): void;
|
||||
|
||||
constructor(element: HTMLElement, options?: SimpleBar.Options);
|
||||
|
||||
recalculate(): void;
|
||||
getScrollElement(): Element;
|
||||
getContentElement(): Element;
|
||||
}
|
||||
|
||||
declare namespace SimpleBar {
|
||||
interface Options {
|
||||
wrapContent?: boolean;
|
||||
autoHide?: boolean;
|
||||
scrollbarMinSize?: number;
|
||||
classNames?: ClassNamesOptions;
|
||||
}
|
||||
|
||||
interface ClassNamesOptions {
|
||||
content?: string;
|
||||
scrollContent?: string;
|
||||
scrollbar?: string;
|
||||
track?: string;
|
||||
}
|
||||
}
|
||||
51
types/simplebar/v2/simplebar-tests.ts
Normal file
51
types/simplebar/v2/simplebar-tests.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
function test_start() {
|
||||
new SimpleBar(document.getElementById('myElement'));
|
||||
}
|
||||
|
||||
function test_options_wrapContent() {
|
||||
new SimpleBar(document.getElementById('myElement'), { wrapContent: false });
|
||||
}
|
||||
|
||||
function test_options_autoHide() {
|
||||
new SimpleBar(document.getElementById('myElement'), { autoHide: false });
|
||||
}
|
||||
|
||||
function test_options_scrollbarMinSize() {
|
||||
new SimpleBar(document.getElementById('myElement'), { scrollbarMinSize: 10 });
|
||||
}
|
||||
|
||||
function test_options_classNames() {
|
||||
new SimpleBar(document.getElementById('myElement'), {
|
||||
classNames: {
|
||||
// defaults
|
||||
content: 'simplebar-content',
|
||||
scrollContent: 'simplebar-scroll-content',
|
||||
scrollbar: 'simplebar-scrollbar',
|
||||
track: 'simplebar-track'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function test_recalculate() {
|
||||
const el = new SimpleBar(document.getElementById('myElement'));
|
||||
el.recalculate();
|
||||
}
|
||||
|
||||
function test_getScrollElement() {
|
||||
const el = new SimpleBar(document.getElementById('myElement'));
|
||||
el.getScrollElement();
|
||||
}
|
||||
|
||||
function test_scrollEvent() {
|
||||
const el = new SimpleBar(document.getElementById('myElement'));
|
||||
el.getScrollElement().addEventListener('scroll', () => { });
|
||||
}
|
||||
|
||||
function test_getContentElement() {
|
||||
const el = new SimpleBar(document.getElementById('myElement'));
|
||||
el.getContentElement();
|
||||
}
|
||||
|
||||
function test_removeObserver() {
|
||||
SimpleBar.removeObserver();
|
||||
}
|
||||
4
types/simplebar/v2/test/module-tests.ts
Normal file
4
types/simplebar/v2/test/module-tests.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import SimpleBar = require('simplebar');
|
||||
|
||||
// $ExpectType typeof SimpleBar
|
||||
SimpleBar;
|
||||
30
types/simplebar/v2/tsconfig.json
Normal file
30
types/simplebar/v2/tsconfig.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"simplebar": [
|
||||
"simplebar/v2"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"simplebar-tests.ts",
|
||||
"test/module-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/simplebar/v2/tslint.json
Normal file
3
types/simplebar/v2/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user