From 490c4210d68c8bb0b271b39695eec76016cebbf4 Mon Sep 17 00:00:00 2001 From: Philipp Shestakov Date: Fri, 20 Oct 2017 17:25:57 +0300 Subject: [PATCH] Added definitions for clusterize.js (#20738) * Added definitions for clusterize.js * Fixed definitions author. * Review fixes. * Review fix. --- types/clusterize.js/clusterize.js-tests.ts | 20 +++++++++++ types/clusterize.js/index.d.ts | 41 ++++++++++++++++++++++ types/clusterize.js/tsconfig.json | 23 ++++++++++++ types/clusterize.js/tslint.json | 1 + 4 files changed, 85 insertions(+) create mode 100644 types/clusterize.js/clusterize.js-tests.ts create mode 100644 types/clusterize.js/index.d.ts create mode 100644 types/clusterize.js/tsconfig.json create mode 100644 types/clusterize.js/tslint.json diff --git a/types/clusterize.js/clusterize.js-tests.ts b/types/clusterize.js/clusterize.js-tests.ts new file mode 100644 index 0000000000..acbfbc36f8 --- /dev/null +++ b/types/clusterize.js/clusterize.js-tests.ts @@ -0,0 +1,20 @@ +import Clusterize = require('clusterize.js'); + +const options: Clusterize.Options = { contentId: '', scrollId: '' }; +const clusterize = new Clusterize(options); + +clusterize.append(['
  • ']); + +clusterize.prepend(['
  • ']); + +clusterize.getRowsAmount(); + +clusterize.update(['
  • ']); + +clusterize.getScrollProgress(); + +clusterize.refresh(); + +clusterize.clear(); + +clusterize.destroy(); diff --git a/types/clusterize.js/index.d.ts b/types/clusterize.js/index.d.ts new file mode 100644 index 0000000000..7c549761d6 --- /dev/null +++ b/types/clusterize.js/index.d.ts @@ -0,0 +1,41 @@ +// Type definitions for clusterize.js 0.17 +// Project: https://github.com/NeXTs/Clusterize.js +// Definitions by: Pr1st0n +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare class Clusterize { + constructor(options: Clusterize.Options); + + destroy(clean?: boolean): void; + refresh(force?: boolean): void; + clear(): void; + getRowsAmount(): number; + getScrollProgress(): number; + update(data?: string[]): void; + append(rows: string[]): void; + prepend(rows: string[]): void; +} + +declare namespace Clusterize { + interface Options { + scrollId: string; + contentId: string; + rows?: string[]; + tag?: string; + rows_in_block?: number; + blocks_in_cluster?: number; + show_no_data_row?: boolean; + no_data_text?: string; + no_data_class?: string; + keep_parity?: boolean; + callbacks?: Callbacks; + } + + interface Callbacks { + clusterWillChange?(cb: () => void): void; + clusterChanged?(cb: () => void): void; + scrollingProgress?(cb: (progress: number) => void): void; + } +} + +export = Clusterize; diff --git a/types/clusterize.js/tsconfig.json b/types/clusterize.js/tsconfig.json new file mode 100644 index 0000000000..10ca5c2a1a --- /dev/null +++ b/types/clusterize.js/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clusterize.js-tests.ts" + ] +} diff --git a/types/clusterize.js/tslint.json b/types/clusterize.js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/clusterize.js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }